From 26e411c576261d1f75def30385aad51813b4db23 Mon Sep 17 00:00:00 2001 From: dongsheng Date: Tue, 23 Sep 2008 01:19:27 +0000 Subject: [PATCH] MDL-16384 1) enable searching 2) catch session exception 3) fix bug of downloading --- repository/alfresco/repository.class.php | 41 ++++++++++++++++++------ 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/repository/alfresco/repository.class.php b/repository/alfresco/repository.class.php index 05918dfcb6..61a2676df3 100755 --- a/repository/alfresco/repository.class.php +++ b/repository/alfresco/repository.class.php @@ -24,15 +24,18 @@ class repository_alfresco extends repository { $this->sess_name = 'alfresco_ticket_'.$this->id; $this->username = optional_param('al_username', '', PARAM_RAW); $this->password = optional_param('al_password', '', PARAM_RAW); - 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}; + 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); $this->current_node = null; } public function print_login() { @@ -125,10 +128,10 @@ class repository_alfresco extends repository { } if (empty($file)) { - $file = $photo_id.'_'.time().'.jpg'; + $file = $uuid.'_'.time(); } if (file_exists($dir.$file)) { - $file = uniqid('m').$file; + $file = uniqid('al_').$file; } $fp = fopen($dir.$file, 'w'); $c = new curl; @@ -138,13 +141,31 @@ class repository_alfresco extends repository { public function print_search() { parent::print_search(); + echo '
'; return true; } public function search($search_text) { global $CFG; + $space = optional_param('space', 'workspace://SpacesStore', PARAM_RAW); + $currentStore = $this->sess->getStoreFromString($space); + $nodes = $this->sess->query($currentStore, $search_text); $ret = array(); $ret['list'] = array(); + foreach($nodes as $v) { + $ret['list'][] = array('title'=>$v->cm_name, 'source'=>$v->id); + } return $ret; } -- 2.39.5