Completed
Branch develop (e5aae4)
by
unknown
25:19
created
htdocs/user/class/user.class.php 1 patch
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -594,8 +594,8 @@  discard block
 block discarded – undo
594 594
 			$sql .= " WHERE u.rowid = ".((int) $id);
595 595
 		} else {
596 596
 			if ($entity < 0) {
597
-				if ((! isModEnabled('multicompany') || ! getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE')) && (! empty($user->entity))) {
598
-					$sql .= " WHERE u.entity IN (0, " . ((int) $conf->entity) . ")";
597
+				if ((!isModEnabled('multicompany') || !getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE')) && (!empty($user->entity))) {
598
+					$sql .= " WHERE u.entity IN (0, ".((int) $conf->entity).")";
599 599
 				} else {
600 600
 					$sql .= " WHERE u.entity IS NOT NULL"; // multicompany is on in transverse mode or user making fetch is on entity 0, so user is allowed to fetch anywhere into database
601 601
 				}
@@ -607,7 +607,7 @@  discard block
 block discarded – undo
607 607
 					if ($entity != '' && $entity == 0) {    // If $entity = 0
608 608
 						$sql .= " WHERE u.entity = 0";
609 609
 					} else {                                // if $entity is -1 or > 0
610
-						$sql .= " WHERE u.entity IN (0, " . ((int) ($entity > 0 ? $entity : $conf->entity)) . ")";
610
+						$sql .= " WHERE u.entity IN (0, ".((int) ($entity > 0 ? $entity : $conf->entity)).")";
611 611
 					}
612 612
 				}
613 613
 			}
@@ -668,11 +668,11 @@  discard block
 block discarded – undo
668 668
 				$this->pass_indatabase = $obj->pass;
669 669
 				$this->pass_indatabase_crypted = $obj->pass_crypted;
670 670
 				$this->pass = $obj->pass;
671
-				$this->pass_temp	= $obj->pass_temp;
671
+				$this->pass_temp = $obj->pass_temp;
672 672
 				$this->datelastpassvalidation = $obj->datelastpassvalidation;
673 673
 				$this->api_key = dolDecrypt($obj->api_key);
674 674
 
675
-				$this->address 		= $obj->address;
675
+				$this->address = $obj->address;
676 676
 				$this->zip 			= $obj->zip;
677 677
 				$this->town 		= $obj->town;
678 678
 
@@ -695,11 +695,11 @@  discard block
 block discarded – undo
695 695
 
696 696
 				$this->job = $obj->job;
697 697
 				$this->signature = $obj->signature;
698
-				$this->admin		= $obj->admin;
698
+				$this->admin = $obj->admin;
699 699
 				$this->note_public = $obj->note_public;
700 700
 				$this->note_private = $obj->note_private;
701 701
 
702
-				$this->statut		= $obj->status;			// deprecated
702
+				$this->statut		= $obj->status; // deprecated
703 703
 				$this->status		= $obj->status;
704 704
 
705 705
 				$this->photo		= $obj->photo;
@@ -837,7 +837,7 @@  discard block
 block discarded – undo
837 837
 			require_once DOL_DOCUMENT_ROOT.'/core/class/defaultvalues.class.php';
838 838
 
839 839
 			$defaultValues = new DefaultValues($this->db);
840
-			$result = $defaultValues->fetchAll('', '', 0, 0, '(t.user_id:in:0,'.$this->id.') AND (entity:in:'.(isset($this->entity) ? $this->entity : $conf->entity).','.$conf->entity.')');	// User 0 (all) + me (if defined)
840
+			$result = $defaultValues->fetchAll('', '', 0, 0, '(t.user_id:in:0,'.$this->id.') AND (entity:in:'.(isset($this->entity) ? $this->entity : $conf->entity).','.$conf->entity.')'); // User 0 (all) + me (if defined)
841 841
 			//$result = $defaultValues->fetchAll('', '', 0, 0, array('t.user_id'=>array(0, $this->id), 'entity'=>array((isset($this->entity) ? $this->entity : $conf->entity), $conf->entity)));	// User 0 (all) + me (if defined)
842 842
 
843 843
 			if (!is_array($result) && $result < 0) {
@@ -954,16 +954,16 @@  discard block
 block discarded – undo
954 954
 		// Special case for external user
955 955
 		if (!empty($this->socid)) {
956 956
 			if ($module == 'societe' && ($permlevel1 == 'creer' || $permlevel1 == 'write')) {
957
-				return 0;	// An external user never has the permission ->societe->write to see all thirdparties (always restricted to himself)
957
+				return 0; // An external user never has the permission ->societe->write to see all thirdparties (always restricted to himself)
958 958
 			}
959 959
 			if ($module == 'societe' && $permlevel1 == 'client' && $permlevel2 == 'voir') {
960
-				return 0;	// An external user never has the permission ->societe->client->voir to see all thirdparties (always restricted to himself)
960
+				return 0; // An external user never has the permission ->societe->client->voir to see all thirdparties (always restricted to himself)
961 961
 			}
962 962
 			if ($module == 'societe' && $permlevel1 == 'export') {
963
-				return 0;	// An external user never has the permission ->societe->export to see all thirdparties (always restricted to himself)
963
+				return 0; // An external user never has the permission ->societe->export to see all thirdparties (always restricted to himself)
964 964
 			}
965 965
 			if ($module == 'societe' && ($permlevel1 == 'supprimer' || $permlevel1 == 'delete')) {
966
-				return 0;	// An external user never has the permission ->societe->delete to see all thirdparties (always restricted to himself)
966
+				return 0; // An external user never has the permission ->societe->delete to see all thirdparties (always restricted to himself)
967 967
 			}
968 968
 		}
969 969
 
@@ -1111,7 +1111,7 @@  discard block
 block discarded – undo
1111 1111
 			$sql .= " FROM ".$this->db->prefix()."rights_def";
1112 1112
 			$sql .= " WHERE entity = ".((int) $entity);
1113 1113
 			if (!empty($whereforadd) && $whereforadd != 'allmodules') {
1114
-				$sql .= " AND (".$whereforadd.")";	// Note: parenthesis are important because whereforadd can contains OR. Also note that $whereforadd is already sanitized
1114
+				$sql .= " AND (".$whereforadd.")"; // Note: parenthesis are important because whereforadd can contains OR. Also note that $whereforadd is already sanitized
1115 1115
 			}
1116 1116
 
1117 1117
 			$sqldelete = "DELETE FROM ".$this->db->prefix()."user_rights";
@@ -1247,7 +1247,7 @@  discard block
 block discarded – undo
1247 1247
 			$sql .= " FROM ".$this->db->prefix()."rights_def";
1248 1248
 			$sql .= " WHERE entity IN (".$this->db->sanitize($entity, 0, 0, 0, 0).")";
1249 1249
 			if (!empty($wherefordel) && $wherefordel != 'allmodules') {
1250
-				$sql .= " AND (".$wherefordel.")";	// Note: parenthesis are important because wherefordel can contains OR. Also note that $wherefordel is already sanitized
1250
+				$sql .= " AND (".$wherefordel.")"; // Note: parenthesis are important because wherefordel can contains OR. Also note that $wherefordel is already sanitized
1251 1251
 			}
1252 1252
 
1253 1253
 			// avoid admin to remove his own important rights
@@ -1426,12 +1426,12 @@  discard block
 block discarded – undo
1426 1426
 					$sql .= " AND r.entity = ".((int) $conf->entity);
1427 1427
 				}
1428 1428
 			} else {
1429
-				$sql .= " AND gr.entity = ".((int) $conf->entity);	// Only groups created in current entity
1429
+				$sql .= " AND gr.entity = ".((int) $conf->entity); // Only groups created in current entity
1430 1430
 				// The entity on the table gu=usergroup_user should be useless and should never be used because it is already into gr and r.
1431 1431
 				// but when using MULTICOMPANY_TRANSVERSE_MODE, we may have inserted record that make rubbish result here due to the duplicate record of
1432 1432
 				// other entities, so we are forced to add a filter on gu here
1433 1433
 				$sql .= " AND gu.entity IN (0,".$conf->entity.")";
1434
-				$sql .= " AND r.entity = ".((int) $conf->entity);	// Only permission of modules enabled in current entity
1434
+				$sql .= " AND r.entity = ".((int) $conf->entity); // Only permission of modules enabled in current entity
1435 1435
 			}
1436 1436
 			// End of strange business rule
1437 1437
 			$sql .= " AND gr.fk_usergroup = gu.fk_usergroup";
@@ -1984,7 +1984,7 @@  discard block
 block discarded – undo
1984 1984
 		$this->civility_code = $member->civility_code;
1985 1985
 		$this->lastname     = $member->lastname;
1986 1986
 		$this->firstname    = $member->firstname;
1987
-		$this->gender		= $member->gender;
1987
+		$this->gender = $member->gender;
1988 1988
 		$this->email        = $member->email;
1989 1989
 		$this->fk_member    = $member->id;
1990 1990
 		$this->address      = $member->address;
@@ -2127,45 +2127,45 @@  discard block
 block discarded – undo
2127 2127
 		$this->lastname						= trim((string) $this->lastname);
2128 2128
 		$this->firstname					= trim((string) $this->firstname);
2129 2129
 		$this->ref_employee					= trim((string) $this->ref_employee);
2130
-		$this->national_registration_number	= trim((string) $this->national_registration_number);
2130
+		$this->national_registration_number = trim((string) $this->national_registration_number);
2131 2131
 		$this->employee						= ($this->employee > 0 ? $this->employee : 0);
2132 2132
 		$this->login						= trim((string) $this->login);
2133
-		$this->gender						= trim((string) $this->gender);
2133
+		$this->gender = trim((string) $this->gender);
2134 2134
 
2135 2135
 		$this->pass							= trim((string) $this->pass);
2136
-		$this->api_key						= trim((string) $this->api_key);
2137
-		$this->datestartvalidity			= empty($this->datestartvalidity) ? '' : $this->datestartvalidity;
2138
-		$this->dateendvalidity				= empty($this->dateendvalidity) ? '' : $this->dateendvalidity;
2136
+		$this->api_key = trim((string) $this->api_key);
2137
+		$this->datestartvalidity = empty($this->datestartvalidity) ? '' : $this->datestartvalidity;
2138
+		$this->dateendvalidity = empty($this->dateendvalidity) ? '' : $this->dateendvalidity;
2139 2139
 
2140
-		$this->address						= trim((string) $this->address);
2141
-		$this->zip							= trim((string) $this->zip);
2142
-		$this->town							= trim((string) $this->town);
2140
+		$this->address = trim((string) $this->address);
2141
+		$this->zip = trim((string) $this->zip);
2142
+		$this->town = trim((string) $this->town);
2143 2143
 
2144
-		$this->state_id						= ($this->state_id > 0 ? $this->state_id : 0);
2144
+		$this->state_id = ($this->state_id > 0 ? $this->state_id : 0);
2145 2145
 		$this->country_id					= ($this->country_id > 0 ? $this->country_id : 0);
2146
-		$this->office_phone					= trim((string) $this->office_phone);
2146
+		$this->office_phone = trim((string) $this->office_phone);
2147 2147
 		$this->office_fax					= trim((string) $this->office_fax);
2148
-		$this->user_mobile					= trim((string) $this->user_mobile);
2149
-		$this->personal_mobile				= trim((string) $this->personal_mobile);
2150
-		$this->email						= trim((string) $this->email);
2151
-		$this->personal_email				= trim((string) $this->personal_email);
2152
-
2153
-		$this->job							= trim((string) $this->job);
2154
-		$this->signature					= trim((string) $this->signature);
2155
-		$this->note_public					= trim((string) $this->note_public);
2156
-		$this->note_private					= trim((string) $this->note_private);
2157
-		$this->openid						= trim((string) $this->openid);
2158
-		$this->admin						= ($this->admin > 0 ? $this->admin : 0);
2159
-
2160
-		$this->accountancy_code_user_general	= trim((string) $this->accountancy_code_user_general);
2148
+		$this->user_mobile = trim((string) $this->user_mobile);
2149
+		$this->personal_mobile = trim((string) $this->personal_mobile);
2150
+		$this->email = trim((string) $this->email);
2151
+		$this->personal_email = trim((string) $this->personal_email);
2152
+
2153
+		$this->job = trim((string) $this->job);
2154
+		$this->signature = trim((string) $this->signature);
2155
+		$this->note_public = trim((string) $this->note_public);
2156
+		$this->note_private = trim((string) $this->note_private);
2157
+		$this->openid = trim((string) $this->openid);
2158
+		$this->admin = ($this->admin > 0 ? $this->admin : 0);
2159
+
2160
+		$this->accountancy_code_user_general = trim((string) $this->accountancy_code_user_general);
2161 2161
 		$this->accountancy_code				= trim((string) $this->accountancy_code);
2162
-		$this->color						= trim((string) $this->color);
2163
-		$this->dateemployment				= empty($this->dateemployment) ? '' : $this->dateemployment;
2162
+		$this->color = trim((string) $this->color);
2163
+		$this->dateemployment = empty($this->dateemployment) ? '' : $this->dateemployment;
2164 2164
 		$this->dateemploymentend			= empty($this->dateemploymentend) ? '' : $this->dateemploymentend;
2165 2165
 
2166
-		$this->birth						= empty($this->birth) ? '' : $this->birth;
2167
-		$this->fk_warehouse					= (int) $this->fk_warehouse;
2168
-		$this->fk_establishment				= (int) $this->fk_establishment;
2166
+		$this->birth = empty($this->birth) ? '' : $this->birth;
2167
+		$this->fk_warehouse = (int) $this->fk_warehouse;
2168
+		$this->fk_establishment = (int) $this->fk_establishment;
2169 2169
 
2170 2170
 		$this->setUpperOrLowerCase();
2171 2171
 
@@ -2930,7 +2930,7 @@  discard block
 block discarded – undo
2930 2930
 		$sql .= " WHERE fk_user  = ".((int) $this->id);
2931 2931
 		$sql .= " AND fk_usergroup = ".((int) $group);
2932 2932
 		if (empty($entity)) {
2933
-			$sql .= " AND entity IN (0, 1)";	// group may be in entity 0 (so $entity=0) and link with user into entity 1.
2933
+			$sql .= " AND entity IN (0, 1)"; // group may be in entity 0 (so $entity=0) and link with user into entity 1.
2934 2934
 		} else {
2935 2935
 			$sql .= " AND entity = ".((int) $entity);
2936 2936
 		}
@@ -3191,7 +3191,7 @@  discard block
 block discarded – undo
3191 3191
 				$linkclose .= ' alt="'.dolPrintHTMLForAttribute($label).'"';
3192 3192
 			}
3193 3193
 			$linkclose .= ($label ? ' title="'.dolPrintHTMLForAttribute($label).'"' : ' title="tocomplete"');
3194
-			$linkclose .= $dataparams . ' class="'.$classfortooltip.($morecss ? ' '.$morecss : '').'"';
3194
+			$linkclose .= $dataparams.' class="'.$classfortooltip.($morecss ? ' '.$morecss : '').'"';
3195 3195
 		} else {
3196 3196
 			$linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
3197 3197
 		}
