Passed
Push — master ( 49af33...3cffbe )
by Alxarafe
21:21
created
dolibarr/htdocs/societe/canvas/individual/tpl/card_edit.tpl.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  */
18 18
 
19 19
 // Protection to avoid direct call of template
20
-if (empty($conf) || ! is_object($conf))
20
+if (empty($conf) || !is_object($conf))
21 21
 {
22 22
 	print "Error, template page can't be called as URL";
23 23
 	exit;
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 	<td colspan="3"><input type="text" size="40" maxlength="60" name="nom" value="<?php echo $this->control->tpl['nom']; ?>"></td>
51 51
 </tr>
52 52
 
53
-<?php if (! empty($conf->global->SOCIETE_USEPREFIX)) { ?>
53
+<?php if (!empty($conf->global->SOCIETE_USEPREFIX)) { ?>
54 54
 <tr>
55 55
 	<td><?php echo $langs->trans("Prefix"); ?></td>
56 56
 	<td colspan="3">
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 </tr>
116 116
 <?php } }?>
117 117
 
118
-<?php if (! empty($conf->barcode->enabled)) { ?>
118
+<?php if (!empty($conf->barcode->enabled)) { ?>
119 119
 <tr>
120 120
 	<td><?php echo $langs->trans('Gencod'); ?></td>
121 121
 	<td colspan="3"><input type="text" name="barcode" value="<?php echo $this->control->tpl['barcode']; ?>"></td>
@@ -152,13 +152,13 @@  discard block
 block discarded – undo
152 152
 </tr>
153 153
 
154 154
 <tr>
155
-	<td><?php echo $langs->trans('EMail').($conf->global->SOCIETE_EMAIL_MANDATORY?'*':''); ?></td>
155
+	<td><?php echo $langs->trans('EMail').($conf->global->SOCIETE_EMAIL_MANDATORY ? '*' : ''); ?></td>
156 156
 	<td><input type="text" name="email" size="32" value="<?php echo $this->control->tpl['email']; ?>"></td>
157 157
 	<td><?php echo $langs->trans('Web'); ?></td>
158 158
 	<td><input type="text" name="url" size="32" value="<?php echo $this->control->tpl['url']; ?>"></td>
159 159
 </tr>
160 160
 
161
-<?php if (! empty($conf->global->MAIN_MULTILANGS)) { ?>
161
+<?php if (!empty($conf->global->MAIN_MULTILANGS)) { ?>
162 162
 <tr>
163 163
 	<td><?php echo $langs->trans("DefaultLang"); ?></td>
164 164
 	<td colspan="3"><?php echo $this->control->tpl['select_lang']; ?></td>
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 	<td colspan="3"><?php echo $this->control->tpl['yn_assujtva']; ?></td>
171 171
 </tr>
172 172
 
173
-<?php if(!empty($this->control->tpl['localtax'])) echo $this->control->tpl['localtax']; ?>
173
+<?php if (!empty($this->control->tpl['localtax'])) echo $this->control->tpl['localtax']; ?>
174 174
 
175 175
 </table>
176 176
 <br>
Please login to merge, or discard this patch.
dolibarr/htdocs/societe/canvas/individual/actions_card_individual.class.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -39,10 +39,10 @@  discard block
 block discarded – undo
39 39
      */
40 40
 	function __construct($db, $dirmodule, $targetmodule, $canvas, $card)
41 41
 	{
42
-		$this->db				= $db;
43
-		$this->dirmodule		= $dirmodule;
42
+		$this->db = $db;
43
+		$this->dirmodule = $dirmodule;
44 44
 		$this->targetmodule		= $targetmodule;
45
-        $this->canvas			= $canvas;
45
+        $this->canvas = $canvas;
46 46
         $this->card				= $card;
47 47
 	}
48 48
 
@@ -57,11 +57,11 @@  discard block
 block discarded – undo
57 57
     {
58 58
         global $langs;
59 59
 
60
-        $out='';
60
+        $out = '';
61 61
 
62
-        if ($action == 'view')      $out.= $langs->trans("Individual");
63
-        if ($action == 'edit')      $out.= $langs->trans("EditCompany");
64
-        if ($action == 'create')    $out.= $langs->trans("NewCompany");
62
+        if ($action == 'view')      $out .= $langs->trans("Individual");
63
+        if ($action == 'edit')      $out .= $langs->trans("EditCompany");
64
+        if ($action == 'create')    $out .= $langs->trans("NewCompany");
65 65
 
66 66
         return $out;
67 67
     }
@@ -93,13 +93,13 @@  discard block
 block discarded – undo
93 93
 	 *    @param	string	$ref		Ref of object
94 94
 	 *    @return	void
95 95
 	 */
96
-	function assign_values(&$action, $id=0, $ref='')
96
+	function assign_values(&$action, $id = 0, $ref = '')
97 97
 	{
98 98
         // phpcs:enable
99 99
 		global $conf, $langs;
100 100
 		global $form, $formcompany;
101 101
 
102
-		$ret = $this->getObject($id,$ref);
102
+		$ret = $this->getObject($id, $ref);
103 103
 
104 104
 		parent::assign_values($action);
105 105
 
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 			// Confirm delete third party
115 115
 			if ($action == 'delete' || $conf->use_javascript_ajax)
116 116
 			{
117
-				$this->tpl['action_delete'] = $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$this->object->id,$langs->trans("DeleteAnIndividual"),$langs->trans("ConfirmDeleteIndividual"),"confirm_delete",'',0,"1,action-delete");
117
+				$this->tpl['action_delete'] = $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$this->object->id, $langs->trans("DeleteAnIndividual"), $langs->trans("ConfirmDeleteIndividual"), "confirm_delete", '', 0, "1,action-delete");
118 118
 			}
119 119
 		}
120 120
 	}
@@ -132,8 +132,8 @@  discard block
 block discarded – undo
132 132
 	 *  @param      string	$dbt_select		Field name for select if not rowid. (optional)
133 133
 	 *  @return		int						1
134 134
 	 */
135
-	function restrictedArea($user, $features='societe', $objectid=0, $dbtablename='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid')
135
+	function restrictedArea($user, $features = 'societe', $objectid = 0, $dbtablename = '', $feature2 = '', $dbt_keyfield = 'fk_soc', $dbt_select = 'rowid')
136 136
 	{
137
-		return restrictedArea($user,$features,$objectid,$dbtablename,$feature2,$dbt_keyfield,$dbt_select);
137
+		return restrictedArea($user, $features, $objectid, $dbtablename, $feature2, $dbt_keyfield, $dbt_select);
138 138
 	}
139 139
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/societe/checkvat/checkVatPopup.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -28,35 +28,35 @@  discard block
 block discarded – undo
28 28
 $langs->load("companies");
29 29
 
30 30
 //http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl
31
-$WS_DOL_URL='http://ec.europa.eu/taxation_customs/vies/services/checkVatService';
31
+$WS_DOL_URL = 'http://ec.europa.eu/taxation_customs/vies/services/checkVatService';
32 32
 //$WS_DOL_URL_WSDL=$WS_DOL_URL.'?wsdl';
33
-$WS_DOL_URL_WSDL='http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl';
34
-$WS_METHOD ='checkVat';
33
+$WS_DOL_URL_WSDL = 'http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl';
34
+$WS_METHOD = 'checkVat';
35 35
 
36 36
 
37 37
 
38
-$conf->dol_hide_topmenu=1;
39
-$conf->dol_hide_leftmenu=1;
38
+$conf->dol_hide_topmenu = 1;
39
+$conf->dol_hide_leftmenu = 1;
40 40
 
41 41
 llxHeader('', $langs->trans("VATIntraCheckableOnEUSite"));
42 42
 
43 43
 print '<div>';
44 44
 print '<div>';
45 45
 
46
-print load_fiche_titre($langs->trans("VATIntraCheckableOnEUSite"),'','title_setup');
46
+print load_fiche_titre($langs->trans("VATIntraCheckableOnEUSite"), '', 'title_setup');
47 47
 
48
-$vatNumber = GETPOST("vatNumber",'alpha');
48
+$vatNumber = GETPOST("vatNumber", 'alpha');
49 49
 
50
-if (! $vatNumber)
50
+if (!$vatNumber)
51 51
 {
52 52
 	print '<br>';
53
-	print '<font class="error">'.$langs->transnoentities("ErrorFieldRequired",$langs->trans("VATIntraShort")).'</font><br>';
53
+	print '<font class="error">'.$langs->transnoentities("ErrorFieldRequired", $langs->trans("VATIntraShort")).'</font><br>';
54 54
 }
55 55
 else
56 56
 {
57 57
 	$vatNumber = preg_replace('/\^\w/', '', $vatNumber);
58
-	$countryCode=substr($vatNumber,0,2);
59
-	$vatNumber=substr($vatNumber,2);
58
+	$countryCode = substr($vatNumber, 0, 2);
59
+	$vatNumber = substr($vatNumber, 2);
60 60
 
61 61
 	print '<b>'.$langs->trans("Country").'</b>: '.$countryCode.'<br>';
62 62
 	print '<b>'.$langs->trans("VATIntraShort").'</b>: '.$vatNumber.'<br>';
@@ -69,10 +69,10 @@  discard block
 block discarded – undo
69 69
 	// Set the WebService URL
70 70
 	dol_syslog("Create nusoap_client for URL=".$WS_DOL_URL." WSDL=".$WS_DOL_URL_WSDL);
71 71
     require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
72
-    $params=getSoapParams();
72
+    $params = getSoapParams();
73 73
     //ini_set('default_socket_timeout', $params['response_timeout']);
74 74
     //$soapclient = new SoapClient($WS_DOL_URL_WSDL,$params);
75
-	$soapclient = new nusoap_client($WS_DOL_URL_WSDL,true,$params['proxy_host'],$params['proxy_port'],$params['proxy_login'],$params['proxy_password'],$params['connection_timeout'],$params['response_timeout']);
75
+	$soapclient = new nusoap_client($WS_DOL_URL_WSDL, true, $params['proxy_host'], $params['proxy_port'], $params['proxy_login'], $params['proxy_password'], $params['connection_timeout'], $params['response_timeout']);
76 76
 	$soapclient->soap_defencoding = 'utf-8';
77 77
 	$soapclient->xml_encoding = 'utf-8';
78 78
 	$soapclient->decode_utf8 = false;
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 
87 87
 	// Call the WebService and store its result in $result.
88 88
 	dol_syslog("Call method ".$WS_METHOD);
89
-	$result = $soapclient->call($WS_METHOD,$parameters);
89
+	$result = $soapclient->call($WS_METHOD, $parameters);
90 90
 
91 91
 	//var_dump($parameters);
92 92
 	//var_dump($soapclient);
@@ -95,33 +95,33 @@  discard block
 block discarded – undo
95 95
 	//print $soapclient->request.'<br>';
96 96
 	//print $soapclient->response.'<br>';
97 97
 
98
-	$messagetoshow='';
98
+	$messagetoshow = '';
99 99
 	print '<b>'.$langs->trans("Response").'</b>:<br>';
100 100
 
101 101
 	// Service indisponible
102
-	if (! is_array($result) || preg_match('/SERVICE_UNAVAILABLE/i',$result['faultstring']))
102
+	if (!is_array($result) || preg_match('/SERVICE_UNAVAILABLE/i', $result['faultstring']))
103 103
 	{
104 104
 		print '<font class="error">'.$langs->trans("ErrorServiceUnavailableTryLater").'</font><br>';
105
-		$messagetoshow=$soapclient->response;
105
+		$messagetoshow = $soapclient->response;
106 106
 	}
107
-	elseif (preg_match('/TIMEOUT/i',$result['faultstring']))
107
+	elseif (preg_match('/TIMEOUT/i', $result['faultstring']))
108 108
 	{
109 109
 		print '<font class="error">'.$langs->trans("ErrorServiceUnavailableTryLater").'</font><br>';
110
-		$messagetoshow=$soapclient->response;
110
+		$messagetoshow = $soapclient->response;
111 111
 	}
112
-	elseif (preg_match('/SERVER_BUSY/i',$result['faultstring']))
112
+	elseif (preg_match('/SERVER_BUSY/i', $result['faultstring']))
113 113
 	{
114 114
 		print '<font class="error">'.$langs->trans("ErrorServiceUnavailableTryLater").'</font><br>';
115
-		$messagetoshow=$soapclient->response;
115
+		$messagetoshow = $soapclient->response;
116 116
 	}
117 117
 	elseif ($result['faultstring'])
118 118
 	{
119 119
 		print '<font class="error">'.$langs->trans("Error").'</font><br>';
120
-		$messagetoshow=$result['faultstring'];
120
+		$messagetoshow = $result['faultstring'];
121 121
 	}
122 122
 	// Syntaxe ko
123
-	elseif (preg_match('/INVALID_INPUT/i',$result['faultstring'])
124
-	|| ($result['requestDate'] && ! $result['valid']))
123
+	elseif (preg_match('/INVALID_INPUT/i', $result['faultstring'])
124
+	|| ($result['requestDate'] && !$result['valid']))
125 125
 	{
126 126
 		if ($result['requestDate']) print $langs->trans("Date").': '.$result['requestDate'].'<br>';
127 127
 		print $langs->trans("VATIntraSyntaxIsValid").': <font class="error">'.$langs->trans("No").'</font> (Might be a non europeen VAT)<br>';
@@ -134,13 +134,13 @@  discard block
 block discarded – undo
134 134
 		if ($result['requestDate']) print $langs->trans("Date").': '.$result['requestDate'].'<br>';
135 135
 		print $langs->trans("VATIntraSyntaxIsValid").': <font class="ok">'.$langs->trans("Yes").'</font><br>';
136 136
 		print $langs->trans("ValueIsValid").': ';
137
-		if (preg_match('/MS_UNAVAILABLE/i',$result['faultstring']))
137
+		if (preg_match('/MS_UNAVAILABLE/i', $result['faultstring']))
138 138
 		{
139
-			print '<font class="error">'.$langs->trans("ErrorVATCheckMS_UNAVAILABLE",$countryCode).'</font><br>';
139
+			print '<font class="error">'.$langs->trans("ErrorVATCheckMS_UNAVAILABLE", $countryCode).'</font><br>';
140 140
 		}
141 141
 		else
142 142
 		{
143
-			if (! empty($result['valid']) && ($result['valid']==1 || $result['valid']=='true'))
143
+			if (!empty($result['valid']) && ($result['valid'] == 1 || $result['valid'] == 'true'))
144 144
 			{
145 145
 				print '<font class="ok">'.$langs->trans("Yes").'</font>';
146 146
 				print '<br>';
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
 }
164 164
 
165 165
 print '<br>';
166
-print $langs->trans("VATIntraManualCheck",$langs->trans("VATIntraCheckURL"),$langs->trans("VATIntraCheckURL")).'<br>';
166
+print $langs->trans("VATIntraManualCheck", $langs->trans("VATIntraCheckURL"), $langs->trans("VATIntraCheckURL")).'<br>';
167 167
 print '<br>';
168 168
 print '<div class="center"><input type="button" class="button" value="'.$langs->trans("CloseWindow").'" onclick="javascript: window.close()"></div>';
169 169
 
Please login to merge, or discard this patch.
dolibarr/htdocs/api/class/api_login.class.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 	 * @url GET /
56 56
 	 * @url POST /
57 57
 	 */
58
-    public function index($login, $password, $entity='', $reset=0)
58
+    public function index($login, $password, $entity = '', $reset = 0)
59 59
     {
60 60
 
61 61
 	    global $conf, $dolibarr_main_authentication, $dolibarr_auto_user;
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 		// Authentication mode: forceuser
67 67
 		if ($dolibarr_main_authentication == 'forceuser')
68 68
 		{
69
-			if (empty($dolibarr_auto_user)) $dolibarr_auto_user='auto';
69
+			if (empty($dolibarr_auto_user)) $dolibarr_auto_user = 'auto';
70 70
 			if ($dolibarr_auto_user != $login)
71 71
 			{
72 72
 				dol_syslog("Warning: your instance is set to use the automatic forced login '".$dolibarr_auto_user."' that is not the requested login. API usage is forbidden in this mode.");
@@ -76,13 +76,13 @@  discard block
 block discarded – undo
76 76
 		// Set authmode
77 77
 		$authmode = explode(',', $dolibarr_main_authentication);
78 78
 
79
-		if ($entity != '' && ! is_numeric($entity))
79
+		if ($entity != '' && !is_numeric($entity))
80 80
 		{
81 81
 			throw new RestException(403, "Bad value for entity, must be the numeric ID of company.");
82 82
 		}
83
-		if ($entity == '') $entity=1;
83
+		if ($entity == '') $entity = 1;
84 84
 
85
-		include_once DOL_DOCUMENT_ROOT . '/core/lib/security2.lib.php';
85
+		include_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
86 86
 		$login = checkLoginPassEntity($login, $password, $entity, $authmode);
87 87
 		if (empty($login))
88 88
 		{
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 
92 92
 		$token = 'failedtogenerateorgettoken';
93 93
 
94
-		$tmpuser=new User($this->db);
94
+		$tmpuser = new User($this->db);
95 95
 		$tmpuser->fetch(0, $login, 0, 0, $entity);
96 96
 		if (empty($tmpuser->id))
97 97
 		{
@@ -108,14 +108,14 @@  discard block
 block discarded – undo
108 108
 			}
109 109
 
110 110
     		// Generate token for user
111
-    		$token = dol_hash($login.uniqid().$conf->global->MAIN_API_KEY,1);
111
+    		$token = dol_hash($login.uniqid().$conf->global->MAIN_API_KEY, 1);
112 112
 
113 113
     		// We store API token into database
114 114
     		$sql = "UPDATE ".MAIN_DB_PREFIX."user";
115
-    		$sql.= " SET api_key = '".$this->db->escape($token)."'";
116
-    		$sql.= " WHERE login = '".$this->db->escape($login)."'";
115
+    		$sql .= " SET api_key = '".$this->db->escape($token)."'";
116
+    		$sql .= " WHERE login = '".$this->db->escape($login)."'";
117 117
 
118
-    		dol_syslog(get_class($this)."::login", LOG_DEBUG);	// No log
118
+    		dol_syslog(get_class($this)."::login", LOG_DEBUG); // No log
119 119
     		$result = $this->db->query($sql);
120 120
     		if (!$result)
121 121
     		{
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 				'code' => 200,
134 134
 				'token' => $token,
135 135
 			    'entity' => $tmpuser->entity,
136
-			    'message' => 'Welcome ' . $login.($reset?' - Token is new':' - This is your token (generated by a previous call). You can use it to make any REST API call, or enter it into the DOLAPIKEY field to use the Dolibarr API explorer.')
136
+			    'message' => 'Welcome '.$login.($reset ? ' - Token is new' : ' - This is your token (generated by a previous call). You can use it to make any REST API call, or enter it into the DOLAPIKEY field to use the Dolibarr API explorer.')
137 137
 			)
138 138
 		);
139 139
 	}
Please login to merge, or discard this patch.
dolibarr/htdocs/api/class/api.class.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
      * @param   string  $cachedir       Cache dir
47 47
      * @param   boolean $refreshCache   Update cache
48 48
      */
49
-    function __construct($db, $cachedir='', $refreshCache=false)
49
+    function __construct($db, $cachedir = '', $refreshCache = false)
50 50
     {
51 51
         global $conf, $dolibarr_main_url_root;
52 52
 
@@ -54,14 +54,14 @@  discard block
 block discarded – undo
54 54
         Defaults::$cacheDirectory = $cachedir;
55 55
 
56 56
         $this->db = $db;
57
-        $production_mode = ( empty($conf->global->API_PRODUCTION_MODE) ? false : true );
57
+        $production_mode = (empty($conf->global->API_PRODUCTION_MODE) ? false : true);
58 58
         $this->r = new Restler($production_mode, $refreshCache);
59 59
 
60
-        $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
61
-        $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
60
+        $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
61
+        $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
62 62
 
63
-        $urlwithouturlrootautodetect=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim(DOL_MAIN_URL_ROOT));
64
-        $urlwithrootautodetect=$urlwithouturlroot.DOL_URL_ROOT; // This is to use local domain autodetected by dolibarr from url
63
+        $urlwithouturlrootautodetect = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim(DOL_MAIN_URL_ROOT));
64
+        $urlwithrootautodetect = $urlwithouturlroot.DOL_URL_ROOT; // This is to use local domain autodetected by dolibarr from url
65 65
 
66 66
         $this->r->setBaseUrls($urlwithouturlroot, $urlwithouturlrootautodetect);
67 67
         $this->r->setAPIVersion(1);
@@ -118,9 +118,9 @@  discard block
 block discarded – undo
118 118
         unset($object->ref_next);
119 119
         unset($object->ref_int);
120 120
 
121
-        unset($object->projet);     // Should be fk_project
122
-        unset($object->project);    // Should be fk_project
123
-        unset($object->author);     // Should be fk_user_author
121
+        unset($object->projet); // Should be fk_project
122
+        unset($object->project); // Should be fk_project
123
+        unset($object->author); // Should be fk_user_author
124 124
         unset($object->timespent_old_duration);
125 125
         unset($object->timespent_id);
126 126
         unset($object->timespent_duration);
@@ -162,9 +162,9 @@  discard block
 block discarded – undo
162 162
         unset($object->oldcopy);
163 163
 
164 164
         // If object has lines, remove $db property
165
-        if (isset($object->lines) && is_array($object->lines) && count($object->lines) > 0)  {
165
+        if (isset($object->lines) && is_array($object->lines) && count($object->lines) > 0) {
166 166
             $nboflines = count($object->lines);
167
-        	for ($i=0; $i < $nboflines; $i++)
167
+        	for ($i = 0; $i < $nboflines; $i++)
168 168
             {
169 169
                 $this->_cleanObjectDatas($object->lines[$i]);
170 170
 
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
             }
201 201
         }
202 202
 
203
-        if (! empty($object->thirdparty) && is_object($object->thirdparty))
203
+        if (!empty($object->thirdparty) && is_object($object->thirdparty))
204 204
         {
205 205
         	$this->_cleanObjectDatas($object->thirdparty);
206 206
         }
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
      * @return bool
223 223
 	 * @throws RestException
224 224
 	 */
225
-    static function _checkAccessToResource($resource, $resource_id=0, $dbtablename='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid')
225
+    static function _checkAccessToResource($resource, $resource_id = 0, $dbtablename = '', $feature2 = '', $dbt_keyfield = 'fk_soc', $dbt_select = 'rowid')
226 226
     {
227 227
 
228 228
 		// Features/modules to check
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
 		}
236 236
 
237 237
 		// More subfeatures to check
238
-		if (! empty($feature2)) {
238
+		if (!empty($feature2)) {
239 239
 			$feature2 = explode("|", $feature2);
240 240
 		}
241 241
 
@@ -252,17 +252,17 @@  discard block
 block discarded – undo
252 252
 	{
253 253
 	    //$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
254 254
 	    //$tmp=preg_replace_all('/'.$regexstring.'/', '', $sqlfilters);
255
-	    $tmp=$sqlfilters;
256
-	    $ok=0;
257
-	    $i=0; $nb=strlen($tmp);
258
-	    $counter=0;
255
+	    $tmp = $sqlfilters;
256
+	    $ok = 0;
257
+	    $i = 0; $nb = strlen($tmp);
258
+	    $counter = 0;
259 259
 	    while ($i < $nb)
260 260
 	    {
261
-	        if ($tmp[$i]=='(') $counter++;
262
-	        if ($tmp[$i]==')') $counter--;
261
+	        if ($tmp[$i] == '(') $counter++;
262
+	        if ($tmp[$i] == ')') $counter--;
263 263
             if ($counter < 0)
264 264
             {
265
-	           $error="Bad sqlfilters=".$sqlfilters;
265
+	           $error = "Bad sqlfilters=".$sqlfilters;
266 266
 	           dol_syslog($error, LOG_WARNING);
267 267
 	           return false;
268 268
             }
@@ -285,10 +285,10 @@  discard block
 block discarded – undo
285 285
 
286 286
 	    //dol_syslog("Convert matches ".$matches[1]);
287 287
 	    if (empty($matches[1])) return '';
288
-	    $tmp=explode(':',$matches[1]);
288
+	    $tmp = explode(':', $matches[1]);
289 289
         if (count($tmp) < 3) return '';
290 290
 
291
-	    $tmpescaped=$tmp[2];
291
+	    $tmpescaped = $tmp[2];
292 292
 	    if (preg_match('/^\'(.*)\'$/', $tmpescaped, $regbis))
293 293
 	    {
294 294
 	        $tmpescaped = "'".$db->escape($regbis[1])."'";
Please login to merge, or discard this patch.
dolibarr/htdocs/api/class/api_access.class.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 
19 19
 // Create the autoloader for Luracast
20 20
 require_once DOL_DOCUMENT_ROOT.'/includes/restler/framework/Luracast/Restler/AutoLoader.php';
21
-call_user_func(function () {
21
+call_user_func(function() {
22 22
     $loader = Luracast\Restler\AutoLoader::instance();
23 23
     spl_autoload_register($loader);
24 24
     return $loader;
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 	/**
48 48
 	 * @var array $requires	role required by API method		user / external / admin
49 49
 	 */
50
-	public static $requires = array('user','external','admin');
50
+	public static $requires = array('user', 'external', 'admin');
51 51
 
52 52
 	/**
53 53
 	 * @var string $role		user role
@@ -91,11 +91,11 @@  discard block
 block discarded – undo
91 91
 		if (isset($_GET['DOLAPIKEY']))
92 92
 		{
93 93
 		    // TODO Add option to disable use of api key on url. Return errors if used.
94
-		    $api_key = $_GET['DOLAPIKEY'];                     // With GET method
94
+		    $api_key = $_GET['DOLAPIKEY']; // With GET method
95 95
 		}
96 96
 		if (isset($_SERVER['HTTP_DOLAPIKEY']))         // Param DOLAPIKEY in header can be read with HTTP_DOLAPIKEY
97 97
 		{
98
-		    $api_key = $_SERVER['HTTP_DOLAPIKEY'];     // With header method (recommanded)
98
+		    $api_key = $_SERVER['HTTP_DOLAPIKEY']; // With header method (recommanded)
99 99
 		}
100 100
 
101 101
 		if ($api_key)
@@ -103,9 +103,9 @@  discard block
 block discarded – undo
103 103
 			$userentity = 0;
104 104
 
105 105
 			$sql = "SELECT u.login, u.datec, u.api_key, ";
106
-			$sql.= " u.tms as date_modification, u.entity";
107
-			$sql.= " FROM ".MAIN_DB_PREFIX."user as u";
108
-			$sql.= " WHERE u.api_key = '".$db->escape($api_key)."'";
106
+			$sql .= " u.tms as date_modification, u.entity";
107
+			$sql .= " FROM ".MAIN_DB_PREFIX."user as u";
108
+			$sql .= " WHERE u.api_key = '".$db->escape($api_key)."'";
109 109
 			// TODO Check if 2 users has same API key.
110 110
 
111 111
 			$result = $db->query($sql);
@@ -118,11 +118,11 @@  discard block
 block discarded – undo
118 118
 					$stored_key = $obj->api_key;
119 119
 					$userentity = $obj->entity;
120 120
 
121
-					if (! defined("DOLENTITY") && $conf->entity != ($obj->entity?$obj->entity:1))		// If API was not forced with HTTP_DOLENTITY, and user is on another entity, so we reset entity to entity of user
121
+					if (!defined("DOLENTITY") && $conf->entity != ($obj->entity ? $obj->entity : 1))		// If API was not forced with HTTP_DOLENTITY, and user is on another entity, so we reset entity to entity of user
122 122
 					{
123
-						$conf->entity = ($obj->entity?$obj->entity:1);
123
+						$conf->entity = ($obj->entity ? $obj->entity : 1);
124 124
 						// We must also reload global conf to get params from the entity
125
-						dol_syslog("Entity was not set on http header with HTTP_DOLAPIENTITY (recommanded for performance purpose), so we switch now on entity of user (".$conf->entity .") and we have to reload configuration.", LOG_WARNING);
125
+						dol_syslog("Entity was not set on http header with HTTP_DOLAPIENTITY (recommanded for performance purpose), so we switch now on entity of user (".$conf->entity.") and we have to reload configuration.", LOG_WARNING);
126 126
 						$conf->setValues($db);
127 127
 					}
128 128
 				}
@@ -136,22 +136,22 @@  discard block
 block discarded – undo
136 136
 				return false;
137 137
 			}
138 138
 
139
-			if (! $login)
139
+			if (!$login)
140 140
 			{
141 141
 			    throw new RestException(503, 'Error when searching login user from api key');
142 142
 			}
143 143
 			$fuser = new User($db);
144
-			$result = $fuser->fetch('', $login, '', 0, (empty($userentity) ? -1 : $conf->entity));	// If user is not entity 0, we search in working entity $conf->entity  (that may have been forced to a different value than user entity)
144
+			$result = $fuser->fetch('', $login, '', 0, (empty($userentity) ? -1 : $conf->entity)); // If user is not entity 0, we search in working entity $conf->entity  (that may have been forced to a different value than user entity)
145 145
 			if ($result <= 0) {
146 146
 				throw new RestException(503, 'Error when fetching user :'.$fuser->error.' (conf->entity='.$conf->entity.')');
147 147
 			}
148 148
 			$fuser->getrights();
149 149
 			static::$user = $fuser;
150 150
 
151
-			if($fuser->societe_id)
151
+			if ($fuser->societe_id)
152 152
 				static::$role = 'external';
153 153
 
154
-			if($fuser->admin)
154
+			if ($fuser->admin)
155 155
 				static::$role = 'admin';
156 156
         }
157 157
 		else
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 	    $userClass::setCacheIdentifier(static::$role);
163 163
 	    Resources::$accessControlFunction = 'DolibarrApiAccess::verifyAccess';
164 164
 	    $requirefortest = static::$requires;
165
-	    if (! is_array($requirefortest)) $requirefortest=explode(',',$requirefortest);
165
+	    if (!is_array($requirefortest)) $requirefortest = explode(',', $requirefortest);
166 166
 	    return in_array(static::$role, (array) $requirefortest) || static::$role == 'admin';
167 167
 	}
168 168
 
Please login to merge, or discard this patch.
dolibarr/htdocs/api/class/api_setup.class.php 1 patch
Spacing   +223 added lines, -223 removed lines patch added patch discarded remove patch
@@ -66,22 +66,22 @@  discard block
 block discarded – undo
66 66
         $list = array();
67 67
 
68 68
         $sql = "SELECT id, code, type, libelle as label, module";
69
-        $sql.= " FROM ".MAIN_DB_PREFIX."c_paiement as t";
70
-        $sql.= " WHERE t.entity IN (".getEntity('c_paiement').")";
71
-        $sql.= " AND t.active = ".$active;
69
+        $sql .= " FROM ".MAIN_DB_PREFIX."c_paiement as t";
70
+        $sql .= " WHERE t.entity IN (".getEntity('c_paiement').")";
71
+        $sql .= " AND t.active = ".$active;
72 72
         // Add sql filters
73 73
         if ($sqlfilters)
74 74
         {
75
-            if (! DolibarrApi::_checkFilters($sqlfilters))
75
+            if (!DolibarrApi::_checkFilters($sqlfilters))
76 76
             {
77 77
                 throw new RestException(400, 'error when validating parameter sqlfilters '.$sqlfilters);
78 78
             }
79
-	          $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
80
-            $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
79
+	          $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
80
+            $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
81 81
         }
82 82
 
83 83
 
84
-        $sql.= $this->db->order($sortfield, $sortorder);
84
+        $sql .= $this->db->order($sortfield, $sortorder);
85 85
 
86 86
         if ($limit) {
87 87
             if ($page < 0) {
@@ -135,19 +135,19 @@  discard block
 block discarded – undo
135 135
         // Note: The filter is not applied in the SQL request because it must
136 136
         // be applied to the translated names, not to the names in database.
137 137
         $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."c_country as t";
138
-        $sql.=" WHERE 1 = 1";
138
+        $sql .= " WHERE 1 = 1";
139 139
         // Add sql filters
140 140
         if ($sqlfilters)
141 141
         {
142
-            if (! DolibarrApi::_checkFilters($sqlfilters))
142
+            if (!DolibarrApi::_checkFilters($sqlfilters))
143 143
             {
144 144
                 throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
145 145
             }
146
-	        $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
147
-            $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
146
+	        $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
147
+            $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
148 148
         }
149 149
 
150
-        $sql.= $this->db->order($sortfield, $sortorder);
150
+        $sql .= $this->db->order($sortfield, $sortorder);
151 151
 
152 152
         if ($limit) {
153 153
             if ($page < 0) {
@@ -233,21 +233,21 @@  discard block
 block discarded – undo
233 233
         $list = array();
234 234
 
235 235
         $sql = "SELECT rowid, code, label";
236
-        $sql.= " FROM ".MAIN_DB_PREFIX."c_availability as t";
237
-        $sql.= " WHERE t.active = ".$active;
236
+        $sql .= " FROM ".MAIN_DB_PREFIX."c_availability as t";
237
+        $sql .= " WHERE t.active = ".$active;
238 238
         // Add sql filters
239 239
         if ($sqlfilters)
240 240
         {
241
-            if (! DolibarrApi::_checkFilters($sqlfilters))
241
+            if (!DolibarrApi::_checkFilters($sqlfilters))
242 242
             {
243 243
                 throw new RestException(400, 'error when validating parameter sqlfilters '.$sqlfilters);
244 244
             }
245
-                  $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
246
-            $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
245
+                  $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
246
+            $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
247 247
         }
248 248
 
249 249
 
250
-        $sql.= $this->db->order($sortfield, $sortorder);
250
+        $sql .= $this->db->order($sortfield, $sortorder);
251 251
 
252 252
         if ($limit) {
253 253
             if ($page < 0) {
@@ -338,23 +338,23 @@  discard block
 block discarded – undo
338 338
         $list = array();
339 339
 
340 340
         $sql = "SELECT id, code, type, libelle as label, module";
341
-        $sql.= " FROM ".MAIN_DB_PREFIX."c_actioncomm as t";
342
-        $sql.= " WHERE t.active = 1";
343
-        if ($type) $sql.=" AND t.type LIKE '%" . $this->db->escape($type) . "%'";
344
-        if ($module)    $sql.=" AND t.module LIKE '%" . $this->db->escape($module) . "%'";
341
+        $sql .= " FROM ".MAIN_DB_PREFIX."c_actioncomm as t";
342
+        $sql .= " WHERE t.active = 1";
343
+        if ($type) $sql .= " AND t.type LIKE '%".$this->db->escape($type)."%'";
344
+        if ($module)    $sql .= " AND t.module LIKE '%".$this->db->escape($module)."%'";
345 345
         // Add sql filters
346 346
         if ($sqlfilters)
347 347
         {
348
-            if (! DolibarrApi::_checkFilters($sqlfilters))
348
+            if (!DolibarrApi::_checkFilters($sqlfilters))
349 349
             {
350 350
                 throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
351 351
             }
352
-	        $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
353
-            $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
352
+	        $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
353
+            $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
354 354
         }
355 355
 
356 356
 
357
-        $sql.= $this->db->order($sortfield, $sortorder);
357
+        $sql .= $this->db->order($sortfield, $sortorder);
358 358
 
359 359
         if ($limit) {
360 360
             if ($page < 0) {
@@ -400,22 +400,22 @@  discard block
 block discarded – undo
400 400
         $list = array();
401 401
 
402 402
         $sql = "SELECT rowid, code, label, module";
403
-        $sql.= " FROM ".MAIN_DB_PREFIX."c_civility as t";
404
-        $sql.= " WHERE t.active = 1";
405
-        if ($module)    $sql.=" AND t.module LIKE '%" . $this->db->escape($module) . "%'";
403
+        $sql .= " FROM ".MAIN_DB_PREFIX."c_civility as t";
404
+        $sql .= " WHERE t.active = 1";
405
+        if ($module)    $sql .= " AND t.module LIKE '%".$this->db->escape($module)."%'";
406 406
         // Add sql filters
407 407
         if ($sqlfilters)
408 408
         {
409
-            if (! DolibarrApi::_checkFilters($sqlfilters))
409
+            if (!DolibarrApi::_checkFilters($sqlfilters))
410 410
             {
411 411
                 throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
412 412
             }
413
-	        $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
414
-            $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
413
+	        $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
414
+            $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
415 415
         }
416 416
 
417 417
 
418
-        $sql.= $this->db->order($sortfield, $sortorder);
418
+        $sql .= $this->db->order($sortfield, $sortorder);
419 419
 
420 420
         if ($limit) {
421 421
             if ($page < 0) {
@@ -458,27 +458,27 @@  discard block
 block discarded – undo
458 458
     {
459 459
         $list = array();
460 460
 
461
-        if ($type == 'thirdparty') $type='societe';
462
-        if ($type == 'contact') $type='socpeople';
461
+        if ($type == 'thirdparty') $type = 'societe';
462
+        if ($type == 'contact') $type = 'socpeople';
463 463
 
464 464
         $sql = "SELECT t.rowid, t.name, t.label, t.type, t.size, t.elementtype, t.fieldunique, t.fieldrequired, t.param, t.pos, t.alwayseditable, t.perms, t.list, t.fielddefault, t.fieldcomputed";
465
-        $sql.= " FROM ".MAIN_DB_PREFIX."extrafields as t";
466
-        $sql.= " WHERE t.entity IN (".getEntity('extrafields').")";
467
-        if (! empty($type)) $sql.= " AND t.elementtype = '".$this->db->escape($type)."'";
465
+        $sql .= " FROM ".MAIN_DB_PREFIX."extrafields as t";
466
+        $sql .= " WHERE t.entity IN (".getEntity('extrafields').")";
467
+        if (!empty($type)) $sql .= " AND t.elementtype = '".$this->db->escape($type)."'";
468 468
         // Add sql filters
469 469
         if ($sqlfilters)
470 470
         {
471
-        	if (! DolibarrApi::_checkFilters($sqlfilters))
471
+        	if (!DolibarrApi::_checkFilters($sqlfilters))
472 472
         	{
473 473
         		throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
474 474
         	}
475
-        	$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
476
-        	$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
475
+        	$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
476
+        	$sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
477 477
         }
478 478
 
479
-        $sql.= $this->db->order($sortfield, $sortorder);
479
+        $sql .= $this->db->order($sortfield, $sortorder);
480 480
 
481
-        $resql=$this->db->query($sql);
481
+        $resql = $this->db->query($sql);
482 482
         if ($resql)
483 483
         {
484 484
         	if ($this->db->num_rows($resql))
@@ -486,19 +486,19 @@  discard block
 block discarded – undo
486 486
         		while ($tab = $this->db->fetch_object($resql))
487 487
         		{
488 488
         			// New usage
489
-        			$list[$tab->elementtype][$tab->name]['type']=$tab->type;
490
-        			$list[$tab->elementtype][$tab->name]['label']=$tab->label;
491
-        			$list[$tab->elementtype][$tab->name]['size']=$tab->size;
492
-        			$list[$tab->elementtype][$tab->name]['elementtype']=$tab->elementtype;
493
-        			$list[$tab->elementtype][$tab->name]['default']=$tab->fielddefault;
494
-        			$list[$tab->elementtype][$tab->name]['computed']=$tab->fieldcomputed;
495
-        			$list[$tab->elementtype][$tab->name]['unique']=$tab->fieldunique;
496
-        			$list[$tab->elementtype][$tab->name]['required']=$tab->fieldrequired;
497
-        			$list[$tab->elementtype][$tab->name]['param']=($tab->param ? unserialize($tab->param) : '');
498
-        			$list[$tab->elementtype][$tab->name]['pos']=$tab->pos;
499
-        			$list[$tab->elementtype][$tab->name]['alwayseditable']=$tab->alwayseditable;
500
-        			$list[$tab->elementtype][$tab->name]['perms']=$tab->perms;
501
-        			$list[$tab->elementtype][$tab->name]['list']=$tab->list;
489
+        			$list[$tab->elementtype][$tab->name]['type'] = $tab->type;
490
+        			$list[$tab->elementtype][$tab->name]['label'] = $tab->label;
491
+        			$list[$tab->elementtype][$tab->name]['size'] = $tab->size;
492
+        			$list[$tab->elementtype][$tab->name]['elementtype'] = $tab->elementtype;
493
+        			$list[$tab->elementtype][$tab->name]['default'] = $tab->fielddefault;
494
+        			$list[$tab->elementtype][$tab->name]['computed'] = $tab->fieldcomputed;
495
+        			$list[$tab->elementtype][$tab->name]['unique'] = $tab->fieldunique;
496
+        			$list[$tab->elementtype][$tab->name]['required'] = $tab->fieldrequired;
497
+        			$list[$tab->elementtype][$tab->name]['param'] = ($tab->param ? unserialize($tab->param) : '');
498
+        			$list[$tab->elementtype][$tab->name]['pos'] = $tab->pos;
499
+        			$list[$tab->elementtype][$tab->name]['alwayseditable'] = $tab->alwayseditable;
500
+        			$list[$tab->elementtype][$tab->name]['perms'] = $tab->perms;
501
+        			$list[$tab->elementtype][$tab->name]['list'] = $tab->list;
502 502
         		}
503 503
         	}
504 504
         }
@@ -507,7 +507,7 @@  discard block
 block discarded – undo
507 507
             throw new RestException(503, 'Error when retrieving list of extra fields : '.$this->db->lasterror());
508 508
         }
509 509
 
510
-        if (! count($list))
510
+        if (!count($list))
511 511
         {
512 512
         	throw new RestException(404, 'No extrafield found');
513 513
         }
@@ -537,23 +537,23 @@  discard block
 block discarded – undo
537 537
         $list = array();
538 538
 
539 539
         $sql = "SELECT rowid AS id, zip, town, fk_county, fk_pays AS fk_country";
540
-        $sql.= " FROM ".MAIN_DB_PREFIX."c_ziptown as t";
541
-        $sql.= " WHERE t.active = 1";
542
-        if ($zipcode) $sql.=" AND t.zip LIKE '%" . $this->db->escape($zipcode) . "%'";
543
-        if ($town)    $sql.=" AND t.town LIKE '%" . $this->db->escape($town) . "%'";
540
+        $sql .= " FROM ".MAIN_DB_PREFIX."c_ziptown as t";
541
+        $sql .= " WHERE t.active = 1";
542
+        if ($zipcode) $sql .= " AND t.zip LIKE '%".$this->db->escape($zipcode)."%'";
543
+        if ($town)    $sql .= " AND t.town LIKE '%".$this->db->escape($town)."%'";
544 544
         // Add sql filters
545 545
         if ($sqlfilters)
546 546
         {
547
-            if (! DolibarrApi::_checkFilters($sqlfilters))
547
+            if (!DolibarrApi::_checkFilters($sqlfilters))
548 548
             {
549 549
                 throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
550 550
             }
551
-	        $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
552
-            $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
551
+	        $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
552
+            $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
553 553
         }
554 554
 
555 555
 
556
-        $sql.= $this->db->order($sortfield, $sortorder);
556
+        $sql .= $this->db->order($sortfield, $sortorder);
557 557
 
558 558
         if ($limit) {
559 559
             if ($page < 0) {
@@ -601,22 +601,22 @@  discard block
 block discarded – undo
601 601
         $list = array();
602 602
 
603 603
         $sql = "SELECT rowid as id, code, sortorder, libelle as label, libelle_facture as descr, type_cdr, nbjour, decalage, module";
604
-        $sql.= " FROM ".MAIN_DB_PREFIX."c_payment_term as t";
605
-        $sql.= " WHERE t.entity IN (".getEntity('c_payment_term').")";
606
-        $sql.= " AND t.active = ".$active;
604
+        $sql .= " FROM ".MAIN_DB_PREFIX."c_payment_term as t";
605
+        $sql .= " WHERE t.entity IN (".getEntity('c_payment_term').")";
606
+        $sql .= " AND t.active = ".$active;
607 607
         // Add sql filters
608 608
         if ($sqlfilters)
609 609
         {
610
-            if (! DolibarrApi::_checkFilters($sqlfilters))
610
+            if (!DolibarrApi::_checkFilters($sqlfilters))
611 611
             {
612 612
                 throw new RestException(400, 'Error when validating parameter sqlfilters '.$sqlfilters);
613 613
             }
614
-                $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
615
-            $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
614
+                $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
615
+            $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
616 616
         }
617 617
 
618 618
 
619
-        $sql.= $this->db->order($sortfield, $sortorder);
619
+        $sql .= $this->db->order($sortfield, $sortorder);
620 620
 
621 621
         if ($limit) {
622 622
             if ($page < 0) {
@@ -661,21 +661,21 @@  discard block
 block discarded – undo
661 661
     	$list = array();
662 662
 
663 663
     	$sql = "SELECT rowid, code, pos,  label, use_default, description";
664
-    	$sql.= " FROM ".MAIN_DB_PREFIX."c_ticket_category as t";
665
-    	$sql.= " WHERE t.active = 1";
664
+    	$sql .= " FROM ".MAIN_DB_PREFIX."c_ticket_category as t";
665
+    	$sql .= " WHERE t.active = 1";
666 666
     	// Add sql filters
667 667
     	if ($sqlfilters)
668 668
     	{
669
-    		if (! DolibarrApi::_checkFilters($sqlfilters))
669
+    		if (!DolibarrApi::_checkFilters($sqlfilters))
670 670
     		{
671 671
     			throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
672 672
     		}
673
-    		$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
674
-    		$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
673
+    		$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
674
+    		$sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
675 675
     	}
676 676
 
677 677
 
678
-    	$sql.= $this->db->order($sortfield, $sortorder);
678
+    	$sql .= $this->db->order($sortfield, $sortorder);
679 679
 
680 680
     	if ($limit) {
681 681
     		if ($page < 0) {
@@ -720,21 +720,21 @@  discard block
 block discarded – undo
720 720
     	$list = array();
721 721
 
722 722
     	$sql = "SELECT rowid, code, pos,  label, use_default, color, description";
723
-    	$sql.= " FROM ".MAIN_DB_PREFIX."c_ticket_severity as t";
724
-    	$sql.= " WHERE t.active = 1";
723
+    	$sql .= " FROM ".MAIN_DB_PREFIX."c_ticket_severity as t";
724
+    	$sql .= " WHERE t.active = 1";
725 725
     	// Add sql filters
726 726
     	if ($sqlfilters)
727 727
     	{
728
-    		if (! DolibarrApi::_checkFilters($sqlfilters))
728
+    		if (!DolibarrApi::_checkFilters($sqlfilters))
729 729
     		{
730 730
     			throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
731 731
     		}
732
-    		$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
733
-    		$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
732
+    		$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
733
+    		$sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
734 734
     	}
735 735
 
736 736
 
737
-    	$sql.= $this->db->order($sortfield, $sortorder);
737
+    	$sql .= $this->db->order($sortfield, $sortorder);
738 738
 
739 739
     	if ($limit) {
740 740
     		if ($page < 0) {
@@ -779,23 +779,23 @@  discard block
 block discarded – undo
779 779
     	$list = array();
780 780
 
781 781
     	$sql = "SELECT rowid, code, pos,  label, use_default, description";
782
-    	$sql.= " FROM ".MAIN_DB_PREFIX."c_ticket_type as t";
783
-    	$sql.= " WHERE t.active = 1";
784
-    	if ($type) $sql.=" AND t.type LIKE '%" . $this->db->escape($type) . "%'";
785
-    	if ($module)    $sql.=" AND t.module LIKE '%" . $this->db->escape($module) . "%'";
782
+    	$sql .= " FROM ".MAIN_DB_PREFIX."c_ticket_type as t";
783
+    	$sql .= " WHERE t.active = 1";
784
+    	if ($type) $sql .= " AND t.type LIKE '%".$this->db->escape($type)."%'";
785
+    	if ($module)    $sql .= " AND t.module LIKE '%".$this->db->escape($module)."%'";
786 786
     	// Add sql filters
787 787
     	if ($sqlfilters)
788 788
     	{
789
-    		if (! DolibarrApi::_checkFilters($sqlfilters))
789
+    		if (!DolibarrApi::_checkFilters($sqlfilters))
790 790
     		{
791 791
     			throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
792 792
     		}
793
-    		$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
794
-    		$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
793
+    		$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
794
+    		$sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
795 795
     	}
796 796
 
797 797
 
798
-    	$sql.= $this->db->order($sortfield, $sortorder);
798
+    	$sql .= $this->db->order($sortfield, $sortorder);
799 799
 
800 800
     	if ($limit) {
801 801
     		if ($page < 0) {
@@ -836,7 +836,7 @@  discard block
 block discarded – undo
836 836
     {
837 837
     	global $langs, $conf;
838 838
 
839
-    	if (! DolibarrApiAccess::$user->admin
839
+    	if (!DolibarrApiAccess::$user->admin
840 840
     		&& (empty($conf->global->API_LOGIN_ALLOWED_FOR_INTEGRITY_CHECK) || DolibarrApiAccess::$user->login != $conf->global->API_LOGIN_ALLOWED_FOR_INTEGRITY_CHECK))
841 841
     	{
842 842
     		throw new RestException(503, 'Error API open to admin users only or to login user defined with constant API_LOGIN_ALLOWED_FOR_INTEGRITY_CHECK');
@@ -854,13 +854,13 @@  discard block
 block discarded – undo
854 854
     	$file_list = array('missing' => array(), 'updated' => array());
855 855
 
856 856
     	// Local file to compare to
857
-    	$xmlshortfile = GETPOST('xmlshortfile')?GETPOST('xmlshortfile'):'/install/filelist-'.DOL_VERSION.'.xml';
857
+    	$xmlshortfile = GETPOST('xmlshortfile') ?GETPOST('xmlshortfile') : '/install/filelist-'.DOL_VERSION.'.xml';
858 858
     	$xmlfile = DOL_DOCUMENT_ROOT.$xmlshortfile;
859 859
     	// Remote file to compare to
860 860
     	$xmlremote = ($target == 'default' ? '' : $target);
861
-    	if (empty($xmlremote) && ! empty($conf->global->MAIN_FILECHECK_URL)) $xmlremote = $conf->global->MAIN_FILECHECK_URL;
862
-    	$param='MAIN_FILECHECK_URL_'.DOL_VERSION;
863
-    	if (empty($xmlremote) && ! empty($conf->global->$param)) $xmlremote = $conf->global->$param;
861
+    	if (empty($xmlremote) && !empty($conf->global->MAIN_FILECHECK_URL)) $xmlremote = $conf->global->MAIN_FILECHECK_URL;
862
+    	$param = 'MAIN_FILECHECK_URL_'.DOL_VERSION;
863
+    	if (empty($xmlremote) && !empty($conf->global->$param)) $xmlremote = $conf->global->$param;
864 864
     	if (empty($xmlremote)) $xmlremote = 'https://www.dolibarr.org/files/stable/signatures/filelist-'.DOL_VERSION.'.xml';
865 865
 
866 866
     	if ($target == 'local')
@@ -871,7 +871,7 @@  discard block
 block discarded – undo
871 871
     		}
872 872
     		else
873 873
     		{
874
-    			throw new RestException(500, $langs->trans('XmlNotFound') . ': ' . $xmlfile);
874
+    			throw new RestException(500, $langs->trans('XmlNotFound').': '.$xmlfile);
875 875
     		}
876 876
     	}
877 877
     	else
@@ -879,7 +879,7 @@  discard block
 block discarded – undo
879 879
     		$xmlarray = getURLContent($xmlremote);
880 880
 
881 881
     		// Return array('content'=>response,'curl_error_no'=>errno,'curl_error_msg'=>errmsg...)
882
-    		if (! $xmlarray['curl_error_no'] && $xmlarray['http_code'] != '404')
882
+    		if (!$xmlarray['curl_error_no'] && $xmlarray['http_code'] != '404')
883 883
     		{
884 884
     			$xmlfile = $xmlarray['content'];
885 885
     			//print "xmlfilestart".$xmlfile."endxmlfile";
@@ -887,7 +887,7 @@  discard block
 block discarded – undo
887 887
     		}
888 888
     		else
889 889
     		{
890
-    			$errormsg=$langs->trans('XmlNotFound') . ': ' . $xmlremote.' - '.$xmlarray['http_code'].' '.$xmlarray['curl_error_no'].' '.$xmlarray['curl_error_msg'];
890
+    			$errormsg = $langs->trans('XmlNotFound').': '.$xmlremote.' - '.$xmlarray['http_code'].' '.$xmlarray['curl_error_no'].' '.$xmlarray['curl_error_msg'];
891 891
     			throw new RestException(500, $errormsg);
892 892
     		}
893 893
     	}
@@ -903,83 +903,83 @@  discard block
 block discarded – undo
903 903
     		// Forced constants
904 904
     		if (is_object($xml->dolibarr_constants[0]))
905 905
     		{
906
-    			$out.=load_fiche_titre($langs->trans("ForcedConstants"));
906
+    			$out .= load_fiche_titre($langs->trans("ForcedConstants"));
907 907
 
908
-    			$out.='<div class="div-table-responsive-no-min">';
909
-    			$out.='<table class="noborder">';
910
-    			$out.='<tr class="liste_titre">';
911
-    			$out.='<td>#</td>';
912
-    			$out.='<td>' . $langs->trans("Constant") . '</td>';
913
-    			$out.='<td align="center">' . $langs->trans("ExpectedValue") . '</td>';
914
-    			$out.='<td align="center">' . $langs->trans("Value") . '</td>';
915
-    			$out.='</tr>'."\n";
908
+    			$out .= '<div class="div-table-responsive-no-min">';
909
+    			$out .= '<table class="noborder">';
910
+    			$out .= '<tr class="liste_titre">';
911
+    			$out .= '<td>#</td>';
912
+    			$out .= '<td>'.$langs->trans("Constant").'</td>';
913
+    			$out .= '<td align="center">'.$langs->trans("ExpectedValue").'</td>';
914
+    			$out .= '<td align="center">'.$langs->trans("Value").'</td>';
915
+    			$out .= '</tr>'."\n";
916 916
 
917 917
     			$i = 0;
918 918
     			foreach ($xml->dolibarr_constants[0]->constant as $constant)    // $constant is a simpleXMLElement
919 919
     			{
920
-    				$constname=$constant['name'];
921
-    				$constvalue=(string) $constant;
922
-    				$constvalue = (empty($constvalue)?'0':$constvalue);
920
+    				$constname = $constant['name'];
921
+    				$constvalue = (string) $constant;
922
+    				$constvalue = (empty($constvalue) ? '0' : $constvalue);
923 923
     				// Value found
924
-    				$value='';
925
-    				if ($constname && $conf->global->$constname != '') $value=$conf->global->$constname;
926
-    				$valueforchecksum=(empty($value)?'0':$value);
924
+    				$value = '';
925
+    				if ($constname && $conf->global->$constname != '') $value = $conf->global->$constname;
926
+    				$valueforchecksum = (empty($value) ? '0' : $value);
927 927
 
928
-    				$checksumconcat[]=$valueforchecksum;
928
+    				$checksumconcat[] = $valueforchecksum;
929 929
 
930 930
     				$i++;
931
-    				$out.='<tr class="oddeven">';
932
-    				$out.='<td>'.$i.'</td>' . "\n";
933
-    				$out.='<td>'.$constname.'</td>' . "\n";
934
-    				$out.='<td align="center">'.$constvalue.'</td>' . "\n";
935
-    				$out.='<td align="center">'.$valueforchecksum.'</td>' . "\n";
936
-    				$out.="</tr>\n";
931
+    				$out .= '<tr class="oddeven">';
932
+    				$out .= '<td>'.$i.'</td>'."\n";
933
+    				$out .= '<td>'.$constname.'</td>'."\n";
934
+    				$out .= '<td align="center">'.$constvalue.'</td>'."\n";
935
+    				$out .= '<td align="center">'.$valueforchecksum.'</td>'."\n";
936
+    				$out .= "</tr>\n";
937 937
     			}
938 938
 
939
-    			if ($i==0)
939
+    			if ($i == 0)
940 940
     			{
941
-    				$out.='<tr class="oddeven"><td colspan="4" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
941
+    				$out .= '<tr class="oddeven"><td colspan="4" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
942 942
     			}
943
-    			$out.='</table>';
944
-    			$out.='</div>';
943
+    			$out .= '</table>';
944
+    			$out .= '</div>';
945 945
 
946
-    			$out.='<br>';
946
+    			$out .= '<br>';
947 947
     		}
948 948
 
949 949
     		// Scan htdocs
950 950
     		if (is_object($xml->dolibarr_htdocs_dir[0]))
951 951
     		{
952 952
     			//var_dump($xml->dolibarr_htdocs_dir[0]['includecustom']);exit;
953
-    			$includecustom=(empty($xml->dolibarr_htdocs_dir[0]['includecustom'])?0:$xml->dolibarr_htdocs_dir[0]['includecustom']);
953
+    			$includecustom = (empty($xml->dolibarr_htdocs_dir[0]['includecustom']) ? 0 : $xml->dolibarr_htdocs_dir[0]['includecustom']);
954 954
 
955 955
     			// Defined qualified files (must be same than into generate_filelist_xml.php)
956
-    			$regextoinclude='\.(php|css|html|js|json|tpl|jpg|png|gif|sql|lang)$';
957
-    			$regextoexclude='('.($includecustom?'':'custom|').'documents|conf|install|public\/test|Shared\/PCLZip|nusoap\/lib\/Mail|php\/example|php\/test|geoip\/sample.*\.php|ckeditor\/samples|ckeditor\/adapters)$';  // Exclude dirs
956
+    			$regextoinclude = '\.(php|css|html|js|json|tpl|jpg|png|gif|sql|lang)$';
957
+    			$regextoexclude = '('.($includecustom ? '' : 'custom|').'documents|conf|install|public\/test|Shared\/PCLZip|nusoap\/lib\/Mail|php\/example|php\/test|geoip\/sample.*\.php|ckeditor\/samples|ckeditor\/adapters)$'; // Exclude dirs
958 958
     			$scanfiles = dol_dir_list(DOL_DOCUMENT_ROOT, 'files', 1, $regextoinclude, $regextoexclude);
959 959
 
960 960
     			// Fill file_list with files in signature, new files, modified files
961
-    			$ret = getFilesUpdated($file_list, $xml->dolibarr_htdocs_dir[0], '', DOL_DOCUMENT_ROOT, $checksumconcat, $scanfiles);		// Fill array $file_list
961
+    			$ret = getFilesUpdated($file_list, $xml->dolibarr_htdocs_dir[0], '', DOL_DOCUMENT_ROOT, $checksumconcat, $scanfiles); // Fill array $file_list
962 962
     			// Complete with list of new files
963 963
     			foreach ($scanfiles as $keyfile => $valfile)
964 964
     			{
965
-    				$tmprelativefilename=preg_replace('/^'.preg_quote(DOL_DOCUMENT_ROOT,'/').'/','', $valfile['fullname']);
966
-    				if (! in_array($tmprelativefilename, $file_list['insignature']))
965
+    				$tmprelativefilename = preg_replace('/^'.preg_quote(DOL_DOCUMENT_ROOT, '/').'/', '', $valfile['fullname']);
966
+    				if (!in_array($tmprelativefilename, $file_list['insignature']))
967 967
     				{
968
-    					$md5newfile=@md5_file($valfile['fullname']);    // Can fails if we don't have permission to open/read file
969
-    					$file_list['added'][]=array('filename'=>$tmprelativefilename, 'md5'=>$md5newfile);
968
+    					$md5newfile = @md5_file($valfile['fullname']); // Can fails if we don't have permission to open/read file
969
+    					$file_list['added'][] = array('filename'=>$tmprelativefilename, 'md5'=>$md5newfile);
970 970
     				}
971 971
     			}
972 972
 
973 973
     			// Files missings
974
-    			$out.=load_fiche_titre($langs->trans("FilesMissing"));
975
-
976
-    			$out.='<div class="div-table-responsive-no-min">';
977
-    			$out.='<table class="noborder">';
978
-    			$out.='<tr class="liste_titre">';
979
-    			$out.='<td>#</td>';
980
-    			$out.='<td>' . $langs->trans("Filename") . '</td>';
981
-    			$out.='<td align="center">' . $langs->trans("ExpectedChecksum") . '</td>';
982
-    			$out.='</tr>'."\n";
974
+    			$out .= load_fiche_titre($langs->trans("FilesMissing"));
975
+
976
+    			$out .= '<div class="div-table-responsive-no-min">';
977
+    			$out .= '<table class="noborder">';
978
+    			$out .= '<tr class="liste_titre">';
979
+    			$out .= '<td>#</td>';
980
+    			$out .= '<td>'.$langs->trans("Filename").'</td>';
981
+    			$out .= '<td align="center">'.$langs->trans("ExpectedChecksum").'</td>';
982
+    			$out .= '</tr>'."\n";
983 983
     			$tmpfilelist = dol_sort_array($file_list['missing'], 'filename');
984 984
     			if (is_array($tmpfilelist) && count($tmpfilelist))
985 985
     			{
@@ -987,36 +987,36 @@  discard block
 block discarded – undo
987 987
     				foreach ($tmpfilelist as $file)
988 988
     				{
989 989
     					$i++;
990
-    					$out.='<tr class="oddeven">';
991
-    					$out.='<td>'.$i.'</td>' . "\n";
992
-    					$out.='<td>'.$file['filename'].'</td>' . "\n";
993
-    					$out.='<td align="center">'.$file['expectedmd5'].'</td>' . "\n";
994
-    					$out.="</tr>\n";
990
+    					$out .= '<tr class="oddeven">';
991
+    					$out .= '<td>'.$i.'</td>'."\n";
992
+    					$out .= '<td>'.$file['filename'].'</td>'."\n";
993
+    					$out .= '<td align="center">'.$file['expectedmd5'].'</td>'."\n";
994
+    					$out .= "</tr>\n";
995 995
     				}
996 996
     			}
997 997
     			else
998 998
     			{
999
-    				$out.='<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
999
+    				$out .= '<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
1000 1000
     			}
1001
-    			$out.='</table>';
1002
-    			$out.='</div>';
1001
+    			$out .= '</table>';
1002
+    			$out .= '</div>';
1003 1003
 
1004
-    			$out.='<br>';
1004
+    			$out .= '<br>';
1005 1005
 
1006 1006
     			// Files modified
1007
-    			$out.=load_fiche_titre($langs->trans("FilesModified"));
1008
-
1009
-    			$totalsize=0;
1010
-    			$out.='<div class="div-table-responsive-no-min">';
1011
-    			$out.='<table class="noborder">';
1012
-    			$out.='<tr class="liste_titre">';
1013
-    			$out.='<td>#</td>';
1014
-    			$out.='<td>' . $langs->trans("Filename") . '</td>';
1015
-    			$out.='<td align="center">' . $langs->trans("ExpectedChecksum") . '</td>';
1016
-    			$out.='<td align="center">' . $langs->trans("CurrentChecksum") . '</td>';
1017
-    			$out.='<td align="right">' . $langs->trans("Size") . '</td>';
1018
-    			$out.='<td align="right">' . $langs->trans("DateModification") . '</td>';
1019
-    			$out.='</tr>'."\n";
1007
+    			$out .= load_fiche_titre($langs->trans("FilesModified"));
1008
+
1009
+    			$totalsize = 0;
1010
+    			$out .= '<div class="div-table-responsive-no-min">';
1011
+    			$out .= '<table class="noborder">';
1012
+    			$out .= '<tr class="liste_titre">';
1013
+    			$out .= '<td>#</td>';
1014
+    			$out .= '<td>'.$langs->trans("Filename").'</td>';
1015
+    			$out .= '<td align="center">'.$langs->trans("ExpectedChecksum").'</td>';
1016
+    			$out .= '<td align="center">'.$langs->trans("CurrentChecksum").'</td>';
1017
+    			$out .= '<td align="right">'.$langs->trans("Size").'</td>';
1018
+    			$out .= '<td align="right">'.$langs->trans("DateModification").'</td>';
1019
+    			$out .= '</tr>'."\n";
1020 1020
     			$tmpfilelist2 = dol_sort_array($file_list['updated'], 'filename');
1021 1021
     			if (is_array($tmpfilelist2) && count($tmpfilelist2))
1022 1022
     			{
@@ -1024,49 +1024,49 @@  discard block
 block discarded – undo
1024 1024
     				foreach ($tmpfilelist2 as $file)
1025 1025
     				{
1026 1026
     					$i++;
1027
-    					$out.='<tr class="oddeven">';
1028
-    					$out.='<td>'.$i.'</td>' . "\n";
1029
-    					$out.='<td>'.$file['filename'].'</td>' . "\n";
1030
-    					$out.='<td align="center">'.$file['expectedmd5'].'</td>' . "\n";
1031
-    					$out.='<td align="center">'.$file['md5'].'</td>' . "\n";
1027
+    					$out .= '<tr class="oddeven">';
1028
+    					$out .= '<td>'.$i.'</td>'."\n";
1029
+    					$out .= '<td>'.$file['filename'].'</td>'."\n";
1030
+    					$out .= '<td align="center">'.$file['expectedmd5'].'</td>'."\n";
1031
+    					$out .= '<td align="center">'.$file['md5'].'</td>'."\n";
1032 1032
     					$size = dol_filesize(DOL_DOCUMENT_ROOT.'/'.$file['filename']);
1033 1033
     					$totalsize += $size;
1034
-    					$out.='<td align="right">'.dol_print_size($size).'</td>' . "\n";
1035
-    					$out.='<td align="right">'.dol_print_date(dol_filemtime(DOL_DOCUMENT_ROOT.'/'.$file['filename']),'dayhour').'</td>' . "\n";
1036
-    					$out.="</tr>\n";
1034
+    					$out .= '<td align="right">'.dol_print_size($size).'</td>'."\n";
1035
+    					$out .= '<td align="right">'.dol_print_date(dol_filemtime(DOL_DOCUMENT_ROOT.'/'.$file['filename']), 'dayhour').'</td>'."\n";
1036
+    					$out .= "</tr>\n";
1037 1037
     				}
1038
-    				$out.='<tr class="liste_total">';
1039
-    				$out.='<td></td>' . "\n";
1040
-    				$out.='<td>'.$langs->trans("Total").'</td>' . "\n";
1041
-    				$out.='<td align="center"></td>' . "\n";
1042
-    				$out.='<td align="center"></td>' . "\n";
1043
-    				$out.='<td align="right">'.dol_print_size($totalsize).'</td>' . "\n";
1044
-    				$out.='<td align="right"></td>' . "\n";
1045
-    				$out.="</tr>\n";
1038
+    				$out .= '<tr class="liste_total">';
1039
+    				$out .= '<td></td>'."\n";
1040
+    				$out .= '<td>'.$langs->trans("Total").'</td>'."\n";
1041
+    				$out .= '<td align="center"></td>'."\n";
1042
+    				$out .= '<td align="center"></td>'."\n";
1043
+    				$out .= '<td align="right">'.dol_print_size($totalsize).'</td>'."\n";
1044
+    				$out .= '<td align="right"></td>'."\n";
1045
+    				$out .= "</tr>\n";
1046 1046
     			}
1047 1047
     			else
1048 1048
     			{
1049
-    				$out.='<tr class="oddeven"><td colspan="5" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
1049
+    				$out .= '<tr class="oddeven"><td colspan="5" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
1050 1050
     			}
1051
-    			$out.='</table>';
1052
-    			$out.='</div>';
1051
+    			$out .= '</table>';
1052
+    			$out .= '</div>';
1053 1053
 
1054
-    			$out.='<br>';
1054
+    			$out .= '<br>';
1055 1055
 
1056 1056
     			// Files added
1057
-    			$out.=load_fiche_titre($langs->trans("FilesAdded"));
1057
+    			$out .= load_fiche_titre($langs->trans("FilesAdded"));
1058 1058
 
1059 1059
     			$totalsize = 0;
1060
-    			$out.='<div class="div-table-responsive-no-min">';
1061
-    			$out.='<table class="noborder">';
1062
-    			$out.='<tr class="liste_titre">';
1063
-    			$out.='<td>#</td>';
1064
-    			$out.='<td>' . $langs->trans("Filename") . '</td>';
1065
-    			$out.='<td align="center">' . $langs->trans("ExpectedChecksum") . '</td>';
1066
-    			$out.='<td align="center">' . $langs->trans("CurrentChecksum") . '</td>';
1067
-    			$out.='<td align="right">' . $langs->trans("Size") . '</td>';
1068
-    			$out.='<td align="right">' . $langs->trans("DateModification") . '</td>';
1069
-    			$out.='</tr>'."\n";
1060
+    			$out .= '<div class="div-table-responsive-no-min">';
1061
+    			$out .= '<table class="noborder">';
1062
+    			$out .= '<tr class="liste_titre">';
1063
+    			$out .= '<td>#</td>';
1064
+    			$out .= '<td>'.$langs->trans("Filename").'</td>';
1065
+    			$out .= '<td align="center">'.$langs->trans("ExpectedChecksum").'</td>';
1066
+    			$out .= '<td align="center">'.$langs->trans("CurrentChecksum").'</td>';
1067
+    			$out .= '<td align="right">'.$langs->trans("Size").'</td>';
1068
+    			$out .= '<td align="right">'.$langs->trans("DateModification").'</td>';
1069
+    			$out .= '</tr>'."\n";
1070 1070
     			$tmpfilelist3 = dol_sort_array($file_list['added'], 'filename');
1071 1071
     			if (is_array($tmpfilelist3) && count($tmpfilelist3))
1072 1072
     			{
@@ -1074,32 +1074,32 @@  discard block
 block discarded – undo
1074 1074
     				foreach ($tmpfilelist3 as $file)
1075 1075
     				{
1076 1076
     					$i++;
1077
-    					$out.='<tr class="oddeven">';
1078
-    					$out.='<td>'.$i.'</td>' . "\n";
1079
-    					$out.='<td>'.$file['filename'].'</td>' . "\n";
1080
-    					$out.='<td align="center">'.$file['expectedmd5'].'</td>' . "\n";
1081
-    					$out.='<td align="center">'.$file['md5'].'</td>' . "\n";
1077
+    					$out .= '<tr class="oddeven">';
1078
+    					$out .= '<td>'.$i.'</td>'."\n";
1079
+    					$out .= '<td>'.$file['filename'].'</td>'."\n";
1080
+    					$out .= '<td align="center">'.$file['expectedmd5'].'</td>'."\n";
1081
+    					$out .= '<td align="center">'.$file['md5'].'</td>'."\n";
1082 1082
     					$size = dol_filesize(DOL_DOCUMENT_ROOT.'/'.$file['filename']);
1083 1083
     					$totalsize += $size;
1084
-    					$out.='<td align="right">'.dol_print_size($size).'</td>' . "\n";
1085
-    					$out.='<td align="right">'.dol_print_date(dol_filemtime(DOL_DOCUMENT_ROOT.'/'.$file['filename']),'dayhour').'</td>' . "\n";
1086
-    					$out.="</tr>\n";
1084
+    					$out .= '<td align="right">'.dol_print_size($size).'</td>'."\n";
1085
+    					$out .= '<td align="right">'.dol_print_date(dol_filemtime(DOL_DOCUMENT_ROOT.'/'.$file['filename']), 'dayhour').'</td>'."\n";
1086
+    					$out .= "</tr>\n";
1087 1087
     				}
1088
-    				$out.='<tr class="liste_total">';
1089
-    				$out.='<td></td>' . "\n";
1090
-    				$out.='<td>'.$langs->trans("Total").'</td>' . "\n";
1091
-    				$out.='<td align="center"></td>' . "\n";
1092
-    				$out.='<td align="center"></td>' . "\n";
1093
-    				$out.='<td align="right">'.dol_print_size($totalsize).'</td>' . "\n";
1094
-    				$out.='<td align="right"></td>' . "\n";
1095
-    				$out.="</tr>\n";
1088
+    				$out .= '<tr class="liste_total">';
1089
+    				$out .= '<td></td>'."\n";
1090
+    				$out .= '<td>'.$langs->trans("Total").'</td>'."\n";
1091
+    				$out .= '<td align="center"></td>'."\n";
1092
+    				$out .= '<td align="center"></td>'."\n";
1093
+    				$out .= '<td align="right">'.dol_print_size($totalsize).'</td>'."\n";
1094
+    				$out .= '<td align="right"></td>'."\n";
1095
+    				$out .= "</tr>\n";
1096 1096
     			}
1097 1097
     			else
1098 1098
     			{
1099
-    				$out.='<tr class="oddeven"><td colspan="5" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
1099
+    				$out .= '<tr class="oddeven"><td colspan="5" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
1100 1100
     			}
1101
-    			$out.='</table>';
1102
-    			$out.='</div>';
1101
+    			$out .= '</table>';
1102
+    			$out .= '</div>';
1103 1103
 
1104 1104
 
1105 1105
     			// Show warning
@@ -1123,7 +1123,7 @@  discard block
 block discarded – undo
1123 1123
 
1124 1124
     		asort($checksumconcat); // Sort list of checksum
1125 1125
     		//var_dump($checksumconcat);
1126
-    		$checksumget = md5(join(',',$checksumconcat));
1126
+    		$checksumget = md5(join(',', $checksumconcat));
1127 1127
     		$checksumtoget = trim((string) $xml->dolibarr_htdocs_dir_checksum);
1128 1128
 
1129 1129
     		$outexpectedchecksum = ($checksumtoget ? $checksumtoget : $langs->trans("Unknown"));
@@ -1132,24 +1132,24 @@  discard block
 block discarded – undo
1132 1132
     			if (count($file_list['added']))
1133 1133
     			{
1134 1134
     				$resultcode = 'warning';
1135
-    				$resultcomment='FileIntegrityIsOkButFilesWereAdded';
1135
+    				$resultcomment = 'FileIntegrityIsOkButFilesWereAdded';
1136 1136
     				//$outcurrentchecksum =  $checksumget.' - <span class="'.$resultcode.'">'.$langs->trans("FileIntegrityIsOkButFilesWereAdded").'</span>';
1137
-    				$outcurrentchecksum =  $checksumget;
1137
+    				$outcurrentchecksum = $checksumget;
1138 1138
     			}
1139 1139
     			else
1140 1140
     			{
1141 1141
     				$resultcode = 'ok';
1142
-    				$resultcomment='Success';
1142
+    				$resultcomment = 'Success';
1143 1143
     				//$outcurrentchecksum = '<span class="'.$resultcode.'">'.$checksumget.'</span>';
1144
-    				$outcurrentchecksum =  $checksumget;
1144
+    				$outcurrentchecksum = $checksumget;
1145 1145
     			}
1146 1146
     		}
1147 1147
     		else
1148 1148
     		{
1149 1149
     			$resultcode = 'error';
1150
-    			$resultcomment='Error';
1150
+    			$resultcomment = 'Error';
1151 1151
     			//$outcurrentchecksum = '<span class="'.$resultcode.'">'.$checksumget.'</span>';
1152
-    			$outcurrentchecksum =  $checksumget;
1152
+    			$outcurrentchecksum = $checksumget;
1153 1153
     		}
1154 1154
     	}
1155 1155
     	else {
Please login to merge, or discard this patch.
dolibarr/htdocs/api/class/api_status.class.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 16
  */
17 17
 
18
-require_once DOL_DOCUMENT_ROOT . '/core/lib/functions.lib.php';
18
+require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
19 19
 
20 20
 
21 21
 /**
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
             'success' => array(
40 40
                 'code' => 200,
41 41
                 'dolibarr_version' => DOL_VERSION,
42
-                'access_locked' => (empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED)?'0':$conf->global->MAIN_ONLY_LOGIN_ALLOWED),
42
+                'access_locked' => (empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED) ? '0' : $conf->global->MAIN_ONLY_LOGIN_ALLOWED),
43 43
             ),
44 44
         );
45 45
     }
Please login to merge, or discard this patch.
dolibarr/htdocs/api/class/api_documents.class.php 1 patch
Spacing   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 	 *
68 68
 	 * @url GET /download
69 69
 	 */
70
-	public function index($module_part, $original_file='')
70
+	public function index($module_part, $original_file = '')
71 71
 	{
72 72
 		global $conf, $langs;
73 73
 
@@ -79,14 +79,14 @@  discard block
 block discarded – undo
79 79
 		}
80 80
 
81 81
 		//--- Finds and returns the document
82
-		$entity=$conf->entity;
82
+		$entity = $conf->entity;
83 83
 
84 84
 		$check_access = dol_check_secure_access_document($module_part, $original_file, $entity, DolibarrApiAccess::$user, '', 'read');
85 85
 		$accessallowed              = $check_access['accessallowed'];
86 86
 		$sqlprotectagainstexternals = $check_access['sqlprotectagainstexternals'];
87 87
 		$original_file              = $check_access['original_file'];
88 88
 
89
-		if (preg_match('/\.\./',$original_file) || preg_match('/[<>|]/',$original_file))
89
+		if (preg_match('/\.\./', $original_file) || preg_match('/[<>|]/', $original_file))
90 90
 		{
91 91
 			throw new RestException(401);
92 92
 		}
@@ -95,15 +95,15 @@  discard block
 block discarded – undo
95 95
 		}
96 96
 
97 97
 		$filename = basename($original_file);
98
-		$original_file_osencoded=dol_osencode($original_file);	// New file name encoded in OS encoding charset
98
+		$original_file_osencoded = dol_osencode($original_file); // New file name encoded in OS encoding charset
99 99
 
100
-		if (! file_exists($original_file_osencoded))
100
+		if (!file_exists($original_file_osencoded))
101 101
 		{
102 102
 			throw new RestException(404, 'File not found');
103 103
 		}
104 104
 
105
-		$file_content=file_get_contents($original_file_osencoded);
106
-		return array('filename'=>$filename, 'content-type' => dol_mimetype($filename), 'filesize'=>filesize($original_file), 'content'=>base64_encode($file_content), 'encoding'=>'base64' );
105
+		$file_content = file_get_contents($original_file_osencoded);
106
+		return array('filename'=>$filename, 'content-type' => dol_mimetype($filename), 'filesize'=>filesize($original_file), 'content'=>base64_encode($file_content), 'encoding'=>'base64');
107 107
 	}
108 108
 
109 109
 
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 	 *
128 128
 	 * @url PUT /builddoc
129 129
 	 */
130
-	public function builddoc($module_part, $original_file='', $doctemplate='', $langcode='')
130
+	public function builddoc($module_part, $original_file = '', $doctemplate = '', $langcode = '')
131 131
 	{
132 132
 		global $conf, $langs;
133 133
 
@@ -141,19 +141,19 @@  discard block
 block discarded – undo
141 141
 		$outputlangs = $langs;
142 142
 		if ($langcode && $langs->defaultlang != $langcode)
143 143
 		{
144
-			$outputlangs=new Translate('', $conf);
144
+			$outputlangs = new Translate('', $conf);
145 145
 			$outputlangs->setDefaultLang($langcode);
146 146
 		}
147 147
 
148 148
 		//--- Finds and returns the document
149
-		$entity=$conf->entity;
149
+		$entity = $conf->entity;
150 150
 
151 151
 		$check_access = dol_check_secure_access_document($module_part, $original_file, $entity, DolibarrApiAccess::$user, '', 'write');
152 152
 		$accessallowed              = $check_access['accessallowed'];
153 153
 		$sqlprotectagainstexternals = $check_access['sqlprotectagainstexternals'];
154 154
 		$original_file              = $check_access['original_file'];
155 155
 
156
-		if (preg_match('/\.\./',$original_file) || preg_match('/[<>|]/',$original_file)) {
156
+		if (preg_match('/\.\./', $original_file) || preg_match('/[<>|]/', $original_file)) {
157 157
 			throw new RestException(401);
158 158
 		}
159 159
 		if (!$accessallowed) {
@@ -165,20 +165,20 @@  discard block
 block discarded – undo
165 165
 		$hidedesc = empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 0 : 1;
166 166
 		$hideref = empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 0 : 1;
167 167
 
168
-		$templateused='';
168
+		$templateused = '';
169 169
 
170 170
 		if ($module_part == 'facture' || $module_part == 'invoice')
171 171
 		{
172 172
 			require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
173 173
 			$this->invoice = new Facture($this->db);
174 174
 			$result = $this->invoice->fetch(0, preg_replace('/\.[^\.]+$/', '', basename($original_file)));
175
-			if( ! $result ) {
175
+			if (!$result) {
176 176
 				throw new RestException(404, 'Invoice not found');
177 177
 			}
178 178
 
179
-			$templateused = $doctemplate?$doctemplate:$this->invoice->modelpdf;
179
+			$templateused = $doctemplate ? $doctemplate : $this->invoice->modelpdf;
180 180
 			$result = $this->invoice->generateDocument($templateused, $outputlangs, $hidedetails, $hidedesc, $hideref);
181
-			if( $result <= 0 ) {
181
+			if ($result <= 0) {
182 182
 				throw new RestException(500, 'Error generating document');
183 183
 			}
184 184
 		}
@@ -187,12 +187,12 @@  discard block
 block discarded – undo
187 187
 			require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
188 188
 			$this->order = new Commande($this->db);
189 189
 			$result = $this->order->fetch(0, preg_replace('/\.[^\.]+$/', '', basename($original_file)));
190
-			if( ! $result ) {
190
+			if (!$result) {
191 191
 				throw new RestException(404, 'Order not found');
192 192
 			}
193
-			$templateused = $doctemplate?$doctemplate:$this->order->modelpdf;
193
+			$templateused = $doctemplate ? $doctemplate : $this->order->modelpdf;
194 194
 			$result = $this->order->generateDocument($templateused, $outputlangs, $hidedetails, $hidedesc, $hideref);
195
-			if( $result <= 0 ) {
195
+			if ($result <= 0) {
196 196
 				throw new RestException(500, 'Error generating document');
197 197
 			}
198 198
 		}
@@ -201,12 +201,12 @@  discard block
 block discarded – undo
201 201
 			require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
202 202
 			$this->propal = new Propal($this->db);
203 203
 			$result = $this->propal->fetch(0, preg_replace('/\.[^\.]+$/', '', basename($original_file)));
204
-			if( ! $result ) {
204
+			if (!$result) {
205 205
 				throw new RestException(404, 'Proposal not found');
206 206
 			}
207
-			$templateused = $doctemplate?$doctemplate:$this->propal->modelpdf;
207
+			$templateused = $doctemplate ? $doctemplate : $this->propal->modelpdf;
208 208
 			$result = $this->propal->generateDocument($templateused, $outputlangs, $hidedetails, $hidedesc, $hideref);
209
-			if( $result <= 0 ) {
209
+			if ($result <= 0) {
210 210
 				throw new RestException(500, 'Error generating document');
211 211
 			}
212 212
 		}
@@ -216,15 +216,15 @@  discard block
 block discarded – undo
216 216
 		}
217 217
 
218 218
 		$filename = basename($original_file);
219
-		$original_file_osencoded=dol_osencode($original_file);	// New file name encoded in OS encoding charset
219
+		$original_file_osencoded = dol_osencode($original_file); // New file name encoded in OS encoding charset
220 220
 
221
-		if (! file_exists($original_file_osencoded))
221
+		if (!file_exists($original_file_osencoded))
222 222
 		{
223 223
 			throw new RestException(404, 'File not found');
224 224
 		}
225 225
 
226
-		$file_content=file_get_contents($original_file_osencoded);
227
-		return array('filename'=>$filename, 'content-type' => dol_mimetype($filename), 'filesize'=>filesize($original_file), 'content'=>base64_encode($file_content), 'langcode'=>$outputlangs->defaultlang, 'template'=>$templateused, 'encoding'=>'base64' );
226
+		$file_content = file_get_contents($original_file_osencoded);
227
+		return array('filename'=>$filename, 'content-type' => dol_mimetype($filename), 'filesize'=>filesize($original_file), 'content'=>base64_encode($file_content), 'langcode'=>$outputlangs->defaultlang, 'template'=>$templateused, 'encoding'=>'base64');
228 228
 	}
229 229
 
230 230
 	/**
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
 	 *
246 246
 	 * @url GET /
247 247
 	 */
248
-	function getDocumentsListByElement($modulepart, $id=0, $ref='', $sortfield='', $sortorder='')
248
+	function getDocumentsListByElement($modulepart, $id = 0, $ref = '', $sortfield = '', $sortorder = '')
249 249
 	{
250 250
 		global $conf;
251 251
 
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
 			throw new RestException(400, 'bad value for parameter id or ref');
258 258
 		}
259 259
 
260
-		$id = (empty($id)?0:$id);
260
+		$id = (empty($id) ? 0 : $id);
261 261
 
262 262
 		if ($modulepart == 'societe' || $modulepart == 'thirdparty')
263 263
 		{
@@ -268,12 +268,12 @@  discard block
 block discarded – undo
268 268
 			}
269 269
 
270 270
 			$object = new Societe($this->db);
271
-			$result=$object->fetch($id, $ref);
272
-			if ( ! $result ) {
271
+			$result = $object->fetch($id, $ref);
272
+			if (!$result) {
273 273
 				throw new RestException(404, 'Thirdparty not found');
274 274
 			}
275 275
 
276
-			$upload_dir = $conf->societe->multidir_output[$object->entity] . "/" . $object->id;
276
+			$upload_dir = $conf->societe->multidir_output[$object->entity]."/".$object->id;
277 277
 		}
278 278
 		else if ($modulepart == 'adherent' || $modulepart == 'member')
279 279
 		{
@@ -284,12 +284,12 @@  discard block
 block discarded – undo
284 284
 			}
285 285
 
286 286
 			$object = new Adherent($this->db);
287
-			$result=$object->fetch($id, $ref);
288
-			if ( ! $result ) {
287
+			$result = $object->fetch($id, $ref);
288
+			if (!$result) {
289 289
 				throw new RestException(404, 'Member not found');
290 290
 			}
291 291
 
292
-			$upload_dir = $conf->adherent->dir_output . "/" . get_exdir(0, 0, 0, 1, $object, 'member');
292
+			$upload_dir = $conf->adherent->dir_output."/".get_exdir(0, 0, 0, 1, $object, 'member');
293 293
 		}
294 294
 		else if ($modulepart == 'propal' || $modulepart == 'proposal')
295 295
 		{
@@ -300,12 +300,12 @@  discard block
 block discarded – undo
300 300
 			}
301 301
 
302 302
 			$object = new Propal($this->db);
303
-			$result=$object->fetch($id, $ref);
304
-			if ( ! $result ) {
303
+			$result = $object->fetch($id, $ref);
304
+			if (!$result) {
305 305
 				throw new RestException(404, 'Proposal not found');
306 306
 			}
307 307
 
308
-			$upload_dir = $conf->propal->multidir_output[$object->entity] . "/" . get_exdir(0, 0, 0, 1, $object, 'propal');
308
+			$upload_dir = $conf->propal->multidir_output[$object->entity]."/".get_exdir(0, 0, 0, 1, $object, 'propal');
309 309
 		}
310 310
 		else if ($modulepart == 'commande' || $modulepart == 'order')
311 311
 		{
@@ -316,12 +316,12 @@  discard block
 block discarded – undo
316 316
 			}
317 317
 
318 318
 			$object = new Commande($this->db);
319
-			$result=$object->fetch($id, $ref);
320
-			if ( ! $result ) {
319
+			$result = $object->fetch($id, $ref);
320
+			if (!$result) {
321 321
 				throw new RestException(404, 'Order not found');
322 322
 			}
323 323
 
324
-			$upload_dir = $conf->commande->dir_output . "/" . get_exdir(0, 0, 0, 1, $object, 'commande');
324
+			$upload_dir = $conf->commande->dir_output."/".get_exdir(0, 0, 0, 1, $object, 'commande');
325 325
 		}
326 326
 		else if ($modulepart == 'shipment' || $modulepart == 'expedition')
327 327
 		{
@@ -332,12 +332,12 @@  discard block
 block discarded – undo
332 332
 			}
333 333
 
334 334
 			$object = new Expedition($this->db);
335
-			$result=$object->fetch($id, $ref);
336
-			if ( ! $result ) {
335
+			$result = $object->fetch($id, $ref);
336
+			if (!$result) {
337 337
 				throw new RestException(404, 'Shipment not found');
338 338
 			}
339 339
 
340
-			$upload_dir = $conf->expedition->dir_output . "/sending/" . get_exdir(0, 0, 0, 1, $object, 'shipment');
340
+			$upload_dir = $conf->expedition->dir_output."/sending/".get_exdir(0, 0, 0, 1, $object, 'shipment');
341 341
 		}
342 342
 		else if ($modulepart == 'facture' || $modulepart == 'invoice')
343 343
 		{
@@ -348,12 +348,12 @@  discard block
 block discarded – undo
348 348
 			}
349 349
 
350 350
 			$object = new Facture($this->db);
351
-			$result=$object->fetch($id, $ref);
352
-			if ( ! $result ) {
351
+			$result = $object->fetch($id, $ref);
352
+			if (!$result) {
353 353
 				throw new RestException(404, 'Invoice not found');
354 354
 			}
355 355
 
356
-			$upload_dir = $conf->facture->dir_output . "/" . get_exdir(0, 0, 0, 1, $object, 'invoice');
356
+			$upload_dir = $conf->facture->dir_output."/".get_exdir(0, 0, 0, 1, $object, 'invoice');
357 357
 		}
358 358
 		else if ($modulepart == 'agenda' || $modulepart == 'action' || $modulepart == 'event')
359 359
 		{
@@ -364,8 +364,8 @@  discard block
 block discarded – undo
364 364
 			}
365 365
 
366 366
 			$object = new ActionComm($this->db);
367
-			$result=$object->fetch($id, $ref);
368
-			if ( ! $result ) {
367
+			$result = $object->fetch($id, $ref);
368
+			if (!$result) {
369 369
 				throw new RestException(404, 'Event not found');
370 370
 			}
371 371
 
@@ -376,9 +376,9 @@  discard block
 block discarded – undo
376 376
 			throw new RestException(500, 'Modulepart '.$modulepart.' not implemented yet.');
377 377
 		}
378 378
 
379
-		$filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
379
+		$filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1);
380 380
 		if (empty($filearray)) {
381
-			throw new RestException(404, 'Search for modulepart '.$modulepart.' with Id '.$object->id.(! empty($object->Ref)?' or Ref '.$object->ref:'').' does not return any document.');
381
+			throw new RestException(404, 'Search for modulepart '.$modulepart.' with Id '.$object->id.(!empty($object->Ref) ? ' or Ref '.$object->ref : '').' does not return any document.');
382 382
 		}
383 383
 
384 384
 		return $filearray;
@@ -421,7 +421,7 @@  discard block
 block discarded – undo
421 421
 	 *
422 422
 	 * @url POST /upload
423 423
 	 */
424
-	public function post($filename, $modulepart, $ref='', $subdir='', $filecontent='', $fileencoding='', $overwriteifexists=0)
424
+	public function post($filename, $modulepart, $ref = '', $subdir = '', $filecontent = '', $fileencoding = '', $overwriteifexists = 0)
425 425
 	{
426 426
 		global $db, $conf;
427 427
 
@@ -430,7 +430,7 @@  discard block
 block discarded – undo
430 430
         var_dump($filecontent);
431 431
         exit;*/
432 432
 
433
-		if(empty($modulepart))
433
+		if (empty($modulepart))
434 434
 		{
435 435
 			throw new RestException(400, 'Modulepart not provided.');
436 436
 		}
@@ -450,11 +450,11 @@  discard block
 block discarded – undo
450 450
 		$entity = DolibarrApiAccess::$user->entity;
451 451
 		if ($ref)
452 452
 		{
453
-			$tmpreldir='';
453
+			$tmpreldir = '';
454 454
 
455 455
 			if ($modulepart == 'facture' || $modulepart == 'invoice')
456 456
 			{
457
-				$modulepart='facture';
457
+				$modulepart = 'facture';
458 458
 
459 459
 				require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
460 460
 				$object = new Facture($this->db);
@@ -474,11 +474,11 @@  discard block
 block discarded – undo
474 474
 				$task_result = $object->fetch('', $ref);
475 475
 
476 476
 				// Fetching the tasks project is required because its out_dir might be a sub-directory of the project
477
-				if($task_result > 0)
477
+				if ($task_result > 0)
478 478
 				{
479 479
 					$project_result = $object->fetch_projet();
480 480
 
481
-					if($project_result >= 0)
481
+					if ($project_result >= 0)
482 482
 					{
483 483
 						$tmpreldir = dol_sanitizeFileName($object->project->ref).'/';
484 484
 					}
@@ -494,11 +494,11 @@  discard block
 block discarded – undo
494 494
 				throw new RestException(500, 'Modulepart '.$modulepart.' not implemented yet.');
495 495
 			}
496 496
 
497
-			if(is_object($object))
497
+			if (is_object($object))
498 498
 			{
499 499
 				$result = $object->fetch('', $ref);
500 500
 
501
-				if($result == 0)
501
+				if ($result == 0)
502 502
 				{
503 503
 					throw new RestException(404, "Object with ref '".$ref."' was not found.");
504 504
 			}
@@ -508,7 +508,7 @@  discard block
 block discarded – undo
508 508
 				}
509 509
 			}
510 510
 
511
-			if (! ($object->id > 0))
511
+			if (!($object->id > 0))
512 512
 			{
513 513
    				throw new RestException(404, 'The object '.$modulepart." with ref '".$ref."' was not found.");
514 514
 			}
@@ -516,7 +516,7 @@  discard block
 block discarded – undo
516 516
 			$relativefile = $tmpreldir.dol_sanitizeFileName($object->ref);
517 517
 
518 518
 			$tmp = dol_check_secure_access_document($modulepart, $relativefile, $entity, DolibarrApiAccess::$user, $ref, 'write');
519
-			$upload_dir = $tmp['original_file'];	// No dirname here, tmp['original_file'] is already the dir because dol_check_secure_access_document was called with param original_file that is only the dir
519
+			$upload_dir = $tmp['original_file']; // No dirname here, tmp['original_file'] is already the dir because dol_check_secure_access_document was called with param original_file that is only the dir
520 520
 
521 521
 			if (empty($upload_dir) || $upload_dir == '/')
522 522
 			{
@@ -525,12 +525,12 @@  discard block
 block discarded – undo
525 525
 		}
526 526
 		else
527 527
 		{
528
-			if ($modulepart == 'invoice') $modulepart ='facture';
528
+			if ($modulepart == 'invoice') $modulepart = 'facture';
529 529
 
530 530
 			$relativefile = $subdir;
531 531
 
532 532
 			$tmp = dol_check_secure_access_document($modulepart, $relativefile, $entity, DolibarrApiAccess::$user, '', 'write');
533
-			$upload_dir = $tmp['original_file'];	// No dirname here, tmp['original_file'] is already the dir because dol_check_secure_access_document was called with param original_file that is only the dir
533
+			$upload_dir = $tmp['original_file']; // No dirname here, tmp['original_file'] is already the dir because dol_check_secure_access_document was called with param original_file that is only the dir
534 534
 
535 535
 			if (empty($upload_dir) || $upload_dir == '/')
536 536
 			{
@@ -541,8 +541,8 @@  discard block
 block discarded – undo
541 541
 
542 542
 		$upload_dir = dol_sanitizePathName($upload_dir);
543 543
 
544
-		$destfile = $upload_dir . '/' . $original_file;
545
-		$destfiletmp = DOL_DATA_ROOT.'/admin/temp/' . $original_file;
544
+		$destfile = $upload_dir.'/'.$original_file;
545
+		$destfiletmp = DOL_DATA_ROOT.'/admin/temp/'.$original_file;
546 546
 		dol_delete_file($destfiletmp);
547 547
 		//var_dump($original_file);exit;
548 548
 
@@ -550,7 +550,7 @@  discard block
 block discarded – undo
550 550
 			throw new RestException(401, 'Directory not exists : '.dirname($destfile));
551 551
 		}
552 552
 
553
-		if (! $overwriteifexists && dol_is_file($destfile))
553
+		if (!$overwriteifexists && dol_is_file($destfile))
554 554
 		{
555 555
 			throw new RestException(500, "File with name '".$original_file."' already exists.");
556 556
 		}
@@ -568,7 +568,7 @@  discard block
 block discarded – undo
568 568
 		}
569 569
 
570 570
 		$result = dol_move($destfiletmp, $destfile, 0, $overwriteifexists, 1);
571
-		if (! $result)
571
+		if (!$result)
572 572
 		{
573 573
 			throw new RestException(500, "Failed to move file into '".$destfile."'");
574 574
 		}
Please login to merge, or discard this patch.