"MDL-17014, stop create repository type if plugin_init return false"
This commit is contained in:
@@ -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')) {
|
||||
|
||||
+8
-7
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user