Passed
Push — master ( 49af33...3cffbe )
by Alxarafe
21:21
created
dolibarr/htdocs/core/lib/price.lib.php 1 patch
Braces   +64 added lines, -32 removed lines patch added patch discarded remove patch
@@ -89,14 +89,20 @@  discard block
 block discarded – undo
89 89
 	$result=array();
90 90
 
91 91
 	// Clean parameters
92
-	if (empty($info_bits)) $info_bits=0;
93
-	if (empty($txtva)) $txtva=0;
92
+	if (empty($info_bits)) {
93
+	    $info_bits=0;
94
+	}
95
+	if (empty($txtva)) {
96
+	    $txtva=0;
97
+	}
94 98
 	if (empty($seller) || ! is_object($seller))
95 99
 	{
96 100
 		dol_syslog("Price.lib::calcul_price_total Warning: function is called with parameter seller that is missing", LOG_WARNING);
97
-		if (! is_object($mysoc))	// mysoc may be not defined (during migration process)
101
+		if (! is_object($mysoc)) {
102
+		    // mysoc may be not defined (during migration process)
98 103
 		{
99 104
 			$mysoc=new Societe($db);
105
+		}
100 106
 			$mysoc->setMysoc($conf);
101 107
 		}
102 108
 		$seller=$mysoc;	// If sell is done to a customer, $seller is not provided, we use $mysoc
@@ -111,11 +117,19 @@  discard block
 block discarded – undo
111 117
 
112 118
 	$countryid=$seller->country_id;
113 119
 
114
-	if (is_numeric($uselocaltax1_rate)) $uselocaltax1_rate=(float) $uselocaltax1_rate;
115
-	if (is_numeric($uselocaltax2_rate)) $uselocaltax2_rate=(float) $uselocaltax2_rate;
120
+	if (is_numeric($uselocaltax1_rate)) {
121
+	    $uselocaltax1_rate=(float) $uselocaltax1_rate;
122
+	}
123
+	if (is_numeric($uselocaltax2_rate)) {
124
+	    $uselocaltax2_rate=(float) $uselocaltax2_rate;
125
+	}
116 126
 
117
-	if ($uselocaltax1_rate < 0) $uselocaltax1_rate=$seller->localtax1_assuj;
118
-	if ($uselocaltax2_rate < 0) $uselocaltax2_rate=$seller->localtax2_assuj;
127
+	if ($uselocaltax1_rate < 0) {
128
+	    $uselocaltax1_rate=$seller->localtax1_assuj;
129
+	}
130
+	if ($uselocaltax2_rate < 0) {
131
+	    $uselocaltax2_rate=$seller->localtax2_assuj;
132
+	}
119 133
 
120 134
 	//var_dump($uselocaltax1_rate.' - '.$uselocaltax2_rate);
121 135
 	dol_syslog('Price.lib::calcul_price_total qty='.$qty.' pu='.$pu.' remise_percent_ligne='.$remise_percent_ligne.' txtva='.$txtva.' uselocaltax1_rate='.$uselocaltax1_rate.' uselocaltax2_rate='.$uselocaltax2_rate.' remise_percent_global='.$remise_percent_global.' price_base_type='.$price_base_type.' type='.$type.' progress='.$progress);
@@ -130,8 +144,7 @@  discard block
 block discarded – undo
130 144
 		$localtax1_rate = $localtaxes_array[1];
131 145
 		$localtax2_type = $localtaxes_array[2];
132 146
 		$localtax2_rate = $localtaxes_array[3];
133
-	}
134
-	else	// deprecated method. values and type for localtaxes must be provided by caller and loaded with getLocalTaxesFromRate
147
+	} else	// deprecated method. values and type for localtaxes must be provided by caller and loaded with getLocalTaxesFromRate
135 148
 	{
136 149
 		$sql = "SELECT taux, localtax1, localtax2, localtax1_type, localtax2_type";
137 150
 		$sql.= " FROM ".MAIN_DB_PREFIX."c_tva as cv";
@@ -150,24 +163,29 @@  discard block
 block discarded – undo
150 163
 				$localtax2_type=$obj->localtax2_type;
151 164
 				//var_dump($localtax1_rate.' '.$localtax2_rate.' '.$localtax1_type.' '.$localtax2_type);exit;
152 165
 			}
166
+		} else {
167
+		    dol_print_error($db);
153 168
 		}
154
-		else dol_print_error($db);
155 169
 	}
156 170
 
157 171
 	// pu calculation from pu_devise if pu empty
158 172
 	if (empty($pu) && !empty($pu_devise)) {
159
-		if (! empty($multicurrency_tx)) $pu = $pu_devise / $multicurrency_tx;
160
-		else
173
+		if (! empty($multicurrency_tx)) {
174
+		    $pu = $pu_devise / $multicurrency_tx;
175
+		} else
161 176
 		{
162 177
 			dol_syslog('Price.lib::calcul_price_total function called with bad parameters combination (multicurrency_tx empty when pu_devise not) ', LOG_ERR);
163 178
 			return array();
164 179
 		}
165 180
 	}
166
-	if ($pu === '') $pu=0;
181
+	if ($pu === '') {
182
+	    $pu=0;
183
+	}
167 184
 	// pu_devise calculation from pu
168 185
 	if (empty($pu_devise) && !empty($multicurrency_tx)) {
169
-		if (is_numeric($pu) && is_numeric($multicurrency_tx)) $pu_devise = $pu * $multicurrency_tx;
170
-		else
186
+		if (is_numeric($pu) && is_numeric($multicurrency_tx)) {
187
+		    $pu_devise = $pu * $multicurrency_tx;
188
+		} else
171 189
 		{
172 190
 			dol_syslog('Price.lib::calcul_price_total function called with bad parameters combination (pu or multicurrency_tx are not numeric)', LOG_ERR);
173 191
 			return array();
@@ -180,7 +198,9 @@  discard block
 block discarded – undo
180 198
 	$tot_avec_remise       = $tot_avec_remise_ligne * (1 - ($remise_percent_global / 100));
181 199
 
182 200
 	// initialize result array
183
-	for ($i=0; $i <= 15; $i++) $result[$i] = 0;
201
+	for ($i=0; $i <= 15; $i++) {
202
+	    $result[$i] = 0;
203
+	}
184 204
 
185 205
 	// if there's some localtax including vat, we calculate localtaxes (we will add later)
186 206
 
@@ -190,8 +210,7 @@  discard block
 block discarded – undo
190 210
     	$tot_sans_remise_wt = price2num($tot_sans_remise * (1 + ($txtva / 100)),'MU');
191 211
     	$tot_avec_remise_wt = price2num($tot_avec_remise * (1 + ($txtva / 100)),'MU');
192 212
     	$pu_wt = price2num($pu * (1 + ($txtva / 100)),'MU');
193
-    }
194
-    else
213
+    } else
195 214
     {
196 215
     	$tot_sans_remise_wt = $tot_sans_remise;
197 216
     	$tot_avec_remise_wt = $tot_avec_remise;
@@ -207,10 +226,14 @@  discard block
 block discarded – undo
207 226
         $apply_tax = true;
208 227
         break;
209 228
       case '4':     // localtax on product
210
-        if ($type == 0) $apply_tax = true;
229
+        if ($type == 0) {
230
+            $apply_tax = true;
231
+        }
211 232
         break;
212 233
       case '6':     // localtax on service
213
-        if ($type == 1) $apply_tax = true;
234
+        if ($type == 1) {
235
+            $apply_tax = true;
236
+        }
214 237
         break;
215 238
     }
216 239
 
@@ -231,10 +254,14 @@  discard block
 block discarded – undo
231 254
         $apply_tax = true;
232 255
         break;
233 256
       case '4':     // localtax on product
234
-        if ($type == 0) $apply_tax = true;
257
+        if ($type == 0) {
258
+            $apply_tax = true;
259
+        }
235 260
         break;
236 261
       case '6':     // localtax on service
237
-        if ($type == 1) $apply_tax = true;
262
+        if ($type == 1) {
263
+            $apply_tax = true;
264
+        }
238 265
         break;
239 266
     }
240 267
     if ($uselocaltax2_rate && $apply_tax) {
@@ -266,8 +293,7 @@  discard block
 block discarded – undo
266 293
 		$result[5] = price2num($pu * (1 + ( (($info_bits & 1)?0:$txtva) / 100)) + $localtaxes[2], 'MU');	// Selon TVA NPR ou non
267 294
 		$result5bis= price2num($pu * (1 + ($txtva / 100)) + $localtaxes[2], 'MU');	// Si TVA consideree normale (non NPR)
268 295
 		$result[4] = price2num($result5bis - ($result[3] + $localtaxes[2]), 'MU');
269
-	}
270
-	else
296
+	} else
271 297
 	{
272 298
 		// We work to define prices using the price with tax
273 299
 		$result[8] = price2num($tot_sans_remise + $localtaxes[0], 'MT');
@@ -302,10 +328,14 @@  discard block
 block discarded – undo
302 328
         $apply_tax = true;
303 329
         break;
304 330
       case '3':     // localtax on product
305
-        if ($type == 0) $apply_tax = true;
331
+        if ($type == 0) {
332
+            $apply_tax = true;
333
+        }
306 334
         break;
307 335
       case '5':     // localtax on service
308
-        if ($type == 1) $apply_tax = true;
336
+        if ($type == 1) {
337
+            $apply_tax = true;
338
+        }
309 339
         break;
310 340
     }
311 341
     if ($uselocaltax1_rate && $apply_tax) {
@@ -325,10 +355,14 @@  discard block
 block discarded – undo
325 355
         $apply_tax = true;
326 356
         break;
327 357
       case '3':     // localtax on product
328
-        if ($type == 0) $apply_tax = true;
358
+        if ($type == 0) {
359
+            $apply_tax = true;
360
+        }
329 361
         break;
330 362
       case '5':     // localtax on service
331
-        if ($type == 1) $apply_tax = true;
363
+        if ($type == 1) {
364
+            $apply_tax = true;
365
+        }
332 366
         break;
333 367
     }
334 368
     if ($uselocaltax2_rate && $apply_tax) {
@@ -352,8 +386,7 @@  discard block
 block discarded – undo
352 386
 			$result[2]=price2num($result[0]+$result[1], 'MT');
353 387
 			$result[9]=round($result[9]/$conf->global->MAIN_ROUNDING_RULE_TOT, 0)*$conf->global->MAIN_ROUNDING_RULE_TOT;
354 388
 			$result[10]=round($result[10]/$conf->global->MAIN_ROUNDING_RULE_TOT, 0)*$conf->global->MAIN_ROUNDING_RULE_TOT;
355
-		}
356
-		else
389
+		} else
357 390
 		{
358 391
 			$result[1]=round($result[1]/$conf->global->MAIN_ROUNDING_RULE_TOT, 0)*$conf->global->MAIN_ROUNDING_RULE_TOT;
359 392
 			$result[2]=round($result[2]/$conf->global->MAIN_ROUNDING_RULE_TOT, 0)*$conf->global->MAIN_ROUNDING_RULE_TOT;
@@ -386,8 +419,7 @@  discard block
 block discarded – undo
386 419
 		$result[18] = price2num($result[2] * $multicurrency_tx, 'MT');
387 420
 		$result[19] = price2num($pu_devise, 'MU');
388 421
 		*/
389
-	}
390
-	else
422
+	} else
391 423
 	{
392 424
 		$result[16] = $result[0];
393 425
 		$result[17] = $result[1];
Please login to merge, or discard this patch.
dolibarr/htdocs/core/lib/ldap.lib.php 1 patch
Braces   +34 added lines, -18 removed lines patch added patch discarded remove patch
@@ -112,17 +112,14 @@  discard block
 block discarded – undo
112 112
 	if (! function_exists("ldap_connect"))
113 113
 	{
114 114
 		print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans('LDAPFunctionsNotAvailableOnPHP').'">'.$butlabel.'</a>';
115
-	}
116
-	else if (empty($conf->global->LDAP_SERVER_HOST))
115
+	} else if (empty($conf->global->LDAP_SERVER_HOST))
117 116
 	{
118 117
 		print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans('LDAPSetupNotComplete').'">'.$butlabel.'</a>';
119
-	}
120
-	else if (empty($key) || empty($dn) || empty($objectclass))
118
+	} else if (empty($key) || empty($dn) || empty($objectclass))
121 119
 	{
122 120
 		$langs->load("errors");
123 121
 		print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans('ErrorLDAPSetupNotComplete').'">'.$butlabel.'</a>';
124
-	}
125
-	else
122
+	} else
126 123
 	{
127 124
 		print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action='.$testlabel.'">'.$butlabel.'</a>';
128 125
 	}
@@ -146,15 +143,28 @@  discard block
 block discarded – undo
146 143
 	global $bc, $conf;
147 144
 
148 145
 	$count--;
149
-	if ($count == 0) return -1;	// To stop loop
150
-	if (! is_array($result)) return -1;
146
+	if ($count == 0) {
147
+	    return -1;
148
+	}
149
+	// To stop loop
150
+	if (! is_array($result)) {
151
+	    return -1;
152
+	}
151 153
 
152 154
 	foreach($result as $key => $val)
153 155
 	{
154
-		if ("$key" == "objectclass") continue;
155
-		if ("$key" == "count") continue;
156
-		if ("$key" == "dn") continue;
157
-		if ("$val" == "objectclass") continue;
156
+		if ("$key" == "objectclass") {
157
+		    continue;
158
+		}
159
+		if ("$key" == "count") {
160
+		    continue;
161
+		}
162
+		if ("$key" == "dn") {
163
+		    continue;
164
+		}
165
+		if ("$val" == "objectclass") {
166
+		    continue;
167
+		}
158 168
 
159 169
 		$lastkey[$level]=$key;
160 170
 
@@ -168,19 +178,25 @@  discard block
 block discarded – undo
168 178
 				print '<td>';
169 179
 				print $key;
170 180
 				print '</td><td>';
171
-				if (strtolower($key) == 'userpassword') $hide=1;
181
+				if (strtolower($key) == 'userpassword') {
182
+				    $hide=1;
183
+				}
172 184
 			}
173 185
 			show_ldap_content($val,$level+1,$count,$var,$hide,$val["count"]);
174
-		}
175
-		else if ($subcount)
186
+		} else if ($subcount)
176 187
 		{
177 188
 			$subcount--;
178 189
 			$newstring=dol_htmlentitiesbr($val);
179
-			if ($hide) print preg_replace('/./i','*',$newstring);
180
-			else print $newstring;
190
+			if ($hide) {
191
+			    print preg_replace('/./i','*',$newstring);
192
+			} else {
193
+			    print $newstring;
194
+			}
181 195
 			print '<br>';
182 196
 		}
183
-		if ("$val" != $lastkey[$level] && !$subcount) print '</td></tr>';
197
+		if ("$val" != $lastkey[$level] && !$subcount) {
198
+		    print '</td></tr>';
199
+		}
184 200
 	}
185 201
 	return 1;
186 202
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/lib/security.lib.php 1 patch
Braces   +217 added lines, -137 removed lines patch added patch discarded remove patch
@@ -36,17 +36,18 @@  discard block
 block discarded – undo
36 36
  */
37 37
 function dol_encode($chain, $key='1')
