1 | <?php |
||
44 | class Session |
||
45 | { |
||
46 | // HTTP Client instance |
||
47 | protected $httpClient = null; |
||
48 | |||
49 | // Service URL to which client connects to |
||
50 | protected $vtigerUrl = null; |
||
51 | protected $wsBaseURL = null; |
||
52 | |||
53 | // Vtiger CRM and WebServices API version |
||
54 | private $vtigerApiVersion = '0.0'; |
||
55 | private $vtigerVersion = '0.0'; |
||
56 | |||
57 | // Webservice login validity |
||
58 | # private $serviceServerTime = null; |
||
|
|||
59 | private $serviceExpireTime = null; |
||
60 | private $serviceToken = null; |
||
61 | |||
62 | // Webservice user credentials |
||
63 | private $userName = null; |
||
64 | private $accessKey = null; |
||
65 | |||
66 | // Webservice login credentials |
||
67 | private $userID = null; |
||
68 | private $sessionName = null; |
||
69 | |||
70 | /** |
||
71 | * Class constructor |
||
72 | * @param string $vtigerUrl The URL of the remote WebServices server |
||
73 | * @param string [$wsBaseURL = 'webservice.php'] WebServices base URL appended to vTiger root URL |
||
74 | */ |
||
75 | public function __construct($vtigerUrl, $wsBaseURL = 'webservice.php') |
||
85 | |||
86 | /** |
||
87 | * Login to the server using username and VTiger access key token |
||
88 | * @access public |
||
89 | * @param string $username VTiger user name |
||
90 | * @param string $accessKey VTiger access key token (visible on user profile/settings page) |
||
91 | * @return boolean Returns true if login operation has been successful |
||
92 | */ |
||
93 | public function login($username, $accessKey) |
||
125 | |||
126 | /** |
||
127 | * Allows you to login using username and password instead of access key (works on some VTige forks) |
||
128 | * @access public |
||
129 | * @param string $username VTiger user name |
||
130 | * @param string $password VTiger password (used to access CRM using the standard login page) |
||
131 | * @param string $accessKey This parameter will be filled with user's VTiger access key |
||
132 | * @return boolean Returns true if login operation has been successful |
||
133 | */ |
||
134 | public function loginPassword($username, $password, &$accessKey = null) |
||
158 | |||
159 | /** |
||
160 | * Gets a challenge token from the server and stores for future requests |
||
161 | * @access private |
||
162 | * @param string $username VTiger user name |
||
163 | * @return boolean Returns false in case of failure |
||
164 | */ |
||
165 | private function passChallenge($username) |
||
183 | |||
184 | /** |
||
185 | * Gets an array containing the basic information about current API user |
||
186 | * @access public |
||
187 | * @return array Basic information about current API user |
||
188 | */ |
||
189 | public function getUserInfo() |
||
197 | |||
198 | /** |
||
199 | * Gets vTiger version, retrieved on successful login |
||
200 | * @access public |
||
201 | * @return string vTiger version, retrieved on successful login |
||
202 | */ |
||
203 | public function getVtigerVersion() |
||
207 | |||
208 | /** |
||
209 | * Gets vTiger WebServices API version, retrieved on successful login |
||
210 | * @access public |
||
211 | * @return string vTiger WebServices API version, retrieved on successful login |
||
212 | */ |
||
213 | public function getVtigerApiVersion() |
||
217 | |||
218 | /** |
||
219 | * Sends HTTP request to VTiger web service API endpoint |
||
220 | * @access private |
||
221 | * @param array $requestData HTTP request data |
||
222 | * @param string $method HTTP request method (GET, POST etc) |
||
223 | * @return array Returns request result object (null in case of failure) |
||
224 | */ |
||
225 | public function sendHttpRequest(array $requestData, $method = 'POST') |
||
265 | |||
266 | /** |
||
267 | * Cleans and fixes vTiger URL |
||
268 | * @access private |
||
269 | * @static |
||
270 | * @param string Base URL of vTiger CRM |
||
271 | * @return boolean Returns cleaned and fixed vTiger URL |
||
272 | */ |
||
273 | private static function fixVtigerBaseUrl($baseUrl) |
||
283 | |||
284 | /** |
||
285 | * Check if server response contains an error, therefore the requested operation has failed |
||
286 | * @access private |
||
287 | * @static |
||
288 | * @param array $jsonResult Server response object to check for errors |
||
289 | * @return boolean True if response object contains an error |
||
290 | */ |
||
291 | private static function checkForError(array $jsonResult) |
||
308 | } |
||
309 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.