"MDL-13766, fixed popup authentication"
authorDongsheng Cai <unoter@gmail.com>
Mon, 15 Mar 2010 05:19:43 +0000 (05:19 +0000)
committerDongsheng Cai <unoter@gmail.com>
Mon, 15 Mar 2010 05:19:43 +0000 (05:19 +0000)
repository/filepicker.js
repository/repository_ajax.php

index fc84df9..b642a26 100644 (file)
@@ -44,6 +44,7 @@ M.core_filepicker = M.core_filepicker || {};
  * instances of file pickers used on page
  */
 M.core_filepicker.instances = M.core_filepicker.instances || {};
+M.core_filepicker.active_filepicker = null;
 
 /**
  * Init and show file picker
@@ -94,6 +95,7 @@ M.core_filepicker.init = function(Y, options) {
             params['accepted_types']=this.options.accepted_types;
             params['sesskey']=M.cfg.sesskey;
             params['client_id'] = args.client_id;
+            params['filearea'] = this.options.filearea?this.options.filearea:'user_draft';
             params['itemid'] = this.options.itemid?this.options.itemid:0;
             params['maxbytes'] = this.options.maxbytes?this.options.maxbytes:-1;
             if (args['params']) {
@@ -705,9 +707,10 @@ M.core_filepicker.init = function(Y, options) {
             }
             var popup_button = Y.one('#'+popup_button_id);
             if (popup_button) {
-                popup_button.on('click', function(){
-                    window.open(loginurl, 'repo_auth', 'location=0,status=0,scrollbars=0,width=500,height=300');
-                    active_filepicker = this;
+                popup_button.on('click', function(e){
+                    M.core_filepicker.active_filepicker = this;
+                    window.open(loginurl, 'repo_auth', 'location=0,status=0,width=500,height=300');
+                    e.preventDefault(); 
                 }, this);
             }
             var elform = Y.one('#'+form_id);
index df143c0..b0d6094 100755 (executable)
     $contextid = optional_param('ctx_id', SITEID, PARAM_INT);       // context ID
     $env       = optional_param('env', 'filepicker', PARAM_ALPHA);  // opened in editor or moodleform
     $file      = optional_param('file', '', PARAM_RAW);             // file to download
-    $itemid    = optional_param('itemid', '', PARAM_INT);
+    $itemid    = optional_param('itemid', 0, PARAM_INT);
     $title     = optional_param('title', '', PARAM_FILE);           // new file name
     $page      = optional_param('page', '', PARAM_RAW);             // page
     $maxbytes  = optional_param('maxbytes', -1, PARAM_INT);           // repository ID
     $req_path  = optional_param('p', '', PARAM_RAW);                // path
     $save_path = optional_param('savepath', '/', PARAM_PATH);
+    $save_filearea = optional_param('filearea', 'user_draft', PARAM_TEXT);
     $search_text   = optional_param('s', '', PARAM_CLEANHTML);
     $linkexternal = optional_param('linkexternal', '', PARAM_ALPHA);
 
 <html><head>
 <script type="text/javascript">
 if(window.opener){
-    M.core_filepicker.active.list();
+    window.opener.M.core_filepicker.active_filepicker.list();
     window.close();
 } else {
     alert("{$strhttpsbug }");
@@ -255,7 +256,7 @@ EOD;
                 if (($maxbytes!==-1) && (filesize($filepath) > $maxbytes)) {
                     throw new file_exception('maxbytes');
                 }
-                $info = repository::move_to_filepool($filepath, $title, $itemid, $save_path);
+                $info = repository::move_to_filepool($filepath, $title, $itemid, $save_path, $save_filearea);
                 if (empty($info)) {
                     $info['e'] = get_string('error', 'moodle');
                 }