38 38
 {
39
-	if (is_numeric($key) && $key == '1')	// rule 1 is offset of 17 for char
39
+	if (is_numeric($key) && $key == '1') {
40
+	    // rule 1 is offset of 17 for char
40 41
 	{
41 42
 		$output_tab=array();
43
+	}
42 44
 		$strlength=dol_strlen($chain);
43 45
 		for ($i=0; $i < $strlength; $i++)
44 46
 		{
45 47
 			$output_tab[$i] = chr(ord(substr($chain,$i,1))+17);
46 48
 		}
47 49
 		$chain = implode("",$output_tab);
48
-	}
49
-	elseif ($key)
50
+	} elseif ($key)
50 51
 	{
51 52
 		$result='';
52 53
 		$strlength=dol_strlen($chain);
@@ -74,9 +75,11 @@  discard block
 block discarded – undo
74 75
 {
75 76
 	$chain = base64_decode($chain);
76 77
 
77
-	if (is_numeric($key) && $key == '1')	// rule 1 is offset of 17 for char
78
+	if (is_numeric($key) && $key == '1') {
79
+	    // rule 1 is offset of 17 for char
78 80
 	{
79 81
 		$output_tab=array();
82
+	}
80 83
 		$strlength=dol_strlen($chain);
81 84
 		for ($i=0; $i < $strlength;$i++)
82 85
 		{
@@ -84,8 +87,7 @@  discard block
 block discarded – undo
84 87
 		}
85 88
 
86 89
 		$chain = implode("",$output_tab);
87
-	}
88
-	elseif ($key)
90
+	} elseif ($key)
89 91
 	{
90 92
 		$result='';
91 93
 		$strlength=dol_strlen($chain);
@@ -122,15 +124,27 @@  discard block
 block discarded – undo
122 124
 	}
123 125
 
124 126
 	// Salt value
125
-	if (! empty($conf->global->MAIN_SECURITY_SALT)) $chain=$conf->global->MAIN_SECURITY_SALT.$chain;
127
+	if (! empty($conf->global->MAIN_SECURITY_SALT)) {
128
+	    $chain=$conf->global->MAIN_SECURITY_SALT.$chain;
129
+	}
126 130
 
127
-	if ($type == '1' || $type == 'sha1') return sha1($chain);
128
-	else if ($type == '2' || $type == 'sha1md5') return sha1(md5($chain));
129
-	else if ($type == '3' || $type == 'md5') return md5($chain);
130
-	else if ($type == '4' || $type == 'md5openldap') return '{md5}'.base64_encode(mhash(MHASH_MD5,$chain)); // For OpenLdap with md5 (based on an unencrypted password in base)
131
-	else if ($type == '5') return hash('sha256',$chain);
132
-	else if (! empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'sha1') return sha1($chain);
133
-	else if (! empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'sha1md5') return sha1(md5($chain));
131
+	if ($type == '1' || $type == 'sha1') {
132
+	    return sha1($chain);
133
+	} else if ($type == '2' || $type == 'sha1md5') {
134
+	    return sha1(md5($chain));
135
+	} else if ($type == '3' || $type == 'md5') {
136
+	    return md5($chain);
137
+	} else if ($type == '4' || $type == 'md5openldap') {
138
+	    return '{md5}'.base64_encode(mhash(MHASH_MD5,$chain));
139
+	}
140
+	// For OpenLdap with md5 (based on an unencrypted password in base)
141
+	else if ($type == '5') {
142
+	    return hash('sha256',$chain);
143
+	} else if (! empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'sha1') {
144
+	    return sha1($chain);
145
+	} else if (! empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'sha1md5') {
146
+	    return sha1(md5($chain));
147
+	}
134 148
 
135 149
 	// No particular encoding defined, use default
136 150
 	return md5($chain);
@@ -152,9 +166,16 @@  discard block
 block discarded – undo
152 166
 	global $conf;
153 167
 
154 168
 	if ($type == '0' && ! empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'password_hash' && function_exists('password_verify')) {
155
-		if ($hash[0] == '$') return password_verify($chain, $hash);
156
-		else if(strlen($hash) == 32) return dol_verifyHash($chain, $hash, '3'); // md5
157
-		else if(strlen($hash) == 40) return dol_verifyHash($chain, $hash, '2'); // sha1md5
169
+		if ($hash[0] == '$') {
170
+		    return password_verify($chain, $hash);
171
+		} else if(strlen($hash) == 32) {
172
+		    return dol_verifyHash($chain, $hash, '3');
173
+		}
174
+		// md5
175
+		else if(strlen($hash) == 40) {
176
+		    return dol_verifyHash($chain, $hash, '2');
177
+		}
178
+		// sha1md5
158 179
 
159 180
 		return false;
160 181
 	}
@@ -191,18 +212,29 @@  discard block
 block discarded – undo
191 212
 	// Get more permissions checks from hooks
192 213
 	$parameters=array('features'=>$features, 'objectid'=>$objectid, 'idtype'=>$dbt_select);
193 214
 	$reshook=$hookmanager->executeHooks('restrictedArea',$parameters);
194
-	if (! empty($hookmanager->resArray['result'])) return true;
195
-	if ($reshook > 0) return false;
215
+	if (! empty($hookmanager->resArray['result'])) {
216
+	    return true;
217
+	}
218
+	if ($reshook > 0) {
219
+	    return false;
220
+	}
196 221
 
197
-	if ($dbt_select != 'rowid' && $dbt_select != 'id') $objectid = "'".$objectid."'";
222
+	if ($dbt_select != 'rowid' && $dbt_select != 'id') {
223
+	    $objectid = "'".$objectid."'";
224
+	}
198 225
 
199 226
 	// Features/modules to check
200 227
 	$featuresarray = array($features);
201
-	if (preg_match('/&/', $features)) $featuresarray = explode("&", $features);
202
-	else if (preg_match('/\|/', $features)) $featuresarray = explode("|", $features);
228
+	if (preg_match('/&/', $features)) {
229
+	    $featuresarray = explode("&", $features);
230
+	} else if (preg_match('/\|/', $features)) {
231
+	    $featuresarray = explode("|", $features);
232
+	}
203 233
 
204 234
 	// More subfeatures to check
205
-	if (! empty($feature2)) $feature2 = explode("|", $feature2);
235
+	if (! empty($feature2)) {
236
+	    $feature2 = explode("|", $feature2);
237
+	}
206 238
 
207 239
 	// More parameters
208 240
 	$params = explode('&', $tableandshare);
@@ -213,67 +245,77 @@  discard block
 block discarded – undo
213 245
 
214 246
 	// Check read permission from module
215 247
 	$readok=1; $nbko=0;
216
-	foreach ($featuresarray as $feature)	// first we check nb of test ko
248
+	foreach ($featuresarray as $feature) {
249
+	    // first we check nb of test ko
217 250
 	{
218 251
 		$featureforlistofmodule=$feature;
219
-		if ($featureforlistofmodule == 'produit') $featureforlistofmodule='product';
220
-		if (! empty($user->societe_id) && ! empty($conf->global->MAIN_MODULES_FOR_EXTERNAL) && ! in_array($featureforlistofmodule,$listofmodules))	// If limits on modules for external users, module must be into list of modules for external users
252
+	}
253
+		if ($featureforlistofmodule == 'produit') {
254
+		    $featureforlistofmodule='product';
255
+		}
256
+		if (! empty($user->societe_id) && ! empty($conf->global->MAIN_MODULES_FOR_EXTERNAL) && ! in_array($featureforlistofmodule,$listofmodules)) {
257
+		    // If limits on modules for external users, module must be into list of modules for external users
221 258
 		{
222
-			$readok=0; $nbko++;
259
+			$readok=0;
260
+		}
261
+		$nbko++;
223 262
 			continue;
224 263
 		}
225 264
 
226 265
 		if ($feature == 'societe')
227 266
 		{
228 267
 			if (! $user->rights->societe->lire && ! $user->rights->fournisseur->lire) { $readok=0; $nbko++; }
229
-		}
230
-		else if ($feature == 'contact')
268
+		} else if ($feature == 'contact')
231 269
 		{
232 270
 			if (! $user->rights->societe->contact->lire) { $readok=0; $nbko++; }
233
-		}
234
-		else if ($feature == 'produit|service')
271
+		} else if ($feature == 'produit|service')
235 272
 		{
236 273
 			if (! $user->rights->produit->lire && ! $user->rights->service->lire) { $readok=0; $nbko++; }
237
-		}
238
-		else if ($feature == 'prelevement')
274
+		} else if ($feature == 'prelevement')
239 275
 		{
240 276
 			if (! $user->rights->prelevement->bons->lire) { $readok=0; $nbko++; }
241
-		}
242
-		else if ($feature == 'cheque')
277
+		} else if ($feature == 'cheque')
243 278
 		{
244 279
 			if (! $user->rights->banque->cheque) { $readok=0; $nbko++; }
245
-		}
246
-		else if ($feature == 'projet')
280
+		} else if ($feature == 'projet')
247 281
 		{
248 282
 			if (! $user->rights->projet->lire && ! $user->rights->projet->all->lire) { $readok=0; $nbko++; }
249
-		}
250
-		else if (! empty($feature2))	// This should be used for future changes
283
+		} else if (! empty($feature2)) {
284
+		    // This should be used for future changes
251 285
 		{
252 286
 			$tmpreadok=1;
287
+		}
253 288
 			foreach($feature2 as $subfeature)
254 289
 			{
255
-				if (! empty($subfeature) && empty($user->rights->$feature->$subfeature->lire) && empty($user->rights->$feature->$subfeature->read)) { $tmpreadok=0; }
256
-				else if (empty($subfeature) && empty($user->rights->$feature->lire) && empty($user->rights->$feature->read)) { $tmpreadok=0; }
257
-				else { $tmpreadok=1; break; } // Break is to bypass second test if the first is ok
290
+				if (! empty($subfeature) && empty($user->rights->$feature->$subfeature->lire) && empty($user->rights->$feature->$subfeature->read)) { $tmpreadok=0; } else if (empty($subfeature) && empty($user->rights->$feature->lire) && empty($user->rights->$feature->read)) { $tmpreadok=0; } else { $tmpreadok=1; break; } // Break is to bypass second test if the first is ok
258 291
 			}
259
-			if (! $tmpreadok)	// We found a test on feature that is ko
292
+			if (! $tmpreadok) {
293
+			    // We found a test on feature that is ko
260 294
 			{
261
-				$readok=0;	// All tests are ko (we manage here the and, the or will be managed later using $nbko).
295
+				$readok=0;
296
+			}
297
+			// All tests are ko (we manage here the and, the or will be managed later using $nbko).
262 298
 				$nbko++;
263 299
 			}
264
-		}
265
-		else if (! empty($feature) && ($feature!='user' && $feature!='usergroup'))		// This is for old permissions
300
+		} else if (! empty($feature) && ($feature!='user' && $feature!='usergroup')) {
301
+		    // This is for old permissions
266 302
 		{
267 303
 			if (empty($user->rights->$feature->lire)
268 304
 				&& empty($user->rights->$feature->read)
269
-				&& empty($user->rights->$feature->run)) { $readok=0; $nbko++; }
305
+				&& empty($user->rights->$feature->run)) { $readok=0;
306
+		}
307
+		$nbko++; }
270 308
 		}
271 309
 	}
272 310
 
273 311
 	// If a or and at least one ok
274
-	if (preg_match('/\|/', $features) && $nbko < count($featuresarray)) $readok=1;
312
+	if (preg_match('/\|/', $features) && $nbko < count($featuresarray)) {
313
+	    $readok=1;
314
+	}
275 315
 
276
-	if (! $readok) accessforbidden();
316
+	if (! $readok) {
317
+	    accessforbidden();
318
+	}
277 319
 	//print "Read access is ok";
278 320
 
279 321
 	// Check write permission from module (we need to know write permission to create but also to delete drafts record)
@@ -285,50 +327,52 @@  discard block
 block discarded – undo
285 327
 			if ($feature == 'contact')
286 328
 			{
287 329
 				if (! $user->rights->societe->contact->creer) { $createok=0; $nbko++; }
288
-			}
289
-			else if ($feature == 'produit|service')
330
+			} else if ($feature == 'produit|service')
290 331
 			{
291 332
 				if (! $user->rights->produit->creer && ! $user->rights->service->creer) { $createok=0; $nbko++; }
292
-			}
293
-			else if ($feature == 'prelevement')
333
+			} else if ($feature == 'prelevement')
294 334
 			{
295 335
 				if (! $user->rights->prelevement->bons->creer) { $createok=0; $nbko++; }
296
-			}
297
-			else if ($feature == 'commande_fournisseur')
336
+			} else if ($feature == 'commande_fournisseur')
298 337
 			{
299 338
 				if (! $user->rights->fournisseur->commande->creer) { $createok=0; $nbko++; }
300
-			}
301
-			else if ($feature == 'banque')
339
+			} else if ($feature == 'banque')
302 340
 			{
303 341
 				if (! $user->rights->banque->modifier) { $createok=0; $nbko++; }
304
-			}
305
-			else if ($feature == 'cheque')
342
+			} else if ($feature == 'cheque')
306 343
 			{
307 344
 				if (! $user->rights->banque->cheque) { $createok=0; $nbko++; }
308
-			}
309
-			else if (! empty($feature2))	// This should be used
345
+			} else if (! empty($feature2)) {
346
+			    // This should be used
310 347
 			{
311 348
 				foreach($feature2 as $subfeature)
312 349
 				{
313 350
 					if (empty($user->rights->$feature->$subfeature->creer)
314 351
 						&& empty($user->rights->$feature->$subfeature->write)
315
-						&& empty($user->rights->$feature->$subfeature->create)) { $createok=0; $nbko++; }
316
-						else { $createok=1; break; } // Break to bypass second test if the first is ok
317
-				}
352
+						&& empty($user->rights->$feature->$subfeature->create)) { $createok=0;
318 353
 			}
319
-			else if (! empty($feature))		// This is for old permissions ('creer' or 'write')
354
+			$nbko++; } else { $createok=1; break; } // Break to bypass second test if the first is ok
355
+				}
356
+			} else if (! empty($feature)) {
357
+			    // This is for old permissions ('creer' or 'write')
320 358
 			{
321 359
 				//print '<br>feature='.$feature.' creer='.$user->rights->$feature->creer.' write='.$user->rights->$feature->write;
322 360
 				if (empty($user->rights->$feature->creer)
323 361
 					&& empty($user->rights->$feature->write)
324
-					&& empty($user->rights->$feature->create)) { $createok=0; $nbko++; }
362
+					&& empty($user->rights->$feature->create)) { $createok=0;
363
+			}
364
+			$nbko++; }
325 365
 			}
326 366
 		}
327 367
 
328 368
 		// If a or and at least one ok
329
-		if (preg_match('/\|/', $features) && $nbko < count($featuresarray)) $createok=1;
369
+		if (preg_match('/\|/', $features) && $nbko < count($featuresarray)) {
370
+		    $createok=1;
371
+		}
330 372
 
331
-		if (GETPOST('action','aZ09') == 'create' && ! $createok) accessforbidden();
373
+		if (GETPOST('action','aZ09') == 'create' && ! $createok) {
374
+		    accessforbidden();
375
+		}
332 376
 		//print "Write access is ok";
333 377
 	}
334 378
 
@@ -336,9 +380,13 @@  discard block
 block discarded – undo
336 380
 	$createuserok=1;
337 381
 	if (GETPOST('action','aZ09') == 'confirm_create_user' && GETPOST("confirm",'aZ09') == 'yes')
338 382
 	{
339
-		if (! $user->rights->user->user->creer) $createuserok=0;
383
+		if (! $user->rights->user->user->creer) {
384
+		    $createuserok=0;
385
+		}
340 386
 
341
-		if (! $createuserok) accessforbidden();
387
+		if (! $createuserok) {
388
+		    accessforbidden();
389
+		}
342 390
 		//print "Create user access is ok";
343 391
 	}
344 392
 
@@ -350,60 +398,76 @@  discard block
 block discarded – undo
350 398
 		{
351 399
 			if ($feature == 'contact')
352 400
 			{
353
-				if (! $user->rights->societe->contact->supprimer) $deleteok=0;
354
-			}
355
-			else if ($feature == 'produit|service')
401
+				if (! $user->rights->societe->contact->supprimer) {
402
+				    $deleteok=0;
403
+				}
404
+			} else if ($feature == 'produit|service')
356 405
 			{
357
-				if (! $user->rights->produit->supprimer && ! $user->rights->service->supprimer) $deleteok=0;
358
-			}
359
-			else if ($feature == 'commande_fournisseur')
406
+				if (! $user->rights->produit->supprimer && ! $user->rights->service->supprimer) {
407
+				    $deleteok=0;
408
+				}
409
+			} else if ($feature == 'commande_fournisseur')
360 410
 			{
361
-				if (! $user->rights->fournisseur->commande->supprimer) $deleteok=0;
362
-			}
363
-			else if ($feature == 'banque')
411
+				if (! $user->rights->fournisseur->commande->supprimer) {
412
+				    $deleteok=0;
413
+				}
414
+			} else if ($feature == 'banque')
364 415
 			{
365
-				if (! $user->rights->banque->modifier) $deleteok=0;
366
-			}
367
-			else if ($feature == 'cheque')
416
+				if (! $user->rights->banque->modifier) {
417
+				    $deleteok=0;
418
+				}
419
+			} else if ($feature == 'cheque')
368 420
 			{
369
-				if (! $user->rights->banque->cheque) $deleteok=0;
370
-			}
371
-			else if ($feature == 'ecm')
421
+				if (! $user->rights->banque->cheque) {
422
+				    $deleteok=0;
423
+				}
424
+			} else if ($feature == 'ecm')
372 425
 			{
373
-				if (! $user->rights->ecm->upload) $deleteok=0;
374
-			}
375
-			else if ($feature == 'ftp')
426
+				if (! $user->rights->ecm->upload) {
427
+				    $deleteok=0;
428
+				}
429
+			} else if ($feature == 'ftp')
376 430
 			{
377
-				if (! $user->rights->ftp->write) $deleteok=0;
378
-			}else if ($feature == 'salaries')
431
+				if (! $user->rights->ftp->write) {
432
+				    $deleteok=0;
433
+				}
434
+			} else if ($feature == 'salaries')
379 435
 			{
380
-				if (! $user->rights->salaries->delete) $deleteok=0;
381
-			}
382
-			else if ($feature == 'salaries')
436
+				if (! $user->rights->salaries->delete) {
437
+				    $deleteok=0;
438
+				}
439
+			} else if ($feature == 'salaries')
383 440
 			{
384
-				if (! $user->rights->salaries->delete) $deleteok=0;
385
-			}
386
-			else if (! empty($feature2))	// This should be used for permissions on 2 levels
441
+				if (! $user->rights->salaries->delete) {
442
+				    $deleteok=0;
443
+				}
444
+			} else if (! empty($feature2)) {
445
+			    // This should be used for permissions on 2 levels
387 446
 			{
388 447
 				foreach($feature2 as $subfeature)
389 448
 				{
390 449
 					if (empty($user->rights->$feature->$subfeature->supprimer) && empty($user->rights->$feature->$subfeature->delete)) $deleteok=0;
391
-					else { $deleteok=1; break; } // For bypass the second test if the first is ok
450
+			} else { $deleteok=1; break; } // For bypass the second test if the first is ok
392 451
 				}
393
-			}
394
-			else if (! empty($feature))		// This is used for permissions on 1 level
452
+			} else if (! empty($feature)) {
453
+			    // This is used for permissions on 1 level
395 454
 			{
396 455
 				//print '<br>feature='.$feature.' creer='.$user->rights->$feature->supprimer.' write='.$user->rights->$feature->delete;
397 456
 				if (empty($user->rights->$feature->supprimer)
398 457
 					&& empty($user->rights->$feature->delete)
399 458
 					&& empty($user->rights->$feature->run)) $deleteok=0;
400 459
 			}
460
+			}
401 461
 		}
402 462
 
403 463
 		// If a or and at least one ok
404
-		if (preg_match('/\|/', $features) && $nbko < count($featuresarray)) $deleteok=1;
464
+		if (preg_match('/\|/', $features) && $nbko < count($featuresarray)) {
465
+		    $deleteok=1;
466
+		}
405 467
 
406
-		if (! $deleteok && ! ($isdraft && $createok)) accessforbidden();
468
+		if (! $deleteok && ! ($isdraft && $createok)) {
469
+		    accessforbidden();
470
+		}
407 471
 		//print "Delete access is ok";
408 472
 	}
409 473
 
@@ -446,9 +510,15 @@  discard block
 block discarded – undo
446 510
 		$sql='';
447 511
 
448 512
 		// For backward compatibility
449
-		if ($feature == 'member')  $feature='adherent';
450
-		if ($feature == 'project') $feature='projet';
451
-		if ($feature == 'task')    $feature='projet_task';
513
+		if ($feature == 'member') {
514
+		    $feature='adherent';
515
+		}
516
+		if ($feature == 'project') {
517
+		    $feature='projet';
518
+		}
519
+		if ($feature == 'task') {
520
+		    $feature='projet_task';
521
+		}
452 522
 
453 523
 		$check = array('adherent','banque','don','user','usergroup','product','produit','service','produit|service','categorie','resource'); // Test on entity only (Objects with no link to company)
454 524
 		$checksoc = array('societe');	 // Test for societe object
@@ -478,8 +548,7 @@  discard block
 block discarded – undo
478 548
 					{
479 549
 						$sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")";
480 550
 						$sql.= " AND dbt.entity IS NOT NULL";
481
-					}
482
-					else
551
+					} else
483 552
 					{
484 553
 						$sql.= ",".MAIN_DB_PREFIX."usergroup_user as ug";
485 554
 						$sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")";
@@ -487,24 +556,23 @@  discard block
 block discarded – undo
487 556
 						$sql.= " AND ug.entity IN (".getEntity('user')."))";
488 557
 						$sql.= " OR dbt.entity = 0"; // Show always superadmin
489 558
 					}
490
-				}
491
-				else {
559
+				} else {
492 560
 					$sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")";
493 561
 					$sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")";
494 562
 				}
495
-			}
496
-			else
563
+			} else
497 564
 			{
498 565
 				$sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")";
499 566
 				$sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")";
500 567
 			}