@@ -3430,11 +3430,11 @@  discard block
 block discarded – undo
3430 3430
 		global $conf;
3431 3431
 		$dn = '';
3432 3432
 		if ($mode == 0) {
3433
-			$dn = getDolGlobalString('LDAP_KEY_USERS') . "=".$info[getDolGlobalString('LDAP_KEY_USERS')]."," . getDolGlobalString('LDAP_USER_DN');
3433
+			$dn = getDolGlobalString('LDAP_KEY_USERS')."=".$info[getDolGlobalString('LDAP_KEY_USERS')].",".getDolGlobalString('LDAP_USER_DN');
3434 3434
 		} elseif ($mode == 1) {
3435 3435
 			$dn = getDolGlobalString('LDAP_USER_DN');
3436 3436
 		} elseif ($mode == 2) {
3437
-			$dn = getDolGlobalString('LDAP_KEY_USERS') . "=".$info[getDolGlobalString('LDAP_KEY_USERS')];
3437
+			$dn = getDolGlobalString('LDAP_KEY_USERS')."=".$info[getDolGlobalString('LDAP_KEY_USERS')];
3438 3438
 		}
3439 3439
 		return $dn;
3440 3440
 	}
@@ -3649,7 +3649,7 @@  discard block
 block discarded – undo
