Commit 9dbb7b14b9f3c2c74dce3887446ff1e750dd7cee

Authored by Conrad Vermeulen
1 parent 1d0288e1

WSA-65

"Remove php5 specific modifiers on functions so that web services works on both 3.4.x and 3.5.x"
Updated. The webservice must not have any try/catch handling as this does not parse at all in php4

Committed By: Conrad Vermeulen
Reviewed By: Martin Kirsten

git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@7691 c91229c3-7414-0410-bfa2-8a42b809f60b
ktwebservice/webservice.php
@@ -3953,65 +3953,34 @@ class KTWebService @@ -3953,65 +3953,34 @@ class KTWebService
3953 return new SOAP_Value('return',"{urn:$this->namespace}kt_search_response", $kt); 3953 return new SOAP_Value('return',"{urn:$this->namespace}kt_search_response", $kt);
3954 } 3954 }
3955 $response=array( 3955 $response=array(
3956 - 'status_code'=>KTWS_ERR_INVALID_DOCUMENT, 3956 + 'status_code'=>KTWS_ERR_PROBLEM,
3957 'message'=>'', 3957 'message'=>'',
3958 'hits'=>array() 3958 'hits'=>array()
3959 ); 3959 );
3960 3960
3961 - $noText = (stripos($options,'notext') !== false);  
3962 - $results = array();  
3963 -  
3964 - try 3961 + if (!defined('HAS_SEARCH_FUNCTIONALITY'))
3965 { 3962 {
3966 - $expr = parseExpression($query);  
3967 -  
3968 - $rs = $expr->evaluate();  
3969 - usort($rs, 'rank_compare');  
3970 -  
3971 - $results = array();  
3972 - foreach($rs as $hit)  
3973 - {  
3974 - $item = array(  
3975 - 'document_id' => (int) $hit->DocumentID,  
3976 - 'title' => (string) $hit->Title,  
3977 - 'relevance' => (float) $hit->Rank,  
3978 - 'text' => (string) $noText?'':$hit->Text,  
3979 - 'filesize' => (int) $hit->Filesize,  
3980 - 'fullpath' => (string) $hit->FullPath,  
3981 - 'version' => (string) $hit->Version,  
3982 - 'filename' => (string) $hit->Filename,  
3983 - 'checked_out_by' => (string) $hit->CheckedOutUser,  
3984 - 'checked_out_date' => (string) $hit->DateCheckedOut,  
3985 - 'is_available' => (bool) $hit->IsAvailable,  
3986 - 'workflow' => (string) $hit->Workflow,  
3987 - 'workflow_state' => (string) $hit->WorkflowState,  
3988 - 'folder_id' => (int) $hit->FolderId,  
3989 - 'mime_type' => (string) $hit->MimeType,  
3990 - 'modified_by' => (string) $hit->ModifiedBy,  
3991 - 'modified_date' => (string) $hit->DateModified,  
3992 - 'created_by' => (string) $hit->CreatedBy,  
3993 - 'created_date' => (string) $hit->DateCreated,  
3994 - 'owner' => (string) $hit->Owner,  
3995 - 'is_immutable'=> (bool) $hit->Immutable,  
3996 - 'status' => (string) $hit->Status  
3997 - );  
3998 -  
3999 - $item = new SOAP_Value('item',"{urn:$this->namespace}kt_search_result_item", $item);  
4000 - $results[] = $item;  
4001 -  
4002 - } 3963 + $response['message'] = _kt('Search has not been implemented for this version of KnowledgeTree');
  3964 + return new SOAP_Value('return',"{urn:$this->namespace}kt_search_response", $response);
  3965 + }
4003 3966
4004 - $response['message'] = ''; 3967 + $results = processSearchExpression($query);
  3968 + if (PEAR::isError($results))
  3969 + {
  3970 + $response['message'] = _kt('Could not process query.') . $results->getMessage();
  3971 + $results = array();
  3972 + }
  3973 + else
  3974 + {
  3975 + foreach($results as $key=>$item)
  3976 + {
  3977 + $results[$key] = new SOAP_Value('item',"{urn:$this->namespace}kt_search_result_item", $item);
  3978 + }
  3979 + $response['message'] = '';
4005 $response['status_code'] = KTWS_SUCCESS; 3980 $response['status_code'] = KTWS_SUCCESS;
4006 - }  
4007 - catch(Exception $e)  
4008 - {  
4009 - $this->debug("search - exception " . $e->getMessage(), $session_id);  
4010 3981
4011 - $results = array();  
4012 - $response['message'] = _kt('Could not process query.') . $e->getMessage();  
4013 - }  
4014 - $response['hits'] = new SOAP_Value('hits',"{urn:$this->namespace}kt_search_results", $results); 3982 + }
  3983 + $response['hits'] = new SOAP_Value('hits',"{urn:$this->namespace}kt_search_results", $results);