501
-		}
502
-		else if (in_array($feature,$checksoc))	// We check feature = checksoc
568
+		} else if (in_array($feature,$checksoc)) {
569
+		    // We check feature = checksoc
503 570
 		{
504 571
 			// If external user: Check permission for external users
505 572
 			if ($user->socid > 0)
506 573
 			{
507 574
 				if ($user->socid <> $objectid) return false;
575
+		}
508 576
 			}
509 577
 			// If internal user: Check permission for internal users that are restricted on their objects
510 578
 			else if (! empty($conf->societe->enabled) && ($user->rights->societe->lire && ! $user->rights->societe->client->voir))
@@ -525,13 +593,14 @@  discard block
 block discarded – undo
525 593
 				$sql.= " WHERE s.rowid IN (".$objectid.")";
526 594
 				$sql.= " AND s.entity IN (".getEntity($sharedelement, 1).")";
527 595
 			}
528
-		}
529
-		else if (in_array($feature,$checkother))	// Test on entity and link to societe. Allowed if link is empty (Ex: contacts...).
596
+		} else if (in_array($feature,$checkother)) {
597
+		    // Test on entity and link to societe. Allowed if link is empty (Ex: contacts...).
530 598
 		{
531 599
 			// If external user: Check permission for external users
532 600
 			if ($user->socid > 0)
533 601
 			{
534 602
 				$sql = "SELECT COUNT(dbt.".$dbt_select.") as nb";
603
+		}
535 604
 				$sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
536 605
 				$sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")";
537 606
 				$sql.= " AND dbt.fk_soc = ".$user->socid;
@@ -554,8 +623,7 @@  discard block
 block discarded – undo
554 623
 				$sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")";
555 624
 				$sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")";
556 625
 			}
557
-		}
558
-		else if (in_array($feature,$checkproject))
626
+		} else if (in_array($feature,$checkproject))
559 627
 		{
560 628
 			if (! empty($conf->projet->enabled) && empty($user->rights->projet->all->lire))
561 629
 			{
@@ -563,17 +631,17 @@  discard block
 block discarded – undo
563 631
 				$projectstatic=new Project($db);
564 632
 				$tmps=$projectstatic->getProjectsAuthorizedForUser($user,0,1,0);
565 633
 				$tmparray=explode(',',$tmps);
566
-				if (! in_array($objectid,$tmparray)) return false;
567
-			}
568
-			else
634
+				if (! in_array($objectid,$tmparray)) {
635
+				    return false;
636
+				}
637
+			} else
569 638
 			{
570 639
 				$sql = "SELECT COUNT(dbt.".$dbt_select.") as nb";
571 640
 				$sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
572 641
 				$sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")";
573 642
 				$sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")";
574 643
 			}
575
-		}
576
-		else if (in_array($feature,$checktask))
644
+		} else if (in_array($feature,$checktask))
577 645
 		{
578 646
 			if (! empty($conf->projet->enabled) && empty($user->rights->projet->all->lire))
579 647
 			{
@@ -584,22 +652,24 @@  discard block
 block discarded – undo
584 652
 				$projectstatic=new Project($db);
585 653
 				$tmps=$projectstatic->getProjectsAuthorizedForUser($user,0,1,0);
586 654
 				$tmparray=explode(',',$tmps);
587
-				if (! in_array($task->fk_project,$tmparray)) return false;
588
-			}
589
-			else
655
+				if (! in_array($task->fk_project,$tmparray)) {
656
+				    return false;
657
+				}
658
+			} else
590 659
 			{
591 660
 				$sql = "SELECT COUNT(dbt.".$dbt_select.") as nb";
592 661
 				$sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
593 662
 				$sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")";
594 663
 				$sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")";
595 664
 			}
596
-		}
597
-		else if (! in_array($feature,$nocheck))		// By default (case of $checkdefault), we check on object entity + link to third party on field $dbt_keyfield
665
+		} else if (! in_array($feature,$nocheck)) {
666
+		    // By default (case of $checkdefault), we check on object entity + link to third party on field $dbt_keyfield
598 667
 		{
599 668
 			// If external user: Check permission for external users
600 669
 			if ($user->socid > 0)
601 670
 			{
602 671
 				if (empty($dbt_keyfield)) dol_print_error('','Param dbt_keyfield is required but not defined');
672
+		}
603 673
 				$sql = "SELECT COUNT(dbt.".$dbt_keyfield.") as nb";
604 674
 				$sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
605 675
 				$sql.= " WHERE dbt.rowid IN (".$objectid.")";
@@ -608,7 +678,9 @@  discard block
 block discarded – undo
608 678
 			// If internal user: Check permission for internal users that are restricted on their objects
609 679
 			else if (! empty($conf->societe->enabled) && ($user->rights->societe->lire && ! $user->rights->societe->client->voir))
610 680
 			{
611
-				if (empty($dbt_keyfield)) dol_print_error('','Param dbt_keyfield is required but not defined');
681
+				if (empty($dbt_keyfield)) {
682
+				    dol_print_error('','Param dbt_keyfield is required but not defined');
683
+				}
612 684
 				$sql = "SELECT COUNT(sc.fk_soc) as nb";
613 685
 				$sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
614 686
 				$sql.= ", ".MAIN_DB_PREFIX."societe as s";
@@ -635,9 +707,10 @@  discard block
 block discarded – undo
635 707
 			if ($resql)
636 708
 			{
637 709
 				$obj = $db->fetch_object($resql);
638
-				if (! $obj || $obj->nb < count(explode(',', $objectid))) return false;
639
-			}
640
-			else
710
+				if (! $obj || $obj->nb < count(explode(',', $objectid))) {
711
+				    return false;
712
+				}
713
+			} else
641 714
 			{
642 715
 				return false;
643 716
 			}
@@ -670,12 +743,18 @@  discard block
 block discarded – undo
670 743
 
671 744
 	if ($printheader)
672 745
 	{
673
-		if (function_exists("llxHeader")) llxHeader('');
674
-		else if (function_exists("llxHeaderVierge")) llxHeaderVierge('');
746
+		if (function_exists("llxHeader")) {
747
+		    llxHeader('');
748
+		} else if (function_exists("llxHeaderVierge")) {
749
+		    llxHeaderVierge('');
750
+		}
675 751
 	}
676 752
 	print '<div class="error">';
677
-	if (! $message) print $langs->trans("ErrorForbidden");
678
-	else print $message;
753
+	if (! $message) {
754
+	    print $langs->trans("ErrorForbidden");
755
+	} else {
756
+	    print $message;
757
+	}
679 758
 	print '</div>';
680 759
 	print '<br>';
681 760
 	if (empty($showonlymessage))
@@ -684,12 +763,13 @@  discard block
 block discarded – undo
684 763
 		{
685 764
 			print $langs->trans("CurrentLogin").': <font class="error">'.$user->login.'</font><br>';
686 765
 			print $langs->trans("ErrorForbidden2",$langs->trans("Home"),$langs->trans("Users"));
687
-		}
688
-		else
766
+		} else
689 767
 		{
690 768
 			print $langs->trans("ErrorForbidden3");
691 769
 		}
692 770
 	}
693
-	if ($printfooter && function_exists("llxFooter")) llxFooter();
771
+	if ($printfooter && function_exists("llxFooter")) {
772
+	    llxFooter();
773
+	}
694 774
 	exit(0);
695 775
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/lib/functions2.lib.php 1 patch
Braces   +696 added lines, -349 removed lines patch added patch discarded remove patch
@@ -55,8 +55,7 @@  discard block
 block discarded – undo
55 55
                 $entity = "&#". $unicode . ';';
56 56
                 $decodedStr .= utf8_encode($entity);
57 57
                 $pos += 4;
58
-            }
59
-            else {
58
+            } else {
60 59
                 // we have an escaped ascii character
61 60
                 $hexVal = substr($source, $pos, 2);
62 61
                 $decodedStr .= chr(hexdec($hexVal));
@@ -97,7 +96,10 @@  discard block
 block discarded – undo
97 96
         {
98 97
             while (($file = readdir($handle))!==false)
99 98
             {
100
-                if (preg_match('/disabled/',$file)) continue;   // We discard module if it contains disabled into name.
99
+                if (preg_match('/disabled/',$file)) {
100
+                    continue;
101
+                }
102
+                // We discard module if it contains disabled into name.
101 103
 
102 104
                 if (is_dir($dirroot.'/'.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS' && $file != 'includes')
103 105
                 {
@@ -129,8 +131,14 @@  discard block
 block discarded – undo
129 131
     	$outputlangs=$langs;
130 132
     }
131 133
 
132
-    if ($outputlangs->defaultlang == 'ca_CA') $selected='CAP4';        // Canada
133
-    if ($outputlangs->defaultlang == 'en_US') $selected='USLetter';    // US
134
+    if ($outputlangs->defaultlang == 'ca_CA') {
135
+        $selected='CAP4';
136
+    }
137
+    // Canada
138
+    if ($outputlangs->defaultlang == 'en_US') {
139
+        $selected='USLetter';
140
+    }
141
+    // US
134 142
     return $selected;
135 143
 }
136 144
 
@@ -155,29 +163,42 @@  discard block
 block discarded – undo
155 163
         {
156 164
             $content=file_get_contents($formfile);
157 165
             $isutf8=utf8_check($content);
158
-            if (! $isutf8 && $conf->file->character_set_client == 'UTF-8') print utf8_encode($content);
159
-            elseif ($isutf8 && $conf->file->character_set_client == 'ISO-8859-1') print utf8_decode($content);
160
-            else print $content;
166
+            if (! $isutf8 && $conf->file->character_set_client == 'UTF-8') {
167
+                print utf8_encode($content);
168
+            } elseif ($isutf8 && $conf->file->character_set_client == 'ISO-8859-1') {
169
+                print utf8_decode($content);
170
+            } else {
171
+                print $content;
172
+            }
161 173
             return true;
174
+        } else {
175
+            dol_syslog('functions2::dol_print_file not found', LOG_DEBUG);
162 176
         }
163
-        else dol_syslog('functions2::dol_print_file not found', LOG_DEBUG);
164 177
 
165 178
         if ($searchalt) {
166 179
             // Test si fichier dans repertoire de la langue alternative
167
-            if ($langs->defaultlang != "en_US") $formfilealt = $searchdir."/langs/en_US/".$filename;
168
-            else $formfilealt = $searchdir."/langs/fr_FR/".$filename;
180
+            if ($langs->defaultlang != "en_US") {
181
+                $formfilealt = $searchdir."/langs/en_US/".$filename;
182
+            } else {
183
+                $formfilealt = $searchdir."/langs/fr_FR/".$filename;
184
+            }
169 185
             dol_syslog('functions2::dol_print_file search alt file '.$formfilealt, LOG_DEBUG);
170 186
             //print 'getcwd='.getcwd().' htmlfilealt='.$formfilealt.' X '.file_exists(getcwd().'/'.$formfilealt);
171 187
             if (is_readable($formfilealt))
172 188
             {
173 189
                 $content=file_get_contents($formfilealt);
174 190
                 $isutf8=utf8_check($content);
175
-                if (! $isutf8 && $conf->file->character_set_client == 'UTF-8') print utf8_encode($content);
176
-                elseif ($isutf8 && $conf->file->character_set_client == 'ISO-8859-1') print utf8_decode($content);
177
-                else print $content;
191
+                if (! $isutf8 && $conf->file->character_set_client == 'UTF-8') {
192
+                    print utf8_encode($content);
193
+                } elseif ($isutf8 && $conf->file->character_set_client == 'ISO-8859-1') {
194
+                    print utf8_decode($content);
195
+                } else {
196
+                    print $content;
197
+                }
178 198
                 return true;
199
+            } else {
200
+                dol_syslog('functions2::dol_print_file not found', LOG_DEBUG);
179 201
             }
180
-            else dol_syslog('functions2::dol_print_file not found', LOG_DEBUG);
181 202
         }
182 203
     }
183 204
 
@@ -207,279 +228,460 @@  discard block
 block discarded – undo
207 228
     $deltadateforuser=round($deltadateforclient-$deltadateforserver);
208 229
     //print "x".$deltadateforserver." - ".$deltadateforclient." - ".$deltadateforuser;
209 230
 
210
-    if ($usetable) print '<table class="border centpercent">';
231
+    if ($usetable) {
232
+        print '<table class="border centpercent">';
233
+    }
211 234
 
212 235
     // Import key
213 236
     if (! empty($object->import_key))
214 237
     {
215
-        if ($usetable) print '<tr><td class="titlefield">';
238
+        if ($usetable) {
239
+            print '<tr><td class="titlefield">';
240
+        }
216 241
         print $langs->trans("ImportedWithSet");
217
-        if ($usetable) print '</td><td>';
218
-        else print ': ';
242
+        if ($usetable) {
243
+            print '</td><td>';
244
+        } else {
245
+            print ': ';
246
+        }
219 247
         print $object->import_key;
220
-        if ($usetable) print '</td></tr>';
221
-        else print '<br>';
248
+        if ($usetable) {
249
+            print '</td></tr>';
250
+        } else {
251
+            print '<br>';
252
+        }
222 253
     }
223 254
 
224 255
     // User creation (old method using already loaded object and not id is kept for backward compatibility)
225 256
     if (! empty($object->user_creation) || ! empty($object->user_creation_id))
226 257
     {
227
-        if ($usetable) print '<tr><td class="titlefield">';
258
+        if ($usetable) {
259
+            print '<tr><td class="titlefield">';
260
+        }
228 261
         print $langs->trans("CreatedBy");
229
-        if ($usetable) print '</td><td>';
230
-        else print ': ';
262
+        if ($usetable) {
263
+            print '</td><td>';
264
+        } else {
265
+            print ': ';
266
+        }
231 267
         if (is_object($object->user_creation))
232 268
         {
233
-        	if ($object->user_creation->id) print $object->user_creation->getNomUrl(1, '', 0, 0, 0);
234
-        	else print $langs->trans("Unknown");
235
-        }
236
-        else
269
+        	if ($object->user_creation->id) {
270
+        	    print $object->user_creation->getNomUrl(1, '', 0, 0, 0);
271
+        	} else {
272
+        	    print $langs->trans("Unknown");
273
+        	}
274
+        } else
237 275
         {
238 276
             $userstatic=new User($db);
239 277
             $userstatic->fetch($object->user_creation_id ? $object->user_creation_id : $object->user_creation);
240
-            if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0);
241
-        	else print $langs->trans("Unknown");
278
+            if ($userstatic->id) {
279
+                print $userstatic->getNomUrl(1, '', 0, 0, 0);
280
+            } else {
281
+        	    print $langs->trans("Unknown");
282
+        	}
283
+        }
284
+        if ($usetable) {
285
+            print '</td></tr>';
286
+        } else {
287
+            print '<br>';
242 288
         }
243
-        if ($usetable) print '</td></tr>';
244
-        else print '<br>';
245 289
     }
246 290
 
247 291
     // Date creation
248 292
     if (! empty($object->date_creation))
249 293
     {
250
-        if ($usetable) print '<tr><td class="titlefield">';
294
+        if ($usetable) {
295
+            print '<tr><td class="titlefield">';
296
+        }
251 297
         print $langs->trans("DateCreation");
252
-        if ($usetable) print '</td><td>';
253
-        else print ': ';
298
+        if ($usetable) {
299
+            print '</td><td>';
300
+        } else {
301
+            print ': ';
302
+        }
254 303
         print dol_print_date($object->date_creation, 'dayhour');
255
-        if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' &nbsp; / &nbsp; '.dol_print_date($object->date_creation+($deltadateforuser*3600),"dayhour").' &nbsp;'.$langs->trans("ClientHour");
256
-        if ($usetable) print '</td></tr>';
257
-        else print '<br>';
304
+        if ($deltadateforuser) {
305
+            print ' '.$langs->trans("CurrentHour").' &nbsp; / &nbsp; '.dol_print_date($object->date_creation+($deltadateforuser*3600),"dayhour").' &nbsp;'.$langs->trans("ClientHour");
306
+        }
307
+        if ($usetable) {
308
+            print '</td></tr>';
309
+        } else {
310
+            print '<br>';
311
+        }
258 312
     }
259 313
 
260 314
     // User change (old method using already loaded object and not id is kept for backward compatibility)
261 315
     if (! empty($object->user_modification) || ! empty($object->user_modification_id))
262 316
     {
263
-        if ($usetable) print '<tr><td class="titlefield">';
317
+        if ($usetable) {
318
+            print '<tr><td class="titlefield">';
319
+        }
264 320
         print $langs->trans("ModifiedBy");
265
-        if ($usetable) print '</td><td>';
266
-        else print ': ';
321
+        if ($usetable) {
322
+            print '</td><td>';
323
+        } else {
324
+            print ': ';
325
+        }
267 326
         if (is_object($object->user_modification))
268 327
         {
269
-        	if ($object->user_modification->id) print $object->user_modification->getNomUrl(1, '', 0, 0, 0);
270
-        	else print $langs->trans("Unknown");
271
-        }
272
-        else
328
+        	if ($object->user_modification->id) {
329
+        	    print $object->user_modification->getNomUrl(1, '', 0, 0, 0);
330
+        	} else {
331
+        	    print $langs->trans("Unknown");
332
+        	}
333
+        } else
273 334
         {
274 335
             $userstatic=new User($db);
275 336
             $userstatic->fetch($object->user_modification_id ? $object->user_modification_id : $object->user_modification);
276
-            if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0);
277
-        	else print $langs->trans("Unknown");
337
+            if ($userstatic->id) {
338
+                print $userstatic->getNomUrl(1, '', 0, 0, 0);
339
+            } else {
340
+        	    print $langs->trans("Unknown");
341
+        	}
342
+        }
343
+        if ($usetable) {
344
+            print '</td></tr>';
345
+        } else {
346
+            print '<br>';
278 347
         }
279
-        if ($usetable) print '</td></tr>';
280
-        else print '<br>';
281 348
     }
282 349
 
283 350
     // Date change
284 351
     if (! empty($object->date_modification))
285 352
     {
286
-        if ($usetable) print '<tr><td class="titlefield">';
353
+        if ($usetable) {
354
+            print '<tr><td class="titlefield">';
355
+        }
287 356
         print $langs->trans("DateLastModification");
288
-        if ($usetable) print '</td><td>';
289
-        else print ': ';
357
+        if ($usetable) {
358
+            print '</td><td>';
359
+        } else {
360
+            print ': ';
361
+        }
290 362
         print dol_print_date($object->date_modification, 'dayhour');
291
-        if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' &nbsp; / &nbsp; '.dol_print_date($object->date_modification+($deltadateforuser*3600),"dayhour").' &nbsp;'.$langs->trans("ClientHour");
292
-        if ($usetable) print '</td></tr>';
293
-        else print '<br>';
363
+        if ($deltadateforuser) {
364
+            print ' '.$langs->trans("CurrentHour").' &nbsp; / &nbsp; '.dol_print_date($object->date_modification+($deltadateforuser*3600),"dayhour").' &nbsp;'.$langs->trans("ClientHour");
365
+        }
366
+        if ($usetable) {
367
+            print '</td></tr>';
368
+        } else {
369
+            print '<br>';
370
+        }
294 371
     }
