Passed
Push — master ( 49af33...3cffbe )
by Alxarafe
21:21
created
dolibarr/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php 1 patch
Braces   +10 added lines, -5 removed lines patch added patch discarded remove patch
@@ -166,8 +166,7 @@  discard block
 block discarded – undo
166 166
 	                	}
167 167
 
168 168
                         $ok = 1;
169
-	                }
170
-	                else
169
+	                } else
171 170
 	                {
172 171
 	                	$this->error = $userstat->error;
173 172
 	                	$this->errors = $userstat->errors;
@@ -282,10 +281,16 @@  discard block
 block discarded – undo
282 281
 			            	}
283 282
 
284 283
 			            	$qualified = true;
285
-			            	if (empty($enabled)) $qualified = false;
286
-			            	if (empty($perms)) $qualified = false;
284
+			            	if (empty($enabled)) {
285
+			            	    $qualified = false;
286
+			            	}
287
+			            	if (empty($perms)) {
288
+			            	    $qualified = false;
289
+			            	}
287 290
 
288
-			            	if ($qualified) $message_customer.='<li>'.$langs->trans($key).' : '.$value.'</li>';
291
+			            	if ($qualified) {
292
+			            	    $message_customer.='<li>'.$langs->trans($key).' : '.$value.'</li>';
293
+			            	}
289 294
 			            }
290 295
 
291 296
 			            $message_customer.='</ul>';
Please login to merge, or discard this patch.
htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php 1 patch
Braces   +14 added lines, -9 removed lines patch added patch discarded remove patch
@@ -56,11 +56,16 @@  discard block
 block discarded – undo
56 56
 	 */
57 57
 	public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
58 58
 	{
59
-		if (empty($conf->blockedlog->enabled)) return 0;     // Module not active, we do nothing
59
+		if (empty($conf->blockedlog->enabled)) {
60
+		    return 0;
61
+		}
62
+		// Module not active, we do nothing
60 63
 
61 64
 		// Test if event/record is qualified
62 65
 		$listofqualifiedelement = array('facture', 'don', 'payment', 'payment_donation', 'subscription', 'payment_various', 'cashcontrol');
63
-		if (! in_array($object->element, $listofqualifiedelement)) return 1;
66
+		if (! in_array($object->element, $listofqualifiedelement)) {
67
+		    return 1;
68
+		}
64 69
 
65 70
 		dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
66 71
 
@@ -88,12 +93,14 @@  discard block
 block discarded – undo
88 93
 
89 94
 			if (in_array($action, array(
90 95
 				'MEMBER_SUBSCRIPTION_CREATE','MEMBER_SUBSCRIPTION_MODIFY','MEMBER_SUBSCRIPTION_DELETE',
91
-				'DON_VALIDATE','DON_MODIFY','DON_DELETE'))) $amounts = (double) $object->amount;
92
-			elseif ($action == 'CASHCONTROL_VALIDATE')
96
+				'DON_VALIDATE','DON_MODIFY','DON_DELETE'))) {
97
+			    $amounts = (double) $object->amount;
98
+			} elseif ($action == 'CASHCONTROL_VALIDATE')
93 99
 			{
94 100
 				$amounts = (double) $object->cash + (double) $object->cheque + (double) $object->card;
101
+			} else {
102
+			    $amounts = (double) $object->total_ttc;
95 103
 			}
96
-			else $amounts = (double) $object->total_ttc;
97 104
 		}
