Skip to content

Commit

Permalink
MDL-15402: fix a small bug in repository.create(), create an instance…
Browse files Browse the repository at this point in the history
… for type for which the administrator can not create a instance
  • Loading branch information
jerome committed Sep 4, 2008
1 parent f74e601 commit 0a6221f
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions repository/lib.php
Expand Up @@ -202,6 +202,16 @@ public function create(){

//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');
Expand Down Expand Up @@ -595,9 +605,9 @@ final public static function create($type, $userid, $context, $params) {
$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];
}
Expand Down

0 comments on commit 0a6221f

Please sign in to comment.