295 372
 
296 373
     // User validation (old method using already loaded object and not id is kept for backward compatibility)
297 374
     if (! empty($object->user_validation) || ! empty($object->user_validation_id))
298 375
     {
299
-        if ($usetable) print '<tr><td class="titlefield">';
376
+        if ($usetable) {
377
+            print '<tr><td class="titlefield">';
378
+        }
300 379
         print $langs->trans("ValidatedBy");
301
-        if ($usetable) print '</td><td>';
302
-        else print ': ';
380
+        if ($usetable) {
381
+            print '</td><td>';
382
+        } else {
383
+            print ': ';
384
+        }
303 385
         if (is_object($object->user_validation))
304 386
         {
305
-            if ($object->user_validation->id) print $object->user_validation->getNomUrl(1, '', 0, 0, 0);
306
-        	else print $langs->trans("Unknown");
307
-        }
308
-        else
387
+            if ($object->user_validation->id) {
388
+                print $object->user_validation->getNomUrl(1, '', 0, 0, 0);
389
+            } else {
390
+        	    print $langs->trans("Unknown");
391
+        	}
392
+        } else
309 393
         {
310 394
             $userstatic=new User($db);
311 395
             $userstatic->fetch($object->user_validation_id ? $object->user_validation_id : $object->user_validation);
312
-			if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0);
313
-        	else print $langs->trans("Unknown");
396
+			if ($userstatic->id) {
397
+			    print $userstatic->getNomUrl(1, '', 0, 0, 0);
398
+			} else {
399
+        	    print $langs->trans("Unknown");
400
+        	}
401
+        }
402
+        if ($usetable) {
403
+            print '</td></tr>';
404
+        } else {
405
+            print '<br>';
314 406
         }
315
-        if ($usetable) print '</td></tr>';
316
-        else print '<br>';
317 407
     }
318 408
 
319 409
     // Date validation
320 410
     if (! empty($object->date_validation))
321 411
     {
322
-        if ($usetable) print '<tr><td class="titlefield">';
412
+        if ($usetable) {
413
+            print '<tr><td class="titlefield">';
414
+        }
323 415
         print $langs->trans("DateValidation");
324
-        if ($usetable) print '</td><td>';
325
-        else print ': ';
416
+        if ($usetable) {
417
+            print '</td><td>';
418
+        } else {
419
+            print ': ';
420
+        }
326 421
         print dol_print_date($object->date_validation, 'dayhour');
327
-        if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' &nbsp; / &nbsp; '.dol_print_date($object->date_validation+($deltadateforuser*3600),"dayhour").' &nbsp;'.$langs->trans("ClientHour");
328
-        if ($usetable) print '</td></tr>';
329
-        else print '<br>';
422
+        if ($deltadateforuser) {
423
+            print ' '.$langs->trans("CurrentHour").' &nbsp; / &nbsp; '.dol_print_date($object->date_validation+($deltadateforuser*3600),"dayhour").' &nbsp;'.$langs->trans("ClientHour");
424
+        }
425
+        if ($usetable) {
426
+            print '</td></tr>';
427
+        } else {
428
+            print '<br>';
429
+        }
330 430
     }
331 431
 
332 432
     // User approve (old method using already loaded object and not id is kept for backward compatibility)
333 433
     if (! empty($object->user_approve) || ! empty($object->user_approve_id))
334 434
     {
335
-        if ($usetable) print '<tr><td class="titlefield">';
435
+        if ($usetable) {
436
+            print '<tr><td class="titlefield">';
437
+        }
336 438
         print $langs->trans("ApprovedBy");
337
-        if ($usetable) print '</td><td>';
338
-        else print ': ';
439
+        if ($usetable) {
440
+            print '</td><td>';
441
+        } else {
442
+            print ': ';
443
+        }
339 444
         if (is_object($object->user_approve))
340 445
         {
341
-            if ($object->user_approve->id) print $object->user_approve->getNomUrl(1, '', 0, 0, 0);
342
-        	else print $langs->trans("Unknown");
343
-        }
344
-        else
446
+            if ($object->user_approve->id) {
447
+                print $object->user_approve->getNomUrl(1, '', 0, 0, 0);
448
+            } else {
449
+        	    print $langs->trans("Unknown");
450
+        	}
451
+        } else
345 452
         {
346 453
             $userstatic=new User($db);
347 454
             $userstatic->fetch($object->user_approve_id ? $object->user_approve_id : $object->user_approve);
348
-			if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0);
349
-        	else print $langs->trans("Unknown");
455
+			if ($userstatic->id) {
456
+			    print $userstatic->getNomUrl(1, '', 0, 0, 0);
457
+			} else {
458
+        	    print $langs->trans("Unknown");
459
+        	}
460
+        }
461
+        if ($usetable) {
462
+            print '</td></tr>';
463
+        } else {
464
+            print '<br>';
350 465
         }
351
-        if ($usetable) print '</td></tr>';
352
-        else print '<br>';
353 466
     }
354 467
 
355 468
     // Date approve
356 469
     if (! empty($object->date_approve))
357 470
     {
358
-        if ($usetable) print '<tr><td class="titlefield">';
471
+        if ($usetable) {
472
+            print '<tr><td class="titlefield">';
473
+        }
359 474
         print $langs->trans("DateApprove");
360
-        if ($usetable) print '</td><td>';
361
-        else print ': ';
475
+        if ($usetable) {
476
+            print '</td><td>';
477
+        } else {
478
+            print ': ';
479
+        }
362 480
         print dol_print_date($object->date_approve, 'dayhour');
363
-        if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' &nbsp; / &nbsp; '.dol_print_date($object->date_approve+($deltadateforuser*3600),"dayhour").' &nbsp;'.$langs->trans("ClientHour");
364
-        if ($usetable) print '</td></tr>';
365
-        else print '<br>';
481
+        if ($deltadateforuser) {
482
+            print ' '.$langs->trans("CurrentHour").' &nbsp; / &nbsp; '.dol_print_date($object->date_approve+($deltadateforuser*3600),"dayhour").' &nbsp;'.$langs->trans("ClientHour");
483
+        }
484
+        if ($usetable) {
485
+            print '</td></tr>';
486
+        } else {
487
+            print '<br>';
488
+        }
366 489
     }
367 490
 
368 491
     // User approve
369 492
     if (! empty($object->user_approve_id2))
370 493
     {
371
-        if ($usetable) print '<tr><td class="titlefield">';
494
+        if ($usetable) {
495
+            print '<tr><td class="titlefield">';
496
+        }
372 497
         print $langs->trans("ApprovedBy");
373
-        if ($usetable) print '</td><td>';
374
-        else print ': ';
498
+        if ($usetable) {
499
+            print '</td><td>';
500
+        } else {
501
+            print ': ';
502
+        }
375 503
         $userstatic=new User($db);
376 504
         $userstatic->fetch($object->user_approve_id2);
377
-        if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0);
378
-        else print $langs->trans("Unknown");
379
-        if ($usetable) print '</td></tr>';
380
-        else print '<br>';
505
+        if ($userstatic->id) {
506
+            print $userstatic->getNomUrl(1, '', 0, 0, 0);
507
+        } else {
508
+            print $langs->trans("Unknown");
509
+        }
510
+        if ($usetable) {
511
+            print '</td></tr>';
512
+        } else {
513
+            print '<br>';
514
+        }
381 515
     }
382 516
 
383 517
     // Date approve
384 518
     if (! empty($object->date_approve2))
385 519
     {
386
-        if ($usetable) print '<tr><td class="titlefield">';
520
+        if ($usetable) {
521
+            print '<tr><td class="titlefield">';
522
+        }
387 523
         print $langs->trans("DateApprove2");
388
-        if ($usetable) print '</td><td>';
389
-        else print ': ';
524
+        if ($usetable) {
525
+            print '</td><td>';
526
+        } else {
527
+            print ': ';
528
+        }
390 529
         print dol_print_date($object->date_approve2, 'dayhour');
391
-        if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' &nbsp; / &nbsp; '.dol_print_date($object->date_approve2+($deltadateforuser*3600),"dayhour").' &nbsp;'.$langs->trans("ClientHour");
392
-        if ($usetable) print '</td></tr>';
393
-        else print '<br>';
530
+        if ($deltadateforuser) {
531
+            print ' '.$langs->trans("CurrentHour").' &nbsp; / &nbsp; '.dol_print_date($object->date_approve2+($deltadateforuser*3600),"dayhour").' &nbsp;'.$langs->trans("ClientHour");
532
+        }
533
+        if ($usetable) {
534
+            print '</td></tr>';
535
+        } else {
536
+            print '<br>';
537
+        }
394 538
     }
395 539
 
396 540
     // User close
397 541
     if (! empty($object->user_cloture))
398 542
     {
399
-        if ($usetable) print '<tr><td class="titlefield">';
543
+        if ($usetable) {
544
+            print '<tr><td class="titlefield">';
545
+        }
400 546
         print $langs->trans("ClosedBy");
401
-        if ($usetable) print '</td><td>';
402
-        else print ': ';
547
+        if ($usetable) {
548
+            print '</td><td>';
549
+        } else {
550
+            print ': ';
551
+        }
403 552
         if (is_object($object->user_cloture))
404 553
         {
405
-			if ($object->user_cloture->id) print $object->user_cloture->getNomUrl(1, '', 0, 0, 0);
406
-        	else print $langs->trans("Unknown");
407
-        }
408
-        else
554
+			if ($object->user_cloture->id) {
555
+			    print $object->user_cloture->getNomUrl(1, '', 0, 0, 0);
556
+			} else {
557
+        	    print $langs->trans("Unknown");
558
+        	}
559
+        } else
409 560
         {
410 561
             $userstatic=new User($db);
411 562
             $userstatic->fetch($object->user_cloture);
412
-			if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0);
413
-        	else print $langs->trans("Unknown");
563
+			if ($userstatic->id) {
564
+			    print $userstatic->getNomUrl(1, '', 0, 0, 0);
565
+			} else {
566
+        	    print $langs->trans("Unknown");
567
+        	}
568
+        }
569
+        if ($usetable) {
570
+            print '</td></tr>';
571
+        } else {
572
+            print '<br>';
414 573
         }
415
-        if ($usetable) print '</td></tr>';
416
-        else print '<br>';
417 574
     }
418 575
 
419 576
     // Date close
420 577
     if (! empty($object->date_cloture))
421 578
     {
422
-        if ($usetable) print '<tr><td class="titlefield">';
579
+        if ($usetable) {
580
+            print '<tr><td class="titlefield">';
581
+        }
423 582
         print $langs->trans("DateClosing");
424
-        if ($usetable) print '</td><td>';
425
-        else print ': ';
583
+        if ($usetable) {
584
+            print '</td><td>';
585
+        } else {
586
+            print ': ';
587
+        }
426 588
         print dol_print_date($object->date_cloture, 'dayhour');
427
-        if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' &nbsp; / &nbsp; '.dol_print_date($object->date_cloture+($deltadateforuser*3600),"dayhour").' &nbsp;'.$langs->trans("ClientHour");
428
-        if ($usetable) print '</td></tr>';
429
-        else print '<br>';
589
+        if ($deltadateforuser) {
590
+            print ' '.$langs->trans("CurrentHour").' &nbsp; / &nbsp; '.dol_print_date($object->date_cloture+($deltadateforuser*3600),"dayhour").' &nbsp;'.$langs->trans("ClientHour");
591
+        }
592
+        if ($usetable) {
593
+            print '</td></tr>';
594
+        } else {
595
+            print '<br>';
596
+        }
430 597
     }
431 598
 
432 599
     // User conciliate
433 600
     if (! empty($object->user_rappro))
434 601
     {
435
-        if ($usetable) print '<tr><td class="titlefield">';
602
+        if ($usetable) {
603
+            print '<tr><td class="titlefield">';
604
+        }
436 605
         print $langs->trans("ConciliatedBy");
437
-        if ($usetable) print '</td><td>';
438
-        else print ': ';
606
+        if ($usetable) {
607
+            print '</td><td>';
608
+        } else {
609
+            print ': ';
610
+        }
439 611
         if (is_object($object->user_rappro))
440 612
         {
441
-			if ($object->user_rappro->id) print $object->user_rappro->getNomUrl(1, '', 0, 0, 0);
442
-        	else print $langs->trans("Unknown");
443
-        }
444
-        else
613
+			if ($object->user_rappro->id) {
614
+			    print $object->user_rappro->getNomUrl(1, '', 0, 0, 0);
615
+			} else {
616
+        	    print $langs->trans("Unknown");
617
+        	}
618
+        } else
445 619
         {
446 620
             $userstatic=new User($db);
447 621
             $userstatic->fetch($object->user_rappro);
448
-			if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0);
449
-        	else print $langs->trans("Unknown");
622
+			if ($userstatic->id) {
623
+			    print $userstatic->getNomUrl(1, '', 0, 0, 0);
624
+			} else {
625
+        	    print $langs->trans("Unknown");
626
+        	}
627
+        }
628
+        if ($usetable) {
629
+            print '</td></tr>';
630
+        } else {
631
+            print '<br>';
450 632
         }
451
-        if ($usetable) print '</td></tr>';
452
-        else print '<br>';
453 633
     }
454 634
 
455 635
     // Date conciliate
456 636
     if (! empty($object->date_rappro))
457 637
     {
458
-        if ($usetable) print '<tr><td class="titlefield">';
638
+        if ($usetable) {
639
+            print '<tr><td class="titlefield">';
640
+        }
459 641
         print $langs->trans("DateConciliating");
460
-        if ($usetable) print '</td><td>';
461
-        else print ': ';
642
+        if ($usetable) {
643
+            print '</td><td>';
644
+        } else {
645
+            print ': ';
646
+        }
462 647
         print dol_print_date($object->date_rappro, 'dayhour');
463
-        if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' &nbsp; / &nbsp; '.dol_print_date($object->date_rappro+($deltadateforuser*3600),"dayhour").' &nbsp;'.$langs->trans("ClientHour");
464
-        if ($usetable) print '</td></tr>';
465
-        else print '<br>';
648
+        if ($deltadateforuser) {
649
+            print ' '.$langs->trans("CurrentHour").' &nbsp; / &nbsp; '.dol_print_date($object->date_rappro+($deltadateforuser*3600),"dayhour").' &nbsp;'.$langs->trans("ClientHour");
650
+        }
651
+        if ($usetable) {
652
+            print '</td></tr>';
653
+        } else {
654
+            print '<br>';
655
+        }
466 656
     }
467 657
 
468 658
     // Date send
469 659
     if (! empty($object->date_envoi))
470 660
     {
471
-        if ($usetable) print '<tr><td class="titlefield">';
661
+        if ($usetable) {
662
+            print '<tr><td class="titlefield">';
663
+        }
472 664
         print $langs->trans("DateLastSend");
473
-        if ($usetable) print '</td><td>';
474
-        else print ': ';
665
+        if ($usetable) {
666
+            print '</td><td>';
667
+        } else {
668
+            print ': ';
669
+        }
475 670
         print dol_print_date($object->date_envoi, 'dayhour');
476
-        if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' &nbsp; / &nbsp; '.dol_print_date($object->date_envoi+($deltadateforuser*3600),"dayhour").' &nbsp;'.$langs->trans("ClientHour");
477
-        if ($usetable) print '</td></tr>';
478
-        else print '<br>';
671
+        if ($deltadateforuser) {
672
+            print ' '.$langs->trans("CurrentHour").' &nbsp; / &nbsp; '.dol_print_date($object->date_envoi+($deltadateforuser*3600),"dayhour").' &nbsp;'.$langs->trans("ClientHour");
673
+        }
674
+        if ($usetable) {
675
+            print '</td></tr>';
676
+        } else {
677
+            print '<br>';
678
+        }
479 679
     }
480 680
 
481
-    if ($usetable) print '</table>';
482
-}
681
+    if ($usetable) {
682
+        print '</table>';
683
+    }
684
+    }
483 685
 
484 686
 
485 687
 /**
@@ -508,8 +710,7 @@  discard block
 block discarded – undo
508 710
     if (checkdnsrr($domain, "MX"))
509 711
     {
510 712
         return true;
511
-    }
512
-    else
713
+    } else
513 714
     {
514 715
         return false;
515 716
     }
@@ -534,10 +735,14 @@  discard block
 block discarded – undo
534 735
     $urlregex = '';
535 736
 
536 737
     // SCHEME
537
-    if ($http) $urlregex .= "^(http:\/\/|https:\/\/)";
738
+    if ($http) {
739
+        $urlregex .= "^(http:\/\/|https:\/\/)";
740
+    }
538 741
 
539 742
     // USER AND PASS
540
-    if ($pass) $urlregex .= "([a-z0-9+!*(),;?&=\$_.-]+(\:[a-z0-9+!*(),;?&=\$_.-]+)?@)";
743
+    if ($pass) {
744
+        $urlregex .= "([a-z0-9+!*(),;?&=\$_.-]+(\:[a-z0-9+!*(),;?&=\$_.-]+)?@)";
745
+    }
541 746
 
542 747
     // HOSTNAME OR IP
543 748
     //$urlregex .= "[a-z0-9+\$_-]+(\.[a-z0-9+\$_-]+)*";  // x allowed (ex. http://localhost, http://routerlogin)
@@ -546,13 +751,21 @@  discard block
 block discarded – undo
546 751
     //use only one of the above
547 752
 
548 753
     // PORT
549
-    if ($port) $urlregex .= "(\:[0-9]{2,5})";
754
+    if ($port) {
755
+        $urlregex .= "(\:[0-9]{2,5})";
756
+    }
550 757
     // PATH
551
-    if ($path) $urlregex .= "(\/([a-z0-9+\$_-]\.?)+)*\/";
758
+    if ($path) {
759
+        $urlregex .= "(\/([a-z0-9+\$_-]\.?)+)*\/";
760
+    }
552 761
     // GET Query
553
-    if ($query) $urlregex .= "(\?[a-z+&\$_.-][a-z0-9;:@\/&%=+\$_.-]*)";
762
+    if ($query) {
763
+        $urlregex .= "(\?[a-z+&\$_.-][a-z0-9;:@\/&%=+\$_.-]*)";
764
+    }
554 765
     // ANCHOR
555
-    if ($anchor) $urlregex .= "(#[a-z_.-][a-z0-9+\$_.-]*)$";
766
+    if ($anchor) {
767
+        $urlregex .= "(#[a-z_.-][a-z0-9+\$_.-]*)$";
768
+    }
556 769
 
557 770
     // check
558 771
     if (preg_match('/'.$urlregex.'/i', $url))
@@ -600,9 +813,10 @@  discard block
 block discarded – undo
600 813
         $CleanUrl = preg_replace('/^'.preg_quote($proto.$domain,'/').'/i', $newproto.strtolower($domain), $url);
601 814
 
602 815
         return $CleanUrl;
816
+    } else {
817
+        return $url;
818
+    }
603 819
     }
604
-    else return $url;
605
-}
606 820
 
607 821
 
608 822
 
@@ -619,7 +833,9 @@  discard block
 block discarded – undo
619 833
  */
