Test Failed
Push — master ( ed0f4f...3aebc2 )
by Alxarafe
43:14
created
dolibarr/scripts/user/sync_groups_ldap2dolibarr.php 1 patch
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 
28 28
 $sapi_type = php_sapi_name();
29 29
 $script_file = basename(__FILE__);
30
-$path=dirname(__FILE__).'/';
30
+$path = dirname(__FILE__).'/';
31 31
 
32 32
 // Test if batch mode
33 33
 if (substr($sapi_type, 0, 3) == 'cgi') {
@@ -44,10 +44,10 @@  discard block
 block discarded – undo
44 44
 $langs->loadLangs(array("main", "errors"));
45 45
 
46 46
 // Global variables
47
-$version=DOL_VERSION;
48
-$error=0;
49
-$forcecommit=0;
50
-$confirmed=0;
47
+$version = DOL_VERSION;
48
+$error = 0;
49
+$forcecommit = 0;
50
+$confirmed = 0;
51 51
 
52 52
 
53 53
 /*
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 
57 57
 @set_time_limit(0);
58 58
 print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n";
59
-dol_syslog($script_file." launched with arg ".join(',',$argv));
59
+dol_syslog($script_file." launched with arg ".join(',', $argv));
60 60
 
61 61
 // List of fields to get from LDAP
62 62
 $required_fields = array(
@@ -67,31 +67,31 @@  discard block
 block discarded – undo
67 67
 );
68 68
 
69 69
 // Remove from required_fields all entries not configured in LDAP (empty) and duplicated
70
-$required_fields=array_unique(array_values(array_filter($required_fields, "dolValidElement")));
70
+$required_fields = array_unique(array_values(array_filter($required_fields, "dolValidElement")));
71 71
 
72 72
 
73
-if (! isset($argv[1])) {
73
+if (!isset($argv[1])) {
74 74
 	//print "Usage:  $script_file (nocommitiferror|commitiferror) [id_group]\n";
75 75
 	print "Usage:  $script_file (nocommitiferror|commitiferror) [--server=ldapserverhost] [--excludeuser=user1,user2...] [-y]\n";
76 76
 	exit(-1);
77 77
 }
78 78
 
79
-foreach($argv as $key => $val)
79
+foreach ($argv as $key => $val)
80 80
 {
81
-	if ($val == 'commitiferror') $forcecommit=1;
82
-	if (preg_match('/--server=([^\s]+)$/',$val,$reg)) $conf->global->LDAP_SERVER_HOST=$reg[1];
83
-	if (preg_match('/--excludeuser=([^\s]+)$/',$val,$reg)) $excludeuser=explode(',',$reg[1]);
84
-	if (preg_match('/-y$/',$val,$reg)) $confirmed=1;
81
+	if ($val == 'commitiferror') $forcecommit = 1;
82
+	if (preg_match('/--server=([^\s]+)$/', $val, $reg)) $conf->global->LDAP_SERVER_HOST = $reg[1];
83
+	if (preg_match('/--excludeuser=([^\s]+)$/', $val, $reg)) $excludeuser = explode(',', $reg[1]);
84
+	if (preg_match('/-y$/', $val, $reg)) $confirmed = 1;
85 85
 }
86 86
 
87 87
 print "Mails sending disabled (useless in batch mode)\n";
88
-$conf->global->MAIN_DISABLE_ALL_MAILS=1;	// On bloque les mails
88
+$conf->global->MAIN_DISABLE_ALL_MAILS = 1; // On bloque les mails
89 89
 print "\n";
90 90
 print "----- Synchronize all records from LDAP database:\n";
91 91
 print "host=".$conf->global->LDAP_SERVER_HOST."\n";
92 92
 print "port=".$conf->global->LDAP_SERVER_PORT."\n";
93 93
 print "login=".$conf->global->LDAP_ADMIN_DN."\n";
94
-print "pass=".preg_replace('/./i','*',$conf->global->LDAP_ADMIN_PASS)."\n";
94
+print "pass=".preg_replace('/./i', '*', $conf->global->LDAP_ADMIN_PASS)."\n";
95 95
 print "DN to extract=".$conf->global->LDAP_GROUP_DN."\n";
96 96
 print 'Filter=('.$conf->global->LDAP_KEY_GROUPS.'=*)'."\n";
97 97
 print "----- To Dolibarr database:\n";
@@ -102,10 +102,10 @@  discard block
 block discarded – undo
102 102
 print "database=".$conf->db->name."\n";
103 103
 print "----- Options:\n";
104 104
 print "commitiferror=".$forcecommit."\n";
105
-print "Mapped LDAP fields=".join(',',$required_fields)."\n";
105
+print "Mapped LDAP fields=".join(',', $required_fields)."\n";
106 106
 print "\n";
107 107
 
108
-if (! $confirmed)
108
+if (!$confirmed)
109 109
 {
110 110
 	print "Hit Enter to continue or CTRL+C to stop...\n";
111 111
 	$input = trim(fgets(STDIN));
@@ -122,13 +122,13 @@  discard block
 block discarded – undo
122 122
 $result = $ldap->connect_bind();
123 123
 if ($result >= 0)
124 124
 {
125
-	$justthese=array();
125
+	$justthese = array();
126 126
 
127 127
 
128 128
 	// We disable synchro Dolibarr-LDAP
129
-	$conf->global->LDAP_SYNCHRO_ACTIVE=0;
129
+	$conf->global->LDAP_SYNCHRO_ACTIVE = 0;
130 130
 
131
-	$ldaprecords = $ldap->getRecords('*',$conf->global->LDAP_GROUP_DN, $conf->global->LDAP_KEY_GROUPS, $required_fields, 0, array($conf->global->LDAP_GROUP_FIELD_GROUPMEMBERS));
131
+	$ldaprecords = $ldap->getRecords('*', $conf->global->LDAP_GROUP_DN, $conf->global->LDAP_KEY_GROUPS, $required_fields, 0, array($conf->global->LDAP_GROUP_FIELD_GROUPMEMBERS));
132 132
 	if (is_array($ldaprecords))
133 133
 	{
134 134
 		$db->begin();
@@ -139,15 +139,15 @@  discard block
 block discarded – undo
139 139
 			$group = new UserGroup($db);
140 140
 			$group->fetch('', $ldapgroup[$conf->global->LDAP_KEY_GROUPS]);
141 141
 			$group->name = $ldapgroup[$conf->global->LDAP_GROUP_FIELD_FULLNAME];
142
-			$group->nom = $group->name;		// For backward compatibility
142
+			$group->nom = $group->name; // For backward compatibility
143 143
 			$group->note = $ldapgroup[$conf->global->LDAP_GROUP_FIELD_DESCRIPTION];
144 144
 			$group->entity = $conf->entity;
145 145
 
146 146
 			//print_r($ldapgroup);
147 147
 
148
-			if($group->id > 0) { // Group update
148
+			if ($group->id > 0) { // Group update
149 149
 				print $langs->transnoentities("GroupUpdate").' # '.$key.': name='.$group->name;
150
-				$res=$group->update();
150
+				$res = $group->update();
151 151
 
152 152
 				if ($res > 0)
153 153
 				{
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 				print "\n";
162 162
 			} else { // Group creation
163 163
 				print $langs->transnoentities("GroupCreate").' # '.$key.': name='.$group->name;
164
-				$res=$group->create();
164
+				$res = $group->create();
165 165
 
166 166
 				if ($res > 0)
167 167
 				{
@@ -181,24 +181,24 @@  discard block
 block discarded – undo
181 181
 			// 1 - Association des utilisateurs du groupe LDAP au groupe Dolibarr
182 182
 			$userList = array();
183 183
 			$userIdList = array();
184
-			foreach($ldapgroup[$conf->global->LDAP_GROUP_FIELD_GROUPMEMBERS] as $key => $userdn) {
185
-				if($key === 'count') continue;
186
-				if(empty($userList[$userdn])) { // Récupération de l'utilisateur
184
+			foreach ($ldapgroup[$conf->global->LDAP_GROUP_FIELD_GROUPMEMBERS] as $key => $userdn) {
185
+				if ($key === 'count') continue;
186
+				if (empty($userList[$userdn])) { // Récupération de l'utilisateur
187 187
 					// Schéma rfc2307: les membres sont listés dans l'attribut memberUid sous form de login uniquement
188
-					if ($conf->global->LDAP_GROUP_FIELD_GROUPMEMBERS === 'memberUid'){
188
+					if ($conf->global->LDAP_GROUP_FIELD_GROUPMEMBERS === 'memberUid') {
189 189
 						$userKey = array($userdn);
190 190
 					} else { // Pour les autres schémas, les membres sont listés sous forme de DN complets
191 191
 						$userFilter = explode(',', $userdn);
192 192
 						$userKey = $ldap->getAttributeValues('('.$userFilter[0].')', $conf->global->LDAP_KEY_USERS);
193 193
 					}
194
-					if(!is_array($userKey)) continue;
194
+					if (!is_array($userKey)) continue;
195 195
 
196 196
 					$fuser = new User($db);
197 197
 
198
-					if($conf->global->LDAP_KEY_USERS == $conf->global->LDAP_FIELD_SID) {
199
-						$fuser->fetch('','',$userKey[0]); // Chargement du user concerné par le SID
200
-					} else if($conf->global->LDAP_KEY_USERS == $conf->global->LDAP_FIELD_LOGIN) {
201
-						$fuser->fetch('',$userKey[0]); // Chargement du user concerné par le login
198
+					if ($conf->global->LDAP_KEY_USERS == $conf->global->LDAP_FIELD_SID) {
199
+						$fuser->fetch('', '', $userKey[0]); // Chargement du user concerné par le SID
200
+					} else if ($conf->global->LDAP_KEY_USERS == $conf->global->LDAP_FIELD_LOGIN) {
201
+						$fuser->fetch('', $userKey[0]); // Chargement du user concerné par le login
202 202
 					}
203 203
 
204 204
 					$userList[$userdn] = $fuser;
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 				$userIdList[$userdn] = $fuser->id;
210 210
 
211 211
 				// Ajout de l'utilisateur dans le groupe
212
-				if(!in_array($fuser->id, array_keys($group->members))) {
212
+				if (!in_array($fuser->id, array_keys($group->members))) {
213 213
 					$fuser->SetInGroup($group->id, $group->entity);
214 214
 					echo $fuser->login.' added'."\n";
215 215
 				}
@@ -217,35 +217,35 @@  discard block
 block discarded – undo
217 217
 
218 218
 			// 2 - Suppression des utilisateurs du groupe Dolibarr qui ne sont plus dans le groupe LDAP
219 219
 			foreach ($group->members as $guser) {
220
-				if(!in_array($guser->id, $userIdList)) {
220
+				if (!in_array($guser->id, $userIdList)) {
221 221
 					$guser->RemoveFromGroup($group->id, $group->entity);
222 222
 					echo $guser->login.' removed'."\n";
223 223
 				}
224 224
 			}
225 225
 		}
226 226
 
227
-		if (! $error || $forcecommit)
227
+		if (!$error || $forcecommit)
228 228
 		{
229
-			if (! $error) print $langs->transnoentities("NoErrorCommitIsDone")."\n";
229
+			if (!$error) print $langs->transnoentities("NoErrorCommitIsDone")."\n";
230 230
 			else print $langs->transnoentities("ErrorButCommitIsDone")."\n";
231 231
 			$db->commit();
232 232
 		}
233 233
 		else
234 234
 		{
235
-			print $langs->transnoentities("ErrorSomeErrorWereFoundRollbackIsDone",$error)."\n";
235
+			print $langs->transnoentities("ErrorSomeErrorWereFoundRollbackIsDone", $error)."\n";
236 236
 			$db->rollback();
237 237
 		}
238 238
 		print "\n";
239 239
 	}
240 240
 	else
241 241
 	{
242
-		dol_print_error('',$ldap->error);
242
+		dol_print_error('', $ldap->error);
243 243
 		$error++;
244 244
 	}
245 245
 }
246 246
 else
247 247
 {
248
-	dol_print_error('',$ldap->error);
248
+	dol_print_error('', $ldap->error);
249 249
 	$error++;
250 250
 }
251 251
 
Please login to merge, or discard this patch.
dolibarr/scripts/members/sync_members_ldap2dolibarr.php 1 patch
Spacing   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 
27 27
 $sapi_type = php_sapi_name();
28 28
 $script_file = basename(__FILE__);
29
-$path=dirname(__FILE__).'/';
29
+$path = dirname(__FILE__).'/';
30 30
 
31 31
 // Test if batch mode
32 32
 if (substr($sapi_type, 0, 3) == 'cgi') {
@@ -43,10 +43,10 @@  discard block
 block discarded – undo
43 43
 $langs->loadLangs(array("main", "errors"));
44 44
 
45 45
 // Global variables
46
-$version=DOL_VERSION;
47
-$error=0;
48
-$forcecommit=0;
49
-$confirmed=0;
46
+$version = DOL_VERSION;
47
+$error = 0;
48
+$forcecommit = 0;
49
+$confirmed = 0;
50 50
 
51 51
 
52 52
 /*
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 
56 56
 @set_time_limit(0);
57 57
 print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n";
58
-dol_syslog($script_file." launched with arg ".join(',',$argv));
58
+dol_syslog($script_file." launched with arg ".join(',', $argv));
59 59
 
60 60
 // List of fields to get from LDAP
61 61
 $required_fields = array(
@@ -88,32 +88,32 @@  discard block
 block discarded – undo
88 88
 );
89 89
 
90 90
 // Remove from required_fields all entries not configured in LDAP (empty) and duplicated
91
-$required_fields=array_unique(array_values(array_filter($required_fields, "dolValidElement")));
91
+$required_fields = array_unique(array_values(array_filter($required_fields, "dolValidElement")));
92 92
 
93 93
 
94
-if (! isset($argv[2]) || ! is_numeric($argv[2])) {
94
+if (!isset($argv[2]) || !is_numeric($argv[2])) {
95 95
     print "Usage:  $script_file (nocommitiferror|commitiferror) id_member_type  [--server=ldapserverhost] [-y]\n";
96 96
 	exit(-1);
97 97
 }
98 98
 
99
-$typeid=$argv[2];
100
-foreach($argv as $key => $val)
99
+$typeid = $argv[2];
100
+foreach ($argv as $key => $val)
101 101
 {
102
-	if ($val == 'commitiferror') $forcecommit=1;
103
-	if (preg_match('/--server=([^\s]+)$/',$val,$reg)) $conf->global->LDAP_SERVER_HOST=$reg[1];
104
-	if (preg_match('/-y$/',$val,$reg)) $confirmed=1;
102
+	if ($val == 'commitiferror') $forcecommit = 1;
103
+	if (preg_match('/--server=([^\s]+)$/', $val, $reg)) $conf->global->LDAP_SERVER_HOST = $reg[1];
104
+	if (preg_match('/-y$/', $val, $reg)) $confirmed = 1;
105 105
 }
106 106
 
107 107
 print "Mails sending disabled (useless in batch mode)\n";
108
-$conf->global->MAIN_DISABLE_ALL_MAILS=1;	// On bloque les mails
108
+$conf->global->MAIN_DISABLE_ALL_MAILS = 1; // On bloque les mails
109 109
 print "\n";
110 110
 print "----- Synchronize all records from LDAP database:\n";
111 111
 print "host=".$conf->global->LDAP_SERVER_HOST."\n";
112 112
 print "port=".$conf->global->LDAP_SERVER_PORT."\n";
113 113
 print "login=".$conf->global->LDAP_ADMIN_DN."\n";
114
-print "pass=".preg_replace('/./i','*',$conf->global->LDAP_ADMIN_PASS)."\n";
114
+print "pass=".preg_replace('/./i', '*', $conf->global->LDAP_ADMIN_PASS)."\n";
115 115
 print "DN to extract=".$conf->global->LDAP_MEMBER_DN."\n";
116
-if (! empty($conf->global->LDAP_MEMBER_FILTER)) print 'Filter=('.$conf->global->LDAP_MEMBER_FILTER.')'."\n";	// Note: filter is defined into function getRecords
116
+if (!empty($conf->global->LDAP_MEMBER_FILTER)) print 'Filter=('.$conf->global->LDAP_MEMBER_FILTER.')'."\n"; // Note: filter is defined into function getRecords
117 117
 else print 'Filter=('.$conf->global->LDAP_KEY_MEMBERS.'=*)'."\n";
118 118
 print "----- To Dolibarr database:\n";
119 119
 print "type=".$conf->db->type."\n";
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 print "database=".$conf->db->name."\n";
124 124
 print "----- Options:\n";
125 125
 print "commitiferror=".$forcecommit."\n";
126
-print "Mapped LDAP fields=".join(',',$required_fields)."\n";
126
+print "Mapped LDAP fields=".join(',', $required_fields)."\n";
127 127
 print "\n";
128 128
 
129 129
 // Check parameters
@@ -139,20 +139,20 @@  discard block
 block discarded – undo
139 139
 }
140 140
 
141 141
 
142
-if (! $confirmed)
142
+if (!$confirmed)
143 143
 {
144 144
 	print "Hit Enter to continue or CTRL+C to stop...\n";
145 145
 	$input = trim(fgets(STDIN));
146 146
 }
147 147
 
148 148
 // Load table of correspondence of countries
149
-$hashlib2rowid=array();
150
-$countries=array();
149
+$hashlib2rowid = array();
150
+$countries = array();
151 151
 $sql = "SELECT rowid, code, label, active";
152
-$sql.= " FROM ".MAIN_DB_PREFIX."c_country";
153
-$sql.= " WHERE active = 1";
154
-$sql.= " ORDER BY code ASC";
155
-$resql=$db->query($sql);
152
+$sql .= " FROM ".MAIN_DB_PREFIX."c_country";
153
+$sql .= " WHERE active = 1";
154
+$sql .= " ORDER BY code ASC";
155
+$resql = $db->query($sql);
156 156
 if ($resql)
157 157
 {
158 158
 	$num = $db->num_rows($resql);
@@ -165,8 +165,8 @@  discard block
 block discarded – undo
165 165
 			if ($obj)
166 166
 			{
167 167
 				//print 'Load cache for country '.strtolower($obj->label).' rowid='.$obj->rowid."\n";
168
-				$hashlib2rowid[strtolower($obj->label)]=$obj->rowid;
169
-				$countries[$obj->rowid]=array('rowid' => $obj->rowid, 'label' => $obj->label, 'code' => $obj->code);
168
+				$hashlib2rowid[strtolower($obj->label)] = $obj->rowid;
169
+				$countries[$obj->rowid] = array('rowid' => $obj->rowid, 'label' => $obj->label, 'code' => $obj->code);
170 170
 			}
171 171
 			$i++;
172 172
 		}
@@ -184,13 +184,13 @@  discard block
 block discarded – undo
184 184
 $result = $ldap->connect_bind();
185 185
 if ($result >= 0)
186 186
 {
187
-	$justthese=array();
187
+	$justthese = array();
188 188
 
189 189
 
190 190
 	// We disable synchro Dolibarr-LDAP
191
-	$conf->global->LDAP_MEMBER_ACTIVE=0;
191
+	$conf->global->LDAP_MEMBER_ACTIVE = 0;
192 192
 
193
-	$ldaprecords = $ldap->getRecords('*',$conf->global->LDAP_MEMBER_DN, $conf->global->LDAP_KEY_MEMBERS, $required_fields, 'member');	// Fiter on 'member' filter param
193
+	$ldaprecords = $ldap->getRecords('*', $conf->global->LDAP_MEMBER_DN, $conf->global->LDAP_KEY_MEMBERS, $required_fields, 'member'); // Fiter on 'member' filter param
194 194
 	if (is_array($ldaprecords))
195 195
 	{
196 196
 		$db->begin();
@@ -201,48 +201,48 @@  discard block
 block discarded – undo
201 201
 			$member = new Adherent($db);
202 202
 
203 203
 			// Propriete membre
204
-			$member->firstname=$ldapuser[$conf->global->LDAP_FIELD_FIRSTNAME];
205
-			$member->lastname=$ldapuser[$conf->global->LDAP_FIELD_NAME];
206
-			$member->login=$ldapuser[$conf->global->LDAP_FIELD_LOGIN];
207
-			$member->pass=$ldapuser[$conf->global->LDAP_FIELD_PASSWORD];
204
+			$member->firstname = $ldapuser[$conf->global->LDAP_FIELD_FIRSTNAME];
205
+			$member->lastname = $ldapuser[$conf->global->LDAP_FIELD_NAME];
206
+			$member->login = $ldapuser[$conf->global->LDAP_FIELD_LOGIN];
207
+			$member->pass = $ldapuser[$conf->global->LDAP_FIELD_PASSWORD];
208 208
 
209 209
 			//$member->societe;
210
-			$member->address=$ldapuser[$conf->global->LDAP_FIELD_ADDRESS];
211
-			$member->zip=$ldapuser[$conf->global->LDAP_FIELD_ZIP];
212
-			$member->town=$ldapuser[$conf->global->LDAP_FIELD_TOWN];
213
-			$member->country=$ldapuser[$conf->global->LDAP_FIELD_COUNTRY];
214
-			$member->country_id=$countries[$hashlib2rowid[strtolower($member->country)]]['rowid'];
215
-			$member->country_code=$countries[$hashlib2rowid[strtolower($member->country)]]['code'];
216
-
217
-			$member->phone=$ldapuser[$conf->global->LDAP_FIELD_PHONE];
218
-			$member->phone_perso=$ldapuser[$conf->global->LDAP_FIELD_PHONE_PERSO];
219
-			$member->phone_mobile=$ldapuser[$conf->global->LDAP_FIELD_MOBILE];
220
-			$member->email=$ldapuser[$conf->global->LDAP_FIELD_MAIL];
221
-
222
-			$member->note=$ldapuser[$conf->global->LDAP_FIELD_DESCRIPTION];
223
-			$member->morphy='phy';
224
-			$member->photo='';
225
-			$member->public=1;
226
-			$member->birth=dol_stringtotime($ldapuser[$conf->global->LDAP_FIELD_BIRTHDATE]);
227
-
228
-			$member->statut=-1;
210
+			$member->address = $ldapuser[$conf->global->LDAP_FIELD_ADDRESS];
211
+			$member->zip = $ldapuser[$conf->global->LDAP_FIELD_ZIP];
212
+			$member->town = $ldapuser[$conf->global->LDAP_FIELD_TOWN];
213
+			$member->country = $ldapuser[$conf->global->LDAP_FIELD_COUNTRY];
214
+			$member->country_id = $countries[$hashlib2rowid[strtolower($member->country)]]['rowid'];
215
+			$member->country_code = $countries[$hashlib2rowid[strtolower($member->country)]]['code'];
216
+
217
+			$member->phone = $ldapuser[$conf->global->LDAP_FIELD_PHONE];
218
+			$member->phone_perso = $ldapuser[$conf->global->LDAP_FIELD_PHONE_PERSO];
219
+			$member->phone_mobile = $ldapuser[$conf->global->LDAP_FIELD_MOBILE];
220
+			$member->email = $ldapuser[$conf->global->LDAP_FIELD_MAIL];
221
+
222
+			$member->note = $ldapuser[$conf->global->LDAP_FIELD_DESCRIPTION];
223
+			$member->morphy = 'phy';
224
+			$member->photo = '';
225
+			$member->public = 1;
226
+			$member->birth = dol_stringtotime($ldapuser[$conf->global->LDAP_FIELD_BIRTHDATE]);
227
+
228
+			$member->statut = -1;
229 229
 			if (isset($ldapuser[$conf->global->LDAP_FIELD_MEMBER_STATUS]))
230 230
 			{
231
-				$member->datec=dol_stringtotime($ldapuser[$conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE]);
232
-				$member->datevalid=dol_stringtotime($ldapuser[$conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE]);
233
-				$member->statut=$ldapuser[$conf->global->LDAP_FIELD_MEMBER_STATUS];
231
+				$member->datec = dol_stringtotime($ldapuser[$conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE]);
232
+				$member->datevalid = dol_stringtotime($ldapuser[$conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE]);
233
+				$member->statut = $ldapuser[$conf->global->LDAP_FIELD_MEMBER_STATUS];
234 234
 			}
235 235
 			//if ($member->statut > 1) $member->statut=1;
236 236
 
237 237
 			//print_r($ldapuser);
238 238
 
239 239
 			// Propriete type membre
240
-			$member->typeid=$typeid;
240
+			$member->typeid = $typeid;
241 241
 
242 242
 			// Creation membre
243 243
 			print $langs->transnoentities("MemberCreate").' # '.$key.': login='.$member->login.', fullname='.$member->getFullName($langs);
244 244
 			print ', datec='.$member->datec;
245
-			$member_id=$member->create($user);
245
+			$member_id = $member->create($user);
246 246
 			if ($member_id > 0)
247 247
 			{
248 248
 				print ' --> Created member id='.$member_id.' login='.$member->login;
@@ -256,30 +256,30 @@  discard block
 block discarded – undo
256 256
 
257 257
 			//print_r($member);
258 258
 
259
-			$datefirst='';
259
+			$datefirst = '';
260 260
 			if ($conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE)
261 261
 			{
262
-				$datefirst=dol_stringtotime($ldapuser[$conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE]);
263
-				$pricefirst=price2num($ldapuser[$conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT]);
262
+				$datefirst = dol_stringtotime($ldapuser[$conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE]);
263
+				$pricefirst = price2num($ldapuser[$conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT]);
264 264
 			}
265 265
 
266
-			$datelast='';
266
+			$datelast = '';
267 267
 			if ($conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE)
268 268
 			{
269
-				$datelast=dol_stringtotime($ldapuser[$conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE]);
270
-				$pricelast=price2num($ldapuser[$conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT]);
269
+				$datelast = dol_stringtotime($ldapuser[$conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE]);
270
+				$pricelast = price2num($ldapuser[$conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT]);
271 271
 			}
272 272
 			elseif ($conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION)
273 273
 			{
274
-				$datelast=dol_time_plus_duree(dol_stringtotime($ldapuser[$conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION]),-1,'y')+60*60*24;
275
-				$pricelast=price2num($ldapuser[$conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT]);
274
+				$datelast = dol_time_plus_duree(dol_stringtotime($ldapuser[$conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION]), -1, 'y') + 60 * 60 * 24;
275
+				$pricelast = price2num($ldapuser[$conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT]);
276 276
 
277 277
 				// Cas special ou date derniere <= date premiere
278 278
 				if ($datefirst && $datelast && $datelast <= $datefirst)
279 279
 				{
280 280
 					// On ne va inserer que la premiere
281
-					$datelast=0;
282
-					if (! $pricefirst && $pricelast) $pricefirst = $pricelast;
281
+					$datelast = 0;
282
+					if (!$pricefirst && $pricelast) $pricefirst = $pricelast;
283 283
 				}
284 284
 			}
285 285
 
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 			{
290 290
 				// Cree premiere cotisation et met a jour datefin dans adherent
291 291
 				//print "xx".$datefirst."\n";
292
-				$crowid=$member->subscription($datefirst, $pricefirst, 0);
292
+				$crowid = $member->subscription($datefirst, $pricefirst, 0);
293 293
 			}
294 294
 
295 295
 			// Insert last subscription
@@ -297,32 +297,32 @@  discard block
 block discarded – undo
297 297
 			{
298 298
 				// Cree derniere cotisation et met a jour datefin dans adherent
299 299
 				//print "yy".dol_print_date($datelast)."\n";
300
-				$crowid=$member->subscription($datelast, $pricelast, 0);
300
+				$crowid = $member->subscription($datelast, $pricelast, 0);
301 301
 			}
302 302
 		}
303 303
 
304
-		if (! $error || $forcecommit)
304
+		if (!$error || $forcecommit)
305 305
 		{
306
-			if (! $error) print $langs->transnoentities("NoErrorCommitIsDone")."\n";
306
+			if (!$error) print $langs->transnoentities("NoErrorCommitIsDone")."\n";
307 307
 			else print $langs->transnoentities("ErrorButCommitIsDone")."\n";
308 308
 			$db->commit();
309 309
 		}
310 310
 		else
311 311
 		{
312
-			print $langs->transnoentities("ErrorSomeErrorWereFoundRollbackIsDone",$error)."\n";
312
+			print $langs->transnoentities("ErrorSomeErrorWereFoundRollbackIsDone", $error)."\n";
313 313
 			$db->rollback();
314 314
 		}
315 315
 		print "\n";
316 316
 	}
317 317
 	else
318 318
 	{
319
-		dol_print_error('',$ldap->error);
319
+		dol_print_error('', $ldap->error);
320 320
 		$error++;
321 321
 	}
322 322
 }
323 323
 else
324 324
 {
325
-	dol_print_error('',$ldap->error);
325
+	dol_print_error('', $ldap->error);
326 326
 	$error++;
327 327
 }
328 328
 
Please login to merge, or discard this patch.
dolibarr/scripts/members/sync_members_dolibarr2ldap.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 
27 27
 $sapi_type = php_sapi_name();
28 28
 $script_file = basename(__FILE__);
29
-$path=dirname(__FILE__).'/';
29
+$path = dirname(__FILE__).'/';
30 30
 
31 31
 // Test if batch mode
32 32
 if (substr($sapi_type, 0, 3) == 'cgi') {
@@ -41,9 +41,9 @@  discard block
 block discarded – undo
41 41
 $langs->load("main");
42 42
 
43 43
 // Global variables
44
-$version=DOL_VERSION;
45
-$error=0;
46
-$confirmed=0;
44
+$version = DOL_VERSION;
45
+$error = 0;
46
+$confirmed = 0;
47 47
 
48 48
 
49 49
 /*
@@ -52,22 +52,22 @@  discard block
 block discarded – undo
52 52
 
53 53
 @set_time_limit(0);
54 54
 print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n";
55
-dol_syslog($script_file." launched with arg ".join(',',$argv));
55
+dol_syslog($script_file." launched with arg ".join(',', $argv));
56 56
 
57
-if (! isset($argv[1]) || ! $argv[1]) {
57
+if (!isset($argv[1]) || !$argv[1]) {
58 58
     print "Usage: $script_file now [-y]\n";
59 59
 	exit(-1);
60 60
 }
61 61
 
62
-foreach($argv as $key => $val)
62
+foreach ($argv as $key => $val)
63 63
 {
64
-	if (preg_match('/-y$/',$val,$reg)) $confirmed=1;
64
+	if (preg_match('/-y$/', $val, $reg)) $confirmed = 1;
65 65
 }
66 66
 
67
-$now=$argv[1];
67
+$now = $argv[1];
68 68
 
69 69
 print "Mails sending disabled (useless in batch mode)\n";
70
-$conf->global->MAIN_DISABLE_ALL_MAILS=1;	// On bloque les mails
70
+$conf->global->MAIN_DISABLE_ALL_MAILS = 1; // On bloque les mails
71 71
 print "\n";
72 72
 print "----- Synchronize all records from Dolibarr database:\n";
73 73
 print "type=".$conf->db->type."\n";
@@ -81,11 +81,11 @@  discard block
 block discarded – undo
81 81
 print "host=".$conf->global->LDAP_SERVER_HOST."\n";
82 82
 print "port=".$conf->global->LDAP_SERVER_PORT."\n";
83 83
 print "login=".$conf->global->LDAP_ADMIN_DN."\n";
84
-print "pass=".preg_replace('/./i','*',$conf->global->LDAP_ADMIN_PASS)."\n";
84
+print "pass=".preg_replace('/./i', '*', $conf->global->LDAP_ADMIN_PASS)."\n";
85 85
 print "DN target=".$conf->global->LDAP_MEMBER_DN."\n";
86 86
 print "\n";
87 87
 
88
-if (! $confirmed)
88
+if (!$confirmed)
89 89
 {
90 90
 	print "Press a key to confirm...\n";
91 91
 	$input = trim(fgets(STDIN));
@@ -112,41 +112,41 @@  discard block
 block discarded – undo
112 112
 	$num = $db->num_rows($resql);
113 113
 	$i = 0;
114 114
 
115
-	$ldap=new Ldap();
115
+	$ldap = new Ldap();
116 116
 	$ldap->connect_bind();
117 117
 
118 118
 	while ($i < $num)
119 119
 	{
120
-		$ldap->error="";
120
+		$ldap->error = "";
121 121
 
122 122
 		$obj = $db->fetch_object($resql);
123 123
 
124 124
 		$member = new Adherent($db);
125
-		$result=$member->fetch($obj->rowid);
125
+		$result = $member->fetch($obj->rowid);
126 126
 		if ($result < 0)
127 127
 		{
128
-			dol_print_error($db,$member->error);
128
+			dol_print_error($db, $member->error);
129 129
 			exit(-1);
130 130
 		}
131
-		$result=$member->fetch_subscriptions();
131
+		$result = $member->fetch_subscriptions();
132 132
 		if ($result < 0)
133 133
 		{
134
-			dol_print_error($db,$member->error);
134
+			dol_print_error($db, $member->error);
135 135
 			exit(-1);
136 136
 		}
137 137
 
138 138
 		print $langs->transnoentities("UpdateMember")." rowid=".$member->id." ".$member->getFullName($langs);
139 139
 
140
-		$oldobject=$member;
140
+		$oldobject = $member;
141 141
 
142
-	    $oldinfo=$oldobject->_load_ldap_info();
143
-	    $olddn=$oldobject->_load_ldap_dn($oldinfo);
142
+	    $oldinfo = $oldobject->_load_ldap_info();
143
+	    $olddn = $oldobject->_load_ldap_dn($oldinfo);
144 144
 
145
-	    $info=$member->_load_ldap_info();
146
-		$dn=$member->_load_ldap_dn($info);
145
+	    $info = $member->_load_ldap_info();
146
+		$dn = $member->_load_ldap_dn($info);
147 147
 
148
-		$result=$ldap->add($dn,$info,$user);	// Wil fail if already exists
149
-		$result=$ldap->update($dn,$info,$user,$olddn);
148
+		$result = $ldap->add($dn, $info, $user); // Wil fail if already exists
149
+		$result = $ldap->update($dn, $info, $user, $olddn);
150 150
 		if ($result > 0)
151 151
 		{
152 152
 			print " - ".$langs->transnoentities("OK");
Please login to merge, or discard this patch.
dolibarr/scripts/members/sync_members_types_dolibarr2ldap.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 
28 28
 $sapi_type = php_sapi_name();
29 29
 $script_file = basename(__FILE__);
30
-$path=dirname(__FILE__).'/';
30
+$path = dirname(__FILE__).'/';
31 31
 
32 32
 // Test if batch mode
33 33
 if (substr($sapi_type, 0, 3) == 'cgi') {
@@ -35,19 +35,19 @@  discard block
 block discarded – undo
35 35
 	exit(-1);
36 36
 }
37 37
 
38
-if (! isset($argv[1]) || ! $argv[1]) {
38
+if (!isset($argv[1]) || !$argv[1]) {
39 39
     print "Usage: ".$script_file." now\n";
40 40
 	exit(-1);
41 41
 }
42
-$now=$argv[1];
42
+$now = $argv[1];
43 43
 
44 44
 require_once $path."../../htdocs/master.inc.php";
45 45
 require_once DOL_DOCUMENT_ROOT."/core/class/ldap.class.php";
46 46
 require_once DOL_DOCUMENT_ROOT."/adherents/class/adherent_type.class.php";
47 47
 
48 48
 // Global variables
49
-$version=DOL_VERSION;
50
-$error=0;
49
+$version = DOL_VERSION;
50
+$error = 0;
51 51
 
52 52
 
53 53
 /*
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 
57 57
 @set_time_limit(0);
58 58
 print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n";
59
-dol_syslog($script_file." launched with arg ".join(',',$argv));
59
+dol_syslog($script_file." launched with arg ".join(',', $argv));
60 60
 
61 61
 /*
62 62
 if (! $conf->global->LDAP_SYNCHRO_ACTIVE)
@@ -75,14 +75,14 @@  discard block
 block discarded – undo
75 75
 	$num = $db->num_rows($resql);
76 76
 	$i = 0;
77 77
 
78
-	$ldap=new Ldap();
79
-	$result=$ldap->connect_bind();
78
+	$ldap = new Ldap();
79
+	$result = $ldap->connect_bind();
80 80
 
81 81
 	if ($result > 0)
82 82
 	{
83 83
 		while ($i < $num)
84 84
 		{
85
-			$ldap->error="";
85
+			$ldap->error = "";
86 86
 
87 87
 			$obj = $db->fetch_object($resql);
88 88
 
@@ -90,18 +90,18 @@  discard block
 block discarded – undo
90 90
 			$membertype->id = $obj->rowid;
91 91
 			$membertype->fetch($membertype->id);
92 92
 
93
-			print $langs->trans("UpdateMemberType")." rowid=".$membertype->id." ".$membertype-label;
93
+			print $langs->trans("UpdateMemberType")." rowid=".$membertype->id." ".$membertype - label;
94 94
 
95
-			$oldobject=$membertype;
95
+			$oldobject = $membertype;
96 96
 
97
-			$oldinfo=$membertype->_load_ldap_info();
98
-			$olddn=$membertype->_load_ldap_dn($oldinfo);
97
+			$oldinfo = $membertype->_load_ldap_info();
98
+			$olddn = $membertype->_load_ldap_dn($oldinfo);
99 99
 
100
-			$info=$membertype->_load_ldap_info();
101
-			$dn=$membertype->_load_ldap_dn($info);
100
+			$info = $membertype->_load_ldap_info();
101
+			$dn = $membertype->_load_ldap_dn($info);
102 102
 
103
-			$result=$ldap->add($dn,$info,$user);	// Wil fail if already exists
104
-			$result=$ldap->update($dn,$info,$user,$olddn);
103
+			$result = $ldap->add($dn, $info, $user); // Wil fail if already exists
104
+			$result = $ldap->update($dn, $info, $user, $olddn);
105 105
 			if ($result > 0)
106 106
 			{
107 107
 				print " - ".$langs->trans("OK");
Please login to merge, or discard this patch.
dolibarr/scripts/members/sync_members_types_ldap2dolibarr.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 
29 29
 $sapi_type = php_sapi_name();
30 30
 $script_file = basename(__FILE__);
31
-$path=dirname(__FILE__).'/';
31
+$path = dirname(__FILE__).'/';
32 32
 
33 33
 // Test if batch mode
34 34
 if (substr($sapi_type, 0, 3) == 'cgi') {
@@ -44,10 +44,10 @@  discard block
 block discarded – undo
44 44
 $langs->loadLangs(array("main", "errors"));
45 45
 
46 46
 // Global variables
47
-$version=DOL_VERSION;
48
-$error=0;
49
-$forcecommit=0;
50
-$confirmed=0;
47
+$version = DOL_VERSION;
48
+$error = 0;
49
+$forcecommit = 0;
50
+$confirmed = 0;
51 51
 
52 52
 
53 53
 /*
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 
57 57
 @set_time_limit(0);
58 58
 print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n";
59
-dol_syslog($script_file." launched with arg ".join(',',$argv));
59
+dol_syslog($script_file." launched with arg ".join(',', $argv));
60 60
 
61 61
 // List of fields to get from LDAP
62 62
 $required_fields = array(
@@ -67,31 +67,31 @@  discard block
 block discarded – undo
67 67
 );
68 68
 
69 69
 // Remove from required_fields all entries not configured in LDAP (empty) and duplicated
70
-$required_fields=array_unique(array_values(array_filter($required_fields, "dolValidElementType")));
70
+$required_fields = array_unique(array_values(array_filter($required_fields, "dolValidElementType")));
71 71
 
72 72
 
73
-if (! isset($argv[1])) {
73
+if (!isset($argv[1])) {
74 74
 	//print "Usage:  $script_file (nocommitiferror|commitiferror) [id_group]\n";
75 75
 	print "Usage:  $script_file (nocommitiferror|commitiferror) [--server=ldapserverhost] [--excludeuser=user1,user2...] [-y]\n";
76 76
 	exit(-1);
77 77
 }
78 78
 
79
-foreach($argv as $key => $val)
79
+foreach ($argv as $key => $val)
80 80
 {
81
-	if ($val == 'commitiferror') $forcecommit=1;
82
-	if (preg_match('/--server=([^\s]+)$/',$val,$reg)) $conf->global->LDAP_SERVER_HOST=$reg[1];
83
-	if (preg_match('/--excludeuser=([^\s]+)$/',$val,$reg)) $excludeuser=explode(',',$reg[1]);
84
-	if (preg_match('/-y$/',$val,$reg)) $confirmed=1;
81
+	if ($val == 'commitiferror') $forcecommit = 1;
82
+	if (preg_match('/--server=([^\s]+)$/', $val, $reg)) $conf->global->LDAP_SERVER_HOST = $reg[1];
83
+	if (preg_match('/--excludeuser=([^\s]+)$/', $val, $reg)) $excludeuser = explode(',', $reg[1]);
84
+	if (preg_match('/-y$/', $val, $reg)) $confirmed = 1;
85 85
 }
86 86
 
87 87
 print "Mails sending disabled (useless in batch mode)\n";
88
-$conf->global->MAIN_DISABLE_ALL_MAILS=1;	// On bloque les mails
88
+$conf->global->MAIN_DISABLE_ALL_MAILS = 1; // On bloque les mails
89 89
 print "\n";
90 90
 print "----- Synchronize all records from LDAP database:\n";
91 91
 print "host=".$conf->global->LDAP_SERVER_HOST."\n";
92 92
 print "port=".$conf->global->LDAP_SERVER_PORT."\n";
93 93
 print "login=".$conf->global->LDAP_ADMIN_DN."\n";
94
-print "pass=".preg_replace('/./i','*',$conf->global->LDAP_ADMIN_PASS)."\n";
94
+print "pass=".preg_replace('/./i', '*', $conf->global->LDAP_ADMIN_PASS)."\n";
95 95
 print "DN to extract=".$conf->global->LDAP_MEMBER_TYPE_DN."\n";
96 96
 print 'Filter=('.$conf->global->LDAP_KEY_MEMBERS_TYPES.'=*)'."\n";
97 97
 print "----- To Dolibarr database:\n";
@@ -102,10 +102,10 @@  discard block
 block discarded – undo
102 102
 print "database=".$conf->db->name."\n";
103 103
 print "----- Options:\n";
104 104
 print "commitiferror=".$forcecommit."\n";
105
-print "Mapped LDAP fields=".join(',',$required_fields)."\n";
105
+print "Mapped LDAP fields=".join(',', $required_fields)."\n";
106 106
 print "\n";
107 107
 
108
-if (! $confirmed)
108
+if (!$confirmed)
109 109
 {
110 110
 	print "Hit Enter to continue or CTRL+C to stop...\n";
111 111
 	$input = trim(fgets(STDIN));
@@ -122,13 +122,13 @@  discard block
 block discarded – undo
122 122
 $result = $ldap->connect_bind();
123 123
 if ($result >= 0)
124 124
 {
125
-	$justthese=array();
125
+	$justthese = array();
126 126
 
127 127
 
128 128
 	// We disable synchro Dolibarr-LDAP
129
-	$conf->global->LDAP_MEMBER_TYPE_ACTIVE=0;
129
+	$conf->global->LDAP_MEMBER_TYPE_ACTIVE = 0;
130 130
 
131
-	$ldaprecords = $ldap->getRecords('*',$conf->global->LDAP_MEMBER_TYPE_DN, $conf->global->LDAP_KEY_MEMBERS_TYPES, $required_fields, 0, array($conf->global->LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS));
131
+	$ldaprecords = $ldap->getRecords('*', $conf->global->LDAP_MEMBER_TYPE_DN, $conf->global->LDAP_KEY_MEMBERS_TYPES, $required_fields, 0, array($conf->global->LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS));
132 132
 	if (is_array($ldaprecords))
133 133
 	{
134 134
 		$db->begin();
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 
147 147
 			if ($membertype->id > 0) { // Member type update
148 148
 				print $langs->transnoentities("MemberTypeUpdate").' # '.$key.': name='.$membertype->label;
149
-				$res=$membertype->update($user);
149
+				$res = $membertype->update($user);
150 150
 
151 151
 				if ($res > 0)
152 152
 				{
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 				print "\n";
161 161
 			} else { // Member type creation
162 162
 				print $langs->transnoentities("MemberTypeCreate").' # '.$key.': name='.$membertype->label;
163
-				$res=$membertype->create($user);
163
+				$res = $membertype->create($user);
164 164
 
165 165
 				if ($res > 0)
166 166
 				{
@@ -177,28 +177,28 @@  discard block
 block discarded – undo
177 177
 			//print_r($membertype);
178 178
 		}
179 179
 
180
-		if (! $error || $forcecommit)
180
+		if (!$error || $forcecommit)
181 181
 		{
182
-			if (! $error) print $langs->transnoentities("NoErrorCommitIsDone")."\n";
182
+			if (!$error) print $langs->transnoentities("NoErrorCommitIsDone")."\n";
183 183
 			else print $langs->transnoentities("ErrorButCommitIsDone")."\n";
184 184
 			$db->commit();
185 185
 		}
186 186
 		else
187 187
 		{
188
-			print $langs->transnoentities("ErrorSomeErrorWereFoundRollbackIsDone",$error)."\n";
188
+			print $langs->transnoentities("ErrorSomeErrorWereFoundRollbackIsDone", $error)."\n";
189 189
 			$db->rollback();
190 190
 		}
191 191
 		print "\n";
192 192
 	}
193 193
 	else
194 194
 	{
195
-		dol_print_error('',$ldap->error);
195
+		dol_print_error('', $ldap->error);
196 196
 		$error++;
197 197
 	}
198 198
 }
199 199
 else
200 200
 {
201
-	dol_print_error('',$ldap->error);
201
+	dol_print_error('', $ldap->error);
202 202
 	$error++;
203 203
 }
204 204
 
Please login to merge, or discard this patch.
dolibarr/scripts/product/migrate_picture_path.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 
26 26
 $sapi_type = php_sapi_name();
27 27
 $script_file = basename(__FILE__);
28
-$path=dirname(__FILE__).'/';
28
+$path = dirname(__FILE__).'/';
29 29
 
30 30
 // Test if batch mode
31 31
 if (substr($sapi_type, 0, 3) == 'cgi') {
@@ -33,8 +33,8 @@  discard block
 block discarded – undo
33 33
 	exit(-1);
34 34
 }
35 35
 
36
-@set_time_limit(0);							// No timeout for this script
37
-define('EVEN_IF_ONLY_LOGIN_ALLOWED',1);		// Set this define to 0 if you want to lock your script when dolibarr setup is "locked to admin user only".
36
+@set_time_limit(0); // No timeout for this script
37
+define('EVEN_IF_ONLY_LOGIN_ALLOWED', 1); // Set this define to 0 if you want to lock your script when dolibarr setup is "locked to admin user only".
38 38
 
39 39
 // Include and load Dolibarr environment variables
40 40
 require_once $path."../../htdocs/master.inc.php";
@@ -44,19 +44,19 @@  discard block
 block discarded – undo
44 44
 // $user is created but empty.
45 45
 
46 46
 //$langs->setDefaultLang('en_US'); 	// To change default language of $langs
47
-$langs->load("main");				// To load language file for default language
47
+$langs->load("main"); // To load language file for default language
48 48
 
49 49
 
50 50
 // Global variables
51
-$version=DOL_VERSION;
52
-$error=0;
53
-$forcecommit=0;
51
+$version = DOL_VERSION;
52
+$error = 0;
53
+$forcecommit = 0;
54 54
 
55 55
 
56 56
 print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n";
57
-dol_syslog($script_file." launched with arg ".join(',',$argv));
57
+dol_syslog($script_file." launched with arg ".join(',', $argv));
58 58
 
59
-if (! isset($argv[1]) || $argv[1] != 'product') {
59
+if (!isset($argv[1]) || $argv[1] != 'product') {
60 60
     print "Usage:  $script_file product\n";
61 61
 	exit(-1);
62 62
 }
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 {
69 69
 	$product = new Product($db);
70 70
 
71
-	$sql = "SELECT rowid as pid from ".MAIN_DB_PREFIX."product";	// Get list of all products
71
+	$sql = "SELECT rowid as pid from ".MAIN_DB_PREFIX."product"; // Get list of all products
72 72
 	$resql = $db->query($sql);
73 73
 	if ($resql)
74 74
 	{
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 }
88 88
 
89 89
 
90
-$db->close();	// Close $db database opened handler
90
+$db->close(); // Close $db database opened handler
91 91
 
92 92
 exit($error);
93 93
 
@@ -105,18 +105,18 @@  discard block
 block discarded – undo
105 105
 
106 106
 	$dir = $conf->product->multidir_output[$product->entity];
107 107
 	$conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO = 1;
108
-	$origin = $dir .'/'. get_exdir($product->id,2,0,0,$product,'product') . $product->id ."/photos";
108
+	$origin = $dir.'/'.get_exdir($product->id, 2, 0, 0, $product, 'product').$product->id."/photos";
109 109
 	$destin = $dir.'/'.dol_sanitizeFileName($product->ref);
110 110
 
111 111
 	$error = 0;
112 112
 
113
-	$origin_osencoded=dol_osencode($origin);
114
-	$destin_osencoded=dol_osencode($destin);
113
+	$origin_osencoded = dol_osencode($origin);
114
+	$destin_osencoded = dol_osencode($destin);
115 115
 	dol_mkdir($destin);
116 116
 
117 117
 	if (dol_is_dir($origin))
118 118
 	{
119
-		$handle=opendir($origin_osencoded);
119
+		$handle = opendir($origin_osencoded);
120 120
         if (is_resource($handle))
121 121
         {
122 122
         	while (($file = readdir($handle)) !== false)
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
     			}
137 137
     			else
138 138
     			{
139
-    				if (dol_is_file($origin.'/'.$file) )
139
+    				if (dol_is_file($origin.'/'.$file))
140 140
     				{
141 141
     					dol_move($origin.'/'.$file, $destin.'/'.$file);
142 142
     				}
Please login to merge, or discard this patch.
dolibarr/scripts/product/regenerate_thumbs.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 
26 26
 $sapi_type = php_sapi_name();
27 27
 $script_file = basename(__FILE__);
28
-$path=dirname(__FILE__).'/';
28
+$path = dirname(__FILE__).'/';
29 29
 
30 30
 // Test if batch mode
31 31
 if (substr($sapi_type, 0, 3) == 'cgi') {
@@ -33,8 +33,8 @@  discard block
 block discarded – undo
33 33
 	exit(-1);
34 34
 }
35 35
 
36
-@set_time_limit(0);							// No timeout for this script
37
-define('EVEN_IF_ONLY_LOGIN_ALLOWED',1);		// Set this define to 0 if you want to lock your script when dolibarr setup is "locked to admin user only".
36
+@set_time_limit(0); // No timeout for this script
37
+define('EVEN_IF_ONLY_LOGIN_ALLOWED', 1); // Set this define to 0 if you want to lock your script when dolibarr setup is "locked to admin user only".
38 38
 
39 39
 // Include and load Dolibarr environment variables
40 40
 require_once $path."../../htdocs/master.inc.php";
@@ -45,17 +45,17 @@  discard block
 block discarded – undo
45 45
 // $user is created but empty.
46 46
 
47 47
 //$langs->setDefaultLang('en_US'); 	// To change default language of $langs
48
-$langs->load("main");				// To load language file for default language
48
+$langs->load("main"); // To load language file for default language
49 49
 
50 50
 
51 51
 // Global variables
52
-$version=DOL_VERSION;
53
-$error=0;
54
-$forcecommit=0;
52
+$version = DOL_VERSION;
53
+$error = 0;
54
+$forcecommit = 0;
55 55
 
56 56
 
57 57
 print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n";
58
-dol_syslog($script_file." launched with arg ".join(',',$argv));
58
+dol_syslog($script_file." launched with arg ".join(',', $argv));
59 59
 
60 60
 if (empty($argv[1])) {
61 61
     print "Usage:    $script_file  subdirtoscan\n";
@@ -66,27 +66,27 @@  discard block
 block discarded – undo
66 66
 print '--- start'."\n";
67 67
 
68 68
 $dir = DOL_DATA_ROOT;
69
-$subdir=$argv[1];
69
+$subdir = $argv[1];
70 70
 if (empty($dir) || empty($subdir))
71 71
 {
72 72
 	dol_print_error('', 'dir not defined');
73 73
 	exit(1);
74 74
 }
75
-if (! dol_is_dir($dir.'/'.$subdir))
75
+if (!dol_is_dir($dir.'/'.$subdir))
76 76
 {
77 77
 	print 'Directory '.$dir.'/'.$subdir.' not found.'."\n";
78 78
 	exit(2);
79 79
 }
80 80
 
81
-$filearray=dol_dir_list($dir.'/'.$subdir,"directories",0,'','temp$');
81
+$filearray = dol_dir_list($dir.'/'.$subdir, "directories", 0, '', 'temp$');
82 82
 
83 83
 global $maxwidthsmall, $maxheightsmall, $maxwidthmini, $maxheightmini;
84 84
 
85
-foreach($filearray as $keyf => $valf)
85
+foreach ($filearray as $keyf => $valf)
86 86
 {
87
-	$ref=basename($valf['name']);
88
-	$filearrayimg=dol_dir_list($valf['fullname'],"files",0,'(\.gif|\.png|\.jpg|\.jpeg|\.bmp)$','(\.meta|_preview.*\.png)$');
89
-	foreach($filearrayimg as $keyi => $vali)
87
+	$ref = basename($valf['name']);
88
+	$filearrayimg = dol_dir_list($valf['fullname'], "files", 0, '(\.gif|\.png|\.jpg|\.jpeg|\.bmp)$', '(\.meta|_preview.*\.png)$');
89
+	foreach ($filearrayimg as $keyi => $vali)
90 90
 	{
91 91
 		print 'Process image for ref '.$ref.' : '.$vali['name']."\n";
92 92
 
@@ -102,6 +102,6 @@  discard block
 block discarded – undo
102 102
 	}
103 103
 }
104 104
 
105
-$db->close();	// Close $db database opened handler
105
+$db->close(); // Close $db database opened handler
106 106
 
107 107
 exit($error);
Please login to merge, or discard this patch.
dolibarr/test/phpunit/MouvementStockTest.php 1 patch
Spacing   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  *		\remarks	To run this script as CLI:  phpunit filename.php
24 24
  */
25 25
 
26
-global $conf,$user,$langs,$db;
26
+global $conf, $user, $langs, $db;
27 27
 //define('TEST_DB_FORCE_TYPE','mysql');	// This is to force using mysql driver
28 28
 //require_once 'PHPUnit/Autoload.php';
29 29
 require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	$user->fetch(1);
38 38
 	$user->getrights();
39 39
 }
