@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | return $this->_form->display(); |
45 | 45 | } |
46 | 46 | |
47 | - public function definition_after_data(){ |
|
47 | + public function definition_after_data() { |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | public function return_form() |
@@ -64,9 +64,9 @@ discard block |
||
64 | 64 | * @param bool $slashed true means return data with addslashes applied |
65 | 65 | * @return object submitted data; NULL if not valid or not submitted |
66 | 66 | */ |
67 | - public function get_data($slashed=true) |
|
67 | + public function get_data($slashed = true) |
|
68 | 68 | { |
69 | - $cform =& $this->_form; |
|
69 | + $cform = & $this->_form; |
|
70 | 70 | |
71 | 71 | if ($this->is_submitted() and $this->is_validated()) { |
72 | 72 | $data = $cform->exportValues(null, $slashed); |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | if (empty($data)) { |
75 | 75 | return null; |
76 | 76 | } else { |
77 | - return (object)$data; |
|
77 | + return (object) $data; |
|
78 | 78 | } |
79 | 79 | } else { |
80 | 80 | return null; |
@@ -87,9 +87,9 @@ discard block |
||
87 | 87 | * @param bool $slashed true means return data with addslashes applied |
88 | 88 | * @return object submitted data; NULL if not submitted |
89 | 89 | */ |
90 | - public function get_submitted_data($slashed=true) |
|
90 | + public function get_submitted_data($slashed = true) |
|
91 | 91 | { |
92 | - $cform =& $this->_form; |
|
92 | + $cform = & $this->_form; |
|
93 | 93 | |
94 | 94 | if ($this->is_submitted()) { |
95 | 95 | $data = $cform->exportValues(null, $slashed); |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | if (empty($data)) { |
98 | 98 | return null; |
99 | 99 | } else { |
100 | - return (object)$data; |
|
100 | + return (object) $data; |
|
101 | 101 | } |
102 | 102 | } else { |
103 | 103 | return null; |
@@ -121,10 +121,10 @@ discard block |
||
121 | 121 | */ |
122 | 122 | public function is_cancelled() |
123 | 123 | { |
124 | - $cform =& $this->_form; |
|
125 | - if ($cform->isSubmitted()){ |
|
126 | - foreach ($cform->_cancelButtons as $cancelbutton){ |
|
127 | - if (optional_param($cancelbutton, 0, PARAM_RAW)){ |
|
124 | + $cform = & $this->_form; |
|
125 | + if ($cform->isSubmitted()) { |
|
126 | + foreach ($cform->_cancelButtons as $cancelbutton) { |
|
127 | + if (optional_param($cancelbutton, 0, PARAM_RAW)) { |
|
128 | 128 | return true; |
129 | 129 | } |
130 | 130 | } |
@@ -168,12 +168,12 @@ discard block |
||
168 | 168 | * |
169 | 169 | * @return bool true if form data valid |
170 | 170 | */ |
171 | - public function validate_defined_fields($validateonnosubmit=false) |
|
171 | + public function validate_defined_fields($validateonnosubmit = false) |
|
172 | 172 | { |
173 | 173 | static $validated = null; // one validation is enough |
174 | - $cform =& $this->_form; |
|
174 | + $cform = & $this->_form; |
|
175 | 175 | |
176 | - if ($this->no_submit_button_pressed() && empty($validateonnosubmit)){ |
|
176 | + if ($this->no_submit_button_pressed() && empty($validateonnosubmit)) { |
|
177 | 177 | return false; |
178 | 178 | } elseif ($validated === null) { |
179 | 179 | $internal_val = $cform->validate(); |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | |
192 | 192 | $data = $cform->exportValues(null, true); |
193 | 193 | $chamilo_val = $this->validation($data, $files); |
194 | - if ((is_array($chamilo_val) && count($chamilo_val)!==0)) { |
|
194 | + if ((is_array($chamilo_val) && count($chamilo_val) !== 0)) { |
|
195 | 195 | // non-empty array means errors |
196 | 196 | foreach ($chamilo_val as $element => $msg) { |
197 | 197 | $cform->setElementError($element, $msg); |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | return $nosubmit; |
218 | 218 | } |
219 | 219 | |
220 | - $cform =& $this->_form; |
|
220 | + $cform = & $this->_form; |
|
221 | 221 | $nosubmit = false; |
222 | 222 | if (!$this->is_submitted()) { |
223 | 223 | return false; |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | public function set_data($default_values, $slashed = false) |
247 | 247 | { |
248 | 248 | if (is_object($default_values)) { |
249 | - $default_values = (array)$default_values; |
|
249 | + $default_values = (array) $default_values; |
|
250 | 250 | } |
251 | 251 | $filter = $slashed ? 'stripslashes' : NULL; |
252 | 252 | $this->_form->setDefaults($default_values, $filter); |
@@ -266,14 +266,14 @@ discard block |
||
266 | 266 | } |
267 | 267 | |
268 | 268 | $errors = array(); |
269 | - $mform =& $this->_form; |
|
269 | + $mform = & $this->_form; |
|
270 | 270 | |
271 | 271 | // check the files |
272 | 272 | $status = $this->_upload_manager->preprocess_files(); |
273 | 273 | |
274 | 274 | // now check that we really want each file |
275 | 275 | foreach ($_FILES as $elname=>$file) { |
276 | - if ($mform->elementExists($elname) and $mform->getElementType($elname)=='file') { |
|
276 | + if ($mform->elementExists($elname) and $mform->getElementType($elname) == 'file') { |
|
277 | 277 | $required = $mform->isElementRequired($elname); |
278 | 278 | if (!empty($this->_upload_manager->files[$elname]['uploadlog']) && |
279 | 279 | empty($this->_upload_manager->files[$elname]['clear']) |
@@ -78,16 +78,16 @@ discard block |
||
78 | 78 | // res=-1 -> the user does not exist in the ldap database |
79 | 79 | // res=1 -> invalid password (user does exist) |
80 | 80 | |
81 | - if ($res==1) { //WRONG PASSWORD |
|
81 | + if ($res == 1) { //WRONG PASSWORD |
|
82 | 82 | //$errorMessage = "LDAP User or password incorrect, try again.<br />"; |
83 | 83 | if (isset($log)) unset($log); if (isset($uid)) unset($uid); |
84 | 84 | $loginLdapSucces = false; |
85 | 85 | } |
86 | - if ($res==-1) { //WRONG USERNAME |
|
86 | + if ($res == -1) { //WRONG USERNAME |
|
87 | 87 | //$errorMessage = "LDAP User or password incorrect, try again.<br />"; |
88 | 88 | $login_ldap_success = false; |
89 | 89 | } |
90 | - if ($res==0) { //LOGIN & PASSWORD OK - SUCCES |
|
90 | + if ($res == 0) { //LOGIN & PASSWORD OK - SUCCES |
|
91 | 91 | //$errorMessage = "Successful login w/ LDAP.<br>"; |
92 | 92 | $login_ldap_success = true; |
93 | 93 | } |
@@ -103,30 +103,30 @@ discard block |
||
103 | 103 | * @author Stefan De Wannemacker |
104 | 104 | * @author Roan Embrechts |
105 | 105 | */ |
106 | -function ldap_find_user_info ($login) { |
|
106 | +function ldap_find_user_info($login) { |
|
107 | 107 | //error_log('Entering ldap_find_user_info('.$login.')',0); |
108 | 108 | global $ldap_host, $ldap_port, $ldap_basedn, $ldap_rdn, $ldap_pass, $ldap_search_dn; |
109 | 109 | // basic sequence with LDAP is connect, bind, search, |
110 | 110 | // interpret search result, close connection |
111 | 111 | |
112 | 112 | //echo "Connecting ..."; |
113 | - $ldap_connect = ldap_connect( $ldap_host, $ldap_port); |
|
113 | + $ldap_connect = ldap_connect($ldap_host, $ldap_port); |
|
114 | 114 | ldap_set_version($ldap_connect); |
115 | 115 | if ($ldap_connect) { |
116 | 116 | //echo " Connect to LDAP server successful "; |
117 | 117 | //echo "Binding ..."; |
118 | 118 | $ldap_bind = false; |
119 | - $ldap_bind_res = ldap_handle_bind($ldap_connect,$ldap_bind); |
|
119 | + $ldap_bind_res = ldap_handle_bind($ldap_connect, $ldap_bind); |
|
120 | 120 | if ($ldap_bind_res) { |
121 | 121 | //echo " LDAP bind successful... "; |
122 | 122 | //echo " Searching for uid... "; |
123 | 123 | // Search surname entry |
124 | 124 | //OLD: $sr=ldap_search($ldapconnect,"dc=rug, dc=ac, dc=be", "uid=$login"); |
125 | 125 | //echo "<p> ldapDc = '$LDAPbasedn' </p>"; |
126 | - if(!empty($ldap_search_dn)) { |
|
127 | - $sr=ldap_search($ldap_connect, $ldap_search_dn, "uid=$login"); |
|
126 | + if (!empty($ldap_search_dn)) { |
|
127 | + $sr = ldap_search($ldap_connect, $ldap_search_dn, "uid=$login"); |
|
128 | 128 | } else { |
129 | - $sr=ldap_search($ldap_connect, $ldap_basedn, "uid=$login"); |
|
129 | + $sr = ldap_search($ldap_connect, $ldap_basedn, "uid=$login"); |
|
130 | 130 | } |
131 | 131 | //echo " Search result is ".$sr; |
132 | 132 | //echo " Number of entries returned is ".ldap_count_entries($ldapconnect,$sr); |
@@ -177,25 +177,25 @@ discard block |
||
177 | 177 | $password1 = $ldap_pass_placeholder; |
178 | 178 | $official_code = ''; |
179 | 179 | |
180 | - define ("STUDENT",5); |
|
181 | - define ("COURSEMANAGER",1); |
|
180 | + define("STUDENT", 5); |
|
181 | + define("COURSEMANAGER", 1); |
|
182 | 182 | |
183 | 183 | $tutor_field = api_get_setting('ldap_filled_tutor_field'); |
184 | 184 | $tutor_value = api_get_setting('ldap_filled_tutor_field_value'); |
185 | - if(empty($tutor_field)) { |
|
185 | + if (empty($tutor_field)) { |
|
186 | 186 | $status = STUDENT; |
187 | 187 | } else { |
188 | - if(empty($tutor_value)) { |
|
188 | + if (empty($tutor_value)) { |
|
189 | 189 | //in this case, we are assuming that the admin didn't give a criteria |
190 | 190 | // so that if the field is not empty, it is a tutor |
191 | - if(!empty($info_array[$tutor_field])) { |
|
191 | + if (!empty($info_array[$tutor_field])) { |
|
192 | 192 | $status = COURSEMANAGER; |
193 | 193 | } else { |
194 | 194 | $status = STUDENT; |
195 | 195 | } |
196 | 196 | } else { |
197 | 197 | //the tutor_value is filled, so we need to check the contents of the LDAP field |
198 | - if (is_array($info_array[$tutor_field]) && in_array($tutor_value,$info_array[$tutor_field])) { |
|
198 | + if (is_array($info_array[$tutor_field]) && in_array($tutor_value, $info_array[$tutor_field])) { |
|
199 | 199 | $status = COURSEMANAGER; |
200 | 200 | } else { |
201 | 201 | $status = STUDENT; |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | if (empty($language)) { $language = 'english'; } |
213 | 213 | $_userId = UserManager::create_user($prenom, $nom, $status, |
214 | 214 | $email, $uname, $password, $official_code, |
215 | - $language,'', '', 'ldap'); |
|
215 | + $language, '', '', 'ldap'); |
|
216 | 216 | |
217 | 217 | //echo "new user added to Chamilo, id = $_userId"; |
218 | 218 | |
@@ -246,58 +246,58 @@ discard block |
||
246 | 246 | * @param string password given by user |
247 | 247 | * @return int 0 if authentication succeeded, 1 if password was incorrect, -1 if it didn't belong to LDAP |
248 | 248 | */ |
249 | -function ldap_authentication_check ($uname, $passwd) { |
|
249 | +function ldap_authentication_check($uname, $passwd) { |
|
250 | 250 | //error_log('Entering ldap_authentication_check('.$uname.','.$passwd.')',0); |
251 | - global $ldap_host, $ldap_port, $ldap_basedn, $ldap_host2, $ldap_port2,$ldap_rdn,$ldap_pass; |
|
251 | + global $ldap_host, $ldap_port, $ldap_basedn, $ldap_host2, $ldap_port2, $ldap_rdn, $ldap_pass; |
|
252 | 252 | //error_log('Entering ldap_authentication_check('.$uname.','.$passwd.')',0); |
253 | 253 | // Establish anonymous connection with LDAP server |
254 | 254 | // Etablissement de la connexion anonyme avec le serveur LDAP |
255 | - $ds=ldap_connect($ldap_host,$ldap_port); |
|
255 | + $ds = ldap_connect($ldap_host, $ldap_port); |
|
256 | 256 | ldap_set_version($ds); |
257 | 257 | |
258 | 258 | $test_bind = false; |
259 | - $test_bind_res = ldap_handle_bind($ds,$test_bind); |
|
259 | + $test_bind_res = ldap_handle_bind($ds, $test_bind); |
|
260 | 260 | //if problem, use the replica |
261 | - if ($test_bind_res===false) { |
|
262 | - $ds=ldap_connect($ldap_host2,$ldap_port2); |
|
261 | + if ($test_bind_res === false) { |
|
262 | + $ds = ldap_connect($ldap_host2, $ldap_port2); |
|
263 | 263 | ldap_set_version($ds); |
264 | 264 | } else { |
265 | 265 | //error_log('Connected to server '.$ldap_host); |
266 | 266 | } |
267 | - if ($ds!==false) { |
|
267 | + if ($ds !== false) { |
|
268 | 268 | //Creation of filter containing values input by the user |
269 | 269 | // Here it might be necessary to use $filter="(samaccountName=$uname)"; - see http://support.chamilo.org/issues/4675 |
270 | - $filter="(uid=$uname)"; |
|
270 | + $filter = "(uid=$uname)"; |
|
271 | 271 | // Open anonymous LDAP connection |
272 | - $result=false; |
|
273 | - $ldap_bind_res = ldap_handle_bind($ds,$result); |
|
272 | + $result = false; |
|
273 | + $ldap_bind_res = ldap_handle_bind($ds, $result); |
|
274 | 274 | // Executing the search with the $filter parametr |
275 | 275 | //error_log('Searching for '.$filter.' on LDAP server',0); |
276 | - $sr=ldap_search($ds,$ldap_basedn,$filter); |
|
276 | + $sr = ldap_search($ds, $ldap_basedn, $filter); |
|
277 | 277 | $info = ldap_get_entries($ds, $sr); |
278 | - $dn=($info[0]["dn"]); |
|
278 | + $dn = ($info[0]["dn"]); |
|
279 | 279 | // debug !! echo"<br> dn = $dn<br> pass = $passwd<br>"; |
280 | 280 | // closing 1st connection |
281 | 281 | ldap_close($ds); |
282 | 282 | } |
283 | 283 | |
284 | 284 | // test the Distinguish Name from the 1st connection |
285 | - if ($dn=="") { |
|
286 | - return (-1); // doesn't belong to the addressbook |
|
285 | + if ($dn == "") { |
|
286 | + return (-1); // doesn't belong to the addressbook |
|
287 | 287 | } |
288 | 288 | //bug ldap.. if password empty, return 1! |
289 | - if ($passwd=="") { |
|
289 | + if ($passwd == "") { |
|
290 | 290 | return(1); |
291 | 291 | } |
292 | 292 | // Opening 2nd LDAP connection : Connection user for password check |
293 | - $ds=ldap_connect($ldap_host,$ldap_port); |
|
293 | + $ds = ldap_connect($ldap_host, $ldap_port); |
|
294 | 294 | ldap_set_version($ds); |
295 | 295 | if (!$test_bind) { |
296 | - $ds=ldap_connect($ldap_host2,$ldap_port2); |
|
296 | + $ds = ldap_connect($ldap_host2, $ldap_port2); |
|
297 | 297 | ldap_set_version($ds); |
298 | 298 | } |
299 | 299 | // return in case of wrong password connection error |
300 | - if (@ldap_bind( $ds, $dn , $passwd) === false) { |
|
300 | + if (@ldap_bind($ds, $dn, $passwd) === false) { |
|
301 | 301 | return (1); // invalid password |
302 | 302 | } else {// connection successfull |
303 | 303 | return (0); |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | function ldap_set_version(&$resource) { |
312 | 312 | //error_log('Entering ldap_set_version(&$resource)',0); |
313 | 313 | global $ldap_version; |
314 | - if ($ldap_version>2) { |
|
314 | + if ($ldap_version > 2) { |
|
315 | 315 | if (ldap_set_option($resource, LDAP_OPT_PROTOCOL_VERSION, 3)) { |
316 | 316 | //ok - don't do anything |
317 | 317 | } else { |
@@ -325,14 +325,14 @@ discard block |
||
325 | 325 | * @param resource The LDAP bind handler we will be modifying |
326 | 326 | * @return boolean Status of the bind assignment. True for success, false for failure. |
327 | 327 | */ |
328 | -function ldap_handle_bind(&$ldap_handler,&$ldap_bind) { |
|
328 | +function ldap_handle_bind(&$ldap_handler, &$ldap_bind) { |
|
329 | 329 | //error_log('Entering ldap_handle_bind(&$ldap_handler,&$ldap_bind)',0); |
330 | - global $ldap_rdn,$ldap_pass, $extldap_config; |
|
330 | + global $ldap_rdn, $ldap_pass, $extldap_config; |
|
331 | 331 | $ldap_rdn = $extldap_config['admin_dn']; |
332 | 332 | $ldap_pass = $extldap_config['admin_password']; |
333 | 333 | if (!empty($ldap_rdn) and !empty($ldap_pass)) { |
334 | 334 | //error_log('Trying authenticated login :'.$ldap_rdn.'/'.$ldap_pass,0); |
335 | - $ldap_bind = ldap_bind($ldap_handler,$ldap_rdn,$ldap_pass); |
|
335 | + $ldap_bind = ldap_bind($ldap_handler, $ldap_rdn, $ldap_pass); |
|
336 | 336 | if (!$ldap_bind) { |
337 | 337 | //error_log('Authenticated login failed',0); |
338 | 338 | //try in anonymous mode, you never know... |
@@ -358,40 +358,40 @@ discard block |
||
358 | 358 | |
359 | 359 | global $ldap_basedn, $ldap_host, $ldap_port, $ldap_rdn, $ldap_pass, $ldap_search_dn, $extldap_user_correspondance; |
360 | 360 | |
361 | - $keyword_firstname = isset($_GET['keyword_firstname']) ? trim(Database::escape_string($_GET['keyword_firstname'])): ''; |
|
361 | + $keyword_firstname = isset($_GET['keyword_firstname']) ? trim(Database::escape_string($_GET['keyword_firstname'])) : ''; |
|
362 | 362 | $keyword_lastname = isset($_GET['keyword_lastname']) ? trim(Database::escape_string($_GET['keyword_lastname'])) : ''; |
363 | 363 | $keyword_username = isset($_GET['keyword_username']) ? trim(Database::escape_string($_GET['keyword_username'])) : ''; |
364 | 364 | $keyword_type = isset($_GET['keyword_type']) ? Database::escape_string($_GET['keyword_type']) : ''; |
365 | 365 | |
366 | - $ldap_query=array(); |
|
366 | + $ldap_query = array(); |
|
367 | 367 | |
368 | 368 | if ($keyword_username != "") { |
369 | 369 | $ldap_query[] = str_replace('%username%', $keyword_username, $ldap_search_dn); |
370 | 370 | } else { |
371 | - if ($keyword_lastname!=""){ |
|
372 | - $ldap_query[]="(".$extldap_user_correspondance['lastname']."=".$keyword_lastname."*)"; |
|
371 | + if ($keyword_lastname != "") { |
|
372 | + $ldap_query[] = "(".$extldap_user_correspondance['lastname']."=".$keyword_lastname."*)"; |
|
373 | 373 | } |
374 | - if ($keyword_firstname!="") { |
|
375 | - $ldap_query[]="(".$extldap_user_correspondance['firstname']."=".$keyword_firstname."*)"; |
|
374 | + if ($keyword_firstname != "") { |
|
375 | + $ldap_query[] = "(".$extldap_user_correspondance['firstname']."=".$keyword_firstname."*)"; |
|
376 | 376 | } |
377 | 377 | } |
378 | - if ($keyword_type !="" && $keyword_type !="all") { |
|
379 | - $ldap_query[]="(employeeType=".$keyword_type.")"; |
|
378 | + if ($keyword_type != "" && $keyword_type != "all") { |
|
379 | + $ldap_query[] = "(employeeType=".$keyword_type.")"; |
|
380 | 380 | } |
381 | 381 | |
382 | - if (count($ldap_query)>1){ |
|
383 | - $str_query.="(& "; |
|
384 | - foreach ($ldap_query as $query){ |
|
385 | - $str_query.=" $query"; |
|
382 | + if (count($ldap_query) > 1) { |
|
383 | + $str_query .= "(& "; |
|
384 | + foreach ($ldap_query as $query) { |
|
385 | + $str_query .= " $query"; |
|
386 | 386 | } |
387 | - $str_query.=" )"; |
|
387 | + $str_query .= " )"; |
|
388 | 388 | } else { |
389 | - $str_query= count($ldap_query) > 0 ? $ldap_query[0] : null; |
|
389 | + $str_query = count($ldap_query) > 0 ? $ldap_query[0] : null; |
|
390 | 390 | } |
391 | 391 | |
392 | 392 | $ds = ldap_connect($ldap_host, $ldap_port); |
393 | 393 | ldap_set_version($ds); |
394 | - if ($ds && count($ldap_query)>0) { |
|
394 | + if ($ds && count($ldap_query) > 0) { |
|
395 | 395 | $r = false; |
396 | 396 | $res = ldap_handle_bind($ds, $r); |
397 | 397 | //$sr = ldap_search($ds, "ou=test-ou,$ldap_basedn", $str_query); |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | return $info; |
402 | 402 | |
403 | 403 | } else { |
404 | - if (count($ldap_query)!=0) |
|
404 | + if (count($ldap_query) != 0) |
|
405 | 405 | Display :: display_error_message(get_lang('LDAPConnectionError')); |
406 | 406 | return array(); |
407 | 407 | } |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | */ |
415 | 415 | function ldap_get_number_of_users() { |
416 | 416 | $info = ldap_get_users(); |
417 | - if (count($info)>0) { |
|
417 | + if (count($info) > 0) { |
|
418 | 418 | return $info['count']; |
419 | 419 | } else { |
420 | 420 | return 0; |
@@ -434,9 +434,9 @@ discard block |
||
434 | 434 | $is_western_name_order = api_is_western_name_order(); |
435 | 435 | if (isset($_GET['submit'])) { |
436 | 436 | $info = ldap_get_users(); |
437 | - if ($info['count']>0) { |
|
438 | - for ($key = 0; $key < $info["count"]; $key ++) { |
|
439 | - $user=array(); |
|
437 | + if ($info['count'] > 0) { |
|
438 | + for ($key = 0; $key < $info["count"]; $key++) { |
|
439 | + $user = array(); |
|
440 | 440 | // Get uid from dn |
441 | 441 | //YW: this might be a variation between LDAP 2 and LDAP 3, but in LDAP 3, the uid is in |
442 | 442 | //the corresponding index of the array |
@@ -470,9 +470,9 @@ discard block |
||
470 | 470 | * @return string Some HTML-code with modify-buttons |
471 | 471 | * @author Mustapha Alouani |
472 | 472 | */ |
473 | -function modify_filter($user_id,$url_params, $row) { |
|
474 | - $query_string="id[]=".$row[0]; |
|
475 | - if (!empty($_GET['id_session'])){ |
|
473 | +function modify_filter($user_id, $url_params, $row) { |
|
474 | + $query_string = "id[]=".$row[0]; |
|
475 | + if (!empty($_GET['id_session'])) { |
|
476 | 476 | $query_string .= '&id_session='.Security::remove_XSS($_GET['id_session']); |
477 | 477 | } |
478 | 478 | //$url_params_id="id=".$row[0]; |
@@ -497,7 +497,7 @@ discard block |
||
497 | 497 | $firstname = api_convert_encoding($data['cn'][0], api_get_system_encoding(), 'UTF-8'); |
498 | 498 | $email = $data['mail'][0]; |
499 | 499 | // Get uid from dn |
500 | - $dn_array=ldap_explode_dn($data['dn'],1); |
|
500 | + $dn_array = ldap_explode_dn($data['dn'], 1); |
|
501 | 501 | $username = $dn_array[0]; // uid is first key |
502 | 502 | $outab[] = $data['edupersonprimaryaffiliation'][0]; // Here, "student" |
503 | 503 | //$val = ldap_get_values_len($ds, $entry, "userPassword"); |
@@ -505,29 +505,29 @@ discard block |
||
505 | 505 | //$password = $val[0]; |
506 | 506 | // TODO the password, if encrypted at the source, will be encrypted twice, which makes it useless. Try to fix that. |
507 | 507 | $password = $data['userPassword'][0]; |
508 | - $structure=$data['edupersonprimaryorgunitdn'][0]; |
|
509 | - $array_structure=explode(",", $structure); |
|
510 | - $array_val=explode("=", $array_structure[0]); |
|
511 | - $etape=$array_val[1]; |
|
512 | - $array_val=explode("=", $array_structure[1]); |
|
513 | - $annee=$array_val[1]; |
|
508 | + $structure = $data['edupersonprimaryorgunitdn'][0]; |
|
509 | + $array_structure = explode(",", $structure); |
|
510 | + $array_val = explode("=", $array_structure[0]); |
|
511 | + $etape = $array_val[1]; |
|
512 | + $array_val = explode("=", $array_structure[1]); |
|
513 | + $annee = $array_val[1]; |
|
514 | 514 | // To ease management, we add the step-year (etape-annee) code |
515 | - $official_code=$etape."-".$annee; |
|
516 | - $auth_source='ldap'; |
|
515 | + $official_code = $etape."-".$annee; |
|
516 | + $auth_source = 'ldap'; |
|
517 | 517 | // No expiration date for students (recover from LDAP's shadow expiry) |
518 | - $expiration_date=''; |
|
519 | - $active=1; |
|
520 | - if(empty($status)){$status = 5;} |
|
521 | - if(empty($phone)){$phone = '';} |
|
522 | - if(empty($picture_uri)){$picture_uri = '';} |
|
518 | + $expiration_date = ''; |
|
519 | + $active = 1; |
|
520 | + if (empty($status)) {$status = 5; } |
|
521 | + if (empty($phone)) {$phone = ''; } |
|
522 | + if (empty($picture_uri)) {$picture_uri = ''; } |
|
523 | 523 | // Adding user |
524 | 524 | $user_id = 0; |
525 | 525 | if (UserManager::is_username_available($username)) { |
526 | - $user_id = UserManager::create_user($firstname,$lastname,$status,$email,$username,$password,$official_code,api_get_setting('platformLanguage'),$phone,$picture_uri,$auth_source,$expiration_date,$active); |
|
526 | + $user_id = UserManager::create_user($firstname, $lastname, $status, $email, $username, $password, $official_code, api_get_setting('platformLanguage'), $phone, $picture_uri, $auth_source, $expiration_date, $active); |
|
527 | 527 | } else { |
528 | 528 | if ($update_if_exists) { |
529 | 529 | $user = api_get_user_info($username); |
530 | - $user_id=$user['user_id']; |
|
530 | + $user_id = $user['user_id']; |
|
531 | 531 | UserManager::update_user($user_id, $firstname, $lastname, $username, null, null, $email, $status, $official_code, $phone, $picture_uri, $expiration_date, $active); |
532 | 532 | } |
533 | 533 | } |
@@ -544,21 +544,21 @@ discard block |
||
544 | 544 | |
545 | 545 | // Database Table Definitions |
546 | 546 | $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION); |
547 | - $tbl_session_rel_class = Database::get_main_table(TABLE_MAIN_SESSION_CLASS); |
|
547 | + $tbl_session_rel_class = Database::get_main_table(TABLE_MAIN_SESSION_CLASS); |
|
548 | 548 | $tbl_session_rel_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE); |
549 | 549 | $tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); |
550 | 550 | $tbl_course = Database::get_main_table(TABLE_MAIN_COURSE); |
551 | 551 | $tbl_user = Database::get_main_table(TABLE_MAIN_USER); |
552 | 552 | $tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER); |
553 | - $tbl_class = Database::get_main_table(TABLE_MAIN_CLASS); |
|
554 | - $tbl_class_user = Database::get_main_table(TABLE_MAIN_CLASS_USER); |
|
553 | + $tbl_class = Database::get_main_table(TABLE_MAIN_CLASS); |
|
554 | + $tbl_class_user = Database::get_main_table(TABLE_MAIN_CLASS_USER); |
|
555 | 555 | |
556 | 556 | $id_session = (int) $id_session; |
557 | 557 | // Once users are imported in the users base, we can assign them to the session |
558 | - $result=Database::query("SELECT c_id FROM $tbl_session_rel_course WHERE session_id ='$id_session'"); |
|
559 | - $CourseList=array(); |
|
560 | - while ($row=Database::fetch_array($result)) { |
|
561 | - $CourseList[]=$row['c_id']; |
|
558 | + $result = Database::query("SELECT c_id FROM $tbl_session_rel_course WHERE session_id ='$id_session'"); |
|
559 | + $CourseList = array(); |
|
560 | + while ($row = Database::fetch_array($result)) { |
|
561 | + $CourseList[] = $row['c_id']; |
|
562 | 562 | } |
563 | 563 | foreach ($CourseList as $enreg_course) { |
564 | 564 | foreach ($UserList as $enreg_user) { |
@@ -569,21 +569,21 @@ discard block |
||
569 | 569 | "('$id_session','$enreg_course','$enreg_user')"); |
570 | 570 | } |
571 | 571 | $sql = "SELECT COUNT(user_id) as nbUsers ". |
572 | - " FROM $tbl_session_rel_course_rel_user " . |
|
572 | + " FROM $tbl_session_rel_course_rel_user ". |
|
573 | 573 | " WHERE session_id='$id_session' ". |
574 | 574 | " AND c_id='$enreg_course'"; |
575 | 575 | $rs = Database::query($sql); |
576 | 576 | list($nbr_users) = Database::fetch_array($rs); |
577 | 577 | Database::query("UPDATE $tbl_session_rel_course ". |
578 | - " SET nbr_users=$nbr_users " . |
|
578 | + " SET nbr_users=$nbr_users ". |
|
579 | 579 | " WHERE session_id='$id_session' ". |
580 | 580 | " AND c_id='$enreg_course'"); |
581 | 581 | } |
582 | 582 | foreach ($UserList as $enreg_user) { |
583 | 583 | $enreg_user = (int) $enreg_user; |
584 | 584 | Database::query("INSERT IGNORE INTO $tbl_session_rel_user ". |
585 | - " (session_id, user_id, registered_at) " . |
|
586 | - " VALUES('$id_session','$enreg_user', '" . api_get_utc_datetime() . "')"); |
|
585 | + " (session_id, user_id, registered_at) ". |
|
586 | + " VALUES('$id_session','$enreg_user', '".api_get_utc_datetime()."')"); |
|
587 | 587 | } |
588 | 588 | // We update the number of users in the session |
589 | 589 | $sql = "SELECT COUNT(user_id) as nbUsers FROM $tbl_session_rel_user ". |
@@ -598,13 +598,13 @@ discard block |
||
598 | 598 | function syncro_users() { |
599 | 599 | global $ldap_basedn, $ldap_host, $ldap_port, $ldap_rdn, $ldap_pass, $ldap_search_dn; |
600 | 600 | echo "Connecting ..."; |
601 | - $ldap_connect = ldap_connect( $ldap_host, $ldap_port); |
|
601 | + $ldap_connect = ldap_connect($ldap_host, $ldap_port); |
|
602 | 602 | ldap_set_version($ldap_connect); |
603 | 603 | if ($ldap_connect) { |
604 | 604 | //echo " Connect to LDAP server successful "; |
605 | 605 | //echo "Binding ..."; |
606 | 606 | $ldap_bind = false; |
607 | - $ldap_bind_res = ldap_handle_bind($ldap_connect,$ldap_bind); |
|
607 | + $ldap_bind_res = ldap_handle_bind($ldap_connect, $ldap_bind); |
|
608 | 608 | if ($ldap_bind_res) { |
609 | 609 | //echo " LDAP bind successful... "; |
610 | 610 | //echo " Searching for uid... "; |
@@ -612,7 +612,7 @@ discard block |
||
612 | 612 | //OLD: $sr=ldap_search($ldapconnect,"dc=rug, dc=ac, dc=be", "uid=$login"); |
613 | 613 | //echo "<p> ldapDc = '$LDAPbasedn' </p>"; |
614 | 614 | $all_user_query = "uid=*"; |
615 | - if(!empty($ldap_search_dn)) { |
|
615 | + if (!empty($ldap_search_dn)) { |
|
616 | 616 | $sr = ldap_search($ldap_connect, $ldap_search_dn, $all_user_query); |
617 | 617 | } else { |
618 | 618 | $sr = ldap_search($ldap_connect, $ldap_basedn, $all_user_query); |
@@ -620,7 +620,7 @@ discard block |
||
620 | 620 | //echo " Number of entries returned is ".ldap_count_entries($ldapconnect,$sr); |
621 | 621 | //echo " Getting entries ..."; |
622 | 622 | $info = ldap_get_entries($ldap_connect, $sr); |
623 | - for ($key = 0; $key < $info['count']; $key ++) { |
|
623 | + for ($key = 0; $key < $info['count']; $key++) { |
|
624 | 624 | $user_id = ldap_add_user_by_array($info[$key], false); |
625 | 625 | if ($user_id) { |
626 | 626 | echo "User #$user_id created "; |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | if (!$alreadyInstalled) { |
48 | 48 | $global_error_code = 2; |
49 | 49 | // The system has not been installed yet. |
50 | - require_once __DIR__ . '/../inc/global_error_message.inc.php'; |
|
50 | + require_once __DIR__.'/../inc/global_error_message.inc.php'; |
|
51 | 51 | die(); |
52 | 52 | } |
53 | 53 | } |
@@ -158,9 +158,9 @@ discard block |
||
158 | 158 | $request_url_root = ''; |
159 | 159 | if (empty($_SERVER['HTTP_HOST'])) { |
160 | 160 | if (empty($_SERVER['SERVER_NAME'])) { |
161 | - $request_url_root = $protocol . 'localhost/'; |
|
161 | + $request_url_root = $protocol.'localhost/'; |
|
162 | 162 | } else { |
163 | - $request_url_root = $protocol . $_SERVER['SERVER_NAME'] . '/'; |
|
163 | + $request_url_root = $protocol.$_SERVER['SERVER_NAME'].'/'; |
|
164 | 164 | } |
165 | 165 | } else { |
166 | 166 | $request_url_root = $protocol.$_SERVER['HTTP_HOST'].'/'; |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | } |
455 | 455 | |
456 | 456 | if (!empty($language_priority1) && api_get_language_from_type($language_priority1) !== false) { |
457 | - $language_interface = api_get_language_from_type($language_priority1); |
|
457 | + $language_interface = api_get_language_from_type($language_priority1); |
|
458 | 458 | } else { |
459 | 459 | if (isset($_course['language'])) { |
460 | 460 | $language_interface = $_course['language']; |
@@ -25,16 +25,16 @@ |
||
25 | 25 | $audioFileName = Database::escape_string($audioFileName); |
26 | 26 | $audioFileName = api_replace_dangerous_char($audioFileName); |
27 | 27 | $audioFileName = disable_dangerous_file($audioFileName); |
28 | -$audioDir = Security::remove_XSS($audioDir); |
|
28 | +$audioDir = Security::remove_XSS($audioDir); |
|
29 | 29 | |
30 | -$dirBaseDocuments = api_get_path(SYS_COURSE_PATH) . $courseInfo['path'] . '/document'; |
|
31 | -$saveDir = $dirBaseDocuments . $audioDir; |
|
30 | +$dirBaseDocuments = api_get_path(SYS_COURSE_PATH).$courseInfo['path'].'/document'; |
|
31 | +$saveDir = $dirBaseDocuments.$audioDir; |
|
32 | 32 | |
33 | 33 | if (!is_dir($saveDir)) { |
34 | 34 | DocumentManager::createDefaultAudioFolder($courseInfo); |
35 | 35 | } |
36 | 36 | |
37 | -$documentPath = $saveDir . '/' . $audioFileName; |
|
37 | +$documentPath = $saveDir.'/'.$audioFileName; |
|
38 | 38 | |
39 | 39 | $file['file'] = $file; |
40 | 40 |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | // Do not use here check Fileinfo method because return: text/plain |
49 | 49 | |
50 | 50 | $dirBaseDocuments = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'; |
51 | -$saveDir = $dirBaseDocuments . $wamidir; |
|
51 | +$saveDir = $dirBaseDocuments.$wamidir; |
|
52 | 52 | |
53 | 53 | if (!is_dir($saveDir)) { |
54 | 54 | DocumentManager::createDefaultAudioFolder($_course); |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | ob_start(); |
89 | 89 | |
90 | 90 | // Strangely the file path changes with a double extension |
91 | -copy($documentPath, $documentPath . '.wav'); |
|
91 | +copy($documentPath, $documentPath.'.wav'); |
|
92 | 92 | |
93 | 93 | $documentData = DocumentManager::upload_document( |
94 | 94 | $file, |
@@ -149,8 +149,8 @@ discard block |
||
149 | 149 | ); |
150 | 150 | } |
151 | 151 | } else { |
152 | - foreach($document_data['parents'] as $document_sub_data) { |
|
153 | - if (!isset($_GET['createdir']) && $document_sub_data['id'] == $document_data['id']) { |
|
152 | + foreach ($document_data['parents'] as $document_sub_data) { |
|
153 | + if (!isset($_GET['createdir']) && $document_sub_data['id'] == $document_data['id']) { |
|
154 | 154 | $document_sub_data['document_url'] = '#'; |
155 | 155 | } |
156 | 156 | $interbreadcrumb[] = array( |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | } |
181 | 181 | $js_glossary_in_documents = ''; |
182 | 182 | |
183 | -$js_glossary_in_documents = ' |
|
183 | +$js_glossary_in_documents = ' |
|
184 | 184 | $.frameReady(function(){ |
185 | 185 | // $("<div>I am a div courses</div>").prependTo("body"); |
186 | 186 | }, "top.mainFrame", |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | // PDF should be displayed with viewerJS |
201 | 201 | $web_odf_supported_files[] = 'pdf'; |
202 | 202 | if (in_array(strtolower($pathinfo['extension']), $web_odf_supported_files)) { |
203 | - $show_web_odf = true; |
|
203 | + $show_web_odf = true; |
|
204 | 204 | /* |
205 | 205 | $htmlHeadXtra[] = api_get_js('webodf/webodf.js'); |
206 | 206 | $htmlHeadXtra[] = api_get_css(api_get_path(WEB_LIBRARY_PATH).'javascript/webodf/webodf.css'); |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | $htmlHeadXtra[] = api_get_js('highlight/highlight.pack.js'); |
244 | 244 | $htmlHeadXtra[] = api_get_css(api_get_path(WEB_CSS_PATH).'chat.css'); |
245 | 245 | $htmlHeadXtra[] = api_get_css( |
246 | - api_get_path(WEB_LIBRARY_PATH) . 'javascript/highlight/styles/github.css' |
|
246 | + api_get_path(WEB_LIBRARY_PATH).'javascript/highlight/styles/github.css' |
|
247 | 247 | ); |
248 | 248 | $htmlHeadXtra[] = ' |
249 | 249 | <script> |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | $execute_iframe = true; |
255 | 255 | if ($jplayer_supported) { |
256 | 256 | $extension = api_strtolower($pathinfo['extension']); |
257 | - if ($extension == 'mp4') { |
|
257 | + if ($extension == 'mp4') { |
|
258 | 258 | $extension = 'm4v'; |
259 | 259 | } |
260 | 260 | $js_path = api_get_path(WEB_LIBRARY_PATH).'javascript/'; |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | $execute_iframe = false; |
296 | 296 | } |
297 | 297 | |
298 | -$is_freemind_available = $pathinfo['extension']=='mm' && api_get_setting('enable_freemind') == 'true'; |
|
298 | +$is_freemind_available = $pathinfo['extension'] == 'mm' && api_get_setting('enable_freemind') == 'true'; |
|
299 | 299 | if ($is_freemind_available) { |
300 | 300 | $execute_iframe = false; |
301 | 301 | } |
@@ -339,18 +339,18 @@ discard block |
||
339 | 339 | $file_url_web = $file_url.'?'.api_get_cidreq(); |
340 | 340 | |
341 | 341 | if (in_array(strtolower($pathinfo['extension']), array('html', "htm"))) { |
342 | - echo '<a class="btn btn-default" href="' . $file_url_web . '" target="_blank">' . get_lang('CutPasteLink') . '</a>'; |
|
342 | + echo '<a class="btn btn-default" href="'.$file_url_web.'" target="_blank">'.get_lang('CutPasteLink').'</a>'; |
|
343 | 343 | } |
344 | 344 | |
345 | 345 | if ($show_web_odf) { |
346 | 346 | $browser = api_get_navigator(); |
347 | - $pdfUrl = api_get_path(WEB_LIBRARY_PATH) . 'javascript/ViewerJS/index.html#' . $file_url; |
|
347 | + $pdfUrl = api_get_path(WEB_LIBRARY_PATH).'javascript/ViewerJS/index.html#'.$file_url; |
|
348 | 348 | if ($browser['name'] == 'Mozilla' && preg_match('|.*\.pdf|i', $header_file)) { |
349 | 349 | $pdfUrl = $file_url; |
350 | 350 | } |
351 | 351 | echo '<div id="viewerJS">'; |
352 | 352 | echo '<iframe id="viewerJSContent" frameborder="0" allowfullscreen="allowfullscreen" webkitallowfullscreen style="width:100%;" |
353 | - src="' . $pdfUrl. '"> |
|
353 | + src="' . $pdfUrl.'"> |
|
354 | 354 | </iframe>'; |
355 | 355 | echo '</div>'; |
356 | 356 | } elseif (!$originIsLearnpath) { |
@@ -90,12 +90,12 @@ |
||
90 | 90 | $file_url_web = api_get_path(WEB_COURSE_PATH).$_course['path'].'/document'.$header_file.'?'.api_get_cidreq(); |
91 | 91 | $pathinfo = pathinfo($header_file); |
92 | 92 | |
93 | -if ($pathinfo['extension']=='swf') { |
|
94 | - $width='83%'; |
|
95 | - $height='83%'; |
|
93 | +if ($pathinfo['extension'] == 'swf') { |
|
94 | + $width = '83%'; |
|
95 | + $height = '83%'; |
|
96 | 96 | } else { |
97 | - $width='100%'; |
|
98 | - $height='100%'; |
|
97 | + $width = '100%'; |
|
98 | + $height = '100%'; |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | echo '<iframe border="0" frameborder="0" scrolling="no" style="width:'.$width.'; height:'.$height.';background-color:#ffffff;" id="mainFrame" name="mainFrame" src="'.$file_url_web.'?'.api_get_cidreq().'&rand='.mt_rand(1, 1000).'"></iframe>'; |
@@ -15,16 +15,16 @@ discard block |
||
15 | 15 | //Add the JS needed to use the jqgrid |
16 | 16 | $htmlHeadXtra[] = api_get_jqgrid_js(); |
17 | 17 | // setting breadcrumbs |
18 | -$interbreadcrumb[] = array('url' => 'index.php','name' => get_lang('PlatformAdmin')); |
|
18 | +$interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin')); |
|
19 | 19 | $action = isset($_GET['action']) ? $_GET['action'] : null; |
20 | 20 | if ($action == 'add') { |
21 | - $interbreadcrumb[] = array('url' => 'usergroups.php','name' => get_lang('Classes')); |
|
22 | - $interbreadcrumb[] = array('url' => '#','name' => get_lang('Add')); |
|
21 | + $interbreadcrumb[] = array('url' => 'usergroups.php', 'name' => get_lang('Classes')); |
|
22 | + $interbreadcrumb[] = array('url' => '#', 'name' => get_lang('Add')); |
|
23 | 23 | } elseif ($action == 'edit') { |
24 | - $interbreadcrumb[] = array('url' => 'usergroups.php','name' => get_lang('Classes')); |
|
25 | - $interbreadcrumb[] = array('url' => '#','name' => get_lang('Edit')); |
|
24 | + $interbreadcrumb[] = array('url' => 'usergroups.php', 'name' => get_lang('Classes')); |
|
25 | + $interbreadcrumb[] = array('url' => '#', 'name' => get_lang('Edit')); |
|
26 | 26 | } else { |
27 | - $interbreadcrumb[] = array('url' => '#','name' => get_lang('Classes')); |
|
27 | + $interbreadcrumb[] = array('url' => '#', 'name' => get_lang('Classes')); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | // The header. |
@@ -55,13 +55,13 @@ discard block |
||
55 | 55 | ); |
56 | 56 | |
57 | 57 | //Column config |
58 | -$column_model = array( |
|
59 | - array('name'=>'name', 'index'=>'name', 'width'=>'35', 'align'=>'left'), |
|
60 | - array('name'=>'users', 'index'=>'users', 'width'=>'15', 'align'=>'left'), |
|
61 | - array('name'=>'courses', 'index'=>'courses', 'width'=>'15', 'align'=>'left'), |
|
62 | - array('name'=>'sessions', 'index'=>'sessions', 'width'=>'15', 'align'=>'left'), |
|
63 | - array('name'=>'group_type', 'index'=>'group_type', 'width'=>'15', 'align'=>'center'), |
|
64 | - array('name'=>'actions', 'index'=>'actions', 'width'=>'20', 'align'=>'center', 'sortable'=>'false','formatter'=>'action_formatter'), |
|
58 | +$column_model = array( |
|
59 | + array('name'=>'name', 'index'=>'name', 'width'=>'35', 'align'=>'left'), |
|
60 | + array('name'=>'users', 'index'=>'users', 'width'=>'15', 'align'=>'left'), |
|
61 | + array('name'=>'courses', 'index'=>'courses', 'width'=>'15', 'align'=>'left'), |
|
62 | + array('name'=>'sessions', 'index'=>'sessions', 'width'=>'15', 'align'=>'left'), |
|
63 | + array('name'=>'group_type', 'index'=>'group_type', 'width'=>'15', 'align'=>'center'), |
|
64 | + array('name'=>'actions', 'index'=>'actions', 'width'=>'20', 'align'=>'center', 'sortable'=>'false', 'formatter'=>'action_formatter'), |
|
65 | 65 | ); |
66 | 66 | |
67 | 67 | //Autowidth |
@@ -73,11 +73,11 @@ discard block |
||
73 | 73 | //With this function we can add actions to the jgrid |
74 | 74 | $action_links = 'function action_formatter (cellvalue, options, rowObject) { |
75 | 75 | return \'' |
76 | - .' <a href="add_users_to_usergroup.php?id=\'+options.rowId+\'">' . Display::return_icon('user_to_class.png', get_lang('SubscribeUsersToClass'), null, ICON_SIZE_MEDIUM) . '</a>' |
|
77 | - .' <a href="add_courses_to_usergroup.php?id=\'+options.rowId+\'">' . Display::return_icon('course_to_class.png', get_lang('SubscribeClassToCourses'), null, ICON_SIZE_MEDIUM) . '</a>' |
|
78 | - .' <a href="add_sessions_to_usergroup.php?id=\'+options.rowId+\'">' . Display::return_icon('sessions_to_class.png', get_lang('SubscribeClassToSessions'), null, ICON_SIZE_MEDIUM) . '</a>' |
|
79 | - .' <a href="?action=edit&id=\'+options.rowId+\'">' . Display::return_icon('edit.png', get_lang('Edit'), null, ICON_SIZE_SMALL) . '</a>' |
|
80 | - .' <a onclick="javascript:if(!confirm('."\'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES))."\'".')) return false;" href="?action=delete&id=\'+options.rowId+\'">' . Display::return_icon('delete.png', get_lang('Delete'), null, ICON_SIZE_SMALL) . '</a>\'; |
|
76 | + .' <a href="add_users_to_usergroup.php?id=\'+options.rowId+\'">'.Display::return_icon('user_to_class.png', get_lang('SubscribeUsersToClass'), null, ICON_SIZE_MEDIUM).'</a>' |
|
77 | + .' <a href="add_courses_to_usergroup.php?id=\'+options.rowId+\'">'.Display::return_icon('course_to_class.png', get_lang('SubscribeClassToCourses'), null, ICON_SIZE_MEDIUM).'</a>' |
|
78 | + .' <a href="add_sessions_to_usergroup.php?id=\'+options.rowId+\'">'.Display::return_icon('sessions_to_class.png', get_lang('SubscribeClassToSessions'), null, ICON_SIZE_MEDIUM).'</a>' |
|
79 | + .' <a href="?action=edit&id=\'+options.rowId+\'">'.Display::return_icon('edit.png', get_lang('Edit'), null, ICON_SIZE_SMALL).'</a>' |
|
80 | + .' <a onclick="javascript:if(!confirm('."\'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES))."\'".')) return false;" href="?action=delete&id=\'+options.rowId+\'">'.Display::return_icon('delete.png', get_lang('Delete'), null, ICON_SIZE_SMALL).'</a>\'; |
|
81 | 81 | }'; |
82 | 82 | |
83 | 83 | ?> |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | } else { |
129 | 129 | echo '<div class="actions">'; |
130 | 130 | echo '<a href="'.api_get_self().'">'. |
131 | - Display::return_icon('back.png',get_lang('Back'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
131 | + Display::return_icon('back.png', get_lang('Back'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
132 | 132 | echo '</div>'; |
133 | 133 | $token = Security::get_token(); |
134 | 134 | $form->addElement('hidden', 'sec_token'); |
@@ -8,47 +8,47 @@ discard block |
||
8 | 8 | */ |
9 | 9 | exit(); //not yet functional, needs to be revised |
10 | 10 | |
11 | -$cidReset=true; |
|
11 | +$cidReset = true; |
|
12 | 12 | |
13 | 13 | require('../inc/global.inc.php'); |
14 | 14 | $libpath = api_get_path(LIBRARY_PATH); |
15 | 15 | require_once('../auth/ldap/authldap.php'); |
16 | -$annee_base=date('Y'); |
|
16 | +$annee_base = date('Y'); |
|
17 | 17 | // setting the section (for the tabs) |
18 | 18 | $this_section = SECTION_PLATFORM_ADMIN; |
19 | 19 | //api_protect_admin_script(); // on vire la secu... qui n'a pas lieu d'etre ici (script de synchro) |
20 | 20 | |
21 | 21 | // setting breadcrumbs |
22 | -$interbreadcrumb[]=array('url' => 'index.php',"name" => get_lang('PlatformAdmin')); |
|
23 | -$interbreadcrumb[]=array('url' => api_get_self(),"name" => "Liste des sessions"); |
|
22 | +$interbreadcrumb[] = array('url' => 'index.php', "name" => get_lang('PlatformAdmin')); |
|
23 | +$interbreadcrumb[] = array('url' => api_get_self(), "name" => "Liste des sessions"); |
|
24 | 24 | |
25 | 25 | // Database Table Definitions |
26 | 26 | $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION); |
27 | -$tbl_session_rel_class = Database::get_main_table(TABLE_MAIN_SESSION_CLASS); |
|
28 | -$tbl_session_rel_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE); |
|
29 | -$tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); |
|
30 | -$tbl_course = Database::get_main_table(TABLE_MAIN_COURSE); |
|
31 | -$tbl_user = Database::get_main_table(TABLE_MAIN_USER); |
|
32 | -$tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER); |
|
33 | -$tbl_class = Database::get_main_table(TABLE_MAIN_CLASS); |
|
34 | -$tbl_class_user = Database::get_main_table(TABLE_MAIN_CLASS_USER); |
|
27 | +$tbl_session_rel_class = Database::get_main_table(TABLE_MAIN_SESSION_CLASS); |
|
28 | +$tbl_session_rel_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE); |
|
29 | +$tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); |
|
30 | +$tbl_course = Database::get_main_table(TABLE_MAIN_COURSE); |
|
31 | +$tbl_user = Database::get_main_table(TABLE_MAIN_USER); |
|
32 | +$tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER); |
|
33 | +$tbl_class = Database::get_main_table(TABLE_MAIN_CLASS); |
|
34 | +$tbl_class_user = Database::get_main_table(TABLE_MAIN_CLASS_USER); |
|
35 | 35 | |
36 | -$tbl_session_rel_etape = "session_rel_etape"; |
|
36 | +$tbl_session_rel_etape = "session_rel_etape"; |
|
37 | 37 | |
38 | -$message=""; |
|
38 | +$message = ""; |
|
39 | 39 | |
40 | -$result=Database::query("SELECT id, name FROM $tbl_session"); |
|
41 | -$Sessions=Database::store_result($result); |
|
40 | +$result = Database::query("SELECT id, name FROM $tbl_session"); |
|
41 | +$Sessions = Database::store_result($result); |
|
42 | 42 | |
43 | -$result=Database::query($sql); |
|
44 | -$users=Database::store_result($result); |
|
43 | +$result = Database::query($sql); |
|
44 | +$users = Database::store_result($result); |
|
45 | 45 | |
46 | -foreach($Sessions as $session){ |
|
46 | +foreach ($Sessions as $session) { |
|
47 | 47 | $id_session = $session['id']; |
48 | 48 | $name_session = $session['name']; |
49 | - $UserList=array(); |
|
50 | - $UserUpdate=array(); |
|
51 | - $UserAdd=array(); |
|
49 | + $UserList = array(); |
|
50 | + $UserUpdate = array(); |
|
51 | + $UserAdd = array(); |
|
52 | 52 | |
53 | 53 | // Parse des code etape de la session |
54 | 54 | /* |
@@ -65,8 +65,8 @@ discard block |
||
65 | 65 | { |
66 | 66 | $r = false; |
67 | 67 | $res = ldap_handle_bind($ds, $r); |
68 | - $UserList=array(); |
|
69 | - if($result !== false) |
|
68 | + $UserList = array(); |
|
69 | + if ($result !== false) |
|
70 | 70 | { |
71 | 71 | //while($row = Database::fetch_array($result)) |
72 | 72 | //{ |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | //$sr = @ ldap_search($ds, "ou=people,$LDAPbasedn", "edupersonorgunitdn=ou=$etape,ou=$annee,ou=diploma,$LDAPbasedn"); |
82 | 82 | $sr = @ ldap_search($ds, $ldap_basedn, '(uid=*)'); |
83 | 83 | $info = ldap_get_entries($ds, $sr); |
84 | - for ($key = 0; $key < $info["count"]; $key ++) |
|
84 | + for ($key = 0; $key < $info["count"]; $key++) |
|
85 | 85 | { |
86 | 86 | echo "<pre>"; |
87 | 87 | print_r($info[$key]); |
@@ -90,28 +90,28 @@ discard block |
||
90 | 90 | $firstname = api_utf8_decode($info[$key]["givenname"][0]); |
91 | 91 | $email = $info[$key]["mail"][0]; |
92 | 92 | // Get uid from dn |
93 | - $dn_array=ldap_explode_dn($info[$key]["dn"],1); |
|
93 | + $dn_array = ldap_explode_dn($info[$key]["dn"], 1); |
|
94 | 94 | $username = $dn_array[0]; // uid is first key |
95 | 95 | $outab[] = $info[$key]["edupersonprimaryaffiliation"][0]; // Ici "student" |
96 | 96 | $val = ldap_get_values_len($ds, $sr, "userPassword"); |
97 | 97 | $password = $val[0]; |
98 | 98 | // Pour faciliter la gestion on ajoute le code "etape-annee" |
99 | - $official_code=$etape."-".$annee; |
|
100 | - $auth_source="ldap"; |
|
99 | + $official_code = $etape."-".$annee; |
|
100 | + $auth_source = "ldap"; |
|
101 | 101 | // Pas de date d'expiration d'etudiant (a recuperer par rapport au shadow expire LDAP) |
102 | - $expiration_date=''; |
|
103 | - $active=1; |
|
102 | + $expiration_date = ''; |
|
103 | + $active = 1; |
|
104 | 104 | // Ajout de l'utilisateur |
105 | 105 | if (UserManager::is_username_available($username)) { |
106 | - $user_id = UserManager::create_user($firstname,$lastname,$status,$email,$username,$password,$official_code,api_get_setting('platformLanguage'),$phone,$picture_uri,$auth_source,$expiration_date,$active); |
|
107 | - $UserAdd[]=$user_id; |
|
106 | + $user_id = UserManager::create_user($firstname, $lastname, $status, $email, $username, $password, $official_code, api_get_setting('platformLanguage'), $phone, $picture_uri, $auth_source, $expiration_date, $active); |
|
107 | + $UserAdd[] = $user_id; |
|
108 | 108 | } else { |
109 | 109 | $user = api_get_user_info_from_username($username); |
110 | - $user_id=$user['user_id']; |
|
110 | + $user_id = $user['user_id']; |
|
111 | 111 | UserManager::update_user($user_id, $firstname, $lastname, $username, null, null, $email, $status, $official_code, $phone, $picture_uri, $expiration_date, $active); |
112 | - $UserUpdate[]=$user_id; |
|
112 | + $UserUpdate[] = $user_id; |
|
113 | 113 | } |
114 | - $UserList[]=$user_id; |
|
114 | + $UserList[] = $user_id; |
|
115 | 115 | } |
116 | 116 | //} |
117 | 117 | } |
@@ -125,10 +125,10 @@ discard block |
||
125 | 125 | } |
126 | 126 | |
127 | 127 | // Une fois les utilisateurs importer dans la base des utilisateurs, on peux les affecter la session |
128 | - $result=Database::query("SELECT c_id FROM $tbl_session_rel_course WHERE session_id='$id_session'"); |
|
129 | - $CourseList=array(); |
|
130 | - while($row=Database::fetch_array($result)) { |
|
131 | - $CourseList[]= $row['c_id']; |
|
128 | + $result = Database::query("SELECT c_id FROM $tbl_session_rel_course WHERE session_id='$id_session'"); |
|
129 | + $CourseList = array(); |
|
130 | + while ($row = Database::fetch_array($result)) { |
|
131 | + $CourseList[] = $row['c_id']; |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | foreach ($CourseList as $enreg_course) { |
@@ -138,8 +138,8 @@ discard block |
||
138 | 138 | VALUES('$id_session','$enreg_course','$enreg_user')"; |
139 | 139 | Database::query($sql); |
140 | 140 | } |
141 | - $sql = "SELECT COUNT(user_id) as nbUsers " . |
|
142 | - "FROM $tbl_session_rel_course_rel_user " . |
|
141 | + $sql = "SELECT COUNT(user_id) as nbUsers ". |
|
142 | + "FROM $tbl_session_rel_course_rel_user ". |
|
143 | 143 | "WHERE session_id='$id_session' AND c_id='$enreg_course'"; |
144 | 144 | $rs = Database::query($sql); |
145 | 145 | list($nbr_users) = Database::fetch_array($rs); |
@@ -148,13 +148,13 @@ discard block |
||
148 | 148 | Database::query($sql); |
149 | 149 | } |
150 | 150 | // On ajoute la relation entre l'utilisateur et la session |
151 | - foreach($UserList as $enreg_user){ |
|
152 | - $sql = "INSERT IGNORE INTO $tbl_session_rel_user(session_id, user_id, registered_at) " . |
|
153 | - "VALUES('$id_session','$enreg_user', '" . api_get_utc_datetime() . "')"; |
|
151 | + foreach ($UserList as $enreg_user) { |
|
152 | + $sql = "INSERT IGNORE INTO $tbl_session_rel_user(session_id, user_id, registered_at) ". |
|
153 | + "VALUES('$id_session','$enreg_user', '".api_get_utc_datetime()."')"; |
|
154 | 154 | Database::query($sql); |
155 | 155 | } |
156 | - $sql = "SELECT COUNT(user_id) as nbUsers " . |
|
157 | - "FROM $tbl_session_rel_user " . |
|
156 | + $sql = "SELECT COUNT(user_id) as nbUsers ". |
|
157 | + "FROM $tbl_session_rel_user ". |
|
158 | 158 | "WHERE session_id='$id_session' AND relation_type<>".SESSION_RELATION_TYPE_RRHH.""; |
159 | 159 | $rs = Database::query($sql); |
160 | 160 | list($nbr_users) = Database::fetch_array($rs); |