]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-13766
authordongsheng <dongsheng>
Tue, 2 Sep 2008 04:05:11 +0000 (04:05 +0000)
committerdongsheng <dongsheng>
Tue, 2 Sep 2008 04:05:11 +0000 (04:05 +0000)
1. Remove search link in upload plugin
2. add get_name function

lang/en_utf8/repository_upload.php [new file with mode: 0644]
repository/lib.php
repository/local/repository.class.php
repository/upload/repository.class.php

diff --git a/lang/en_utf8/repository_upload.php b/lang/en_utf8/repository_upload.php
new file mode 100644 (file)
index 0000000..2c8456d
--- /dev/null
@@ -0,0 +1,4 @@
+<?php // $Id$
+$string['configplugin'] = 'Configuration for upload plugin';
+$string['repositoryname'] = 'Upload a file';
+$string['repositorydesc'] = 'Upload a file to Moodle';
index 1b265221c05e8196d691ca330766fe8097dd5ac4..5f3f1f1c4c149760c570061dcbfcd73c85b011d2 100644 (file)
@@ -80,6 +80,7 @@ abstract class repository {
         foreach ($options as $n => $v) {
             $this->options[$n] = $v;
         }
+        $this->name = $this->get_name();
     }
 
     /**
@@ -188,6 +189,22 @@ abstract class repository {
             return $str;
         }
     }
+    public function get_name(){
+        global $DB;
+        // We always verify instance id from database,
+        // so we always know repository name before init
+        // a repository, so we don't enquery repository
+        // name from database again here.
+        if (isset($this->options['name'])) {
+            return $this->options['name'];
+        } else {
+            if ( $repo = $DB->get_record('repository_instances', array('id'=>$this->id)) ) {
+                return $repo->name;
+            } else {
+                return '';
+            }
+        }
+    }
 
     /**
      * Provide repository instance information for Ajax
@@ -198,7 +215,7 @@ abstract class repository {
         global $CFG;
         $repo = new stdclass;
         $repo->id   = $this->id;
-        $repo->name = $this->options['name'];
+        $repo->name = $this->get_name();
         $repo->type = $this->options['type'];
         $repo->icon = $CFG->wwwroot.'/repository/'.$repo->type.'/icon.png';
         return $repo;
@@ -386,6 +403,7 @@ abstract class repository {
      *   'dynload' => (bool) use dynamic loading,
      *   'manage' => (string) link to file manager,
      *   'nologin' => (bool) requires login,
+     *   'nosearch' => (bool) no search link,
      *   'upload' => array( // upload manager
      *     'name' => (string) label of the form element,
      *     'id' => (string) id of the form element
@@ -1300,7 +1318,9 @@ _client.callback = {
                 mgr.id = 'repo-mgr-$suffix-'+_client.repositoryid;
                 mgr.target = "_blank";
             }
-            oDiv.appendChild(search);
+            if(_client.ds.nosearch != true){
+                oDiv.appendChild(search);
+            }
             if(mgr != null) {
                 oDiv.appendChild(mgr);
             }
index 8164ca9b44e4ae71b8de376f228704a436fb5e61..58891e3ad7e4e37e3b57a628bd6d1eba9824bdf3 100755 (executable)
@@ -176,5 +176,8 @@ class repository_local extends repository {
     // empty function is necessary to make it possible to edit the name of the repository
     public function admin_config_form(&$mform) {
     }
+    public function get_name(){
+        return get_string('repositoryname', 'repository_local');;
+    }
 }
 ?>
index c09f3b2c9a856b00cde1bd4f69f8394653c337f3..ae61b90527a63b2d0656d8116923092ca5146398 100755 (executable)
@@ -28,7 +28,8 @@ class repository_upload extends repository {
             return $this->info;
         }else{
             $ret = array();
-            $ret['nologin'] = true;
+            $ret['nologin']  = true;
+            $ret['nosearch'] = 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
@@ -56,5 +57,8 @@ class repository_upload extends repository {
     // empty function is necessary to make it possible to edit the name of the repository
     public function admin_config_form(&$mform) {
     }
+    public function get_name(){
+        return get_string('repositoryname', 'repository_upload');;
+    }
 }
 ?>