620 834
 function dolObfuscateEmail($mail, $replace="*", $nbreplace=8, $nbdisplaymail=4, $nbdisplaydomain=3, $displaytld=true)
621 835
 {
622
-	if(!isValidEmail($mail))return '';
836
+	if(!isValidEmail($mail)) {
837
+	    return '';
838
+	}
623 839
 	$tab = explode('@', $mail);
624 840
 	$tab2 = explode('.',$tab[1]);
625 841
 	$string_replace = '';
@@ -681,7 +897,9 @@  discard block
 block discarded – undo
681 897
 function array2table($data,$tableMarkup=1,$tableoptions='',$troptions='',$tdoptions='')
682 898
 {
683 899
     $text='' ;
684
-    if($tableMarkup) $text = '<table '.$tableoptions.'>' ;
900
+    if($tableMarkup) {
901
+        $text = '<table '.$tableoptions.'>' ;
902
+    }
685 903
     foreach($data as $key => $item){
686 904
         if(is_array($item)){
687 905
             $text.=array2tr($item,$troptions,$tdoptions);
@@ -692,7 +910,9 @@  discard block
 block discarded – undo
692 910
             $text.= '</tr>' ;
693 911
         }
694 912
     }
695
-    if($tableMarkup) $text.= '</table>' ;
913
+    if($tableMarkup) {
914
+        $text.= '</table>' ;
915
+    }
696 916
     return $text ;
697 917
 }
698 918
 
@@ -716,15 +936,25 @@  discard block
 block discarded – undo
716 936
 {
717 937
     global $conf,$user;
718 938
 
719
-    if (! is_object($objsoc)) $valueforccc=$objsoc;
720
-    else if ($table == "commande_fournisseur" || $table == "facture_fourn" ) $valueforccc=$objsoc->code_fournisseur;
721
-    else $valueforccc=$objsoc->code_client;
939
+    if (! is_object($objsoc)) {
940
+        $valueforccc=$objsoc;
941
+    } else if ($table == "commande_fournisseur" || $table == "facture_fourn" ) {
942
+        $valueforccc=$objsoc->code_fournisseur;
943
+    } else {
944
+        $valueforccc=$objsoc->code_client;
945
+    }
722 946
 
723 947
     $sharetable = $table;
724
-    if ($table == 'facture' || $table == 'invoice') $sharetable = 'invoicenumber'; // for getEntity function
948
+    if ($table == 'facture' || $table == 'invoice') {
949
+        $sharetable = 'invoicenumber';
950
+    }
951
+    // for getEntity function
725 952
 
726 953
     // Clean parameters
727
-    if ($date == '') $date=dol_now();	// We use local year and month of PHP server to search numbers
954
+    if ($date == '') {
955
+        $date=dol_now();
956
+    }
957
+    // We use local year and month of PHP server to search numbers
728 958
     // but we should use local year and month of user
729 959
 
730 960
     // For debugging
@@ -741,8 +971,7 @@  discard block
 block discarded – undo
741 971
         $masktri=$reg[1].(! empty($reg[2])?$reg[2]:'').(! empty($reg[3])?$reg[3]:'');
742 972
         $maskcounter=$reg[1];
743 973
         $hasglobalcounter=true;
744
-    }
745
-    else
974
+    } else
746 975
     {
747 976
         // setting some defaults so the rest of the code won't fail if there is a third party counter
748 977
         $masktri='00000';
@@ -752,7 +981,9 @@  discard block
 block discarded – undo
752 981
     $maskraz=-1;
753 982
     $maskoffset=0;
754 983
     $resetEveryMonth=false;
755
-    if (dol_strlen($maskcounter) < 3 && empty($conf->global->MAIN_COUNTER_WITH_LESS_3_DIGITS)) return 'ErrorCounterMustHaveMoreThan3Digits';
984
+    if (dol_strlen($maskcounter) < 3 && empty($conf->global->MAIN_COUNTER_WITH_LESS_3_DIGITS)) {
985
+        return 'ErrorCounterMustHaveMoreThan3Digits';
986
+    }
756 987
 
757 988
     // Extract value for third party mask counter
758 989
     if (preg_match('/\{(c+)(0*)\}/i',$mask,$regClientRef))
@@ -764,9 +995,12 @@  discard block
 block discarded – undo
764 995
         $maskrefclient_clientcode=substr($valueforccc,0,dol_strlen($maskrefclient_maskclientcode));//get n first characters of client code where n is length in mask
765 996
         $maskrefclient_clientcode=str_pad($maskrefclient_clientcode,dol_strlen($maskrefclient_maskclientcode),"#",STR_PAD_RIGHT);//padding maskrefclient_clientcode for having exactly n characters in maskrefclient_clientcode
766 997
         $maskrefclient_clientcode=dol_string_nospecial($maskrefclient_clientcode);//sanitize maskrefclient_clientcode for sql insert and sql select like
767
-        if (dol_strlen($maskrefclient_maskcounter) > 0 && dol_strlen($maskrefclient_maskcounter) < 3) return 'ErrorCounterMustHaveMoreThan3Digits';
998
+        if (dol_strlen($maskrefclient_maskcounter) > 0 && dol_strlen($maskrefclient_maskcounter) < 3) {
999
+            return 'ErrorCounterMustHaveMoreThan3Digits';
1000
+        }
1001
+    } else {
1002
+        $maskrefclient='';
768 1003
     }
769
-    else $maskrefclient='';
770 1004
 
771 1005
     // fail if there is neither a global nor a third party counter
772 1006
     if (! $hasglobalcounter && ($maskrefclient_maskcounter == ''))
@@ -780,8 +1014,7 @@  discard block
 block discarded – undo
780 1014
         $masktype=$regType[1];
781 1015
         $masktype_value=substr(preg_replace('/^TE_/','',$objsoc->typent_code),0,dol_strlen($regType[1]));// get n first characters of thirdpaty typent_code (where n is length in mask)
782 1016
         $masktype_value=str_pad($masktype_value,dol_strlen($regType[1]),"#",STR_PAD_RIGHT);				 // we fill on right with # to have same number of char than into mask
783
-    }
784
-    else
1017
+    } else
785 1018
     {
786 1019
     	$masktype='';
787 1020
     	$masktype_value='';
@@ -791,13 +1024,14 @@  discard block
 block discarded – undo
791 1024
     if (preg_match('/\{(u+)\}/i',$mask,$regType))
792 1025
     {
793 1026
     	$lastname = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
794
-    	if (is_object($objuser)) $lastname = $objuser->lastname;
1027
+    	if (is_object($objuser)) {
1028
+    	    $lastname = $objuser->lastname;
1029
+    	}
795 1030
 
796 1031
     	$maskuser=$regType[1];
797 1032
     	$maskuser_value=substr($lastname,0,dol_strlen($regType[1]));// get n first characters of user firstname (where n is length in mask)
798 1033
     	$maskuser_value=str_pad($maskuser_value,dol_strlen($regType[1]),"#",STR_PAD_RIGHT);				 // we fill on right with # to have same number of char than into mask
799
-    }
800
-    else
1034
+    } else
801 1035
     {
802 1036
     	$maskuser='';
803 1037
     	$maskuser_value='';
@@ -844,8 +1078,12 @@  discard block
 block discarded – undo
844 1078
     //var_dump($reg);
845 1079
 
846 1080
     // If an offset is asked
847
-    if (! empty($reg[2]) && preg_match('/^\+/',$reg[2])) $maskoffset=preg_replace('/^\+/','',$reg[2]);
848
-    if (! empty($reg[3]) && preg_match('/^\+/',$reg[3])) $maskoffset=preg_replace('/^\+/','',$reg[3]);
1081
+    if (! empty($reg[2]) && preg_match('/^\+/',$reg[2])) {
1082
+        $maskoffset=preg_replace('/^\+/','',$reg[2]);
1083
+    }
1084
+    if (! empty($reg[3]) && preg_match('/^\+/',$reg[3])) {
1085
+        $maskoffset=preg_replace('/^\+/','',$reg[3]);
1086
+    }
849 1087
 
850 1088
     // Define $sqlwhere
851 1089
     $sqlwhere='';
@@ -853,14 +1091,21 @@  discard block
 block discarded – undo
853 1091
     $yearoffsettype=false;		// false: no reset, 0,-,=,+: reset at offset SOCIETE_FISCAL_MONTH_START, x=reset at offset x
854 1092
 
855 1093
     // If a restore to zero after a month is asked we check if there is already a value for this year.
856
-    if (! empty($reg[2]) && preg_match('/^@/',$reg[2]))	$yearoffsettype = preg_replace('/^@/','',$reg[2]);
857
-    if (! empty($reg[3]) && preg_match('/^@/',$reg[3]))	$yearoffsettype = preg_replace('/^@/','',$reg[3]);
1094
+    if (! empty($reg[2]) && preg_match('/^@/',$reg[2])) {
1095
+        $yearoffsettype = preg_replace('/^@/','',$reg[2]);
1096
+    }
1097
+    if (! empty($reg[3]) && preg_match('/^@/',$reg[3])) {
1098
+        $yearoffsettype = preg_replace('/^@/','',$reg[3]);
1099
+    }
858 1100
 
859 1101
     //print "yearoffset=".$yearoffset." yearoffsettype=".$yearoffsettype;
860
-    if (is_numeric($yearoffsettype) && $yearoffsettype >= 1)
861
-        $maskraz=$yearoffsettype; // For backward compatibility
862
-    else if ($yearoffsettype === '0' || (! empty($yearoffsettype) && ! is_numeric($yearoffsettype) && $conf->global->SOCIETE_FISCAL_MONTH_START > 1))
863
-        $maskraz = $conf->global->SOCIETE_FISCAL_MONTH_START;
1102
+    if (is_numeric($yearoffsettype) && $yearoffsettype >= 1) {
1103
+            $maskraz=$yearoffsettype;
1104
+    }
1105
+    // For backward compatibility
1106
+    else if ($yearoffsettype === '0' || (! empty($yearoffsettype) && ! is_numeric($yearoffsettype) && $conf->global->SOCIETE_FISCAL_MONTH_START > 1)) {
1107
+            $maskraz = $conf->global->SOCIETE_FISCAL_MONTH_START;
1108
+    }
864 1109
     //print "maskraz=".$maskraz;	// -1=no reset
865 1110
 
866 1111
     if ($maskraz > 0) {   // A reset is required
@@ -868,23 +1113,28 @@  discard block
 block discarded – undo
868 1113
             $maskraz = date('m', $date);
869 1114
             $resetEveryMonth = true;
870 1115
         }
871
-        if ($maskraz > 12) return 'ErrorBadMaskBadRazMonth';
1116
+        if ($maskraz > 12) {
1117
+            return 'ErrorBadMaskBadRazMonth';
1118
+        }
872 1119
 
873 1120
         // Define posy, posm and reg
874
-        if ($maskraz > 1)	// if reset is not first month, we need month and year into mask
1121
+        if ($maskraz > 1) {
1122
+            // if reset is not first month, we need month and year into mask
875 1123
         {
876
-            if (preg_match('/^(.*)\{(y+)\}\{(m+)\}/i',$maskwithonlyymcode,$reg)) { $posy=2; $posm=3; }
877
-            elseif (preg_match('/^(.*)\{(m+)\}\{(y+)\}/i',$maskwithonlyymcode,$reg)) { $posy=3; $posm=2; }
878
-            else return 'ErrorCantUseRazInStartedYearIfNoYearMonthInMask';
879
-
880
-            if (dol_strlen($reg[$posy]) < 2) return 'ErrorCantUseRazWithYearOnOneDigit';
1124
+            if (preg_match('/^(.*)\{(y+)\}\{(m+)\}/i',$maskwithonlyymcode,$reg)) { $posy=2;
881 1125
         }
882
-        else // if reset is for a specific month in year, we need year
1126
+        $posm=3; } elseif (preg_match('/^(.*)\{(m+)\}\{(y+)\}/i',$maskwithonlyymcode,$reg)) { $posy=3; $posm=2; } else {
1127
+                return 'ErrorCantUseRazInStartedYearIfNoYearMonthInMask';
1128
+            }
1129
+
1130
+            if (dol_strlen($reg[$posy]) < 2) {
1131
+                return 'ErrorCantUseRazWithYearOnOneDigit';
1132
+            }
1133
+        } else // if reset is for a specific month in year, we need year
883 1134
         {
884
-            if (preg_match('/^(.*)\{(m+)\}\{(y+)\}/i',$maskwithonlyymcode,$reg)) { $posy=3; $posm=2; }
885
-        	else if (preg_match('/^(.*)\{(y+)\}\{(m+)\}/i',$maskwithonlyymcode,$reg)) { $posy=2; $posm=3; }
886
-            else if (preg_match('/^(.*)\{(y+)\}/i',$maskwithonlyymcode,$reg)) { $posy=2; $posm=0; }
887
-            else return 'ErrorCantUseRazIfNoYearInMask';
1135
+            if (preg_match('/^(.*)\{(m+)\}\{(y+)\}/i',$maskwithonlyymcode,$reg)) { $posy=3; $posm=2; } else if (preg_match('/^(.*)\{(y+)\}\{(m+)\}/i',$maskwithonlyymcode,$reg)) { $posy=2; $posm=3; } else if (preg_match('/^(.*)\{(y+)\}/i',$maskwithonlyymcode,$reg)) { $posy=2; $posm=0; } else {
1136
+                return 'ErrorCantUseRazIfNoYearInMask';
1137
+            }
888 1138
         }
889 1139
         // Define length
890 1140
         $yearlen = $posy?dol_strlen($reg[$posy]):0;
@@ -902,9 +1152,11 @@  discard block
 block discarded – undo
902 1152
         $monthcomp=$maskraz;
903 1153
         $yearcomp=0;
904 1154
 
905
-        if (! empty($yearoffsettype) && ! is_numeric($yearoffsettype) && $yearoffsettype != '=')	// $yearoffsettype is - or +
1155
+        if (! empty($yearoffsettype) && ! is_numeric($yearoffsettype) && $yearoffsettype != '=') {
1156
+            // $yearoffsettype is - or +
906 1157
         {
907 1158
         	$currentyear=date("Y", $date);
1159
+        }
908 1160
         	$fiscaldate=dol_mktime('0','0','0',$maskraz,'1',$currentyear);
909 1161
         	$newyeardate=dol_mktime('0','0','0','1','1',$currentyear);
910 1162
         	$nextnewyeardate=dol_mktime('0','0','0','1','1',$currentyear+1);
@@ -914,21 +1166,32 @@  discard block
 block discarded – undo
914 1166
         	if ($date >= $fiscaldate)
915 1167
         	{
916 1168
         		// If before of next new year date
917
-        		if ($date < $nextnewyeardate && $yearoffsettype == '+') $yearoffset=1;
1169
+        		if ($date < $nextnewyeardate && $yearoffsettype == '+') {
1170
+        		    $yearoffset=1;
1171
+        		}
918 1172
         	}
919 1173
         	// If after or equal of current new year date
920
-        	else if ($date >= $newyeardate && $yearoffsettype == '-') $yearoffset=-1;
1174
+        	else if ($date >= $newyeardate && $yearoffsettype == '-') {
1175
+        	    $yearoffset=-1;
1176
+        	}
921 1177
         }
922 1178
         // For backward compatibility
923 1179
         else if (date("m",$date) < $maskraz && empty($resetEveryMonth)) { $yearoffset=-1; }	// If current month lower that month of return to zero, year is previous year
924 1180
 
925
-        if ($yearlen == 4) $yearcomp=sprintf("%04d",date("Y",$date)+$yearoffset);
926
-        elseif ($yearlen == 2) $yearcomp=sprintf("%02d",date("y",$date)+$yearoffset);
927
-        elseif ($yearlen == 1) $yearcomp=substr(date("y",$date),2,1)+$yearoffset;
928
-        if ($monthcomp > 1 && empty($resetEveryMonth))	// Test with month is useless if monthcomp = 0 or 1 (0 is same as 1) (regis: $monthcomp can't equal 0)
1181
+        if ($yearlen == 4) {
1182
+            $yearcomp=sprintf("%04d",date("Y",$date)+$yearoffset);
1183
+        } elseif ($yearlen == 2) {
1184
+            $yearcomp=sprintf("%02d",date("y",$date)+$yearoffset);
1185
+        } elseif ($yearlen == 1) {
1186
+            $yearcomp=substr(date("y",$date),2,1)+$yearoffset;
1187
+        }
1188
+        if ($monthcomp > 1 && empty($resetEveryMonth)) {
1189
+            // Test with month is useless if monthcomp = 0 or 1 (0 is same as 1) (regis: $monthcomp can't equal 0)
929 1190
         {
930 1191
             if ($yearlen == 4) $yearcomp1=sprintf("%04d",date("Y",$date)+$yearoffset+1);
931
-            elseif ($yearlen == 2) $yearcomp1=sprintf("%02d",date("y",$date)+$yearoffset+1);
1192
+        } elseif ($yearlen == 2) {
1193
+                $yearcomp1=sprintf("%02d",date("y",$date)+$yearoffset+1);
1194
+            }
932 1195
 
933 1196
             $sqlwhere.="(";
934 1197
             $sqlwhere.=" (SUBSTRING(".$field.", ".$yearpos.", ".$yearlen.") = '".$yearcomp."'";
@@ -937,13 +1200,11 @@  discard block
 block discarded – undo
937 1200
             $sqlwhere.=" (SUBSTRING(".$field.", ".$yearpos.", ".$yearlen.") = '".$yearcomp1."'";
938 1201
             $sqlwhere.=" AND SUBSTRING(".$field.", ".$monthpos.", ".$monthlen.") < '".str_pad($monthcomp, $monthlen, '0', STR_PAD_LEFT)."') ";
939 1202
             $sqlwhere.=')';
940
-        }
941
-		else if ($resetEveryMonth)
1203
+        } else if ($resetEveryMonth)
942 1204
 		{
943 1205
 			$sqlwhere.="(SUBSTRING(".$field.", ".$yearpos.", ".$yearlen.") = '".$yearcomp."'";
944 1206
             $sqlwhere.=" AND SUBSTRING(".$field.", ".$monthpos.", ".$monthlen.") = '".str_pad($monthcomp, $monthlen, '0', STR_PAD_LEFT)."')";
945
-		}
946
-        else   // reset is done on january
1207
+		} else   // reset is done on january
947 1208
         {
948 1209
             $sqlwhere.='(SUBSTRING('.$field.', '.$yearpos.', '.$yearlen.") = '".$yearcomp."')";
949 1210
         }
