Scrutinizer Auto-Fixes

This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com
This commit is contained in:
Scrutinizer Auto-Fixer
2020-03-12 11:45:44 +00:00
parent f38134e44d
commit f413ce6aac
69 changed files with 2962 additions and 2962 deletions

View File

@@ -118,16 +118,16 @@ class Orders extends DolibarrApi
*/
private function _fetch($id, $ref = '', $ref_ext = '', $contact_list = 1)
{
if(! DolibarrApiAccess::$user->rights->commande->lire) {
if (!DolibarrApiAccess::$user->rights->commande->lire) {
throw new RestException(401);
}
$result = $this->commande->fetch($id, $ref, $ref_ext);
if( ! $result ) {
if (!$result) {
throw new RestException(404, 'Order not found');
}
if( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
@@ -163,18 +163,18 @@ class Orders extends DolibarrApi
// If the internal user must only see his customers, force searching by him
$search_sale = 0;
if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id;
if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id;
$sql = "SELECT t.rowid";
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
$sql.= " FROM ".MAIN_DB_PREFIX."commande as t";
$sql .= " FROM ".MAIN_DB_PREFIX."commande as t";
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale
$sql.= ' WHERE t.entity IN ('.getEntity('commande').')';
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc";
if ($socids) $sql.= " AND t.fk_soc IN (".$socids.")";
if ($search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
$sql .= ' WHERE t.entity IN ('.getEntity('commande').')';
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= " AND t.fk_soc = sc.fk_soc";
if ($socids) $sql .= " AND t.fk_soc IN (".$socids.")";
if ($search_sale > 0) $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
// Insert sale filter
if ($search_sale > 0)
{
@@ -183,23 +183,23 @@ class Orders extends DolibarrApi
// Add sql filters
if ($sqlfilters)
{
if (! DolibarrApi::_checkFilters($sqlfilters))
if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
}
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
}
$sql.= $db->order($sortfield, $sortorder);
if ($limit) {
$sql .= $db->order($sortfield, $sortorder);
if ($limit) {
if ($page < 0)
{
$page = 0;
}
$offset = $limit * $page;
$sql.= $db->plimit($limit + 1, $offset);
$sql .= $db->plimit($limit + 1, $offset);
}
dol_syslog("API Rest request");
@@ -209,12 +209,12 @@ class Orders extends DolibarrApi
{
$num = $db->num_rows($result);
$min = min($num, ($limit <= 0 ? $num : $limit));
$i=0;
$i = 0;
while ($i < $min)
{
$obj = $db->fetch_object($result);
$commande_static = new Commande($db);
if($commande_static->fetch($obj->rowid)) {
if ($commande_static->fetch($obj->rowid)) {
// Add external contacts ids
$commande_static->contacts_ids = $commande_static->liste_contact(-1, 'external', 1);
$obj_ret[] = $this->_cleanObjectDatas($commande_static);
@@ -225,7 +225,7 @@ class Orders extends DolibarrApi
else {
throw new RestException(503, 'Error when retrieve commande list : '.$db->lasterror());
}
if( ! count($obj_ret)) {
if (!count($obj_ret)) {
throw new RestException(404, 'No order found');
}
return $obj_ret;
@@ -239,13 +239,13 @@ class Orders extends DolibarrApi
*/
public function post($request_data = null)
{
if(! DolibarrApiAccess::$user->rights->commande->creer) {
if (!DolibarrApiAccess::$user->rights->commande->creer) {
throw new RestException(401, "Insuffisant rights");
}
// Check mandatory fields
$result = $this->_validate($request_data);
foreach($request_data as $field => $value) {
foreach ($request_data as $field => $value) {
$this->commande->$field = $value;
}
/*if (isset($request_data["lines"])) {
@@ -274,16 +274,16 @@ class Orders extends DolibarrApi
*/
public function getLines($id)
{
if(! DolibarrApiAccess::$user->rights->commande->lire) {
if (!DolibarrApiAccess::$user->rights->commande->lire) {
throw new RestException(401);
}
$result = $this->commande->fetch($id);
if( ! $result ) {
if (!$result) {
throw new RestException(404, 'Order not found');
}
if( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$this->commande->getLinesArray();
@@ -306,16 +306,16 @@ class Orders extends DolibarrApi
*/
public function postLine($id, $request_data = null)
{
if(! DolibarrApiAccess::$user->rights->commande->creer) {
if (!DolibarrApiAccess::$user->rights->commande->creer) {
throw new RestException(401);
}
$result = $this->commande->fetch($id);
if( ! $result ) {
if (!$result) {
throw new RestException(404, 'Order not found');
}
if( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$request_data = (object) $request_data;
@@ -368,16 +368,16 @@ class Orders extends DolibarrApi
*/
public function putLine($id, $lineid, $request_data = null)
{
if(! DolibarrApiAccess::$user->rights->commande->creer) {
if (!DolibarrApiAccess::$user->rights->commande->creer) {
throw new RestException(401);
}
$result = $this->commande->fetch($id);
if( ! $result ) {
if (!$result) {
throw new RestException(404, 'Order not found');
}
if( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$request_data = (object) $request_data;
@@ -430,16 +430,16 @@ class Orders extends DolibarrApi
*/
public function deleteLine($id, $lineid)
{
if(! DolibarrApiAccess::$user->rights->commande->creer) {
if (!DolibarrApiAccess::$user->rights->commande->creer) {
throw new RestException(401);
}
$result = $this->commande->fetch($id);
if( ! $result ) {
if (!$result) {
throw new RestException(404, 'Order not found');
}
if( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
@@ -469,16 +469,16 @@ class Orders extends DolibarrApi
*/
public function postContact($id, $contactid, $type)
{
if (! DolibarrApiAccess::$user->rights->commande->creer) {
if (!DolibarrApiAccess::$user->rights->commande->creer) {
throw new RestException(401);
}
$result = $this->commande->fetch($id);
if (! $result) {
if (!$result) {
throw new RestException(404, 'Order not found');
}
if (! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
@@ -507,16 +507,16 @@ class Orders extends DolibarrApi
*/
public function deleteContact($id, $rowid)
{
if (! DolibarrApiAccess::$user->rights->commande->creer) {
if (!DolibarrApiAccess::$user->rights->commande->creer) {
throw new RestException(401);
}
$result = $this->commande->fetch($id);
if (! $result) {
if (!$result) {
throw new RestException(404, 'Order not found');
}
if (! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
@@ -539,19 +539,19 @@ class Orders extends DolibarrApi
*/
public function put($id, $request_data = null)
{
if (! DolibarrApiAccess::$user->rights->commande->creer) {
if (!DolibarrApiAccess::$user->rights->commande->creer) {
throw new RestException(401);
}
$result = $this->commande->fetch($id);
if (! $result) {
if (!$result) {
throw new RestException(404, 'Order not found');
}
if (! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
foreach($request_data as $field => $value) {
foreach ($request_data as $field => $value) {
if ($field == 'id') continue;
$this->commande->$field = $value;
}
@@ -580,19 +580,19 @@ class Orders extends DolibarrApi
*/
public function delete($id)
{
if(! DolibarrApiAccess::$user->rights->commande->supprimer) {
if (!DolibarrApiAccess::$user->rights->commande->supprimer) {
throw new RestException(401);
}
$result = $this->commande->fetch($id);
if( ! $result ) {
if (!$result) {
throw new RestException(404, 'Order not found');
}
if( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
if( ! $this->commande->delete(DolibarrApiAccess::$user)) {
if (!$this->commande->delete(DolibarrApiAccess::$user)) {
throw new RestException(500, 'Error when deleting order : '.$this->commande->error);
}
@@ -628,15 +628,15 @@ class Orders extends DolibarrApi
*/
public function validate($id, $idwarehouse = 0, $notrigger = 0)
{
if(! DolibarrApiAccess::$user->rights->commande->creer) {
if (!DolibarrApiAccess::$user->rights->commande->creer) {
throw new RestException(401);
}
$result = $this->commande->fetch($id);
if( ! $result ) {
if (!$result) {
throw new RestException(404, 'Order not found');
}
if( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
@@ -648,11 +648,11 @@ class Orders extends DolibarrApi
throw new RestException(500, 'Error when validating Order: '.$this->commande->error);
}
$result = $this->commande->fetch($id);
if( ! $result ) {
if (!$result) {
throw new RestException(404, 'Order not found');
}
if( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
@@ -681,21 +681,21 @@ class Orders extends DolibarrApi
public function reopen($id)
{
if(! DolibarrApiAccess::$user->rights->commande->creer) {
if (!DolibarrApiAccess::$user->rights->commande->creer) {
throw new RestException(401);
}
if(empty($id)) {
if (empty($id)) {
throw new RestException(400, 'Order ID is mandatory');
}
$result = $this->commande->fetch($id);
if( ! $result ) {
if (!$result) {
throw new RestException(404, 'Order not found');
}
$result = $this->commande->set_reopen(DolibarrApiAccess::$user);
if( $result < 0) {
if ($result < 0) {
throw new RestException(405, $this->commande->error);
}elseif( $result == 0) {
}elseif ($result == 0) {
throw new RestException(304);
}
@@ -719,28 +719,28 @@ class Orders extends DolibarrApi
public function setinvoiced($id)
{
if(! DolibarrApiAccess::$user->rights->commande->creer) {
if (!DolibarrApiAccess::$user->rights->commande->creer) {
throw new RestException(401);
}
if(empty($id)) {
if (empty($id)) {
throw new RestException(400, 'Order ID is mandatory');
}
$result = $this->commande->fetch($id);
if( ! $result ) {
if (!$result) {
throw new RestException(404, 'Order not found');
}
$result = $this->commande->classifyBilled(DolibarrApiAccess::$user);
if( $result < 0) {
if ($result < 0) {
throw new RestException(400, $this->commande->error);
}
$result = $this->commande->fetch($id);
if( ! $result ) {
if (!$result) {
throw new RestException(404, 'Order not found');
}
if( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
@@ -761,15 +761,15 @@ class Orders extends DolibarrApi
*/
public function close($id, $notrigger = 0)
{
if(! DolibarrApiAccess::$user->rights->commande->creer) {
if (!DolibarrApiAccess::$user->rights->commande->creer) {
throw new RestException(401);
}
$result = $this->commande->fetch($id);
if( ! $result ) {
if (!$result) {
throw new RestException(404, 'Order not found');
}
if( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
@@ -782,11 +782,11 @@ class Orders extends DolibarrApi
}
$result = $this->commande->fetch($id);
if( ! $result ) {
if (!$result) {
throw new RestException(404, 'Order not found');
}
if( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
@@ -807,15 +807,15 @@ class Orders extends DolibarrApi
*/
public function settodraft($id, $idwarehouse = -1)
{
if(! DolibarrApiAccess::$user->rights->commande->creer) {
if (!DolibarrApiAccess::$user->rights->commande->creer) {
throw new RestException(401);
}
$result = $this->commande->fetch($id);
if( ! $result ) {
if (!$result) {
throw new RestException(404, 'Order not found');
}
if( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
@@ -828,11 +828,11 @@ class Orders extends DolibarrApi
}
$result = $this->commande->fetch($id);
if( ! $result ) {
if (!$result) {
throw new RestException(404, 'Order not found');
}
if( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
@@ -859,26 +859,26 @@ class Orders extends DolibarrApi
public function createOrderFromProposal($proposalid)
{
require_once DOL_DOCUMENT_ROOT . '/comm/propal/class/propal.class.php';
require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
if(! DolibarrApiAccess::$user->rights->propal->lire) {
if (!DolibarrApiAccess::$user->rights->propal->lire) {
throw new RestException(401);
}
if(! DolibarrApiAccess::$user->rights->commande->creer) {
if (!DolibarrApiAccess::$user->rights->commande->creer) {
throw new RestException(401);
}
if(empty($proposalid)) {
if (empty($proposalid)) {
throw new RestException(400, 'Proposal ID is mandatory');
}
$propal = new Propal($this->db);
$result = $propal->fetch($proposalid);
if( ! $result ) {
if (!$result) {
throw new RestException(404, 'Proposal not found');
}
$result = $this->commande->createFromProposal($propal, DolibarrApiAccess::$user);
if( $result < 0) {
if ($result < 0) {
throw new RestException(405, $this->commande->error);
}
$this->commande->fetchObjectLinked();
@@ -921,7 +921,7 @@ class Orders extends DolibarrApi
$commande = array();
foreach (Orders::$FIELDS as $field) {
if (!isset($data[$field]))
throw new RestException(400, $field ." field missing");
throw new RestException(400, $field." field missing");
$commande[$field] = $data[$field];
}
return $commande;