diff --git a/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php b/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php index bb59fa93929..4b8978462fb 100644 --- a/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php +++ b/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php @@ -48,6 +48,7 @@ class PrestaShopWebservice const PSCOMPATIBLEVERSIONMIN = '1.4.0.0'; const PSCOMPATIBLEVERSIONMAX = '1.6.99.99'; + /** * PrestaShopWebservice constructor. Throw an exception when CURL is not installed/activated * @@ -79,6 +80,7 @@ class PrestaShopWebservice /** * Take the status code and throw an exception if the server didn't return 200 or 201 code + * * @param int $status_code Status code of an HTTP return */ protected function checkStatusCode($status_code) @@ -86,21 +88,32 @@ class PrestaShopWebservice $error_label = 'This call to PrestaShop Web Services failed and returned an HTTP status of %d. That means: %s.'; switch($status_code) { - case 200: case 201: break; - case 204: throw new PrestaShopWebserviceException(sprintf($error_label, $status_code, 'No content'));break; - case 400: throw new PrestaShopWebserviceException(sprintf($error_label, $status_code, 'Bad Request'));break; - case 401: throw new PrestaShopWebserviceException(sprintf($error_label, $status_code, 'Unauthorized'));break; - case 404: throw new PrestaShopWebserviceException(sprintf($error_label, $status_code, 'Not Found'));break; - case 405: throw new PrestaShopWebserviceException(sprintf($error_label, $status_code, 'Method Not Allowed'));break; - case 500: throw new PrestaShopWebserviceException(sprintf($error_label, $status_code, 'Internal Server Error'));break; - default: throw new PrestaShopWebserviceException('This call to PrestaShop Web Services returned an unexpected HTTP status of:' . $status_code); + case 200: + case 201: + break; + case 204: + throw new PrestaShopWebserviceException(sprintf($error_label, $status_code, 'No content')); + case 400: + throw new PrestaShopWebserviceException(sprintf($error_label, $status_code, 'Bad Request')); + case 401: + throw new PrestaShopWebserviceException(sprintf($error_label, $status_code, 'Unauthorized')); + case 404: + throw new PrestaShopWebserviceException(sprintf($error_label, $status_code, 'Not Found')); + case 405: + throw new PrestaShopWebserviceException(sprintf($error_label, $status_code, 'Method Not Allowed')); + case 500: + throw new PrestaShopWebserviceException(sprintf($error_label, $status_code, 'Internal Server Error')); + default: + throw new PrestaShopWebserviceException('This call to PrestaShop Web Services returned an unexpected HTTP status of:' . $status_code); } } + /** * Handles a CURL request to PrestaShop Webservice. Can throw exception. - * @param string $url Resource name - * @param mixed $curl_params CURL parameters (sent to curl_set_opt) - * @return array status_code, response + * + * @param string $url Resource name + * @param mixed $curl_params CURL parameters (sent to curl_set_opt) + * @return array status_code, response */ public function executeRequest($url, $curl_params = array()) { @@ -178,11 +191,23 @@ class PrestaShopWebservice return array('status_code' => $status_code, 'response' => $body, 'header' => $header); } + /** + * Output debug info + * + * @param string $title Title + * @param string $content Content + * @return void + */ public function printDebug($title, $content) { echo '
'.$title.'
'.htmlentities($content).'
'; } + /** + * Return version + * + * @return string Version + */ public function getVersion() { return $this->version; @@ -190,8 +215,9 @@ class PrestaShopWebservice /** * Load XML from string. Can throw exception - * @param string $response String from a CURL response - * @return SimpleXMLElement status_code, response + * + * @param string $response String from a CURL response + * @return SimpleXMLElement status_code, response */ protected function parseXML($response) { @@ -268,8 +294,8 @@ class PrestaShopWebservice * } * ?> *
- * @param array $options Array representing resource to get. - * @return SimpleXMLElement status_code, response + * @param array $options Array representing resource to get. + * @return SimpleXMLElement status_code, response */ public function get($options) { @@ -301,8 +327,8 @@ class PrestaShopWebservice /** * Head method (HEAD) a resource * - * @param array $options Array representing resource for head request. - * @return SimpleXMLElement status_code, response + * @param array $options Array representing resource for head request. + * @return SimpleXMLElement status_code, response */ public function head($options) { @@ -336,7 +362,9 @@ class PrestaShopWebservice * 'id' => ID of a resource you want to edit,
* 'putXml' => Modified XML string of a resource

* Examples are given in the tutorial

- * @param array $options Array representing resource to edit. + * + * @param array $options Array representing resource to edit. + * @return SimpleXMLElement status_code, response */ public function edit($options) { @@ -381,7 +409,8 @@ class PrestaShopWebservice * } * ?> * - * @param array $options Array representing resource to delete. + * @param array $options Array representing resource to delete. + * @return boolean true */ public function delete($options) { @@ -400,8 +429,6 @@ class PrestaShopWebservice self::checkStatusCode($request['status_code']);// check the response validity return true; } - - } /** diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 0123535ebb1..8c762121c32 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -1171,8 +1171,6 @@ class ExpenseReport extends CommonObject $this->error=$this->db->lasterror(); return -1; } - - return 0; } /**