@@ -955,12 +1216,13 @@  discard block
 block discarded – undo
955 1216
     if (function_exists('mb_strrpos'))
956 1217
     	{
957 1218
     	$posnumstart=mb_strrpos($maskwithnocode,$maskcounter, 'UTF-8');
958
-	}
959
-	else
1219
+	} else
960 1220
 	{
961 1221
     	$posnumstart=strrpos($maskwithnocode,$maskcounter);
962 1222
 	}	// Pos of counter in final string (from 0 to ...)
963
-    if ($posnumstart < 0) return 'ErrorBadMaskFailedToLocatePosOfSequence';
1223
+    if ($posnumstart < 0) {
1224
+        return 'ErrorBadMaskFailedToLocatePosOfSequence';
1225
+    }
964 1226
     $sqlstring='SUBSTRING('.$field.', '.($posnumstart+1).', '.dol_strlen($maskcounter).')';
965 1227
 
966 1228
     // Define $maskLike
@@ -973,9 +1235,15 @@  discard block
 block discarded – undo
973 1235
     $maskLike = preg_replace('/\{mm\}/i','__',$maskLike);
974 1236
     $maskLike = preg_replace('/\{dd\}/i','__',$maskLike);
975 1237
     $maskLike = str_replace(dol_string_nospecial('{'.$masktri.'}'),str_pad("",dol_strlen($maskcounter),"_"),$maskLike);
976
-    if ($maskrefclient) $maskLike = str_replace(dol_string_nospecial('{'.$maskrefclient.'}'),str_pad("",dol_strlen($maskrefclient),"_"),$maskLike);
977
-    if ($masktype) $maskLike = str_replace(dol_string_nospecial('{'.$masktype.'}'),$masktype_value,$maskLike);
978
-    if ($maskuser) $maskLike = str_replace(dol_string_nospecial('{'.$maskuser.'}'),$maskuser_value,$maskLike);
1238
+    if ($maskrefclient) {
1239
+        $maskLike = str_replace(dol_string_nospecial('{'.$maskrefclient.'}'),str_pad("",dol_strlen($maskrefclient),"_"),$maskLike);
1240
+    }
1241
+    if ($masktype) {
1242
+        $maskLike = str_replace(dol_string_nospecial('{'.$masktype.'}'),$masktype_value,$maskLike);
1243
+    }
1244
+    if ($maskuser) {
1245
+        $maskLike = str_replace(dol_string_nospecial('{'.$maskuser.'}'),$maskuser_value,$maskLike);
1246
+    }
979 1247
     foreach($maskperso as $key => $val)
980 1248
     {
981 1249
     	$maskLike = str_replace(dol_string_nospecial($maskperso[$key]),$maskpersonew[$key],$maskLike);
@@ -987,12 +1255,18 @@  discard block
 block discarded – undo
987 1255
     $sql.= " FROM ".MAIN_DB_PREFIX.$table;
988 1256
     $sql.= " WHERE ".$field." LIKE '".$maskLike."'";
989 1257
 	$sql.= " AND ".$field." NOT LIKE '(PROV%)'";
990
-    if ($bentityon) // only if entity enable
1258
+    if ($bentityon) {
1259
+        // only if entity enable
991 1260
     	$sql.= " AND entity IN (".getEntity($sharetable).")";
992
-    else if (! empty($forceentity))
993
-    	$sql.= " AND entity IN (".$forceentity.")";
994
-    if ($where) $sql.=$where;
995
-    if ($sqlwhere) $sql.=' AND '.$sqlwhere;
1261
+    } else if (! empty($forceentity)) {
1262
+        	$sql.= " AND entity IN (".$forceentity.")";
1263
+    }
1264
+    if ($where) {
1265
+        $sql.=$where;
1266
+    }
1267
+    if ($sqlwhere) {
1268
+        $sql.=' AND '.$sqlwhere;
1269
+    }
996 1270
 
997 1271
     //print $sql.'<br>';
998 1272
     dol_syslog("functions2::get_next_value mode=".$mode."", LOG_DEBUG);
@@ -1001,21 +1275,26 @@  discard block
 block discarded – undo
1001 1275
     {
1002 1276
         $obj = $db->fetch_object($resql);
1003 1277
         $counter = $obj->val;
1278
+    } else {
1279
+        dol_print_error($db);
1004 1280
     }
1005
-    else dol_print_error($db);
1006 1281
 
1007 1282
     // Check if we must force counter to maskoffset
1008
-    if (empty($counter)) $counter=$maskoffset;
1009
-    else if (preg_match('/[^0-9]/i',$counter))
1283
+    if (empty($counter)) {
1284
+        $counter=$maskoffset;
1285
+    } else if (preg_match('/[^0-9]/i',$counter))
1010 1286
     {
1011 1287
     	$counter=0;
1012 1288
     	dol_syslog("Error, the last counter found is '".$counter."' so is not a numeric value. We will restart to 1.", LOG_ERR);
1289
+    } else if ($counter < $maskoffset && empty($conf->global->MAIN_NUMBERING_OFFSET_ONLY_FOR_FIRST)) {
1290
+        $counter=$maskoffset;
1013 1291
     }
1014
-    else if ($counter < $maskoffset && empty($conf->global->MAIN_NUMBERING_OFFSET_ONLY_FOR_FIRST)) $counter=$maskoffset;
1015 1292
 
1016
-    if ($mode == 'last')	// We found value for counter = last counter value. Now need to get corresponding ref of invoice.
1293
+    if ($mode == 'last') {
1294
+        // We found value for counter = last counter value. Now need to get corresponding ref of invoice.
1017 1295
     {
1018 1296
         $counterpadded=str_pad($counter,dol_strlen($maskcounter),"0",STR_PAD_LEFT);
1297
+    }
1019 1298
 
1020 1299
         // Define $maskLike
1021 1300
         $maskLike = dol_string_nospecial($mask);
@@ -1027,34 +1306,48 @@  discard block
 block discarded – undo
1027 1306
         $maskLike = preg_replace('/\{mm\}/i','__',$maskLike);
1028 1307
         $maskLike = preg_replace('/\{dd\}/i','__',$maskLike);
1029 1308
         $maskLike = str_replace(dol_string_nospecial('{'.$masktri.'}'),$counterpadded,$maskLike);
1030
-        if ($maskrefclient) $maskLike = str_replace(dol_string_nospecial('{'.$maskrefclient.'}'),str_pad("",dol_strlen($maskrefclient),"_"),$maskLike);
1031
-        if ($masktype) $maskLike = str_replace(dol_string_nospecial('{'.$masktype.'}'),$masktype_value,$maskLike);
1032
-        if ($maskuser) $maskLike = str_replace(dol_string_nospecial('{'.$maskuser.'}'),$maskuser_value,$maskLike);
1309
+        if ($maskrefclient) {
1310
+            $maskLike = str_replace(dol_string_nospecial('{'.$maskrefclient.'}'),str_pad("",dol_strlen($maskrefclient),"_"),$maskLike);
1311
+        }
1312
+        if ($masktype) {
1313
+            $maskLike = str_replace(dol_string_nospecial('{'.$masktype.'}'),$masktype_value,$maskLike);
1314
+        }
1315
+        if ($maskuser) {
1316
+            $maskLike = str_replace(dol_string_nospecial('{'.$maskuser.'}'),$maskuser_value,$maskLike);
1317
+        }
1033 1318
 
1034 1319
         $ref='';
1035 1320
         $sql = "SELECT ".$field." as ref";
1036 1321
         $sql.= " FROM ".MAIN_DB_PREFIX.$table;
1037 1322
         $sql.= " WHERE ".$field." LIKE '".$maskLike."'";
1038 1323
     	$sql.= " AND ".$field." NOT LIKE '%PROV%'";
1039
-    	if ($bentityon) // only if entity enable
1324
+    	if ($bentityon) {
1325
+    	    // only if entity enable
1040 1326
         	$sql.= " AND entity IN (".getEntity($sharetable).")";
1041
-        else if (! empty($forceentity))
1042
-        	$sql.= " AND entity IN (".$forceentity.")";
1043
-        if ($where) $sql.=$where;
1044
-        if ($sqlwhere) $sql.=' AND '.$sqlwhere;
1327
+    	} else if (! empty($forceentity)) {
1328
+                	$sql.= " AND entity IN (".$forceentity.")";
1329
+        }
1330
+        if ($where) {
1331
+            $sql.=$where;
1332
+        }
1333
+        if ($sqlwhere) {
1334
+            $sql.=' AND '.$sqlwhere;
1335
+        }
1045 1336
 
1046 1337
         dol_syslog("functions2::get_next_value mode=".$mode."", LOG_DEBUG);
1047 1338
         $resql=$db->query($sql);
1048 1339
         if ($resql)
1049 1340
         {
1050 1341
             $obj = $db->fetch_object($resql);
1051
-            if ($obj) $ref = $obj->ref;
1342
+            if ($obj) {
1343
+                $ref = $obj->ref;
1344
+            }
1345
+        } else {
1346
+            dol_print_error($db);
1052 1347
         }
1053
-        else dol_print_error($db);
1054 1348
 
1055 1349
         $numFinal=$ref;
1056
-    }
1057
-    else if ($mode == 'next')
1350
+    } else if ($mode == 'next')
1058 1351
     {
1059 1352
         $counter++;
1060 1353
 
@@ -1070,7 +1363,9 @@  discard block
 block discarded – undo
1070 1363
 
1071 1364
             // Define $sqlstring
1072 1365
             $maskrefclient_posnumstart=strpos($maskwithnocode,$maskrefclient_maskcounter,strpos($maskwithnocode,$maskrefclient));	// Pos of counter in final string (from 0 to ...)
1073
-            if ($maskrefclient_posnumstart <= 0) return 'ErrorBadMask';
1366
+            if ($maskrefclient_posnumstart <= 0) {
1367
+                return 'ErrorBadMask';
1368
+            }
1074 1369
             $maskrefclient_sqlstring='SUBSTRING('.$field.', '.($maskrefclient_posnumstart+1).', '.dol_strlen($maskrefclient_maskcounter).')';
1075 1370
             //print "x".$sqlstring;
1076 1371
 
@@ -1092,12 +1387,20 @@  discard block
 block discarded – undo
1092 1387
             $maskrefclient_sql.= " FROM ".MAIN_DB_PREFIX.$table;
1093 1388
             //$sql.= " WHERE ".$field." not like '(%'";
1094 1389
             $maskrefclient_sql.= " WHERE ".$field." LIKE '".$maskrefclient_maskLike."'";
1095
-            if ($bentityon) // only if entity enable
1390
+            if ($bentityon) {
1391
+                // only if entity enable
1096 1392
             	$maskrefclient_sql.= " AND entity IN (".getEntity($sharetable).")";
1097
-            else if (! empty($forceentity))
1098
-            	$sql.= " AND entity IN (".$forceentity.")";
1099
-            if ($where) $maskrefclient_sql.=$where; //use the same optional where as general mask
1100
-            if ($sqlwhere) $maskrefclient_sql.=' AND '.$sqlwhere; //use the same sqlwhere as general mask
1393
+            } else if (! empty($forceentity)) {
1394
+                        	$sql.= " AND entity IN (".$forceentity.")";
1395
+            }
1396
+            if ($where) {
1397
+                $maskrefclient_sql.=$where;
1398
+            }
1399
+            //use the same optional where as general mask
1400
+            if ($sqlwhere) {
1401
+                $maskrefclient_sql.=' AND '.$sqlwhere;
1402
+            }
1403
+            //use the same sqlwhere as general mask
1101 1404
             $maskrefclient_sql.=' AND (SUBSTRING('.$field.', '.(strpos($maskwithnocode,$maskrefclient)+1).', '.dol_strlen($maskrefclient_maskclientcode).")='".$maskrefclient_clientcode."')";
1102 1405
 
1103 1406
             dol_syslog("functions2::get_next_value maskrefclient", LOG_DEBUG);
@@ -1106,10 +1409,13 @@  discard block
 block discarded – undo
1106 1409
             {
1107 1410
                 $maskrefclient_obj = $db->fetch_object($maskrefclient_resql);
1108 1411
                 $maskrefclient_counter = $maskrefclient_obj->val;
1412
+            } else {
1413
+                dol_print_error($db);
1109 1414
             }
1110
-            else dol_print_error($db);
1111 1415
 
1112
-            if (empty($maskrefclient_counter) || preg_match('/[^0-9]/i',$maskrefclient_counter)) $maskrefclient_counter=$maskrefclient_maskoffset;
1416
+            if (empty($maskrefclient_counter) || preg_match('/[^0-9]/i',$maskrefclient_counter)) {
1417
+                $maskrefclient_counter=$maskrefclient_maskoffset;
1418
+            }
1113 1419
 			$maskrefclient_counter++;
1114 1420
         }
1115 1421
 
@@ -1117,13 +1423,14 @@  discard block
 block discarded – undo
1117 1423
         $numFinal = $mask;
1118 1424
 
1119 1425
         // We replace special codes except refclient
1120
-		if (! empty($yearoffsettype) && ! is_numeric($yearoffsettype) && $yearoffsettype != '=')	// yearoffsettype is - or +, so we don't want current year
1426
+		if (! empty($yearoffsettype) && ! is_numeric($yearoffsettype) && $yearoffsettype != '=') {
1427
+		    // yearoffsettype is - or +, so we don't want current year
1121 1428
 		{
1122 1429
 	        $numFinal = preg_replace('/\{yyyy\}/i',date("Y",$date)+$yearoffset, $numFinal);
1430
+		}
1123 1431
         	$numFinal = preg_replace('/\{yy\}/i',  date("y",$date)+$yearoffset, $numFinal);
1124 1432
         	$numFinal = preg_replace('/\{y\}/i',   substr(date("y",$date),1,1)+$yearoffset, $numFinal);
1125
-		}
1126
-		else	// we want yyyy to be current year
1433
+		} else	// we want yyyy to be current year
1127 1434
 		{
1128 1435
         	$numFinal = preg_replace('/\{yyyy\}/i',date("Y",$date), $numFinal);
1129 1436
         	$numFinal = preg_replace('/\{yy\}/i',  date("y",$date), $numFinal);
@@ -1180,7 +1487,9 @@  discard block
 block discarded – undo
1180 1487
 {
1181 1488
     $string = " ".$string;
1182 1489
      $ini = strpos($string,$start);
1183
-     if ($ini == 0) return "";
1490
+     if ($ini == 0) {
1491
+         return "";
1492
+     }
1184 1493
      $ini += strlen($start);
1185 1494
      $len = strpos($string,$end,$ini) - $ini;
1186 1495
      return substr($string,$ini,$len);
@@ -1204,8 +1513,7 @@  discard block
 block discarded – undo
1204 1513
         $masktri=$reg[1].(isset($reg[2])?$reg[2]:'').(isset($reg[3])?$reg[3]:'');
1205 1514
         $maskcounter=$reg[1];
1206 1515
         $hasglobalcounter=true;
1207
-    }
1208
-    else
1516
+    } else
1209 1517
     {
1210 1518
         // setting some defaults so the rest of the code won't fail if there is a third party counter
1211 1519
         $masktri='00000';
@@ -1214,7 +1522,9 @@  discard block
 block discarded – undo
1214 1522
 
1215 1523
     $maskraz=-1;
1216 1524
     $maskoffset=0;
1217
-    if (dol_strlen($maskcounter) < 3) return 'ErrorCounterMustHaveMoreThan3Digits';
1525
+    if (dol_strlen($maskcounter) < 3) {
1526
+        return 'ErrorCounterMustHaveMoreThan3Digits';
1527
+    }
1218 1528
 
1219 1529
     // Extract value for third party mask counter
1220 1530
     if (preg_match('/\{(c+)(0*)\}/i',$mask,$regClientRef))
@@ -1226,9 +1536,12 @@  discard block
 block discarded – undo
1226 1536
         $maskrefclient_clientcode=substr('',0,dol_strlen($maskrefclient_maskclientcode));//get n first characters of client code to form maskrefclient_clientcode
1227 1537
         $maskrefclient_clientcode=str_pad($maskrefclient_clientcode,dol_strlen($maskrefclient_maskclientcode),"#",STR_PAD_RIGHT);//padding maskrefclient_clientcode for having exactly n characters in maskrefclient_clientcode
1228 1538
         $maskrefclient_clientcode=dol_string_nospecial($maskrefclient_clientcode);//sanitize maskrefclient_clientcode for sql insert and sql select like
1229
-        if (dol_strlen($maskrefclient_maskcounter) > 0 && dol_strlen($maskrefclient_maskcounter) < 3) return 'ErrorCounterMustHaveMoreThan3Digits';
1539
+        if (dol_strlen($maskrefclient_maskcounter) > 0 && dol_strlen($maskrefclient_maskcounter) < 3) {
1540
+            return 'ErrorCounterMustHaveMoreThan3Digits';
1541
+        }
1542
+    } else {
1543
+        $maskrefclient='';
1230 1544
     }
1231
-    else $maskrefclient='';
1232 1545
 
1233 1546
     // fail if there is neither a global nor a third party counter
1234 1547
     if (! $hasglobalcounter && ($maskrefclient_maskcounter == ''))
@@ -1250,21 +1563,35 @@  discard block
 block discarded – undo
1250 1563
     //print "maskwithonlyymcode=".$maskwithonlyymcode." maskwithnocode=".$maskwithnocode."\n<br>";
1251 1564
 
1252 1565
     // If an offset is asked
1253
-    if (! empty($reg[2]) && preg_match('/^\+/',$reg[2])) $maskoffset=preg_replace('/^\+/','',$reg[2]);
1254
-    if (! empty($reg[3]) && preg_match('/^\+/',$reg[3])) $maskoffset=preg_replace('/^\+/','',$reg[3]);
1566
+    if (! empty($reg[2]) && preg_match('/^\+/',$reg[2])) {
1567
+        $maskoffset=preg_replace('/^\+/','',$reg[2]);
1568
+    }
1569
+    if (! empty($reg[3]) && preg_match('/^\+/',$reg[3])) {
1570
+        $maskoffset=preg_replace('/^\+/','',$reg[3]);
1571
+    }
1255 1572
 
1256 1573
     // Define $sqlwhere
1257 1574
 
1258 1575
     // If a restore to zero after a month is asked we check if there is already a value for this year.
