From 122defc546188c81e34b224a85fa79781806b7d6 Mon Sep 17 00:00:00 2001 From: dongsheng Date: Tue, 26 Aug 2008 08:00:47 +0000 Subject: [PATCH] MDL-13766, add a cancel button on file picker, fix bugs in repository administration panel --- repository/lib.php | 40 ++++++++++++++++++++++++---------------- repository/ws.php | 2 +- 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/repository/lib.php b/repository/lib.php index 3eae7694d5..1fe8638e0c 100644 --- a/repository/lib.php +++ b/repository/lib.php @@ -200,23 +200,24 @@ abstract class repository { require_once($CFG->dirroot . '/repository/'. $type . '/repository.class.php'); $classname = 'repository_' . $type; $record = new stdclass; + $repo = $DB->get_record('repository', array('type'=>$type)); + $record->name = $params['name']; + $record->typeid = $repo->id; + $record->timecreated = time(); + $record->timemodified = time(); + $record->contextid = $context->id; + $record->userid = $userid; + $id = $DB->insert_record('repository_instances', $record); if (call_user_func($classname . '::has_admin_config')) { $configs = call_user_func($classname . '::get_option_names'); $options = array(); foreach ($configs as $config) { $options[$config] = $params[$config]; } - $record->data1 = serialize($options); } - $record->repositoryname = $params['name']; - $record->repositorytype = $type; - $record->timecreated = time(); - $record->timemodified = time(); - $record->contextid = $context->id; - $record->visible = 1; - $record->userid = $userid; - $id = $DB->insert_record('repository', $record); if (!empty($id)) { + $instance = repository_instance($id); + $instance->set_option($options); return $id; } else { return null; @@ -227,7 +228,7 @@ abstract class repository { */ final public function delete(){ global $DB; - $DB->delete_records('repository', array('id'=>$this->id)); + $DB->delete_records('repository_instances', array('id'=>$this->id)); return true; } /** @@ -297,11 +298,13 @@ abstract class repository { */ public function set_option($options = array()){ global $DB; - $r = new object(); - $r->id = $this->id; - $r->name = $options['name']; - $DB->update_record('repository_instances', $r); - unset($options['name']); + if (!empty($options['name'])) { + $r = new object(); + $r->id = $this->id; + $r->name = $options['name']; + $DB->update_record('repository_instances', $r); + unset($options['name']); + } foreach ($options as $name=>$value) { if ($id = $DB->get_field('repository_instance_config', 'id', array('name'=>$name, 'instanceid'=>$this->id))) { if ($value===null) { @@ -798,6 +801,7 @@ _client.rename = function(oldname, url){ html += ''; html += '$strback '; html += ''; + html += ''; html += ''; panel.get('element').innerHTML = html; } @@ -1071,6 +1075,10 @@ _client.end = function(str){ _client.instance.hide(); _client.viewfiles(); } +_client.hide = function(){ + _client.instance.hide(); + _client.viewfiles(); +} _client.callback = { success: function(o) { var panel = new YAHOO.util.Element('panel-$suffix'); @@ -1090,7 +1098,7 @@ _client.callback = { var search = null; var logout = null; var mgr = null; - if(_client.ds.login){ + if(_client.ds && _client.ds.login){ _client.print_login(); } else if(_client.ds.list) { if(_client.viewmode) { diff --git a/repository/ws.php b/repository/ws.php index a6be573de8..ad71f65227 100644 --- a/repository/ws.php +++ b/repository/ws.php @@ -26,7 +26,7 @@ $repo_id = optional_param('repo_id', 1, PARAM_INT); $ctx_id = optional_param('ctx_id', SITEID, PARAM_INT); $userid = $USER->id; -if(!$repository = $DB->get_record('repository', array('id'=>$repo_id))) +if(!$repository = repository_instance($repo_id)) { $err = new stdclass; $err->e = get_string('invalidrepositoryid', 'repository'); -- 2.39.5