Skip to content

Commit

Permalink
MDL-13766
Browse files Browse the repository at this point in the history
1. Remove search link in upload plugin
2. add get_name function
  • Loading branch information
dongsheng committed Sep 2, 2008
1 parent 99bd2ec commit d31af46
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 3 deletions.
4 changes: 4 additions & 0 deletions lang/en_utf8/repository_upload.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php // $Id$
$string['configplugin'] = 'Configuration for upload plugin';
$string['repositoryname'] = 'Upload a file';
$string['repositorydesc'] = 'Upload a file to Moodle';
24 changes: 22 additions & 2 deletions repository/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public function __construct($repositoryid, $contextid = SITEID, $options = array
foreach ($options as $n => $v) {
$this->options[$n] = $v;
}
$this->name = $this->get_name();
}

/**
Expand Down Expand Up @@ -188,6 +189,22 @@ public function print_listing($listing = array(), $print=true) {
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
Expand All @@ -198,7 +215,7 @@ final public function ajax_info() {
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;
Expand Down Expand Up @@ -386,6 +403,7 @@ public function get_option($config = ''){
* '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
Expand Down Expand Up @@ -1300,7 +1318,9 @@ function _client(){
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);
}
Expand Down
3 changes: 3 additions & 0 deletions repository/local/repository.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,5 +176,8 @@ public static function get_option_names() {
// 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');;
}
}
?>
6 changes: 5 additions & 1 deletion repository/upload/repository.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ public function get_listing($path='', $search='') {
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
Expand Down Expand Up @@ -56,5 +57,8 @@ public static function get_option_names() {
// 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');;
}
}
?>

0 comments on commit d31af46

Please sign in to comment.