Commit 19d5440d33121b46cedf348c78a0841b23e44c1e
1 parent
58d9ce33
ClientTools Comms Update
Showing
8 changed files
with
374 additions
and
360 deletions
webservice/clienttools/ajaxhandler.php
| ... | ... | @@ -5,14 +5,16 @@ class ajaxHandler{ |
| 5 | 5 | public $version=NULL; |
| 6 | 6 | public $auth=NULL; |
| 7 | 7 | public $request=NULL; |
| 8 | - | |
| 9 | - public function __construct(&$ret=NULL){ | |
| 8 | + public $kt=NULL; | |
| 9 | + public $authenticator=NULL; | |
| 10 | + | |
| 11 | + public function __construct(&$ret=NULL,&$kt){ | |
| 10 | 12 | // set a local copy of the json request wrapper |
| 11 | 13 | $this->req=new jsonWrapper(isset($_GET['request'])?$_GET['request']:(isset($_POST['request'])?$_POST['request']:'')); |
| 12 | 14 | $this->auth=$this->req->jsonArray['auth']; |
| 13 | 15 | $this->request=$this->req->jsonArray['request']; |
| 14 | - | |
| 15 | - | |
| 16 | + | |
| 17 | + | |
| 16 | 18 | // set the response object |
| 17 | 19 | if(get_class($ret)=='jsonResponseObject'){ |
| 18 | 20 | $this->ret=&$ret; |
| ... | ... | @@ -20,71 +22,97 @@ class ajaxHandler{ |
| 20 | 22 | $this->ret=new jsonResponseObject(); |
| 21 | 23 | } |
| 22 | 24 | $this->ret->setRequest($this->req->jsonArray); |
| 25 | + | |
| 26 | + if(get_class($kt)=='KTAPI'){ | |
| 27 | + $this->kt=&$kt; | |
| 28 | + }else{ | |
| 29 | + $this->ret->addError('KnowledgeTree Object not Received in '.__CLASS__.' constructor. Quitting.'); | |
| 30 | + return $this->render(); | |
| 31 | + } | |
| 32 | + | |
| 33 | + // Prepar | |
| 34 | + $this->loadService('auth'); | |
| 35 | + $this->authenticator=new auth($this->ret,$this->kt,$this->request,$this->auth); | |
| 23 | 36 | |
| 24 | - | |
| 37 | + | |
| 25 | 38 | //Make sure a token exists before continuing |
| 26 | 39 | if(!$this->verifyToken())return $this->render(); |
| 27 | - | |
| 28 | - | |
| 40 | + | |
| 41 | + | |
| 29 | 42 | if(!$this->verifySession()){ |
| 30 | 43 | $this->doLogin(); |
| 31 | 44 | if(!$this->isAuthenticated())return $this->render(); |
| 32 | 45 | } |
| 33 | 46 | |
| 34 | - | |
| 47 | + $this->dispatch(); | |
| 48 | + | |
| 35 | 49 | return $this->render(); |
| 36 | 50 | } |
| 51 | + | |
| 52 | + public function dispatch(){ | |
| 53 | + $request=$this->request; | |
| 54 | + $this->loadService($request['service']); | |
| 55 | + $service=new $request['service']($this->ret,$this->kt,$this->request,$this->auth); | |
| 56 | + $this->ret->setTitle($request['service'].'::'.$request['function']); | |
| 57 | + if(method_exists($service,$request['function'])){ | |
| 58 | + //$this->ret->setDebug('got here'); | |
| 59 | + $service->$request['function']($request['parameters']); | |
| 60 | + }else{ | |
| 61 | + $this->ret->addError("Service {$request['service']} does not contain the method: {$request['function']}"); | |
| 62 | + return false; | |
| 63 | + } | |
| 64 | + } | |
| 37 | 65 | |
| 38 | - | |
| 66 | + | |
| 39 | 67 | public function loadService($serviceName=NULL){ |
| 40 | 68 | $version=$this->getVersion(); |
| 41 | 69 | if(!class_exists($serviceName)){ |
| 42 | 70 | if(file_exists('services/'.$version.'/'.$serviceName.'.php')){ |
| 43 | 71 | require_once('services/'.$version.'/'.$serviceName.'.php'); |
| 72 | + return true; | |
| 44 | 73 | }else{ |
| 45 | 74 | throw new Exception('Service could not be found: '.$serviceName); |
| 75 | + return false; | |
| 46 | 76 | } |
| 47 | 77 | } |
| 48 | 78 | } |
| 49 | - | |
| 79 | + | |
| 50 | 80 | protected function verifyToken(){ |
| 51 | 81 | $token=isset($this->auth['token'])?$this->auth['token']:NULL; |
| 52 | 82 | if(!$token){ |
| 53 | - $token=md5(rand()*rand()); | |
| 83 | + $token=md5(rand()*rand()); | |
| 54 | 84 | $this->ret->setStatus('random_token',$token); |
| 55 | - return false; | |
| 85 | + return false; | |
| 56 | 86 | } |
| 57 | 87 | return true; |
| 58 | - } | |
| 59 | - | |
| 88 | + } | |
| 89 | + | |
| 60 | 90 | protected function getVersion(){ |
| 61 | 91 | if(!$this->version)$this->version=$this->req->getVersion(); |
| 62 | 92 | return $this->version; |
| 63 | 93 | } |
| 64 | - | |
| 94 | + | |
| 65 | 95 | protected function verifySession(){ |
| 66 | - return false; | |
| 96 | + return $this->authenticator->pickup_session(); | |
| 67 | 97 | } |
| 68 | - | |
| 98 | + | |
| 69 | 99 | protected function isAuthenticated(){ |
| 70 | - | |
| 100 | + return true; | |
| 71 | 101 | } |
| 72 | - | |
| 102 | + | |
| 73 | 103 | protected function doLogin(){ |
| 74 | - $this->loadService('auth'); | |
| 75 | - $auth=new auth($this->ret); | |
| 76 | - if(!$auth->login($this->auth)){ | |
| 104 | + if($this->authenticator->login()){ | |
| 77 | 105 | return true; |
| 78 | 106 | }else{ |
| 79 | 107 | $this->ret->addError('Unsuccesful Login'); |
| 80 | 108 | return false; |
| 81 | 109 | } |
| 82 | 110 | } |
| 83 | - | |
| 111 | + | |
| 84 | 112 | public function render(){ |
| 85 | 113 | echo $this->ret->getJson(); |
| 86 | 114 | return true; |
| 87 | 115 | } |
| 88 | - | |
| 116 | + | |
| 89 | 117 | } |
| 90 | 118 | ?> |
| 91 | 119 | \ No newline at end of file | ... | ... |
webservice/clienttools/client_service.php
0 โ 100644
| 1 | +<?php | |
| 2 | + | |
| 3 | +class client_service{ | |
| 4 | + public $Response; | |
| 5 | + public $KT; | |
| 6 | + public $Request; | |
| 7 | + public $AuthInfo; | |
| 8 | + | |
| 9 | + public function __construct(&$ResponseObject,&$KT_Instance,&$Request,&$AuthInfo){ | |
| 10 | + // set the response object | |
| 11 | +// if(get_class($ResponseObject)=='jsonResponseObject'){ | |
| 12 | +// $this->Response=&$ResponseObject; | |
| 13 | +// }else{ | |
| 14 | +// $this->Response=new jsonResponseObject(); | |
| 15 | +// } | |
| 16 | + | |
| 17 | + | |
| 18 | + $this->Response=&$ResponseObject; | |
| 19 | + $this->KT=&$KT_Instance; | |
| 20 | + $this->AuthInfo=&$AuthInfo; | |
| 21 | + $this->Request=&$Request; | |
| 22 | + } | |
| 23 | + | |
| 24 | + protected function addResponse($name,$value){ | |
| 25 | + $this->Response->setData($name,$value); | |
| 26 | + } | |
| 27 | + | |
| 28 | + protected function addDebug($name,$value){ | |
| 29 | + $this->Response->setDebug($name,$value); | |
| 30 | + } | |
| 31 | + | |
| 32 | + protected function setResponse($value){ | |
| 33 | + $this->Response->overwriteData($value); | |
| 34 | + } | |
| 35 | + | |
| 36 | + protected function addError($message,$code){ | |
| 37 | + $this->Response->addError($message,$code); | |
| 38 | + } | |
| 39 | + | |
| 40 | + protected function xlate($var=NULL){ | |
| 41 | + return $var; | |
| 42 | + } | |
| 43 | + | |
| 44 | +} | |
| 45 | + | |
| 46 | +?> | |
| 0 | 47 | \ No newline at end of file | ... | ... |
webservice/clienttools/comms.php
| 1 | 1 | <?php |
| 2 | 2 | include_once('../../ktapi/ktapi.inc.php'); |
| 3 | -require_once("../../config/dmsDefaults.php"); | |
| 4 | -error_reporting(E_ERROR&~E_WARNING); | |
| 3 | +error_reporting(E_ERROR); | |
| 5 | 4 | |
| 6 | 5 | /** |
| 7 | 6 | * Intercept Errors and Exceptions and provide a json response in return. |
| ... | ... | @@ -17,7 +16,7 @@ error_reporting(E_ERROR&~E_WARNING); |
| 17 | 16 | function error_handler($e,$errstr=null,$errfile=null,$errline=null){ |
| 18 | 17 | if($GLOBALS['RET']){ |
| 19 | 18 | $GLOBALS['RET']->addError($errfile?$errstr:$e->getmessage()); |
| 20 | - $GLOBALS['RET']->setDebug('',$errfile?(array('error_number'=>$e,'error_string'=>$errstr,'error_file'=>$errfile,'error_line'=>$errline)):$e); | |
| 19 | + $GLOBALS['RET']->setDebug($errfile?'ERR':'EXC',$errfile?(array('error_number'=>$e,'error_string'=>$errstr,'error_file'=>$errfile,'error_line'=>$errline)):$e); | |
| 21 | 20 | echo $GLOBALS['RET']->getJson(); |
| 22 | 21 | exit; |
| 23 | 22 | }; |
| ... | ... | @@ -27,23 +26,24 @@ function error_handler($e,$errstr=null,$errfile=null,$errline=null){ |
| 27 | 26 | * Set the error & exception handlers |
| 28 | 27 | */ |
| 29 | 28 | $old_exception_handler=set_exception_handler('error_handler'); |
| 30 | -$old_error_handler=set_error_handler('error_handler',E_ALL); | |
| 29 | +$old_error_handler=set_error_handler('error_handler',E_ERROR); | |
| 31 | 30 | |
| 32 | 31 | |
| 33 | 32 | |
| 34 | 33 | /** |
| 35 | 34 | * Load additional generic libaries |
| 36 | 35 | */ |
| 37 | -require_once("../../config/dmsDefaults.php"); | |
| 38 | 36 | |
| 39 | 37 | |
| 40 | 38 | //Interpret the Json Object that was passed |
| 41 | 39 | include_once('jsonWrapper.php'); |
| 42 | 40 | include_once('ajaxhandler.php'); |
| 41 | +include_once('client_service.php'); | |
| 43 | 42 | |
| 44 | 43 | //Instantiate base classes |
| 44 | +$KT = new KTAPI(); | |
| 45 | 45 | $RET=new jsonResponseObject(); |
| 46 | -$handler=new ajaxHandler($RET); | |
| 46 | +$handler=new ajaxHandler($RET,$KT); | |
| 47 | 47 | |
| 48 | 48 | |
| 49 | 49 | ... | ... |
webservice/clienttools/comms(2).php renamed to webservice/clienttools/comms_old.php
webservice/clienttools/jsonWrapper.php
| ... | ... | @@ -5,6 +5,7 @@ class jsonContentException extends Exception{ |
| 5 | 5 | } |
| 6 | 6 | |
| 7 | 7 | class jsonResponseObject{ |
| 8 | + protected $title=''; | |
| 8 | 9 | protected $errors=array(); |
| 9 | 10 | protected $status=array('session_id'=>'','random_token'=>''); |
| 10 | 11 | protected $data=array(); |
| ... | ... | @@ -13,6 +14,7 @@ class jsonResponseObject{ |
| 13 | 14 | public $additional=array(); |
| 14 | 15 | |
| 15 | 16 | public $response=array( |
| 17 | + 'requestName' =>'', | |
| 16 | 18 | 'errors' =>array( |
| 17 | 19 | 'hadErrors' =>0 , |
| 18 | 20 | 'errors' =>array() |
| ... | ... | @@ -39,6 +41,10 @@ class jsonResponseObject{ |
| 39 | 41 | $this->data[$varName]=$value; |
| 40 | 42 | } |
| 41 | 43 | |
| 44 | + public function overwriteData($value=NULL){ | |
| 45 | + $this->data=$value; | |
| 46 | + } | |
| 47 | + | |
| 42 | 48 | public function setDebug($varName=NULL,$value=NULL){ |
| 43 | 49 | $this->debug[$varName]=$value; |
| 44 | 50 | } |
| ... | ... | @@ -47,8 +53,14 @@ class jsonResponseObject{ |
| 47 | 53 | $this->request=$request; |
| 48 | 54 | } |
| 49 | 55 | |
| 56 | + public function setTitle($title=NULL){ | |
| 57 | + $title=(string)$title; | |
| 58 | + $this->title=$title; | |
| 59 | + } | |
| 60 | + | |
| 50 | 61 | public function getJson(){ |
| 51 | 62 | $response=array_merge(array( |
| 63 | + 'title' =>$this->title, | |
| 52 | 64 | 'errors' =>array( |
| 53 | 65 | 'hadErrors' =>(count($this->errors)>0?1:0), |
| 54 | 66 | 'errors' =>$this->errors |
| ... | ... | @@ -64,6 +76,8 @@ class jsonResponseObject{ |
| 64 | 76 | } |
| 65 | 77 | } |
| 66 | 78 | |
| 79 | + | |
| 80 | + | |
| 67 | 81 | class jsonWrapper{ |
| 68 | 82 | public $raw=''; |
| 69 | 83 | public $jsonArray=array(); | ... | ... |
webservice/clienttools/services/3.6.1/auth.php
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -class auth{ | |
| 4 | - protected $ret; | |
| 5 | - | |
| 6 | - public function __construct(&$ret=NULL){ | |
| 7 | - // set the response object | |
| 8 | - if(get_class($ret)=='jsonResponseObject'){ | |
| 9 | - $this->ret=&$ret; | |
| 10 | - }else{ | |
| 11 | - $this->ret=new jsonResponseObject(); | |
| 12 | - } | |
| 13 | - } | |
| 14 | - | |
| 15 | - public function login($params){ | |
| 3 | +class auth extends client_service { | |
| 4 | + | |
| 5 | + public function login(){ | |
| 6 | + $params=$this->AuthInfo; | |
| 16 | 7 | |
| 17 | 8 | $username=$params['user']; |
| 18 | 9 | $passhash=$params['passhash']; |
| ... | ... | @@ -21,33 +12,33 @@ class auth{ |
| 21 | 12 | $session_id=$params['session']; |
| 22 | 13 | $ip=$_SERVER['REMOTE_ADDR']; |
| 23 | 14 | $language=isset($params['language'])?$params['language']:'en'; |
| 15 | + | |
| 16 | + $this->Response->setDebug('parameters',$params); | |
| 24 | 17 | |
| 25 | 18 | setcookie("kt_language", $language, 2147483647, '/'); |
| 26 | 19 | |
| 27 | - | |
| 28 | - $kt = new KTAPI(); | |
| 29 | - | |
| 20 | + $kt =& $this->KT; | |
| 30 | 21 | |
| 31 | -// if ($username != 'admin') { | |
| 32 | -// require_once(KT_DIR . '/plugins/wintools/baobabkeyutil.inc.php'); | |
| 33 | -// | |
| 34 | -// if (!BaobabKeyUtil::checkIfLicensed(true)) { | |
| 35 | -// return array('authenticated'=> false, 'message'=> 'license_expired'); | |
| 36 | -// } | |
| 37 | -// } | |
| 22 | + if ($username != 'admin') { | |
| 23 | + require_once(KT_DIR . '/plugins/wintools/baobabkeyutil.inc.php'); | |
| 24 | + | |
| 25 | + if (!BaobabKeyUtil::checkIfLicensed(true)) { | |
| 26 | + return array('authenticated'=> false, 'message'=> 'license_expired'); | |
| 27 | + } | |
| 28 | + } | |
| 38 | 29 | |
| 39 | 30 | $user=$kt->get_user_object_by_username($username); |
| 40 | 31 | if(!PEAR::isError($user)){ |
| 41 | 32 | $password=$user->getPassword(); |
| 42 | 33 | $localPassHash=md5($password.$token); |
| 43 | 34 | if($localPassHash==$passhash){ |
| 44 | - $session=array(); | |
| 45 | - $this->ret->setDebug('trying to start session with',array('username'=>$username,'password'=>$password)); | |
| 46 | - $session = $kt->start_session($username, $password, NULL, NULL); | |
| 35 | + $session=new stdClass(); | |
| 36 | + $this->Response->setDebug('trying to start session with',array('username'=>$username,'password'=>$password)); | |
| 37 | + $session = $kt->start_session($username, $params['pass'],NULL,$app_type); | |
| 47 | 38 | if(!PEAR::isError($session)){ |
| 48 | - $this->ret->setStatus('session_id',$session); | |
| 39 | + $this->Response->setStatus('session_id',$session->get_session()); | |
| 49 | 40 | }else{ |
| 50 | - $this->ret->setDebug('failed login',$session); | |
| 41 | + $this->Response->setDebug('failed login',print_r($session,true)); | |
| 51 | 42 | throw new Exception('Unknown Login Error'); |
| 52 | 43 | return false; |
| 53 | 44 | } |
| ... | ... | @@ -61,6 +52,21 @@ class auth{ |
| 61 | 52 | } |
| 62 | 53 | return true; |
| 63 | 54 | } |
| 55 | + | |
| 56 | + public function pickup_session(){ | |
| 57 | + $params=$this->AuthInfo; | |
| 58 | + $app_type=$params['appType']; | |
| 59 | + $session_id=$params['session']; | |
| 60 | + $ip=$_SERVER['REMOTE_ADDR']; | |
| 61 | + | |
| 62 | + $session = $this->KT->get_active_session($session_id, $ip, $app_type); | |
| 63 | + | |
| 64 | + if (PEAR::isError($session)){ | |
| 65 | + return false; | |
| 66 | + } | |
| 67 | + $this->Response->setStatus('session_id',$session->get_session()); | |
| 68 | + return true; | |
| 69 | + } | |
| 64 | 70 | } |
| 65 | 71 | |
| 66 | 72 | ?> |
| 67 | 73 | \ No newline at end of file | ... | ... |
webservice/clienttools/services/3.6.1/list.service.php renamed to webservice/clienttools/services/3.6.1/kt.php
| 1 | 1 | <?php |
| 2 | -class clientTools_service_list_361 extends clientTools_service { | |
| 3 | - var $ktapi; | |
| 4 | - var $dfp; | |
| 5 | - | |
| 6 | - public function __construct(&$kt,&$session,&$session_id){ | |
| 7 | - parent::__construct(&$kt,&$session,&$session_id); | |
| 8 | - $this->ktapi=$kt; | |
| 9 | - } | |
| 2 | +class kt extends client_service { | |
| 10 | 3 | |
| 11 | 4 | /** |
| 12 | 5 | * Get Supported (?) Languages |
| ... | ... | @@ -30,28 +23,24 @@ class clientTools_service_list_361 extends clientTools_service { |
| 30 | 23 | } |
| 31 | 24 | } |
| 32 | 25 | |
| 33 | - $this->setResponse('language_info',array('languages' => $languages, 'count' => count($languages), 'defaultLanguage' => $default->defaultLanguage)); | |
| 26 | + $this->setResponse(array('languages' => $languages, 'count' => count($languages), 'defaultLanguage' => $default->defaultLanguage)); | |
| 34 | 27 | } |
| 35 | 28 | |
| 36 | 29 | |
| 37 | 30 | function get_rootfolder_detail($params){ |
| 38 | 31 | $params['folderId'] = '1'; |
| 39 | - $this->setResponse($this->get_folder_detail($params)); | |
| 32 | + $this->get_folder_detail($params); | |
| 40 | 33 | } |
| 41 | 34 | |
| 42 | 35 | |
| 43 | 36 | function get_folder_detail($params) { |
| 44 | - $kt = &$this->ktapi; | |
| 45 | -// if (is_array($kt)) | |
| 46 | -// { | |
| 47 | -// $this->response= $kt; | |
| 48 | -// } | |
| 37 | + $kt = &$this->KT; | |
| 49 | 38 | |
| 50 | 39 | $folder = &$kt->get_folder_by_id($params['folderId']); |
| 51 | 40 | if (PEAR::isError($folder)) |
| 52 | 41 | { |
| 53 | - $this->setError(self::ERR_SERVICE_RESOURCE_NOT_FOUND ,"Could not get folder by Id: {$params['folderId']}"); | |
| 54 | - $this->setDebug('FolderError'.self::ERR_SERVICE_RESOURCE_NOT_FOUND ,array('kt'=>$kt,'folder'=>$folder)); | |
| 42 | + $this->setError("Could not get folder by Id: {$params['folderId']}"); | |
| 43 | + $this->setDebug('FolderError',array('kt'=>$kt,'folder'=>$folder)); | |
| 55 | 44 | return; |
| 56 | 45 | } |
| 57 | 46 | |
| ... | ... | @@ -65,7 +54,7 @@ class clientTools_service_list_361 extends clientTools_service { |
| 65 | 54 | $detail['folder_name'] = 'KnowledgeTree'; |
| 66 | 55 | } |
| 67 | 56 | |
| 68 | - $qtip .= _kt('Folder name').": {$detail['folder_name']}<br>"; | |
| 57 | + $qtip .= $this->xlate('Folder name').": {$detail['folder_name']}<br>"; | |
| 69 | 58 | $class = 'folder'; |
| 70 | 59 | |
| 71 | 60 | $permissions = $detail['permissions']; |
| ... | ... | @@ -80,13 +69,13 @@ class clientTools_service_list_361 extends clientTools_service { |
| 80 | 69 | { |
| 81 | 70 | case 'W': |
| 82 | 71 | $canWrite = true; |
| 83 | - $perms .= _kt('write, '); | |
| 72 | + $perms .= $this->xlate('write, '); | |
| 84 | 73 | break; |
| 85 | 74 | case 'R': |
| 86 | - $perms .= _kt('read, '); | |
| 75 | + $perms .= $this->xlate('read, '); | |
| 87 | 76 | break; |
| 88 | 77 | case 'A': |
| 89 | - $perms .= _kt('add folder, '); | |
| 78 | + $perms .= $this->xlate('add folder, '); | |
| 90 | 79 | break; |
| 91 | 80 | } |
| 92 | 81 | } |
| ... | ... | @@ -98,10 +87,10 @@ class clientTools_service_list_361 extends clientTools_service { |
| 98 | 87 | } |
| 99 | 88 | |
| 100 | 89 | //permissions |
| 101 | - $qtip .= _kt('Permissions:') . " {$perms}<br>"; | |
| 90 | + $qtip .= $this->xlate('Permissions:') . " {$perms}<br>"; | |
| 102 | 91 | |
| 103 | 92 | //comment |
| 104 | - $qtip .= $canWrite ? _kt('You may add content to this folder') : _kt('You may not add content to this folder'); | |
| 93 | + $qtip .= $canWrite ? $this->xlate('You may add content to this folder') : $this->xlate('You may not add content to this folder'); | |
| 105 | 94 | |
| 106 | 95 | $result[] = array |
| 107 | 96 | ( |
| ... | ... | @@ -116,130 +105,33 @@ class clientTools_service_list_361 extends clientTools_service { |
| 116 | 105 | 'qtip'=> $qtip |
| 117 | 106 | ); |
| 118 | 107 | |
| 119 | - $this->response= $result; | |
| 108 | + $this->setResponse($result); | |
| 120 | 109 | } |
| 121 | 110 | |
| 122 | 111 | |
| 123 | -} | |
| 124 | - | |
| 125 | - | |
| 126 | -/* | |
| 127 | - | |
| 128 | - | |
| 129 | - | |
| 130 | - | |
| 131 | - function get_folder_detail($params) | |
| 132 | - { | |
| 133 | - $kt = &$this->get_ktapi($params['session_id'], $params['application']); | |
| 134 | - if (is_array($kt)) | |
| 135 | - { | |
| 136 | - $this->response= $kt; | |
| 137 | - } | |
| 112 | + function get_folder_contents($params){ | |
| 113 | + $kt=&$this->KT; | |
| 138 | 114 | |
| 139 | 115 | $params['control'] = 'F_'; |
| 140 | 116 | $params['node'] = substr($params['node'], strlen($params['control'])); |
| 141 | 117 | |
| 142 | 118 | $folder = &$kt->get_folder_by_id($params['node']); |
| 143 | - if (PEAR::isError($folder)) | |
| 144 | - { | |
| 145 | - $this->response= "folder error {$params['node']}"; | |
| 119 | + if (PEAR::isError($folder)){ | |
| 120 | + $this->addError("[error 1] Folder Not Found: {$params['control']}{$params['node']}"); | |
| 121 | + return false; | |
| 146 | 122 | } |
| 147 | 123 | |
| 148 | - $detail = $folder->get_detail(); | |
| 149 | - if (PEAR::isError($detail)) | |
| 150 | - { | |
| 151 | - $this->response= "detail error {$params['node']}"; | |
| 152 | - } | |
| 153 | - | |
| 154 | - if(strtolower($detail['folder_name']) == 'root folder') { | |
| 155 | - $detail['folder_name'] = 'KnowledgeTree'; | |
| 156 | - } | |
| 157 | - | |
| 158 | - $qtip .= _kt('Folder name').": {$detail['folder_name']}<br>"; | |
| 159 | - $class = 'folder'; | |
| 160 | - | |
| 161 | - $permissions = $detail['permissions']; | |
| 162 | - $perms = ''; | |
| 163 | - //default write permissions to false | |
| 164 | - $canWrite = false; | |
| 165 | - | |
| 166 | - //iterate through the permissions and convert to human-readable | |
| 167 | - for ($j = 0; $j < strlen($permissions); $j++) | |
| 168 | - { | |
| 169 | - switch (strtoupper($permissions{$j})) | |
| 170 | - { | |
| 171 | - case 'W': | |
| 172 | - $canWrite = true; | |
| 173 | - $perms .= _kt('write, '); | |
| 174 | - break; | |
| 175 | - case 'R': | |
| 176 | - $perms .= _kt('read, '); | |
| 177 | - break; | |
| 178 | - case 'A': | |
| 179 | - $perms .= _kt('add folder, '); | |
| 180 | - break; | |
| 181 | - } | |
| 182 | - } | |
| 183 | - | |
| 184 | - //now chop off trailing ', ' if any | |
| 185 | - if (strlen($perms) > 2) | |
| 186 | - { | |
| 187 | - $perms = substr($perms, 0, strlen($perms)-2); | |
| 188 | - } | |
| 189 | - | |
| 190 | - //permissions | |
| 191 | - $qtip .= _kt('Permissions:') . " {$perms}<br>"; | |
| 192 | - | |
| 193 | - //comment | |
| 194 | - $qtip .= $canWrite ? _kt('You may add content to this folder') : _kt('You may not add content to this folder'); | |
| 195 | - | |
| 196 | - $result[] = array | |
| 197 | - ( | |
| 198 | - 'text' => $detail['folder_name'], | |
| 199 | - 'id' => $params['control'] . $params['node'], | |
| 200 | - 'filename' => $detail['folder_name'], | |
| 201 | - 'cls' => 'folder', | |
| 202 | - 'leaf' => false, | |
| 203 | - 'document_type' => '', | |
| 204 | - 'item_type' => 'F', | |
| 205 | - 'permissions' => $permissions, | |
| 206 | - 'qtip'=> $qtip | |
| 207 | - ); | |
| 208 | - | |
| 209 | - $this->response= $result; | |
| 210 | - } | |
| 211 | - | |
| 212 | - function get_folder_contents($arr) | |
| 213 | - { | |
| 214 | - $kt = &$this->get_ktapi($arr['session_id'], $arr['application']); | |
| 215 | - | |
| 216 | - if (is_array($kt)) | |
| 217 | - { | |
| 218 | - $this->response= $kt; | |
| 219 | - } | |
| 220 | - | |
| 221 | - $arr['control'] = 'F_'; | |
| 222 | - $arr['node'] = substr($arr['node'], strlen($arr['control'])); | |
| 223 | - | |
| 224 | - $folder = &$kt->get_folder_by_id($arr['node']); | |
| 225 | - if (PEAR::isError($folder)) | |
| 226 | - { | |
| 227 | - $response = 'error'; | |
| 228 | - | |
| 229 | - $this->response= 'error 1'; | |
| 230 | - } | |
| 231 | - | |
| 232 | - $types = (isset($arr['types']) ? $arr['types'] : 'DF'); | |
| 124 | + $types = (isset($params['types']) ? $params['types'] : 'DF'); | |
| 233 | 125 | |
| 234 | 126 | $listing = $folder->get_listing(1, $types); |
| 235 | 127 | |
| 236 | - $result = ListController::_processListing($listing, 'folderContents', $arr); | |
| 128 | + $result = $this->_processListing($listing, 'folderContents', $params); | |
| 237 | 129 | |
| 238 | - $this->response= $result; | |
| 130 | + $this->setResponse($result); | |
| 239 | 131 | } |
| 240 | 132 | |
| 241 | - private function _processListing($listing, $type, $arr) | |
| 242 | - { | |
| 133 | + | |
| 134 | + private function _processListing($listing, $type, $arr){ | |
| 243 | 135 | $result = array(); |
| 244 | 136 | $methodToIncludeItem = '_processItemInclusion_'.$type; |
| 245 | 137 | |
| ... | ... | @@ -269,13 +161,13 @@ class clientTools_service_list_361 extends clientTools_service { |
| 269 | 161 | { |
| 270 | 162 | case 'W': |
| 271 | 163 | $canWrite = true; |
| 272 | - $perms .= _kt('write, '); | |
| 164 | + $perms .= $this->xlate('write, '); | |
| 273 | 165 | break; |
| 274 | 166 | case 'R': |
| 275 | - $perms .= _kt('read, '); | |
| 167 | + $perms .= $this->xlate('read, '); | |
| 276 | 168 | break; |
| 277 | 169 | case 'A': |
| 278 | - $perms .= _kt('add folder, '); | |
| 170 | + $perms .= $this->xlate('add folder, '); | |
| 279 | 171 | break; |
| 280 | 172 | // default: |
| 281 | 173 | // $perms .= strtoupper($permissions{$j}); |
| ... | ... | @@ -292,14 +184,14 @@ class clientTools_service_list_361 extends clientTools_service { |
| 292 | 184 | //folders |
| 293 | 185 | if ($itemType == 'F') |
| 294 | 186 | { |
| 295 | - $qtip .= _kt('Folder name').": {$filename}<br>"; | |
| 187 | + $qtip .= $this->xlate('Folder name').": {$filename}<br>"; | |
| 296 | 188 | $class = 'folder'; |
| 297 | 189 | |
| 298 | 190 | //permissions |
| 299 | - $qtip .= _kt('Permissions:') . " {$perms}<br>"; | |
| 191 | + $qtip .= $this->xlate('Permissions:') . " {$perms}<br>"; | |
| 300 | 192 | |
| 301 | 193 | //comment |
| 302 | - $qtip .= $canWrite ? _kt('You may add content to this folder') : _kt('You may not add content to this folder'); | |
| 194 | + $qtip .= $canWrite ? $this->xlate('You may add content to this folder') : $this->xlate('You may not add content to this folder'); | |
| 303 | 195 | } |
| 304 | 196 | |
| 305 | 197 | //documents |
| ... | ... | @@ -331,19 +223,19 @@ class clientTools_service_list_361 extends clientTools_service { |
| 331 | 223 | else |
| 332 | 224 | { |
| 333 | 225 | //filename |
| 334 | - $qtip .= _kt('Filename') . ": {$filename}<br>"; | |
| 226 | + $qtip .= $this->xlate('Filename') . ": {$filename}<br>"; | |
| 335 | 227 | |
| 336 | 228 | //size |
| 337 | - $qtip .= _kt('File Size') . ": " . fsize_desc($item['filesize']) . "<br>"; | |
| 229 | + $qtip .= $this->xlate('File Size') . ": " . fsize_desc($item['filesize']) . "<br>"; | |
| 338 | 230 | |
| 339 | 231 | //last modified |
| 340 | - $qtip .= _kt('Modified') . ": {$item['modified_date']}<br>"; | |
| 232 | + $qtip .= $this->xlate('Modified') . ": {$item['modified_date']}<br>"; | |
| 341 | 233 | |
| 342 | 234 | //owner |
| 343 | - $qtip .= _kt('Owner') . ": {$item['created_by']}<br>"; | |
| 235 | + $qtip .= $this->xlate('Owner') . ": {$item['created_by']}<br>"; | |
| 344 | 236 | |
| 345 | 237 | //version |
| 346 | - $qtip .= _kt('Version') . ": {$item['version']}<br>"; | |
| 238 | + $qtip .= $this->xlate('Version') . ": {$item['version']}<br>"; | |
| 347 | 239 | |
| 348 | 240 | //immutability |
| 349 | 241 | if (bool2str(strtolower($item['is_immutable'])) == 'true') |
| ... | ... | @@ -355,49 +247,50 @@ class clientTools_service_list_361 extends clientTools_service { |
| 355 | 247 | //status, i.e. checked out or not, or immutable |
| 356 | 248 | if ($immutable) |
| 357 | 249 | { |
| 358 | - $qtip .= _kt('Status: Immutable') . '<br>'; | |
| 250 | + $qtip .= $this->xlate('Status: Immutable') . '<br>'; | |
| 359 | 251 | } |
| 360 | 252 | else if (strtolower($item['checked_out_by']) != 'n/a' && ($item['checked_out_by'] != '')) |
| 361 | 253 | { |
| 362 | - $qtip .= _kt('Status: Checked out by') . " {$item['checked_out_by']}<br>"; | |
| 254 | + $qtip .= $this->xlate('Status: Checked out by') . " {$item['checked_out_by']}<br>"; | |
| 363 | 255 | } |
| 364 | 256 | else |
| 365 | 257 | { |
| 366 | - $qtip .= _kt('Status: Available') . '<br>'; | |
| 258 | + $qtip .= $this->xlate('Status: Available') . '<br>'; | |
| 367 | 259 | } |
| 368 | 260 | |
| 369 | 261 | //permissions |
| 370 | - $qtip .= _kt('Permissions:') . " {$perms}<br>"; | |
| 262 | + $qtip .= $this->xlate('Permissions:') . " {$perms}<br>"; | |
| 371 | 263 | |
| 372 | 264 | //immutable |
| 373 | 265 | if($immutable) |
| 374 | 266 | { |
| 375 | - $qtip .= _kt('This document is not editable'); | |
| 267 | + $qtip .= $this->xlate('This document is not editable'); | |
| 376 | 268 | } |
| 377 | 269 | else if ($canWrite) |
| 378 | 270 | { |
| 379 | - $qtip .= _kt('You may edit this document'); | |
| 271 | + $qtip .= $this->xlate('You may edit this document'); | |
| 380 | 272 | } |
| 381 | 273 | else |
| 382 | 274 | { |
| 383 | - $qtip .= _kt('This document is not editable'); | |
| 275 | + $qtip .= $this->xlate('This document is not editable'); | |
| 384 | 276 | } |
| 385 | 277 | } |
| 386 | 278 | }//end of if for files |
| 387 | 279 | if($includeMe) |
| 388 | 280 | { |
| 389 | - $result[] = ListController::$methodToIncludeItem($item, $class, $qtip); | |
| 281 | + $result[] = $this->$methodToIncludeItem($item, $class, $qtip); | |
| 390 | 282 | } |
| 391 | 283 | } |
| 392 | 284 | |
| 393 | - $this->response= $result; | |
| 285 | + return $result; | |
| 394 | 286 | } |
| 395 | 287 | |
| 396 | 288 | |
| 397 | 289 | |
| 290 | + | |
| 398 | 291 | private function _processItemInclusion_folderContents($item, $class, $qtip) |
| 399 | 292 | { |
| 400 | - $this->response= array ( | |
| 293 | + return array ( | |
| 401 | 294 | 'text' => htmlspecialchars($item['title']), |
| 402 | 295 | 'originaltext' => $item['title'], |
| 403 | 296 | 'id' => ($item['item_type'] == 'F' ? $item['item_type']."_" : "").$item['id'], |
| ... | ... | @@ -415,7 +308,7 @@ class clientTools_service_list_361 extends clientTools_service { |
| 415 | 308 | |
| 416 | 309 | private function _processItemInclusion_search($item, $class, $qtip) |
| 417 | 310 | { |
| 418 | - $this->response= array ( | |
| 311 | + return array ( | |
| 419 | 312 | 'text' => htmlspecialchars($item['title']), |
| 420 | 313 | 'originaltext' => $item['title'], |
| 421 | 314 | 'id' => $item['document_id'], |
| ... | ... | @@ -431,27 +324,23 @@ class clientTools_service_list_361 extends clientTools_service { |
| 431 | 324 | ); |
| 432 | 325 | } |
| 433 | 326 | |
| 327 | + | |
| 434 | 328 | |
| 329 | + public function get_metadata($params) { | |
| 435 | 330 | |
| 436 | - function get_metadata($arr) { | |
| 331 | + $kt = &$this->KT; | |
| 437 | 332 | |
| 438 | - $kt = &$this->get_ktapi($arr['session_id'], $arr['application']); | |
| 439 | - if (is_array($kt)) | |
| 440 | - { | |
| 441 | - $this->response= $kt; | |
| 442 | - } | |
| 443 | - | |
| 444 | - $document_id = (int)$arr['document_id']; | |
| 333 | + $document_id = (int)$params['document_id']; | |
| 445 | 334 | if($document_id > 0) { |
| 446 | - $document = $kt->get_document_by_id($arr['document_id']); | |
| 335 | + $document = $kt->get_document_by_id($params['document_id']); | |
| 447 | 336 | $detail = $document->get_metadata(); |
| 448 | 337 | $document_detail = $document->get_detail(); |
| 449 | 338 | $title = $document_detail['title']; |
| 450 | 339 | $document_type = $document_detail['document_type']; |
| 451 | 340 | |
| 452 | 341 | } else { |
| 453 | - if(isset($arr['document_type'])) { | |
| 454 | - $document_type = $arr['document_type']; | |
| 342 | + if(isset($params['document_type'])) { | |
| 343 | + $document_type = $params['document_type']; | |
| 455 | 344 | } else { |
| 456 | 345 | $document_type = 'Default'; |
| 457 | 346 | } |
| ... | ... | @@ -467,14 +356,14 @@ class clientTools_service_list_361 extends clientTools_service { |
| 467 | 356 | |
| 468 | 357 | // Commented out for timebeing - will be used by 'Save in Format' |
| 469 | 358 | |
| 470 | - if (isset($arr['extensions'])) { | |
| 359 | + if (isset($params['extensions'])) { | |
| 471 | 360 | |
| 472 | 361 | $fileParts = pathinfo($document_detail['filename']); |
| 473 | 362 | |
| 474 | - $items[] = array("name" => "__document_extension", "index" => 0, "value" => strtolower($fileParts['extension']), "control_type" => "lookup", "selection" => explode(',', str_replace('.', '', $arr['extensions']))); | |
| 363 | + $items[] = array("name" => "__document_extension", "index" => 0, "value" => strtolower($fileParts['extension']), "control_type" => "lookup", "selection" => explode(',', str_replace('.', '', $params['extensions']))); | |
| 475 | 364 | } |
| 476 | 365 | |
| 477 | - $document_types = $this->get_documenttypes($arr); | |
| 366 | + $document_types = $this->get_documenttypes($params); | |
| 478 | 367 | $json_document_types = array(); |
| 479 | 368 | foreach($document_types['items'] as $val) { |
| 480 | 369 | $json_document_types[] = $val['name']; |
| ... | ... | @@ -506,18 +395,15 @@ class clientTools_service_list_361 extends clientTools_service { |
| 506 | 395 | } |
| 507 | 396 | |
| 508 | 397 | |
| 509 | - $this->response= array('id' => $title, 'items' => $items, 'count' => count($items)); | |
| 398 | + $this->setResponse(array('id' => $title, 'items' => $items, 'count' => count($items))); | |
| 510 | 399 | |
| 511 | 400 | |
| 512 | 401 | } |
| 513 | 402 | |
| 514 | - function get_documenttypes($arr) { | |
| 515 | 403 | |
| 516 | - $kt = &$this->get_ktapi($arr['session_id'], $arr['application']); | |
| 517 | - if (is_array($kt)) | |
| 518 | - { | |
| 519 | - $this->response= $kt; | |
| 520 | - } | |
| 404 | + public function get_documenttypes($params) { | |
| 405 | + | |
| 406 | + $kt = &$this->KT; | |
| 521 | 407 | |
| 522 | 408 | $detail = $kt->get_documenttypes(); |
| 523 | 409 | $result = array(); |
| ... | ... | @@ -526,50 +412,39 @@ class clientTools_service_list_361 extends clientTools_service { |
| 526 | 412 | if(strtolower(substr($detail[$i], -5)) != 'email') |
| 527 | 413 | { |
| 528 | 414 | $items[] = array( |
| 529 | - 'name' => $detail[$i] | |
| 415 | + 'name' => $detail[$i] | |
| 530 | 416 | ); |
| 531 | 417 | } |
| 532 | 418 | } |
| 533 | - $this->response= array('items' => $items, 'count' => count($items)); | |
| 534 | - | |
| 535 | - | |
| 419 | + $this->setResponse(array('items' => $items, 'count' => count($items))); | |
| 536 | 420 | } |
| 537 | 421 | |
| 538 | - function update_document_type($arr) { | |
| 539 | - $kt = &$this->get_ktapi($arr['session_id'], $arr['application']); | |
| 540 | - if (is_array($kt)) | |
| 541 | - { | |
| 542 | - $this->response= $kt; | |
| 543 | - } | |
| 544 | - $document_id = (int)$arr['document_id']; | |
| 422 | + function update_document_type($params) { | |
| 423 | + $kt = &$this->KT; | |
| 424 | + $document_id = (int)$params['document_id']; | |
| 545 | 425 | if($document_id > 0) { |
| 546 | 426 | $document = $kt->get_document_by_id($document_id); |
| 547 | - $document->change_document_type($arr['document_type']); | |
| 548 | - $this->response= array('status_code' => 0); | |
| 549 | - | |
| 427 | + $document->change_document_type($params['document_type']); | |
| 428 | + $this->setResponse(array('status_code' => 0)); | |
| 429 | + return true; | |
| 430 | + | |
| 431 | + }else{ | |
| 432 | + $this->addError("Invalid document Id : {$document_id}"); | |
| 433 | + $this->setResponse(array('status_code' => 1)); | |
| 434 | + return false; | |
| 550 | 435 | } |
| 551 | 436 | |
| 552 | - $this->response= array('status_code' => 1); | |
| 553 | - | |
| 554 | 437 | } |
| 555 | 438 | |
| 439 | + function download_document($params) { | |
| 556 | 440 | |
| 557 | - function debug($str) { | |
| 558 | - $this->response= true; | |
| 559 | - if(!is_resource($this->dfp)) { | |
| 560 | - $this->dfp = fopen("./debug.log", "a+"); | |
| 561 | - } | |
| 562 | - fwrite($this->dfp, strftime("[DEBUG %Y-%m-%d %H:%M:%S] ").$str."\r\n"); | |
| 563 | - } | |
| 564 | - | |
| 565 | - function download_document($params) | |
| 566 | - { | |
| 567 | - | |
| 568 | - $kt = &$this->get_ktapi($params['session_id'], $params['application']); | |
| 569 | - if (is_array($kt)) | |
| 570 | - { | |
| 571 | - $this->response= array('status_code' => 1); | |
| 572 | - } | |
| 441 | + $kt=&$this->KT; | |
| 442 | + $params['session_id']=$params['session_id']?$params['session_id']:$this->AuthInfo['session']; | |
| 443 | + $params['app_type']=$params['app_type']?$params['app_type']:$this->AuthInfo['appType']; | |
| 444 | + | |
| 445 | + $this->addDebug('parameters',$params); | |
| 446 | + | |
| 447 | + $session_id=$params['session_id']; | |
| 573 | 448 | |
| 574 | 449 | |
| 575 | 450 | $document = &$kt->get_document_by_id($params['document_id']); |
| ... | ... | @@ -580,14 +455,16 @@ class clientTools_service_list_361 extends clientTools_service { |
| 580 | 455 | $response['message'] = $document->getMessage(); |
| 581 | 456 | $this->debug("download_document - cannot get $document_id - " . $document->getMessage(), $session_id); |
| 582 | 457 | |
| 583 | - $this->response= new SOAP_Value('$this->response=',"{urn:$this->namespace}kt_response", $response); | |
| 458 | + $this->setResponse(new SOAP_Value('$this->response=',"{urn:$this->namespace}kt_response", $response)); | |
| 459 | + return; | |
| 584 | 460 | } |
| 585 | 461 | |
| 586 | 462 | $result = $document->download(); |
| 587 | 463 | if (PEAR::isError($result)) |
| 588 | 464 | { |
| 589 | 465 | $response['message'] = $result->getMessage(); |
| 590 | - $this->response= array('status_code' => 1, 'message' => $result->getMessage()); | |
| 466 | + $this->setResponse(array('status_code' => 1, 'message' => $result->getMessage())); | |
| 467 | + return; | |
| 591 | 468 | } |
| 592 | 469 | |
| 593 | 470 | $session = &$kt->get_session(); |
| ... | ... | @@ -599,32 +476,37 @@ class clientTools_service_list_361 extends clientTools_service { |
| 599 | 476 | $response['status_code'] = 0; |
| 600 | 477 | $response['message'] = $url; |
| 601 | 478 | $response['filename'] = $docname; |
| 602 | - $this->response= $response; | |
| 479 | + $this->setResponse($response); | |
| 603 | 480 | } |
| 604 | 481 | |
| 605 | - function checkout_document($params) | |
| 606 | - { | |
| 607 | - //$this->debug("checkout_document('$session_id',$document_id,'$reason')"); | |
| 608 | - | |
| 482 | + | |
| 483 | + /** | |
| 484 | + * Checkout a Document | |
| 485 | + * params contains: | |
| 486 | + * document_id the id of the document | |
| 487 | + * reason the checkout reason | |
| 488 | + * | |
| 489 | + * @param array $params | |
| 490 | + * | |
| 491 | + */ | |
| 492 | + function checkout_document($params){ | |
| 609 | 493 | $responseType = 'kt_response'; |
| 610 | - | |
| 611 | - $kt = &$this->get_ktapi($params['session_id'], $params['application']); | |
| 612 | - if (is_array($kt)) | |
| 613 | - { | |
| 614 | - $this->response= array('status_code' => 1); | |
| 615 | - } | |
| 494 | + $kt=&$this->KT; | |
| 616 | 495 | |
| 617 | 496 | $document = &$kt->get_document_by_id($params['document_id']); |
| 618 | 497 | if (PEAR::isError($document)) |
| 619 | 498 | { |
| 620 | - $this->debug("checkout_document - cannot get documentid {$params['document_id']} - " . $document->getMessage()); | |
| 621 | - $this->response= array('status_code' => 1, 'message' => $document->getMessage()); | |
| 499 | + $this->addError("checkout_document - cannot get documentid {$params['document_id']} - " . $document->getMessage()); | |
| 500 | + $this->setResponse(array('status_code' => 1, 'message' => $document->getMessage())); | |
| 501 | + return; | |
| 622 | 502 | } |
| 623 | 503 | |
| 624 | 504 | $result = $document->checkout($params['reason']); |
| 625 | 505 | if (PEAR::isError($result)) |
| 626 | 506 | { |
| 627 | - $this->response= array('status_code' => 1, 'message' => $result->getMessage()); | |
| 507 | + $this->addError($result->getMessage()); | |
| 508 | + $this->setResponse(array('status_code' => 1, 'message' => $result->getMessage())); | |
| 509 | + return; | |
| 628 | 510 | } |
| 629 | 511 | |
| 630 | 512 | $url = ''; |
| ... | ... | @@ -636,12 +518,69 @@ class clientTools_service_list_361 extends clientTools_service { |
| 636 | 518 | $url = $download_manager->allow_download($document); |
| 637 | 519 | } |
| 638 | 520 | |
| 639 | - $this->response= array('status_code' => 0, 'message' => $url); | |
| 521 | + $this->setResponse(array('status_code' => 0, 'message' => $url)); | |
| 640 | 522 | } |
| 641 | 523 | |
| 642 | 524 | |
| 643 | - function add_document_with_metadata($arr) | |
| 644 | - { | |
| 525 | + /** | |
| 526 | + * Checkin Document //TODO: Find out how upload works | |
| 527 | + * params contains: | |
| 528 | + * document_id | |
| 529 | + * filename | |
| 530 | + * reason | |
| 531 | + * tempfilename | |
| 532 | + * | |
| 533 | + * @param array $params | |
| 534 | + */ | |
| 535 | + function checkin_document($params){ | |
| 536 | + $session_id = $this->AuthInfo['session']; | |
| 537 | + $document_id = $params['document_id']; | |
| 538 | + $filename = $params['filename']; | |
| 539 | + $reason = $params['reason']; | |
| 540 | + $tempfilename = $params['tempfilename']; | |
| 541 | + $application = $this->AuthInfo['appType']; | |
| 542 | + | |
| 543 | + $this->addDebug('Checkin',"checkin_document('$session_id',$document_id,'$filename','$reason','$tempfilename', '$application')"); | |
| 544 | + $kt = &$this->KT; | |
| 545 | + | |
| 546 | + // we need to add some security to ensure that people don't frig the checkin process to access restricted files. | |
| 547 | + // possibly should change 'tempfilename' to be a hash or id of some sort if this is troublesome. | |
| 548 | + $upload_manager = new KTUploadManager(); | |
| 549 | + if (!$upload_manager->is_valid_temporary_file($tempfilename)) | |
| 550 | + { | |
| 551 | + $this->setResponse(array('status_code' => 12)); | |
| 552 | + return; | |
| 553 | + } | |
| 554 | + | |
| 555 | + $document = &$kt->get_document_by_id($document_id); | |
| 556 | + if (PEAR::isError($document)) | |
| 557 | + { | |
| 558 | + $this->setResponse(array('status_code' => 13)); | |
| 559 | + } | |
| 560 | + | |
| 561 | + // checkin | |
| 562 | + $result = $document->checkin($filename, $reason, $tempfilename, false); | |
| 563 | + if (PEAR::isError($result)) | |
| 564 | + { | |
| 565 | + $this->setResponse(array('status_code' => 14)); | |
| 566 | + } | |
| 567 | + | |
| 568 | + // get status after checkin | |
| 569 | + //$this->response= $this->get_document_detail($session_id, $document_id); | |
| 570 | + $detail = $document->get_detail(); | |
| 571 | + $detail['status_code'] = 0; | |
| 572 | + $detail['message'] = ''; | |
| 573 | + | |
| 574 | + $this->setResponse($detail); | |
| 575 | + } | |
| 576 | + | |
| 577 | + | |
| 578 | + /** | |
| 579 | + * Upload a document | |
| 580 | + * | |
| 581 | + * @param unknown_type $arr | |
| 582 | + */ | |
| 583 | + function add_document_with_metadata($arr){ | |
| 645 | 584 | $session_id = $arr['session_id']; |
| 646 | 585 | //error_reporting(E_ALL); |
| 647 | 586 | $metadata = array(); |
| ... | ... | @@ -680,7 +619,7 @@ class clientTools_service_list_361 extends clientTools_service { |
| 680 | 619 | $this->response= $update_result; |
| 681 | 620 | } |
| 682 | 621 | |
| 683 | - $kt = &$this->get_ktapi($arr['session_id'], $arr['application']); | |
| 622 | + $kt = &$this->KT; | |
| 684 | 623 | if (is_array($kt)) |
| 685 | 624 | { |
| 686 | 625 | $this->response= array('status_code' => 1); |
| ... | ... | @@ -703,6 +642,33 @@ class clientTools_service_list_361 extends clientTools_service { |
| 703 | 642 | $this->response= array('status_code' => 0, 'document_id' => $document_id, 'content_id' => $content_id); |
| 704 | 643 | } |
| 705 | 644 | |
| 645 | +} | |
| 646 | + | |
| 647 | + | |
| 648 | +/* | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + function debug($str) { | |
| 662 | + $this->response= true; | |
| 663 | + if(!is_resource($this->dfp)) { | |
| 664 | + $this->dfp = fopen("./debug.log", "a+"); | |
| 665 | + } | |
| 666 | + fwrite($this->dfp, strftime("[DEBUG %Y-%m-%d %H:%M:%S] ").$str."\r\n"); | |
| 667 | + } | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 706 | 672 | function add_document_params($params) |
| 707 | 673 | { |
| 708 | 674 | $session_id = $params['session_id']; |
| ... | ... | @@ -714,7 +680,7 @@ class clientTools_service_list_361 extends clientTools_service { |
| 714 | 680 | $application = $params['application']; |
| 715 | 681 | |
| 716 | 682 | $this->debug('Entered add_document'); |
| 717 | - $kt = &$this->get_ktapi($session_id, $application); | |
| 683 | + $kt = &$this->get$this->xlateapi($session_id, $application); | |
| 718 | 684 | if (is_array($kt)) |
| 719 | 685 | { |
| 720 | 686 | $this->response= array('status_code' => 1); |
| ... | ... | @@ -756,7 +722,7 @@ class clientTools_service_list_361 extends clientTools_service { |
| 756 | 722 | function add_document($session_id, $folder_id, $title, $filename, $documenttype, $tempfilename, $application) |
| 757 | 723 | { |
| 758 | 724 | $this->debug('Entered add_document'); |
| 759 | - $kt = &$this->get_ktapi($session_id, $application); | |
| 725 | + $kt = &$this->get$this->xlateapi($session_id, $application); | |
| 760 | 726 | if (is_array($kt)) |
| 761 | 727 | { |
| 762 | 728 | $this->response= array('status_code' => 1); |
| ... | ... | @@ -794,55 +760,10 @@ class clientTools_service_list_361 extends clientTools_service { |
| 794 | 760 | } |
| 795 | 761 | |
| 796 | 762 | |
| 797 | - function checkin_document($params) | |
| 798 | - { | |
| 799 | - $session_id = $params['session_id']; | |
| 800 | - $document_id = $params['document_id']; | |
| 801 | - $filename = $params['filename']; | |
| 802 | - $reason = $params['reason']; | |
| 803 | - $tempfilename = $params['tempfilename']; | |
| 804 | - $application = $params['application']; | |
| 805 | - | |
| 806 | - $this->debug("checkin_document('$session_id',$document_id,'$filename','$reason','$tempfilename', '$application')"); | |
| 807 | - $kt = &$this->get_ktapi($session_id, $application ); | |
| 808 | - if (is_array($kt)) | |
| 809 | - { | |
| 810 | - $this->response= array('status_code' => 11); | |
| 811 | - } | |
| 812 | - | |
| 813 | - // we need to add some security to ensure that people don't frig the checkin process to access restricted files. | |
| 814 | - // possibly should change 'tempfilename' to be a hash or id of some sort if this is troublesome. | |
| 815 | - $upload_manager = new KTUploadManager(); | |
| 816 | - if (!$upload_manager->is_valid_temporary_file($tempfilename)) | |
| 817 | - { | |
| 818 | - $this->response= array('status_code' => 12); | |
| 819 | - } | |
| 820 | - | |
| 821 | - $document = &$kt->get_document_by_id($document_id); | |
| 822 | - if (PEAR::isError($document)) | |
| 823 | - { | |
| 824 | - $this->response= array('status_code' => 13); | |
| 825 | - } | |
| 826 | - | |
| 827 | - // checkin | |
| 828 | - $result = $document->checkin($filename, $reason, $tempfilename, false); | |
| 829 | - if (PEAR::isError($result)) | |
| 830 | - { | |
| 831 | - $this->response= array('status_code' => 14); | |
| 832 | - } | |
| 833 | - | |
| 834 | - // get status after checkin | |
| 835 | - //$this->response= $this->get_document_detail($session_id, $document_id); | |
| 836 | - $detail = $document->get_detail(); | |
| 837 | - $detail['status_code'] = 0; | |
| 838 | - $detail['message'] = ''; | |
| 839 | - | |
| 840 | - $this->response= $detail; | |
| 841 | - } | |
| 842 | 763 | |
| 843 | 764 | function delete_document($session_id, $document_id, $reason, $application) |
| 844 | 765 | { |
| 845 | - $kt = &$this->get_ktapi($session_id, $application ); | |
| 766 | + $kt = &$this->get$this->xlateapi($session_id, $application ); | |
| 846 | 767 | if (is_array($kt)) |
| 847 | 768 | { |
| 848 | 769 | $this->response= array('status_code' => 1); |
| ... | ... | @@ -869,7 +790,7 @@ class clientTools_service_list_361 extends clientTools_service { |
| 869 | 790 | function update_document_metadata($session_id, $document_id, $metadata, $application, $sysdata=null) |
| 870 | 791 | { |
| 871 | 792 | $this->debug('entered update_document_metadata'); |
| 872 | - $kt = &$this->get_ktapi($session_id, $application ); | |
| 793 | + $kt = &$this->get$this->xlateapi($session_id, $application ); | |
| 873 | 794 | $responseType = 'kt_response'; |
| 874 | 795 | if ($this->version >= 2) |
| 875 | 796 | { |
| ... | ... | @@ -962,7 +883,7 @@ class clientTools_service_list_361 extends clientTools_service { |
| 962 | 883 | |
| 963 | 884 | function search($arr) |
| 964 | 885 | { |
| 965 | - $kt = &$this->get_ktapi($arr['session_id'], $arr['application']); | |
| 886 | + $kt = &$this->get$this->xlateapi($arr['session_id'], $arr['application']); | |
| 966 | 887 | |
| 967 | 888 | if (is_array($kt)) |
| 968 | 889 | { |
| ... | ... | @@ -977,11 +898,11 @@ class clientTools_service_list_361 extends clientTools_service { |
| 977 | 898 | |
| 978 | 899 | $result[] = array |
| 979 | 900 | ( |
| 980 | - 'text' => _kt("No results found"), | |
| 901 | + 'text' => $this->xlate("No results found"), | |
| 981 | 902 | 'id' => ($listing[$i]['item_type'] == 'F' ? $listing[$i]['item_type']."_" : "").$listing[$i]['id'], |
| 982 | 903 | 'leaf' => true, |
| 983 | 904 | 'relevance' => 0, |
| 984 | - 'qtip'=> _kt("Please retry your search") | |
| 905 | + 'qtip'=> $this->xlate("Please retry your search") | |
| 985 | 906 | ); |
| 986 | 907 | } else { |
| 987 | 908 | $result = array_slice($result, 0, 200); |
| ... | ... | @@ -1026,7 +947,7 @@ class clientTools_service_list_361 extends clientTools_service { |
| 1026 | 947 | $this->response= $update_result; |
| 1027 | 948 | } |
| 1028 | 949 | |
| 1029 | - $kt = &$this->get_ktapi($arr['session_id']); | |
| 950 | + $kt = &$this->get$this->xlateapi($arr['session_id']); | |
| 1030 | 951 | if (is_array($kt)) |
| 1031 | 952 | { |
| 1032 | 953 | $this->response= $kt; |
| ... | ... | @@ -1050,7 +971,7 @@ class clientTools_service_list_361 extends clientTools_service { |
| 1050 | 971 | function check_document_title($arr) |
| 1051 | 972 | { |
| 1052 | 973 | |
| 1053 | - $kt = &$this->get_ktapi($arr['session_id'], $arr['application'] ); | |
| 974 | + $kt = &$this->get$this->xlateapi($arr['session_id'], $arr['application'] ); | |
| 1054 | 975 | |
| 1055 | 976 | |
| 1056 | 977 | if (is_array($kt)) |
| ... | ... | @@ -1079,7 +1000,7 @@ class clientTools_service_list_361 extends clientTools_service { |
| 1079 | 1000 | { |
| 1080 | 1001 | //$this->debug("undo_document_checkout({$params['session_id']}, {$params['document_id']}, {$params['reason']})"); |
| 1081 | 1002 | |
| 1082 | - $kt = &$this->get_ktapi($params['session_id'], $params['application'] ); | |
| 1003 | + $kt = &$this->get$this->xlateapi($params['session_id'], $params['application'] ); | |
| 1083 | 1004 | if (is_array($kt)) |
| 1084 | 1005 | { |
| 1085 | 1006 | $this->response= array('status_code' => 1); |
| ... | ... | @@ -1104,7 +1025,7 @@ class clientTools_service_list_361 extends clientTools_service { |
| 1104 | 1025 | |
| 1105 | 1026 | function get_users_groups($params) |
| 1106 | 1027 | { |
| 1107 | - $kt = &$this->get_ktapi($params['session_id'],$params['application'] ); | |
| 1028 | + $kt = &$this->get$this->xlateapi($params['session_id'],$params['application'] ); | |
| 1108 | 1029 | if (is_array($kt)) |
| 1109 | 1030 | { |
| 1110 | 1031 | $this->response= array('status_code' => 1); |
| ... | ... | @@ -1145,7 +1066,7 @@ class clientTools_service_list_361 extends clientTools_service { |
| 1145 | 1066 | |
| 1146 | 1067 | function send_email($params) |
| 1147 | 1068 | { |
| 1148 | - $kt = &$this->get_ktapi($params['session_id'], $params['application'] ); | |
| 1069 | + $kt = &$this->get$this->xlateapi($params['session_id'], $params['application'] ); | |
| 1149 | 1070 | if (is_array($kt)) |
| 1150 | 1071 | { |
| 1151 | 1072 | $this->response= array('status_code' => 1); |
| ... | ... | @@ -1212,7 +1133,7 @@ class clientTools_service_list_361 extends clientTools_service { |
| 1212 | 1133 | |
| 1213 | 1134 | function is_latest_version($params) |
| 1214 | 1135 | { |
| 1215 | - $kt = &$this->get_ktapi($params['session_id'], $params['application']); | |
| 1136 | + $kt=&$this->KT; | |
| 1216 | 1137 | |
| 1217 | 1138 | |
| 1218 | 1139 | if (is_array($kt)) |
| ... | ... | @@ -1231,7 +1152,7 @@ class clientTools_service_list_361 extends clientTools_service { |
| 1231 | 1152 | |
| 1232 | 1153 | function check_permission($params) |
| 1233 | 1154 | { |
| 1234 | - $kt = &$this->get_ktapi($params['session_id'], $params['application']); | |
| 1155 | + $kt=&$this->KT; | |
| 1235 | 1156 | |
| 1236 | 1157 | |
| 1237 | 1158 | if (is_array($kt)) |
| ... | ... | @@ -1260,7 +1181,7 @@ class clientTools_service_list_361 extends clientTools_service { |
| 1260 | 1181 | |
| 1261 | 1182 | function renamefolder($params) |
| 1262 | 1183 | { |
| 1263 | - $kt = &$this->get_ktapi($params['session_id'], $params['application'] ); | |
| 1184 | + $kt = &$this->get$this->xlateapi($params['session_id'], $params['application'] ); | |
| 1264 | 1185 | if (is_array($kt)) |
| 1265 | 1186 | { |
| 1266 | 1187 | $this->response= array('status_code' => 1); |
| ... | ... | @@ -1269,16 +1190,16 @@ class clientTools_service_list_361 extends clientTools_service { |
| 1269 | 1190 | $response = $kt->rename_folder($params['currentfolderid'], $params['newname']); |
| 1270 | 1191 | |
| 1271 | 1192 | if ($response['status_code'] == 0) { |
| 1272 | - $this->response= array('status_code' => 0, 'status'=>'folderupdated', 'icon'=>'success', 'title'=>_kt('Folder Renamed'), 'message'=>_kt('Folder has been successfully renamed')); | |
| 1193 | + $this->response= array('status_code' => 0, 'status'=>'folderupdated', 'icon'=>'success', 'title'=>$this->xlate('Folder Renamed'), 'message'=>$this->xlate('Folder has been successfully renamed')); | |
| 1273 | 1194 | } else { |
| 1274 | - $this->response= array('status_code' => 1, 'status'=>'error', 'icon'=>'failure', 'title'=>_kt('Unable to rename folder'), 'message'=>_kt('Unable to rename folder')); //$response['message'] | |
| 1195 | + $this->response= array('status_code' => 1, 'status'=>'error', 'icon'=>'failure', 'title'=>$this->xlate('Unable to rename folder'), 'message'=>$this->xlate('Unable to rename folder')); //$response['message'] | |
| 1275 | 1196 | } |
| 1276 | 1197 | |
| 1277 | 1198 | } |
| 1278 | 1199 | |
| 1279 | 1200 | function addfolder($params) |
| 1280 | 1201 | { |
| 1281 | - $kt = &$this->get_ktapi($params['session_id'], $params['application'] ); | |
| 1202 | + $kt = &$this->get$this->xlateapi($params['session_id'], $params['application'] ); | |
| 1282 | 1203 | if (is_array($kt)) |
| 1283 | 1204 | { |
| 1284 | 1205 | $this->response= array('status_code' => 1); |
| ... | ... | @@ -1288,16 +1209,16 @@ class clientTools_service_list_361 extends clientTools_service { |
| 1288 | 1209 | $response = $kt->create_folder($params['currentfolderid'], $params['newname']); |
| 1289 | 1210 | |
| 1290 | 1211 | if ($response['status_code'] == 0) { |
| 1291 | - $this->response= array('status_code' => 0, 'status'=>'folderupdated', 'icon'=>'success', 'title'=>_kt('Folder Created'), 'message'=>_kt('Folder has been successfully created'), 'id' =>$response['results']['id']); //$params['newname']);// | |
| 1212 | + $this->response= array('status_code' => 0, 'status'=>'folderupdated', 'icon'=>'success', 'title'=>$this->xlate('Folder Created'), 'message'=>$this->xlate('Folder has been successfully created'), 'id' =>$response['results']['id']); //$params['newname']);// | |
| 1292 | 1213 | } else { |
| 1293 | - $this->response= array('status_code' => 1, 'status'=>'error', 'icon'=>'failure', 'title'=>_kt('Unable to create folder'), 'message'=>_kt('Unable to create folder')); //$response['message'] | |
| 1214 | + $this->response= array('status_code' => 1, 'status'=>'error', 'icon'=>'failure', 'title'=>$this->xlate('Unable to create folder'), 'message'=>$this->xlate('Unable to create folder')); //$response['message'] | |
| 1294 | 1215 | } |
| 1295 | 1216 | |
| 1296 | 1217 | } |
| 1297 | 1218 | |
| 1298 | 1219 | function deletefolder($params) |
| 1299 | 1220 | { |
| 1300 | - $kt = &$this->get_ktapi($params['session_id'], $params['application'] ); | |
| 1221 | + $kt = &$this->get$this->xlateapi($params['session_id'], $params['application'] ); | |
| 1301 | 1222 | if (is_array($kt)) |
| 1302 | 1223 | { |
| 1303 | 1224 | $this->response= array('status_code' => 1); |
| ... | ... | @@ -1306,16 +1227,16 @@ class clientTools_service_list_361 extends clientTools_service { |
| 1306 | 1227 | $response = $kt->delete_folder($params['folderid'], 'Deleted from office addin'); |
| 1307 | 1228 | |
| 1308 | 1229 | if ($response['status_code'] == 0) { |
| 1309 | - $this->response= array('status_code' => 0, 'status'=>'folderdeleted', 'icon'=>'success', 'title'=>_kt('Folder Deleted'), 'message'=>_kt('Folder has been successfully deleted')); | |
| 1230 | + $this->response= array('status_code' => 0, 'status'=>'folderdeleted', 'icon'=>'success', 'title'=>$this->xlate('Folder Deleted'), 'message'=>$this->xlate('Folder has been successfully deleted')); | |
| 1310 | 1231 | } else { |
| 1311 | - $this->response= array('status_code' => 1, 'status'=>'error', 'icon'=>'failure', 'title'=>_kt('Unable to delete folder'), 'message'=>_kt('Unable to delete folder')); //$response['message'] | |
| 1232 | + $this->response= array('status_code' => 1, 'status'=>'error', 'icon'=>'failure', 'title'=>$this->xlate('Unable to delete folder'), 'message'=>$this->xlate('Unable to delete folder')); //$response['message'] | |
| 1312 | 1233 | } |
| 1313 | 1234 | |
| 1314 | 1235 | } |
| 1315 | 1236 | |
| 1316 | 1237 | function candeletefolder($arr) |
| 1317 | 1238 | { |
| 1318 | - $kt = &$this->get_ktapi($arr['session_id'], $arr['application']); | |
| 1239 | + $kt = &$this->get$this->xlateapi($arr['session_id'], $arr['application']); | |
| 1319 | 1240 | |
| 1320 | 1241 | if (is_array($kt)) |
| 1321 | 1242 | { | ... | ... |
webservice/clienttools/services/3.6.1/server.service.php renamed to webservice/clienttools/services/3.6.1/server.php
| 1 | 1 | <?php |
| 2 | -require_once(str_replace('/','\\',str_replace('//','/',dirname(__FILE__).'/')."../../clientTools_service.php")); | |
| 3 | - | |
| 4 | -class clientTools_service_server_361 extends clientTools_service{ | |
| 2 | +class server extends client_service { | |
| 5 | 3 | public function status(){ |
| 6 | 4 | |
| 7 | 5 | } |
| 6 | + | |
| 7 | + public function ping(){ | |
| 8 | + $this->addResponse('pong',time()); | |
| 9 | + } | |
| 8 | 10 | |
| 9 | 11 | public function getToken(){ |
| 10 | 12 | |
| ... | ... | @@ -13,11 +15,8 @@ class clientTools_service_server_361 extends clientTools_service{ |
| 13 | 15 | public function phpInfo(){ |
| 14 | 16 | ob_start(); |
| 15 | 17 | phpinfo(); |
| 16 | - $this->response['phpinfo']=ob_get_clean(); | |
| 18 | + $this->addResponse('phpinfo',ob_get_clean()); | |
| 17 | 19 | } |
| 18 | 20 | |
| 19 | - public function getServiceObject(){ | |
| 20 | - $this->response['serviceobject']=new clientTools_service_server_361(&$this->kt,&$this->session,&$this->session_id); | |
| 21 | - } | |
| 22 | 21 | } |
| 23 | 22 | ?> |
| 24 | 23 | \ No newline at end of file | ... | ... |