]> git.mjollnir.org Git - moodle.git/commitdiff
"MDL-17014, stop create repository type if plugin_init return false"
authordongsheng <dongsheng>
Thu, 11 Dec 2008 03:19:46 +0000 (03:19 +0000)
committerdongsheng <dongsheng>
Thu, 11 Dec 2008 03:19:46 +0000 (03:19 +0000)
repository/alfresco/repository.class.php
repository/lib.php

index addc476cec7dc610597b4f0007f8adb263d2e05e..cfe7bee2df4b244376d20a5771ad34fa7b9a0115 100755 (executable)
@@ -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')) {
index e6fdeab2ccd60d24e58f207265972a44bbfda2ea..f99127cbc67aed4638eac935d1e84129a08078ef 100644 (file)
@@ -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;
     }