client_service.php
2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
class client_service{
public $Response;
public $KT;
public $Request;
public $AuthInfo;
public $handler;
public function __construct(&$handler,&$ResponseObject,&$KT_Instance,&$Request,&$AuthInfo){
// set the response object
// if(get_class($ResponseObject)=='jsonResponseObject'){
// $this->Response=&$ResponseObject;
// }else{
// $this->Response=new jsonResponseObject();
// }
$this->handler=$handler;
$this->Response=&$ResponseObject;
$this->KT=&$KT_Instance;
$this->AuthInfo=&$AuthInfo;
$this->Request=&$Request;
$this->Response->location='client service';
}
protected function addResponse($name,$value){
$this->Response->setData($name,$value);
}
protected function addDebug($name,$value){
$this->Response->setDebug($name,$value);
}
protected function setResponse($value){
$this->Response->overwriteData($value);
}
protected function addError($message,$code){
$this->Response->addError($message,$code);
}
protected function xlate($var=NULL){
return $var;
}
protected function logTrace($location=NULL,$message=NULL){
Clienttools_Syslog::logTrace($this->AuthInfo['user'],'SERVICE - '.$location,$message);
}
protected function logError($location=NULL,$detail=NULL,$err=NULL){
Clienttools_Syslog::logError($this->AuthInfo['user'],'SERVICE - '.$location,$detail,$err);
}
protected function logInfo($location=NULL,$message=NULL,$debugData=NULL){
Clienttools_Syslog::logInfo($this->AuthInfo['user'],'SERVICE - '.$location,$message,$debugData);
}
protected function checkPearError($obj,$errMsg,$debug=NULL,$response=NULL){
if (PEAR::isError($obj)){
if($response===NULL)$response=array('status_code' => 1);
$this->addError($errMsg);
if((isset($debug) || $debug==NULL) && $debug!=='')$this->addDebug('',$debug!==NULL?$debug:$obj);
$this->setResponse($response);
return false;
}
return true;
}
/**
* Forces parameter to boolean.
* $isTrue array contains a list of values that are recognized as 'true' values in boolean
*/
protected function bool($var=NULL){
$ret=false;
$isTrue=Array('true','0','yes');
if(is_bool($var))$ret=$var;
$var=strtolower(trim(($var.'')));
$ret=(in_array($var,$isTrue));
return $ret;
}
}
?>