4015 3984
4016 return new SOAP_Value('return',"{urn:$this->namespace}kt_search_response", $response); 3985 return new SOAP_Value('return',"{urn:$this->namespace}kt_search_response", $response);
4017 } 3986 }
search2/search/search.inc.php
@@ -263,14 +263,14 @@ class SearchHelper @@ -263,14 +263,14 @@ class SearchHelper
263 263
264 public static function getSavedSearches($userID) 264 public static function getSavedSearches($userID)
265 { 265 {
266 - 266 +
267 // need to test for broken db configuration so that the queries dont fail 267 // need to test for broken db configuration so that the queries dont fail
268 // and so that we can be redirected to the db error page 268 // and so that we can be redirected to the db error page
269 // TODO: maybe best to have a special db error page rather than the default template when logged in 269 // TODO: maybe best to have a special db error page rather than the default template when logged in
270 - 270 +
271 global $default; 271 global $default;
272 if (is_null($default->_db) || PEAR::isError($default->_db)) return array(); 272 if (is_null($default->_db) || PEAR::isError($default->_db)) return array();
273 - 273 +
274 $sql = "SELECT id, name FROM search_saved WHERE type='S'"; 274 $sql = "SELECT id, name FROM search_saved WHERE type='S'";
275 275
276 // if we are not the system admin, then we get only ours or shared searches 276 // if we are not the system admin, then we get only ours or shared searches
@@ -540,6 +540,52 @@ function parseExpression($expr_str) @@ -540,6 +540,52 @@ function parseExpression($expr_str)
540 return $parser->getExprResult(); 540 return $parser->getExprResult();
541 } 541 }
542 542
543 - 543 +function processSearchExpression($query)
  544 +{
  545 + try
  546 + {
  547 + $expr = parseExpression($query);
  548 +
  549 + $rs = $expr->evaluate();
  550 + usort($rs, 'rank_compare');
  551 +
  552 + $results = array();
  553 + foreach($rs as $hit)
  554 + {
  555 + $item = array(
  556 + 'document_id' => (int) $hit->DocumentID,
  557 + 'title' => (string) $hit->Title,
  558 + 'relevance' => (float) $hit->Rank,
  559 + 'text' => (string) $noText?'':$hit->Text,
  560 + 'filesize' => (int) $hit->Filesize,
  561 + 'fullpath' => (string) $hit->FullPath,
  562 + 'version' => (string) $hit->Version,
  563 + 'filename' => (string) $hit->Filename,
  564 + 'checked_out_by' => (string) $hit->CheckedOutUser,
  565 + 'checked_out_date' => (string) $hit->DateCheckedOut,
  566 + 'is_available' => (bool) $hit->IsAvailable,
  567 + 'workflow' => (string) $hit->Workflow,
  568 + 'workflow_state' => (string) $hit->WorkflowState,
  569 + 'folder_id' => (int) $hit->FolderId,
  570 + 'mime_type' => (string) $hit->MimeType,
  571 + 'modified_by' => (string) $hit->ModifiedBy,
  572 + 'modified_date' => (string) $hit->DateModified,
  573 + 'created_by' => (string) $hit->CreatedBy,
  574 + 'created_date' => (string) $hit->DateCreated,
  575 + 'owner' => (string) $hit->Owner,
  576 + 'is_immutable'=> (bool) $hit->Immutable,
  577 + 'status' => (string) $hit->Status
  578 + );
  579 +
  580 + $results[] = $item;
  581 +
  582 + }
  583 + return $results;
  584 + }
  585 + catch(Exception $e)
  586 + {
  587 + return new PEAR_Error(_kt('Could not process query.') . $e->getMessage());
  588 + }
  589 +}
544 590
545 ?> 591 ?>
546 \ No newline at end of file 592 \ No newline at end of file