1259
-    if (! empty($reg[2]) && preg_match('/^@/',$reg[2]))  $maskraz=preg_replace('/^@/','',$reg[2]);
1260
-    if (! empty($reg[3]) && preg_match('/^@/',$reg[3]))  $maskraz=preg_replace('/^@/','',$reg[3]);
1576
+    if (! empty($reg[2]) && preg_match('/^@/',$reg[2])) {
1577
+        $maskraz=preg_replace('/^@/','',$reg[2]);
1578
+    }
1579
+    if (! empty($reg[3]) && preg_match('/^@/',$reg[3])) {
1580
+        $maskraz=preg_replace('/^@/','',$reg[3]);
1581
+    }
1261 1582
     if ($maskraz >= 0)
1262 1583
     {
1263
-        if ($maskraz > 12) return 'ErrorBadMaskBadRazMonth';
1584
+        if ($maskraz > 12) {
1585
+            return 'ErrorBadMaskBadRazMonth';
1586
+        }
1264 1587
 
1265 1588
         // Define reg
1266
-        if ($maskraz > 1 && ! preg_match('/^(.*)\{(y+)\}\{(m+)\}/i',$maskwithonlyymcode,$reg)) return 'ErrorCantUseRazInStartedYearIfNoYearMonthInMask';
1267
-        if ($maskraz <= 1 && ! preg_match('/^(.*)\{(y+)\}/i',$maskwithonlyymcode,$reg)) return 'ErrorCantUseRazIfNoYearInMask';
1589
+        if ($maskraz > 1 && ! preg_match('/^(.*)\{(y+)\}\{(m+)\}/i',$maskwithonlyymcode,$reg)) {
1590
+            return 'ErrorCantUseRazInStartedYearIfNoYearMonthInMask';
1591
+        }
1592
+        if ($maskraz <= 1 && ! preg_match('/^(.*)\{(y+)\}/i',$maskwithonlyymcode,$reg)) {
1593
+            return 'ErrorCantUseRazIfNoYearInMask';
1594
+        }
1268 1595
         //print "x".$maskwithonlyymcode." ".$maskraz;
1269 1596
     }
1270 1597
     //print "masktri=".$masktri." maskcounter=".$maskcounter." maskraz=".$maskraz." maskoffset=".$maskoffset."<br>\n";
@@ -1274,7 +1601,9 @@  discard block
 block discarded – undo
1274 1601
 
1275 1602
     // Check length
1276 1603
     $len=dol_strlen($maskwithnocode);
1277
-    if (dol_strlen($value) != $len) $result=-1;
1604
+    if (dol_strlen($value) != $len) {
1605
+        $result=-1;
1606
+    }
1278 1607
 
1279 1608
     // Define $maskLike
1280 1609
     /* seems not used
@@ -1355,29 +1684,37 @@  discard block
 block discarded – undo
1355 1684
      */
1356 1685
 
1357 1686
     // Definition du Jeudi de la semaine
1358
-    if (date("w",mktime(12,0,0,$mois,$jour,$annee))==0) // Dimanche
1687
+    if (date("w",mktime(12,0,0,$mois,$jour,$annee))==0) {
1688
+        // Dimanche
1359 1689
     $jeudiSemaine = mktime(12,0,0,$mois,$jour,$annee)-3*24*60*60;
1360
-    else if (date("w",mktime(12,0,0,$mois,$jour,$annee))<4) // du Lundi au Mercredi
1690
+    } else if (date("w",mktime(12,0,0,$mois,$jour,$annee))<4) {
1691
+        // du Lundi au Mercredi
1361 1692
     $jeudiSemaine = mktime(12,0,0,$mois,$jour,$annee)+(4-date("w",mktime(12,0,0,$mois,$jour,$annee)))*24*60*60;
1362
-    else if (date("w",mktime(12,0,0,$mois,$jour,$annee))>4) // du Vendredi au Samedi
1693
+    } else if (date("w",mktime(12,0,0,$mois,$jour,$annee))>4) {
1694
+        // du Vendredi au Samedi
1363 1695
     $jeudiSemaine = mktime(12,0,0,$mois,$jour,$annee)-(date("w",mktime(12,0,0,$mois,$jour,$annee))-4)*24*60*60;
1364
-    else // Jeudi
1696
+    } else {
1697
+        // Jeudi
1365 1698
     $jeudiSemaine = mktime(12,0,0,$mois,$jour,$annee);
1699
+    }
1366 1700
 
1367 1701
     // Definition du premier Jeudi de l'annee
1368
-    if (date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine)))==0) // Dimanche
1702
+    if (date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine)))==0) {
1703
+        // Dimanche
1369 1704
     {
1370 1705
         $premierJeudiAnnee = mktime(12,0,0,1,1,date("Y",$jeudiSemaine))+4*24*60*60;
1371 1706
     }
1372
-    else if (date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine)))<4) // du Lundi au Mercredi
1707
+    } else if (date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine)))<4) {
1708
+        // du Lundi au Mercredi
1373 1709
     {
1374 1710
         $premierJeudiAnnee = mktime(12,0,0,1,1,date("Y",$jeudiSemaine))+(4-date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine))))*24*60*60;
1375 1711
     }
1376
-    else if (date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine)))>4) // du Vendredi au Samedi
1712
+    } else if (date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine)))>4) {
1713
+        // du Vendredi au Samedi
1377 1714
     {
1378 1715
         $premierJeudiAnnee = mktime(12,0,0,1,1,date("Y",$jeudiSemaine))+(7-(date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine)))-4))*24*60*60;
1379 1716
     }
1380
-    else // Jeudi
1717
+    } else // Jeudi
1381 1718
     {
1382 1719
         $premierJeudiAnnee = mktime(12,0,0,1,1,date("Y",$jeudiSemaine));
1383 1720
     }
@@ -1398,8 +1735,7 @@  discard block
 block discarded – undo
1398 1735
         if (date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine)))==4 || (date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine)))==3 && date("z",mktime(12,0,0,12,31,date("Y",$jeudiSemaine)))==365))
1399 1736
         {
1400 1737
             $numeroSemaine = 53;
1401
-        }
1402
-        else
1738
+        } else
1403 1739
         {
1404 1740
             $numeroSemaine = 1;
1405 1741
         }
@@ -1458,7 +1794,9 @@  discard block
 block discarded – undo
1458 1794
 function dol_set_user_param($db, $conf, &$user, $tab)
1459 1795
 {
1460 1796
     // Verification parametres
1461
-    if (count($tab) < 1) return -1;
1797
+    if (count($tab) < 1) {
1798
+        return -1;
1799
+    }
1462 1800
 
1463 1801
     $db->begin();
1464 1802
 
@@ -1470,7 +1808,9 @@  discard block
 block discarded – undo
1470 1808
     $i=0;
1471 1809
     foreach ($tab as $key => $value)
1472 1810
     {
1473
-        if ($i > 0) $sql.=',';
1811
+        if ($i > 0) {
1812
+            $sql.=',';
1813
+        }
1474 1814
         $sql.="'".$db->escape($key)."'";
1475 1815
         $i++;
1476 1816
     }
@@ -1504,8 +1844,7 @@  discard block
 block discarded – undo
1504 1844
             }
1505 1845
             $user->conf->$key = $value;
1506 1846
             //print "key=".$key." user->conf->key=".$user->conf->$key;
1507
-        }
1508
-        else
1847
+        } else
1509 1848
         {
1510 1849
             unset($user->conf->$key);
1511 1850
         }
@@ -1528,8 +1867,7 @@  discard block
 block discarded – undo
1528 1867
     if ($reduction == 100)
1529 1868
     {
1530 1869
         $string = $langs->transnoentities("Offered");
1531
-    }
1532
-    else
1870
+    } else
1533 1871
     {
1534 1872
     	$string = vatrate($reduction,true);
1535 1873
     }
@@ -1616,9 +1954,11 @@  discard block
 block discarded – undo
1616 1954
 
1617 1955
             // If this generation module needs to scan a directory, then description field is filled
1618 1956
             // with the constant that contains list of directories to scan (COMPANY_ADDON_PDF_ODT_PATH, ...).
1619
-            if (! empty($obj->description))	// A list of directories to scan is defined
1957
+            if (! empty($obj->description)) {
1958
+                // A list of directories to scan is defined
1620 1959
             {
1621 1960
                 include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
1961
+            }
1622 1962
 
1623 1963
                 $const=$obj->description;
1624 1964
                 //irtoscan.=($dirtoscan?',':'').preg_replace('/[\r\n]+/',',',trim($conf->global->$const));
@@ -1637,7 +1977,9 @@  discard block
 block discarded – undo
1637 1977
                     {
1638 1978
 			// all type of template is allowed
1639 1979
 			$tmpfiles=dol_dir_list($tmpdir, 'files', 0, '', '', 'name', SORT_ASC, 0);
1640
-                        if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
1980
+                        if (count($tmpfiles)) {
1981
+                            $listoffiles=array_merge($listoffiles,$tmpfiles);
1982
+                        }
1641 1983
                     }
1642 1984
                 }
1643 1985
 
@@ -1648,40 +1990,41 @@  discard block
 block discarded – undo
1648 1990
                         $max=($maxfilenamelength?$maxfilenamelength:28);
1649 1991
                         $liste[$obj->id.':'.$record['fullname']]=dol_trunc($record['name'],$max,'middle');
1650 1992
                     }
1651
-                }
1652
-                else
1993
+                } else
1653 1994
                 {
1654 1995
                     $liste[0]=$obj->label.': '.$langs->trans("None");
1655 1996
                 }
1656
-            }
1657
-            else
1997
+            } else
1658 1998
             {
1659
-                if ($type == 'member' && $obj->lib == 'standard')   // Special case, if member template, we add variant per format
1999
+                if ($type == 'member' && $obj->lib == 'standard') {
2000
+                    // Special case, if member template, we add variant per format
1660 2001
                 {
1661 2002
                     global $_Avery_Labels;
2003
+                }
1662 2004
                     include_once DOL_DOCUMENT_ROOT.'/core/lib/format_cards.lib.php';
1663 2005
                     foreach($_Avery_Labels as $key => $val)
1664 2006
                     {
1665 2007
                         $liste[$obj->id.':'.$key]=($obj->label?$obj->label:$obj->lib).' '.$val['name'];
1666 2008
                     }
1667
-                }
1668
-                else    // Common usage
2009
+                } else    // Common usage
1669 2010
                 {
1670 2011
                     $liste[$obj->id]=$obj->label?$obj->label:$obj->lib;
1671 2012
                 }
1672 2013
             }
1673 2014
             $i++;
1674 2015
         }
1675
-    }
1676
-    else
2016
+    } else
1677 2017
     {
1678 2018
         dol_print_error($db);
1679 2019
         return -1;
1680 2020
     }
1681 2021
 
1682
-    if ($found) return $liste;
1683
-    else return 0;
1684
-}
2022
+    if ($found) {
2023
+        return $liste;
2024
+    } else {
2025
+        return 0;
2026
+    }
2027
+    }
1685 2028
 
1686 2029
 /**
1687 2030
  * This function evaluates a string that should be a valid IPv4
@@ -1696,10 +2039,14 @@  discard block
 block discarded – undo
1696 2039
 	if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
1697 2040
 
1698 2041
 		// Then we test if it is a private range
1699
-		if (! filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE)) return 2;
2042
+		if (! filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE)) {
2043
+		    return 2;
2044
+		}
1700 2045
 
1701 2046
 		// Then we test if it is a reserved range
1702
-		if (! filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE)) return 0;
2047
+		if (! filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE)) {
2048
+		    return 0;
2049
+		}
1703 2050
 
1704 2051
 		return 1;
1705 2052
 	}
@@ -1752,8 +2099,7 @@  discard block
 block discarded – undo
1752 2099
                       'proxy_password' => $proxypass,
1753 2100
                       'trace'		   => 1
1754 2101
         );
1755
-    }
1756
-    else
2102
+    } else
1757 2103
     {
1758 2104
         $params=array('connection_timeout'=>$timeout,
1759 2105
                       'response_timeout'=>$response_timeout,
@@ -1860,14 +2206,12 @@  discard block
 block discarded – undo
1860 2206
 		$classname='FactureFournisseur';
1861 2207
 		$classpath = 'fourn/class';
1862 2208
 		$module='fournisseur';
1863
-	}
1864
-	elseif ($objecttype == 'order_supplier')   {
2209
+	} elseif ($objecttype == 'order_supplier')   {
1865 2210
 		$classfile = 'fournisseur.commande';
1866 2211
 		$classname='CommandeFournisseur';
1867 2212
 		$classpath = 'fourn/class';
1868 2213
 		$module='fournisseur';
1869
-	}
1870
-	elseif ($objecttype == 'stock')   {
2214
+	} elseif ($objecttype == 'stock')   {
1871 2215
 		$classpath = 'product/stock/class';
1872 2216
 		$classfile='entrepot';
1873 2217
 		$classname='Entrepot';
@@ -1887,8 +2231,9 @@  discard block
 block discarded – undo
1887 2231
 					$ret=$langs->trans('Deleted');
1888 2232
 				}
1889 2233
 				unset($object);
2234
+			} else {
2235
+			    dol_syslog("Class with classname ".$classname." is unknown even after the include", LOG_ERR);
1890 2236
 			}
1891
-			else dol_syslog("Class with classname ".$classname." is unknown even after the include", LOG_ERR);
1892 2237
 		}
1893 2238
 	}
1894 2239
 	return $ret;
@@ -1920,11 +2265,12 @@  discard block
 block discarded – undo
1920 2265
 		{
1921 2266
 			$obj = $db->fetch_object($resql);
1922 2267
 			$listofid[]=$obj->rowid;
1923
-			if ($obj->parent_id > 0) $listofparentid[$obj->rowid]=$obj->parent_id;
2268
+			if ($obj->parent_id > 0) {
2269
+			    $listofparentid[$obj->rowid]=$obj->parent_id;
2270
+			}
1924 2271
 			$i++;
1925 2272
 		}
1926
-	}
1927
-	else
2273
+	} else
1928 2274
 	{
1929 2275
 		dol_print_error($db);
1930 2276
 	}
@@ -1959,9 +2305,11 @@  discard block
 block discarded – undo
1959 2305
 			while ($cursor > 0)
1960 2306
 			{
1961 2307
 				$arrayidparsed[$cursor]=1;
1962
-				if ($arrayidparsed[$listofparentid[$cursor]])	// We detect a loop. A record with a parent that was already into child
2308
+				if ($arrayidparsed[$listofparentid[$cursor]]) {
2309
+				    // We detect a loop. A record with a parent that was already into child
1963 2310
 				{
1964 2311
 					print 'Found a loop between id '.$id.' - '.$cursor.'<br>';
2312
+				}
1965 2313
 					unset($arrayidparsed);
1966 2314
 					$listofidtoclean[$cursor]=$id;
1967 2315
 					break;
@@ -1969,7 +2317,9 @@  discard block
 block discarded – undo
1969 2317
 				$cursor=$listofparentid[$cursor];
1970 2318
 			}
1971 2319
 
1972
-			if (count($listofidtoclean)) break;
2320
+			if (count($listofidtoclean)) {
2321
+			    break;
2322
+			}
1973 2323
 		}
1974 2324
 
1975 2325
 		$sql = "UPDATE ".MAIN_DB_PREFIX.$tabletocleantree;
@@ -2116,9 +2466,15 @@  discard block
 block discarded – undo
2116 2466
         $classfile='fournisseur.facture';
2117 2467
     }
2118 2468
 
2119
-    if (!isset($classfile)) $classfile = strtolower($subelement);
2120
-    if (!isset($classname)) $classname = ucfirst($subelement);
2121
-    if (!isset($classpath)) $classpath = $module.'/class';
2469
+    if (!isset($classfile)) {
2470
+        $classfile = strtolower($subelement);
2471
+    }
2472
+    if (!isset($classname)) {
2473
+        $classname = ucfirst($subelement);
2474
+    }
2475
+    if (!isset($classpath)) {
2476
+        $classpath = $module.'/class';
2477
+    }
2122 2478
 
2123 2479
     $element_properties = array(
2124 2480
         'module' => $module,
@@ -2172,8 +2528,12 @@  discard block
 block discarded – undo
2172 2528
  */
2173 2529
 function colorArrayToHex($arraycolor,$colorifnotfound='888888')
2174 2530
 {
2175
-	if (! is_array($arraycolor)) return $colorifnotfound;
2176
-	if (empty($arraycolor)) return $colorifnotfound;
2531
+	if (! is_array($arraycolor)) {
2532
+	    return $colorifnotfound;
2533
+	}
2534
+	if (empty($arraycolor)) {
2535
+	    return $colorifnotfound;
2536
+	}
2177 2537
 	return sprintf("%02s",dechex($arraycolor[0])).sprintf("%02s",dechex($arraycolor[1])).sprintf("%02s",dechex($arraycolor[2]));
2178 2538
 }
2179 2539
 
@@ -2189,12 +2549,17 @@  discard block
 block discarded – undo
2189 2549
  */
2190 2550
 function colorStringToArray($stringcolor,$colorifnotfound=array(88,88,88))
