From eb239694deea2b538659800994d41000a419a5f6 Mon Sep 17 00:00:00 2001 From: jerome Date: Thu, 4 Sep 2008 07:24:31 +0000 Subject: [PATCH] MDL-15402: Repository admin: delete a repository type => the general options (example: API key) are now deleted from config_plugin table --- repository/lib.php | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/repository/lib.php b/repository/lib.php index 73e81aceeb..015578eee1 100644 --- a/repository/lib.php +++ b/repository/lib.php @@ -60,7 +60,8 @@ require_once(dirname(dirname(__FILE__)).'/lib/formslib.php'); * - a repository_type object is mapped to the "repository" database table * - "typename" attibut maps the "type" database field. It is unique. * - general "options" for a repository type are saved in the config_plugin table - * - TODO: when you delete a repository, all instances are deleted + * - when you delete a repository, all instances are deleted, and general + * options are also deleted from database * - When you create a type for a plugin that can't have multiple instances, a * instance is automatically created. */ @@ -340,8 +341,8 @@ class repository_type { /** - * Delete a repository_type - DO NOT CALL IT TILL THE TODO IS DONE - * TODO: delete all instances for this type + * Delete a repository_type (general options are removed from config_plugin + * table, and all instances are deleted) * @global object $DB * @return boolean */ @@ -354,6 +355,11 @@ class repository_type { $instance->delete(); } + //delete all general options + foreach ($this->_options as $name => $value){ + set_config($name, null, $this->_typename); + } + return $DB->delete_records('repository', array('type' => $this->_typename)); } } @@ -549,6 +555,12 @@ abstract class repository { return $str; } } + + /** + * TODO: write documentation here + * @global $DB + * @return + */ public function get_name(){ global $DB; // We always verify instance id from database, -- 2.39.5