Commit 3506e6515e478af7ea69246b58495c8f6890ee90

Authored by Jarrett Jordaan
2 parents f8e9e0ae c12dcc60

Merge branch 'edge' of git@github.com:ktgit/knowledgetree into edge

webservice/clienttools/services/3.6.1/auth.php
... ... @@ -20,13 +20,32 @@ class auth extends client_service {
20 20 $kt =& $this->KT;
21 21  
22 22 if ($username != 'admin') {
23   - require_once(KT_DIR . '/plugins/wintools/baobabkeyutil.inc.php');
  23 + //$this->addDebug('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@','');
  24 + if(!file_exists(KT_DIR . '/plugins/wintools/baobabkeyutil.inc.php')){
  25 + $this->setResponse(array('authenticated'=> false, 'message'=> 'baobabkeyutil not found - this appears to be a community install.'));
  26 + $this->addError('baobabkeyutil not found - this appears to be a community install.');
  27 + return;
  28 + }
  29 + try{
  30 + require_once(KT_DIR . '/plugins/wintools/baobabkeyutil.inc.php');
  31 +
  32 + }catch(Exception $e){
  33 + $this->addError('could not include plugins/wintools/baobabkeyutil.inc.php');
  34 + $this->setResponse(array('authenticated'=> false, 'message'=> 'Baobab load error'));
  35 + return;
  36 + }
24 37  
25   - if (!BaobabKeyUtil::checkIfLicensed(true)) {
26   - $this->setResponse(array('authenticated'=> false, 'message'=> 'license_expired'));
27   - $this->addError('Licence Expired');
28   - return false;
29   - }
  38 + try{
  39 + if (!BaobabKeyUtil::checkIfLicensed(true)) {
  40 + $this->setResponse(array('authenticated'=> false, 'message'=> 'license_expired'));
  41 + $this->addError('Licence Expired');
  42 + return false;
  43 + }
  44 + }catch(Exception $e){
  45 + $this->addError('could not execute BaobabKeyUtil::checkIfLicensed');
  46 + $this->setResponse(array('authenticated'=> false, 'message'=> 'BaobabKeyUtil::checkIfLicensed error'));
  47 + return;
  48 + }
30 49 }
31 50  
32 51 $user=$kt->get_user_object_by_username($username);
... ... @@ -60,6 +79,7 @@ class auth extends client_service {
60 79  
61 80 public function japiLogin(){
62 81 global $default;
  82 +
63 83 $user=$this->KT->get_user_object_by_username($this->AuthInfo['user']);
64 84 $ret=array(
65 85 'fullName' =>PEAR::isError($user)?'':$user->getName()
... ...
webservice/clienttools/services/3.6.1/kt.php
... ... @@ -434,7 +434,16 @@ class kt extends client_service {
434 434  
435 435 }
436 436  
437   - function download_document($params) {
  437 + /**
  438 + * Get a url for downloading the specified document
  439 + * Parameters:
  440 + * session_id
  441 + * app_type
  442 + * document_id
  443 + *
  444 + * @param unknown_type $params
  445 + */
  446 + function download_document($params,$returnResult=false) {
438 447  
439 448 $kt=&$this->KT;
440 449 $params['session_id']=$params['session_id']?$params['session_id']:$this->AuthInfo['session'];
... ... @@ -484,10 +493,37 @@ class kt extends client_service {
484 493 $response['status_code']=0;
485 494 $response['message']=$url.'&apptype='.$params['app_type'];
486 495 $response['filename']=$docname;
  496 +
487 497 $this->addDebug('effective params',$params);
  498 +
  499 + if($returnResult){
  500 + return $response;
  501 + }else{
  502 + $this->setResponse($response);
  503 + }
  504 + }
  505 +
  506 + /**
  507 + * Get download URLS for multiple documents
  508 + * params contains:
  509 + * app_type
  510 + * documents = array of doc_id
  511 + *
  512 + * @param unknown_type $params
  513 + */
  514 + public function download_multiple_documents($params){
  515 + $response=array();
  516 + foreach($params['documents'] as $docId){
  517 + $ret=$this->download_document(array('document_id'=>$docId,'app_type'=>$params['app_type']),true);
  518 + $rec=array(
  519 + 'filename' =>$ret['filename'],
  520 + 'url' =>$ret['message'],
  521 + 'succeeded' =>$ret['status_code']==0?true:false
  522 + );
  523 + if(is_array($ret))$response[$docId]=$rec;
  524 + }
488 525 $this->setResponse($response);
489 526 }
490   -
491 527  
492 528 /**
493 529 * Checkout a Document
... ... @@ -982,7 +1018,11 @@ class kt extends client_service {
982 1018 $this->setResponse(array('status'=>'norecipients'));
983 1019 return false;
984 1020 }else{
985   - $document->email($recipientsList, $message, TRUE); // true to attach document
  1021 + $result = $document->email($recipientsList, $message, TRUE); // true to attach document
  1022 + if (PEAR::isError($result)) {
  1023 + $this->setResponse(array('status'=>$result->getMessage()));;
  1024 + return false;
  1025 + }
986 1026 $this->setResponse(array('status'=>'documentemailed'));
987 1027 }
988 1028 return true;
... ...