From: dongsheng Date: Thu, 11 Dec 2008 03:19:46 +0000 (+0000) Subject: "MDL-17014, stop create repository type if plugin_init return false" X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=f1cfe56eb68645923ae4e375b6bc95dd298e90d4;p=moodle.git "MDL-17014, stop create repository type if plugin_init return false" --- diff --git a/repository/alfresco/repository.class.php b/repository/alfresco/repository.class.php index addc476cec..cfe7bee2df 100755 --- a/repository/alfresco/repository.class.php +++ b/repository/alfresco/repository.class.php @@ -182,12 +182,13 @@ class repository_alfresco extends repository { } public function instance_config_form(&$mform) { - $soap = class_exists('SoapClient'); - if (!$soap) { + if (!class_exists('SoapClient')) { $mform->addElement('static', null, get_string('notice'), get_string('soapmustbeenabled', 'repository_alfresco')); + return false; } $mform->addElement('text', 'alfresco_url', get_string('alfresco_url', 'repository_alfresco'), array('size' => '40')); $mform->addRule('alfresco_url', get_string('required'), 'required', null, 'client'); + return false; } public static function plugin_init() { if (!class_exists('SoapClient')) { diff --git a/repository/lib.php b/repository/lib.php index e6fdeab2cc..f99127cbc6 100644 --- a/repository/lib.php +++ b/repository/lib.php @@ -225,6 +225,11 @@ class repository_type { //only create a new type if it doesn't already exist $existingtype = $DB->get_record('repository', array('type'=>$this->_typename)); if (!$existingtype) { + //run init function + if (!repository::static_function($this->_typename, 'plugin_init')) { + throw new repository_exception('cannotcreatetype', 'repository'); + } + //create the type $newtype = new stdclass; $newtype->type = $this->_typename; @@ -245,11 +250,6 @@ class repository_type { repository::static_function($this->_typename, 'create', $this->_typename, 0, get_system_context(), $instanceoptions); } - //run init function - if (!repository::static_function($this->_typename, 'plugin_init')) { - throw new repository_exception('cannotcreatetype', 'repository'); - } - } else { throw new repository_exception('existingrepository', 'repository'); } @@ -677,7 +677,8 @@ abstract class repository { //check that the plugin exists $typedirectory = $CFG->dirroot . '/repository/'. $plugin . '/repository.class.php'; if (!file_exists($typedirectory)) { - throw new repository_exception('invalidplugin', 'repository'); + //throw new repository_exception('invalidplugin', 'repository'); + return false; } $pname = null; @@ -1595,7 +1596,7 @@ abstract class repository { * function which is run when the type is created (moodle administrator add the plugin) * @return boolean success or fail? */ - public static function plugin_init(){ + public static function plugin_init() { return true; }