diff --git a/lang/en_utf8/repository_alfresco.php b/lang/en_utf8/repository_alfresco.php index 710abc6c4ce..787d4f25273 100644 --- a/lang/en_utf8/repository_alfresco.php +++ b/lang/en_utf8/repository_alfresco.php @@ -1,8 +1,9 @@ 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; + } + } } ?> diff --git a/repository/lib.php b/repository/lib.php index 6db8628e941..33b1ae4a066 100644 --- a/repository/lib.php +++ b/repository/lib.php @@ -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; } /**