98 105
 		/*if ($action === 'BILL_PAYED' || $action==='BILL_UNPAYED'
99 106
 		 || $action === 'BILL_SUPPLIER_PAYED' || $action === 'BILL_SUPPLIER_UNPAYED')
@@ -111,8 +118,7 @@  discard block
 block discarded – undo
111 118
 					$amounts += price2num($amount);
112 119
 				}
113 120
 			}
114
-		}
115
-		elseif (strpos($action,'PAYMENT')!==false && ! in_array($action, array('PAYMENT_ADD_TO_BANK')))
121
+		} elseif (strpos($action,'PAYMENT')!==false && ! in_array($action, array('PAYMENT_ADD_TO_BANK')))
116 122
 		{
117 123
 			$qualified++;
118 124
 			$amounts = (double) $object->amount;
@@ -141,8 +147,7 @@  discard block
 block discarded – undo
141 147
 			$this->error = $b->error;
142 148
 			$this->errors = $b->errors;
143 149
 			return -1;
144
-		}
145
-		else
150
+		} else
146 151
 		{
147 152
 			return 1;
148 153
 		}
Please login to merge, or discard this patch.
dolibarr/htdocs/core/db/DoliDB.class.php 1 patch
Braces   +24 added lines, -17 removed lines patch added patch discarded remove patch
@@ -120,8 +120,7 @@  discard block
 block discarded – undo
120 120
 				dol_syslog('',0,1);
121 121
 			}
122 122
 			return $ret;
123
-		}
124
-		else
123
+		} else
125 124
 		{
126 125
 			$this->transaction_opened++;
127 126
 			dol_syslog('',0,1);
@@ -146,13 +145,11 @@  discard block
 block discarded – undo
146 145
 				$this->transaction_opened=0;
147 146
 				dol_syslog("COMMIT Transaction".($log?' '.$log:''),LOG_DEBUG);
148 147
 				return 1;
149
-			}
150
-			else
148
+			} else
151 149
 			{
152 150
 				return 0;
153 151
 			}
154
-		}
155
-		else
152
+		} else
156 153
 		{
157 154
 			$this->transaction_opened--;
158 155
 			return 1;
@@ -174,8 +171,7 @@  discard block
 block discarded – undo
174 171
 			$this->transaction_opened=0;
175 172
 			dol_syslog("ROLLBACK Transaction".($log?' '.$log:''),LOG_DEBUG);
176 173
 			return $ret;
177
-		}
178
-		else
174
+		} else
179 175
 		{
180 176
 			$this->transaction_opened--;
181 177
 			return 1;
@@ -192,10 +188,17 @@  discard block
 block discarded – undo
192 188
 	function plimit($limit=0,$offset=0)
193 189
 	{
194 190
 		global $conf;
195
-		if (empty($limit)) return "";
196
-		if ($limit < 0) $limit=$conf->liste_limit;
197
-		if ($offset > 0) return " LIMIT $offset,$limit ";
198
-		else return " LIMIT $limit ";
191
+		if (empty($limit)) {
192
+		    return "";
193
+		}
194
+		if ($limit < 0) {
195
+		    $limit=$conf->liste_limit;
196
+		}
197
+		if ($offset > 0) {
198
+		    return " LIMIT $offset,$limit ";
199
+		} else {
200
+		    return " LIMIT $limit ";
201
+		}
199 202
 	}
200 203
 
201 204
 	/**
@@ -235,8 +238,11 @@  discard block
 block discarded – undo
235 238
 			$i=0;
236 239
 			foreach($fields as $val)
237 240
 			{
238
-				if (! $return) $return.=' ORDER BY ';
239
-				else $return.=', ';
241
+				if (! $return) {
242
+				    $return.=' ORDER BY ';
243
+				} else {
244
+				    $return.=', ';
245
+				}
240 246
 
241 247
 				$return.=preg_replace('/[^0-9a-z_\.]/i','',$val);
242 248
 
@@ -252,8 +258,7 @@  discard block
 block discarded – undo
252 258
 				$i++;
253 259
 			}
254 260
 			return $return;
255
-		}
256
-		else
261
+		} else
257 262
 		{
258 263
 			return '';
259 264
 		}
@@ -281,7 +286,9 @@  discard block
 block discarded – undo
281 286
 	function jdate($string, $gm=false)
282 287
 	{
283 288
 		// TODO GMT must set param gm to true by default
284
-		if ($string==0 || $string=="0000-00-00 00:00:00") return '';
289
+		if ($string==0 || $string=="0000-00-00 00:00:00") {
290
+		    return '';
291
+		}
285 292
 		$string=preg_replace('/([^0-9])/i','',$string);
286 293
 		$tmp=$string.'000000';
287 294
 		$date=dol_mktime(substr($tmp,8,2),substr($tmp,10,2),substr($tmp,12,2),substr($tmp,4,2),substr($tmp,6,2),substr($tmp,0,4),$gm);
Please login to merge, or discard this patch.
dolibarr/htdocs/core/actions_builddoc.inc.php 1 patch
Braces   +33 added lines, -14 removed lines patch added patch discarded remove patch
@@ -37,8 +37,7 @@  discard block
 block discarded – undo
37 37
     if (is_numeric(GETPOST('model','alpha')))
38 38
     {
39 39
         $error=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Model"));
40
-    }
41
-    else
40
+    } else
42 41
     {
43 42
    		// Reload to get all modified line records and be ready for hooks
44 43
         $ret = $object->fetch($id);
@@ -68,9 +67,17 @@  discard block
 block discarded – undo
68 67
         $outputlangs = $langs;
69 68
         $newlang='';
70 69
 
71
-        if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang=GETPOST('lang_id','aZ09');
72
-        if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($object->thirdparty->default_lang)) $newlang=$object->thirdparty->default_lang;  // for proposal, order, invoice, ...
73
-        if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($object->default_lang)) $newlang=$object->default_lang;                  // for thirdparty
70
+        if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) {
71
+            $newlang=GETPOST('lang_id','aZ09');
72
+        }
73
+        if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($object->thirdparty->default_lang)) {
74
+            $newlang=$object->thirdparty->default_lang;
75
+        }
76
+        // for proposal, order, invoice, ...
77
+        if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($object->default_lang)) {
78
+            $newlang=$object->default_lang;
79
+        }
80
+        // for thirdparty
74 81
         if (! empty($newlang))
75 82
         {
76 83
             $outputlangs = new Translate("",$conf);
@@ -78,22 +85,31 @@  discard block
 block discarded – undo
78 85
         }
79 86
 
80 87
         // To be sure vars is defined
81
-        if (empty($hidedetails)) $hidedetails=0;
82
-        if (empty($hidedesc)) $hidedesc=0;
83
-        if (empty($hideref)) $hideref=0;
84
-        if (empty($moreparams)) $moreparams=null;
88
+        if (empty($hidedetails)) {
89
+            $hidedetails=0;
90
+        }
91
+        if (empty($hidedesc)) {
92
+            $hidedesc=0;
93
+        }
94
+        if (empty($hideref)) {
95
+            $hideref=0;
96
+        }
97
+        if (empty($moreparams)) {
98
+            $moreparams=null;
99
+        }
85 100
 
86 101
         $result= $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
87 102
         if ($result <= 0)
88 103
         {
89 104
             setEventMessages($object->error, $object->errors, 'errors');
90 105
             $action='';
91
-        }
92
-        else
106
+        } else
93 107
         {
94
-        	if (empty($donotredirect))	// This is set when include is done by bulk action "Bill Orders"
108
+        	if (empty($donotredirect)) {
109
+        	    // This is set when include is done by bulk action "Bill Orders"
95 110
         	{
96 111
 	            setEventMessages($langs->trans("FileGenerated"), null);
112
+        	}
97 113
 
98 114
 	            $urltoredirect = $_SERVER['REQUEST_URI'];
99 115
 	            $urltoredirect = preg_replace('/#builddoc$/', '', $urltoredirect);
@@ -122,8 +138,11 @@  discard block
 block discarded – undo
122 138
     $filetodelete=GETPOST('file','alpha');
123 139
     $file =	$upload_dir	. '/' .	$filetodelete;
124 140
     $ret=dol_delete_file($file,0,0,0,$object);
125
-    if ($ret) setEventMessages($langs->trans("FileWasRemoved", $filetodelete), null, 'mesgs');
126
-    else setEventMessages($langs->trans("ErrorFailToDeleteFile", $filetodelete), null, 'errors');
141
+    if ($ret) {
142
+        setEventMessages($langs->trans("FileWasRemoved", $filetodelete), null, 'mesgs');
143
+    } else {
144
+        setEventMessages($langs->trans("ErrorFailToDeleteFile", $filetodelete), null, 'errors');
145
+    }
127 146
 
128 147
     // Make a redirect to avoid to keep the remove_file into the url that create side effects
129 148
     $urltoredirect = $_SERVER['REQUEST_URI'];
Please login to merge, or discard this patch.
dolibarr/htdocs/core/search_page.php 1 patch
Braces   +19 added lines, -8 removed lines patch added patch discarded remove patch
@@ -27,15 +27,24 @@  discard block
 block discarded – undo
27 27
 //if (! defined('NOREQUIREDB'))   define('NOREQUIREDB','1');		// Not disabled cause need to load personalized language
28 28
 //if (! defined('NOREQUIRESOC'))    define('NOREQUIRESOC','1');
29 29
 //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');		// Not disabled cause need to do translations
30
-if (! defined('NOCSRFCHECK'))     define('NOCSRFCHECK',1);
31
-if (! defined('NOTOKENRENEWAL'))  define('NOTOKENRENEWAL',1);
30
+if (! defined('NOCSRFCHECK')) {
31
+    define('NOCSRFCHECK',1);
32
+}
33
+if (! defined('NOTOKENRENEWAL')) {
34
+    define('NOTOKENRENEWAL',1);
35
+}
32 36
 //if (! defined('NOLOGIN')) define('NOLOGIN',1);					// Not disabled cause need to load personalized language
33
-if (! defined('NOREQUIREMENU'))  define('NOREQUIREMENU',1);
37
+if (! defined('NOREQUIREMENU')) {
38
+    define('NOREQUIREMENU',1);
39
+}
34 40
 //if (! defined('NOREQUIREHTML'))  define('NOREQUIREHTML',1);
35 41
 
36 42
 require_once '../main.inc.php';
37 43
 
38
-if (GETPOST('lang', 'aZ09')) $langs->setDefaultLang(GETPOST('lang', 'aZ09'));	// If language was forced on URL by the main.inc.php
44
+if (GETPOST('lang', 'aZ09')) {
45
+    $langs->setDefaultLang(GETPOST('lang', 'aZ09'));
46
+}
47
+// If language was forced on URL by the main.inc.php
39 48
 
40 49
 $langs->load("main");
41 50
 
@@ -69,13 +78,14 @@  discard block
 block discarded – undo
69 78
 // Define $searchform
70 79
 $searchform = '';
71 80
 
72
-if ($conf->use_javascript_ajax && 1 == 2)   // select2 is ko with jmobile
81
+if ($conf->use_javascript_ajax && 1 == 2) {
82
+    // select2 is ko with jmobile
73 83
 {
74 84
     if (! is_object($form)) $form=new Form($db);
85
+}
75 86
     $selected=-1;
76 87
     $searchform.='<br><br>'.$form->selectArrayAjax('searchselectcombo', DOL_URL_ROOT.'/core/ajax/selectsearchbox.php', $selected, '', '', 0, 1, 'minwidth300', 1, $langs->trans("Search"), 0);
77
-}
78
-else
88
+} else
79 89
 {
80 90
     $usedbyinclude = 1; // Used into next include
81 91
 	$showtitlebefore = GETPOST('showtitlebefore','int');
@@ -104,8 +114,9 @@  discard block
 block discarded – undo
104 114
 if (empty($reshook))
105 115
 {
106 116
 	$searchform.=$hookmanager->resPrint;
117
+} else {
118
+    $searchform=$hookmanager->resPrint;
107 119
 }
108
-else $searchform=$hookmanager->resPrint;
109 120
 
110 121
 
111 122
 print "\n";
Please login to merge, or discard this patch.
dolibarr/htdocs/core/actions_extrafields.inc.php 1 patch
Braces   +31 added lines, -29 removed lines patch added patch discarded remove patch
@@ -31,10 +31,18 @@  discard block
 block discarded – undo
31 31
 $type=GETPOST('type','alpha');
32 32
 $param=GETPOST('param','alpha');
33 33
 
34
-if ($type=='double' && strpos($extrasize,',')===false) $extrasize='24,8';
35
-if ($type=='date')     $extrasize='';
36
-if ($type=='datetime') $extrasize='';
37
-if ($type=='select')   $extrasize='';
34
+if ($type=='double' && strpos($extrasize,',')===false) {
35
+    $extrasize='24,8';
36
+}
37
+if ($type=='date') {
38
+    $extrasize='';
39
+}
40
+if ($type=='datetime') {
41
+    $extrasize='';
42
+}
43
+if ($type=='select') {
44
+    $extrasize='';
45
+}
38 46
 
39 47
 
40 48
 // Add attribute
@@ -122,8 +130,7 @@  discard block
 block discarded – undo
122 130
 	    					$mesg[]=$langs->trans("ErrorBadFormatValueList",$param_ligne);
123 131
 	    					$action = 'create';
124 132
 	    				}
125
-	    			}
126
-	    			else
133
+	    			} else
127 134
 	    			{
128 135
 	    				$error++;
129 136
 	    				$langs->load("errors");
@@ -149,8 +156,7 @@  discard block
 block discarded – undo
149 156
     				{
150 157
     					$params['options'] = array($parameters=>null);
151 158
     				}
152
-    			}
153
-    			else
159
+    			} else
154 160
     			{
155 161
     				//Esle it's separated key/value and coma list
156 162
     				foreach($parameters_array as $param_ligne)
@@ -162,7 +168,9 @@  discard block
 block discarded – undo
162 168
 
163 169
     			// Visibility: -1=not visible by default in list, 1=visible, 0=hidden
164 170
     			$visibility = GETPOST('list', 'alpha');
165
-				if ($type == 'separate') $visibility=3;
171
+				if ($type == 'separate') {
172
+				    $visibility=3;
173
+				}
166 174
 
167 175
                 $result=$extrafields->addExtraField(
168 176
                 	GETPOST('attrname', 'alpha'),
@@ -190,15 +198,13 @@  discard block
 block discarded – undo
190 198
     				setEventMessages($langs->trans('SetupSaved'), null, 'mesgs');
191 199
     				header("Location: ".$_SERVER["PHP_SELF"]);
192 200
     				exit;
193
-    			}
194
-    			else
201
+    			} else
195 202
     			{
196 203
                     $error++;
197 204
     			    $mesg=$extrafields->error;
198 205
                     setEventMessages($mesg, null, 'errors');
199 206
     			}
200
-    		}
201
-    		else
207
+    		} else
202 208
     		{
203 209
                 $error++;
204 210
     		    $langs->load("errors");
@@ -206,8 +212,7 @@  discard block
 block discarded – undo
206 212
     			setEventMessages($mesg, null, 'errors');
207 213
     			$action = 'create';
208 214
     		}
209
-	    }
210
-	    else
215
+	    } else
211 216
 	    {
212 217
 	    	setEventMessages($mesg, null, 'errors');
213 218
 	    }
@@ -292,8 +297,7 @@  discard block
 block discarded – undo
292 297
 	        				$mesg[]=$langs->trans("ErrorBadFormatValueList",$param_ligne);
293 298
 	        				$action = 'edit';
294 299
 	        			}
295
-	        		}
296
-	        		else
300
+	        		} else
297 301
 	        		{
298 302
 	        			$error++;
299 303
 	        			$langs->load("errors");
@@ -318,8 +322,7 @@  discard block
 block discarded – undo
318 322
     				{
319 323
     					$params['options'] = array($parameters=>null);
320 324
     				}
321
-    			}
322
-    			else
325
+    			} else
323 326
     			{
324 327
     				//Esle it's separated key/value and coma list
325 328
     				foreach($parameters_array as $param_ligne)
@@ -331,7 +334,9 @@  discard block
 block discarded – undo
331 334
 
332 335
     			// Visibility: -1=not visible by default in list, 1=visible, 0=hidden
333 336
     			$visibility = GETPOST('list', 'alpha');
334
-    			if ($type == 'separate') $visibility=3;
337
+    			if ($type == 'separate') {
338
+    			    $visibility=3;
339
+    			}
335 340
 
336 341
                 $result=$extrafields->update(
337 342
     				GETPOST('attrname', 'alpha'),
@@ -359,23 +364,20 @@  discard block
 block discarded – undo
359 364
     				setEventMessages($langs->trans('SetupSaved'), null, 'mesgs');
360 365
     				header("Location: ".$_SERVER["PHP_SELF"]);
361 366
     				exit;
362
-    			}
363
-    			else
367
+    			} else
364 368
     			{
365 369
                     $error++;
366 370
     			    $mesg=$extrafields->error;
367 371
     			    setEventMessages($mesg, null, 'errors');
368 372
     			}
369
-    		}
370
-    		else
373
+    		} else
371 374
     		{
372 375
     		    $error++;
373 376
     			$langs->load("errors");
374 377
     			$mesg=$langs->trans("ErrorFieldCanNotContainSpecialCharacters",$langs->transnoentities("AttributeCode"));
375 378
     			setEventMessages($mesg, null, 'errors');
376 379
     		}
377
-	    }
378
-	    else
380
+	    } else
379 381
 	    {
380 382
 	    	setEventMessages($mesg, null, 'errors');
381 383
 	    }
@@ -392,10 +394,10 @@  discard block
 block discarded – undo
392 394
         {
393 395
             header("Location: ".$_SERVER["PHP_SELF"]);
394 396
             exit;
397
+        } else {
398
+            $mesg=$extrafields->error;
395 399
         }
396
-        else $mesg=$extrafields->error;
397
-	}
398
-	else
400
+	} else
399 401
 	{
400 402
 	    $error++;
401 403
 		$langs->load("errors");
Please login to merge, or discard this patch.
dolibarr/htdocs/core/login/functions_openid.php 1 patch
Braces   +4 added lines, -8 removed lines patch added patch discarded remove patch
@@ -56,8 +56,7 @@  discard block
 block discarded – undo
56 56
         {
57 57
             $openid->SetApprovedURL($protocol . $_SERVER["HTTP_HOST"] . $_SERVER["SCRIPT_NAME"]);      // Send Response from OpenID server to this script
58 58
             $openid->Redirect();     // This will redirect user to OpenID Server
59
-        }
60
-        else
59
+        } else
61 60
         {
62 61
             $error = $openid->GetError();
63 62
             return false;
@@ -89,21 +88,18 @@  discard block
 block discarded – undo
89 88
                     $login=$obj->login;
90 89
                 }
91 90
             }
92
-        }
93
-        else if($openid->IsError() === true)
91
+        } else if($openid->IsError() === true)
94 92
         {
95 93
             // ON THE WAY, WE GOT SOME ERROR
96 94
             $error = $openid->GetError();
97 95
             return false;
98
-        }
99
-        else
96
+        } else
100 97
         {
101 98
             // Signature Verification Failed
102 99
             //echo "INVALID AUTHORIZATION";
103 100
             return false;
104 101
         }
105
-    }
106
-    else if ($_GET['openid_mode'] == 'cancel')
102
+    } else if ($_GET['openid_mode'] == 'cancel')
107 103
     {
108 104
         // User Canceled your Request
109 105
         //echo "USER CANCELED REQUEST";
Please login to merge, or discard this patch.
dolibarr/htdocs/core/login/functions_forceuser.php 1 patch
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -40,9 +40,13 @@
 block discarded – undo
40 40
 	dol_syslog("functions_forceuser::check_user_password_forceuser");
41 41
 
42 42
 	$login=$dolibarr_auto_user;
43
-	if (empty($login)) $login='auto';
43
+	if (empty($login)) {
44
+	    $login='auto';
45
+	}
44 46
 
45
-	if ($_SESSION["dol_loginmesg"]) $login='';
47
+	if ($_SESSION["dol_loginmesg"]) {
48
+	    $login='';
49
+	}
46 50
 
47 51
 	dol_syslog("functions_forceuser::check_user_password_forceuser ok. forced user = ".$login);
48 52
 	return $login;
Please login to merge, or discard this patch.
dolibarr/htdocs/core/login/functions_dolibarr.php 1 patch
Braces   +22 added lines, -12 removed lines patch added patch discarded remove patch
@@ -39,7 +39,9 @@  discard block
 block discarded – undo
39 39
 
40 40
 	// Force master entity in transversal mode
41 41
 	$entity=$entitytotest;
42
-	if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) $entity=1;
42
+	if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
43
+	    $entity=1;
44
+	}
43 45
 
44 46
 	$login='';
45 47
 
@@ -56,7 +58,9 @@  discard block
 block discarded – undo
56 58
 		$sql ='SELECT rowid, login, entity, pass, pass_crypted';
57 59
 		$sql.=' FROM '.$table;
58 60
 		$sql.=' WHERE ('.$usernamecol1." = '".$db->escape($usertotest)."'";
59
-		if (preg_match('/@/',$usertotest)) $sql.=' OR '.$usernamecol2." = '".$db->escape($usertotest)."'";
61
+		if (preg_match('/@/',$usertotest)) {
62
+		    $sql.=' OR '.$usernamecol2." = '".$db->escape($usertotest)."'";
63
+		}
60 64
 		$sql.=') AND '.$entitycol." IN (0," . ($entity ? $entity : 1) . ")";
61 65
 		$sql.=' AND statut = 1';
62 66
 		// Required to first found the user into entity, then the superadmin.
@@ -77,10 +81,14 @@  discard block
 block discarded – undo
77 81
 
78 82
 				// Check crypted password
79 83
 				$cryptType='';
80
-				if (! empty($conf->global->DATABASE_PWD_ENCRYPTED)) $cryptType=$conf->global->DATABASE_PWD_ENCRYPTED;
84
+				if (! empty($conf->global->DATABASE_PWD_ENCRYPTED)) {
85
+				    $cryptType=$conf->global->DATABASE_PWD_ENCRYPTED;
86
+				}
81 87
 
82 88
 				// By default, we used MD5
83
-				if (! in_array($cryptType,array('md5'))) $cryptType='md5';
89
+				if (! in_array($cryptType,array('md5'))) {
90
+				    $cryptType='md5';
91
+				}
84 92
 				// Check crypted password according to crypt algorithm
85 93
 				if ($cryptType == 'md5')
86 94
 				{
@@ -106,8 +114,7 @@  discard block
 block discarded – undo
106 114
 				if ($passok)
107 115
 				{
108 116
 					$login=$obj->login;
109
-				}
110
-				else
117
+				} else
111 118
 				{
112 119
 					dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentification ko bad password for '".$usertotest."'");
113 120
 					sleep(2);      // Anti brut force protection
@@ -119,11 +126,16 @@  discard block
 block discarded – undo
119 126
 				}
120 127
 
121 128
 				// We must check entity
122
-				if ($passok && ! empty($conf->multicompany->enabled))	// We must check entity
129
+				if ($passok && ! empty($conf->multicompany->enabled)) {
130
+				    // We must check entity
123 131
 				{
124 132
 					global $mc;
133
+				}
125 134
 
126
-					if (! isset($mc)) $conf->multicompany->enabled = false; 	// Global not available, disable $conf->multicompany->enabled for safety
135
+					if (! isset($mc)) {
136
+					    $conf->multicompany->enabled = false;
137
+					}
138
+					// Global not available, disable $conf->multicompany->enabled for safety
127 139
 					else
128 140
 					{
129 141
 						$ret = $mc->checkRight($obj->rowid, $entitytotest);
@@ -134,8 +146,7 @@  discard block
 block discarded – undo
134 146
 						}
135 147
 					}
136 148
 				}
137
-			}
138
-			else
149
+			} else
139 150
 			{
140 151
 				dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentification ko user not found for '".$usertotest."'");
141 152
 				sleep(1);
@@ -145,8 +156,7 @@  discard block
 block discarded – undo
145 156
 
146 157
 				$_SESSION["dol_loginmesg"]=$langs->trans("ErrorBadLoginPassword");
147 158
 			}
148
-		}
149
-		else
159
+		} else
150 160
 		{
151 161
 			dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentification ko db error for '".$usertotest."' error=".$db->lasterror());
152 162
 			sleep(1);
Please login to merge, or discard this patch.