]> git.mjollnir.org Git - moodle.git/commitdiff
"MDL-13766, upload plugin"
authordongsheng <dongsheng>
Mon, 1 Sep 2008 08:21:39 +0000 (08:21 +0000)
committerdongsheng <dongsheng>
Mon, 1 Sep 2008 08:21:39 +0000 (08:21 +0000)
repository/local/repository.class.php
repository/upload/icon.png [new file with mode: 0755]
repository/upload/repository.class.php [new file with mode: 0755]

index bc16ec0fb8a87c54e22985d9a90768281d29a0f1..8164ca9b44e4ae71b8de376f228704a436fb5e61 100755 (executable)
@@ -46,9 +46,6 @@ class repository_local extends repository {
 
         // no login required
         $ret['nologin'] = true;
-        // define upload form in file picker
-        // Use ajax upload file
-        $ret['upload'] = array('name'=>get_string('attachment', 'repository'), 'id'=>'repo-form');
         // todo: link to file manager  
         $ret['manage'] = $CFG->wwwroot .'/files/index.php'; // temporary
        
diff --git a/repository/upload/icon.png b/repository/upload/icon.png
new file mode 100755 (executable)
index 0000000..db5c52b
Binary files /dev/null and b/repository/upload/icon.png differ
diff --git a/repository/upload/repository.class.php b/repository/upload/repository.class.php
new file mode 100755 (executable)
index 0000000..c09f3b2
--- /dev/null
@@ -0,0 +1,60 @@
+<?php
+/**
+ * repository_upload class
+ * A subclass of repository, which is used to upload file
+ *
+ * @version $Id$
+ * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
+ */
+
+class repository_upload extends repository {
+
+    public function __construct($repositoryid, $context = SITEID, $options = array()){
+        global $SESSION, $action, $CFG;
+        parent::__construct($repositoryid, $context, $options);
+        if($action=='upload'){
+            $this->info = repository_store_to_filepool('repo_upload_file');
+        }
+    }
+
+    public function print_login($ajax = true) {
+        global $SESSION;
+        return $this->get_listing();
+    }
+
+    public function get_listing($path='', $search='') {
+        global $CFG, $action;
+        if($action=='upload'){
+            return $this->info;
+        }else{
+            $ret = array();
+            $ret['nologin'] = true;
+            // define upload form in file picker
+            $ret['upload'] = array('label'=>get_string('attachment', 'repository'), 'id'=>'repo-form');
+            $ret['manage'] = $CFG->wwwroot .'/files/index.php'; // temporary
+            $ret['list'] = array();
+            $ret['dynload'] = false;
+            return $ret;
+        }
+    }
+
+    public function print_listing() {
+    }
+
+    public function print_search() {
+        return true;
+    }
+
+    public static function has_admin_config() {
+        return true;
+    }
+
+    public static function get_option_names() {
+        return array();
+    }
+
+    // empty function is necessary to make it possible to edit the name of the repository
+    public function admin_config_form(&$mform) {
+    }
+}
+?>