MDL-32981 Filepicker: my private files uses edit page instead of view
authorFrederic Massart <fred@moodle.com>
Mon, 21 May 2012 05:00:31 +0000 (13:00 +0800)
committerFrederic Massart <fred@moodle.com>
Tue, 22 May 2012 02:56:11 +0000 (10:56 +0800)
lib/navigationlib.php
user/filesedit.php
user/filesedit_form.php

index 707ea92..9710c66 100644 (file)
@@ -2305,7 +2305,7 @@ class global_navigation extends navigation_node {
 
         $context = get_context_instance(CONTEXT_USER, $USER->id);
         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);
         }
 
index ab34eef..2438f73 100644 (file)
@@ -33,13 +33,11 @@ if (isguestuser()) {
 }
 
 $returnurl = optional_param('returnurl', '', PARAM_URL);
+$returnbutton = true;
 
 if (empty($returnurl)) {
-    if (!empty($_SERVER["HTTP_REFERER"])) {
-        $returnurl = $_SERVER["HTTP_REFERER"];
-    } else {
-        $returnurl = new moodle_url('/user/files.php');
-    }
+    $returnbutton = false;
+    $returnurl = new moodle_url('/user/filesedit.php');
 }
 
 $context = get_context_instance(CONTEXT_USER, $USER->id);
@@ -48,7 +46,7 @@ require_capability('moodle/user:manageownfiles', $context);
 $title = get_string('myfiles');
 $struser = get_string('user');
 
-$PAGE->set_url('/user/files.php');
+$PAGE->set_url('/user/filesedit.php');
 $PAGE->set_context($context);
 $PAGE->set_title($title);
 $PAGE->set_heading($title);
@@ -60,7 +58,7 @@ $data->returnurl = $returnurl;
 $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);
 
-$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()) {
     redirect($returnurl);
index 4fd1e6f..13cc041 100644 (file)
@@ -31,13 +31,14 @@ class user_filesedit_form extends moodleform {
     function definition() {
         $mform = $this->_form;
 
-        $data    = $this->_customdata['data'];
-        $options = $this->_customdata['options'];
+        $data           = $this->_customdata['data'];
+        $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('hidden', 'returnurl', $data->returnurl);
 
-        $this->add_action_buttons(true, get_string('savechanges'));
+        $this->add_action_buttons($cancelbutton, get_string('savechanges'));
 
         $this->set_data($data);
     }