@@ -26,7 +26,7 @@ discard block |
||
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') { |
@@ -42,11 +42,11 @@ discard block |
||
42 | 42 | $langs->loadLangs(array("main", "errors")); |
43 | 43 | |
44 | 44 | // Global variables |
45 | -$version=DOL_VERSION; |
|
46 | -$error=0; |
|
47 | -$forcecommit=0; |
|
48 | -$excludeuser=array(); |
|
49 | -$confirmed=0; |
|
45 | +$version = DOL_VERSION; |
|
46 | +$error = 0; |
|
47 | +$forcecommit = 0; |
|
48 | +$excludeuser = array(); |
|
49 | +$confirmed = 0; |
|
50 | 50 | |
51 | 51 | /* |
52 | 52 | * Main |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | |
55 | 55 | @set_time_limit(0); |
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 | 59 | // List of fields to get from LDAP |
60 | 60 | $required_fields = array( |
@@ -80,31 +80,31 @@ discard block |
||
80 | 80 | ); |
81 | 81 | |
82 | 82 | // Remove from required_fields all entries not configured in LDAP (empty) and duplicated |
83 | -$required_fields=array_unique(array_values(array_filter($required_fields, "dolValidElement"))); |
|
83 | +$required_fields = array_unique(array_values(array_filter($required_fields, "dolValidElement"))); |
|
84 | 84 | |
85 | -if (! isset($argv[1])) { |
|
85 | +if (!isset($argv[1])) { |
|
86 | 86 | print "Usage: $script_file (nocommitiferror|commitiferror) [--server=ldapserverhost] [--excludeuser=user1,user2...] [-y]\n"; |
87 | 87 | exit(-1); |
88 | 88 | } |
89 | 89 | |
90 | -foreach($argv as $key => $val) |
|
90 | +foreach ($argv as $key => $val) |
|
91 | 91 | { |
92 | - if ($val == 'commitiferror') $forcecommit=1; |
|
93 | - if (preg_match('/--server=([^\s]+)$/',$val,$reg)) $conf->global->LDAP_SERVER_HOST=$reg[1]; |
|
94 | - if (preg_match('/--excludeuser=([^\s]+)$/',$val,$reg)) $excludeuser=explode(',',$reg[1]); |
|
95 | - if (preg_match('/-y$/',$val,$reg)) $confirmed=1; |
|
92 | + if ($val == 'commitiferror') $forcecommit = 1; |
|
93 | + if (preg_match('/--server=([^\s]+)$/', $val, $reg)) $conf->global->LDAP_SERVER_HOST = $reg[1]; |
|
94 | + if (preg_match('/--excludeuser=([^\s]+)$/', $val, $reg)) $excludeuser = explode(',', $reg[1]); |
|
95 | + if (preg_match('/-y$/', $val, $reg)) $confirmed = 1; |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | print "Mails sending disabled (useless in batch mode)\n"; |
99 | -$conf->global->MAIN_DISABLE_ALL_MAILS=1; // On bloque les mails |
|
99 | +$conf->global->MAIN_DISABLE_ALL_MAILS = 1; // On bloque les mails |
|
100 | 100 | print "\n"; |
101 | 101 | print "----- Synchronize all records from LDAP database:\n"; |
102 | 102 | print "host=".$conf->global->LDAP_SERVER_HOST."\n"; |
103 | 103 | print "port=".$conf->global->LDAP_SERVER_PORT."\n"; |
104 | 104 | print "login=".$conf->global->LDAP_ADMIN_DN."\n"; |
105 | -print "pass=".preg_replace('/./i','*',$conf->global->LDAP_ADMIN_PASS)."\n"; |
|
105 | +print "pass=".preg_replace('/./i', '*', $conf->global->LDAP_ADMIN_PASS)."\n"; |
|
106 | 106 | print "DN to extract=".$conf->global->LDAP_USER_DN."\n"; |
107 | -if (! empty($conf->global->LDAP_FILTER_CONNECTION)) print 'Filter=('.$conf->global->LDAP_FILTER_CONNECTION.')'."\n"; // Note: filter is defined into function getRecords |
|
107 | +if (!empty($conf->global->LDAP_FILTER_CONNECTION)) print 'Filter=('.$conf->global->LDAP_FILTER_CONNECTION.')'."\n"; // Note: filter is defined into function getRecords |
|
108 | 108 | else print 'Filter=('.$conf->global->LDAP_KEY_USERS.'=*)'."\n"; |
109 | 109 | print "----- To Dolibarr database:\n"; |
110 | 110 | print "type=".$conf->db->type."\n"; |
@@ -114,11 +114,11 @@ discard block |
||
114 | 114 | print "database=".$conf->db->name."\n"; |
115 | 115 | print "----- Options:\n"; |
116 | 116 | print "commitiferror=".$forcecommit."\n"; |
117 | -print "excludeuser=".join(',',$excludeuser)."\n"; |
|
118 | -print "Mapped LDAP fields=".join(',',$required_fields)."\n"; |
|
117 | +print "excludeuser=".join(',', $excludeuser)."\n"; |
|
118 | +print "Mapped LDAP fields=".join(',', $required_fields)."\n"; |
|
119 | 119 | print "\n"; |
120 | 120 | |
121 | -if (! $confirmed) |
|
121 | +if (!$confirmed) |
|
122 | 122 | { |
123 | 123 | print "Hit Enter to continue or CTRL+C to stop...\n"; |
124 | 124 | $input = trim(fgets(STDIN)); |
@@ -132,13 +132,13 @@ discard block |
||
132 | 132 | |
133 | 133 | |
134 | 134 | // Load table of correspondence of countries |
135 | -$hashlib2rowid=array(); |
|
136 | -$countries=array(); |
|
135 | +$hashlib2rowid = array(); |
|
136 | +$countries = array(); |
|
137 | 137 | $sql = "SELECT rowid, code, label, active"; |
138 | -$sql.= " FROM ".MAIN_DB_PREFIX."c_country"; |
|
139 | -$sql.= " WHERE active = 1"; |
|
140 | -$sql.= " ORDER BY code ASC"; |
|
141 | -$resql=$db->query($sql); |
|
138 | +$sql .= " FROM ".MAIN_DB_PREFIX."c_country"; |
|
139 | +$sql .= " WHERE active = 1"; |
|
140 | +$sql .= " ORDER BY code ASC"; |
|
141 | +$resql = $db->query($sql); |
|
142 | 142 | if ($resql) |
143 | 143 | { |
144 | 144 | $num = $db->num_rows($resql); |
@@ -151,8 +151,8 @@ discard block |
||
151 | 151 | if ($obj) |
152 | 152 | { |
153 | 153 | //print 'Load cache for country '.strtolower($obj->label).' rowid='.$obj->rowid."\n"; |
154 | - $hashlib2rowid[strtolower($obj->label)]=$obj->rowid; |
|
155 | - $countries[$obj->rowid]=array('rowid' => $obj->rowid, 'label' => $obj->label, 'code' => $obj->code); |
|
154 | + $hashlib2rowid[strtolower($obj->label)] = $obj->rowid; |
|
155 | + $countries[$obj->rowid] = array('rowid' => $obj->rowid, 'label' => $obj->label, 'code' => $obj->code); |
|
156 | 156 | } |
157 | 157 | $i++; |
158 | 158 | } |
@@ -170,13 +170,13 @@ discard block |
||
170 | 170 | $result = $ldap->connect_bind(); |
171 | 171 | if ($result >= 0) |
172 | 172 | { |
173 | - $justthese=array(); |
|
173 | + $justthese = array(); |
|
174 | 174 | |
175 | 175 | |
176 | 176 | // We disable synchro Dolibarr-LDAP |
177 | - $conf->global->LDAP_SYNCHRO_ACTIVE=0; |
|
177 | + $conf->global->LDAP_SYNCHRO_ACTIVE = 0; |
|
178 | 178 | |
179 | - $ldaprecords = $ldap->getRecords('*',$conf->global->LDAP_USER_DN, $conf->global->LDAP_KEY_USERS, $required_fields, 'user'); // Fiter on 'user' filter param |
|
179 | + $ldaprecords = $ldap->getRecords('*', $conf->global->LDAP_USER_DN, $conf->global->LDAP_KEY_USERS, $required_fields, 'user'); // Fiter on 'user' filter param |
|
180 | 180 | if (is_array($ldaprecords)) |
181 | 181 | { |
182 | 182 | $db->begin(); |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | foreach ($ldaprecords as $key => $ldapuser) |
186 | 186 | { |
187 | 187 | // If login into exclude list, we discard record |
188 | - if (in_array($ldapuser[$conf->global->LDAP_FIELD_LOGIN],$excludeuser)) |
|
188 | + if (in_array($ldapuser[$conf->global->LDAP_FIELD_LOGIN], $excludeuser)) |
|
189 | 189 | { |
190 | 190 | print $langs->transnoentities("UserDiscarded").' # '.$key.': login='.$ldapuser[$conf->global->LDAP_FIELD_LOGIN].' --> Discarded'."\n"; |
191 | 191 | continue; |
@@ -193,18 +193,18 @@ discard block |
||
193 | 193 | |
194 | 194 | $fuser = new User($db); |
195 | 195 | |
196 | - if($conf->global->LDAP_KEY_USERS == $conf->global->LDAP_FIELD_SID) { |
|
197 | - $fuser->fetch('','',$ldapuser[$conf->global->LDAP_KEY_USERS]); // Chargement du user concerné par le SID |
|
198 | - } else if($conf->global->LDAP_KEY_USERS == $conf->global->LDAP_FIELD_LOGIN) { |
|
199 | - $fuser->fetch('',$ldapuser[$conf->global->LDAP_KEY_USERS]); // Chargement du user concerné par le login |
|
196 | + if ($conf->global->LDAP_KEY_USERS == $conf->global->LDAP_FIELD_SID) { |
|
197 | + $fuser->fetch('', '', $ldapuser[$conf->global->LDAP_KEY_USERS]); // Chargement du user concerné par le SID |
|
198 | + } else if ($conf->global->LDAP_KEY_USERS == $conf->global->LDAP_FIELD_LOGIN) { |
|
199 | + $fuser->fetch('', $ldapuser[$conf->global->LDAP_KEY_USERS]); // Chargement du user concerné par le login |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | // Propriete membre |
203 | - $fuser->firstname=$ldapuser[$conf->global->LDAP_FIELD_FIRSTNAME]; |
|
204 | - $fuser->lastname=$ldapuser[$conf->global->LDAP_FIELD_NAME]; |
|
205 | - $fuser->login=$ldapuser[$conf->global->LDAP_FIELD_LOGIN]; |
|
206 | - $fuser->pass=$ldapuser[$conf->global->LDAP_FIELD_PASSWORD]; |
|
207 | - $fuser->pass_indatabase_crypted=$ldapuser[$conf->global->LDAP_FIELD_PASSWORD_CRYPTED]; |
|
203 | + $fuser->firstname = $ldapuser[$conf->global->LDAP_FIELD_FIRSTNAME]; |
|
204 | + $fuser->lastname = $ldapuser[$conf->global->LDAP_FIELD_NAME]; |
|
205 | + $fuser->login = $ldapuser[$conf->global->LDAP_FIELD_LOGIN]; |
|
206 | + $fuser->pass = $ldapuser[$conf->global->LDAP_FIELD_PASSWORD]; |
|
207 | + $fuser->pass_indatabase_crypted = $ldapuser[$conf->global->LDAP_FIELD_PASSWORD_CRYPTED]; |
|
208 | 208 | |
209 | 209 | //$user->societe; |
210 | 210 | /* |
@@ -216,20 +216,20 @@ discard block |
||
216 | 216 | $fuser->country_code=$countries[$hashlib2rowid[strtolower($fuser->country)]]['code']; |
217 | 217 | */ |
218 | 218 | |
219 | - $fuser->office_phone=$ldapuser[$conf->global->LDAP_FIELD_PHONE]; |
|
220 | - $fuser->user_mobile=$ldapuser[$conf->global->LDAP_FIELD_MOBILE]; |
|
221 | - $fuser->office_fax=$ldapuser[$conf->global->LDAP_FIELD_FAX]; |
|
222 | - $fuser->email=$ldapuser[$conf->global->LDAP_FIELD_MAIL]; |
|
223 | - $fuser->ldap_sid=$ldapuser[$conf->global->LDAP_FIELD_SID]; |
|
219 | + $fuser->office_phone = $ldapuser[$conf->global->LDAP_FIELD_PHONE]; |
|
220 | + $fuser->user_mobile = $ldapuser[$conf->global->LDAP_FIELD_MOBILE]; |
|
221 | + $fuser->office_fax = $ldapuser[$conf->global->LDAP_FIELD_FAX]; |
|
222 | + $fuser->email = $ldapuser[$conf->global->LDAP_FIELD_MAIL]; |
|
223 | + $fuser->ldap_sid = $ldapuser[$conf->global->LDAP_FIELD_SID]; |
|
224 | 224 | |
225 | - $fuser->job=$ldapuser[$conf->global->LDAP_FIELD_TITLE]; |
|
226 | - $fuser->note=$ldapuser[$conf->global->LDAP_FIELD_DESCRIPTION]; |
|
227 | - $fuser->admin=0; |
|
228 | - $fuser->societe_id=0; |
|
229 | - $fuser->contact_id=0; |
|
230 | - $fuser->fk_member=0; |
|
225 | + $fuser->job = $ldapuser[$conf->global->LDAP_FIELD_TITLE]; |
|
226 | + $fuser->note = $ldapuser[$conf->global->LDAP_FIELD_DESCRIPTION]; |
|
227 | + $fuser->admin = 0; |
|
228 | + $fuser->societe_id = 0; |
|
229 | + $fuser->contact_id = 0; |
|
230 | + $fuser->fk_member = 0; |
|
231 | 231 | |
232 | - $fuser->statut=1; |
|
232 | + $fuser->statut = 1; |
|
233 | 233 | // TODO : revoir la gestion du status |
234 | 234 | /*if (isset($ldapuser[$conf->global->LDAP_FIELD_MEMBER_STATUS])) |
235 | 235 | { |
@@ -241,9 +241,9 @@ discard block |
||
241 | 241 | |
242 | 242 | //print_r($ldapuser); |
243 | 243 | |
244 | - if($fuser->id > 0) { // User update |
|
244 | + if ($fuser->id > 0) { // User update |
|
245 | 245 | print $langs->transnoentities("UserUpdate").' # '.$key.': login='.$fuser->login.', fullname='.$fuser->getFullName($langs); |
246 | - $res=$fuser->update($user); |
|
246 | + $res = $fuser->update($user); |
|
247 | 247 | |
248 | 248 | if ($res < 0) |
249 | 249 | { |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | } |
257 | 257 | } else { // User creation |
258 | 258 | print $langs->transnoentities("UserCreate").' # '.$key.': login='.$fuser->login.', fullname='.$fuser->getFullName($langs); |
259 | - $res=$fuser->create($user); |
|
259 | + $res = $fuser->create($user); |
|
260 | 260 | |
261 | 261 | if ($res > 0) |
262 | 262 | { |
@@ -280,28 +280,28 @@ discard block |
||
280 | 280 | }*/ |
281 | 281 | } |
282 | 282 | |
283 | - if (! $error || $forcecommit) |
|
283 | + if (!$error || $forcecommit) |
|
284 | 284 | { |
285 | - if (! $error) print $langs->transnoentities("NoErrorCommitIsDone")."\n"; |
|
285 | + if (!$error) print $langs->transnoentities("NoErrorCommitIsDone")."\n"; |
|
286 | 286 | else print $langs->transnoentities("ErrorButCommitIsDone")."\n"; |
287 | 287 | $db->commit(); |
288 | 288 | } |
289 | 289 | else |
290 | 290 | { |
291 | - print $langs->transnoentities("ErrorSomeErrorWereFoundRollbackIsDone",$error)."\n"; |
|
291 | + print $langs->transnoentities("ErrorSomeErrorWereFoundRollbackIsDone", $error)."\n"; |
|
292 | 292 | $db->rollback(); |
293 | 293 | } |
294 | 294 | print "\n"; |
295 | 295 | } |
296 | 296 | else |
297 | 297 | { |
298 | - dol_print_error('',$ldap->error); |
|
298 | + dol_print_error('', $ldap->error); |
|
299 | 299 | $error++; |
300 | 300 | } |
301 | 301 | } |
302 | 302 | else |
303 | 303 | { |
304 | - dol_print_error('',$ldap->error); |
|
304 | + dol_print_error('', $ldap->error); |
|
305 | 305 | $error++; |
306 | 306 | } |
307 | 307 |
@@ -26,7 +26,7 @@ discard block |
||
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') { |
@@ -34,19 +34,19 @@ discard block |
||
34 | 34 | exit(-1); |
35 | 35 | } |
36 | 36 | |
37 | -if (! isset($argv[1]) || ! $argv[1]) { |
|
37 | +if (!isset($argv[1]) || !$argv[1]) { |
|
38 | 38 | print "Usage: ".$script_file." now\n"; |
39 | 39 | exit(-1); |
40 | 40 | } |
41 | -$now=$argv[1]; |
|
41 | +$now = $argv[1]; |
|
42 | 42 | |
43 | 43 | require_once $path."../../htdocs/master.inc.php"; |
44 | 44 | require_once DOL_DOCUMENT_ROOT."/core/class/ldap.class.php"; |
45 | 45 | require_once DOL_DOCUMENT_ROOT."/user/class/usergroup.class.php"; |
46 | 46 | |
47 | 47 | // Global variables |
48 | -$version=DOL_VERSION; |
|
49 | -$error=0; |
|
48 | +$version = DOL_VERSION; |
|
49 | +$error = 0; |
|
50 | 50 | |
51 | 51 | |
52 | 52 | /* |
@@ -55,7 +55,7 @@ discard block |
||
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 | /* |
61 | 61 | if (! $conf->global->LDAP_SYNCHRO_ACTIVE) |
@@ -74,12 +74,12 @@ discard block |
||
74 | 74 | $num = $db->num_rows($resql); |
75 | 75 | $i = 0; |
76 | 76 | |
77 | - $ldap=new Ldap(); |
|
77 | + $ldap = new Ldap(); |
|
78 | 78 | $ldap->connect_bind(); |
79 | 79 | |
80 | 80 | while ($i < $num) |
81 | 81 | { |
82 | - $ldap->error=""; |
|
82 | + $ldap->error = ""; |
|
83 | 83 | |
84 | 84 | $obj = $db->fetch_object($resql); |
85 | 85 | |
@@ -89,16 +89,16 @@ discard block |
||
89 | 89 | |
90 | 90 | print $langs->trans("UpdateGroup")." rowid=".$fgroup->id." ".$fgroup->name; |
91 | 91 | |
92 | - $oldobject=$fgroup; |
|
92 | + $oldobject = $fgroup; |
|
93 | 93 | |
94 | - $oldinfo=$oldobject->_load_ldap_info(); |
|
95 | - $olddn=$oldobject->_load_ldap_dn($oldinfo); |
|
94 | + $oldinfo = $oldobject->_load_ldap_info(); |
|
95 | + $olddn = $oldobject->_load_ldap_dn($oldinfo); |
|
96 | 96 | |
97 | - $info=$fgroup->_load_ldap_info(); |
|
98 | - $dn=$fgroup->_load_ldap_dn($info); |
|
97 | + $info = $fgroup->_load_ldap_info(); |
|
98 | + $dn = $fgroup->_load_ldap_dn($info); |
|
99 | 99 | |
100 | - $result=$ldap->add($dn,$info,$user); // Wil fail if already exists |
|
101 | - $result=$ldap->update($dn,$info,$user,$olddn); |
|
100 | + $result = $ldap->add($dn, $info, $user); // Wil fail if already exists |
|
101 | + $result = $ldap->update($dn, $info, $user, $olddn); |
|
102 | 102 | if ($result > 0) |
103 | 103 | { |
104 | 104 | print " - ".$langs->trans("OK"); |
@@ -27,7 +27,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -26,7 +26,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -26,7 +26,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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"); |
@@ -27,7 +27,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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"); |
@@ -28,7 +28,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -25,7 +25,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -25,7 +25,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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); |