Standardize code

This commit is contained in:
Laurent Destailleur
2017-10-07 14:11:01 +02:00
parent 66978a3bb4
commit af1d2bfffd
5 changed files with 96 additions and 90 deletions

View File

@@ -370,8 +370,10 @@ class Proposals extends DolibarrApi
* @url DELETE {id}/lines/{lineid}
*
* @return int
* @throws 401
* @throws 404
*/
function delLine($id, $lineid) {
function deleteLine($id, $lineid) {
if(! DolibarrApiAccess::$user->rights->propal->creer) {
throw new RestException(401);
}
@@ -384,9 +386,10 @@ class Proposals extends DolibarrApi
if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$request_data = (object) $request_data;
$request_data = (object) $request_data;
$updateRes = $this->propal->deleteline($lineid);
if ($updateRes == 1) {
if ($updateRes > 0) {
return $this->get($id);
}
return false;

View File

@@ -389,7 +389,7 @@ class CommandeApi extends DolibarrApi
*
* @return int
*/
function delLine($id, $lineid) {
function deleteLine($id, $lineid) {
if(! DolibarrApiAccess::$user->rights->commande->creer) {
throw new RestException(401);
}

View File

@@ -353,14 +353,16 @@ class Orders extends DolibarrApi
* Delete a line to given order
*
*
* @param int $id Id of commande to update
* @param int $id Id of order to update
* @param int $lineid Id of line to delete
*
* @url DELETE {id}/lines/{lineid}
*
* @return int
* @throws 401
* @throws 404
*/
function delLine($id, $lineid) {
function deleteLine($id, $lineid) {
if(! DolibarrApiAccess::$user->rights->commande->creer) {
throw new RestException(401);
}
@@ -373,7 +375,8 @@ class Orders extends DolibarrApi
if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$request_data = (object) $request_data;
$request_data = (object) $request_data;
$updateRes = $this->commande->deleteline(DolibarrApiAccess::$user,$lineid);
if ($updateRes > 0) {
return $this->get($id);

View File

@@ -312,13 +312,13 @@ class Invoices extends DolibarrApi
* @param int $id Id of invoice
* @param int $lineid Id of the line to delete
*
* @url DELETE {id}/deleteline/{lineid}
* @url DELETE {id}/lines/{lineid}
*
* @return array
* @throws 304
* @throws 400
* @throws 401
* @throws 404
* @throws 405
*/
function deleteLine($id, $lineid) {
@@ -340,7 +340,7 @@ class Invoices extends DolibarrApi
$result = $this->invoice->deleteline($lineid);
if( $result < 0) {
throw new RestException(304);
throw new RestException(405, $this->invoice->error);
}
$result = $this->invoice->fetch($id);

View File

@@ -348,7 +348,7 @@ class ExpenseReports extends DolibarrApi
* @return int
*/
/*
function delLine($id, $lineid) {
function deleteLine($id, $lineid) {
if(! DolibarrApiAccess::$user->rights->expensereport->creer) {
throw new RestException(401);
}