Skip to content

Commit

Permalink
"MDL-18520, file system, supported choose a subdirectory"
Browse files Browse the repository at this point in the history
  • Loading branch information
dongsheng committed Jun 30, 2009
1 parent a1b53dc commit 93e9aa2
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
4 changes: 3 additions & 1 deletion admin/repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@
if ($edit) {
$settings = array();
foreach($configs as $config) {
$settings[$config] = $fromform->$config;
if (!empty($fromform->$config)) {
$settings[$config] = $fromform->$config;
}
}
$instanceoptionnames = repository::static_function($edit, 'get_instance_option_names');
if (!empty($instanceoptionnames)) {
Expand Down
2 changes: 0 additions & 2 deletions admin/repositoryinstance.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,6 @@
print_error('confirmsesskeybad', '', $baseurl);
}
$instance = repository::get_type_by_typename($hide);
var_dump($instance);
var_dump($hide);
$instance->hide();
$return = true;
} else if (!empty($delete)) {
Expand Down
21 changes: 19 additions & 2 deletions repository/filesystem/repository.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ public function __construct($repositoryid, $context = SITEID, $options = array()
global $CFG;
parent::__construct($repositoryid, $context, $options);
$this->root_path = $CFG->dataroot.'/repository/';
$this->root_path .= ($this->options['fs_path'] . '/');
if (!empty($options['ajax'])) {
if (!is_dir($this->root_path)) {
$created = mkdir($this->root_path, 0700);
$ret = array();
$ret['msg'] = get_string('invalidpath', 'repository_filesystem');
$ret['nosearch'] = true;
if ($options['ajax']) {
if ($options['ajax'] && !$created) {
echo json_encode($ret);
exit;
}
Expand Down Expand Up @@ -110,12 +112,27 @@ public function logout() {
}

public static function get_instance_option_names() {
return null;
return array('fs_path');
}

public static function get_type_option_names() {
return array();
}
public function type_config_form(&$mform) {
}
public function instance_config_form(&$mform) {
global $CFG;
$path = $CFG->dataroot . '/repository/';
if ($handle = opendir($path)) {
$fieldname = get_string('path', 'repository_filesystem');
while (false !== ($file = readdir($handle))) {
if (is_dir($path.$file) && $file != '.' && $file!= '..') {
$mform->addElement('radio', 'fs_path', $fieldname, $file, $file);
$fieldname = '';
}
}
closedir($handle);
}
$mform->addElement('static', null, '', get_string('information','repository_filesystem'));
}
}

0 comments on commit 93e9aa2

Please sign in to comment.