3649 3649
 		$this->iplastlogin = '127.0.0.1';
3650 3650
 		$this->datepreviouslogin = $now;
3651 3651
 		$this->ippreviouslogin = '127.0.0.1';
3652
-		$this->statut = 1;		// deprecated
3652
+		$this->statut = 1; // deprecated
3653 3653
 		$this->status = 1;
3654 3654
 
3655 3655
 		$this->entity = 1;
@@ -4242,8 +4242,8 @@  discard block
 block discarded – undo
4242 4242
 					$sql .= " WHERE t.entity IS NOT NULL"; // Show all users
4243 4243
 				} else {
4244 4244
 					$sql .= " WHERE t.entity = 0 OR EXISTS (";
4245
-					$sql .= " SELECT ug.rowid FROM " . $this->db->prefix() . "usergroup_user as ug";
4246
-					$sql .= " WHERE ug.fk_user = t.rowid AND ug.entity IN (" . getEntity('usergroup') . "))";
4245
+					$sql .= " SELECT ug.rowid FROM ".$this->db->prefix()."usergroup_user as ug";
4246
+					$sql .= " WHERE ug.fk_user = t.rowid AND ug.entity IN (".getEntity('usergroup')."))";
4247 4247
 				}
4248 4248
 			} else {
4249 4249
 				$sql .= " WHERE t.entity IN (".getEntity('user').")";
Please login to merge, or discard this patch.