From 9b64ec4dae53573137ebd8a58ded4ecc2a70d581 Mon Sep 17 00:00:00 2001 From: Matteo Scaramuccia Date: Sun, 9 Jun 2013 12:19:54 +0200 Subject: [PATCH 1/3] MDL-29218 Repository: Hide the repo if repository::plugin_init returns false --- admin/repository.php | 4 +++- repository/lib.php | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/admin/repository.php b/admin/repository.php index 50a08ee2bbc..8f976cf3222 100644 --- a/admin/repository.php +++ b/admin/repository.php @@ -143,8 +143,10 @@ if (($action == 'edit') || ($action == 'new')) { $success = $repositorytype->update_options($settings); } else { $type = new repository_type($plugin, (array)$fromform, $visible); - $type->create(); $success = true; + if (!$repoid = $type->create()) { + $success = false; + } $data = data_submitted(); } if ($success) { diff --git a/repository/lib.php b/repository/lib.php index 8c197ce30cb..79c7ecb39e5 100644 --- a/repository/lib.php +++ b/repository/lib.php @@ -255,6 +255,7 @@ class repository_type implements cacheable_object { } //run plugin_init function if (!repository::static_function($this->_typename, 'plugin_init')) { + $this->update_visibility(false); if (!$silent) { throw new repository_exception('cannotinitplugin', 'repository'); } From 46d023b77a7183fef0c317405ea6fde1fde67df4 Mon Sep 17 00:00:00 2001 From: Matteo Scaramuccia Date: Mon, 26 Aug 2013 23:32:21 +0200 Subject: [PATCH 2/3] MDL-29218 Repository: $pname, get rid of all the useless code More details in the Tracker. --- repository/lib.php | 8 -------- 1 file changed, 8 deletions(-) diff --git a/repository/lib.php b/repository/lib.php index 79c7ecb39e5..14004294b66 100644 --- a/repository/lib.php +++ b/repository/lib.php @@ -1153,14 +1153,6 @@ abstract class repository implements cacheable_object { return false; } - $pname = null; - if (is_object($plugin) || is_array($plugin)) { - $plugin = (object)$plugin; - $pname = $plugin->name; - } else { - $pname = $plugin; - } - $args = func_get_args(); if (count($args) <= 2) { $args = array(); From a1070d3fff3ca8d7347cef908652dd51e80a06b3 Mon Sep 17 00:00:00 2001 From: Matteo Scaramuccia Date: Mon, 26 Aug 2013 23:35:39 +0200 Subject: [PATCH 3/3] MDL-29218 Repository: fixed a typo in the PHPDoc --- repository/lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/repository/lib.php b/repository/lib.php index 14004294b66..7973c6e33d6 100644 --- a/repository/lib.php +++ b/repository/lib.php @@ -1140,7 +1140,7 @@ abstract class repository implements cacheable_object { * * @static * @param string $plugin repository plugin name - * @param string $function funciton name + * @param string $function function name * @return mixed */ public static function static_function($plugin, $function) { @@ -2430,7 +2430,7 @@ abstract class repository implements cacheable_object { /** * For oauth like external authentication, when external repository direct user back to moodle, - * this funciton will be called to set up token and token_secret + * this function will be called to set up token and token_secret */ public function callback() { }