40
-$conf->global->MAIN_DISABLE_ALL_MAILS=1;
40
+$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
41 41
 
42 42
 
43 43
 /**
@@ -65,11 +65,11 @@  discard block
 block discarded – undo
65 65
 		parent::__construct();
66 66
 
67 67
 		//$this->sharedFixture
68
-		global $conf,$user,$langs,$db;
69
-		$this->savconf=$conf;
70
-		$this->savuser=$user;
71
-		$this->savlangs=$langs;
72
-		$this->savdb=$db;
68
+		global $conf, $user, $langs, $db;
69
+		$this->savconf = $conf;
70
+		$this->savuser = $user;
71
+		$this->savlangs = $langs;
72
+		$this->savdb = $db;
73 73
 
74 74
 		print __METHOD__." db->type=".$db->type." user->id=".$user->id;
75 75
 		//print " - db ".$db->db;
@@ -79,8 +79,8 @@  discard block
 block discarded – undo
79 79
 	// Static methods
80 80
   	public static function setUpBeforeClass()
81 81
     {
82
-    	global $conf,$user,$langs,$db;
83
-		$db->begin();	// This is to have all actions inside a transaction even if test launched without suite.
82
+    	global $conf, $user, $langs, $db;
83
+		$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
84 84
 
85 85
     	print __METHOD__."\n";
86 86
     }
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
     // tear down after class
89 89
     public static function tearDownAfterClass()
90 90
     {
91
-    	global $conf,$user,$langs,$db;
91
+    	global $conf, $user, $langs, $db;
92 92
 		$db->rollback();
93 93
 
94 94
 		print __METHOD__."\n";
@@ -101,11 +101,11 @@  discard block
 block discarded – undo
101 101
 	 */
