Skip to content

Commit

Permalink
MDL-32981 Filepicker: my private files uses edit page instead of view
Browse files Browse the repository at this point in the history
  • Loading branch information
Frederic Massart committed May 22, 2012
1 parent 7d3704f commit 0c9fb0c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lib/navigationlib.php
Expand Up @@ -2018,7 +2018,7 @@ protected function load_for_user($user=null, $forceforcontext=false) {


$context = get_context_instance(CONTEXT_USER, $USER->id); $context = get_context_instance(CONTEXT_USER, $USER->id);
if ($iscurrentuser && has_capability('moodle/user:manageownfiles', $context)) { if ($iscurrentuser && has_capability('moodle/user:manageownfiles', $context)) {
$url = new moodle_url('/user/files.php'); $url = new moodle_url('/user/filesedit.php');
$usernode->add(get_string('myfiles'), $url, self::TYPE_SETTING); $usernode->add(get_string('myfiles'), $url, self::TYPE_SETTING);
} }


Expand Down
12 changes: 5 additions & 7 deletions user/filesedit.php
Expand Up @@ -33,13 +33,11 @@
} }


$returnurl = optional_param('returnurl', '', PARAM_URL); $returnurl = optional_param('returnurl', '', PARAM_URL);
$returnbutton = true;


if (empty($returnurl)) { if (empty($returnurl)) {
if (!empty($_SERVER["HTTP_REFERER"])) { $returnbutton = false;
$returnurl = $_SERVER["HTTP_REFERER"]; $returnurl = new moodle_url('/user/filesedit.php');
} else {
$returnurl = new moodle_url('/user/files.php');
}
} }


$context = get_context_instance(CONTEXT_USER, $USER->id); $context = get_context_instance(CONTEXT_USER, $USER->id);
Expand All @@ -48,7 +46,7 @@
$title = get_string('myfiles'); $title = get_string('myfiles');
$struser = get_string('user'); $struser = get_string('user');


$PAGE->set_url('/user/files.php'); $PAGE->set_url('/user/filesedit.php');
$PAGE->set_context($context); $PAGE->set_context($context);
$PAGE->set_title($title); $PAGE->set_title($title);
$PAGE->set_heading($title); $PAGE->set_heading($title);
Expand All @@ -60,7 +58,7 @@
$options = array('subdirs'=>1, 'maxbytes'=>$CFG->userquota, 'maxfiles'=>-1, 'accepted_types'=>'*', 'return_types'=>FILE_INTERNAL); $options = array('subdirs'=>1, 'maxbytes'=>$CFG->userquota, 'maxfiles'=>-1, 'accepted_types'=>'*', 'return_types'=>FILE_INTERNAL);
file_prepare_standard_filemanager($data, 'files', $options, $context, 'user', 'private', 0); file_prepare_standard_filemanager($data, 'files', $options, $context, 'user', 'private', 0);


$mform = new user_filesedit_form(null, array('data'=>$data, 'options'=>$options)); $mform = new user_filesedit_form(null, array('data'=>$data, 'options'=>$options, 'cancelbutton'=>$returnbutton));


if ($mform->is_cancelled()) { if ($mform->is_cancelled()) {
redirect($returnurl); redirect($returnurl);
Expand Down
7 changes: 4 additions & 3 deletions user/filesedit_form.php
Expand Up @@ -31,13 +31,14 @@ class user_filesedit_form extends moodleform {
function definition() { function definition() {
$mform = $this->_form; $mform = $this->_form;


$data = $this->_customdata['data']; $data = $this->_customdata['data'];
$options = $this->_customdata['options']; $options = $this->_customdata['options'];
$cancelbutton = isset($this->_customdata['cancelbutton']) ? $this->_customdata['cancelbutton'] : true;


$mform->addElement('filemanager', 'files_filemanager', get_string('files'), null, $options); $mform->addElement('filemanager', 'files_filemanager', get_string('files'), null, $options);
$mform->addElement('hidden', 'returnurl', $data->returnurl); $mform->addElement('hidden', 'returnurl', $data->returnurl);


$this->add_action_buttons(true, get_string('savechanges')); $this->add_action_buttons($cancelbutton, get_string('savechanges'));


$this->set_data($data); $this->set_data($data);
} }
Expand Down

0 comments on commit 0c9fb0c

Please sign in to comment.