From: jerome Date: Thu, 4 Sep 2008 02:07:58 +0000 (+0000) Subject: MDL-15402: fix a small bug in repository.create(), create an instance for type for... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=0a6221f94dade3150a8c81e9a2b1f0dd05ae460a;p=moodle.git MDL-15402: fix a small bug in repository.create(), create an instance for type for which the administrator can not create a instance --- diff --git a/repository/lib.php b/repository/lib.php index aa2b02dec1..35db2fd020 100644 --- a/repository/lib.php +++ b/repository/lib.php @@ -202,6 +202,16 @@ class repository_type { //save the options in DB $this->update_options(); + + //if the plugin type has no multiple and no instance config so it wont + //be possible for the administrator to create a instance + //in this case we need to create an instance + if (!repository_static_function($this->_typename,"has_instance_config") + && !repository_static_function($this->_typename,"has_multiple_instances")){ + $instanceoptions = array(); + $instanceoptions['name'] = $this->_typename; + repository_static_function($this->_typename, 'create', $this->_typename, 0, get_system_context(), $instanceoptions); + } } else { throw new repository_exception('existingrepository', 'repository'); @@ -595,9 +605,9 @@ abstract class repository { $record->contextid = $context->id; $record->userid = $userid; $id = $DB->insert_record('repository_instances', $record); + $options = array(); if (call_user_func($classname . '::has_instance_config')) { - $configs = call_user_func($classname . '::get_instance_option_names'); - $options = array(); + $configs = call_user_func($classname . '::get_instance_option_names'); foreach ($configs as $config) { $options[$config] = $params[$config]; }