102 102
     protected function setUp()
103 103
     {
104
-    	global $conf,$user,$langs,$db;
105
-		$conf=$this->savconf;
106
-		$user=$this->savuser;
107
-		$langs=$this->savlangs;
108
-		$db=$this->savdb;
104
+    	global $conf, $user, $langs, $db;
105
+		$conf = $this->savconf;
106
+		$user = $this->savuser;
107
+		$langs = $this->savlangs;
108
+		$db = $this->savdb;
109 109
 
110 110
 		print __METHOD__."\n";
111 111
     }
@@ -126,64 +126,64 @@  discard block
 block discarded – undo
126 126
      */
127 127
     public function testMouvementCreate()
128 128
     {
129
-    	global $conf,$user,$langs,$db;
130
-		$conf=$this->savconf;
131
-		$user=$this->savuser;
132
-		$langs=$this->savlangs;
133
-		$db=$this->savdb;
129
+    	global $conf, $user, $langs, $db;
130
+		$conf = $this->savconf;
131
+		$user = $this->savuser;
132
+		$langs = $this->savlangs;
133
+		$db = $this->savdb;
134 134
 
135 135
 		// We create a product for tests
136
-		$product1=new Product($db);
136
+		$product1 = new Product($db);
137 137
 		$product1->initAsSpecimen();
138
-		$product1->ref.=' 1';
139
-		$product1->label.=' 1';
140
-		$product1id=$product1->create($user);
138
+		$product1->ref .= ' 1';
139
+		$product1->label .= ' 1';
140
+		$product1id = $product1->create($user);
141 141
 
142
-		$product2=new Product($db);
142
+		$product2 = new Product($db);
143 143
 		$product2->initAsSpecimen();
144
-		$product2->ref.=' 2';
145
-		$product2->label.=' 2';
146
-		$product2id=$product2->create($user);
144
+		$product2->ref .= ' 2';
145
+		$product2->label .= ' 2';
146
+		$product2id = $product2->create($user);
147 147
 
148 148
 		// We create a product for tests
149
-		$warehouse1=new Entrepot($db);
149
+		$warehouse1 = new Entrepot($db);
150 150
 		$warehouse1->initAsSpecimen();
151
-		$warehouse1->libelle.=' 1';
152
-		$warehouse1->description.=' 1';
153
-		$warehouse1id=$warehouse1->create($user);
151
+		$warehouse1->libelle .= ' 1';
152
+		$warehouse1->description .= ' 1';
153
+		$warehouse1id = $warehouse1->create($user);
154 154
 
155
-		$warehouse2=new Entrepot($db);
155
+		$warehouse2 = new Entrepot($db);
156 156
 		$warehouse2->initAsSpecimen();
157
-		$warehouse2->libelle.=' 2';
158
-		$warehouse2->description.=' 2';
159
-		$warehouse2id=$warehouse2->create($user);
157
+		$warehouse2->libelle .= ' 2';
158
+		$warehouse2->description .= ' 2';
159
+		$warehouse2id = $warehouse2->create($user);
160 160
 
161
-		$localobject=new MouvementStock($this->savdb);
161
+		$localobject = new MouvementStock($this->savdb);
162 162
 
163 163
     	// Do a list of movement into warehouse 1
164 164
 
165 165
     	// Create an input movement (type = 3) of price 9.9 -> shoul dupdate PMP to 9.9
166
-    	$result=$localobject->_create($user, $product1id, $warehouse1id, 10, 3, 9.9, 'Movement for unit test 1', 'Inventory Code Test');
166
+    	$result = $localobject->_create($user, $product1id, $warehouse1id, 10, 3, 9.9, 'Movement for unit test 1', 'Inventory Code Test');
167 167
     	print __METHOD__." result=".$result."\n";
168 168
     	$this->assertLessThan($result, 0);
169 169
 
170 170
     	// Create an input movement (type = 3) of price 9.7 -> shoul dupdate PMP to 9.9/9.7 = 9.8
171
-    	$result=$localobject->_create($user, $product1id, $warehouse1id, 10, 3, 9.7, 'Movement for unit test 2', 'Inventory Code Test');
171
+    	$result = $localobject->_create($user, $product1id, $warehouse1id, 10, 3, 9.7, 'Movement for unit test 2', 'Inventory Code Test');
172 172
     	print __METHOD__." result=".$result."\n";
173 173
     	$this->assertLessThan($result, 0);
174 174
 
175 175
     	// Create an output movement (type = 2) of price 9.7 -> shoul dupdate PMP to 9.9/9.7 = 9.8
176
-    	$result=$localobject->_create($user, $product1id, $warehouse1id, -5, 2, 999, 'Movement for unit test 3', 'Inventory Code Test');
176
+    	$result = $localobject->_create($user, $product1id, $warehouse1id, -5, 2, 999, 'Movement for unit test 3', 'Inventory Code Test');
177 177
     	print __METHOD__." result=".$result."\n";
178 178
     	$this->assertLessThan($result, 0);
179 179
 
180 180
     	// Create an output movement (type = 1) of price 9.7 -> shoul dupdate PMP to 9.9/9.7 = 9.8
181
-    	$result=$localobject->_create($user, $product1id, $warehouse1id, 1, 0, 0, 'Input from transfer', 'Transfert X');
181
+    	$result = $localobject->_create($user, $product1id, $warehouse1id, 1, 0, 0, 'Input from transfer', 'Transfert X');
182 182
     	print __METHOD__." result=".$result."\n";
183 183
     	$this->assertLessThan($result, 0);
184 184
 
185 185
     	// Create an output movement (type = 1) of price 9.7 -> shoul dupdate PMP to 9.9/9.7 = 9.8
186
-    	$result=$localobject->_create($user, $product1id, $warehouse1id, -2, 1, 0, 'Output from transfer', 'Transfert Y');
186
+    	$result = $localobject->_create($user, $product1id, $warehouse1id, -2, 1, 0, 'Output from transfer', 'Transfert Y');
187 187
     	print __METHOD__." result=".$result."\n";
188 188
     	$this->assertLessThan($result, 0);
189 189
 
@@ -191,27 +191,27 @@  discard block
 block discarded – undo
191 191
     	// Do same but into warehouse 2
192 192
 
193 193
     	// Create an input movement (type = 3) of price 9.9 -> shoul dupdate PMP to 9.9
194
-    	$result=$localobject->_create($user, $product1id, $warehouse2id, 10, 3, 9.9, 'Movement for unit test 1 wh 2', 'Inventory Code Test 2');
194
+    	$result = $localobject->_create($user, $product1id, $warehouse2id, 10, 3, 9.9, 'Movement for unit test 1 wh 2', 'Inventory Code Test 2');
195 195
     	print __METHOD__." result=".$result."\n";
196 196
     	$this->assertLessThan($result, 0);
197 197
 
198 198
     	// Create an input movement (type = 3) of price 9.7 -> shoul dupdate PMP to 9.9/9.7 = 9.8
199
-    	$result=$localobject->_create($user, $product1id, $warehouse2id, 10, 3, 9.7, 'Movement for unit test 2 wh 2', 'Inventory Code Test 2');
199
+    	$result = $localobject->_create($user, $product1id, $warehouse2id, 10, 3, 9.7, 'Movement for unit test 2 wh 2', 'Inventory Code Test 2');
200 200
     	print __METHOD__." result=".$result."\n";
201 201
     	$this->assertLessThan($result, 0);
202 202
 
203 203
     	// Create an output movement (type = 2) of price 9.7 -> shoul dupdate PMP to 9.9/9.7 = 9.8
204
-    	$result=$localobject->_create($user, $product1id, $warehouse2id, -5, 2, 999, 'Movement for unit test 3 wh 2', 'Inventory Code Test 2');
204
+    	$result = $localobject->_create($user, $product1id, $warehouse2id, -5, 2, 999, 'Movement for unit test 3 wh 2', 'Inventory Code Test 2');
205 205
     	print __METHOD__." result=".$result."\n";
206 206
     	$this->assertLessThan($result, 0);
207 207
 
208 208
     	// Create an output movement (type = 1) of price 9.7 -> shoul dupdate PMP to 9.9/9.7 = 9.8
209
-    	$result=$localobject->_create($user, $product1id, $warehouse2id, 1, 0, 0, 'Input from transfer wh 2', 'Transfert X 2');
209
+    	$result = $localobject->_create($user, $product1id, $warehouse2id, 1, 0, 0, 'Input from transfer wh 2', 'Transfert X 2');
210 210
     	print __METHOD__." result=".$result."\n";
211 211
     	$this->assertLessThan($result, 0);
212 212
 
213 213
     	// Create an output movement (type = 1) of price 9.7 -> shoul dupdate PMP to 9.9/9.7 = 9.8
214
-    	$result=$localobject->_create($user, $product1id, $warehouse2id, -2, 1, 0, 'Output from transfer wh 2', 'Transfert Y 2');
214
+    	$result = $localobject->_create($user, $product1id, $warehouse2id, -2, 1, 0, 'Output from transfer wh 2', 'Transfert Y 2');
215 215
     	print __METHOD__." result=".$result."\n";
216 216
     	$this->assertLessThan($result, 0);
217 217
 
@@ -230,11 +230,11 @@  discard block
 block discarded – undo
230 230
      */
231 231
     public function testMouvementCheck($localobject)
232 232
     {
233
-    	global $conf,$user,$langs,$db;
234
-		$conf=$this->savconf;
235
-		$user=$this->savuser;
236
-		$langs=$this->savlangs;
237
-		$db=$this->savdb;
233
+    	global $conf, $user, $langs, $db;
234
+		$conf = $this->savconf;
235
+		$user = $this->savuser;
236
+		$langs = $this->savlangs;
237
+		$db = $this->savdb;
238 238
 
239 239
 		$productid = $localobject->product_id;
240 240
 		$warehouseid = $localobject->entrepot_id;
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
 		$producttotest->fetch($productid);
246 246
 
247 247
     	print __METHOD__." producttotest->stock_reel=".$producttotest->stock_reel."\n";
248
-    	$this->assertEquals($producttotest->stock_reel, 28);	// 28 is result of stock movement defined into testMouvementCreate
248
+    	$this->assertEquals($producttotest->stock_reel, 28); // 28 is result of stock movement defined into testMouvementCreate
249 249
 
250 250
     	print __METHOD__." producttotest->pmp=".$producttotest->pmp."\n";
251 251
     	$this->assertEquals($producttotest->pmp, 9.8);
Please login to merge, or discard this patch.
dolibarr/test/phpunit/ActionCommTest.php 1 patch
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  *      \remarks    To run this script as CLI:  phpunit filename.php
24 24
  */
25 25
 
26
-global $conf,$user,$langs,$db;
26
+global $conf, $user, $langs, $db;
27 27
 //define('TEST_DB_FORCE_TYPE','mysql');	// This is to force using mysql driver
28 28
 //require_once 'PHPUnit/Autoload.php';
29 29
 require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
     $user->fetch(1);
35 35
     $user->getrights();
36 36
 }
37
-$conf->global->MAIN_DISABLE_ALL_MAILS=1;
37
+$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
38 38
 
39 39
 
40 40
 /**
@@ -62,11 +62,11 @@  discard block
 block discarded – undo
62 62
     	parent::__construct();
63 63
 
64 64
     	//$this->sharedFixture
65
-        global $conf,$user,$langs,$db;
66
-        $this->savconf=$conf;
67
-        $this->savuser=$user;
68
-        $this->savlangs=$langs;
69
-        $this->savdb=$db;
65
+        global $conf, $user, $langs, $db;
66
+        $this->savconf = $conf;
67
+        $this->savuser = $user;
68
+        $this->savlangs = $langs;
69
+        $this->savdb = $db;
70 70
 
71 71
         print __METHOD__." db->type=".$db->type." user->id=".$user->id;
72 72
         //print " - db ".$db->db;
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
     // Static methods
77 77
     public static function setUpBeforeClass()
78 78
     {
79
-        global $conf,$user,$langs,$db;
79
+        global $conf, $user, $langs, $db;
80 80
         $db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
81 81
 
82 82
         if (empty($conf->agenda->enabled)) { print __METHOD__." module agenda must be enabled.\n"; die(); }
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
     // tear down after class
88 88
     public static function tearDownAfterClass()
89 89
     {
90
-        global $conf,$user,$langs,$db;
90
+        global $conf, $user, $langs, $db;
91 91
         $db->rollback();
92 92
 
93 93
         print __METHOD__."\n";
@@ -100,11 +100,11 @@  discard block
 block discarded – undo
100 100
      */
101 101
     protected function setUp()
102 102
     {
103
-        global $conf,$user,$langs,$db;
104
-        $conf=$this->savconf;
105
-        $user=$this->savuser;
106
-        $langs=$this->savlangs;
107
-        $db=$this->savdb;
103
+        global $conf, $user, $langs, $db;
104
+        $conf = $this->savconf;
105
+        $user = $this->savuser;
106
+        $langs = $this->savlangs;
107
+        $db = $this->savdb;
108 108
 
109 109
         print __METHOD__."\n";
110 110
         //print $db->getVersion()."\n";
@@ -127,28 +127,28 @@  discard block
 block discarded – undo
127 127
      */
128 128
     public function testActionCommCreate()
129 129
     {
130
-        global $conf,$user,$langs,$db;
131
-        $conf=$this->savconf;
132
-        $user=$this->savuser;
133
-        $langs=$this->savlangs;
134
-        $db=$this->savdb;
130
+        global $conf, $user, $langs, $db;
131
+        $conf = $this->savconf;
132
+        $user = $this->savuser;
133
+        $langs = $this->savlangs;
134
+        $db = $this->savdb;
135 135
 
136 136
         $now = dol_now();
137 137
 
138
-        $localobject=new ActionComm($this->savdb);
138
+        $localobject = new ActionComm($this->savdb);
139 139
 
140
-        $localobject->type_code   = 'AC_OTH_AUTO';		// Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...)
140
+        $localobject->type_code   = 'AC_OTH_AUTO'; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...)
141 141
         $localobject->code        = 'AC_PHPUNITTEST';
142 142
         $localobject->label       = 'This is a description';
143 143
         $localobject->note        = 'This is note';
144 144
         $localobject->fk_project  = 0;
145 145
         $localobject->datep       = $now;
146 146
         $localobject->datef       = $now;
147
-        $localobject->percentage  = -1;   // Not applicable
147
+        $localobject->percentage  = -1; // Not applicable
148 148
         $localobject->socid       = 0;
149 149
         $localobject->contactid   = 0;
150
-        $localobject->authorid    = $user->id;   // User saving action
151
-        $localobject->userownerid = $user->id;	// Owner of action
150
+        $localobject->authorid    = $user->id; // User saving action
151
+        $localobject->userownerid = $user->id; // Owner of action
152 152
         // Fields when action is en email (content should be added into note)
153 153
         /*$localobject->email_msgid = $object->email_msgid;
154 154
          $localobject->email_from  = $object->email_from;
@@ -180,14 +180,14 @@  discard block
 block discarded – undo
180 180
      */
181 181
     public function testActionCommFetch($id)
182 182
     {
183
-        global $conf,$user,$langs,$db;
184
-        $conf=$this->savconf;
185
-        $user=$this->savuser;
186
-        $langs=$this->savlangs;
187
-        $db=$this->savdb;
183
+        global $conf, $user, $langs, $db;
184
+        $conf = $this->savconf;
185
+        $user = $this->savuser;
186
+        $langs = $this->savlangs;
187
+        $db = $this->savdb;
188 188
 
189
-        $localobject=new ActionComm($this->savdb);
190
-        $result=$localobject->fetch($id);
189
+        $localobject = new ActionComm($this->savdb);
190
+        $result = $localobject->fetch($id);
191 191
 
192 192
         $this->assertLessThan($result, 0);
193 193
         print __METHOD__." id=".$id." result=".$result."\n";
@@ -205,14 +205,14 @@  discard block
 block discarded – undo
205 205
      */
206 206
     public function testActionCommUpdate($localobject)
207 207
     {
208
-    	global $conf,$user,$langs,$db;
209
-    	$conf=$this->savconf;
210
-    	$user=$this->savuser;
211
-    	$langs=$this->savlangs;
212
-    	$db=$this->savdb;
208
+    	global $conf, $user, $langs, $db;
209
+    	$conf = $this->savconf;
210
+    	$user = $this->savuser;
211
+    	$langs = $this->savlangs;
212
+    	$db = $this->savdb;
213 213
 
214
-    	$localobject->label='New label';
215
-    	$result=$localobject->update($user);
214
+    	$localobject->label = 'New label';
215
+    	$result = $localobject->update($user);
216 216
 
217 217
     	$this->assertLessThan($result, 0);
218 218
     	print __METHOD__." id=".$id." result=".$result."\n";
@@ -230,15 +230,15 @@  discard block
 block discarded – undo
230 230
      */
231 231
     public function testActionCommDelete($id)
232 232
     {
233
-        global $conf,$user,$langs,$db;
234
-        $conf=$this->savconf;
235
-        $user=$this->savuser;
236
-        $langs=$this->savlangs;
237
-        $db=$this->savdb;
238
-
239
-        $localobject=new ActionComm($this->savdb);
240
-        $result=$localobject->fetch($id);
241
-        $result=$localobject->delete($user);
233
+        global $conf, $user, $langs, $db;
234
+        $conf = $this->savconf;
235
+        $user = $this->savuser;
236
+        $langs = $this->savlangs;
237
+        $db = $this->savdb;
238
+
239
+        $localobject = new ActionComm($this->savdb);
240
+        $result = $localobject->fetch($id);
241
+        $result = $localobject->delete($user);
242 242
 
243 243
         print __METHOD__." id=".$id." result=".$result."\n";
244 244
         $this->assertLessThan($result, 0);
Please login to merge, or discard this patch.