]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-13766
authordongsheng <dongsheng>
Wed, 20 Aug 2008 04:24:38 +0000 (04:24 +0000)
committerdongsheng <dongsheng>
Wed, 20 Aug 2008 04:24:38 +0000 (04:24 +0000)
improve action parameter, add comments for local plugin

repository/boxnet/repository.class.php
repository/flickr/repository.class.php
repository/lib.php
repository/local/repository.class.php
repository/ws.php

index 91cc6709ce91f861a52ff7e2229320527d9ac209..032f7c540b8c3a5aa7dfc8115bf8e78cdf2f4856 100755 (executable)
@@ -41,6 +41,11 @@ class repository_boxnet extends repository{
             } catch (repository_exception $e) {
                 throw $e;
             }
+            if ($SESSION->$sess_name) {
+                $action = 'list';
+            } else {
+                $action = 'login';
+            }
         }
         // already logged
         if(!empty($SESSION->$sess_name)) {
@@ -53,9 +58,8 @@ class repository_boxnet extends repository{
             }
         } else {
             $this->box = new boxclient($this->api_key);
-            if(!empty($action)) {
-                $action = '';
-            }
+            // print login
+            $action = 'login';
         }
     }
 
index 6e424bbfaa294b7278ba787594860318b822d993..c698917adc4fa60804ad2bbf439af79a593a75b1 100755 (executable)
@@ -47,8 +47,10 @@ class repository_flickr extends repository{
                         set_user_preference('flickrmail'.$this->id, $account);
                     }
                     $SESSION->$sess_name = $account;
-                    if(empty($action)) {
+                    if (empty($account)) {
                         $action = 'list';
+                    } else {
+                        $action = 'login';
                     }
                 } else {
                     throw new repository_exception('invalidemail', 'repository_flickr');
@@ -59,6 +61,8 @@ class repository_flickr extends repository{
                     if(empty($action)) {
                         $action = 'list';
                     }
+                } else {
+                    $action = 'login';
                 }
             }
         }
index 9a48e7e84d10ec6950765178881f752689b4b41d..0af9b7472dc71f497ccb8789abd1ee789d0fb536 100644 (file)
@@ -849,6 +849,11 @@ EOD;
             if(node.children){
                 tmpNode.isLeaf = false;
                 tmpNode.subfolder = node.children;
+                if (node.path) {
+                    tmpNode.path = node.path;
+                } else {
+                    tmpNode.path = '';
+                }
                 for(var c in node.children){
                     _client.buildtree(node.children[c], tmpNode);
                 }
@@ -883,7 +888,7 @@ _client.dynload = function (node, fnLoadComplete){
     // TODO: need to include filepath here
     var trans = YAHOO.util.Connect.asyncRequest('GET', 
         '$CFG->wwwroot/repository/ws.php?ctx_id=$context->id&repo_id='
-            +_client.repositoryid+'&action=list', 
+            +_client.repositoryid+'&p='+node.path+'&action=list', 
         callback);
 }
         _client.viewlist = function(){
@@ -983,7 +988,7 @@ _client.dynload = function (node, fnLoadComplete){
             params['ctx_id'] = $context->id;
             _client.loading();
             var trans = YAHOO.util.Connect.asyncRequest('POST', 
-                '$CFG->wwwroot/repository/ws.php', _client.callback,
+                '$CFG->wwwroot/repository/ws.php?action=sign', _client.callback,
                 _client.postdata(params));
         }
         _client.end = function(str){
@@ -1045,7 +1050,7 @@ _client.dynload = function (node, fnLoadComplete){
             _client.viewbar.set('disabled', false);
             _client.loading();
             _client.repositoryid = id;
-            var trans = YAHOO.util.Connect.asyncRequest('GET', '$CFG->wwwroot/repository/ws.php?ctx_id=$context->id&repo_id='+id+'&p='+path+'&reset='+reset+'&env='+_client.env, _client.callback);
+            var trans = YAHOO.util.Connect.asyncRequest('GET', '$CFG->wwwroot/repository/ws.php?action=list&ctx_id=$context->id&repo_id='+id+'&p='+path+'&reset='+reset+'&env='+_client.env, _client.callback);
         }
         _client.search = function(id){
             var data = window.prompt("$strsearching");
@@ -1055,7 +1060,7 @@ _client.dynload = function (node, fnLoadComplete){
             }
             _client.viewbar.set('disabled', false);
             _client.loading();
-            var trans = YAHOO.util.Connect.asyncRequest('GET', '$CFG->wwwroot/repository/ws.php?ctx_id=$context->id&repo_id='+id+'&s='+data+'&env='+_client.env, _client.callback);
+            var trans = YAHOO.util.Connect.asyncRequest('GET', '$CFG->wwwroot/repository/ws.php?action=search&ctx_id=$context->id&repo_id='+id+'&s='+data+'&env='+_client.env, _client.callback);
         }
         return _client;
     })();
index 9b269aa5592483c799b79607cdef583f262ea509..82e9b7b9ba9f13127d22fbf5811eb87967eb3814 100755 (executable)
@@ -12,26 +12,38 @@ class repository_local extends repository{
     public function __construct($repositoryid, $context = SITEID, $options = array()){
         global $SESSION, $action, $CFG;
         parent::__construct($repositoryid, $context, $options);
+        // TODO:
         // get the parameter from client side
         // $this->context can be used here.
+        // When user upload a file, $action == 'upload'
+        // You can use $_FILES to find that file
     }
 
     public function print_login($ajax = true){
         global $SESSION;
         // TODO
         // Return file list in moodle
-        // Also, this plugin should have ability to
-        // upload files in user's computer, a iframe
-        // need to be created. 
         return $this->get_listing();
     }
     public function get_listing($path = '/', $search = ''){
         global $SESSION;
         $ret = new stdclass;
+
+        // this statement tells file picker to load files dramanically.
         $ret->dynload = true;
+
+        // defina upload form in file picker
+        // Use ajax upload file
         $ret->upload = array('name'=>get_string('attachment: '), 'id'=>'repo-form');
         $ret->list  = array();
-        // call file api get the list of the file
+
+        // TODO: set path and file area for folders, for example
+        //
+        // $ret->list[] = array('title'=>'folder1', 'size'=>0, 
+        //          'date'=>'', 'path'=>'/', 'file_area'=>'course_files');
+        //
+        // call FILE API get the list of the file
+        //
         $ret->list[] = array('title'=>'title','source'=>'download url', 'thumbnail'=>'url of thumbnail', 'date'=>'', 'size'=>'unknown');
         if(empty($ret)) {
             throw new repository_exception('emptyfilelist', 'repository_local');
index de364f4ad1f4f5d91cd1417a8cc7307d645ea64c..a1b8b9132a2e1443f44764d67d921a54f5c7373d 100644 (file)
@@ -50,7 +50,7 @@ if(file_exists($CFG->dirroot.'/repository/'.
     die(json_encode($err));
 }
 
-if($action == 'list') {
+if ($action == 'list' || $action == 'search') {
     try {
         if(!empty($p)) {
             echo json_encode($repo->get_listing($p));
@@ -85,7 +85,7 @@ if($action == 'list') {
         $err->e = $e->getMessage();
         die(json_encode($err));
     }
-} else {
+} elseif ($action == 'login') {
     try {
         echo json_encode($repo->print_login());
     } catch (repository_exception $e){