Completed
Push — 1.11.x ( 6904fa...6a92e6 )
by José
525:44 queued 484:20
created
main/user/add_users_to_session.php 1 patch
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -22,9 +22,9 @@  discard block
 block discarded – undo
22 22
 
23 23
 // setting breadcrumbs
24 24
 if (api_is_platform_admin()) {
25
-    $interbreadcrumb[] = array('url' => 'index.php','name' => get_lang('PlatformAdmin'));
26
-    $interbreadcrumb[] = array('url' => 'session_list.php','name' => get_lang('SessionList'));
27
-    $interbreadcrumb[] = array('url' => "resume_session.php?id_session=".$id_session,"name" => get_lang('SessionOverview'));
25
+    $interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
26
+    $interbreadcrumb[] = array('url' => 'session_list.php', 'name' => get_lang('SessionList'));
27
+    $interbreadcrumb[] = array('url' => "resume_session.php?id_session=".$id_session, "name" => get_lang('SessionOverview'));
28 28
 }
29 29
 $allowTutors = api_get_setting('allow_tutors_to_assign_students_to_session');
30 30
 $extra_field_list = [];
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
     $tool_name = get_lang('SubscribeUsersToSession');
40 40
     $add_type = 'unique';
41 41
 
42
-    if (isset($_REQUEST['add_type']) && $_REQUEST['add_type']!='') {
42
+    if (isset($_REQUEST['add_type']) && $_REQUEST['add_type'] != '') {
43 43
         $add_type = Security::remove_XSS($_REQUEST['add_type']);
44 44
     }
45 45
 
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
     if (is_array($extra_field_list)) {
52 52
     	foreach ($extra_field_list as $extra_field) {
53 53
     		//if is enabled to filter and is a "<select>" field type
54
-    		if ($extra_field[8]==1 && $extra_field[2]==4 ) {
54
+    		if ($extra_field[8] == 1 && $extra_field[2] == 4) {
55 55
                 $new_field_list[] = array(
56 56
                     'name' => $extra_field[3],
57 57
                     'variable' => $extra_field[1],
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
     	if (!empty($needle) && !empty($type)) {
75 75
 
76 76
             //normal behaviour
77
-            if ($type == 'any_session' && $needle == 'false')  {
77
+            if ($type == 'any_session' && $needle == 'false') {
78 78
                 $type = 'multiple';
79 79
                 $needle = '';
80 80
             }
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
     		$cond_user_id = '';
89 89
 
90 90
             //Only for single & multiple
91
-            if (in_array($type, array('single','multiple'))) {
91
+            if (in_array($type, array('single', 'multiple'))) {
92 92
         		if (!empty($id_session)) {
93 93
         		    $id_session = intval($id_session);
94 94
         			// check id_user from session_rel_user table
@@ -98,11 +98,11 @@  discard block
 block discarded – undo
98 98
         			$user_ids = array();
99 99
         			if (Database::num_rows($res) > 0) {
100 100
         				while ($row = Database::fetch_row($res)) {
101
-        					$user_ids[] = (int)$row[0];
101
+        					$user_ids[] = (int) $row[0];
102 102
         				}
103 103
         			}
104 104
         			if (count($user_ids) > 0) {
105
-        				$cond_user_id = ' AND user.user_id NOT IN('.implode(",",$user_ids).')';
105
+        				$cond_user_id = ' AND user.user_id NOT IN('.implode(",", $user_ids).')';
106 106
         			}
107 107
         		}
108 108
             }
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
                     break;
139 139
     		}
140 140
     		if (api_is_multiple_url_enabled()) {
141
-    			$tbl_user_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
141
+    			$tbl_user_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
142 142
     			$access_url_id = api_get_current_access_url_id();
143 143
     			if ($access_url_id != -1) {
144 144
                     switch ($type) {
@@ -183,11 +183,11 @@  discard block
 block discarded – undo
183 183
     		}
184 184
 
185 185
     		$rs = Database::query($sql);
186
-            $i=0;
186
+            $i = 0;
187 187
     		if ($type == 'single') {
188 188
     			while ($user = Database::fetch_array($rs)) {
189 189
     	            $i++;
190
-    	            if ($i<=10) {
190
+    	            if ($i <= 10) {
191 191
                 		$person_name = api_get_person_name($user['firstname'], $user['lastname']);
192 192
     					$return .= '<a href="javascript: void(0);" onclick="javascript: add_user_to_session(\''.$user['user_id'].'\',\''.$person_name.' ('.$user['username'].')'.'\')">'.$person_name.' ('.$user['username'].')</a><br />';
193 193
     	            } else {
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
     	            }
196 196
     			}
197 197
 
198
-    			$xajax_response -> addAssign('ajax_list_users_single','innerHTML',api_utf8_encode($return));
198
+    			$xajax_response -> addAssign('ajax_list_users_single', 'innerHTML', api_utf8_encode($return));
199 199
     		} else {
200 200
     			global $nosessionUsersList;
201 201
     			$return .= '<select id="origin_users" name="nosessionUsersList[]" multiple="multiple" size="15" style="width:360px;">';
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
     	            $return .= '<option value="'.$user['user_id'].'">'.$person_name.' ('.$user['username'].')</option>';
205 205
     			}
206 206
     			$return .= '</select>';
207
-    			$xajax_response -> addAssign('ajax_list_users_multiple','innerHTML',api_utf8_encode($return));
207
+    			$xajax_response -> addAssign('ajax_list_users_multiple', 'innerHTML', api_utf8_encode($return));
208 208
     		}
209 209
     	}
210 210
     	return $xajax_response;
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
     </script>';
262 262
 
263 263
     $form_sent = 0;
264
-    $errorMsg = $firstLetterUser = $firstLetterSession='';
264
+    $errorMsg = $firstLetterUser = $firstLetterSession = '';
265 265
     $UserList = $SessionList = array();
266 266
     $sessions = array();
267 267
     $noPHP_SELF = true;
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
         $UserList = $_POST['sessionUsersList'];
274 274
 
275 275
         if (!is_array($UserList)) {
276
-            $UserList=array();
276
+            $UserList = array();
277 277
         }
278 278
 
279 279
         if ($form_sent == 1) {
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
                 WHERE u.status<>".DRH." AND u.status<>6 $order_clause";
302 302
 
303 303
         if (api_is_multiple_url_enabled()) {
304
-            $tbl_user_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
304
+            $tbl_user_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
305 305
             $access_url_id = api_get_current_access_url_id();
306 306
             if ($access_url_id != -1) {
307 307
                 $sql = "SELECT u.user_id, lastname, firstname, username, session_id
@@ -317,19 +317,19 @@  discard block
 block discarded – undo
317 317
         $result = Database::query($sql);
318 318
         $users = Database::store_result($result);
319 319
         foreach ($users as $user) {
320
-            $sessionUsersList[$user['user_id']] = $user ;
320
+            $sessionUsersList[$user['user_id']] = $user;
321 321
         }
322 322
         unset($users); //clean to free memory
323 323
     } else {
324 324
         //Filter by Extra Fields
325 325
         $use_extra_fields = false;
326 326
         if (is_array($extra_field_list)) {
327
-            if (is_array($new_field_list) && count($new_field_list)>0 ) {
328
-                $result_list=array();
327
+            if (is_array($new_field_list) && count($new_field_list) > 0) {
328
+                $result_list = array();
329 329
                 foreach ($new_field_list as $new_field) {
330 330
                     $varname = 'field_'.$new_field['variable'];
331 331
                     if (UserManager::is_extra_field_available($new_field['variable'])) {
332
-                        if (isset($_POST[$varname]) && $_POST[$varname]!='0') {
332
+                        if (isset($_POST[$varname]) && $_POST[$varname] != '0') {
333 333
                             $use_extra_fields = true;
334 334
                             $extra_field_result[] = UserManager::get_extra_user_data_by_value(
335 335
                                 $new_field['variable'],
@@ -343,9 +343,9 @@  discard block
 block discarded – undo
343 343
 
344 344
         if ($use_extra_fields) {
345 345
             $final_result = array();
346
-           	if (count($extra_field_result)>1) {
347
-    	    for($i=0;$i<count($extra_field_result)-1;$i++) {
348
-                    if (is_array($extra_field_result[$i+1])) {
346
+           	if (count($extra_field_result) > 1) {
347
+    	    for ($i = 0; $i < count($extra_field_result) - 1; $i++) {
348
+                    if (is_array($extra_field_result[$i + 1])) {
349 349
                         $final_result = array_intersect(
350 350
                             $extra_field_result[$i],
351 351
                             $extra_field_result[$i + 1]
@@ -356,17 +356,17 @@  discard block
 block discarded – undo
356 356
                 $final_result = $extra_field_result[0];
357 357
             }
358 358
 
359
-            $where_filter ='';
359
+            $where_filter = '';
360 360
             if (api_is_multiple_url_enabled()) {
361
-                if (is_array($final_result) && count($final_result)>0) {
362
-                    $where_filter = " AND u.user_id IN  ('".implode("','",$final_result)."') ";
361
+                if (is_array($final_result) && count($final_result) > 0) {
362
+                    $where_filter = " AND u.user_id IN  ('".implode("','", $final_result)."') ";
363 363
                 } else {
364 364
                     //no results
365 365
                     $where_filter = " AND u.user_id  = -1";
366 366
                 }
367 367
             } else {
368
-                if (is_array($final_result) && count($final_result)>0) {
369
-                    $where_filter = " WHERE u.user_id IN  ('".implode("','",$final_result)."') ";
368
+                if (is_array($final_result) && count($final_result) > 0) {
369
+                    $where_filter = " WHERE u.user_id IN  ('".implode("','", $final_result)."') ";
370 370
                 } else {
371 371
                     //no results
372 372
                     $where_filter = " WHERE u.user_id  = -1";
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
                     $order_clause";
396 396
         }
397 397
         if (api_is_multiple_url_enabled()) {
398
-            $tbl_user_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
398
+            $tbl_user_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
399 399
             $access_url_id = api_get_current_access_url_id();
400 400
             if ($access_url_id != -1) {
401 401
                 $sql = "SELECT  u.user_id, lastname, firstname, username, session_id
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
         }
413 413
 
414 414
         $result = Database::query($sql);
415
-        $users = Database::store_result($result,'ASSOC');
415
+        $users = Database::store_result($result, 'ASSOC');
416 416
 
417 417
         foreach ($users as $uid => $user) {
418 418
             if ($user['session_id'] != $id_session) {
@@ -427,7 +427,7 @@  discard block
 block discarded – undo
427 427
         unset($users); //clean to free memory
428 428
 
429 429
         //filling the correct users in list
430
-        $sql="SELECT  user_id, lastname, firstname, username, session_id
430
+        $sql = "SELECT  user_id, lastname, firstname, username, session_id
431 431
               FROM $tbl_user u
432 432
               LEFT JOIN $tbl_session_rel_user
433 433
               ON
@@ -437,10 +437,10 @@  discard block
 block discarded – undo
437 437
               WHERE u.status<>".DRH." AND u.status<>6 $order_clause";
438 438
 
439 439
         if (api_is_multiple_url_enabled()) {
440
-            $tbl_user_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
440
+            $tbl_user_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
441 441
             $access_url_id = api_get_current_access_url_id();
442 442
             if ($access_url_id != -1) {
443
-                $sql="SELECT  u.user_id, lastname, firstname, username, session_id
443
+                $sql = "SELECT  u.user_id, lastname, firstname, username, session_id
444 444
                     FROM $tbl_user u
445 445
                     LEFT JOIN $tbl_session_rel_user
446 446
                     ON
@@ -453,11 +453,11 @@  discard block
 block discarded – undo
453 453
             }
454 454
         }
455 455
         $result = Database::query($sql);
456
-        $users = Database::store_result($result,'ASSOC');
456
+        $users = Database::store_result($result, 'ASSOC');
457 457
         foreach ($users as $uid => $user) {
458 458
             if ($user['session_id'] == $id_session) {
459 459
                 $sessionUsersList[$user['user_id']] = $user;
460
-                if (array_key_exists($user['user_id'],$nosessionUsersList)) {
460
+                if (array_key_exists($user['user_id'], $nosessionUsersList)) {
461 461
                     unset($nosessionUsersList[$user['user_id']]);
462 462
                 }
463 463
             }
@@ -473,25 +473,25 @@  discard block
 block discarded – undo
473 473
     	$link_add_type_unique = Display::return_icon('single.gif').get_lang('SessionAddTypeUnique');
474 474
     	$link_add_type_multiple = '<a href="'.api_get_self().'?id_session='.$id_session.'&amp;add='.Security::remove_XSS($_GET['add']).'&amp;add_type=multiple">'.Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple').'</a>';
475 475
     }
476
-    	$link_add_group = '<a href="usergroups.php">'.Display::return_icon('multiple.gif',get_lang('RegistrationByUsersGroups')).get_lang('RegistrationByUsersGroups').'</a>';
476
+    	$link_add_group = '<a href="usergroups.php">'.Display::return_icon('multiple.gif', get_lang('RegistrationByUsersGroups')).get_lang('RegistrationByUsersGroups').'</a>';
477 477
     ?>
478 478
     <div class="actions">
479 479
     	<?php echo $link_add_type_unique ?>&nbsp;|&nbsp;<?php echo $link_add_type_multiple ?>&nbsp;|&nbsp;<?php echo $link_add_group; ?>
480 480
     </div>
481
-    <form name="formulaire" method="post" action="<?php echo api_get_self(); ?>?page=<?php echo $page; ?>&id_session=<?php echo $id_session; ?><?php if(!empty($_GET['add'])) echo '&add=true' ; ?>" style="margin:0px;" <?php if($ajax_search){echo ' onsubmit="valide();"';}?>>
481
+    <form name="formulaire" method="post" action="<?php echo api_get_self(); ?>?page=<?php echo $page; ?>&id_session=<?php echo $id_session; ?><?php if (!empty($_GET['add'])) echo '&add=true'; ?>" style="margin:0px;" <?php if ($ajax_search) {echo ' onsubmit="valide();"'; }?>>
482 482
     <?php echo '<legend>'.$tool_name.' ('.$session_info['name'].') </legend>'; ?>
483 483
     <?php
484 484
     if ($add_type == 'multiple') {
485 485
     	if (is_array($extra_field_list)) {
486
-    		if (is_array($new_field_list) && count($new_field_list)>0 ) {
486
+    		if (is_array($new_field_list) && count($new_field_list) > 0) {
487 487
     			echo '<h3>'.get_lang('FilterUsers').'</h3>';
488 488
     			foreach ($new_field_list as $new_field) {
489 489
     				echo $new_field['name'];
490 490
     				$varname = 'field_'.$new_field['variable'];
491 491
     				echo '&nbsp;<select name="'.$varname.'">';
492 492
     				echo '<option value="0">--'.get_lang('Select').'--</option>';
493
-    				foreach	($new_field['data'] as $option) {
494
-    					$checked='';
493
+    				foreach ($new_field['data'] as $option) {
494
+    					$checked = '';
495 495
     					if (isset($_POST[$varname])) {
496 496
     						if ($_POST[$varname] == $option[1]) {
497 497
     							$checked = 'selected="true"';
@@ -546,7 +546,7 @@  discard block
 block discarded – undo
546 546
                   <?php
547 547
                   foreach ($nosessionUsersList as $uid => $enreg) {
548 548
                   ?>
549
-                      <option value="<?php echo $uid; ?>" <?php if(in_array($uid,$UserList)) echo 'selected="selected"'; ?>><?php echo api_get_person_name($enreg['fn'], $enreg['ln']).' ('.$enreg['un'].')'; ?></option>
549
+                      <option value="<?php echo $uid; ?>" <?php if (in_array($uid, $UserList)) echo 'selected="selected"'; ?>><?php echo api_get_person_name($enreg['fn'], $enreg['ln']).' ('.$enreg['un'].')'; ?></option>
550 550
                   <?php
551 551
                   }
552 552
                   ?>
@@ -598,7 +598,7 @@  discard block
 block discarded – undo
598 598
             </div>
599 599
             <select id="destination_users" name="sessionUsersList[]" multiple="multiple" size="15" class="span5">
600 600
             <?php
601
-            foreach($sessionUsersList as $enreg) {
601
+            foreach ($sessionUsersList as $enreg) {
602 602
             ?>
603 603
                 <option value="<?php echo $enreg['user_id']; ?>"><?php echo api_get_person_name($enreg['firstname'], $enreg['lastname']).' ('.$enreg['username'].')'; ?></option>
604 604
             <?php
Please login to merge, or discard this patch.
main/auth/ldap/authldap.php 1 patch
Spacing   +92 added lines, -92 removed lines patch added patch discarded remove patch
@@ -78,16 +78,16 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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 .= '&amp;id_session='.Security::remove_XSS($_GET['id_session']);
477 477
     }
478 478
     //$url_params_id="id=".$row[0];
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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 ";
Please login to merge, or discard this patch.
main/inc/global.inc.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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'];
Please login to merge, or discard this patch.
main/inc/ajax/record_audio_rtc.ajax.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -25,16 +25,16 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
main/inc/ajax/record_audio_wami.ajax.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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,
Please login to merge, or discard this patch.
main/inc/lib/fileManage.lib.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -225,9 +225,9 @@  discard block
 block discarded – undo
225 225
 		/* File case */
226 226
 		if (is_file($source)) {
227 227
 			if ($forceMove && !$isWindowsOS && $canExec) {
228
-				exec('mv ' . $source . ' ' . $target . '/' . $file_name);
228
+				exec('mv '.$source.' '.$target.'/'.$file_name);
229 229
 			} else {
230
-				copy($source, $target . '/' . $file_name);
230
+				copy($source, $target.'/'.$file_name);
231 231
 				unlink($source);
232 232
 			}
233 233
 			return true;
@@ -349,17 +349,17 @@  discard block
 block discarded – undo
349 349
 			// Recursive operation if subdirectories exist
350 350
 			$dir_number = sizeof($dir_array);
351 351
 			if ($dir_number > 0) {
352
-				for ($i = 0 ; $i < $dir_number ; $i++) {
352
+				for ($i = 0; $i < $dir_number; $i++) {
353 353
 					$sub_dir_array = FileManager::list_all_directories($dir_array[$i]); // Function recursivity
354 354
 					if (is_array($dir_array) && is_array($sub_dir_array)) {
355
-						$dir_array  =  array_merge($dir_array, $sub_dir_array); // Data merge
355
+						$dir_array = array_merge($dir_array, $sub_dir_array); // Data merge
356 356
 					}
357 357
 				}
358 358
 			}
359
-			$result_array  =  $dir_array;
360
-			chdir($save_dir) ;
359
+			$result_array = $dir_array;
360
+			chdir($save_dir);
361 361
 		}
362
-		return $result_array ;
362
+		return $result_array;
363 363
 	}
364 364
 
365 365
 	/**
@@ -404,8 +404,8 @@  discard block
 block discarded – undo
404 404
 		$buffer = '';
405 405
 		if (file_exists($file_name)) {
406 406
 			$fp = fopen($file_name, 'rb');
407
-			$buffer = fread ($fp, filesize($file_name));
408
-			fclose ($fp);
407
+			$buffer = fread($fp, filesize($file_name));
408
+			fclose($fp);
409 409
 		}
410 410
 		return $buffer;
411 411
 	}
Please login to merge, or discard this patch.
main/document/record_audio.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -29,9 +29,9 @@  discard block
 block discarded – undo
29 29
 $dir = $document_data['path'];
30 30
 
31 31
 //make some vars
32
-$wamidir=$dir;
33
-if($wamidir=="/"){
34
-	$wamidir="";
32
+$wamidir = $dir;
33
+if ($wamidir == "/") {
34
+	$wamidir = "";
35 35
 }
36 36
 $wamiurlplay = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document'.$wamidir."/";
37 37
 $groupId = api_get_group_id();
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 
66 66
 //groups //TODO: clean
67 67
 if (!empty($groupId)) {
68
-	$interbreadcrumb[] = array ("url" => "../group/group_space.php?".api_get_cidreq(), "name" => get_lang('GroupSpace'));
68
+	$interbreadcrumb[] = array("url" => "../group/group_space.php?".api_get_cidreq(), "name" => get_lang('GroupSpace'));
69 69
 	$noPHP_SELF = true;
70 70
 	$group = GroupManager :: get_group_properties($groupId);
71 71
 	$path = explode('/', $dir);
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 }
82 82
 
83 83
 if (!($is_allowed_to_edit || $_SESSION['group_member_with_upload_rights'] ||
84
-	DocumentManager::is_my_shared_folder(api_get_user_id(), Security::remove_XSS($dir),api_get_session_id()))) {
84
+	DocumentManager::is_my_shared_folder(api_get_user_id(), Security::remove_XSS($dir), api_get_session_id()))) {
85 85
 	api_not_allowed(true);
86 86
 }
87 87
 
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 // Interbreadcrumb for the current directory root path
100 100
 $counter = 0;
101 101
 if (isset($document_data['parents'])) {
102
-	foreach($document_data['parents'] as $document_sub_data) {
102
+	foreach ($document_data['parents'] as $document_sub_data) {
103 103
 		//fixing double group folder in breadcrumb
104 104
 		if (api_get_group_id()) {
105 105
 			if ($counter == 0) {
@@ -115,14 +115,14 @@  discard block
 block discarded – undo
115 115
 //make some vars
116 116
 $wamiuserid = api_get_user_id();
117 117
 
118
-$htmlHeadXtra[] = '<script src="' . api_get_path(WEB_LIBRARY_JS_PATH) . 'rtc/RecordRTC.js"></script>';
119
-$htmlHeadXtra[] = '<script src="' . api_get_path(WEB_LIBRARY_PATH) . 'wami-recorder/recorder.js"></script>';
120
-$htmlHeadXtra[] = '<script src="' . api_get_path(WEB_LIBRARY_PATH) . 'wami-recorder/gui.js"></script>';
121
-$htmlHeadXtra[] = '<script type="text/javascript" src="' . api_get_path(WEB_LIBRARY_PATH) . 'swfobject/swfobject.js"></script>';
118
+$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_JS_PATH).'rtc/RecordRTC.js"></script>';
119
+$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'wami-recorder/recorder.js"></script>';
120
+$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'wami-recorder/gui.js"></script>';
121
+$htmlHeadXtra[] = '<script type="text/javascript" src="'.api_get_path(WEB_LIBRARY_PATH).'swfobject/swfobject.js"></script>';
122 122
 
123 123
 $actions = Display::toolbarButton(
124
-	get_lang('BackTo') . ' ' . get_lang('DocumentsOverview'),
125
-	'document.php?' . api_get_cidreq() . "&id=$document_id",
124
+	get_lang('BackTo').' '.get_lang('DocumentsOverview'),
125
+	'document.php?'.api_get_cidreq()."&id=$document_id",
126 126
 	'arrow-left',
127 127
 	'default',
128 128
 	[],
Please login to merge, or discard this patch.
main/document/showinframes.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -149,8 +149,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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) {
Please login to merge, or discard this patch.
main/document/show_content.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -90,12 +90,12 @@
 block discarded – undo
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().'&amp;rand='.mt_rand(1, 1000).'"></iframe>';
Please login to merge, or discard this patch.