2191 2551
 {
2192
-	if (is_array($stringcolor)) return $stringcolor;	// If already into correct output format, we return as is
2552
+	if (is_array($stringcolor)) {
2553
+	    return $stringcolor;
2554
+	}
2555
+	// If already into correct output format, we return as is
2193 2556
 	$tmp=preg_match('/^#?([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])$/',$stringcolor,$reg);
2194 2557
 	if (! $tmp)
2195 2558
 	{
2196 2559
 		$tmp=explode(',',$stringcolor);
2197
-		if (count($tmp) < 3) return $colorifnotfound;
2560
+		if (count($tmp) < 3) {
2561
+		    return $colorifnotfound;
2562
+		}
2198 2563
 		return $tmp;
2199 2564
 	}
2200 2565
 	return array(hexdec($reg[1]),hexdec($reg[2]),hexdec($reg[3]));
@@ -2240,69 +2605,51 @@  discard block
 block discarded – undo
2240 2605
 function getModuleDirForApiClass($module)
2241 2606
 {
2242 2607
     $moduledirforclass=$module;
2243
-    if ($moduledirforclass != 'api') $moduledirforclass = preg_replace('/api$/i','',$moduledirforclass);
2608
+    if ($moduledirforclass != 'api') {
2609
+        $moduledirforclass = preg_replace('/api$/i','',$moduledirforclass);
2610
+    }
2244 2611
 
2245 2612
     if ($module == 'contracts') {
2246 2613
     	$moduledirforclass = 'contrat';
2247
-    }
2248
-    elseif (in_array($module, array('admin', 'login', 'setup', 'access', 'status', 'tools', 'documents'))) {
2614
+    } elseif (in_array($module, array('admin', 'login', 'setup', 'access', 'status', 'tools', 'documents'))) {
2249 2615
         $moduledirforclass = 'api';
2250
-    }
2251
-    elseif ($module == 'contact' || $module == 'contacts' || $module == 'customer' || $module == 'thirdparty' || $module == 'thirdparties') {
2616
+    } elseif ($module == 'contact' || $module == 'contacts' || $module == 'customer' || $module == 'thirdparty' || $module == 'thirdparties') {
2252 2617
         $moduledirforclass = 'societe';
2253
-    }
2254
-    elseif ($module == 'propale' || $module == 'proposals') {
2618
+    } elseif ($module == 'propale' || $module == 'proposals') {
2255 2619
         $moduledirforclass = 'comm/propal';
2256
-    }
2257
-    elseif ($module == 'agenda' || $module == 'agendaevents') {
2620
+    } elseif ($module == 'agenda' || $module == 'agendaevents') {
2258 2621
         $moduledirforclass = 'comm/action';
2259
-    }
2260
-    elseif ($module == 'adherent' || $module == 'members' || $module == 'memberstypes' || $module == 'subscriptions') {
2622
+    } elseif ($module == 'adherent' || $module == 'members' || $module == 'memberstypes' || $module == 'subscriptions') {
2261 2623
         $moduledirforclass = 'adherents';
2262
-    }
2263
-    elseif ($module == 'banque' || $module == 'bankaccounts') {
2624
+    } elseif ($module == 'banque' || $module == 'bankaccounts') {
2264 2625
         $moduledirforclass = 'compta/bank';
2265
-    }
2266
-    elseif ($module == 'category' || $module == 'categorie') {
2626
+    } elseif ($module == 'category' || $module == 'categorie') {
2267 2627
         $moduledirforclass = 'categories';
2268
-    }
2269
-    elseif ($module == 'order' || $module == 'orders') {
2628
+    } elseif ($module == 'order' || $module == 'orders') {
2270 2629
         $moduledirforclass = 'commande';
2271
-    }
2272
-    elseif ($module == 'shipments') {
2630
+    } elseif ($module == 'shipments') {
2273 2631
     	$moduledirforclass = 'expedition';
2274
-    }
2275
-    elseif ($module == 'facture' || $module == 'invoice' || $module == 'invoices') {
2632
+    } elseif ($module == 'facture' || $module == 'invoice' || $module == 'invoices') {
2276 2633
         $moduledirforclass = 'compta/facture';
2277
-    }
2278
-    elseif ($module == 'products') {
2634
+    } elseif ($module == 'products') {
2279 2635
         $moduledirforclass = 'product';
2280
-    }
2281
-    elseif ($module == 'project' || $module == 'projects' || $module == 'tasks') {
2636
+    } elseif ($module == 'project' || $module == 'projects' || $module == 'tasks') {
2282 2637
         $moduledirforclass = 'projet';
2283
-    }
2284
-    elseif ($module == 'task') {
2638
+    } elseif ($module == 'task') {
2285 2639
         $moduledirforclass = 'projet';
2286
-    }
2287
-    elseif ($module == 'stock' || $module == 'stockmovements' || $module == 'warehouses') {
2640
+    } elseif ($module == 'stock' || $module == 'stockmovements' || $module == 'warehouses') {
2288 2641
         $moduledirforclass = 'product/stock';
2289
-    }
2290
-    elseif ($module == 'supplierproposals' || $module == 'supplierproposal' || $module == 'supplier_proposal') {
2642
+    } elseif ($module == 'supplierproposals' || $module == 'supplierproposal' || $module == 'supplier_proposal') {
2291 2643
     	$moduledirforclass = 'supplier_proposal';
2292
-    }
2293
-    elseif ($module == 'fournisseur' || $module == 'supplierinvoices' || $module == 'supplierorders') {
2644
+    } elseif ($module == 'fournisseur' || $module == 'supplierinvoices' || $module == 'supplierorders') {
2294 2645
         $moduledirforclass = 'fourn';
2295
-    }
2296
-    elseif ($module == 'expensereports') {
2646
+    } elseif ($module == 'expensereports') {
2297 2647
         $moduledirforclass = 'expensereport';
2298
-    }
2299
-    elseif ($module == 'users') {
2648
+    } elseif ($module == 'users') {
2300 2649
         $moduledirforclass = 'user';
2301
-    }
2302
-    elseif ($module == 'ficheinter' || $module == 'interventions') {
2650
+    } elseif ($module == 'ficheinter' || $module == 'interventions') {
2303 2651
     	$moduledirforclass = 'fichinter';
2304
-    }
2305
-    elseif ($module == 'tickets') {
2652
+    } elseif ($module == 'tickets') {
2306 2653
     	$moduledirforclass = 'ticket';
2307 2654
     }
2308 2655
 
Please login to merge, or discard this patch.
dolibarr/htdocs/core/lib/salaries.lib.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -50,7 +50,9 @@
 block discarded – undo
50 50
     $nbLinks=Link::count($db, $object->element, $object->id);
51 51
 	$head[$h][0] = DOL_URL_ROOT.'/compta/salaries/document.php?id='.$object->id;
52 52
 	$head[$h][1] = $langs->trans('Documents');
53
-	if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
53
+	if (($nbFiles+$nbLinks) > 0) {
54
+	    $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
55
+	}
54 56
 	$head[$h][2] = 'documents';
55 57
 	$h++;
56 58
 
Please login to merge, or discard this patch.
dolibarr/htdocs/core/lib/signature.lib.php 1 patch
Braces   +17 added lines, -8 removed lines patch added patch discarded remove patch
@@ -59,16 +59,23 @@  discard block
 block discarded – undo
59 59
 	if ($type == 'proposal')
60 60
 	{
61 61
 		$out=DOL_MAIN_URL_ROOT.'/public/onlinesign/newonlinesign.php?source=proposal&ref='.($mode?'<font color="#666666">':'');
62
-		if ($mode == 1) $out.='proposal_ref';
63
-		if ($mode == 0) $out.=urlencode($ref);
62
+		if ($mode == 1) {
63
+		    $out.='proposal_ref';
64
+		}
65
+		if ($mode == 0) {
66
+		    $out.=urlencode($ref);
67
+		}
64 68
 		$out.=($mode?'</font>':'');
65
-		if ($mode == 1) $out.='&hashp=<font color="#666666">hash_of_file</font>';
66
-		else
69
+		if ($mode == 1) {
70
+		    $out.='&hashp=<font color="#666666">hash_of_file</font>';
71
+		} else
67 72
 		{
68 73
 			include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
69 74
 			$propaltmp=new Propal($db);
70 75
 			$res = $propaltmp->fetch(0, $ref);
71
-			if ($res <= 0) return 'FailedToGetProposal';
76
+			if ($res <= 0) {
77
+			    return 'FailedToGetProposal';
78
+			}
72 79
 
73 80
 			include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
74 81
 			$ecmfile=new EcmFiles($db);
@@ -80,8 +87,7 @@  discard block
 block discarded – undo
80 87
 			{
81 88
 				$out = $langs->trans("FeatureOnlineSignDisabled");
82 89
 				return $out;
83
-			}
84
-			else
90
+			} else
85 91
 			{
86 92
 				$out.='&hashp='.$hashp;
87 93
 			}
@@ -89,7 +95,10 @@  discard block
 block discarded – undo
89 95
 	}
90 96
 
91 97
 	// For multicompany
92
-	if (! empty($out)) $out.="&entity=".$conf->entity; // Check the entity because He may be the same reference in several entities
98
+	if (! empty($out)) {
99
+	    $out.="&entity=".$conf->entity;
100
+	}
101
+	// Check the entity because He may be the same reference in several entities
93 102
 
94 103
 	return $out;
95 104
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/lib/bank.lib.php 1 patch
Braces   +47 added lines, -25 removed lines patch added patch discarded remove patch
@@ -78,13 +78,17 @@  discard block
 block discarded – undo
78 78
     	if ($resql)
79 79
     	{
80 80
     		$obj = $db->fetch_object($resql);
81
-    		if ($obj) $nbReceipts = $obj->nb;
81
+    		if ($obj) {
82
+    		    $nbReceipts = $obj->nb;
83
+    		}
82 84
     		$db->free($resql);
83 85
     	}
84 86
 
85 87
     	$head[$h][0] = DOL_URL_ROOT."/compta/bank/releve.php?account=".$object->id;
86 88
 	    $head[$h][1] = $langs->trans("AccountStatements");
87
-	    if (($nbReceipts) > 0) $head[$h][1].= ' <span class="badge">'.($nbReceipts).'</span>';
89
+	    if (($nbReceipts) > 0) {
90
+	        $head[$h][1].= ' <span class="badge">'.($nbReceipts).'</span>';
91
+	    }
88 92
 	    $head[$h][2] = 'statement';
89 93
 	    $h++;
90 94
 	}
@@ -97,7 +101,9 @@  discard block
 block discarded – undo
97 101
     $nbLinks=Link::count($db, $object->element, $object->id);
98 102
     $head[$h][0] = DOL_URL_ROOT . "/compta/bank/document.php?account=" . $object->id;
99 103
     $head[$h][1] = $langs->trans("Documents");
100
-    if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
104
+    if (($nbFiles+$nbLinks) > 0) {
105
+        $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
106
+    }
101 107
     $head[$h][2] = 'document';
102 108
     $h++;
103 109
 
@@ -187,7 +193,9 @@  discard block
 block discarded – undo
187 193
     $nbLinks=Link::count($db, $object->element, $object->id);
188 194
 	$head[$h][0] = DOL_URL_ROOT.'/compta/bank/various_payment/document.php?id='.$object->id;
189 195
 	$head[$h][1] = $langs->trans('Documents');
190
-	if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
196
+	if (($nbFiles+$nbLinks) > 0) {
197
+	    $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
198
+	}
191 199
 	$head[$h][2] = 'documents';
192 200
 	$h++;
193 201
 
@@ -230,9 +238,12 @@  discard block
 block discarded – undo
230 238
     $iban = new IBAN($account->iban);
231 239
     $check = $iban->Verify();
232 240
 
233
-    if ($check) return true;
234
-    else return false;
235
-}
241
+    if ($check) {
242
+        return true;
243
+    } else {
244
+        return false;
245
+    }
246
+    }
236 247
 
237 248
 /**
238 249
  * 		Check account number informations for a bank account
@@ -247,10 +258,12 @@  discard block
 block discarded – undo
247 258
     // For compatibility between
248 259
     // account of type CompanyBankAccount class (we use number, cle_rib)
249 260
     // account of type Account class (we use num_compte, cle)
250
-    if (empty($account->number))
251
-        $account->number = $account->num_compte;
252
-    if (empty($account->cle))
253
-        $account->cle = $account->cle_rib;
261
+    if (empty($account->number)) {
262
+            $account->number = $account->num_compte;
263
+    }
264
+    if (empty($account->cle)) {
265
+            $account->cle = $account->cle_rib;
266
+    }
254 267
 
255 268
     dol_syslog("bank.lib::checkBanForAccount account->code_banque=" . $account->code_banque . " account->code_guichet=" . $account->code_guichet . " account->number=" . $account->number . " account->cle=" . $account->cle . " account->iban=" . $account->iban . " country_code=" . $country_code, LOG_DEBUG);
256 269
 
@@ -290,12 +303,17 @@  discard block
 block discarded – undo
290 303
         return false;
291 304
     }
292 305
     if ($country_code == 'AU') {  // Australian
293
-        if (strlen($account->code_banque) > 7)
294
-            return false; // Sould be 6 but can be 123-456
295
-        else if (strlen($account->code_banque) < 6)
296
-            return false; // Sould be 6
297
-        else
298
-            return true;
306
+        if (strlen($account->code_banque) > 7) {
307
+                    return false;
308
+        }
309
+        // Sould be 6 but can be 123-456
310
+        else if (strlen($account->code_banque) < 6) {
311
+                    return false;
312
+        }
313
+        // Sould be 6
314
+        else {
315
+                    return true;
316
+        }
299 317
     }
300 318
 
301 319
     // No particular rule
@@ -346,10 +364,12 @@  discard block
 block discarded – undo
346 364
 
347 365
     $key = 11 - $sum % 11;
348 366
 
349
-    if ($key == 10)
350
-        $key = 1;
351
-    if ($key == 11)
352
-        $key = 0;
367
+    if ($key == 10) {
368
+            $key = 1;
369
+    }
370
+    if ($key == 11) {
371
+            $key = 0;
372
+    }
353 373
 
354 374
     $keycontrol = $key;
355 375
 
@@ -361,10 +381,12 @@  discard block
 block discarded – undo
361 381
 
362 382
     $key = 11 - $sum % 11;
363 383
 
364
-    if ($key == 10)
365
-        $key = 1;
366
-    if ($key == 11)
367
-        $key = 0;
384
+    if ($key == 10) {
385
+            $key = 1;
386
+    }
387
+    if ($key == 11) {
388
+            $key = 0;
389
+    }
368 390
 
369 391
     $keycontrol .= $key;
370 392
     return $keycontrol;
Please login to merge, or discard this patch.
dolibarr/htdocs/core/lib/holiday.lib.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -47,7 +47,9 @@
 block discarded – undo
47 47
     $nbLinks=Link::count($db, $object->element, $object->id);
48 48
     $head[$h][0] = DOL_URL_ROOT.'/holiday/document.php?id='.$object->id;
49 49
     $head[$h][1] = $langs->trans('Documents');
50
-    if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
50
+    if (($nbFiles+$nbLinks) > 0) {
51
+        $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
52
+    }
51 53
     $head[$h][2] = 'documents';
52 54
     $h++;
53 55
 
Please login to merge, or discard this patch.
dolibarr/htdocs/core/lib/geturl.lib.php 1 patch
Braces   +21 added lines, -18 removed lines patch added patch discarded remove patch
@@ -56,12 +56,16 @@  discard block
 block discarded – undo
56 56
 
57 57
 	@curl_setopt($ch, CURLOPT_FOLLOWLOCATION, ($followlocation?true:false));   // We use @ here because this may return warning if safe mode is on or open_basedir is on
58 58
 
59
-	if (count($addheaders)) curl_setopt($ch, CURLOPT_HTTPHEADER, $addheaders);
59
+	if (count($addheaders)) {
60
+	    curl_setopt($ch, CURLOPT_HTTPHEADER, $addheaders);
61
+	}
60 62
 	curl_setopt($ch, CURLINFO_HEADER_OUT, true);	// To be able to retrieve request header and log it
61 63
 
62 64
 	// By default use tls decied by PHP.
63 65
 	// You can force, if supported a version like TLSv1 or TLSv1.2
64
-	if (! empty($conf->global->MAIN_CURL_SSLVERSION)) curl_setopt($ch, CURLOPT_SSLVERSION, $conf->global->MAIN_CURL_SSLVERSION);
66
+	if (! empty($conf->global->MAIN_CURL_SSLVERSION)) {
67
+	    curl_setopt($ch, CURLOPT_SSLVERSION, $conf->global->MAIN_CURL_SSLVERSION);
68
+	}
65 69
 	//curl_setopt($ch, CURLOPT_SSLVERSION, 6); for tls 1.2
66 70
 
67 71
     //turning off the server and peer verification(TrustManager Concept).
@@ -77,33 +81,29 @@  discard block
 block discarded – undo
77 81
     {
78 82
     	curl_setopt($ch, CURLOPT_POST, 1);	// POST
79 83
     	curl_setopt($ch, CURLOPT_POSTFIELDS, $param);	// Setting param x=a&y=z as POST fields
80
-    }
81
-    else if ($postorget == 'PUT')
84
+    } else if ($postorget == 'PUT')
82 85
     {
83 86
     	curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); // HTTP request is 'PUT'
84
-    	if (! is_array($param)) parse_str($param, $array_param);
85
-    	else
87
+    	if (! is_array($param)) {
88
+    	    parse_str($param, $array_param);
89
+    	} else
86 90
     	{
87 91
     	    dol_syslog("parameter param must be a string", LOG_WARNING);
88 92
     	    $array_param=$param;
89 93
     	}
90 94
     	curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($array_param));	// Setting param x=a&y=z as PUT fields
91
-    }
92
-    else if ($postorget == 'PUTALREADYFORMATED')
95
+    } else if ($postorget == 'PUTALREADYFORMATED')
93 96
     {
94 97
     	curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); // HTTP request is 'PUT'
95 98
     	curl_setopt($ch, CURLOPT_POSTFIELDS, $param);	// param = content of post, like a xml string
96
-    }
97
-    else if ($postorget == 'HEAD')
99
+    } else if ($postorget == 'HEAD')
98 100
     {
99 101
     	curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'HEAD'); // HTTP request is 'HEAD'
100 102
     	curl_setopt($ch, CURLOPT_NOBODY, true);
101
-    }
102
-    else if ($postorget == 'DELETE')
103
+    } else if ($postorget == 'DELETE')
103 104
     {
104 105
     	curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');	// POST
105
-    }
106
-    else
106
+    } else
107 107
     {
108 108
     	curl_setopt($ch, CURLOPT_POST, 0);			// GET
109 109
     }
@@ -114,7 +114,9 @@  discard block
 block discarded – undo
114 114
         dol_syslog("getURLContent set proxy to ".$PROXY_HOST. ":" . $PROXY_PORT." - ".$PROXY_USER. ":" . $PROXY_PASS);
115 115
         //curl_setopt ($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP); // Curl 7.10
116 116
         curl_setopt($ch, CURLOPT_PROXY, $PROXY_HOST. ":" . $PROXY_PORT);
117
-        if ($PROXY_USER) curl_setopt($ch, CURLOPT_PROXYUSERPWD, $PROXY_USER. ":" . $PROXY_PASS);
117
+        if ($PROXY_USER) {
118
+            curl_setopt($ch, CURLOPT_PROXYUSERPWD, $PROXY_USER. ":" . $PROXY_PASS);
119
+        }
118 120
     }
119 121
 
120 122
     //getting response from server
@@ -137,8 +139,7 @@  discard block
 block discarded – undo
137 139
         $rep['curl_error_msg']=curl_error($ch);
138 140
 
139 141
 		dol_syslog("getURLContent response array is ".join(',',$rep));
140
-    }
141
-    else
142
+    } else
142 143
     {
143 144
     	$info = curl_getinfo($ch);
144 145
 
@@ -190,7 +191,9 @@  discard block
 block discarded – undo
190 191
 {
191 192
 	$prefix='';
192 193
 	$tmpurl = $url;
193
-	if (preg_match('/^(https?:\/\/)/i', $tmpurl, $reg)) $prefix = $reg[1];
194
+	if (preg_match('/^(https?:\/\/)/i', $tmpurl, $reg)) {
195
+	    $prefix = $reg[1];
196
+	}
194 197
 	$tmpurl = preg_replace('/^https?:\/\//i', '', $tmpurl);				// Remove http(s)://
195 198
 	$tmpurl = preg_replace('/\/.*$/i', '', $tmpurl);					// Remove part after domain
196 199
 
Please login to merge, or discard this patch.