]> git.mjollnir.org Git - moodle.git/commitdiff
"MDL-17014, check soap extension before create alfresco plugin"
authordongsheng <dongsheng>
Mon, 27 Oct 2008 02:57:29 +0000 (02:57 +0000)
committerdongsheng <dongsheng>
Mon, 27 Oct 2008 02:57:29 +0000 (02:57 +0000)
lang/en_utf8/repository_alfresco.php
repository/alfresco/repository.class.php
repository/lib.php

index 710abc6c4cefe8afe0daee98c67faa986c13fbcd..787d4f25273ba8a9e5f5a2a47155484edeb74091 100644 (file)
@@ -1,8 +1,9 @@
 <?php
+$string['alfresco_url'] = 'Alfresco URL';
 $string['configplugin'] = 'Alfresco configuration';
 $string['notitle'] = 'notitle';
 $string['repositoryname'] = 'Alfresco Repository';
 $string['repositorydesc'] = 'A plug-in for Alfresco CMS';
 $string['username'] = 'User name';
 $string['password'] = 'Password';
-$string['alfresco_url'] = 'Alfresco URL';
+$string['soapmustbeenabled'] = "SOAP extension must be enabled for alfresco plugin";
index 2092d5f8ab47056d4ad1b74bdf1c6135aad32b48..3013615f810862e04dd709f60348c4066463cd3b 100755 (executable)
@@ -20,23 +20,25 @@ class repository_alfresco extends repository {
     public function __construct($repositoryid, $context = SITEID, $options = array()) {
         global $SESSION, $CFG;
         parent::__construct ($repositoryid, $context, $options);
-        $this->repo = new Al_Repository($this->alfresco_url);
-        $this->sess_name = 'alfresco_ticket_'.$this->id;
-        $this->username   = optional_param('al_username', '', PARAM_RAW);
-        $this->password   = optional_param('al_password', '', PARAM_RAW);
-        try{
-            if ( empty($SESSION->{$this->sess_name}) && !empty($this->username) && !empty($this->password)) {
-                $this->ticket = $this->repo->authenticate($this->username, $this->password);
-                $SESSION->{$this->sess_name} = $this->ticket;  
-            } else {
-                $this->ticket = $SESSION->{$this->sess_name};  
+        if (class_exists('SoapClient')) {
+            $this->repo = new Al_Repository($this->alfresco_url);
+            $this->sess_name = 'alfresco_ticket_'.$this->id;
+            $this->username   = optional_param('al_username', '', PARAM_RAW);
+            $this->password   = optional_param('al_password', '', PARAM_RAW);
+            try{
+                if ( empty($SESSION->{$this->sess_name}) && !empty($this->username) && !empty($this->password)) {
+                    $this->ticket = $this->repo->authenticate($this->username, $this->password);
+                    $SESSION->{$this->sess_name} = $this->ticket;      
+                } else {
+                    $this->ticket = $SESSION->{$this->sess_name};      
+                }
+                $this->sess = $this->repo->createSession($this->ticket);
+                $this->store = new SpacesStore($this->sess);
+            } catch (Exception $e) {
+                $this->logout();
             }
-            $this->sess = $this->repo->createSession($this->ticket);
-            $this->store = new SpacesStore($this->sess);
-        } catch (Exception $e) {
-            $this->logout();
+            $this->current_node = null;
         }
-        $this->current_node = null;
     }
     public function print_login() {
         if ($this->options['ajax']) {
@@ -178,8 +180,20 @@ class repository_alfresco extends repository {
     }
 
     public function instance_config_form(&$mform) {
+        $soap = class_exists('SoapClient');
+        if (!$soap) {
+            $mform->addElement('static', null, get_string('notice'), get_string('soapmustbeenabled', 'repository_alfresco'));
+        }
         $mform->addElement('text', 'alfresco_url', get_string('alfresco_url', 'repository_alfresco'), array('size' => '40'));
         $mform->addRule('alfresco_url', get_string('required'), 'required', null, 'client');
     }
+    public static function plugin_init() {
+        if (!class_exists('SoapClient')) {
+            print_error('soapmustbeenabled', 'repository_alfresco');
+            return false;
+        } else {
+            return true;
+        }
+    }
 }
 ?>
index 6db8628e94176cf30208431882744d1280553f9a..33b1ae4a066db5c4cf7abe5c6f6217c8e4638b66 100644 (file)
@@ -246,7 +246,9 @@ class repository_type {
             }
 
             //run init function
-            repository_static_function($this->_typename,"plugin_init");
+            if (!repository_static_function($this->_typename, 'plugin_init')) {
+                throw new repository_exception('cannotcreatetype', 'repository');
+            }
 
         } else {
             throw new repository_exception('existingrepository', 'repository');
@@ -960,8 +962,10 @@ 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(){
+        return true;
     }
 
     /**