Completed
Push — 1.11.x ( 3ebade...c47d58 )
by José
213:48 queued 162:56
created
main/inc/lib/login.lib.php 2 patches
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -37,24 +37,24 @@  discard block
 block discarded – undo
37 37
             if ($by_username) {
38 38
                 $secret_word = self::get_secret_word($user['email']);
39 39
                 if ($reset) {
40
-                    $reset_link = $portal_url . "main/auth/lostPassword.php?reset=" . $secret_word . "&id=" . $user['uid'];
40
+                    $reset_link = $portal_url."main/auth/lostPassword.php?reset=".$secret_word."&id=".$user['uid'];
41 41
                 } else {
42
-                    $reset_link = get_lang('Pass') . " : $user[password]";
42
+                    $reset_link = get_lang('Pass')." : $user[password]";
43 43
                 }
44
-                $user_account_list = get_lang('YourRegistrationData') . " : \n" . get_lang('UserName') . ' : ' . $user['loginName'] . "\n" . get_lang('ResetLink') . ' : ' . $reset_link . '';
44
+                $user_account_list = get_lang('YourRegistrationData')." : \n".get_lang('UserName').' : '.$user['loginName']."\n".get_lang('ResetLink').' : '.$reset_link.'';
45 45
 
46 46
                 if ($user_account_list) {
47
-                    $user_account_list = "\n-----------------------------------------------\n" . $user_account_list;
47
+                    $user_account_list = "\n-----------------------------------------------\n".$user_account_list;
48 48
                 }
49 49
             } else {
50 50
                 foreach ($user as $this_user) {
51 51
                     $secret_word = self::get_secret_word($this_user['email']);
52 52
                     if ($reset) {
53
-                        $reset_link = $portal_url . "main/auth/lostPassword.php?reset=" . $secret_word . "&id=" . $this_user['uid'];
53
+                        $reset_link = $portal_url."main/auth/lostPassword.php?reset=".$secret_word."&id=".$this_user['uid'];
54 54
                     } else {
55
-                        $reset_link = get_lang('Pass') . " : $this_user[password]";
55
+                        $reset_link = get_lang('Pass')." : $this_user[password]";
56 56
                     }
57
-                    $user_account_list[] = get_lang('YourRegistrationData') . " : \n" . get_lang('UserName') . ' : ' . $this_user['loginName'] . "\n" . get_lang('ResetLink') . ' : ' . $reset_link . '';
57
+                    $user_account_list[] = get_lang('YourRegistrationData')." : \n".get_lang('UserName').' : '.$this_user['loginName']."\n".get_lang('ResetLink').' : '.$reset_link.'';
58 58
                 }
59 59
                 if ($user_account_list) {
60 60
                     $user_account_list = implode("\n-----------------------------------------------\n", $user_account_list);
@@ -64,8 +64,8 @@  discard block
 block discarded – undo
64 64
             if (!$by_username) {
65 65
                 $user = $user[0];
66 66
             }
67
-            $reset_link = get_lang('Pass') . " : $user[password]";
68
-            $user_account_list = get_lang('YourRegistrationData') . " : \n" . get_lang('UserName') . ' : ' . $user['loginName'] . "\n" . $reset_link . '';
67
+            $reset_link = get_lang('Pass')." : $user[password]";
68
+            $user_account_list = get_lang('YourRegistrationData')." : \n".get_lang('UserName').' : '.$user['loginName']."\n".$reset_link.'';
69 69
         }
70 70
         return $user_account_list;
71 71
     }
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
      */
79 79
     public static function send_password_to_user($user, $by_username = false)
80 80
     {
81
-        $email_subject = "[" . api_get_setting('siteName') . "] " . get_lang('LoginRequest'); // SUBJECT
81
+        $email_subject = "[".api_get_setting('siteName')."] ".get_lang('LoginRequest'); // SUBJECT
82 82
 
83 83
         if ($by_username) { // Show only for lost password
84 84
             $user_account_list = self::get_user_account_list($user, false, $by_username); // BODY
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
             }
98 98
         }
99 99
 
100
-        $email_body = get_lang('YourAccountParam') . " " . $portal_url . "\n\n$user_account_list";
100
+        $email_body = get_lang('YourAccountParam')." ".$portal_url."\n\n$user_account_list";
101 101
         // SEND MESSAGE
102 102
         $sender_name = api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS);
103 103
         $email_admin = api_get_setting('emailAdministrator');
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
      */
132 132
     public static function handle_encrypted_password($user, $by_username = false)
133 133
     {
134
-        $email_subject = "[" . api_get_setting('siteName') . "] " . get_lang('LoginRequest'); // SUBJECT
134
+        $email_subject = "[".api_get_setting('siteName')."] ".get_lang('LoginRequest'); // SUBJECT
135 135
 
136 136
         if ($by_username) {
137 137
         // Show only for lost password
@@ -141,11 +141,11 @@  discard block
 block discarded – undo
141 141
             $user_account_list = self::get_user_account_list($user, true); // BODY
142 142
             $email_to = $user[0]['email'];
143 143
         }
144
-        $email_body = get_lang('DearUser') . " :\n" . get_lang('password_request') . "\n";
145
-        $email_body .= $user_account_list . "\n-----------------------------------------------\n\n";
144
+        $email_body = get_lang('DearUser')." :\n".get_lang('password_request')."\n";
145
+        $email_body .= $user_account_list."\n-----------------------------------------------\n\n";
146 146
         $email_body .= get_lang('PasswordEncryptedForSecurity');
147 147
 
148
-        $email_body .= "\n\n" . get_lang('SignatureFormula') . ",\n" . api_get_setting('administratorName') . " " . api_get_setting('administratorSurname') . "\n" . get_lang('PlataformAdmin') . " - " . api_get_setting('siteName');
148
+        $email_body .= "\n\n".get_lang('SignatureFormula').",\n".api_get_setting('administratorName')." ".api_get_setting('administratorSurname')."\n".get_lang('PlataformAdmin')." - ".api_get_setting('siteName');
149 149
 
150 150
         $sender_name = api_get_person_name(
151 151
             api_get_setting('administratorName'),
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
                     username AS loginName,
239 239
                     password,
240 240
                     email
241
-                FROM " . $tbl_user . "
241
+                FROM " . $tbl_user."
242 242
                 WHERE user_id = $id";
243 243
         $result = Database::query($sql);
244 244
         $num_rows = Database::num_rows($result);
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
                         ON user.user_id = a.user_id
292 292
                         LEFT JOIN $track_e_login login
293 293
                         ON user.user_id  = login.login_user_id
294
-                        WHERE user.user_id = '" . $_user['user_id'] . "'
294
+                        WHERE user.user_id = '".$_user['user_id']."'
295 295
                         ORDER BY login.login_date DESC LIMIT 1";
296 296
 
297 297
                 $result = Database::query($sql);
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
                     Session::write('is_platformAdmin', $is_platformAdmin);
322 322
                     Session::write('is_allowedCreateCourse', $is_allowedCreateCourse);
323 323
                 } else {
324
-                    header('location:' . api_get_path(WEB_PATH));
324
+                    header('location:'.api_get_path(WEB_PATH));
325 325
                     //exit("WARNING UNDEFINED UID !! ");
326 326
                 }
327 327
             } else { // no uid => logout or Anonymous
@@ -368,9 +368,9 @@  discard block
 block discarded – undo
368 368
         global $_course;
369 369
         global $_real_cid;
370 370
 
371
-        global $is_courseAdmin;  //course teacher
372
-        global $is_courseTutor;  //course teacher - some rights
373
-        global $is_courseCoach;  //course coach
371
+        global $is_courseAdmin; //course teacher
372
+        global $is_courseTutor; //course teacher - some rights
373
+        global $is_courseCoach; //course coach
374 374
         global $is_courseMember; //course student
375 375
         global $is_sessionAdmin;
376 376
         global $is_allowed_in_course;
@@ -427,7 +427,7 @@  discard block
 block discarded – undo
427 427
 
428 428
                     if (!empty($_GET['id_session'])) {
429 429
                         $_SESSION['id_session'] = intval($_GET['id_session']);
430
-                        $sql = 'SELECT name FROM ' . $tbl_session . ' WHERE id="' . intval($_SESSION['id_session']) . '"';
430
+                        $sql = 'SELECT name FROM '.$tbl_session.' WHERE id="'.intval($_SESSION['id_session']).'"';
431 431
                         $rs = Database::query($sql);
432 432
                         list($_SESSION['session_name']) = Database::fetch_array($rs);
433 433
                     } else {
@@ -443,7 +443,7 @@  discard block
 block discarded – undo
443 443
                     }
444 444
                 } else {
445 445
                     //exit("WARNING UNDEFINED CID !! ");
446
-                    header('location:' . api_get_path(WEB_PATH));
446
+                    header('location:'.api_get_path(WEB_PATH));
447 447
                 }
448 448
             } else {
449 449
                 Session::erase('_cid');
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
         } else {
471 471
             // Continue with the previous values
472 472
             if (empty($_SESSION['_course']) OR empty($_SESSION['_cid'])) { //no previous values...
473
-                $_cid = -1;        //set default values that will be caracteristic of being unset
473
+                $_cid = -1; //set default values that will be caracteristic of being unset
474 474
                 $_course = -1;
475 475
             } else {
476 476
                 $_cid = $_SESSION['_cid'];
@@ -480,7 +480,7 @@  discard block
 block discarded – undo
480 480
                 // Moreover, if we want to track a course with another session it can be usefull
481 481
                 if (!empty($_GET['id_session'])) {
482 482
                     $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
483
-                    $sql = 'SELECT name FROM ' . $tbl_session . ' WHERE id="' . intval($_SESSION['id_session']) . '"';
483
+                    $sql = 'SELECT name FROM '.$tbl_session.' WHERE id="'.intval($_SESSION['id_session']).'"';
484 484
                     $rs = Database::query($sql);
485 485
                     list($_SESSION['session_name']) = Database::fetch_array($rs);
486 486
                     $_SESSION['id_session'] = intval($_GET['id_session']);
@@ -520,9 +520,9 @@  discard block
 block discarded – undo
520 520
                             //But only if the login date is < than now + max_life_time
521 521
                             $sql = "SELECT course_access_id FROM $course_tracking_table
522 522
                                     WHERE
523
-                                        user_id     = " . intval($_user ['user_id']) . " AND
523
+                                        user_id     = ".intval($_user ['user_id'])." AND
524 524
                                         c_id = '".api_get_course_int_id()."' AND
525
-                                        session_id  = " . api_get_session_id() . " AND
525
+                                        session_id  = " . api_get_session_id()." AND
526 526
                                         login_course_date > now() - INTERVAL $session_lifetime SECOND
527 527
                                     ORDER BY login_course_date DESC LIMIT 0,1";
528 528
                             $result = Database::query($sql);
@@ -532,11 +532,11 @@  discard block
 block discarded – undo
532 532
                                 //We update the course tracking table
533 533
                                 $sql = "UPDATE $course_tracking_table
534 534
                                         SET logout_course_date = '$time', counter = counter+1
535
-                                        WHERE course_access_id = " . intval($i_course_access_id) . " AND session_id = " . api_get_session_id();
535
+                                        WHERE course_access_id = ".intval($i_course_access_id)." AND session_id = ".api_get_session_id();
536 536
                                 Database::query($sql);
537 537
                             } else {
538
-                                $sql = "INSERT INTO $course_tracking_table (c_id, user_id, login_course_date, logout_course_date, counter, session_id)" .
539
-                                        "VALUES('" . api_get_course_int_id() . "', '" . $_user['user_id'] . "', '$time', '$time', '1','" . api_get_session_id() . "')";
538
+                                $sql = "INSERT INTO $course_tracking_table (c_id, user_id, login_course_date, logout_course_date, counter, session_id)".
539
+                                        "VALUES('".api_get_course_int_id()."', '".$_user['user_id']."', '$time', '$time', '1','".api_get_session_id()."')";
540 540
                                 Database::query($sql);
541 541
                             }
542 542
                         }
@@ -564,8 +564,8 @@  discard block
 block discarded – undo
564 564
                 $course_user_table = Database::get_main_table(TABLE_MAIN_COURSE_USER);
565 565
                 $sql = "SELECT * FROM $course_user_table
566 566
                        WHERE
567
-                        user_id  = '" . $user_id . "' AND
568
-                        relation_type <> " . COURSE_RELATION_TYPE_RRHH . " AND
567
+                        user_id  = '".$user_id."' AND
568
+                        relation_type <> " . COURSE_RELATION_TYPE_RRHH." AND
569 569
                         course_code = '$course_id'";
570 570
                 $result = Database::query($sql);
571 571
 
@@ -585,8 +585,8 @@  discard block
 block discarded – undo
585 585
                             $session_id
586 586
                         );
587 587
                         if (!$user_is_subscribed) {
588
-                            $url = api_get_path(WEB_CODE_PATH) . 'course_info/legal.php?course_code=' . $_course['code'] . '&session_id=' . $session_id;
589
-                            header('Location: ' . $url);
588
+                            $url = api_get_path(WEB_CODE_PATH).'course_info/legal.php?course_code='.$_course['code'].'&session_id='.$session_id;
589
+                            header('Location: '.$url);
590 590
                             exit;
591 591
                         }
592 592
                     }
@@ -627,11 +627,11 @@  discard block
 block discarded – undo
627 627
                         } else {
628 628
                             //Im a coach or a student?
629 629
                             $sql = "SELECT user_id, status
630
-                                    FROM " . $tbl_session_course_user . "
630
+                                    FROM " . $tbl_session_course_user."
631 631
                                     WHERE
632 632
                                         c_id = '$_cid' AND
633
-                                        user_id = '" . $user_id . "' AND
634
-                                        session_id = '" . $session_id . "'
633
+                                        user_id = '".$user_id."' AND
634
+                                        session_id = '" . $session_id."'
635 635
                                     LIMIT 1";
636 636
                             $result = Database::query($sql);
637 637
 
@@ -777,7 +777,7 @@  discard block
 block discarded – undo
777 777
         if ($reset) { // session data refresh requested
778 778
             if ($group_id && $_cid && !empty($_course['real_id'])) { // have keys to search data
779 779
                 $group_table = Database::get_course_table(TABLE_GROUP);
780
-                $sql = "SELECT * FROM $group_table WHERE c_id = " . $_course['real_id'] . " AND id = '$group_id'";
780
+                $sql = "SELECT * FROM $group_table WHERE c_id = ".$_course['real_id']." AND id = '$group_id'";
781 781
                 $result = Database::query($sql);
782 782
                 if (Database::num_rows($result) > 0) { // This group has recorded status related to this course
783 783
                     $gpData = Database::fetch_array($result);
@@ -830,7 +830,7 @@  discard block
 block discarded – undo
830 830
      */
831 831
     public static function get_user_accounts_by_username($username)
832 832
     {
833
-        if (strpos($username,'@')){
833
+        if (strpos($username, '@')) {
834 834
             $username = api_strtolower($username);
835 835
             $email = true;
836 836
         } else {
Please login to merge, or discard this patch.
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -852,14 +852,14 @@  discard block
 block discarded – undo
852 852
             $email = false;
853 853
         }
854 854
 
855
-		if ($email) {
856
-			$condition = "LOWER(email) = '".Database::escape_string($username)."' ";
857
-		} else {
855
+        if ($email) {
856
+            $condition = "LOWER(email) = '".Database::escape_string($username)."' ";
857
+        } else {
858 858
             $condition = "LOWER(username) = '".Database::escape_string($username)."'";
859 859
         }
860 860
 
861
-		$tbl_user = Database :: get_main_table(TABLE_MAIN_USER);
862
-		$query = "SELECT 
861
+        $tbl_user = Database :: get_main_table(TABLE_MAIN_USER);
862
+        $query = "SELECT 
863 863
 		            user_id AS uid, 
864 864
 		            lastname AS lastName, 
865 865
 		            firstname AS firstName, 
@@ -874,7 +874,7 @@  discard block
 block discarded – undo
874 874
                     auth_source
875 875
 				 FROM $tbl_user
876 876
 				 WHERE ( $condition AND active = 1) ";
877
-		$result = Database::query($query);
877
+        $result = Database::query($query);
878 878
         $num_rows = Database::num_rows($result);
879 879
         if ($result && $num_rows > 0) {
880 880
             return Database::fetch_assoc($result);
Please login to merge, or discard this patch.
main/inc/lib/specific_fields_manager.lib.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 function delete_specific_field($id)
43 43
 {
44 44
     $table_sf = Database:: get_main_table(TABLE_MAIN_SPECIFIC_FIELD);
45
-    $id = (int)$id;
45
+    $id = (int) $id;
46 46
     if (!is_numeric($id)) {
47 47
         return false;
48 48
     }
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 function edit_specific_field($id, $name)
61 61
 {
62 62
     $table_sf = Database:: get_main_table(TABLE_MAIN_SPECIFIC_FIELD);
63
-    $id = (int)$id;
63
+    $id = (int) $id;
64 64
     if (!is_numeric($id)) {
65 65
         return false;
66 66
     }
Please login to merge, or discard this patch.
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -237,10 +237,10 @@
 block discarded – undo
237 237
  * @param   int     Internal ID used in specific tool table
238 238
  */
239 239
 function delete_all_values_for_item($course_id, $tool_id, $ref_id) {
240
-  $table_sf_values = Database :: get_main_table(TABLE_MAIN_SPECIFIC_FIELD_VALUES);
241
-  $sql = 'DELETE FROM %s WHERE course_code = \'%s\' AND tool_id = \'%s\' AND ref_id = %s';
242
-  $sql = sprintf($sql, $table_sf_values, $course_id, $tool_id, $ref_id);
243
-  Database::query($sql);
240
+    $table_sf_values = Database :: get_main_table(TABLE_MAIN_SPECIFIC_FIELD_VALUES);
241
+    $sql = 'DELETE FROM %s WHERE course_code = \'%s\' AND tool_id = \'%s\' AND ref_id = %s';
242
+    $sql = sprintf($sql, $table_sf_values, $course_id, $tool_id, $ref_id);
243
+    Database::query($sql);
244 244
 }
245 245
 
246 246
 /**
Please login to merge, or discard this patch.
main/inc/lib/timeline.lib.php 2 patches
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -25,10 +25,10 @@  discard block
 block discarded – undo
25 25
     );
26 26
     public $is_course_model = true;
27 27
 
28
-	public function __construct()
28
+    public function __construct()
29 29
     {
30 30
         $this->table =  Database::get_course_table(TABLE_TIMELINE);
31
-	}
31
+    }
32 32
 
33 33
     /**
34 34
      * Get the count of elements
@@ -52,16 +52,16 @@  discard block
 block discarded – undo
52 52
     /**
53 53
      * Displays the title + grid
54 54
      */
55
-	public function listing()
55
+    public function listing()
56 56
     {
57
-		// action links
58
-		$html = '<div class="actions">';
57
+        // action links
58
+        $html = '<div class="actions">';
59 59
         //$html .= '<a href="career_dashboard.php">'.Display::return_icon('back.png',get_lang('Back'),'','32').'</a>';
60
-		$html .= '<a href="'.api_get_self().'?action=add">'.Display::return_icon('add.png', get_lang('Add'),'','32').'</a>';
61
-		$html .= '</div>';
60
+        $html .= '<a href="'.api_get_self().'?action=add">'.Display::return_icon('add.png', get_lang('Add'),'','32').'</a>';
61
+        $html .= '</div>';
62 62
         $html .= Display::grid_html('timelines');
63 63
         return $html;
64
-	}
64
+    }
65 65
 
66 66
     public function get_status_list()
67 67
     {
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 
90 90
         $form->addElement('text', 'headline', get_lang('Name'), array('size' => '70'));
91 91
         //$form->addHtmlEditor('description', get_lang('Description'), false, false, array('ToolbarSet' => 'Careers','Width' => '100%', 'Height' => '250'));
92
-	    $status_list = $this->get_status_list();
92
+        $status_list = $this->get_status_list();
93 93
         $form->addElement('select', 'status', get_lang('Status'), $status_list);
94 94
         if ($action == 'edit') {
95 95
             //$form->addElement('text', 'created_at', get_lang('CreatedAt'));
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 
174 174
         // Setting the rules
175 175
         $form->addRule('headline', get_lang('ThisFieldIsRequired'), 'required');
176
-		return $form;
176
+        return $form;
177 177
 
178 178
     }
179 179
 
@@ -184,11 +184,11 @@  discard block
 block discarded – undo
184 184
     public function save_item($params)
185 185
     {
186 186
         $params['c_id'] = api_get_course_int_id();
187
-	    $id = parent::save($params);
188
-	    if (!empty($id)) {
189
-	    	//event_system(LOG_CAREER_CREATE, LOG_CAREER_ID, $id, api_get_utc_datetime(), api_get_user_id());
190
-   		}
191
-   		return $id;
187
+        $id = parent::save($params);
188
+        if (!empty($id)) {
189
+            //event_system(LOG_CAREER_CREATE, LOG_CAREER_ID, $id, api_get_utc_datetime(), api_get_user_id());
190
+            }
191
+            return $id;
192 192
     }
193 193
 
194 194
     /**
@@ -199,16 +199,16 @@  discard block
 block discarded – undo
199 199
         $params['c_id'] = api_get_course_int_id();
200 200
         $params['parent_id'] = '0';
201 201
         $params['type'] = 'default';
202
-	    $id = parent::save($params);
203
-	    if (!empty($id)) {
204
-	    	//event_system(LOG_CAREER_CREATE, LOG_CAREER_ID, $id, api_get_utc_datetime(), api_get_user_id());
205
-   		}
206
-   		return $id;
202
+        $id = parent::save($params);
203
+        if (!empty($id)) {
204
+            //event_system(LOG_CAREER_CREATE, LOG_CAREER_ID, $id, api_get_utc_datetime(), api_get_user_id());
205
+            }
206
+            return $id;
207 207
     }
208 208
 
209 209
     public function delete($id) {
210
-	    parent::delete($id);
211
-	    //event_system(LOG_CAREER_DELETE, LOG_CAREER_ID, $id, api_get_utc_datetime(), api_get_user_id());
210
+        parent::delete($id);
211
+        //event_system(LOG_CAREER_DELETE, LOG_CAREER_ID, $id, api_get_utc_datetime(), api_get_user_id());
212 212
     }
213 213
 
214 214
     public function get_url($id) {
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
         $item['asset'] = array( 'media'     => $item['media'],
248 248
                                 'credit'    => $item['media_credit'],
249 249
                                 'caption'   => $item['media_caption'],
250
-         );
250
+            );
251 251
 
252 252
         //Cleaning items
253 253
         unset($item['id']);
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 
28 28
 	public function __construct()
29 29
     {
30
-        $this->table =  Database::get_course_table(TABLE_TIMELINE);
30
+        $this->table = Database::get_course_table(TABLE_TIMELINE);
31 31
 	}
32 32
 
33 33
     /**
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
      */
47 47
     public function get_all($where_conditions = array())
48 48
     {
49
-        return Database::select('*',$this->table, array('where'=>$where_conditions,'order' =>'headline ASC'));
49
+        return Database::select('*', $this->table, array('where'=>$where_conditions, 'order' =>'headline ASC'));
50 50
     }
51 51
 
52 52
     /**
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 		// action links
58 58
 		$html = '<div class="actions">';
59 59
         //$html .= '<a href="career_dashboard.php">'.Display::return_icon('back.png',get_lang('Back'),'','32').'</a>';
60
-		$html .= '<a href="'.api_get_self().'?action=add">'.Display::return_icon('add.png', get_lang('Add'),'','32').'</a>';
60
+		$html .= '<a href="'.api_get_self().'?action=add">'.Display::return_icon('add.png', get_lang('Add'), '', '32').'</a>';
61 61
 		$html .= '</div>';
62 62
         $html .= Display::grid_html('timelines');
63 63
         return $html;
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
         }
245 245
         unset($item['end_date']);
246 246
         // Assets
247
-        $item['asset'] = array( 'media'     => $item['media'],
247
+        $item['asset'] = array('media'     => $item['media'],
248 248
                                 'credit'    => $item['media_credit'],
249 249
                                 'caption'   => $item['media_caption'],
250 250
          );
Please login to merge, or discard this patch.
main/inc/lib/urlmanager.lib.php 2 patches
Indentation   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -11,15 +11,15 @@  discard block
 block discarded – undo
11 11
 class UrlManager
12 12
 {
13 13
     /**
14
-    * Creates a new url access
15
-    *
16
-    * @author Julio Montoya <[email protected]>,
17
-    *
18
-    * @param	string	$url The URL of the site
19
-    * @param	string  $description The description of the site
20
-    * @param	int		$active is active or not
21
-    * @return boolean if success
22
-    */
14
+     * Creates a new url access
15
+     *
16
+     * @author Julio Montoya <[email protected]>,
17
+     *
18
+     * @param	string	$url The URL of the site
19
+     * @param	string  $description The description of the site
20
+     * @param	int		$active is active or not
21
+     * @return boolean if success
22
+     */
23 23
     public static function add($url, $description, $active)
24 24
     {
25 25
         $tms = time();
@@ -36,15 +36,15 @@  discard block
 block discarded – undo
36 36
     }
37 37
 
38 38
     /**
39
-    * Updates an URL access
40
-    * @author Julio Montoya <[email protected]>,
41
-    *
42
-    * @param	int 	$url_id The url id
43
-    * @param	string 	$url
44
-    * @param	string  $description The description of the site
45
-    * @param	int		$active is active or not
46
-    * @return 	boolean if success
47
-    */
39
+     * Updates an URL access
40
+     * @author Julio Montoya <[email protected]>,
41
+     *
42
+     * @param	int 	$url_id The url id
43
+     * @param	string 	$url
44
+     * @param	string  $description The description of the site
45
+     * @param	int		$active is active or not
46
+     * @return 	boolean if success
47
+     */
48 48
     public static function update($url_id, $url, $description, $active)
49 49
     {
50 50
         $url_id = intval($url_id);
@@ -63,12 +63,12 @@  discard block
 block discarded – undo
63 63
     }
64 64
 
65 65
     /**
66
-    * Deletes an url
67
-    * @author Julio Montoya
68
-    * @param int $id url id
66
+     * Deletes an url
67
+     * @author Julio Montoya
68
+     * @param int $id url id
69 69
      *
70
-    * @return boolean true if success
71
-    * */
70
+     * @return boolean true if success
71
+     * */
72 72
     public static function delete($id)
73 73
     {
74 74
         $id = intval($id);
@@ -200,12 +200,12 @@  discard block
 block discarded – undo
200 200
     }
201 201
 
202 202
     /**
203
-    * Gets the inner join of access_url and the course table
204
-    *
205
-    * @author Julio Montoya
206
-    * @param int  access url id
207
-    * @return array   Database::store_result of the result
208
-    **/
203
+     * Gets the inner join of access_url and the course table
204
+     *
205
+     * @author Julio Montoya
206
+     * @param int  access url id
207
+     * @return array   Database::store_result of the result
208
+     **/
209 209
     public static function get_url_rel_course_data($access_url_id = null)
210 210
     {
211 211
         $where = '';
@@ -362,12 +362,12 @@  discard block
 block discarded – undo
362 362
     }
363 363
 
364 364
     /**
365
-    * Checks the relationship between an URL and a User (return the num_rows)
366
-    * @author Julio Montoya
367
-    * @param int user id
368
-    * @param int url id
369
-    * @return boolean true if success
370
-    * */
365
+     * Checks the relationship between an URL and a User (return the num_rows)
366
+     * @author Julio Montoya
367
+     * @param int user id
368
+     * @param int url id
369
+     * @return boolean true if success
370
+     * */
371 371
     public static function relation_url_user_exist($user_id, $url_id)
372 372
     {
373 373
         $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
@@ -377,15 +377,15 @@  discard block
 block discarded – undo
377 377
         $num = Database::num_rows($result);
378 378
 
379 379
         return $num;
380
-	}
380
+    }
381 381
 
382 382
     /**
383
-    * Checks the relationship between an URL and a Course (return the num_rows)
384
-    * @author Julio Montoya
385
-    * @param int $courseId
386
-    * @param int $urlId
387
-    * @return boolean true if success
388
-    * */
383
+     * Checks the relationship between an URL and a Course (return the num_rows)
384
+     * @author Julio Montoya
385
+     * @param int $courseId
386
+     * @param int $urlId
387
+     * @return boolean true if success
388
+     * */
389 389
     public static function relation_url_course_exist($courseId, $urlId)
390 390
     {
391 391
         $table_url_rel_course = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
@@ -420,12 +420,12 @@  discard block
 block discarded – undo
420 420
     }
421 421
 
422 422
     /**
423
-    * Checks the relationship between an URL and a Session (return the num_rows)
424
-    * @author Julio Montoya
425
-    * @param int user id
426
-    * @param int url id
427
-    * @return boolean true if success
428
-    * */
423
+     * Checks the relationship between an URL and a Session (return the num_rows)
424
+     * @author Julio Montoya
425
+     * @param int user id
426
+     * @param int url id
427
+     * @return boolean true if success
428
+     * */
429 429
     public static function relation_url_session_exist($session_id, $url_id)
430 430
     {
431 431
         $table_url_rel_session= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
@@ -737,13 +737,13 @@  discard block
 block discarded – undo
737 737
     }
738 738
 
739 739
     /**
740
-    * Deletes an url and user relationship
741
-    * @author Julio Montoya
742
-    * @param int user id
743
-    * @param int url id
740
+     * Deletes an url and user relationship
741
+     * @author Julio Montoya
742
+     * @param int user id
743
+     * @param int url id
744 744
      *
745
-    * @return boolean true if success
746
-    * */
745
+     * @return boolean true if success
746
+     * */
747 747
     public static function delete_url_rel_user($user_id, $url_id)
748 748
     {
749 749
         $table_url_rel_user = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
@@ -758,13 +758,13 @@  discard block
 block discarded – undo
758 758
     }
759 759
 
760 760
     /**
761
-    * Deletes an url and course relationship
762
-    * @author Julio Montoya
763
-    * @param  int  $courseId
764
-    * @param  int  $urlId
761
+     * Deletes an url and course relationship
762
+     * @author Julio Montoya
763
+     * @param  int  $courseId
764
+     * @param  int  $urlId
765 765
      *
766
-    * @return boolean true if success
767
-    * */
766
+     * @return boolean true if success
767
+     * */
768 768
     public static function delete_url_rel_course($courseId, $urlId)
769 769
     {
770 770
         $table_url_rel_course= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
@@ -814,13 +814,13 @@  discard block
 block discarded – undo
814 814
     }
815 815
 
816 816
     /**
817
-    * Deletes an url and session relationship
818
-    * @author Julio Montoya
819
-    * @param  char  course code
820
-    * @param  int url id
817
+     * Deletes an url and session relationship
818
+     * @author Julio Montoya
819
+     * @param  char  course code
820
+     * @param  int url id
821 821
      *
822
-    * @return boolean true if success
823
-    * */
822
+     * @return boolean true if success
823
+     * */
824 824
     public static function delete_url_rel_session($session_id, $url_id)
825 825
     {
826 826
         $table_url_rel_session = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
Please login to merge, or discard this patch.
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
     public static function add($url, $description, $active)
24 24
     {
25 25
         $tms = time();
26
-        $table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
26
+        $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
27 27
         $sql = "INSERT INTO $table
28 28
                 SET url 	= '".Database::escape_string($url)."',
29 29
                 description = '".Database::escape_string($description)."',
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
         $sql = "DELETE FROM $tableUser WHERE access_url_id = ".$id;
93 93
         Database::query($sql);
94 94
 
95
-        $sql= "DELETE FROM $table WHERE id = ".$id;
95
+        $sql = "DELETE FROM $table WHERE id = ".$id;
96 96
         Database::query($sql);
97 97
 
98 98
         return true;
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
      */
106 106
     public static function url_exist($url)
107 107
     {
108
-        $table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
108
+        $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
109 109
         $sql = "SELECT id FROM $table
110 110
                 WHERE url = '".Database::escape_string($url)."' ";
111 111
         $res = Database::query($sql);
@@ -139,10 +139,10 @@  discard block
 block discarded – undo
139 139
      * */
140 140
     public static function url_count()
141 141
     {
142
-        $table_access_url= Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
142
+        $table_access_url = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
143 143
         $sql = "SELECT count(id) as count_result FROM $table_access_url";
144 144
         $res = Database::query($sql);
145
-        $url = Database::fetch_array($res,'ASSOC');
145
+        $url = Database::fetch_array($res, 'ASSOC');
146 146
         $result = $url['count_result'];
147 147
 
148 148
         return $result;
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
                 FROM $table
161 161
                 ORDER BY id";
162 162
         $res = Database::query($sql);
163
-        $urls = array ();
163
+        $urls = array();
164 164
         while ($url = Database::fetch_array($res)) {
165 165
             $urls[] = $url;
166 166
         }
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
      **/
278 278
     public static function get_url_rel_session_data($access_url_id = null)
279 279
     {
280
-        $where ='';
280
+        $where = '';
281 281
         $table_url_rel_session = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
282 282
         $tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION);
283 283
 
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
         $table_user_group = Database::get_main_table(TABLE_USERGROUP);
314 314
 
315 315
         if (!empty($access_url_id)) {
316
-            $where ="WHERE $table_url_rel_usergroup.access_url_id = ".intval($access_url_id);
316
+            $where = "WHERE $table_url_rel_usergroup.access_url_id = ".intval($access_url_id);
317 317
         }
318 318
 
319 319
         $sql = "SELECT id, name, access_url_id
@@ -391,7 +391,7 @@  discard block
 block discarded – undo
391 391
     public static function relation_url_user_exist($user_id, $url_id)
392 392
     {
393 393
         $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
394
-        $sql= "SELECT user_id FROM $table
394
+        $sql = "SELECT user_id FROM $table
395 395
                WHERE access_url_id = ".intval($url_id)." AND user_id = ".intval($user_id)." ";
396 396
         $result = Database::query($sql);
397 397
         $num = Database::num_rows($result);
@@ -409,7 +409,7 @@  discard block
 block discarded – undo
409 409
     public static function relation_url_course_exist($courseId, $urlId)
410 410
     {
411 411
         $table_url_rel_course = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
412
-        $sql= "SELECT c_id FROM $table_url_rel_course
412
+        $sql = "SELECT c_id FROM $table_url_rel_course
413 413
                WHERE
414 414
                     access_url_id = ".intval($urlId)." AND
415 415
                     c_id = '".intval($courseId)."'";
@@ -430,7 +430,7 @@  discard block
 block discarded – undo
430 430
     public static function relationUrlUsergroupExist($userGroupId, $urlId)
431 431
     {
432 432
         $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USERGROUP);
433
-        $sql= "SELECT usergroup_id FROM $table
433
+        $sql = "SELECT usergroup_id FROM $table
434 434
                WHERE 
435 435
                     access_url_id = ".intval($urlId)." AND
436 436
                     usergroup_id = ".intval($userGroupId);
@@ -449,9 +449,9 @@  discard block
 block discarded – undo
449 449
     * */
450 450
     public static function relation_url_session_exist($session_id, $url_id)
451 451
     {
452
-        $table_url_rel_session= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
452
+        $table_url_rel_session = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
453 453
         $session_id = intval($session_id);
454
-        $url_id		= intval($url_id);
454
+        $url_id = intval($url_id);
455 455
         $sql = "SELECT session_id FROM $table_url_rel_session
456 456
                 WHERE
457 457
                     access_url_id = ".intval($url_id)." AND
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
         if (is_array($user_list) && is_array($url_list)) {
478 478
             foreach ($url_list as $url_id) {
479 479
                 foreach ($user_list as $user_id) {
480
-                    $count = UrlManager::relation_url_user_exist($user_id,$url_id);
480
+                    $count = UrlManager::relation_url_user_exist($user_id, $url_id);
481 481
                     if ($count == 0) {
482 482
                         $sql = "INSERT INTO $table_url_rel_user
483 483
                                 SET 
@@ -505,7 +505,7 @@  discard block
 block discarded – undo
505 505
      * @param  array of url_ids
506 506
      * @return array
507 507
      **/
508
-    public static function add_courses_to_urls($course_list,$url_list)
508
+    public static function add_courses_to_urls($course_list, $url_list)
509 509
     {
510 510
         $table_url_rel_course = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
511 511
         $result_array = array();
@@ -517,7 +517,7 @@  discard block
 block discarded – undo
517 517
                     $courseId = $courseInfo['real_id'];
518 518
 
519 519
                     $count = self::relation_url_course_exist($courseId, $url_id);
520
-                    if ($count==0) {
520
+                    if ($count == 0) {
521 521
                         $sql = "INSERT INTO $table_url_rel_course
522 522
                                 SET c_id = '".$courseId."', access_url_id = ".intval($url_id);
523 523
                         $result = Database::query($sql);
@@ -603,7 +603,7 @@  discard block
 block discarded – undo
603 603
     public static function relationUrlCourseCategoryExist($categoryCourseId, $urlId)
604 604
     {
605 605
         $table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE_CATEGORY);
606
-        $sql= "SELECT course_category_id FROM $table
606
+        $sql = "SELECT course_category_id FROM $table
607 607
                WHERE access_url_id = ".intval($urlId)." AND
608 608
                      course_category_id = ".intval($categoryCourseId);
609 609
         $result = Database::query($sql);
@@ -774,7 +774,7 @@  discard block
 block discarded – undo
774 774
         $table_url_rel_user = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
775 775
         $result = true;
776 776
         if (!empty($user_id) && !empty($url_id)) {
777
-            $sql= "DELETE FROM $table_url_rel_user
777
+            $sql = "DELETE FROM $table_url_rel_user
778 778
                    WHERE user_id = ".intval($user_id)." AND access_url_id = ".intval($url_id);
779 779
             $result = Database::query($sql);
780 780
         }
@@ -794,7 +794,7 @@  discard block
 block discarded – undo
794 794
         $table_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
795 795
         $result = true;
796 796
         if (!empty($userId)) {
797
-            $sql= "DELETE FROM $table_url_rel_user
797
+            $sql = "DELETE FROM $table_url_rel_user
798 798
                    WHERE user_id = ".intval($userId);
799 799
             Database::query($sql);
800 800
         }
@@ -812,8 +812,8 @@  discard block
 block discarded – undo
812 812
     * */
813 813
     public static function delete_url_rel_course($courseId, $urlId)
814 814
     {
815
-        $table_url_rel_course= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
816
-        $sql= "DELETE FROM $table_url_rel_course
815
+        $table_url_rel_course = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
816
+        $sql = "DELETE FROM $table_url_rel_course
817 817
                WHERE c_id = '".intval($courseId)."' AND access_url_id=".intval($urlId)."  ";
818 818
         $result = Database::query($sql);
819 819
 
@@ -831,7 +831,7 @@  discard block
 block discarded – undo
831 831
     public static function delete_url_rel_usergroup($userGroupId, $urlId)
832 832
     {
833 833
         $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USERGROUP);
834
-        $sql= "DELETE FROM $table
834
+        $sql = "DELETE FROM $table
835 835
                WHERE usergroup_id = '".intval($userGroupId)."' AND
836 836
                      access_url_id = ".intval($urlId);
837 837
         $result = Database::query($sql);
@@ -850,7 +850,7 @@  discard block
 block discarded – undo
850 850
     public static function deleteUrlRelCourseCategory($userGroupId, $urlId)
851 851
     {
852 852
         $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE_CATEGORY);
853
-        $sql= "DELETE FROM $table
853
+        $sql = "DELETE FROM $table
854 854
                WHERE course_category_id = '".intval($userGroupId)."' AND
855 855
                      access_url_id=".intval($urlId)."  ";
856 856
         $result = Database::query($sql);
@@ -869,9 +869,9 @@  discard block
 block discarded – undo
869 869
     public static function delete_url_rel_session($session_id, $url_id)
870 870
     {
871 871
         $table_url_rel_session = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
872
-        $sql= "DELETE FROM $table_url_rel_session
872
+        $sql = "DELETE FROM $table_url_rel_session
873 873
                WHERE session_id = ".intval($session_id)." AND access_url_id=".intval($url_id)."  ";
874
-        $result = Database::query($sql,'ASSOC');
874
+        $result = Database::query($sql, 'ASSOC');
875 875
 
876 876
         return $result;
877 877
     }
@@ -884,7 +884,7 @@  discard block
 block discarded – undo
884 884
      * */
885 885
     public static function update_urls_rel_user($user_list, $access_url_id)
886 886
     {
887
-        $table_url_rel_user	= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
887
+        $table_url_rel_user = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
888 888
         $sql = "SELECT user_id 
889 889
                 FROM $table_url_rel_user 
890 890
                 WHERE access_url_id = ".intval($access_url_id);
@@ -940,7 +940,7 @@  discard block
 block discarded – undo
940 940
         $result = Database::query($sql);
941 941
 
942 942
         $existing_courses = array();
943
-        while ($row = Database::fetch_array($result)){
943
+        while ($row = Database::fetch_array($result)) {
944 944
             $existing_courses[] = $row['c_id'];
945 945
         }
946 946
 
@@ -973,7 +973,7 @@  discard block
 block discarded – undo
973 973
         $result = Database::query($sql);
974 974
         $existingItems = array();
975 975
 
976
-        while ($row = Database::fetch_array($result)){
976
+        while ($row = Database::fetch_array($result)) {
977 977
             $existingItems[] = $row['usergroup_id'];
978 978
         }
979 979
 
@@ -1006,7 +1006,7 @@  discard block
 block discarded – undo
1006 1006
         $result = Database::query($sql);
1007 1007
         $existingItems = array();
1008 1008
 
1009
-        while ($row = Database::fetch_array($result)){
1009
+        while ($row = Database::fetch_array($result)) {
1010 1010
             $existingItems[] = $row['course_category_id'];
1011 1011
         }
1012 1012
 
@@ -1046,13 +1046,13 @@  discard block
 block discarded – undo
1046 1046
      * */
1047 1047
     public static function update_urls_rel_session($session_list, $access_url_id)
1048 1048
     {
1049
-        $table_url_rel_session	= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
1049
+        $table_url_rel_session = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
1050 1050
 
1051 1051
         $sql = "SELECT session_id FROM $table_url_rel_session WHERE access_url_id=".intval($access_url_id);
1052 1052
         $result = Database::query($sql);
1053 1053
         $existing_sessions = array();
1054 1054
 
1055
-        while ($row = Database::fetch_array($result)){
1055
+        while ($row = Database::fetch_array($result)) {
1056 1056
             $existing_sessions[] = $row['session_id'];
1057 1057
         }
1058 1058
 
@@ -1082,13 +1082,13 @@  discard block
 block discarded – undo
1082 1082
      */
1083 1083
     public static function get_access_url_from_user($user_id)
1084 1084
     {
1085
-        $table_url_rel_user	= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
1086
-        $table_url	= Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
1085
+        $table_url_rel_user = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
1086
+        $table_url = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
1087 1087
         $sql = "SELECT url, access_url_id FROM $table_url_rel_user url_rel_user INNER JOIN $table_url u
1088 1088
                 ON (url_rel_user.access_url_id = u.id)
1089 1089
                 WHERE user_id = ".intval($user_id);
1090 1090
         $result = Database::query($sql);
1091
-        $url_list = Database::store_result($result,'ASSOC');
1091
+        $url_list = Database::store_result($result, 'ASSOC');
1092 1092
 
1093 1093
         return $url_list;
1094 1094
     }
@@ -1099,14 +1099,14 @@  discard block
 block discarded – undo
1099 1099
      */
1100 1100
     public static function get_access_url_from_course($courseId)
1101 1101
     {
1102
-        $table	= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
1103
-        $table_url	= Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
1102
+        $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
1103
+        $table_url = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
1104 1104
         $sql = "SELECT url, access_url_id FROM $table c INNER JOIN $table_url u
1105 1105
                 ON (c.access_url_id = u.id)
1106 1106
                 WHERE c_id = ".intval($courseId);
1107 1107
 
1108 1108
         $result = Database::query($sql);
1109
-        $url_list = Database::store_result($result,'ASSOC');
1109
+        $url_list = Database::store_result($result, 'ASSOC');
1110 1110
         return $url_list;
1111 1111
     }
1112 1112
 
@@ -1117,7 +1117,7 @@  discard block
 block discarded – undo
1117 1117
     public static function get_access_url_from_session($session_id)
1118 1118
     {
1119 1119
         $table_url_rel_session = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
1120
-        $table_url  = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
1120
+        $table_url = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
1121 1121
         $sql = "SELECT url, access_url_id FROM $table_url_rel_session url_rel_session INNER JOIN $table_url u
1122 1122
                 ON (url_rel_session.access_url_id = u.id)
1123 1123
                 WHERE session_id = ".intval($session_id);
@@ -1133,7 +1133,7 @@  discard block
 block discarded – undo
1133 1133
      */
1134 1134
     public static function get_url_id($url)
1135 1135
     {
1136
-        $table_access_url= Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
1136
+        $table_access_url = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
1137 1137
         $sql = "SELECT id FROM $table_access_url WHERE url = '".Database::escape_string($url)."'";
1138 1138
         $result = Database::query($sql);
1139 1139
         $access_url_id = Database::result($result, 0, 0);
Please login to merge, or discard this patch.
main/inc/lib/tracking.lib.php 3 patches
Braces   +74 added lines, -31 removed lines patch added patch discarded remove patch
@@ -2259,7 +2259,9 @@  discard block
 block discarded – undo
2259 2259
             $debug = false;
2260 2260
         }
2261 2261
 
2262
-        if ($debug) echo '<h1>Tracking::get_avg_student_score</h1>';
2262
+        if ($debug) {
2263
+            echo '<h1>Tracking::get_avg_student_score</h1>';
2264
+        }
2263 2265
         $tbl_stats_exercices = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
2264 2266
         $tbl_stats_attempts = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
2265 2267
 
@@ -2336,7 +2338,9 @@  discard block
 block discarded – undo
2336 2338
                             $condition_user1 AND
2337 2339
                             session_id = $session_id
2338 2340
                         GROUP BY lp_id, user_id";
2339
-                if ($debug) echo $sql;
2341
+                if ($debug) {
2342
+                    echo $sql;
2343
+                }
2340 2344
 
2341 2345
                 $rs_last_lp_view_id = Database::query($sql);
2342 2346
 
@@ -2352,7 +2356,9 @@  discard block
 block discarded – undo
2352 2356
                         $lp_view_id = $row_lp_view['id'];
2353 2357
                         $lp_id      = $row_lp_view['lp_id'];
2354 2358
                         $user_id    = $row_lp_view['user_id'];
2355
-                        if ($debug) echo '<h2>LP id '.$lp_id.'</h2>';
2359
+                        if ($debug) {
2360
+                            echo '<h2>LP id '.$lp_id.'</h2>';
2361
+                        }
2356 2362
 
2357 2363
                         if ($get_only_latest_attempt_results) {
2358 2364
                             //Getting lp_items done by the user
@@ -2409,7 +2415,9 @@  discard block
 block discarded – undo
2409 2415
                                          lp_i.c_id  = $course_id AND
2410 2416
                                          (lp_i.item_type='sco' OR lp_i.item_type='".TOOL_QUIZ."')
2411 2417
                                       WHERE lp_view_id = $lp_view_id ";
2412
-                            if ($debug) echo $sql.'<br />';
2418
+                            if ($debug) {
2419
+                                echo $sql.'<br />';
2420
+                            }
2413 2421
                             $res_max_score = Database::query($sql);
2414 2422
 
2415 2423
                             while ($row_max_score = Database::fetch_array($res_max_score,'ASSOC')) {
@@ -2428,7 +2436,9 @@  discard block
 block discarded – undo
2428 2436
                             $max_score_item_view = $row_max_score['max_score_item_view'];
2429 2437
                             $score = $row_max_score['score'];
2430 2438
 
2431
-                            if ($debug) echo '<h3>Item Type: ' .$row_max_score['item_type'].'</h3>';
2439
+                            if ($debug) {
2440
+                                echo '<h3>Item Type: ' .$row_max_score['item_type'].'</h3>';
2441
+                            }
2432 2442
 
2433 2443
                             if ($row_max_score['item_type'] == 'sco') {
2434 2444
                                 /* Check if it is sco (easier to get max_score)
@@ -2448,7 +2458,9 @@  discard block
 block discarded – undo
2448 2458
                                 if (!empty($max_score)) {
2449 2459
                                     $lp_partial_total += $score/$max_score;
2450 2460
                                 }
2451
-                                if ($debug) echo '<b>$lp_partial_total, $score, $max_score '.$lp_partial_total.' '.$score.' '.$max_score.'</b><br />';
2461
+                                if ($debug) {
2462
+                                    echo '<b>$lp_partial_total, $score, $max_score '.$lp_partial_total.' '.$score.' '.$max_score.'</b><br />';
2463
+                                }
2452 2464
                             } else {
2453 2465
                                 // Case of a TOOL_QUIZ element
2454 2466
                                 $item_id = $row_max_score['iid'];
@@ -2470,12 +2482,16 @@  discard block
 block discarded – undo
2470 2482
                                         ORDER BY exe_date DESC
2471 2483
                                         LIMIT 1";
2472 2484
 
2473
-                                if ($debug) echo $sql .'<br />';
2485
+                                if ($debug) {
2486
+                                    echo $sql .'<br />';
2487
+                                }
2474 2488
                                 $result_last_attempt = Database::query($sql);
2475 2489
                                 $num = Database :: num_rows($result_last_attempt);
2476 2490
                                 if ($num > 0 ) {
2477 2491
                                     $id_last_attempt = Database :: result($result_last_attempt, 0, 0);
2478
-                                    if ($debug) echo $id_last_attempt.'<br />';
2492
+                                    if ($debug) {
2493
+                                        echo $id_last_attempt.'<br />';
2494
+                                    }
2479 2495
 
2480 2496
                                     // Within the last attempt number tracking, get the sum of
2481 2497
                                     // the max_scores of all questions that it was
@@ -2494,7 +2510,9 @@  discard block
 block discarded – undo
2494 2510
                                                     q.c_id = $course_id
2495 2511
                                             )
2496 2512
                                             AS t";
2497
-                                    if ($debug) echo '$sql: '.$sql.' <br />';
2513
+                                    if ($debug) {
2514
+                                        echo '$sql: '.$sql.' <br />';
2515
+                                    }
2498 2516
                                     $res_max_score_bis = Database::query($sql);
2499 2517
                                     $row_max_score_bis = Database::fetch_array($res_max_score_bis);
2500 2518
 
@@ -2504,7 +2522,9 @@  discard block
 block discarded – undo
2504 2522
                                     if (!empty($max_score) && floatval($max_score) > 0) {
2505 2523
                                         $lp_partial_total += $score/$max_score;
2506 2524
                                     }
2507
-                                    if ($debug) echo '$lp_partial_total, $score, $max_score <b>'.$lp_partial_total.' '.$score.' '.$max_score.'</b><br />';
2525
+                                    if ($debug) {
2526
+                                        echo '$lp_partial_total, $score, $max_score <b>'.$lp_partial_total.' '.$score.' '.$max_score.'</b><br />';
2527
+                                    }
2508 2528
                                 }
2509 2529
                             }
2510 2530
 
@@ -2517,17 +2537,25 @@  discard block
 block discarded – undo
2517 2537
                                         $count_items++;
2518 2538
                                     }
2519 2539
                                 }
2520
-                                if ($debug) echo '$count_items: '.$count_items;
2540
+                                if ($debug) {
2541
+                                    echo '$count_items: '.$count_items;
2542
+                                }
2521 2543
                             }
2522 2544
                         } //end for
2523 2545
 
2524 2546
                         $score_of_scorm_calculate += $count_items ? (($lp_partial_total / $count_items) * 100) : 0;
2525 2547
 
2526
-                        if ($debug) echo '<h3>$count_items '.$count_items.'</h3>';
2527
-                        if ($debug) echo '<h3>$score_of_scorm_calculate '.$score_of_scorm_calculate.'</h3>';
2548
+                        if ($debug) {
2549
+                            echo '<h3>$count_items '.$count_items.'</h3>';
2550
+                        }
2551
+                        if ($debug) {
2552
+                            echo '<h3>$score_of_scorm_calculate '.$score_of_scorm_calculate.'</h3>';
2553
+                        }
2528 2554
 
2529 2555
                         $global_result += $score_of_scorm_calculate;
2530
-                        if ($debug) echo '<h3>$global_result '.$global_result.'</h3>';
2556
+                        if ($debug) {
2557
+                            echo '<h3>$global_result '.$global_result.'</h3>';
2558
+                        }
2531 2559
                     } // end while
2532 2560
                 }
2533 2561
 
@@ -2540,7 +2568,9 @@  discard block
 block discarded – undo
2540 2568
                                 c_id = $course_id AND
2541 2569
                                 (item_type = 'quiz' OR item_type = 'sco') AND
2542 2570
                                 lp_id = ".$lp_id;
2543
-                    if ($debug) echo $sql;
2571
+                    if ($debug) {
2572
+                        echo $sql;
2573
+                    }
2544 2574
                     $result_have_quiz = Database::query($sql);
2545 2575
 
2546 2576
                     if (Database::num_rows($result_have_quiz) > 0 ) {
@@ -2551,19 +2581,29 @@  discard block
 block discarded – undo
2551 2581
                     }
2552 2582
                 }
2553 2583
 
2554
-                if ($debug) echo '<h3>$lp_with_quiz '.$lp_with_quiz.' </h3>';
2555
-                if ($debug) echo '<h3>Final return</h3>';
2584
+                if ($debug) {
2585
+                    echo '<h3>$lp_with_quiz '.$lp_with_quiz.' </h3>';
2586
+                }
2587
+                if ($debug) {
2588
+                    echo '<h3>Final return</h3>';
2589
+                }
2556 2590
 
2557 2591
                 if ($lp_with_quiz != 0) {
2558 2592
                     if (!$return_array) {
2559 2593
                         $score_of_scorm_calculate = round(($global_result/$lp_with_quiz),2);
2560
-                        if ($debug) var_dump($score_of_scorm_calculate);
2594
+                        if ($debug) {
2595
+                            var_dump($score_of_scorm_calculate);
2596
+                        }
2561 2597
                         if (empty($lp_ids)) {
2562
-                            if ($debug) echo '<h2>All lps fix: '.$score_of_scorm_calculate.'</h2>';
2598
+                            if ($debug) {
2599
+                                echo '<h2>All lps fix: '.$score_of_scorm_calculate.'</h2>';
2600
+                            }
2563 2601
                         }
2564 2602
                         return $score_of_scorm_calculate;
2565 2603
                     } else {
2566
-                        if ($debug) var_dump($global_result, $lp_with_quiz);
2604
+                        if ($debug) {
2605
+                            var_dump($global_result, $lp_with_quiz);
2606
+                        }
2567 2607
                         return array($global_result, $lp_with_quiz);
2568 2608
                     }
2569 2609
                 } else {
@@ -3050,11 +3090,13 @@  discard block
 block discarded – undo
3050 3090
 
3051 3091
         if (!empty ($id_session)) {
3052 3092
             $sql .= ' WHERE session_course.session_id=' . $id_session;
3053
-            if (api_is_multiple_url_enabled())
3054
-            $sql .=  ' AND access_url_id = '.$access_url_id;
3055
-        }  else {
3056
-            if (api_is_multiple_url_enabled())
3057
-            $sql .=  ' WHERE access_url_id = '.$access_url_id;
3093
+            if (api_is_multiple_url_enabled()) {
3094
+                        $sql .=  ' AND access_url_id = '.$access_url_id;
3095
+            }
3096
+        } else {
3097
+            if (api_is_multiple_url_enabled()) {
3098
+                        $sql .=  ' WHERE access_url_id = '.$access_url_id;
3099
+            }
3058 3100
         }
3059 3101
 
3060 3102
         $result = Database::query($sql);
@@ -3162,8 +3204,7 @@  discard block
 block discarded – undo
3162 3204
                 if ($session['access_start_date'] == '0000-00-00 00:00:00' || empty($session['access_start_date'])
3163 3205
                 ) {
3164 3206
                     $session['status'] = get_lang('SessionActive');
3165
-                }
3166
-                else {
3207
+                } else {
3167 3208
                     $time_start = api_strtotime($session['access_start_date'], 'UTC');
3168 3209
                     $time_end = api_strtotime($session['access_end_date'], 'UTC');
3169 3210
                     if ($time_start < time() && time() < $time_end) {
@@ -6599,8 +6640,9 @@  discard block
 block discarded – undo
6599 6640
     		if (is_array($hpresults)) {
6600 6641
     			for($i = 0; $i < sizeof($hpresults); $i++) {
6601 6642
     				$title = GetQuizName($hpresults[$i][0],'');
6602
-    				if ($title == '')
6603
-    				$title = basename($hpresults[$i][0]);
6643
+    				if ($title == '') {
6644
+    				    				$title = basename($hpresults[$i][0]);
6645
+    				}
6604 6646
     				$display_date = api_convert_and_format_date($hpresults[$i][3], null, date_default_timezone_get());
6605 6647
     				?>
6606 6648
                     <tr>
@@ -6972,8 +7014,9 @@  discard block
 block discarded – undo
6972 7014
     			for($i = 0; $i < sizeof($hpresults); $i++) {
6973 7015
     				$title = GetQuizName($hpresults[$i][0],'');
6974 7016
 
6975
-    				if ($title == '')
6976
-    				$title = basename($hpresults[$i][0]);
7017
+    				if ($title == '') {
7018
+    				    				$title = basename($hpresults[$i][0]);
7019
+    				}
6977 7020
 
6978 7021
     				$display_date = api_convert_and_format_date($hpresults[$i][3], null, date_default_timezone_get());
6979 7022
 
Please login to merge, or discard this patch.
Indentation   +849 added lines, -849 removed lines patch added patch discarded remove patch
@@ -314,8 +314,8 @@  discard block
 block discarded – undo
314 314
                     $extend_link = '';
315 315
                     if (!empty($inter_num)) {
316 316
                         $extend_link = Display::url(
317
-                              Display::return_icon('visible.gif', get_lang('HideAttemptView')),
318
-                              api_get_self() . '?action=stats&fold_id=' . $my_item_id . $url_suffix
317
+                                Display::return_icon('visible.gif', get_lang('HideAttemptView')),
318
+                                api_get_self() . '?action=stats&fold_id=' . $my_item_id . $url_suffix
319 319
                         );
320 320
                     }
321 321
                     $title = $row['mytitle'];
@@ -1370,7 +1370,7 @@  discard block
 block discarded – undo
1370 1370
                 $newDate = new DateTime('-30 days', new DateTimeZone('UTC'));
1371 1371
                 $condition_time = " AND (login_date >= '{$newDate->format('Y-m-d H:i:s')}'";
1372 1372
                 $condition_time .= "AND logout_date <= '{$today->format('Y-m-d H:i:s')}') ";
1373
-               break;
1373
+                break;
1374 1374
             case 'custom':
1375 1375
                 if (!empty($start_date) && !empty($end_date)) {
1376 1376
                     $start_date = Database::escape_string($start_date);
@@ -1380,10 +1380,10 @@  discard block
 block discarded – undo
1380 1380
                 break;
1381 1381
         }
1382 1382
 
1383
-    	$sql = 'SELECT SUM(TIMESTAMPDIFF(SECOND, login_date, logout_date)) diff
1383
+        $sql = 'SELECT SUM(TIMESTAMPDIFF(SECOND, login_date, logout_date)) diff
1384 1384
     	        FROM '.$tbl_track_login.'
1385 1385
                 WHERE '.$userCondition.$condition_time;
1386
-    	$rs = Database::query($sql);
1386
+        $rs = Database::query($sql);
1387 1387
         $row = Database::fetch_array($rs, 'ASSOC');
1388 1388
         $diff = $row['diff'];
1389 1389
 
@@ -1405,18 +1405,18 @@  discard block
 block discarded – undo
1405 1405
     public static function get_time_spent_on_the_course($user_id, $courseId, $session_id = 0)
1406 1406
     {
1407 1407
         $courseId = intval($courseId);
1408
-    	$session_id  = intval($session_id);
1409
-
1410
-    	$tbl_track_course = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1411
-    	if (is_array($user_id)) {
1412
-    	    $user_id = array_map('intval', $user_id);
1413
-    		$condition_user = " AND user_id IN (".implode(',',$user_id).") ";
1414
-    	} else {
1415
-    		$user_id = intval($user_id);
1416
-    		$condition_user = " AND user_id = $user_id ";
1417
-    	}
1418
-
1419
-    	$sql = "SELECT
1408
+        $session_id  = intval($session_id);
1409
+
1410
+        $tbl_track_course = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1411
+        if (is_array($user_id)) {
1412
+            $user_id = array_map('intval', $user_id);
1413
+            $condition_user = " AND user_id IN (".implode(',',$user_id).") ";
1414
+        } else {
1415
+            $user_id = intval($user_id);
1416
+            $condition_user = " AND user_id = $user_id ";
1417
+        }
1418
+
1419
+        $sql = "SELECT
1420 1420
     	        SUM(UNIX_TIMESTAMP(logout_course_date) - UNIX_TIMESTAMP(login_course_date)) as nb_seconds
1421 1421
                 FROM $tbl_track_course
1422 1422
                 WHERE UNIX_TIMESTAMP(logout_course_date) > UNIX_TIMESTAMP(login_course_date) ";
@@ -1431,9 +1431,9 @@  discard block
 block discarded – undo
1431 1431
 
1432 1432
         $sql .= $condition_user;
1433 1433
         $rs = Database::query($sql);
1434
-    	$row = Database::fetch_array($rs);
1434
+        $row = Database::fetch_array($rs);
1435 1435
 
1436
-    	return $row['nb_seconds'];
1436
+        return $row['nb_seconds'];
1437 1437
     }
1438 1438
 
1439 1439
     /**
@@ -1444,25 +1444,25 @@  discard block
 block discarded – undo
1444 1444
      */
1445 1445
     public static function get_first_connection_date($student_id)
1446 1446
     {
1447
-    	$tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
1448
-    	$sql = 'SELECT login_date
1447
+        $tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
1448
+        $sql = 'SELECT login_date
1449 1449
     	        FROM ' . $tbl_track_login . '
1450 1450
                 WHERE login_user_id = ' . intval($student_id) . '
1451 1451
                 ORDER BY login_date ASC
1452 1452
                 LIMIT 0,1';
1453 1453
 
1454
-    	$rs = Database::query($sql);
1455
-    	if (Database::num_rows($rs)>0) {
1456
-    		if ($first_login_date = Database::result($rs, 0, 0)) {
1454
+        $rs = Database::query($sql);
1455
+        if (Database::num_rows($rs)>0) {
1456
+            if ($first_login_date = Database::result($rs, 0, 0)) {
1457 1457
                 return api_convert_and_format_date(
1458 1458
                     $first_login_date,
1459 1459
                     DATE_FORMAT_SHORT,
1460 1460
                     date_default_timezone_get()
1461 1461
                 );
1462
-    		}
1463
-    	}
1462
+            }
1463
+        }
1464 1464
 
1465
-    	return false;
1465
+        return false;
1466 1466
     }
1467 1467
 
1468 1468
     /**
@@ -1475,38 +1475,38 @@  discard block
 block discarded – undo
1475 1475
      */
1476 1476
     public static function get_last_connection_date($student_id, $warning_message = false, $return_timestamp = false)
1477 1477
     {
1478
-    	$table = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
1479
-    	$sql = 'SELECT login_date
1478
+        $table = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
1479
+        $sql = 'SELECT login_date
1480 1480
     	        FROM ' . $table . '
1481 1481
                 WHERE login_user_id = ' . intval($student_id) . '
1482 1482
                 ORDER BY login_date
1483 1483
                 DESC LIMIT 0,1';
1484 1484
 
1485
-    	$rs = Database::query($sql);
1486
-    	if (Database::num_rows($rs) > 0) {
1487
-    		if ($last_login_date = Database::result($rs, 0, 0)) {
1488
-    			$last_login_date = api_get_local_time($last_login_date);
1489
-    			if ($return_timestamp) {
1490
-    				return api_strtotime($last_login_date,'UTC');
1491
-    			} else {
1492
-    				if (!$warning_message) {
1493
-    					return api_format_date($last_login_date, DATE_FORMAT_SHORT);
1494
-    				} else {
1495
-    					$timestamp = api_strtotime($last_login_date,'UTC');
1496
-    					$currentTimestamp = time();
1497
-
1498
-    					//If the last connection is > than 7 days, the text is red
1499
-    					//345600 = 7 days in seconds
1500
-    					if ($currentTimestamp - $timestamp > 604800) {
1501
-    						return '<span style="color: #F00;">' . api_format_date($last_login_date, DATE_FORMAT_SHORT) . '</span>';
1502
-    					} else {
1503
-    						return api_format_date($last_login_date, DATE_FORMAT_SHORT);
1504
-    					}
1505
-    				}
1506
-    			}
1507
-    		}
1508
-    	}
1509
-    	return false;
1485
+        $rs = Database::query($sql);
1486
+        if (Database::num_rows($rs) > 0) {
1487
+            if ($last_login_date = Database::result($rs, 0, 0)) {
1488
+                $last_login_date = api_get_local_time($last_login_date);
1489
+                if ($return_timestamp) {
1490
+                    return api_strtotime($last_login_date,'UTC');
1491
+                } else {
1492
+                    if (!$warning_message) {
1493
+                        return api_format_date($last_login_date, DATE_FORMAT_SHORT);
1494
+                    } else {
1495
+                        $timestamp = api_strtotime($last_login_date,'UTC');
1496
+                        $currentTimestamp = time();
1497
+
1498
+                        //If the last connection is > than 7 days, the text is red
1499
+                        //345600 = 7 days in seconds
1500
+                        if ($currentTimestamp - $timestamp > 604800) {
1501
+                            return '<span style="color: #F00;">' . api_format_date($last_login_date, DATE_FORMAT_SHORT) . '</span>';
1502
+                        } else {
1503
+                            return api_format_date($last_login_date, DATE_FORMAT_SHORT);
1504
+                        }
1505
+                    }
1506
+                }
1507
+            }
1508
+        }
1509
+        return false;
1510 1510
     }
1511 1511
 
1512 1512
     /**
@@ -1560,30 +1560,30 @@  discard block
 block discarded – undo
1560 1560
         $session_id = 0,
1561 1561
         $convert_date = true
1562 1562
     ) {
1563
-    	$student_id  = intval($student_id);
1563
+        $student_id  = intval($student_id);
1564 1564
         $courseId = intval($courseId);
1565
-    	$session_id  = intval($session_id);
1565
+        $session_id  = intval($session_id);
1566 1566
 
1567
-    	$tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1568
-    	$sql = 'SELECT login_course_date
1567
+        $tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1568
+        $sql = 'SELECT login_course_date
1569 1569
     	        FROM '.$tbl_track_login.'
1570 1570
                 WHERE
1571 1571
                     user_id = '.$student_id.' AND
1572 1572
                     c_id = '.$courseId.' AND
1573 1573
                     session_id = '.$session_id.'
1574 1574
                 ORDER BY login_course_date ASC LIMIT 0,1';
1575
-    	$rs = Database::query($sql);
1576
-    	if (Database::num_rows($rs) > 0) {
1577
-    		if ($first_login_date = Database::result($rs, 0, 0)) {
1578
-    			if ($convert_date) {
1579
-    				return api_convert_and_format_date($first_login_date, DATE_FORMAT_SHORT);
1580
-    			} else {
1581
-    				return $first_login_date;
1582
-    			}
1583
-    		}
1584
-    	}
1585
-
1586
-    	return false;
1575
+        $rs = Database::query($sql);
1576
+        if (Database::num_rows($rs) > 0) {
1577
+            if ($first_login_date = Database::result($rs, 0, 0)) {
1578
+                if ($convert_date) {
1579
+                    return api_convert_and_format_date($first_login_date, DATE_FORMAT_SHORT);
1580
+                } else {
1581
+                    return $first_login_date;
1582
+                }
1583
+            }
1584
+        }
1585
+
1586
+        return false;
1587 1587
     }
1588 1588
 
1589 1589
     /**
@@ -1599,13 +1599,13 @@  discard block
 block discarded – undo
1599 1599
         $session_id = 0,
1600 1600
         $convert_date = true
1601 1601
     ) {
1602
-    	// protect data
1603
-    	$student_id  = intval($student_id);
1602
+        // protect data
1603
+        $student_id  = intval($student_id);
1604 1604
         $courseId = $courseInfo['real_id'];
1605
-    	$session_id  = intval($session_id);
1605
+        $session_id  = intval($session_id);
1606 1606
 
1607
-    	$tbl_track_e_access = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
1608
-    	$sql = 'SELECT access_date
1607
+        $tbl_track_e_access = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
1608
+        $sql = 'SELECT access_date
1609 1609
                 FROM '.$tbl_track_e_access.'
1610 1610
                 WHERE   access_user_id = '.$student_id.' AND
1611 1611
                         c_id = "'.$courseId.'" AND
@@ -1613,39 +1613,39 @@  discard block
 block discarded – undo
1613 1613
                 ORDER BY access_date DESC
1614 1614
                 LIMIT 0,1';
1615 1615
 
1616
-    	$rs = Database::query($sql);
1617
-    	if (Database::num_rows($rs) > 0) {
1618
-    		if ($last_login_date = Database::result($rs, 0, 0)) {
1616
+        $rs = Database::query($sql);
1617
+        if (Database::num_rows($rs) > 0) {
1618
+            if ($last_login_date = Database::result($rs, 0, 0)) {
1619 1619
                 if (empty($last_login_date)) {
1620 1620
                     return false;
1621 1621
                 }
1622 1622
                 //see #5736
1623 1623
                 $last_login_date_timestamp = api_strtotime($last_login_date);
1624
-    			$now = time();
1625
-    			//If the last connection is > than 7 days, the text is red
1626
-    			//345600 = 7 days in seconds
1627
-    			if ($now - $last_login_date_timestamp > 604800) {
1628
-    				if ($convert_date) {
1624
+                $now = time();
1625
+                //If the last connection is > than 7 days, the text is red
1626
+                //345600 = 7 days in seconds
1627
+                if ($now - $last_login_date_timestamp > 604800) {
1628
+                    if ($convert_date) {
1629 1629
                         $last_login_date = api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT);
1630 1630
                         $icon = api_is_allowed_to_edit() ?
1631 1631
                             '<a href="'.api_get_path(WEB_CODE_PATH).'announcements/announcements.php?action=add&remind_inactive='.$student_id.'&cidReq='.$courseInfo['code'].'" title="'.get_lang('RemindInactiveUser').'">
1632 1632
                               '.Display::return_icon('messagebox_warning.gif').'
1633 1633
                              </a>'
1634 1634
                             : null;
1635
-    					return $icon. Display::label($last_login_date, 'warning');
1636
-    				} else {
1637
-    					return $last_login_date;
1638
-    				}
1639
-    			} else {
1640
-    				if ($convert_date) {
1641
-    					return api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT);
1642
-    				} else {
1643
-    					return $last_login_date;
1644
-    				}
1645
-    			}
1646
-    		}
1647
-    	}
1648
-    	return false;
1635
+                        return $icon. Display::label($last_login_date, 'warning');
1636
+                    } else {
1637
+                        return $last_login_date;
1638
+                    }
1639
+                } else {
1640
+                    if ($convert_date) {
1641
+                        return api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT);
1642
+                    } else {
1643
+                        return $last_login_date;
1644
+                    }
1645
+                }
1646
+            }
1647
+        }
1648
+        return false;
1649 1649
     }
1650 1650
 
1651 1651
     /**
@@ -1659,11 +1659,11 @@  discard block
 block discarded – undo
1659 1659
     public static function get_course_connections_count($courseId, $session_id = 0, $start = 0, $stop = null)
1660 1660
     {
1661 1661
         if ($start < 0) {
1662
-    		$start = 0;
1663
-    	}
1664
-    	if (!isset($stop) or ($stop < 0)) {
1665
-    		$stop = api_get_utc_datetime();
1666
-    	}
1662
+            $start = 0;
1663
+        }
1664
+        if (!isset($stop) or ($stop < 0)) {
1665
+            $stop = api_get_utc_datetime();
1666
+        }
1667 1667
 
1668 1668
         // Given we're storing in cache, round the start and end times
1669 1669
         // to the lower minute
@@ -1672,11 +1672,11 @@  discard block
 block discarded – undo
1672 1672
         $roundedStart = Database::escape_string($roundedStart);
1673 1673
         $roundedStop = Database::escape_string($roundedStop);
1674 1674
 
1675
-    	$month_filter = " AND login_course_date > '$roundedStart' AND login_course_date < '$roundedStop' ";
1675
+        $month_filter = " AND login_course_date > '$roundedStart' AND login_course_date < '$roundedStop' ";
1676 1676
 
1677 1677
         $courseId = intval($courseId);
1678
-    	$session_id  = intval($session_id);
1679
-    	$count = 0;
1678
+        $session_id  = intval($session_id);
1679
+        $count = 0;
1680 1680
         $tbl_track_e_course_access = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1681 1681
         $sql =  "SELECT count(*) as count_connections
1682 1682
                 FROM $tbl_track_e_course_access
@@ -1715,7 +1715,7 @@  discard block
 block discarded – undo
1715 1715
             }
1716 1716
         }
1717 1717
 
1718
-    	return $count;
1718
+        return $count;
1719 1719
     }
1720 1720
 
1721 1721
     /**
@@ -1726,25 +1726,25 @@  discard block
 block discarded – undo
1726 1726
      */
1727 1727
     public static function count_course_per_student($user_id, $include_sessions = true)
1728 1728
     {
1729
-    	$user_id = intval($user_id);
1730
-    	$tbl_course_rel_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
1731
-    	$tbl_session_course_rel_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
1729
+        $user_id = intval($user_id);
1730
+        $tbl_course_rel_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
1731
+        $tbl_session_course_rel_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
1732 1732
 
1733
-    	$sql = 'SELECT DISTINCT c_id
1733
+        $sql = 'SELECT DISTINCT c_id
1734 1734
                 FROM ' . $tbl_course_rel_user . '
1735 1735
                 WHERE user_id = ' . $user_id.' AND relation_type<>'.COURSE_RELATION_TYPE_RRHH;
1736
-    	$rs = Database::query($sql);
1737
-    	$nb_courses = Database::num_rows($rs);
1736
+        $rs = Database::query($sql);
1737
+        $nb_courses = Database::num_rows($rs);
1738 1738
 
1739
-    	if ($include_sessions) {
1740
-    		$sql = 'SELECT DISTINCT c_id
1739
+        if ($include_sessions) {
1740
+            $sql = 'SELECT DISTINCT c_id
1741 1741
                     FROM ' . $tbl_session_course_rel_user . '
1742 1742
                     WHERE user_id = ' . $user_id;
1743
-    		$rs = Database::query($sql);
1744
-    		$nb_courses += Database::num_rows($rs);
1745
-    	}
1743
+            $rs = Database::query($sql);
1744
+            $nb_courses += Database::num_rows($rs);
1745
+        }
1746 1746
 
1747
-    	return $nb_courses;
1747
+        return $nb_courses;
1748 1748
     }
1749 1749
 
1750 1750
     /**
@@ -1775,25 +1775,25 @@  discard block
 block discarded – undo
1775 1775
         $into_lp = 0
1776 1776
     ) {
1777 1777
         $course_code = Database::escape_string($course_code);
1778
-    	$course_info = api_get_course_info($course_code);
1779
-    	if (!empty($course_info)) {
1780
-    		// table definition
1781
-    		$tbl_course_quiz     = Database::get_course_table(TABLE_QUIZ_TEST);
1782
-    		$tbl_stats_exercise  = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
1783
-
1784
-    		// Compose a filter based on optional exercise given
1785
-    		$condition_quiz = "";
1786
-    		if (!empty($exercise_id)) {
1787
-    			$exercise_id = intval($exercise_id);
1788
-    			$condition_quiz =" AND id = $exercise_id ";
1789
-    		}
1790
-
1791
-    		// Compose a filter based on optional session id given
1792
-    		$condition_session = "";
1793
-    		if (isset($session_id)) {
1794
-    			$session_id = intval($session_id);
1795
-    			$condition_session = " AND session_id = $session_id ";
1796
-    		}
1778
+        $course_info = api_get_course_info($course_code);
1779
+        if (!empty($course_info)) {
1780
+            // table definition
1781
+            $tbl_course_quiz     = Database::get_course_table(TABLE_QUIZ_TEST);
1782
+            $tbl_stats_exercise  = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
1783
+
1784
+            // Compose a filter based on optional exercise given
1785
+            $condition_quiz = "";
1786
+            if (!empty($exercise_id)) {
1787
+                $exercise_id = intval($exercise_id);
1788
+                $condition_quiz =" AND id = $exercise_id ";
1789
+            }
1790
+
1791
+            // Compose a filter based on optional session id given
1792
+            $condition_session = "";
1793
+            if (isset($session_id)) {
1794
+                $session_id = intval($session_id);
1795
+                $condition_session = " AND session_id = $session_id ";
1796
+            }
1797 1797
             if ($active_filter == 1) {
1798 1798
                 $condition_active = 'AND active <> -1';
1799 1799
             } elseif ($active_filter == 0) {
@@ -1809,7 +1809,7 @@  discard block
 block discarded – undo
1809 1809
                 $select_lp_id = ', orig_lp_id as lp_id ';
1810 1810
             }
1811 1811
 
1812
-    		$sql = "SELECT count(id) FROM $tbl_course_quiz
1812
+            $sql = "SELECT count(id) FROM $tbl_course_quiz
1813 1813
     				WHERE c_id = {$course_info['real_id']} $condition_active $condition_quiz ";
1814 1814
             $count_quiz = 0;
1815 1815
             $countQuizResult = Database::query($sql);
@@ -1817,21 +1817,21 @@  discard block
 block discarded – undo
1817 1817
                 $count_quiz = Database::fetch_row($countQuizResult);
1818 1818
             }
1819 1819
 
1820
-    		if (!empty($count_quiz[0]) && !empty($student_id)) {
1821
-    			if (is_array($student_id)) {
1820
+            if (!empty($count_quiz[0]) && !empty($student_id)) {
1821
+                if (is_array($student_id)) {
1822 1822
                     $student_id = array_map('intval', $student_id);
1823
-    				$condition_user = " AND exe_user_id IN (".implode(',', $student_id).") ";
1824
-    			} else {
1823
+                    $condition_user = " AND exe_user_id IN (".implode(',', $student_id).") ";
1824
+                } else {
1825 1825
                     $student_id = intval($student_id);
1826
-    				$condition_user = " AND exe_user_id = '$student_id' ";
1827
-    			}
1826
+                    $condition_user = " AND exe_user_id = '$student_id' ";
1827
+                }
1828 1828
 
1829
-    			if (empty($exercise_id)) {
1830
-    				$sql = "SELECT id FROM $tbl_course_quiz
1829
+                if (empty($exercise_id)) {
1830
+                    $sql = "SELECT id FROM $tbl_course_quiz
1831 1831
     						WHERE c_id = {$course_info['real_id']} $condition_active $condition_quiz";
1832 1832
                     $result = Database::query($sql);
1833 1833
                     $exercise_list = array();
1834
-    				$exercise_id = null;
1834
+                    $exercise_id = null;
1835 1835
                     if (!empty($result) && Database::num_rows($result)) {
1836 1836
                         while ($row = Database::fetch_array($result)) {
1837 1837
                             $exercise_list[] = $row['id'];
@@ -1840,11 +1840,11 @@  discard block
 block discarded – undo
1840 1840
                     if (!empty($exercise_list)) {
1841 1841
                         $exercise_id = implode("','",$exercise_list);
1842 1842
                     }
1843
-    			}
1843
+                }
1844 1844
 
1845
-    			$count_quiz = Database::fetch_row(Database::query($sql));
1845
+                $count_quiz = Database::fetch_row(Database::query($sql));
1846 1846
 
1847
-    			$sql = "SELECT
1847
+                $sql = "SELECT
1848 1848
     			        SUM(exe_result/exe_weighting*100) as avg_score,
1849 1849
     			        COUNT(*) as num_attempts
1850 1850
     			        $select_lp_id
@@ -1858,20 +1858,20 @@  discard block
 block discarded – undo
1858 1858
                             $condition_into_lp
1859 1859
                         ORDER BY exe_date DESC";
1860 1860
 
1861
-    			$res = Database::query($sql);
1862
-    			$row = Database::fetch_array($res);
1863
-    			$quiz_avg_score = null;
1861
+                $res = Database::query($sql);
1862
+                $row = Database::fetch_array($res);
1863
+                $quiz_avg_score = null;
1864 1864
 
1865
-    			if (!empty($row['avg_score'])) {
1866
-    				$quiz_avg_score = round($row['avg_score'],2);
1867
-    			}
1865
+                if (!empty($row['avg_score'])) {
1866
+                    $quiz_avg_score = round($row['avg_score'],2);
1867
+                }
1868 1868
 
1869
-    			if(!empty($row['num_attempts'])) {
1870
-    				$quiz_avg_score = round($quiz_avg_score / $row['num_attempts'], 2);
1871
-    			}
1872
-    			if (is_array($student_id)) {
1873
-    				$quiz_avg_score = round($quiz_avg_score / count($student_id), 2);
1874
-    			}
1869
+                if(!empty($row['num_attempts'])) {
1870
+                    $quiz_avg_score = round($quiz_avg_score / $row['num_attempts'], 2);
1871
+                }
1872
+                if (is_array($student_id)) {
1873
+                    $quiz_avg_score = round($quiz_avg_score / count($student_id), 2);
1874
+                }
1875 1875
                 if ($into_lp == 0) {
1876 1876
                     return $quiz_avg_score;
1877 1877
                 } else {
@@ -1894,9 +1894,9 @@  discard block
 block discarded – undo
1894 1894
                         return array($quiz_avg_score, null);
1895 1895
                     }
1896 1896
                 }
1897
-    		}
1898
-    	}
1899
-    	return null;
1897
+            }
1898
+        }
1899
+        return null;
1900 1900
     }
1901 1901
 
1902 1902
     /**
@@ -1929,15 +1929,15 @@  discard block
 block discarded – undo
1929 1929
         $find_all_lp = 0
1930 1930
     ) {
1931 1931
         $courseId = intval($courseId);
1932
-    	$student_id  = intval($student_id);
1933
-    	$exercise_id = intval($exercise_id);
1934
-    	$session_id  = intval($session_id);
1932
+        $student_id  = intval($student_id);
1933
+        $exercise_id = intval($exercise_id);
1934
+        $session_id  = intval($session_id);
1935 1935
 
1936
-    	$lp_id = intval($lp_id);
1936
+        $lp_id = intval($lp_id);
1937 1937
         $lp_item_id = intval($lp_item_id);
1938
-    	$tbl_stats_exercises = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
1938
+        $tbl_stats_exercises = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
1939 1939
 
1940
-    	$sql = "SELECT COUNT(ex.exe_id) as essais FROM $tbl_stats_exercises AS ex
1940
+        $sql = "SELECT COUNT(ex.exe_id) as essais FROM $tbl_stats_exercises AS ex
1941 1941
                 WHERE  ex.c_id = $courseId
1942 1942
                 AND ex.exe_exo_id = $exercise_id
1943 1943
                 AND status = ''
@@ -1952,11 +1952,11 @@  discard block
 block discarded – undo
1952 1952
                 AND orig_lp_item_id = $lp_item_id";
1953 1953
         }
1954 1954
 
1955
-    	$rs = Database::query($sql);
1956
-    	$row = Database::fetch_row($rs);
1957
-    	$count_attempts = $row[0];
1955
+        $rs = Database::query($sql);
1956
+        $row = Database::fetch_row($rs);
1957
+        $count_attempts = $row[0];
1958 1958
 
1959
-    	return $count_attempts;
1959
+        return $count_attempts;
1960 1960
     }
1961 1961
 
1962 1962
     /**
@@ -1966,7 +1966,7 @@  discard block
 block discarded – undo
1966 1966
      * @param int    $user_id
1967 1967
      * @param int    $courseId
1968 1968
      * @param int    $session_id
1969
-    */
1969
+     */
1970 1970
     public static function get_exercise_student_progress($exercise_list, $user_id, $courseId, $session_id)
1971 1971
     {
1972 1972
         $courseId = intval($courseId);
@@ -3634,8 +3634,8 @@  discard block
 block discarded – undo
3634 3634
 
3635 3635
         $condition_session = '';
3636 3636
         if (isset($session_id)) {
3637
-             $session_id = intval($session_id);
3638
-             $condition_session = ' AND f.session_id = '. $session_id;
3637
+                $session_id = intval($session_id);
3638
+                $condition_session = ' AND f.session_id = '. $session_id;
3639 3639
         }
3640 3640
 
3641 3641
         $groupId = intval($groupId);
@@ -5564,9 +5564,9 @@  discard block
 block discarded – undo
5564 5564
     }
5565 5565
 
5566 5566
     /**
5567
-    * @param FormValidator $form
5568
-    * @return mixed
5569
-    */
5567
+     * @param FormValidator $form
5568
+     * @return mixed
5569
+     */
5570 5570
     public static function setUserSearchForm($form)
5571 5571
     {
5572 5572
         global $_configuration;
@@ -5961,26 +5961,26 @@  discard block
 block discarded – undo
5961 5961
         $session_id = api_get_session_id();
5962 5962
         $course_id = api_get_course_int_id();
5963 5963
 
5964
-    	$table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
5965
-    	$table_user = Database :: get_main_table(TABLE_MAIN_USER);
5964
+        $table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
5965
+        $table_user = Database :: get_main_table(TABLE_MAIN_USER);
5966 5966
 
5967
-    	$sql = "SELECT count(tool) AS total_number_of_items
5967
+        $sql = "SELECT count(tool) AS total_number_of_items
5968 5968
     	        FROM $table_item_property track_resource, $table_user user
5969 5969
     	        WHERE
5970 5970
                     track_resource.c_id = $course_id AND
5971 5971
                     track_resource.insert_user_id = user.user_id AND
5972 5972
                     session_id " .(empty($session_id) ? ' IS NULL ' : " = $session_id ");
5973 5973
 
5974
-    	if (isset($_GET['keyword'])) {
5975
-    		$keyword = Database::escape_string(trim($_GET['keyword']));
5976
-    		$sql .= " AND (
5974
+        if (isset($_GET['keyword'])) {
5975
+            $keyword = Database::escape_string(trim($_GET['keyword']));
5976
+            $sql .= " AND (
5977 5977
     		            user.username LIKE '%".$keyword."%' OR
5978 5978
     		            lastedit_type LIKE '%".$keyword."%' OR
5979 5979
     		            tool LIKE '%".$keyword."%'
5980 5980
                     )";
5981
-    	}
5981
+        }
5982 5982
 
5983
-    	$sql .= " AND tool IN (
5983
+        $sql .= " AND tool IN (
5984 5984
     	            'document',
5985 5985
     	            'learnpath',
5986 5986
     	            'quiz',
@@ -5992,10 +5992,10 @@  discard block
 block discarded – undo
5992 5992
     	            'thematic_advance',
5993 5993
     	            'thematic_plan'
5994 5994
                 )";
5995
-    	$res = Database::query($sql);
5996
-    	$obj = Database::fetch_object($res);
5995
+        $res = Database::query($sql);
5996
+        $obj = Database::fetch_object($res);
5997 5997
 
5998
-    	return $obj->total_number_of_items;
5998
+        return $obj->total_number_of_items;
5999 5999
     }
6000 6000
 
6001 6001
     /**
@@ -6010,12 +6010,12 @@  discard block
 block discarded – undo
6010 6010
         $session_id = api_get_session_id();
6011 6011
         $course_id = api_get_course_int_id();
6012 6012
 
6013
-    	$table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
6014
-    	$table_user = Database :: get_main_table(TABLE_MAIN_USER);
6015
-    	$table_session = Database :: get_main_table(TABLE_MAIN_SESSION);
6016
-    	$session_id = intval($session_id);
6013
+        $table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
6014
+        $table_user = Database :: get_main_table(TABLE_MAIN_USER);
6015
+        $table_session = Database :: get_main_table(TABLE_MAIN_SESSION);
6016
+        $session_id = intval($session_id);
6017 6017
 
6018
-    	$sql = "SELECT
6018
+        $sql = "SELECT
6019 6019
                     tool as col0,
6020 6020
                     lastedit_type as col1,
6021 6021
                     ref as ref,
@@ -6029,16 +6029,16 @@  discard block
 block discarded – undo
6029 6029
                   track_resource.insert_user_id = user.user_id AND
6030 6030
                   session_id " .(empty($session_id) ? ' IS NULL ' : " = $session_id ");
6031 6031
 
6032
-    	if (isset($_GET['keyword'])) {
6033
-    		$keyword = Database::escape_string(trim($_GET['keyword']));
6034
-    		$sql .= " AND (
6032
+        if (isset($_GET['keyword'])) {
6033
+            $keyword = Database::escape_string(trim($_GET['keyword']));
6034
+            $sql .= " AND (
6035 6035
     		            user.username LIKE '%".$keyword."%' OR
6036 6036
     		            lastedit_type LIKE '%".$keyword."%' OR
6037 6037
     		            tool LIKE '%".$keyword."%'
6038 6038
                      ) ";
6039
-    	}
6039
+        }
6040 6040
 
6041
-    	$sql .= " AND tool IN (
6041
+        $sql .= " AND tool IN (
6042 6042
     	            'document',
6043 6043
     	            'learnpath',
6044 6044
     	            'quiz',
@@ -6051,41 +6051,41 @@  discard block
 block discarded – undo
6051 6051
     	            'thematic_plan'
6052 6052
                 )";
6053 6053
 
6054
-    	if ($column == 0) {
6055
-    		$column = '0';
6056
-    	}
6057
-    	if ($column != '' && $direction != '') {
6058
-    		if ($column != 2 && $column != 4) {
6059
-    			$sql .= " ORDER BY col$column $direction";
6060
-    		}
6061
-    	} else {
6062
-    		$sql .= " ORDER BY col5 DESC ";
6063
-    	}
6054
+        if ($column == 0) {
6055
+            $column = '0';
6056
+        }
6057
+        if ($column != '' && $direction != '') {
6058
+            if ($column != 2 && $column != 4) {
6059
+                $sql .= " ORDER BY col$column $direction";
6060
+            }
6061
+        } else {
6062
+            $sql .= " ORDER BY col5 DESC ";
6063
+        }
6064 6064
 
6065 6065
         $from = intval($from);
6066 6066
         $number_of_items = intval($number_of_items);
6067 6067
 
6068
-    	$sql .= " LIMIT $from, $number_of_items ";
6069
-
6070
-    	$res = Database::query($sql);
6071
-    	$resources = array();
6072
-    	$thematic_tools = array('thematic', 'thematic_advance', 'thematic_plan');
6073
-    	while ($row = Database::fetch_array($res)) {
6074
-    		$ref = $row['ref'];
6075
-    		$table_name = TrackingCourseLog::get_tool_name_table($row['col0']);
6076
-    		$table_tool = Database :: get_course_table($table_name['table_name']);
6068
+        $sql .= " LIMIT $from, $number_of_items ";
6077 6069
 
6078
-    		$id = $table_name['id_tool'];
6079
-    		$recorset = false;
6080
-
6081
-    		if (in_array($row['col0'], array('thematic_plan', 'thematic_advance'))) {
6082
-    			$tbl_thematic = Database :: get_course_table(TABLE_THEMATIC);
6083
-    			$sql = "SELECT thematic_id FROM $table_tool
6070
+        $res = Database::query($sql);
6071
+        $resources = array();
6072
+        $thematic_tools = array('thematic', 'thematic_advance', 'thematic_plan');
6073
+        while ($row = Database::fetch_array($res)) {
6074
+            $ref = $row['ref'];
6075
+            $table_name = TrackingCourseLog::get_tool_name_table($row['col0']);
6076
+            $table_tool = Database :: get_course_table($table_name['table_name']);
6077
+
6078
+            $id = $table_name['id_tool'];
6079
+            $recorset = false;
6080
+
6081
+            if (in_array($row['col0'], array('thematic_plan', 'thematic_advance'))) {
6082
+                $tbl_thematic = Database :: get_course_table(TABLE_THEMATIC);
6083
+                $sql = "SELECT thematic_id FROM $table_tool
6084 6084
     			        WHERE c_id = $course_id AND id = $ref";
6085
-    			$rs_thematic  = Database::query($sql);
6086
-    			if (Database::num_rows($rs_thematic)) {
6087
-    				$row_thematic = Database::fetch_array($rs_thematic);
6088
-    				$thematic_id = $row_thematic['thematic_id'];
6085
+                $rs_thematic  = Database::query($sql);
6086
+                if (Database::num_rows($rs_thematic)) {
6087
+                    $row_thematic = Database::fetch_array($rs_thematic);
6088
+                    $thematic_id = $row_thematic['thematic_id'];
6089 6089
 
6090 6090
                     $sql = "SELECT session.id, session.name, user.username
6091 6091
                             FROM $tbl_thematic t, $table_session session, $table_user user
@@ -6094,9 +6094,9 @@  discard block
 block discarded – undo
6094 6094
                               t.session_id = session.id AND
6095 6095
                               session.id_coach = user.user_id AND
6096 6096
                               t.id = $thematic_id";
6097
-    				$recorset = Database::query($sql);
6098
-    			}
6099
-    		} else {
6097
+                    $recorset = Database::query($sql);
6098
+                }
6099
+            } else {
6100 6100
                 $sql = "SELECT session.id, session.name, user.username
6101 6101
                           FROM $table_tool tool, $table_session session, $table_user user
6102 6102
     			          WHERE
@@ -6104,134 +6104,134 @@  discard block
 block discarded – undo
6104 6104
     			              tool.session_id = session.id AND
6105 6105
     			              session.id_coach = user.user_id AND
6106 6106
     			              tool.$id = $ref";
6107
-    			$recorset = Database::query($sql);
6108
-    		}
6109
-
6110
-    		if (!empty($recorset)) {
6111
-    			$obj = Database::fetch_object($recorset);
6112
-
6113
-    			$name_session = '';
6114
-    			$coach_name = '';
6115
-    			if (!empty($obj)) {
6116
-    				$name_session = $obj->name;
6117
-    				$coach_name   = $obj->username;
6118
-    			}
6119
-
6120
-    			$url_tool = api_get_path(WEB_CODE_PATH).$table_name['link_tool'];
6121
-    			$row[0] = '';
6122
-    			if ($row['col6'] != 2) {
6123
-    				if (in_array($row['col0'], $thematic_tools)) {
6124
-
6125
-    					$exp_thematic_tool = explode('_', $row['col0']);
6126
-    					$thematic_tool_title = '';
6127
-    					if (is_array($exp_thematic_tool)) {
6128
-    						foreach ($exp_thematic_tool as $exp) {
6129
-    							$thematic_tool_title .= api_ucfirst($exp);
6130
-    						}
6131
-    					} else {
6132
-    						$thematic_tool_title = api_ucfirst($row['col0']);
6133
-    					}
6134
-
6135
-    					$row[0] = '<a href="'.$url_tool.'?'.api_get_cidreq().'&action=thematic_details">'.get_lang($thematic_tool_title).'</a>';
6136
-    				} else {
6137
-    					$row[0] = '<a href="'.$url_tool.'?'.api_get_cidreq().'">'.get_lang('Tool'.api_ucfirst($row['col0'])).'</a>';
6138
-    				}
6139
-    			} else {
6140
-    				$row[0] = api_ucfirst($row['col0']);
6141
-    			}
6142
-    			$row[1] = get_lang($row[1]);
6143
-    			$row[6] = api_convert_and_format_date($row['col5'], null, date_default_timezone_get());
6144
-    			$row[5] = '';
6145
-    			//@todo Improve this code please
6146
-    			switch ($table_name['table_name']) {
6147
-    				case 'document':
6148
-    					$sql = "SELECT tool.title as title FROM $table_tool tool
6107
+                $recorset = Database::query($sql);
6108
+            }
6109
+
6110
+            if (!empty($recorset)) {
6111
+                $obj = Database::fetch_object($recorset);
6112
+
6113
+                $name_session = '';
6114
+                $coach_name = '';
6115
+                if (!empty($obj)) {
6116
+                    $name_session = $obj->name;
6117
+                    $coach_name   = $obj->username;
6118
+                }
6119
+
6120
+                $url_tool = api_get_path(WEB_CODE_PATH).$table_name['link_tool'];
6121
+                $row[0] = '';
6122
+                if ($row['col6'] != 2) {
6123
+                    if (in_array($row['col0'], $thematic_tools)) {
6124
+
6125
+                        $exp_thematic_tool = explode('_', $row['col0']);
6126
+                        $thematic_tool_title = '';
6127
+                        if (is_array($exp_thematic_tool)) {
6128
+                            foreach ($exp_thematic_tool as $exp) {
6129
+                                $thematic_tool_title .= api_ucfirst($exp);
6130
+                            }
6131
+                        } else {
6132
+                            $thematic_tool_title = api_ucfirst($row['col0']);
6133
+                        }
6134
+
6135
+                        $row[0] = '<a href="'.$url_tool.'?'.api_get_cidreq().'&action=thematic_details">'.get_lang($thematic_tool_title).'</a>';
6136
+                    } else {
6137
+                        $row[0] = '<a href="'.$url_tool.'?'.api_get_cidreq().'">'.get_lang('Tool'.api_ucfirst($row['col0'])).'</a>';
6138
+                    }
6139
+                } else {
6140
+                    $row[0] = api_ucfirst($row['col0']);
6141
+                }
6142
+                $row[1] = get_lang($row[1]);
6143
+                $row[6] = api_convert_and_format_date($row['col5'], null, date_default_timezone_get());
6144
+                $row[5] = '';
6145
+                //@todo Improve this code please
6146
+                switch ($table_name['table_name']) {
6147
+                    case 'document':
6148
+                        $sql = "SELECT tool.title as title FROM $table_tool tool
6149 6149
                                 WHERE c_id = $course_id AND id = $ref";
6150
-    					$rs_document = Database::query($sql);
6151
-    					$obj_document = Database::fetch_object($rs_document);
6150
+                        $rs_document = Database::query($sql);
6151
+                        $obj_document = Database::fetch_object($rs_document);
6152 6152
                         if ($obj_document) {
6153 6153
                             $row[5] = $obj_document->title;
6154 6154
                         }
6155
-    					break;
6156
-    				case 'announcement':
6155
+                        break;
6156
+                    case 'announcement':
6157 6157
                         $sql = "SELECT title FROM $table_tool
6158 6158
                                 WHERE c_id = $course_id AND id = $ref";
6159
-    					$rs_document = Database::query($sql);
6160
-    					$obj_document = Database::fetch_object($rs_document);
6159
+                        $rs_document = Database::query($sql);
6160
+                        $obj_document = Database::fetch_object($rs_document);
6161 6161
                         if ($obj_document) {
6162 6162
                             $row[5] = $obj_document->title;
6163 6163
                         }
6164
-    					break;
6165
-    				case 'glossary':
6164
+                        break;
6165
+                    case 'glossary':
6166 6166
                         $sql = "SELECT name FROM $table_tool
6167 6167
     					        WHERE c_id = $course_id AND glossary_id = $ref";
6168
-    					$rs_document = Database::query($sql);
6169
-    					$obj_document = Database::fetch_object($rs_document);
6168
+                        $rs_document = Database::query($sql);
6169
+                        $obj_document = Database::fetch_object($rs_document);
6170 6170
                         if ($obj_document) {
6171 6171
                             $row[5] = $obj_document->name;
6172 6172
                         }
6173
-    					break;
6174
-    				case 'lp':
6173
+                        break;
6174
+                    case 'lp':
6175 6175
                         $sql = "SELECT name
6176 6176
                                 FROM $table_tool WHERE c_id = $course_id AND id = $ref";
6177
-    					$rs_document = Database::query($sql);
6178
-    					$obj_document = Database::fetch_object($rs_document);
6179
-    					$row[5] = $obj_document->name;
6180
-    					break;
6181
-    				case 'quiz':
6177
+                        $rs_document = Database::query($sql);
6178
+                        $obj_document = Database::fetch_object($rs_document);
6179
+                        $row[5] = $obj_document->name;
6180
+                        break;
6181
+                    case 'quiz':
6182 6182
                         $sql = "SELECT title FROM $table_tool
6183 6183
                                 WHERE c_id = $course_id AND id = $ref";
6184
-    					$rs_document = Database::query($sql);
6185
-    					$obj_document = Database::fetch_object($rs_document);
6184
+                        $rs_document = Database::query($sql);
6185
+                        $obj_document = Database::fetch_object($rs_document);
6186 6186
                         if ($obj_document) {
6187 6187
                             $row[5] = $obj_document->title;
6188 6188
                         }
6189
-    					break;
6190
-    				case 'course_description':
6189
+                        break;
6190
+                    case 'course_description':
6191 6191
                         $sql = "SELECT title FROM $table_tool
6192 6192
                                 WHERE c_id = $course_id AND id = $ref";
6193
-    					$rs_document = Database::query($sql);
6194
-    					$obj_document = Database::fetch_object($rs_document);
6193
+                        $rs_document = Database::query($sql);
6194
+                        $obj_document = Database::fetch_object($rs_document);
6195 6195
                         if ($obj_document) {
6196 6196
                             $row[5] = $obj_document->title;
6197 6197
                         }
6198
-    					break;
6199
-    				case 'thematic':
6200
-    					$rs = Database::query("SELECT title FROM $table_tool WHERE c_id = $course_id AND id = $ref");
6201
-    					if (Database::num_rows($rs) > 0) {
6202
-    						$obj = Database::fetch_object($rs);
6198
+                        break;
6199
+                    case 'thematic':
6200
+                        $rs = Database::query("SELECT title FROM $table_tool WHERE c_id = $course_id AND id = $ref");
6201
+                        if (Database::num_rows($rs) > 0) {
6202
+                            $obj = Database::fetch_object($rs);
6203 6203
                             if ($obj) {
6204 6204
                                 $row[5] = $obj->title;
6205 6205
                             }
6206
-    					}
6207
-    					break;
6208
-    				case 'thematic_advance':
6209
-    					$rs = Database::query("SELECT content FROM $table_tool WHERE c_id = $course_id AND id = $ref");
6210
-    					if (Database::num_rows($rs) > 0) {
6211
-    						$obj = Database::fetch_object($rs);
6206
+                        }
6207
+                        break;
6208
+                    case 'thematic_advance':
6209
+                        $rs = Database::query("SELECT content FROM $table_tool WHERE c_id = $course_id AND id = $ref");
6210
+                        if (Database::num_rows($rs) > 0) {
6211
+                            $obj = Database::fetch_object($rs);
6212 6212
                             if ($obj) {
6213 6213
                                 $row[5] = $obj->content;
6214 6214
                             }
6215
-    					}
6216
-    					break;
6217
-    				case 'thematic_plan':
6218
-    					$rs = Database::query("SELECT title FROM $table_tool WHERE c_id = $course_id AND id = $ref");
6219
-    					if (Database::num_rows($rs) > 0) {
6220
-    						$obj = Database::fetch_object($rs);
6215
+                        }
6216
+                        break;
6217
+                    case 'thematic_plan':
6218
+                        $rs = Database::query("SELECT title FROM $table_tool WHERE c_id = $course_id AND id = $ref");
6219
+                        if (Database::num_rows($rs) > 0) {
6220
+                            $obj = Database::fetch_object($rs);
6221 6221
                             if ($obj) {
6222 6222
                                 $row[5] = $obj->title;
6223 6223
                             }
6224
-    					}
6225
-    					break;
6226
-    				default:
6227
-    					break;
6228
-    			}
6229
-
6230
-    			$row2 = $name_session;
6231
-    			if (!empty($coach_name)) {
6232
-    				$row2 .= '<br />'.get_lang('Coach').': '.$coach_name;
6233
-    			}
6234
-    			$row[2] = $row2;
6224
+                        }
6225
+                        break;
6226
+                    default:
6227
+                        break;
6228
+                }
6229
+
6230
+                $row2 = $name_session;
6231
+                if (!empty($coach_name)) {
6232
+                    $row2 .= '<br />'.get_lang('Coach').': '.$coach_name;
6233
+                }
6234
+                $row[2] = $row2;
6235 6235
                 if (!empty($row['col3'])) {
6236 6236
                     $userInfo = api_get_user_info($row['user_id']);
6237 6237
                     $row['col3'] = Display::url(
@@ -6247,11 +6247,11 @@  discard block
 block discarded – undo
6247 6247
                     $row[4] = $ip;
6248 6248
                 }
6249 6249
 
6250
-    			$resources[] = $row;
6251
-    		}
6252
-    	}
6250
+                $resources[] = $row;
6251
+            }
6252
+        }
6253 6253
 
6254
-    	return $resources;
6254
+        return $resources;
6255 6255
     }
6256 6256
 
6257 6257
     /**
@@ -6261,63 +6261,63 @@  discard block
 block discarded – undo
6261 6261
      */
6262 6262
     public static function get_tool_name_table($tool)
6263 6263
     {
6264
-    	switch ($tool) {
6265
-    		case 'document':
6266
-    			$table_name = TABLE_DOCUMENT;
6267
-    			$link_tool = 'document/document.php';
6268
-    			$id_tool = 'id';
6269
-    			break;
6270
-    		case 'learnpath':
6271
-    			$table_name = TABLE_LP_MAIN;
6272
-    			$link_tool = 'lp/lp_controller.php';
6273
-    			$id_tool = 'id';
6274
-    			break;
6275
-    		case 'quiz':
6276
-    			$table_name = TABLE_QUIZ_TEST;
6277
-    			$link_tool = 'exercise/exercise.php';
6278
-    			$id_tool = 'id';
6279
-    			break;
6280
-    		case 'glossary':
6281
-    			$table_name = TABLE_GLOSSARY;
6282
-    			$link_tool = 'glossary/index.php';
6283
-    			$id_tool = 'glossary_id';
6284
-    			break;
6285
-    		case 'link':
6286
-    			$table_name = TABLE_LINK;
6287
-    			$link_tool = 'link/link.php';
6288
-    			$id_tool = 'id';
6289
-    			break;
6290
-    		case 'course_description':
6291
-    			$table_name = TABLE_COURSE_DESCRIPTION;
6292
-    			$link_tool = 'course_description/';
6293
-    			$id_tool = 'id';
6294
-    			break;
6295
-    		case 'announcement':
6296
-    			$table_name = TABLE_ANNOUNCEMENT;
6297
-    			$link_tool = 'announcements/announcements.php';
6298
-    			$id_tool = 'id';
6299
-    			break;
6300
-    		case 'thematic':
6301
-    			$table_name = TABLE_THEMATIC;
6302
-    			$link_tool = 'course_progress/index.php';
6303
-    			$id_tool = 'id';
6304
-    			break;
6305
-    		case 'thematic_advance':
6306
-    			$table_name = TABLE_THEMATIC_ADVANCE;
6307
-    			$link_tool = 'course_progress/index.php';
6308
-    			$id_tool = 'id';
6309
-    			break;
6310
-    		case 'thematic_plan':
6311
-    			$table_name = TABLE_THEMATIC_PLAN;
6312
-    			$link_tool = 'course_progress/index.php';
6313
-    			$id_tool = 'id';
6314
-    			break;
6315
-    		default:
6316
-    			$table_name = $tool;
6317
-    		break;
6318
-    	}
6319
-
6320
-    	return array(
6264
+        switch ($tool) {
6265
+            case 'document':
6266
+                $table_name = TABLE_DOCUMENT;
6267
+                $link_tool = 'document/document.php';
6268
+                $id_tool = 'id';
6269
+                break;
6270
+            case 'learnpath':
6271
+                $table_name = TABLE_LP_MAIN;
6272
+                $link_tool = 'lp/lp_controller.php';
6273
+                $id_tool = 'id';
6274
+                break;
6275
+            case 'quiz':
6276
+                $table_name = TABLE_QUIZ_TEST;
6277
+                $link_tool = 'exercise/exercise.php';
6278
+                $id_tool = 'id';
6279
+                break;
6280
+            case 'glossary':
6281
+                $table_name = TABLE_GLOSSARY;
6282
+                $link_tool = 'glossary/index.php';
6283
+                $id_tool = 'glossary_id';
6284
+                break;
6285
+            case 'link':
6286
+                $table_name = TABLE_LINK;
6287
+                $link_tool = 'link/link.php';
6288
+                $id_tool = 'id';
6289
+                break;
6290
+            case 'course_description':
6291
+                $table_name = TABLE_COURSE_DESCRIPTION;
6292
+                $link_tool = 'course_description/';
6293
+                $id_tool = 'id';
6294
+                break;
6295
+            case 'announcement':
6296
+                $table_name = TABLE_ANNOUNCEMENT;
6297
+                $link_tool = 'announcements/announcements.php';
6298
+                $id_tool = 'id';
6299
+                break;
6300
+            case 'thematic':
6301
+                $table_name = TABLE_THEMATIC;
6302
+                $link_tool = 'course_progress/index.php';
6303
+                $id_tool = 'id';
6304
+                break;
6305
+            case 'thematic_advance':
6306
+                $table_name = TABLE_THEMATIC_ADVANCE;
6307
+                $link_tool = 'course_progress/index.php';
6308
+                $id_tool = 'id';
6309
+                break;
6310
+            case 'thematic_plan':
6311
+                $table_name = TABLE_THEMATIC_PLAN;
6312
+                $link_tool = 'course_progress/index.php';
6313
+                $id_tool = 'id';
6314
+                break;
6315
+            default:
6316
+                $table_name = $tool;
6317
+            break;
6318
+        }
6319
+
6320
+        return array(
6321 6321
             'table_name' => $table_name,
6322 6322
             'link_tool' => $link_tool,
6323 6323
             'id_tool' => $id_tool
@@ -6326,45 +6326,45 @@  discard block
 block discarded – undo
6326 6326
 
6327 6327
     public static function display_additional_profile_fields()
6328 6328
     {
6329
-    	// getting all the extra profile fields that are defined by the platform administrator
6330
-    	$extra_fields = UserManager :: get_extra_fields(0,50,5,'ASC');
6331
-
6332
-    	// creating the form
6333
-    	$return = '<form action="courseLog.php" method="get" name="additional_profile_field_form" id="additional_profile_field_form">';
6334
-
6335
-    	// the select field with the additional user profile fields (= this is where we select the field of which we want to see
6336
-    	// the information the users have entered or selected.
6337
-    	$return .= '<select name="additional_profile_field">';
6338
-    	$return .= '<option value="-">'.get_lang('SelectFieldToAdd').'</option>';
6339
-    	$extra_fields_to_show = 0;
6340
-    	foreach ($extra_fields as $key=>$field) {
6341
-    		// show only extra fields that are visible + and can be filtered, added by J.Montoya
6342
-    		if ($field[6]==1 && $field[8] == 1) {
6343
-    			if (isset($_GET['additional_profile_field']) && $field[0] == $_GET['additional_profile_field'] ) {
6344
-    				$selected = 'selected="selected"';
6345
-    			} else {
6346
-    				$selected = '';
6347
-    			}
6348
-    			$extra_fields_to_show++;
6349
-    			$return .= '<option value="'.$field[0].'" '.$selected.'>'.$field[3].'</option>';
6350
-    		}
6351
-    	}
6352
-    	$return .= '</select>';
6353
-
6354
-    	// the form elements for the $_GET parameters (because the form is passed through GET
6355
-    	foreach ($_GET as $key=>$value){
6356
-    		if ($key <> 'additional_profile_field')    {
6357
-    			$return .= '<input type="hidden" name="'.Security::remove_XSS($key).'" value="'.Security::remove_XSS($value).'" />';
6358
-    		}
6359
-    	}
6360
-    	// the submit button
6361
-    	$return .= '<button class="save" type="submit">'.get_lang('AddAdditionalProfileField').'</button>';
6362
-    	$return .= '</form>';
6363
-    	if ($extra_fields_to_show > 0) {
6364
-    		return $return;
6365
-    	} else {
6366
-    		return '';
6367
-    	}
6329
+        // getting all the extra profile fields that are defined by the platform administrator
6330
+        $extra_fields = UserManager :: get_extra_fields(0,50,5,'ASC');
6331
+
6332
+        // creating the form
6333
+        $return = '<form action="courseLog.php" method="get" name="additional_profile_field_form" id="additional_profile_field_form">';
6334
+
6335
+        // the select field with the additional user profile fields (= this is where we select the field of which we want to see
6336
+        // the information the users have entered or selected.
6337
+        $return .= '<select name="additional_profile_field">';
6338
+        $return .= '<option value="-">'.get_lang('SelectFieldToAdd').'</option>';
6339
+        $extra_fields_to_show = 0;
6340
+        foreach ($extra_fields as $key=>$field) {
6341
+            // show only extra fields that are visible + and can be filtered, added by J.Montoya
6342
+            if ($field[6]==1 && $field[8] == 1) {
6343
+                if (isset($_GET['additional_profile_field']) && $field[0] == $_GET['additional_profile_field'] ) {
6344
+                    $selected = 'selected="selected"';
6345
+                } else {
6346
+                    $selected = '';
6347
+                }
6348
+                $extra_fields_to_show++;
6349
+                $return .= '<option value="'.$field[0].'" '.$selected.'>'.$field[3].'</option>';
6350
+            }
6351
+        }
6352
+        $return .= '</select>';
6353
+
6354
+        // the form elements for the $_GET parameters (because the form is passed through GET
6355
+        foreach ($_GET as $key=>$value){
6356
+            if ($key <> 'additional_profile_field')    {
6357
+                $return .= '<input type="hidden" name="'.Security::remove_XSS($key).'" value="'.Security::remove_XSS($value).'" />';
6358
+            }
6359
+        }
6360
+        // the submit button
6361
+        $return .= '<button class="save" type="submit">'.get_lang('AddAdditionalProfileField').'</button>';
6362
+        $return .= '</form>';
6363
+        if ($extra_fields_to_show > 0) {
6364
+            return $return;
6365
+        } else {
6366
+            return '';
6367
+        }
6368 6368
     }
6369 6369
 
6370 6370
     /**
@@ -6383,31 +6383,31 @@  discard block
 block discarded – undo
6383 6383
      */
6384 6384
     public static function get_addtional_profile_information_of_field_by_user($field_id, $users)
6385 6385
     {
6386
-    	// Database table definition
6387
-    	$table_user = Database::get_main_table(TABLE_MAIN_USER);
6388
-    	$table_user_field_values = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES);
6386
+        // Database table definition
6387
+        $table_user = Database::get_main_table(TABLE_MAIN_USER);
6388
+        $table_user_field_values = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES);
6389 6389
         $extraField = Database::get_main_table(TABLE_EXTRA_FIELD);
6390
-    	$result_extra_field = UserManager::get_extra_field_information($field_id);
6391
-
6392
-    	if (!empty($users)) {
6393
-    		if ($result_extra_field['field_type'] == UserManager::USER_FIELD_TYPE_TAG ) {
6394
-    			foreach($users as $user_id) {
6395
-    				$user_result = UserManager::get_user_tags($user_id, $field_id);
6396
-    				$tag_list = array();
6397
-    				foreach($user_result as $item) {
6398
-    					$tag_list[] = $item['tag'];
6399
-    				}
6400
-    				$return[$user_id][] = implode(', ',$tag_list);
6401
-    			}
6402
-    		} else {
6403
-    			$new_user_array = array();
6404
-    			foreach ($users as $user_id) {
6405
-    				$new_user_array[]= "'".$user_id."'";
6406
-    			}
6407
-    			$users = implode(',',$new_user_array);
6390
+        $result_extra_field = UserManager::get_extra_field_information($field_id);
6391
+
6392
+        if (!empty($users)) {
6393
+            if ($result_extra_field['field_type'] == UserManager::USER_FIELD_TYPE_TAG ) {
6394
+                foreach($users as $user_id) {
6395
+                    $user_result = UserManager::get_user_tags($user_id, $field_id);
6396
+                    $tag_list = array();
6397
+                    foreach($user_result as $item) {
6398
+                        $tag_list[] = $item['tag'];
6399
+                    }
6400
+                    $return[$user_id][] = implode(', ',$tag_list);
6401
+                }
6402
+            } else {
6403
+                $new_user_array = array();
6404
+                foreach ($users as $user_id) {
6405
+                    $new_user_array[]= "'".$user_id."'";
6406
+                }
6407
+                $users = implode(',',$new_user_array);
6408 6408
                 $extraFieldType = EntityExtraField::USER_FIELD_TYPE;
6409
-    			// Selecting only the necessary information NOT ALL the user list
6410
-    			$sql = "SELECT user.user_id, v.value
6409
+                // Selecting only the necessary information NOT ALL the user list
6410
+                $sql = "SELECT user.user_id, v.value
6411 6411
     			        FROM $table_user user
6412 6412
     			        INNER JOIN $table_user_field_values v
6413 6413
                         ON (user.user_id = v.item_id)
@@ -6418,27 +6418,27 @@  discard block
 block discarded – undo
6418 6418
                             v.field_id=".intval($field_id)." AND
6419 6419
                             user.user_id IN ($users)";
6420 6420
 
6421
-    			$result = Database::query($sql);
6422
-    			while($row = Database::fetch_array($result)) {
6423
-    				// get option value for field type double select by id
6424
-    				if (!empty($row['value'])) {
6425
-    					if ($result_extra_field['field_type'] ==
6421
+                $result = Database::query($sql);
6422
+                while($row = Database::fetch_array($result)) {
6423
+                    // get option value for field type double select by id
6424
+                    if (!empty($row['value'])) {
6425
+                        if ($result_extra_field['field_type'] ==
6426 6426
                             ExtraField::FIELD_TYPE_DOUBLE_SELECT
6427 6427
                         ) {
6428
-    						$id_double_select = explode(';', $row['value']);
6429
-    						if (is_array($id_double_select)) {
6430
-    							$value1 = $result_extra_field['options'][$id_double_select[0]]['option_value'];
6431
-    							$value2 = $result_extra_field['options'][$id_double_select[1]]['option_value'];
6432
-    							$row['value'] = ($value1.';'.$value2);
6433
-    						}
6434
-    					}
6435
-    				}
6436
-    				// get other value from extra field
6437
-    				$return[$row['user_id']][] = $row['value'];
6438
-    			}
6439
-    		}
6440
-    	}
6441
-    	return $return;
6428
+                            $id_double_select = explode(';', $row['value']);
6429
+                            if (is_array($id_double_select)) {
6430
+                                $value1 = $result_extra_field['options'][$id_double_select[0]]['option_value'];
6431
+                                $value2 = $result_extra_field['options'][$id_double_select[1]]['option_value'];
6432
+                                $row['value'] = ($value1.';'.$value2);
6433
+                            }
6434
+                        }
6435
+                    }
6436
+                    // get other value from extra field
6437
+                    $return[$row['user_id']][] = $row['value'];
6438
+                }
6439
+            }
6440
+        }
6441
+        return $return;
6442 6442
     }
6443 6443
 
6444 6444
     /**
@@ -6447,18 +6447,18 @@  discard block
 block discarded – undo
6447 6447
      */
6448 6448
     public function count_student_in_course()
6449 6449
     {
6450
-    	global $nbStudents;
6451
-    	return $nbStudents;
6450
+        global $nbStudents;
6451
+        return $nbStudents;
6452 6452
     }
6453 6453
 
6454 6454
     public function sort_users($a, $b)
6455 6455
     {
6456
-    	return strcmp(trim(api_strtolower($a[$_SESSION['tracking_column']])), trim(api_strtolower($b[$_SESSION['tracking_column']])));
6456
+        return strcmp(trim(api_strtolower($a[$_SESSION['tracking_column']])), trim(api_strtolower($b[$_SESSION['tracking_column']])));
6457 6457
     }
6458 6458
 
6459 6459
     public function sort_users_desc($a, $b)
6460 6460
     {
6461
-    	return strcmp( trim(api_strtolower($b[$_SESSION['tracking_column']])), trim(api_strtolower($a[$_SESSION['tracking_column']])));
6461
+        return strcmp( trim(api_strtolower($b[$_SESSION['tracking_column']])), trim(api_strtolower($a[$_SESSION['tracking_column']])));
6462 6462
     }
6463 6463
 
6464 6464
     /**
@@ -6467,8 +6467,8 @@  discard block
 block discarded – undo
6467 6467
      */
6468 6468
     public static function get_number_of_users()
6469 6469
     {
6470
-    	global $user_ids;
6471
-    	return count($user_ids);
6470
+        global $user_ids;
6471
+        return count($user_ids);
6472 6472
     }
6473 6473
 
6474 6474
     /**
@@ -6484,37 +6484,37 @@  discard block
 block discarded – undo
6484 6484
     {
6485 6485
         global $user_ids, $course_code, $additional_user_profile_info, $export_csv, $is_western_name_order, $csv_content, $session_id;
6486 6486
 
6487
-    	$course_code = Database::escape_string($course_code);
6488
-    	$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
6489
-    	$tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
6487
+        $course_code = Database::escape_string($course_code);
6488
+        $tbl_user = Database::get_main_table(TABLE_MAIN_USER);
6489
+        $tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
6490 6490
 
6491
-    	$access_url_id = api_get_current_access_url_id();
6491
+        $access_url_id = api_get_current_access_url_id();
6492 6492
 
6493
-    	// get all users data from a course for sortable with limit
6494
-    	if (is_array($user_ids)) {
6495
-    		$user_ids = array_map('intval', $user_ids);
6496
-    		$condition_user = " WHERE user.user_id IN (".implode(',',$user_ids).") ";
6497
-    	} else {
6498
-    		$user_ids = intval($user_ids);
6499
-    		$condition_user = " WHERE user.user_id = $user_ids ";
6500
-    	}
6493
+        // get all users data from a course for sortable with limit
6494
+        if (is_array($user_ids)) {
6495
+            $user_ids = array_map('intval', $user_ids);
6496
+            $condition_user = " WHERE user.user_id IN (".implode(',',$user_ids).") ";
6497
+        } else {
6498
+            $user_ids = intval($user_ids);
6499
+            $condition_user = " WHERE user.user_id = $user_ids ";
6500
+        }
6501 6501
 
6502
-    	if (!empty($_GET['user_keyword'])) {
6503
-    		$keyword = trim(Database::escape_string($_GET['user_keyword']));
6504
-    		$condition_user .=  " AND (
6502
+        if (!empty($_GET['user_keyword'])) {
6503
+            $keyword = trim(Database::escape_string($_GET['user_keyword']));
6504
+            $condition_user .=  " AND (
6505 6505
                 user.firstname LIKE '%".$keyword."%' OR
6506 6506
                 user.lastname LIKE '%".$keyword."%'  OR
6507 6507
                 user.username LIKE '%".$keyword."%'  OR
6508 6508
                 user.email LIKE '%".$keyword."%'
6509 6509
              ) ";
6510
-    	}
6510
+        }
6511 6511
 
6512 6512
         $url_table = null;
6513 6513
         $url_condition = null;
6514
-    	if (api_is_multiple_url_enabled()) {
6515
-    		$url_table = ", ".$tbl_url_rel_user." as url_users";
6516
-    		$url_condition = " AND user.user_id = url_users.user_id AND access_url_id='$access_url_id'";
6517
-    	}
6514
+        if (api_is_multiple_url_enabled()) {
6515
+            $url_table = ", ".$tbl_url_rel_user." as url_users";
6516
+            $url_condition = " AND user.user_id = url_users.user_id AND access_url_id='$access_url_id'";
6517
+        }
6518 6518
 
6519 6519
         $invitedUsersCondition = '';
6520 6520
 
@@ -6522,7 +6522,7 @@  discard block
 block discarded – undo
6522 6522
             $invitedUsersCondition = " AND user.status != " . INVITEE;
6523 6523
         }
6524 6524
 
6525
-    	$sql = "SELECT  user.user_id as user_id,
6525
+        $sql = "SELECT  user.user_id as user_id,
6526 6526
                     user.official_code  as col0,
6527 6527
                     user.lastname       as col1,
6528 6528
                     user.firstname      as col2,
@@ -6530,16 +6530,16 @@  discard block
 block discarded – undo
6530 6530
                 FROM $tbl_user as user $url_table
6531 6531
     	        $condition_user $url_condition $invitedUsersCondition";
6532 6532
 
6533
-    	if (!in_array($direction, array('ASC','DESC'))) {
6534
-    		$direction = 'ASC';
6535
-    	}
6533
+        if (!in_array($direction, array('ASC','DESC'))) {
6534
+            $direction = 'ASC';
6535
+        }
6536 6536
 
6537
-    	$column = intval($column);
6538
-    	$from = intval($from);
6539
-    	$number_of_items = intval($number_of_items);
6537
+        $column = intval($column);
6538
+        $from = intval($from);
6539
+        $number_of_items = intval($number_of_items);
6540 6540
 
6541
-    	$sql .= " ORDER BY col$column $direction ";
6542
-    	$sql .= " LIMIT $from,$number_of_items";
6541
+        $sql .= " ORDER BY col$column $direction ";
6542
+        $sql .= " LIMIT $from,$number_of_items";
6543 6543
 
6544 6544
         $res = Database::query($sql);
6545 6545
         $users = array();
@@ -6573,7 +6573,7 @@  discard block
 block discarded – undo
6573 6573
             }
6574 6574
         }
6575 6575
 
6576
-    	while ($user = Database::fetch_array($res, 'ASSOC')) {
6576
+        while ($user = Database::fetch_array($res, 'ASSOC')) {
6577 6577
             $courseInfo = api_get_course_info($course_code);
6578 6578
             $courseId = $courseInfo['real_id'];
6579 6579
 
@@ -6604,10 +6604,10 @@  discard block
 block discarded – undo
6604 6604
                 $session_id
6605 6605
             );
6606 6606
 
6607
-    		if (empty($avg_student_progress)) {
6607
+            if (empty($avg_student_progress)) {
6608 6608
                 $avg_student_progress = 0;
6609
-    		}
6610
-    		$user['average_progress'] = $avg_student_progress.'%';
6609
+            }
6610
+            $user['average_progress'] = $avg_student_progress.'%';
6611 6611
 
6612 6612
             $total_user_exercise = Tracking::get_exercise_student_progress(
6613 6613
                 $total_exercises,
@@ -6627,11 +6627,11 @@  discard block
 block discarded – undo
6627 6627
 
6628 6628
             $user['exercise_average_best_attempt'] = $total_user_exercise;
6629 6629
 
6630
-    		if (is_numeric($avg_student_score)) {
6631
-    			$user['student_score']  = $avg_student_score.'%';
6632
-    		} else {
6633
-    			$user['student_score']  = $avg_student_score;
6634
-    		}
6630
+            if (is_numeric($avg_student_score)) {
6631
+                $user['student_score']  = $avg_student_score.'%';
6632
+            } else {
6633
+                $user['student_score']  = $avg_student_score;
6634
+            }
6635 6635
 
6636 6636
             $user['count_assignments'] = Tracking::count_student_assignments(
6637 6637
                 $user['user_id'],
@@ -6654,29 +6654,29 @@  discard block
 block discarded – undo
6654 6654
                 $session_id
6655 6655
             );
6656 6656
 
6657
-    		// we need to display an additional profile field
6658
-    		$user['additional'] = '';
6657
+            // we need to display an additional profile field
6658
+            $user['additional'] = '';
6659 6659
 
6660
-    		if (isset($_GET['additional_profile_field']) && is_numeric($_GET['additional_profile_field'])) {
6661
-    			if (isset($additional_user_profile_info[$user['user_id']]) &&
6660
+            if (isset($_GET['additional_profile_field']) && is_numeric($_GET['additional_profile_field'])) {
6661
+                if (isset($additional_user_profile_info[$user['user_id']]) &&
6662 6662
                     is_array($additional_user_profile_info[$user['user_id']])
6663 6663
                 ) {
6664
-    				$user['additional'] = implode(', ', $additional_user_profile_info[$user['user_id']]);
6665
-    			}
6666
-    		}
6664
+                    $user['additional'] = implode(', ', $additional_user_profile_info[$user['user_id']]);
6665
+                }
6666
+            }
6667 6667
 
6668 6668
             if (empty($session_id)) {
6669 6669
                 $user['survey'] = (isset($survey_user_list[$user['user_id']]) ? $survey_user_list[$user['user_id']] : 0) .' / '.$total_surveys;
6670 6670
             }
6671 6671
 
6672
-    		$user['link'] = '<center>
6672
+            $user['link'] = '<center>
6673 6673
                              <a href="../mySpace/myStudents.php?student='.$user['user_id'].'&details=true&course='.$course_code.'&origin=tracking_course&id_session='.$session_id.'">
6674 6674
     		                 '.Display::return_icon('2rightarrow.png').'
6675 6675
     		                 </a>
6676 6676
                          </center>';
6677 6677
 
6678
-    		// store columns in array $users
6679
-    		$is_western_name_order = api_is_western_name_order();
6678
+            // store columns in array $users
6679
+            $is_western_name_order = api_is_western_name_order();
6680 6680
             $user_row = array();
6681 6681
             $user_row[]= $user['official_code']; //0
6682 6682
             if ($is_western_name_order) {
@@ -6712,21 +6712,21 @@  discard block
 block discarded – undo
6712 6712
 
6713 6713
             $users[] = $user_row;
6714 6714
 
6715
-    		if ($export_csv) {
6716
-    		    if (empty($session_id)) {
6715
+            if ($export_csv) {
6716
+                if (empty($session_id)) {
6717 6717
                     $user_row = array_map('strip_tags', $user_row);
6718
-    			    unset($user_row[14]);
6719
-    			    unset($user_row[15]);
6718
+                    unset($user_row[14]);
6719
+                    unset($user_row[15]);
6720 6720
                 } else {
6721 6721
                     $user_row = array_map('strip_tags', $user_row);
6722 6722
                     unset($user_row[13]);
6723 6723
                     unset($user_row[14]);
6724 6724
                 }
6725 6725
 
6726
-    			$csv_content[] = $user_row;
6727
-    		}
6728
-    	}
6729
-    	return $users;
6726
+                $csv_content[] = $user_row;
6727
+            }
6728
+        }
6729
+        return $users;
6730 6730
     }
6731 6731
 }
6732 6732
 
@@ -6744,18 +6744,18 @@  discard block
 block discarded – undo
6744 6744
      */
6745 6745
     public static function display_login_tracking_info($view, $user_id, $course_id, $session_id = 0)
6746 6746
     {
6747
-    	$MonthsLong = $GLOBALS['MonthsLong'];
6748
-
6749
-    	// protected data
6750
-    	$user_id = intval($user_id);
6751
-    	$session_id = intval($session_id);
6752
-    	$course_id = Database::escape_string($course_id);
6753
-
6754
-    	$track_access_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
6755
-    	$tempView = $view;
6756
-    	if(substr($view,0,1) == '1') {
6757
-    		$new_view = substr_replace($view,'0',0,1);
6758
-    		echo "
6747
+        $MonthsLong = $GLOBALS['MonthsLong'];
6748
+
6749
+        // protected data
6750
+        $user_id = intval($user_id);
6751
+        $session_id = intval($session_id);
6752
+        $course_id = Database::escape_string($course_id);
6753
+
6754
+        $track_access_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
6755
+        $tempView = $view;
6756
+        if(substr($view,0,1) == '1') {
6757
+            $new_view = substr_replace($view,'0',0,1);
6758
+            echo "
6759 6759
                 <tr>
6760 6760
                     <td valign='top'>
6761 6761
                     <font color='#0000FF'>-&nbsp;&nbsp;&nbsp;</font>" .
@@ -6763,9 +6763,9 @@  discard block
 block discarded – undo
6763 6763
                     </td>
6764 6764
                 </tr>
6765 6765
                 ";
6766
-    		echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('LoginsDetails')."<br>";
6766
+            echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('LoginsDetails')."<br>";
6767 6767
 
6768
-    		$sql = "SELECT UNIX_TIMESTAMP(access_date), count(access_date)
6768
+            $sql = "SELECT UNIX_TIMESTAMP(access_date), count(access_date)
6769 6769
                         FROM $track_access_table
6770 6770
                         WHERE access_user_id = $user_id
6771 6771
                         AND c_id = $course_id
@@ -6773,11 +6773,11 @@  discard block
 block discarded – undo
6773 6773
                         GROUP BY YEAR(access_date),MONTH(access_date)
6774 6774
                         ORDER BY YEAR(access_date),MONTH(access_date) ASC";
6775 6775
 
6776
-    		echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6777
-    		$results = getManyResults3Col($sql);
6776
+            echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6777
+            $results = getManyResults3Col($sql);
6778 6778
 
6779
-    		echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
6780
-    		echo "<tr>
6779
+            echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
6780
+            echo "<tr>
6781 6781
                     <td class='secLine'>
6782 6782
                     ".get_lang('LoginsTitleMonthColumn')."
6783 6783
                     </td>
@@ -6785,36 +6785,36 @@  discard block
 block discarded – undo
6785 6785
                     ".get_lang('LoginsTitleCountColumn')."
6786 6786
                     </td>
6787 6787
                 </tr>";
6788
-    		$total = 0;
6789
-    		if (is_array($results)) {
6790
-    			for($j = 0 ; $j < count($results) ; $j++) {
6791
-    				echo "<tr>";
6792
-    				echo "<td class='content'><a href='logins_details.php?uInfo=".$user_id."&reqdate=".$results[$j][0]."&view=".Security::remove_XSS($view)."'>".$MonthsLong[date('n', $results[$j][0])-1].' '.date('Y', $results[$j][0])."</a></td>";
6793
-    				echo "<td valign='top' align='right' class='content'>".$results[$j][1]."</td>";
6794
-    				echo"</tr>";
6795
-    				$total = $total + $results[$j][1];
6796
-    			}
6797
-    			echo "<tr>";
6798
-    			echo "<td>".get_lang('Total')."</td>";
6799
-    			echo "<td align='right' class='content'>".$total."</td>";
6800
-    			echo"</tr>";
6801
-    		} else {
6802
-    			echo "<tr>";
6803
-    			echo "<td colspan='2'><center>".get_lang('NoResult')."</center></td>";
6804
-    			echo"</tr>";
6805
-    		}
6806
-    		echo "</table>";
6807
-    		echo "</td></tr>";
6808
-    	} else {
6809
-    		$new_view = substr_replace($view,'1',0,1);
6810
-    		echo "
6788
+            $total = 0;
6789
+            if (is_array($results)) {
6790
+                for($j = 0 ; $j < count($results) ; $j++) {
6791
+                    echo "<tr>";
6792
+                    echo "<td class='content'><a href='logins_details.php?uInfo=".$user_id."&reqdate=".$results[$j][0]."&view=".Security::remove_XSS($view)."'>".$MonthsLong[date('n', $results[$j][0])-1].' '.date('Y', $results[$j][0])."</a></td>";
6793
+                    echo "<td valign='top' align='right' class='content'>".$results[$j][1]."</td>";
6794
+                    echo"</tr>";
6795
+                    $total = $total + $results[$j][1];
6796
+                }
6797
+                echo "<tr>";
6798
+                echo "<td>".get_lang('Total')."</td>";
6799
+                echo "<td align='right' class='content'>".$total."</td>";
6800
+                echo"</tr>";
6801
+            } else {
6802
+                echo "<tr>";
6803
+                echo "<td colspan='2'><center>".get_lang('NoResult')."</center></td>";
6804
+                echo"</tr>";
6805
+            }
6806
+            echo "</table>";
6807
+            echo "</td></tr>";
6808
+        } else {
6809
+            $new_view = substr_replace($view,'1',0,1);
6810
+            echo "
6811 6811
                 <tr>
6812 6812
                     <td valign='top'>
6813 6813
                     +<font color='#0000FF'>&nbsp;&nbsp;</font><a href='".api_get_self()."?uInfo=".$user_id."&view=".Security::remove_XSS($new_view)."' class='specialLink'>".get_lang('LoginsAndAccessTools')."</a>
6814 6814
                     </td>
6815 6815
                 </tr>
6816 6816
             ";
6817
-    	}
6817
+        }
6818 6818
     }
6819 6819
 
6820 6820
     /**
@@ -6827,38 +6827,38 @@  discard block
 block discarded – undo
6827 6827
      */
6828 6828
     public static function display_exercise_tracking_info($view, $user_id, $courseCode)
6829 6829
     {
6830
-    	global $TBL_TRACK_HOTPOTATOES, $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $dateTimeFormatLong;
6830
+        global $TBL_TRACK_HOTPOTATOES, $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $dateTimeFormatLong;
6831 6831
         $courseId = api_get_course_int_id($courseCode);
6832
-    	if(substr($view,1,1) == '1') {
6833
-    		$new_view = substr_replace($view,'0',1,1);
6834
-    		echo "<tr>
6832
+        if(substr($view,1,1) == '1') {
6833
+            $new_view = substr_replace($view,'0',1,1);
6834
+            echo "<tr>
6835 6835
                     <td valign='top'>
6836 6836
                         <font color='#0000FF'>-&nbsp;&nbsp;&nbsp;</font><b>".get_lang('ExercicesResults')."</b>&nbsp;&nbsp;&nbsp;[<a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."'>".get_lang('Close')."</a>]&nbsp;&nbsp;&nbsp;[<a href='userLogCSV.php?".api_get_cidreq()."&uInfo=".Security::remove_XSS($_GET['uInfo'])."&view=01000'>".get_lang('ExportAsCSV')."</a>]
6837 6837
                     </td>
6838 6838
                 </tr>";
6839
-    		echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('ExercicesDetails')."<br />";
6839
+            echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('ExercicesDetails')."<br />";
6840 6840
 
6841
-    		$sql = "SELECT ce.title, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
6841
+            $sql = "SELECT ce.title, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
6842 6842
                     FROM $TABLECOURSE_EXERCICES AS ce , $TABLETRACK_EXERCICES AS te
6843 6843
                     WHERE te.c_id = $courseId
6844 6844
                         AND te.exe_user_id = ".intval($user_id)."
6845 6845
                         AND te.exe_exo_id = ce.id
6846 6846
                     ORDER BY ce.title ASC, te.exe_date ASC";
6847 6847
 
6848
-    		$hpsql = "SELECT te.exe_name, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
6848
+            $hpsql = "SELECT te.exe_name, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
6849 6849
                         FROM $TBL_TRACK_HOTPOTATOES AS te
6850 6850
                         WHERE te.exe_user_id = '".intval($user_id)."' AND te.c_id = $courseId
6851 6851
                         ORDER BY te.c_id ASC, te.exe_date ASC";
6852 6852
 
6853
-    		$hpresults = StatsUtils::getManyResultsXCol($hpsql, 4);
6853
+            $hpresults = StatsUtils::getManyResultsXCol($hpsql, 4);
6854 6854
 
6855
-    		$NoTestRes = 0;
6856
-    		$NoHPTestRes = 0;
6855
+            $NoTestRes = 0;
6856
+            $NoHPTestRes = 0;
6857 6857
 
6858
-    		echo "<tr>\n<td style='padding-left : 40px;padding-right : 40px;'>\n";
6859
-    		$results = StatsUtils::getManyResultsXCol($sql, 4);
6860
-    		echo "<table cellpadding='2' cellspacing='1' border='0' align='center'>\n";
6861
-    		echo "
6858
+            echo "<tr>\n<td style='padding-left : 40px;padding-right : 40px;'>\n";
6859
+            $results = StatsUtils::getManyResultsXCol($sql, 4);
6860
+            echo "<table cellpadding='2' cellspacing='1' border='0' align='center'>\n";
6861
+            echo "
6862 6862
                 <tr bgcolor='#E6E6E6'>
6863 6863
                     <td>
6864 6864
                     ".get_lang('ExercicesTitleExerciceColumn')."
@@ -6871,28 +6871,28 @@  discard block
 block discarded – undo
6871 6871
                     </td>
6872 6872
                 </tr>";
6873 6873
 
6874
-    		if (is_array($results)) {
6875
-    			for($i = 0; $i < sizeof($results); $i++) {
6876
-    				$display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get());
6877
-    				echo "<tr>\n";
6878
-    				echo "<td class='content'>".$results[$i][0]."</td>\n";
6879
-    				echo "<td class='content'>".$display_date."</td>\n";
6880
-    				echo "<td valign='top' align='right' class='content'>".$results[$i][1]." / ".$results[$i][2]."</td>\n";
6881
-    				echo "</tr>\n";
6882
-    			}
6883
-    		} else {
6884
-    			// istvan begin
6885
-    			$NoTestRes = 1;
6886
-    		}
6887
-
6888
-    		// The Result of Tests
6889
-    		if (is_array($hpresults)) {
6890
-    			for($i = 0; $i < sizeof($hpresults); $i++) {
6891
-    				$title = GetQuizName($hpresults[$i][0],'');
6892
-    				if ($title == '')
6893
-    				$title = basename($hpresults[$i][0]);
6894
-    				$display_date = api_convert_and_format_date($hpresults[$i][3], null, date_default_timezone_get());
6895
-    				?>
6874
+            if (is_array($results)) {
6875
+                for($i = 0; $i < sizeof($results); $i++) {
6876
+                    $display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get());
6877
+                    echo "<tr>\n";
6878
+                    echo "<td class='content'>".$results[$i][0]."</td>\n";
6879
+                    echo "<td class='content'>".$display_date."</td>\n";
6880
+                    echo "<td valign='top' align='right' class='content'>".$results[$i][1]." / ".$results[$i][2]."</td>\n";
6881
+                    echo "</tr>\n";
6882
+                }
6883
+            } else {
6884
+                // istvan begin
6885
+                $NoTestRes = 1;
6886
+            }
6887
+
6888
+            // The Result of Tests
6889
+            if (is_array($hpresults)) {
6890
+                for($i = 0; $i < sizeof($hpresults); $i++) {
6891
+                    $title = GetQuizName($hpresults[$i][0],'');
6892
+                    if ($title == '')
6893
+                    $title = basename($hpresults[$i][0]);
6894
+                    $display_date = api_convert_and_format_date($hpresults[$i][3], null, date_default_timezone_get());
6895
+                    ?>
6896 6896
                     <tr>
6897 6897
                         <td class="content"><?php echo $title; ?></td>
6898 6898
                         <td class="content" align="center"><?php echo $display_date; ?></td>
@@ -6902,26 +6902,26 @@  discard block
 block discarded – undo
6902 6902
 
6903 6903
                     <?php
6904 6904
                 }
6905
-    		} else {
6906
-    			$NoHPTestRes = 1;
6907
-    		}
6908
-
6909
-    		if ($NoTestRes == 1 && $NoHPTestRes == 1) {
6910
-    			echo "<tr>\n";
6911
-    			echo "<td colspan='3'><center>".get_lang('NoResult')."</center></td>\n";
6912
-    			echo "</tr>\n";
6913
-    		}
6914
-    		echo "</table>";
6915
-    		echo "</td>\n</tr>\n";
6916
-    	} else {
6917
-    		$new_view = substr_replace($view,'1',1,1);
6918
-    		echo "
6905
+            } else {
6906
+                $NoHPTestRes = 1;
6907
+            }
6908
+
6909
+            if ($NoTestRes == 1 && $NoHPTestRes == 1) {
6910
+                echo "<tr>\n";
6911
+                echo "<td colspan='3'><center>".get_lang('NoResult')."</center></td>\n";
6912
+                echo "</tr>\n";
6913
+            }
6914
+            echo "</table>";
6915
+            echo "</td>\n</tr>\n";
6916
+        } else {
6917
+            $new_view = substr_replace($view,'1',1,1);
6918
+            echo "
6919 6919
                 <tr>
6920 6920
                     <td valign='top'>
6921 6921
                         +<font color='#0000FF'>&nbsp;&nbsp;</font><a href='".api_get_self()."?uInfo=$user_id&view=".$new_view."' class='specialLink'>".get_lang('ExercicesResults')."</a>
6922 6922
                     </td>
6923 6923
                 </tr>";
6924
-    	}
6924
+        }
6925 6925
     }
6926 6926
 
6927 6927
     /**
@@ -6930,27 +6930,27 @@  discard block
 block discarded – undo
6930 6930
      */
6931 6931
     public static function display_student_publications_tracking_info($view, $user_id, $course_id)
6932 6932
     {
6933
-    	global $TABLETRACK_UPLOADS, $TABLECOURSE_WORK;
6933
+        global $TABLETRACK_UPLOADS, $TABLECOURSE_WORK;
6934 6934
         $_course = api_get_course_info_by_id($course_id);
6935 6935
 
6936
-    	if (substr($view,2,1) == '1') {
6937
-    		$new_view = substr_replace($view,'0',2,1);
6938
-    		echo "<tr>
6936
+        if (substr($view,2,1) == '1') {
6937
+            $new_view = substr_replace($view,'0',2,1);
6938
+            echo "<tr>
6939 6939
                     <td valign='top'>
6940 6940
                     <font color='#0000FF'>-&nbsp;&nbsp;&nbsp;</font><b>".get_lang('WorkUploads')."</b>&nbsp;&nbsp;&nbsp;[<a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."'>".get_lang('Close')."</a>]&nbsp;&nbsp;&nbsp;[<a href='userLogCSV.php?".api_get_cidreq()."&uInfo=".Security::remove_XSS($_GET['uInfo'])."&view=00100'>".get_lang('ExportAsCSV')."</a>]
6941 6941
                     </td>
6942 6942
                 </tr>";
6943
-    		echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('WorksDetails')."<br>";
6944
-    		$sql = "SELECT u.upload_date, w.title, w.author,w.url
6943
+            echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('WorksDetails')."<br>";
6944
+            $sql = "SELECT u.upload_date, w.title, w.author,w.url
6945 6945
                     FROM $TABLETRACK_UPLOADS u , $TABLECOURSE_WORK w
6946 6946
                     WHERE u.upload_work_id = w.id
6947 6947
                         AND u.upload_user_id = '".intval($user_id)."'
6948 6948
                         AND u.c_id = '".intval($course_id)."'
6949 6949
                     ORDER BY u.upload_date DESC";
6950
-    		echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6951
-    		$results = StatsUtils::getManyResultsXCol($sql,4);
6952
-    		echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
6953
-    		echo "<tr>
6950
+            echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6951
+            $results = StatsUtils::getManyResultsXCol($sql,4);
6952
+            echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
6953
+            echo "<tr>
6954 6954
                     <td class='secLine' width='40%'>
6955 6955
                     ".get_lang('WorkTitle')."
6956 6956
                     </td>
@@ -6961,35 +6961,35 @@  discard block
 block discarded – undo
6961 6961
                     ".get_lang('Date')."
6962 6962
                     </td>
6963 6963
                 </tr>";
6964
-    		if (is_array($results)) {
6965
-    			for($j = 0 ; $j < count($results) ; $j++) {
6966
-    				$pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3];
6967
-    				$beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get());
6968
-    				echo "<tr>";
6969
-    				echo "<td class='content'>"
6970
-    				."<a href ='".$pathToFile."'>".$results[$j][1]."</a>"
6971
-    				."</td>";
6972
-    				echo "<td class='content'>".$results[$j][2]."</td>";
6973
-    				echo "<td class='content'>".$beautifulDate."</td>";
6974
-    				echo"</tr>";
6975
-    			}
6976
-    		} else {
6977
-    			echo "<tr>";
6978
-    			echo "<td colspan='3'><center>".get_lang('NoResult')."</center></td>";
6979
-    			echo"</tr>";
6980
-    		}
6981
-    		echo "</table>";
6982
-    		echo "</td></tr>";
6983
-    	} else {
6984
-    		$new_view = substr_replace($view,'1',2,1);
6985
-    		echo "
6964
+            if (is_array($results)) {
6965
+                for($j = 0 ; $j < count($results) ; $j++) {
6966
+                    $pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3];
6967
+                    $beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get());
6968
+                    echo "<tr>";
6969
+                    echo "<td class='content'>"
6970
+                    ."<a href ='".$pathToFile."'>".$results[$j][1]."</a>"
6971
+                    ."</td>";
6972
+                    echo "<td class='content'>".$results[$j][2]."</td>";
6973
+                    echo "<td class='content'>".$beautifulDate."</td>";
6974
+                    echo"</tr>";
6975
+                }
6976
+            } else {
6977
+                echo "<tr>";
6978
+                echo "<td colspan='3'><center>".get_lang('NoResult')."</center></td>";
6979
+                echo"</tr>";
6980
+            }
6981
+            echo "</table>";
6982
+            echo "</td></tr>";
6983
+        } else {
6984
+            $new_view = substr_replace($view,'1',2,1);
6985
+            echo "
6986 6986
                 <tr>
6987 6987
                     <td valign='top'>
6988 6988
                     +<font color='#0000FF'>&nbsp;&nbsp;</font><a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."' class='specialLink'>".get_lang('WorkUploads')."</a>
6989 6989
                     </td>
6990 6990
                 </tr>
6991 6991
             ";
6992
-    	}
6992
+        }
6993 6993
     }
6994 6994
 
6995 6995
     /**
@@ -6998,55 +6998,55 @@  discard block
 block discarded – undo
6998 6998
      */
6999 6999
     public static function display_links_tracking_info($view, $user_id, $courseCode)
7000 7000
     {
7001
-    	global $TABLETRACK_LINKS, $TABLECOURSE_LINKS;
7001
+        global $TABLETRACK_LINKS, $TABLECOURSE_LINKS;
7002 7002
         $courseId = api_get_course_int_id($courseCode);
7003
-    	if (substr($view,3,1) == '1') {
7004
-    		$new_view = substr_replace($view,'0',3,1);
7005
-    		echo "
7003
+        if (substr($view,3,1) == '1') {
7004
+            $new_view = substr_replace($view,'0',3,1);
7005
+            echo "
7006 7006
                 <tr>
7007 7007
                         <td valign='top'>
7008 7008
                         <font color='#0000FF'>-&nbsp;&nbsp;&nbsp;</font><b>".get_lang('LinksAccess')."</b>&nbsp;&nbsp;&nbsp;[<a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."'>".get_lang('Close')."</a>]&nbsp;&nbsp;&nbsp;[<a href='userLogCSV.php?".api_get_cidreq()."&uInfo=".Security::remove_XSS($_GET['uInfo'])."&view=00010'>".get_lang('ExportAsCSV')."</a>]
7009 7009
                         </td>
7010 7010
                 </tr>
7011 7011
             ";
7012
-    		echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('LinksDetails')."<br>";
7013
-    		$sql = "SELECT cl.title, cl.url
7012
+            echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('LinksDetails')."<br>";
7013
+            $sql = "SELECT cl.title, cl.url
7014 7014
                     FROM $TABLETRACK_LINKS AS sl, $TABLECOURSE_LINKS AS cl
7015 7015
                     WHERE sl.links_link_id = cl.id
7016 7016
                         AND sl.c_id = $courseId
7017 7017
                         AND sl.links_user_id = ".intval($user_id)."
7018 7018
                     GROUP BY cl.title, cl.url";
7019
-    		echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
7020
-    		$results = StatsUtils::getManyResults2Col($sql);
7021
-    		echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
7022
-    		echo "<tr>
7019
+            echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
7020
+            $results = StatsUtils::getManyResults2Col($sql);
7021
+            echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
7022
+            echo "<tr>
7023 7023
                     <td class='secLine'>
7024 7024
                     ".get_lang('LinksTitleLinkColumn')."
7025 7025
                     </td>
7026 7026
                 </tr>";
7027
-    		if (is_array($results)) {
7028
-    			for($j = 0 ; $j < count($results) ; $j++) {
7029
-    				echo "<tr>";
7030
-    				echo "<td class='content'><a href='".$results[$j][1]."'>".$results[$j][0]."</a></td>";
7031
-    				echo"</tr>";
7032
-    			}
7033
-    		} else {
7034
-    			echo "<tr>";
7035
-    			echo "<td ><center>".get_lang('NoResult')."</center></td>";
7036
-    			echo"</tr>";
7037
-    		}
7038
-    		echo "</table>";
7039
-    		echo "</td></tr>";
7040
-    	} else {
7041
-    		$new_view = substr_replace($view,'1',3,1);
7042
-    		echo "
7027
+            if (is_array($results)) {
7028
+                for($j = 0 ; $j < count($results) ; $j++) {
7029
+                    echo "<tr>";
7030
+                    echo "<td class='content'><a href='".$results[$j][1]."'>".$results[$j][0]."</a></td>";
7031
+                    echo"</tr>";
7032
+                }
7033
+            } else {
7034
+                echo "<tr>";
7035
+                echo "<td ><center>".get_lang('NoResult')."</center></td>";
7036
+                echo"</tr>";
7037
+            }
7038
+            echo "</table>";
7039
+            echo "</td></tr>";
7040
+        } else {
7041
+            $new_view = substr_replace($view,'1',3,1);
7042
+            echo "
7043 7043
                 <tr>
7044 7044
                     <td valign='top'>
7045 7045
                     +<font color='#0000FF'>&nbsp;&nbsp;</font><a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."' class='specialLink'>".get_lang('LinksAccess')."</a>
7046 7046
                     </td>
7047 7047
                 </tr>
7048 7048
             ";
7049
-    	}
7049
+        }
7050 7050
     }
7051 7051
 
7052 7052
     /**
@@ -7059,61 +7059,61 @@  discard block
 block discarded – undo
7059 7059
      */
7060 7060
     public static function display_document_tracking_info($view, $user_id, $course_code, $session_id = 0)
7061 7061
     {
7062
-    	// protect data
7062
+        // protect data
7063 7063
         $user_id = intval($user_id);
7064 7064
         $courseId = api_get_course_int_id($course_code);
7065
-    	$session_id = intval($session_id);
7065
+        $session_id = intval($session_id);
7066 7066
 
7067
-    	$downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
7068
-    	if(substr($view,4,1) == '1') {
7069
-    		$new_view = substr_replace($view,'0',4,1);
7070
-    		echo "
7067
+        $downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
7068
+        if(substr($view,4,1) == '1') {
7069
+            $new_view = substr_replace($view,'0',4,1);
7070
+            echo "
7071 7071
                 <tr>
7072 7072
                     <td valign='top'>
7073 7073
                     <font color='#0000FF'>-&nbsp;&nbsp;&nbsp;</font><b>".get_lang('DocumentsAccess')."</b>&nbsp;&nbsp;&nbsp;[<a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."'>".get_lang('Close')."</a>]&nbsp;&nbsp;&nbsp;[<a href='userLogCSV.php?".api_get_cidreq()."&uInfo=".Security::remove_XSS($_GET['uInfo'])."&view=00001'>".get_lang('ExportAsCSV')."</a>]
7074 7074
                     </td>
7075 7075
                 </tr>
7076 7076
             ";
7077
-    		echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('DocumentsDetails')."<br>";
7077
+            echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('DocumentsDetails')."<br>";
7078 7078
 
7079
-    		$sql = "SELECT down_doc_path
7079
+            $sql = "SELECT down_doc_path
7080 7080
                     FROM $downloads_table
7081 7081
                     WHERE c_id = $courseId
7082 7082
                         AND down_user_id = $user_id
7083 7083
                         AND down_session_id = $session_id
7084 7084
                     GROUP BY down_doc_path";
7085 7085
 
7086
-    		echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
7087
-    		$results = StatsUtils::getManyResults1Col($sql);
7088
-    		echo "<table cellpadding='2' cellspacing='1' border='0' align='center'>";
7089
-    		echo "<tr>
7086
+            echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
7087
+            $results = StatsUtils::getManyResults1Col($sql);
7088
+            echo "<table cellpadding='2' cellspacing='1' border='0' align='center'>";
7089
+            echo "<tr>
7090 7090
                     <td class='secLine'>
7091 7091
                     ".get_lang('DocumentsTitleDocumentColumn')."
7092 7092
                     </td>
7093 7093
                 </tr>";
7094
-    		if (is_array($results)) {
7095
-    			for($j = 0 ; $j < count($results) ; $j++) {
7096
-    				echo "<tr>";
7097
-    				echo "<td class='content'>".$results[$j]."</td>";
7098
-    				echo"</tr>";
7099
-    			}
7100
-    		} else {
7101
-    			echo "<tr>";
7102
-    			echo "<td><center>".get_lang('NoResult')."</center></td>";
7103
-    			echo"</tr>";
7104
-    		}
7105
-    		echo "</table>";
7106
-    		echo "</td></tr>";
7107
-    	} else {
7108
-    		$new_view = substr_replace($view,'1',4,1);
7109
-    		echo "
7094
+            if (is_array($results)) {
7095
+                for($j = 0 ; $j < count($results) ; $j++) {
7096
+                    echo "<tr>";
7097
+                    echo "<td class='content'>".$results[$j]."</td>";
7098
+                    echo"</tr>";
7099
+                }
7100
+            } else {
7101
+                echo "<tr>";
7102
+                echo "<td><center>".get_lang('NoResult')."</center></td>";
7103
+                echo"</tr>";
7104
+            }
7105
+            echo "</table>";
7106
+            echo "</td></tr>";
7107
+        } else {
7108
+            $new_view = substr_replace($view,'1',4,1);
7109
+            echo "
7110 7110
                 <tr>
7111 7111
                     <td valign='top'>
7112 7112
                     +<font color='#0000FF'>&nbsp;&nbsp;</font><a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."' class='specialLink'>".get_lang('DocumentsAccess')."</a>
7113 7113
                     </td>
7114 7114
                 </tr>
7115 7115
             ";
7116
-    	}
7116
+        }
7117 7117
     }
7118 7118
 
7119 7119
     /**
@@ -7170,43 +7170,43 @@  discard block
 block discarded – undo
7170 7170
      */
7171 7171
     public function display_login_tracking_info($view, $user_id, $course_id, $session_id = 0)
7172 7172
     {
7173
-    	$MonthsLong = $GLOBALS['MonthsLong'];
7174
-    	$track_access_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
7175
-
7176
-    	// protected data
7177
-    	$user_id    = intval($user_id);
7178
-    	$session_id = intval($session_id);
7179
-    	$course_id  = intval($course_id);
7180
-
7181
-    	$tempView = $view;
7182
-    	if (substr($view,0,1) == '1') {
7183
-    		$new_view = substr_replace($view,'0',0,1);
7184
-    		$title[1]= get_lang('LoginsAndAccessTools').get_lang('LoginsDetails');
7185
-    		$sql = "SELECT UNIX_TIMESTAMP(access_date), count(access_date)
7173
+        $MonthsLong = $GLOBALS['MonthsLong'];
7174
+        $track_access_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
7175
+
7176
+        // protected data
7177
+        $user_id    = intval($user_id);
7178
+        $session_id = intval($session_id);
7179
+        $course_id  = intval($course_id);
7180
+
7181
+        $tempView = $view;
7182
+        if (substr($view,0,1) == '1') {
7183
+            $new_view = substr_replace($view,'0',0,1);
7184
+            $title[1]= get_lang('LoginsAndAccessTools').get_lang('LoginsDetails');
7185
+            $sql = "SELECT UNIX_TIMESTAMP(access_date), count(access_date)
7186 7186
                     FROM $track_access_table
7187 7187
                     WHERE access_user_id = $user_id
7188 7188
                     AND c_id = $course_id
7189 7189
                     AND access_session_id = $session_id
7190 7190
                     GROUP BY YEAR(access_date),MONTH(access_date)
7191 7191
                     ORDER BY YEAR(access_date),MONTH(access_date) ASC";
7192
-    		//$results = getManyResults2Col($sql);
7193
-    		$results = getManyResults3Col($sql);
7194
-    		$title_line= get_lang('LoginsTitleMonthColumn').';'.get_lang('LoginsTitleCountColumn')."\n";
7195
-    		$line='';
7196
-    		$total = 0;
7197
-    		if (is_array($results)) {
7198
-    			for($j = 0 ; $j < count($results) ; $j++) {
7199
-    				$line .= $results[$j][0].';'.$results[$j][1]."\n";
7200
-    				$total = $total + $results[$j][1];
7201
-    			}
7202
-    			$line .= get_lang('Total').";".$total."\n";
7203
-    		} else {
7204
-    			$line= get_lang('NoResult')."</center></td>";
7205
-    		}
7206
-    	} else {
7207
-    		$new_view = substr_replace($view,'1',0,1);
7208
-    	}
7209
-    	return array($title_line, $line);
7192
+            //$results = getManyResults2Col($sql);
7193
+            $results = getManyResults3Col($sql);
7194
+            $title_line= get_lang('LoginsTitleMonthColumn').';'.get_lang('LoginsTitleCountColumn')."\n";
7195
+            $line='';
7196
+            $total = 0;
7197
+            if (is_array($results)) {
7198
+                for($j = 0 ; $j < count($results) ; $j++) {
7199
+                    $line .= $results[$j][0].';'.$results[$j][1]."\n";
7200
+                    $total = $total + $results[$j][1];
7201
+                }
7202
+                $line .= get_lang('Total').";".$total."\n";
7203
+            } else {
7204
+                $line= get_lang('NoResult')."</center></td>";
7205
+            }
7206
+        } else {
7207
+            $new_view = substr_replace($view,'1',0,1);
7208
+        }
7209
+        return array($title_line, $line);
7210 7210
     }
7211 7211
 
7212 7212
     /**
@@ -7219,67 +7219,67 @@  discard block
 block discarded – undo
7219 7219
      */
7220 7220
     public function display_exercise_tracking_info($view, $userId, $courseCode)
7221 7221
     {
7222
-    	global $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $TABLETRACK_HOTPOTATOES, $dateTimeFormatLong;
7222
+        global $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $TABLETRACK_HOTPOTATOES, $dateTimeFormatLong;
7223 7223
         $courseId = api_get_course_int_id($courseCode);
7224 7224
         $userId = intval($userId);
7225
-    	if (substr($view,1,1) == '1') {
7226
-    		$new_view = substr_replace($view,'0',1,1);
7227
-    		$title[1] = get_lang('ExercicesDetails');
7228
-    		$line = '';
7229
-    		$sql = "SELECT ce.title, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
7225
+        if (substr($view,1,1) == '1') {
7226
+            $new_view = substr_replace($view,'0',1,1);
7227
+            $title[1] = get_lang('ExercicesDetails');
7228
+            $line = '';
7229
+            $sql = "SELECT ce.title, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
7230 7230
                     FROM $TABLECOURSE_EXERCICES AS ce , $TABLETRACK_EXERCICES AS te
7231 7231
                     WHERE te.c_id = $courseId
7232 7232
                         AND te.exe_user_id = $userId
7233 7233
                         AND te.exe_exo_id = ce.id
7234 7234
                     ORDER BY ce.title ASC, te.exe_date ASC";
7235 7235
 
7236
-    		$hpsql = "SELECT te.exe_name, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
7236
+            $hpsql = "SELECT te.exe_name, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
7237 7237
                         FROM $TABLETRACK_HOTPOTATOES AS te
7238 7238
                         WHERE te.exe_user_id = '$userId' AND te.c_id = $courseId
7239 7239
                         ORDER BY te.c_id ASC, te.exe_date ASC";
7240 7240
 
7241
-    		$hpresults = StatsUtils::getManyResultsXCol($hpsql, 4);
7241
+            $hpresults = StatsUtils::getManyResultsXCol($hpsql, 4);
7242 7242
 
7243
-    		$NoTestRes = 0;
7244
-    		$NoHPTestRes = 0;
7243
+            $NoTestRes = 0;
7244
+            $NoHPTestRes = 0;
7245 7245
 
7246
-    		$results = StatsUtils::getManyResultsXCol($sql, 4);
7247
-    		$title_line = get_lang('ExercicesTitleExerciceColumn').";".get_lang('Date').';'.get_lang('ExercicesTitleScoreColumn')."\n";
7246
+            $results = StatsUtils::getManyResultsXCol($sql, 4);
7247
+            $title_line = get_lang('ExercicesTitleExerciceColumn').";".get_lang('Date').';'.get_lang('ExercicesTitleScoreColumn')."\n";
7248 7248
 
7249
-    		if (is_array($results)) {
7250
-    			for($i = 0; $i < sizeof($results); $i++)
7251
-    			{
7252
-    				$display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get());
7253
-    				$line .= $results[$i][0].";".$display_date.";".$results[$i][1]." / ".$results[$i][2]."\n";
7254
-    			}
7255
-    		} else {
7249
+            if (is_array($results)) {
7250
+                for($i = 0; $i < sizeof($results); $i++)
7251
+                {
7252
+                    $display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get());
7253
+                    $line .= $results[$i][0].";".$display_date.";".$results[$i][1]." / ".$results[$i][2]."\n";
7254
+                }
7255
+            } else {
7256 7256
                 // istvan begin
7257
-    			$NoTestRes = 1;
7258
-    		}
7259
-
7260
-    		// The Result of Tests
7261
-    		if (is_array($hpresults)) {
7262
-    			for($i = 0; $i < sizeof($hpresults); $i++) {
7263
-    				$title = GetQuizName($hpresults[$i][0],'');
7264
-
7265
-    				if ($title == '')
7266
-    				$title = basename($hpresults[$i][0]);
7267
-
7268
-    				$display_date = api_convert_and_format_date($hpresults[$i][3], null, date_default_timezone_get());
7269
-
7270
-    				$line .= $title.';'.$display_date.';'.$hpresults[$i][1].'/'.$hpresults[$i][2]."\n";
7271
-    			}
7272
-    		} else {
7273
-    			$NoHPTestRes = 1;
7274
-    		}
7275
-
7276
-    		if ($NoTestRes == 1 && $NoHPTestRes == 1) {
7277
-    			$line=get_lang('NoResult');
7278
-    		}
7279
-    	} else {
7280
-    		$new_view = substr_replace($view,'1',1,1);
7281
-    	}
7282
-    	return array($title_line, $line);
7257
+                $NoTestRes = 1;
7258
+            }
7259
+
7260
+            // The Result of Tests
7261
+            if (is_array($hpresults)) {
7262
+                for($i = 0; $i < sizeof($hpresults); $i++) {
7263
+                    $title = GetQuizName($hpresults[$i][0],'');
7264
+
7265
+                    if ($title == '')
7266
+                    $title = basename($hpresults[$i][0]);
7267
+
7268
+                    $display_date = api_convert_and_format_date($hpresults[$i][3], null, date_default_timezone_get());
7269
+
7270
+                    $line .= $title.';'.$display_date.';'.$hpresults[$i][1].'/'.$hpresults[$i][2]."\n";
7271
+                }
7272
+            } else {
7273
+                $NoHPTestRes = 1;
7274
+            }
7275
+
7276
+            if ($NoTestRes == 1 && $NoHPTestRes == 1) {
7277
+                $line=get_lang('NoResult');
7278
+            }
7279
+        } else {
7280
+            $new_view = substr_replace($view,'1',1,1);
7281
+        }
7282
+        return array($title_line, $line);
7283 7283
     }
7284 7284
 
7285 7285
     /**
@@ -7288,37 +7288,37 @@  discard block
 block discarded – undo
7288 7288
      */
7289 7289
     public function display_student_publications_tracking_info($view, $user_id, $course_id)
7290 7290
     {
7291
-    	global $TABLETRACK_UPLOADS, $TABLECOURSE_WORK;
7291
+        global $TABLETRACK_UPLOADS, $TABLECOURSE_WORK;
7292 7292
         $_course = api_get_course_info();
7293 7293
         $user_id = intval($user_id);
7294 7294
         $course_id = intval($course_id);
7295 7295
 
7296
-    	if (substr($view,2,1) == '1') {
7297
-    		$sql = "SELECT u.upload_date, w.title, w.author, w.url
7296
+        if (substr($view,2,1) == '1') {
7297
+            $sql = "SELECT u.upload_date, w.title, w.author, w.url
7298 7298
                     FROM $TABLETRACK_UPLOADS u , $TABLECOURSE_WORK w
7299 7299
                     WHERE
7300 7300
                         u.upload_work_id = w.id AND
7301 7301
                         u.upload_user_id = '$user_id' AND
7302 7302
                         u.c_id = '$course_id'
7303 7303
                     ORDER BY u.upload_date DESC";
7304
-    		$results = StatsUtils::getManyResultsXCol($sql,4);
7305
-
7306
-    		$title[1]=get_lang('WorksDetails');
7307
-    		$line='';
7308
-    		$title_line=get_lang('WorkTitle').";".get_lang('WorkAuthors').";".get_lang('Date')."\n";
7309
-
7310
-    		if (is_array($results)) {
7311
-    			for($j = 0 ; $j < count($results) ; $j++) {
7312
-    				$pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3];
7313
-    				$beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get());
7314
-    				$line .= $results[$j][1].";".$results[$j][2].";".$beautifulDate."\n";
7315
-    			}
7316
-
7317
-    		} else {
7318
-    			$line= get_lang('NoResult');
7319
-    		}
7320
-    	}
7321
-    	return array($title_line, $line);
7304
+            $results = StatsUtils::getManyResultsXCol($sql,4);
7305
+
7306
+            $title[1]=get_lang('WorksDetails');
7307
+            $line='';
7308
+            $title_line=get_lang('WorkTitle').";".get_lang('WorkAuthors').";".get_lang('Date')."\n";
7309
+
7310
+            if (is_array($results)) {
7311
+                for($j = 0 ; $j < count($results) ; $j++) {
7312
+                    $pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3];
7313
+                    $beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get());
7314
+                    $line .= $results[$j][1].";".$results[$j][2].";".$beautifulDate."\n";
7315
+                }
7316
+
7317
+            } else {
7318
+                $line= get_lang('NoResult');
7319
+            }
7320
+        }
7321
+        return array($title_line, $line);
7322 7322
     }
7323 7323
 
7324 7324
     /**
@@ -7327,32 +7327,32 @@  discard block
 block discarded – undo
7327 7327
      */
7328 7328
     public function display_links_tracking_info($view, $userId, $courseCode)
7329 7329
     {
7330
-    	global $TABLETRACK_LINKS, $TABLECOURSE_LINKS;
7330
+        global $TABLETRACK_LINKS, $TABLECOURSE_LINKS;
7331 7331
         $courseId = api_get_course_int_id($courseCode);
7332 7332
         $userId = intval($userId);
7333 7333
         $line = null;
7334
-    	if (substr($view,3,1) == '1') {
7335
-    		$new_view = substr_replace($view,'0',3,1);
7336
-    		$title[1]=get_lang('LinksDetails');
7337
-    		$sql = "SELECT cl.title, cl.url
7334
+        if (substr($view,3,1) == '1') {
7335
+            $new_view = substr_replace($view,'0',3,1);
7336
+            $title[1]=get_lang('LinksDetails');
7337
+            $sql = "SELECT cl.title, cl.url
7338 7338
                         FROM $TABLETRACK_LINKS AS sl, $TABLECOURSE_LINKS AS cl
7339 7339
                         WHERE sl.links_link_id = cl.id
7340 7340
                             AND sl.c_id = $courseId
7341 7341
                             AND sl.links_user_id = $userId
7342 7342
                         GROUP BY cl.title, cl.url";
7343
-    		$results = StatsUtils::getManyResults2Col($sql);
7344
-    		$title_line= get_lang('LinksTitleLinkColumn')."\n";
7345
-    		if (is_array($results)) {
7346
-    			for ($j = 0 ; $j < count($results) ; $j++) {
7347
-    				$line .= $results[$j][0]."\n";
7348
-    			}
7349
-    		} else {
7350
-    			$line=get_lang('NoResult');
7351
-    		}
7352
-    	} else {
7353
-    		$new_view = substr_replace($view,'1',3,1);
7354
-    	}
7355
-    	return array($title_line, $line);
7343
+            $results = StatsUtils::getManyResults2Col($sql);
7344
+            $title_line= get_lang('LinksTitleLinkColumn')."\n";
7345
+            if (is_array($results)) {
7346
+                for ($j = 0 ; $j < count($results) ; $j++) {
7347
+                    $line .= $results[$j][0]."\n";
7348
+                }
7349
+            } else {
7350
+                $line=get_lang('NoResult');
7351
+            }
7352
+        } else {
7353
+            $new_view = substr_replace($view,'1',3,1);
7354
+        }
7355
+        return array($title_line, $line);
7356 7356
     }
7357 7357
 
7358 7358
     /**
@@ -7365,38 +7365,38 @@  discard block
 block discarded – undo
7365 7365
      */
7366 7366
     public function display_document_tracking_info($view, $user_id, $courseCode, $session_id = 0)
7367 7367
     {
7368
-    	// protect data
7369
-    	$user_id     = intval($user_id);
7368
+        // protect data
7369
+        $user_id     = intval($user_id);
7370 7370
         $courseId = api_get_course_int_id($courseCode);
7371
-    	$session_id = intval($session_id);
7371
+        $session_id = intval($session_id);
7372 7372
 
7373
-    	$downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
7373
+        $downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
7374 7374
 
7375
-    	if (substr($view,4,1) == '1') {
7376
-    		$new_view = substr_replace($view,'0',4,1);
7377
-    		$title[1]= get_lang('DocumentsDetails');
7375
+        if (substr($view,4,1) == '1') {
7376
+            $new_view = substr_replace($view,'0',4,1);
7377
+            $title[1]= get_lang('DocumentsDetails');
7378 7378
 
7379
-    		$sql = "SELECT down_doc_path
7379
+            $sql = "SELECT down_doc_path
7380 7380
                         FROM $downloads_table
7381 7381
                         WHERE c_id = $courseId
7382 7382
                             AND down_user_id = $user_id
7383 7383
                             AND down_session_id = $session_id
7384 7384
                         GROUP BY down_doc_path";
7385 7385
 
7386
-    		$results = StatsUtils::getManyResults1Col($sql);
7387
-    		$title_line = get_lang('DocumentsTitleDocumentColumn')."\n";
7386
+            $results = StatsUtils::getManyResults1Col($sql);
7387
+            $title_line = get_lang('DocumentsTitleDocumentColumn')."\n";
7388 7388
             $line = null;
7389
-    		if (is_array($results)) {
7390
-    			for ($j = 0 ; $j < count($results) ; $j++) {
7391
-    				$line .= $results[$j]."\n";
7392
-    			}
7393
-    		} else {
7394
-    			$line = get_lang('NoResult');
7395
-    		}
7396
-    	} else {
7397
-    		$new_view = substr_replace($view,'1',4,1);
7398
-    	}
7399
-    	return array($title_line, $line);
7389
+            if (is_array($results)) {
7390
+                for ($j = 0 ; $j < count($results) ; $j++) {
7391
+                    $line .= $results[$j]."\n";
7392
+                }
7393
+            } else {
7394
+                $line = get_lang('NoResult');
7395
+            }
7396
+        } else {
7397
+            $new_view = substr_replace($view,'1',4,1);
7398
+        }
7399
+        return array($title_line, $line);
7400 7400
     }
7401 7401
 
7402 7402
     /**
Please login to merge, or discard this patch.
Spacing   +432 added lines, -432 removed lines patch added patch discarded remove patch
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
         $extendedAttempt = null,
115 115
         $extendedAll = null,
116 116
         $type = 'classic',
117
-        $allowExtend =  true
117
+        $allowExtend = true
118 118
     ) {
119 119
         if (empty($courseInfo) || empty($lp_id)) {
120 120
             return null;
@@ -138,22 +138,22 @@  discard block
 block discarded – undo
138 138
         $extend_all = 0;
139 139
 
140 140
         if ($origin == 'tracking') {
141
-            $url_suffix = '&session_id=' . $session_id . '&course=' . $courseCode . '&student_id=' . $user_id . '&lp_id=' . $lp_id . '&origin=' . $origin;
141
+            $url_suffix = '&session_id='.$session_id.'&course='.$courseCode.'&student_id='.$user_id.'&lp_id='.$lp_id.'&origin='.$origin;
142 142
         } else {
143
-            $url_suffix = '&lp_id=' . $lp_id;
143
+            $url_suffix = '&lp_id='.$lp_id;
144 144
         }
145 145
 
146 146
         if (!empty($extendedAll)) {
147 147
             $extend_all_link = Display::url(
148 148
                 Display::return_icon('view_less_stats.gif', get_lang('HideAllAttempts')),
149
-                api_get_self() . '?action=stats' . $url_suffix
149
+                api_get_self().'?action=stats'.$url_suffix
150 150
             );
151 151
 
152 152
             $extend_all = 1;
153 153
         } else {
154 154
             $extend_all_link = Display::url(
155 155
                 Display::return_icon('view_more_stats.gif', get_lang('ShowAllAttempts')),
156
-                api_get_self() . '?action=stats&extend_all=1' . $url_suffix
156
+                api_get_self().'?action=stats&extend_all=1'.$url_suffix
157 157
             );
158 158
         }
159 159
 
@@ -165,24 +165,24 @@  discard block
 block discarded – undo
165 165
 
166 166
         $actionColumn = null;
167 167
         if ($type == 'classic') {
168
-            $actionColumn = ' <th>' . get_lang('Actions') . '</th>';
168
+            $actionColumn = ' <th>'.get_lang('Actions').'</th>';
169 169
         }
170 170
         $output .= '<div class="table-responsive">';
171 171
         $output .= '<table class="table tracking">
172 172
             <thead>
173 173
             <tr class="table-header">
174
-                <th width="16">' . ($allowExtend == true ? $extend_all_link : '&nbsp;') . '</th>
174
+                <th width="16">' . ($allowExtend == true ? $extend_all_link : '&nbsp;').'</th>
175 175
                 <th colspan="4">
176
-                    ' . get_lang('ScormLessonTitle') .'
176
+                    ' . get_lang('ScormLessonTitle').'
177 177
                 </th>
178 178
                 <th colspan="2">
179
-                    ' . get_lang('ScormStatus') . '
179
+                    ' . get_lang('ScormStatus').'
180 180
                 </th>
181 181
                 <th colspan="2">
182
-                    ' . get_lang('ScormScore') . '
182
+                    ' . get_lang('ScormScore').'
183 183
                 </th>
184 184
                 <th colspan="2">
185
-                    ' . get_lang('ScormTime') . '
185
+                    ' . get_lang('ScormTime').'
186 186
                 </th>
187 187
                 '.$actionColumn.'
188 188
                 </tr>
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
                 // Prepare statement to go through each attempt.
246 246
                 $viewCondition = null;
247 247
                 if (!empty($view)) {
248
-                    $viewCondition =  " AND v.view_count = $view  ";
248
+                    $viewCondition = " AND v.view_count = $view  ";
249 249
                 }
250 250
 
251 251
                 $sql = "SELECT
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
                                 FROM $TBL_QUIZ
294 294
                                 WHERE
295 295
                                     c_id = $course_id AND
296
-                                    id ='" . $my_path . "'";
296
+                                    id ='".$my_path."'";
297 297
                         $res_result_disabled = Database::query($sql);
298 298
                         $row_result_disabled = Database::fetch_row($res_result_disabled);
299 299
 
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
                     if (!empty($inter_num)) {
316 316
                         $extend_link = Display::url(
317 317
                               Display::return_icon('visible.gif', get_lang('HideAttemptView')),
318
-                              api_get_self() . '?action=stats&fold_id=' . $my_item_id . $url_suffix
318
+                              api_get_self().'?action=stats&fold_id='.$my_item_id.$url_suffix
319 319
                         );
320 320
                     }
321 321
                     $title = $row['mytitle'];
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
 
334 334
                     $action = null;
335 335
                     if ($type == 'classic') {
336
-                        $action =  '<td></td>';
336
+                        $action = '<td></td>';
337 337
                     }
338 338
 
339 339
                     if (in_array($row['item_type'], $chapterTypes)) {
@@ -377,13 +377,13 @@  discard block
 block discarded – undo
377 377
                                 $extend_this_attempt = 1;
378 378
                                 $extend_attempt_link = Display::url(
379 379
                                     Display::return_icon('visible.gif', get_lang('HideAttemptView')),
380
-                                    api_get_self() . '?action=stats&extend_id=' . $my_item_id . '&fold_attempt_id=' . $row['iv_id'] . $url_suffix
380
+                                    api_get_self().'?action=stats&extend_id='.$my_item_id.'&fold_attempt_id='.$row['iv_id'].$url_suffix
381 381
                                 );
382 382
                             } else { // Same case if fold_attempt_id is set, so not implemented explicitly.
383 383
                                 // The extend button for this attempt has not been clicked.
384 384
                                 $extend_attempt_link = Display::url(
385 385
                                     Display::return_icon('invisible.gif', get_lang('ExtendAttemptView')),
386
-                                    api_get_self() . '?action=stats&extend_id=' . $my_item_id . '&extend_attempt_id=' . $row['iv_id'] . $url_suffix
386
+                                    api_get_self().'?action=stats&extend_id='.$my_item_id.'&extend_attempt_id='.$row['iv_id'].$url_suffix
387 387
                                 );
388 388
                             }
389 389
                         }
@@ -416,7 +416,7 @@  discard block
 block discarded – undo
416 416
                         }
417 417
 
418 418
                         // Remove "NaN" if any (@todo: locate the source of these NaN)
419
-                        $time = str_replace('NaN', '00' . $h . '00\'00"', $time);
419
+                        $time = str_replace('NaN', '00'.$h.'00\'00"', $time);
420 420
 
421 421
                         if ($row['item_type'] != 'dir') {
422 422
                             if (!$is_allowed_to_edit && $result_disabled_ext_all) {
@@ -444,13 +444,13 @@  discard block
 block discarded – undo
444 444
                                 $action = '<td></td>';
445 445
                             }
446 446
 
447
-                            $output .= '<tr class="' . $oddclass . '">
447
+                            $output .= '<tr class="'.$oddclass.'">
448 448
                                     <td></td>
449
-                                    <td>' . $extend_attempt_link . '</td>
450
-                                    <td colspan="3">' . get_lang('Attempt') . ' ' . $attemptCount . '</td>
451
-                                    <td colspan="2">' . learnpathItem::humanize_status($lesson_status, true, $type) . '</td>
452
-                                    <td colspan="2">' . $view_score . '</td>
453
-                                    <td colspan="2">' . $time . '</td>
449
+                                    <td>' . $extend_attempt_link.'</td>
450
+                                    <td colspan="3">' . get_lang('Attempt').' '.$attemptCount.'</td>
451
+                                    <td colspan="2">' . learnpathItem::humanize_status($lesson_status, true, $type).'</td>
452
+                                    <td colspan="2">' . $view_score.'</td>
453
+                                    <td colspan="2">' . $time.'</td>
454 454
                                     '.$action.'
455 455
                                 </tr>';
456 456
                             $attemptCount++;
@@ -463,10 +463,10 @@  discard block
 block discarded – undo
463 463
                                     if (!$is_allowed_to_edit && $result_disabled_ext_all) {
464 464
                                         $temp[] = '/';
465 465
                                     } else {
466
-                                        $temp[] = ($score == 0 ? '0/' . $maxscore : ($maxscore == 0 ? $score : $score . '/' . float_format($maxscore, 1)));
466
+                                        $temp[] = ($score == 0 ? '0/'.$maxscore : ($maxscore == 0 ? $score : $score.'/'.float_format($maxscore, 1)));
467 467
                                     }
468 468
                                 } else {
469
-                                    $temp[] = ($score == 0 ? '/' : ($maxscore == 0 ? $score : $score . '/' . float_format($maxscore, 1)));
469
+                                    $temp[] = ($score == 0 ? '/' : ($maxscore == 0 ? $score : $score.'/'.float_format($maxscore, 1)));
470 470
                                 }
471 471
                                 $temp[] = $time;
472 472
                                 $csv_content[] = $temp;
@@ -503,13 +503,13 @@  discard block
 block discarded – undo
503 503
                                         <td></td>
504 504
                                         <td></td>
505 505
                                         <td></td>
506
-                                        <td>'.$interaction['order_id'] . '</td>
507
-                                        <td>'.$interaction['id'] . '</td>
506
+                                        <td>'.$interaction['order_id'].'</td>
507
+                                        <td>'.$interaction['id'].'</td>
508 508
                                         <td colspan="2">' . $interaction['type'].'</td>
509
-                                        <td>'.$student_response . '</td>
510
-                                        <td>'.$interaction['result'] . '</td>
511
-                                        <td>'.$interaction['latency'] . '</td>
512
-                                        <td>'.$interaction['time'] . '</td>
509
+                                        <td>'.$student_response.'</td>
510
+                                        <td>'.$interaction['result'].'</td>
511
+                                        <td>'.$interaction['latency'].'</td>
512
+                                        <td>'.$interaction['time'].'</td>
513 513
                                         '.$action.'
514 514
                                     </tr>';
515 515
                                 $counter++;
@@ -526,12 +526,12 @@  discard block
 block discarded – undo
526 526
                                         <td></td>
527 527
                                         <td></td>
528 528
                                         <td></td>
529
-                                        <td>' . $interaction['order_id'] . '</td>
530
-                                        <td colspan="2">' . $interaction['objective_id'] . '</td>
531
-                                        <td colspan="2">' . $interaction['status'] .'</td>
532
-                                        <td>' . $interaction['score_raw'] . '</td>
533
-                                        <td>' . $interaction['score_max'] . '</td>
534
-                                        <td>' . $interaction['score_min'] . '</td>
529
+                                        <td>' . $interaction['order_id'].'</td>
530
+                                        <td colspan="2">' . $interaction['objective_id'].'</td>
531
+                                        <td colspan="2">' . $interaction['status'].'</td>
532
+                                        <td>' . $interaction['score_raw'].'</td>
533
+                                        <td>' . $interaction['score_max'].'</td>
534
+                                        <td>' . $interaction['score_min'].'</td>
535 535
                                         '.$action.'
536 536
                                      </tr>';
537 537
                                 $counter++;
@@ -554,7 +554,7 @@  discard block
 block discarded – undo
554 554
                         $my_path = Database::escape_string($my_path);
555 555
                         $sql = "SELECT results_disabled
556 556
                                 FROM $TBL_QUIZ
557
-                                WHERE c_id = $course_id AND id ='" . $my_path . "'";
557
+                                WHERE c_id = $course_id AND id ='".$my_path."'";
558 558
                         $res_result_disabled = Database::query($sql);
559 559
                         $row_result_disabled = Database::fetch_row($res_result_disabled);
560 560
 
@@ -578,14 +578,14 @@  discard block
 block discarded – undo
578 578
                             $extend_this_attempt = 1;
579 579
                             $extend_attempt_link = Display::url(
580 580
                                 Display::return_icon('visible.gif', get_lang('HideAttemptView')),
581
-                                api_get_self() . '?action=stats&extend_id=' . $my_item_id . '&fold_attempt_id=' . $row['iv_id'] . $url_suffix
581
+                                api_get_self().'?action=stats&extend_id='.$my_item_id.'&fold_attempt_id='.$row['iv_id'].$url_suffix
582 582
                             );
583 583
                         } else {
584 584
                             // Same case if fold_attempt_id is set, so not implemented explicitly.
585 585
                             // The extend button for this attempt has not been clicked.
586 586
                             $extend_attempt_link = Display::url(
587 587
                                 Display::return_icon('invisible.gif', get_lang('ExtendAttemptView')),
588
-                                api_get_self() . '?action=stats&extend_id=' . $my_item_id . '&extend_attempt_id=' . $row['iv_id'] . $url_suffix
588
+                                api_get_self().'?action=stats&extend_id='.$my_item_id.'&extend_attempt_id='.$row['iv_id'].$url_suffix
589 589
                             );
590 590
                         }
591 591
                     }
@@ -600,7 +600,7 @@  discard block
 block discarded – undo
600 600
                     if ($inter_num > 1) {
601 601
                         $extend_link = Display::url(
602 602
                             Display::return_icon('invisible.gif', get_lang('ExtendAttemptView')),
603
-                            api_get_self() . '?action=stats&extend_id=' . $my_item_id . '&extend_attempt_id=' . $row['iv_id'] . $url_suffix
603
+                            api_get_self().'?action=stats&extend_id='.$my_item_id.'&extend_attempt_id='.$row['iv_id'].$url_suffix
604 604
                         );
605 605
                     }
606 606
 
@@ -616,15 +616,15 @@  discard block
 block discarded – undo
616 616
 
617 617
                     // Selecting the exe_id from stats attempts tables in order to look the max score value.
618 618
 
619
-                    $sql = 'SELECT * FROM ' . $tbl_stats_exercices . '
619
+                    $sql = 'SELECT * FROM '.$tbl_stats_exercices.'
620 620
                              WHERE
621
-                                exe_exo_id="' . $row['path'] . '" AND
622
-                                exe_user_id="' . $user_id . '" AND
623
-                                orig_lp_id = "' . $lp_id . '" AND
624
-                                orig_lp_item_id = "' . $row['myid'] . '" AND
625
-                                c_id = ' . $course_id . ' AND
621
+                                exe_exo_id="' . $row['path'].'" AND
622
+                                exe_user_id="' . $user_id.'" AND
623
+                                orig_lp_id = "' . $lp_id.'" AND
624
+                                orig_lp_item_id = "' . $row['myid'].'" AND
625
+                                c_id = ' . $course_id.' AND
626 626
                                 status <> "incomplete" AND
627
-                                session_id = ' . $session_id . '
627
+                                session_id = ' . $session_id.'
628 628
                              ORDER BY exe_date DESC
629 629
                              LIMIT 1';
630 630
 
@@ -655,8 +655,8 @@  discard block
 block discarded – undo
655 655
                                         FROM $TBL_LP_ITEM_VIEW
656 656
                                         WHERE
657 657
                                             c_id = $course_id AND
658
-                                            lp_item_id = '" . (int) $my_id . "' AND
659
-                                            lp_view_id = '" . (int) $my_lp_view_id . "'
658
+                                            lp_item_id = '".(int) $my_id."' AND
659
+                                            lp_view_id = '" . (int) $my_lp_view_id."'
660 660
                                         ORDER BY view_count DESC limit 1";
661 661
                                 $res_score = Database::query($sql);
662 662
                                 $row_score = Database::fetch_array($res_score);
@@ -665,8 +665,8 @@  discard block
 block discarded – undo
665 665
                                         FROM $TBL_LP_ITEM_VIEW
666 666
                                         WHERE
667 667
                                             c_id = $course_id AND
668
-                                            lp_item_id = '" . (int) $my_id . "' AND
669
-                                            lp_view_id = '" . (int) $my_lp_view_id . "'";
668
+                                            lp_item_id = '".(int) $my_id."' AND
669
+                                            lp_view_id = '" . (int) $my_lp_view_id."'";
670 670
                                 $res_time = Database::query($sql);
671 671
                                 $row_time = Database::fetch_array($res_time);
672 672
 
@@ -725,16 +725,16 @@  discard block
 block discarded – undo
725 725
                     } else {
726 726
                         $correct_test_link = '-';
727 727
                         if ($row['item_type'] == 'quiz') {
728
-                            $my_url_suffix = '&course=' . $courseCode . '&student_id=' . $user_id . '&lp_id=' . intval($row['mylpid']) . '&origin=' . $origin;
729
-                            $sql = 'SELECT * FROM ' . $tbl_stats_exercices . '
728
+                            $my_url_suffix = '&course='.$courseCode.'&student_id='.$user_id.'&lp_id='.intval($row['mylpid']).'&origin='.$origin;
729
+                            $sql = 'SELECT * FROM '.$tbl_stats_exercices.'
730 730
                                      WHERE
731
-                                        exe_exo_id="' . $row['path'] . '" AND
732
-                                        exe_user_id="' . $user_id . '" AND
733
-                                        orig_lp_id = "' . $lp_id . '" AND
734
-                                        orig_lp_item_id = "' . $row['myid'] . '" AND
735
-                                        c_id = ' . $course_id . ' AND
731
+                                        exe_exo_id="' . $row['path'].'" AND
732
+                                        exe_user_id="' . $user_id.'" AND
733
+                                        orig_lp_id = "' . $lp_id.'" AND
734
+                                        orig_lp_item_id = "' . $row['myid'].'" AND
735
+                                        c_id = ' . $course_id.' AND
736 736
                                         status <> "incomplete" AND
737
-                                        session_id = ' . $session_id . '
737
+                                        session_id = ' . $session_id.'
738 738
                                      ORDER BY exe_date DESC ';
739 739
 
740 740
                             $resultLastAttempt = Database::query($sql);
@@ -746,12 +746,12 @@  discard block
 block discarded – undo
746 746
                                 ) {
747 747
                                     $correct_test_link = Display::url(
748 748
                                         Display::return_icon('view_less_stats.gif', get_lang('HideAllAttempts')),
749
-                                        api_get_self() . '?action=stats' . $my_url_suffix . '&session_id=' . $session_id . '&lp_item_id=' . $my_id
749
+                                        api_get_self().'?action=stats'.$my_url_suffix.'&session_id='.$session_id.'&lp_item_id='.$my_id
750 750
                                     );
751 751
                                 } else {
752 752
                                     $correct_test_link = Display::url(
753 753
                                         Display::return_icon('view_more_stats.gif', get_lang('ShowAllAttemptsByExercise')),
754
-                                        api_get_self() . '?action=stats&extend_attempt=1' . $my_url_suffix . '&session_id=' . $session_id . '&lp_item_id=' . $my_id
754
+                                        api_get_self().'?action=stats&extend_attempt=1'.$my_url_suffix.'&session_id='.$session_id.'&lp_item_id='.$my_id
755 755
                                     );
756 756
                                 }
757 757
                             }
@@ -761,14 +761,14 @@  discard block
 block discarded – undo
761 761
 
762 762
                         $action = null;
763 763
                         if ($type == 'classic') {
764
-                            $action =  '<td>' . $correct_test_link . '</td>';
764
+                            $action = '<td>'.$correct_test_link.'</td>';
765 765
                         }
766 766
 
767 767
                         if ($lp_id == $my_lp_id && false) {
768 768
 
769
-                            $output .= '<tr class =' . $oddclass . '>
770
-                                    <td>' . $extend_link . '</td>
771
-                                    <td colspan="4">' . $title . '</td>
769
+                            $output .= '<tr class ='.$oddclass.'>
770
+                                    <td>' . $extend_link.'</td>
771
+                                    <td colspan="4">' . $title.'</td>
772 772
                                     <td colspan="2">&nbsp;</td>
773 773
                                     <td colspan="2">&nbsp;</td>
774 774
                                     <td colspan="2">&nbsp;</td>
@@ -793,13 +793,13 @@  discard block
 block discarded – undo
793 793
                                     $scoreItem .= ExerciseLib::show_score($score, $maxscore, false);
794 794
                                 }
795 795
                             } else {
796
-                                $scoreItem .= $score == 0 ? '/' : ($maxscore == 0 ? $score : $score . '/' . $maxscore);
796
+                                $scoreItem .= $score == 0 ? '/' : ($maxscore == 0 ? $score : $score.'/'.$maxscore);
797 797
                             }
798 798
 
799 799
                             $output .= '
800 800
                                 <td>'.$extend_link.'</td>
801
-                                <td colspan="4">' . $title . '</td>
802
-                                <td colspan="2">' . learnpathitem::humanize_status($lesson_status) .'</td>
801
+                                <td colspan="4">' . $title.'</td>
802
+                                <td colspan="2">' . learnpathitem::humanize_status($lesson_status).'</td>
803 803
                                 <td colspan="2">'.$scoreItem.'</td>
804 804
                                 <td colspan="2">'.$time.'</td>
805 805
                                 '.$action.'
@@ -816,10 +816,10 @@  discard block
 block discarded – undo
816 816
                                 if (!$is_allowed_to_edit && $result_disabled_ext_all) {
817 817
                                     $temp[] = '/';
818 818
                                 } else {
819
-                                    $temp[] = ($score == 0 ? '0/' . $maxscore : ($maxscore == 0 ? $score : $score . '/' . float_format($maxscore, 1)));
819
+                                    $temp[] = ($score == 0 ? '0/'.$maxscore : ($maxscore == 0 ? $score : $score.'/'.float_format($maxscore, 1)));
820 820
                                 }
821 821
                             } else {
822
-                                $temp[] = ($score == 0 ? '/' : ($maxscore == 0 ? $score : $score . '/' . float_format($maxscore, 1)));
822
+                                $temp[] = ($score == 0 ? '/' : ($maxscore == 0 ? $score : $score.'/'.float_format($maxscore, 1)));
823 823
                             }
824 824
                             $temp[] = $time;
825 825
                             $csv_content[] = $temp;
@@ -830,7 +830,7 @@  discard block
 block discarded – undo
830 830
 
831 831
                     $action = null;
832 832
                     if ($type == 'classic') {
833
-                        $action =  '<td></td>';
833
+                        $action = '<td></td>';
834 834
                     }
835 835
 
836 836
                     if ($extend_this_attempt || $extend_all) {
@@ -867,11 +867,11 @@  discard block
 block discarded – undo
867 867
                                     <td></td>
868 868
                                     <td></td>
869 869
                                     <td></td>
870
-                                    <td>' . $interaction['order_id'] . '</td>
871
-                                    <td colspan="2">'.$interaction['objective_id'] . '</td>
872
-                                    <td colspan="2">' . $interaction['status'] . '</td>
870
+                                    <td>' . $interaction['order_id'].'</td>
871
+                                    <td colspan="2">'.$interaction['objective_id'].'</td>
872
+                                    <td colspan="2">' . $interaction['status'].'</td>
873 873
                                     <td>' . $interaction['score_raw'].'</td>
874
-                                    <td>' . $interaction['score_max'] .'</td>
874
+                                    <td>' . $interaction['score_max'].'</td>
875 875
                                     <td>' . $interaction['score_min'].'</td>
876 876
                                     '.$action.'
877 877
                                </tr>';
@@ -880,7 +880,7 @@  discard block
 block discarded – undo
880 880
                     }
881 881
 
882 882
                     // Attempts listing by exercise.
883
-                    if ($lp_id == $my_lp_id && $lp_item_id== $my_id && $extendedAttempt) {
883
+                    if ($lp_id == $my_lp_id && $lp_item_id == $my_id && $extendedAttempt) {
884 884
                         // Get attempts of a exercise.
885 885
                         if (!empty($lp_id) &&
886 886
                             !empty($lp_item_id) &&
@@ -895,15 +895,15 @@  discard block
 block discarded – undo
895 895
                             $row_path = Database::fetch_array($res_path);
896 896
 
897 897
                             if (Database::num_rows($res_path) > 0) {
898
-                                $sql = 'SELECT * FROM ' . $tbl_stats_exercices . '
898
+                                $sql = 'SELECT * FROM '.$tbl_stats_exercices.'
899 899
                                         WHERE
900
-                                            exe_exo_id="' . (int) $row_path['path'] . '" AND
900
+                                            exe_exo_id="' . (int) $row_path['path'].'" AND
901 901
                                             status <> "incomplete" AND
902
-                                            exe_user_id="' . $user_id . '" AND
903
-                                            orig_lp_id = "' . (int) $lp_id . '" AND
904
-                                            orig_lp_item_id = "' . (int) $lp_item_id . '" AND
905
-                                            c_id = ' . $course_id . '  AND
906
-                                            session_id = ' . $session_id . '
902
+                                            exe_user_id="' . $user_id.'" AND
903
+                                            orig_lp_id = "' . (int) $lp_id.'" AND
904
+                                            orig_lp_item_id = "' . (int) $lp_item_id.'" AND
905
+                                            c_id = ' . $course_id.'  AND
906
+                                            session_id = ' . $session_id.'
907 907
                                         ORDER BY exe_date';
908 908
                                 $res_attempts = Database::query($sql);
909 909
                                 $num_attempts = Database::num_rows($res_attempts);
@@ -921,7 +921,7 @@  discard block
 block discarded – undo
921 921
                                         if ($mktime_start_date && $mktime_exe_date) {
922 922
                                             $mytime = ((int) $mktime_exe_date - (int) $mktime_start_date);
923 923
                                             $time_attemp = learnpathItem :: getScormTimeFromParameter('js', $mytime);
924
-                                            $time_attemp = str_replace('NaN', '00' . $h . '00\'00"', $time_attemp);
924
+                                            $time_attemp = str_replace('NaN', '00'.$h.'00\'00"', $time_attemp);
925 925
                                         } else {
926 926
                                             $time_attemp = ' - ';
927 927
                                         }
@@ -947,33 +947,33 @@  discard block
 block discarded – undo
947 947
                                             $my_lesson_status = learnpathitem::humanize_status('incomplete');
948 948
                                         }
949 949
 
950
-                                        $output .= '<tr class="' . $oddclass . '" >
950
+                                        $output .= '<tr class="'.$oddclass.'" >
951 951
                                         <td></td>
952
-                                        <td>' . $extend_attempt_link . '</td>
953
-                                        <td colspan="3">' . get_lang('Attempt').' '. $n.'</td>
954
-                                        <td colspan="2">' . $my_lesson_status . '</td>
955
-                                        <td colspan="2">'.$view_score . '</td>
956
-                                        <td colspan="2">'.$time_attemp . '</td>';
952
+                                        <td>' . $extend_attempt_link.'</td>
953
+                                        <td colspan="3">' . get_lang('Attempt').' '.$n.'</td>
954
+                                        <td colspan="2">' . $my_lesson_status.'</td>
955
+                                        <td colspan="2">'.$view_score.'</td>
956
+                                        <td colspan="2">'.$time_attemp.'</td>';
957 957
                                         if ($action == 'classic') {
958 958
                                             if ($origin != 'tracking') {
959 959
                                                 if (!$is_allowed_to_edit && $result_disabled_ext_all) {
960 960
                                                     $output .= '<td>
961
-                                                            <img src="' . Display::returnIconPath('quiz_na.gif').'" alt="' . get_lang('ShowAttempt') . '" title="' . get_lang('ShowAttempt') . '">
961
+                                                            <img src="' . Display::returnIconPath('quiz_na.gif').'" alt="'.get_lang('ShowAttempt').'" title="'.get_lang('ShowAttempt').'">
962 962
                                                             </td>';
963 963
                                                 } else {
964 964
                                                     $output .= '<td>
965
-                                                            <a href="../exercise/exercise_show.php?origin=' . $origin . '&id=' . $my_exe_id . '&cidReq=' . $courseCode . '" target="_parent">
966
-                                                            <img src="' . Display::returnIconPath('quiz.gif').'" alt="' . get_lang('ShowAttempt') . '" title="' . get_lang('ShowAttempt') . '">
965
+                                                            <a href="../exercise/exercise_show.php?origin=' . $origin.'&id='.$my_exe_id.'&cidReq='.$courseCode.'" target="_parent">
966
+                                                            <img src="' . Display::returnIconPath('quiz.gif').'" alt="'.get_lang('ShowAttempt').'" title="'.get_lang('ShowAttempt').'">
967 967
                                                             </a></td>';
968 968
                                                 }
969 969
                                             } else {
970 970
                                                 if (!$is_allowed_to_edit && $result_disabled_ext_all) {
971 971
                                                     $output .= '<td>
972
-                                                                <img src="' . Display::returnIconPath('quiz_na.gif').'" alt="' . get_lang('ShowAndQualifyAttempt') . '" title="' . get_lang('ShowAndQualifyAttempt') . '"></td>';
972
+                                                                <img src="' . Display::returnIconPath('quiz_na.gif').'" alt="'.get_lang('ShowAndQualifyAttempt').'" title="'.get_lang('ShowAndQualifyAttempt').'"></td>';
973 973
                                                 } else {
974 974
                                                     $output .= '<td>
975
-                                                                    <a href="../exercise/exercise_show.php?cidReq=' . $courseCode . '&origin=correct_exercise_in_lp&id=' . $my_exe_id . '" target="_parent">
976
-                                                                    <img src="' . Display::returnIconPath('quiz.gif').'" alt="' . get_lang('ShowAndQualifyAttempt') . '" title="' . get_lang('ShowAndQualifyAttempt') . '"></a></td>';
975
+                                                                    <a href="../exercise/exercise_show.php?cidReq=' . $courseCode.'&origin=correct_exercise_in_lp&id='.$my_exe_id.'" target="_parent">
976
+                                                                    <img src="' . Display::returnIconPath('quiz.gif').'" alt="'.get_lang('ShowAndQualifyAttempt').'" title="'.get_lang('ShowAndQualifyAttempt').'"></a></td>';
977 977
                                                 }
978 978
                                             }
979 979
                                         }
@@ -1032,13 +1032,13 @@  discard block
 block discarded – undo
1032 1032
         }
1033 1033
 
1034 1034
         $total_time = learnpathItem::getScormTimeFromParameter('js', $total_time);
1035
-        $total_time = str_replace('NaN', '00' . $h . '00\'00"', $total_time);
1035
+        $total_time = str_replace('NaN', '00'.$h.'00\'00"', $total_time);
1036 1036
 
1037 1037
         if (!$is_allowed_to_edit && $result_disabled_ext_all) {
1038 1038
             $final_score = Display::return_icon('invisible.gif', get_lang('ResultsHiddenByExerciseSetting'));
1039 1039
         } else {
1040 1040
             if (is_numeric($total_score)) {
1041
-                $final_score = $total_score . '%';
1041
+                $final_score = $total_score.'%';
1042 1042
             } else {
1043 1043
                 $final_score = $total_score;
1044 1044
             }
@@ -1054,19 +1054,19 @@  discard block
 block discarded – undo
1054 1054
 
1055 1055
         $action = null;
1056 1056
         if ($type == 'classic') {
1057
-            $action =  '<td></td>';
1057
+            $action = '<td></td>';
1058 1058
         }
1059 1059
 
1060 1060
         $output .= '<tr class="'.$oddclass.'">
1061 1061
                 <td></td>
1062 1062
                 <td colspan="4">
1063
-                    <i>' . get_lang('AccomplishedStepsTotal') .'</i>
1063
+                    <i>' . get_lang('AccomplishedStepsTotal').'</i>
1064 1064
                 </td>
1065 1065
                 <td colspan="2">'.$progress.'%</td>
1066 1066
                 <td colspan="2">
1067 1067
                     ' . $final_score.'
1068 1068
                 </td>
1069
-                <td colspan="2">' . $total_time . '</div>
1069
+                <td colspan="2">' . $total_time.'</div>
1070 1070
                 '.$action.'
1071 1071
            </tr>';
1072 1072
 
@@ -1410,7 +1410,7 @@  discard block
 block discarded – undo
1410 1410
     	$tbl_track_course = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1411 1411
     	if (is_array($user_id)) {
1412 1412
     	    $user_id = array_map('intval', $user_id);
1413
-    		$condition_user = " AND user_id IN (".implode(',',$user_id).") ";
1413
+    		$condition_user = " AND user_id IN (".implode(',', $user_id).") ";
1414 1414
     	} else {
1415 1415
     		$user_id = intval($user_id);
1416 1416
     		$condition_user = " AND user_id = $user_id ";
@@ -1446,13 +1446,13 @@  discard block
 block discarded – undo
1446 1446
     {
1447 1447
     	$tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
1448 1448
     	$sql = 'SELECT login_date
1449
-    	        FROM ' . $tbl_track_login . '
1450
-                WHERE login_user_id = ' . intval($student_id) . '
1449
+    	        FROM ' . $tbl_track_login.'
1450
+                WHERE login_user_id = ' . intval($student_id).'
1451 1451
                 ORDER BY login_date ASC
1452 1452
                 LIMIT 0,1';
1453 1453
 
1454 1454
     	$rs = Database::query($sql);
1455
-    	if (Database::num_rows($rs)>0) {
1455
+    	if (Database::num_rows($rs) > 0) {
1456 1456
     		if ($first_login_date = Database::result($rs, 0, 0)) {
1457 1457
                 return api_convert_and_format_date(
1458 1458
                     $first_login_date,
@@ -1477,8 +1477,8 @@  discard block
 block discarded – undo
1477 1477
     {
1478 1478
     	$table = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
1479 1479
     	$sql = 'SELECT login_date
1480
-    	        FROM ' . $table . '
1481
-                WHERE login_user_id = ' . intval($student_id) . '
1480
+    	        FROM ' . $table.'
1481
+                WHERE login_user_id = ' . intval($student_id).'
1482 1482
                 ORDER BY login_date
1483 1483
                 DESC LIMIT 0,1';
1484 1484
 
@@ -1487,18 +1487,18 @@  discard block
 block discarded – undo
1487 1487
     		if ($last_login_date = Database::result($rs, 0, 0)) {
1488 1488
     			$last_login_date = api_get_local_time($last_login_date);
1489 1489
     			if ($return_timestamp) {
1490
-    				return api_strtotime($last_login_date,'UTC');
1490
+    				return api_strtotime($last_login_date, 'UTC');
1491 1491
     			} else {
1492 1492
     				if (!$warning_message) {
1493 1493
     					return api_format_date($last_login_date, DATE_FORMAT_SHORT);
1494 1494
     				} else {
1495
-    					$timestamp = api_strtotime($last_login_date,'UTC');
1495
+    					$timestamp = api_strtotime($last_login_date, 'UTC');
1496 1496
     					$currentTimestamp = time();
1497 1497
 
1498 1498
     					//If the last connection is > than 7 days, the text is red
1499 1499
     					//345600 = 7 days in seconds
1500 1500
     					if ($currentTimestamp - $timestamp > 604800) {
1501
-    						return '<span style="color: #F00;">' . api_format_date($last_login_date, DATE_FORMAT_SHORT) . '</span>';
1501
+    						return '<span style="color: #F00;">'.api_format_date($last_login_date, DATE_FORMAT_SHORT).'</span>';
1502 1502
     					} else {
1503 1503
     						return api_format_date($last_login_date, DATE_FORMAT_SHORT);
1504 1504
     					}
@@ -1533,7 +1533,7 @@  discard block
 block discarded – undo
1533 1533
         $sql = "$select
1534 1534
                 FROM $tbl_track_login
1535 1535
                 WHERE
1536
-                    login_user_id IN (' ". implode("','", $studentList) . "' ) AND
1536
+                    login_user_id IN (' ".implode("','", $studentList)."' ) AND
1537 1537
                     login_date < '$date'
1538 1538
                 ";
1539 1539
         $rs = Database::query($sql);
@@ -1632,7 +1632,7 @@  discard block
 block discarded – undo
1632 1632
                               '.Display::return_icon('messagebox_warning.gif').'
1633 1633
                              </a>'
1634 1634
                             : null;
1635
-    					return $icon. Display::label($last_login_date, 'warning');
1635
+    					return $icon.Display::label($last_login_date, 'warning');
1636 1636
     				} else {
1637 1637
     					return $last_login_date;
1638 1638
     				}
@@ -1667,8 +1667,8 @@  discard block
 block discarded – undo
1667 1667
 
1668 1668
         // Given we're storing in cache, round the start and end times
1669 1669
         // to the lower minute
1670
-        $roundedStart = substr($start, 0, -2) . '00';
1671
-        $roundedStop = substr($stop, 0, -2) . '00';
1670
+        $roundedStart = substr($start, 0, -2).'00';
1671
+        $roundedStop = substr($stop, 0, -2).'00';
1672 1672
         $roundedStart = Database::escape_string($roundedStart);
1673 1673
         $roundedStop = Database::escape_string($roundedStop);
1674 1674
 
@@ -1678,7 +1678,7 @@  discard block
 block discarded – undo
1678 1678
     	$session_id  = intval($session_id);
1679 1679
     	$count = 0;
1680 1680
         $tbl_track_e_course_access = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1681
-        $sql =  "SELECT count(*) as count_connections
1681
+        $sql = "SELECT count(*) as count_connections
1682 1682
                 FROM $tbl_track_e_course_access
1683 1683
                 WHERE
1684 1684
                     c_id = $courseId AND
@@ -1700,7 +1700,7 @@  discard block
 block discarded – undo
1700 1700
                 $count = apcu_fetch($apc_var);
1701 1701
             } else {
1702 1702
                 $rs = Database::query($sql);
1703
-                if (Database::num_rows($rs)>0) {
1703
+                if (Database::num_rows($rs) > 0) {
1704 1704
                     $row = Database::fetch_object($rs);
1705 1705
                     $count = $row->count_connections;
1706 1706
                 }
@@ -1709,7 +1709,7 @@  discard block
 block discarded – undo
1709 1709
             }
1710 1710
         } else {
1711 1711
             $rs = Database::query($sql);
1712
-            if (Database::num_rows($rs)>0) {
1712
+            if (Database::num_rows($rs) > 0) {
1713 1713
                 $row = Database::fetch_object($rs);
1714 1714
                 $count = $row->count_connections;
1715 1715
             }
@@ -1731,14 +1731,14 @@  discard block
 block discarded – undo
1731 1731
     	$tbl_session_course_rel_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
1732 1732
 
1733 1733
     	$sql = 'SELECT DISTINCT c_id
1734
-                FROM ' . $tbl_course_rel_user . '
1734
+                FROM ' . $tbl_course_rel_user.'
1735 1735
                 WHERE user_id = ' . $user_id.' AND relation_type<>'.COURSE_RELATION_TYPE_RRHH;
1736 1736
     	$rs = Database::query($sql);
1737 1737
     	$nb_courses = Database::num_rows($rs);
1738 1738
 
1739 1739
     	if ($include_sessions) {
1740 1740
     		$sql = 'SELECT DISTINCT c_id
1741
-                    FROM ' . $tbl_session_course_rel_user . '
1741
+                    FROM ' . $tbl_session_course_rel_user.'
1742 1742
                     WHERE user_id = ' . $user_id;
1743 1743
     		$rs = Database::query($sql);
1744 1744
     		$nb_courses += Database::num_rows($rs);
@@ -1785,7 +1785,7 @@  discard block
 block discarded – undo
1785 1785
     		$condition_quiz = "";
1786 1786
     		if (!empty($exercise_id)) {
1787 1787
     			$exercise_id = intval($exercise_id);
1788
-    			$condition_quiz =" AND id = $exercise_id ";
1788
+    			$condition_quiz = " AND id = $exercise_id ";
1789 1789
     		}
1790 1790
 
1791 1791
     		// Compose a filter based on optional session id given
@@ -1838,7 +1838,7 @@  discard block
 block discarded – undo
1838 1838
                         }
1839 1839
                     }
1840 1840
                     if (!empty($exercise_list)) {
1841
-                        $exercise_id = implode("','",$exercise_list);
1841
+                        $exercise_id = implode("','", $exercise_list);
1842 1842
                     }
1843 1843
     			}
1844 1844
 
@@ -1863,10 +1863,10 @@  discard block
 block discarded – undo
1863 1863
     			$quiz_avg_score = null;
1864 1864
 
1865 1865
     			if (!empty($row['avg_score'])) {
1866
-    				$quiz_avg_score = round($row['avg_score'],2);
1866
+    				$quiz_avg_score = round($row['avg_score'], 2);
1867 1867
     			}
1868 1868
 
1869
-    			if(!empty($row['num_attempts'])) {
1869
+    			if (!empty($row['num_attempts'])) {
1870 1870
     				$quiz_avg_score = round($quiz_avg_score / $row['num_attempts'], 2);
1871 1871
     			}
1872 1872
     			if (is_array($student_id)) {
@@ -1996,7 +1996,7 @@  discard block
 block discarded – undo
1996 1996
             $row = Database::fetch_row($rs);
1997 1997
             $count = $row[0];
1998 1998
         }
1999
-        $count = ($count != 0 ) ? 100*round(intval($count)/count($exercise_list), 2) .'%' : '0%';
1999
+        $count = ($count != 0) ? 100 * round(intval($count) / count($exercise_list), 2).'%' : '0%';
2000 2000
         return $count;
2001 2001
     }
2002 2002
 
@@ -2021,7 +2021,7 @@  discard block
 block discarded – undo
2021 2021
                 );
2022 2022
 
2023 2023
                 if (!empty($best_attempt) && !empty($best_attempt['exe_weighting'])) {
2024
-                    $result += $best_attempt['exe_result']/$best_attempt['exe_weighting'];
2024
+                    $result += $best_attempt['exe_result'] / $best_attempt['exe_weighting'];
2025 2025
                 }
2026 2026
             }
2027 2027
             $result = $result / count($exercise_list);
@@ -2058,7 +2058,7 @@  discard block
 block discarded – undo
2058 2058
         $query = sprintf($sql, intval($courseId), $sessionId);
2059 2059
         $rs = Database::query($query);
2060 2060
         $teachers = array();
2061
-        while ($teacher = Database::fetch_array($rs,'ASSOC')) {
2061
+        while ($teacher = Database::fetch_array($rs, 'ASSOC')) {
2062 2062
             $teachers[] = $teacher;
2063 2063
         }
2064 2064
         $data = array();
@@ -2182,7 +2182,7 @@  discard block
 block discarded – undo
2182 2182
             $data[] = array(
2183 2183
                 'course' => $course['title'],
2184 2184
                 'session' => $teacher['name'],
2185
-                'tutor' => $tutor['username'] . ' - ' . $tutor['lastname'] . ' ' . $tutor['firstname'],
2185
+                'tutor' => $tutor['username'].' - '.$tutor['lastname'].' '.$tutor['firstname'],
2186 2186
                 'documents' => $totalDocuments,
2187 2187
                 'links' => $totalLinks,
2188 2188
                 'forums' => $totalForums,
@@ -2245,7 +2245,7 @@  discard block
 block discarded – undo
2245 2245
             for ($i = 0; $i < count($lpIdList); $i++) {
2246 2246
                 $placeHolders[] = '?';
2247 2247
             }
2248
-            $lpConditions['AND id IN(' . implode(', ', $placeHolders) . ') '] = $lpIdList;
2248
+            $lpConditions['AND id IN('.implode(', ', $placeHolders).') '] = $lpIdList;
2249 2249
         }
2250 2250
 
2251 2251
         if ($onlySeriousGame) {
@@ -2265,14 +2265,14 @@  discard block
 block discarded – undo
2265 2265
 
2266 2266
         $conditions = [
2267 2267
             " c_id = {$courseInfo['real_id']} ",
2268
-            " lp_view.lp_id IN(" . implode(', ', $filteredLP) . ") "
2268
+            " lp_view.lp_id IN(".implode(', ', $filteredLP).") "
2269 2269
         ];
2270 2270
 
2271 2271
         $groupBy = 'GROUP BY lp_id';
2272 2272
 
2273 2273
         if (is_array($studentId)) {
2274 2274
             $studentId = array_map('intval', $studentId);
2275
-            $conditions[] = " lp_view.user_id IN (" . implode(',', $studentId) . ")  ";
2275
+            $conditions[] = " lp_view.user_id IN (".implode(',', $studentId).")  ";
2276 2276
 
2277 2277
 
2278 2278
         } else {
@@ -2407,7 +2407,7 @@  discard block
 block discarded – undo
2407 2407
             // Compose a filter based on optional learning paths list given
2408 2408
             $condition_lp = "";
2409 2409
             if (count($lp_ids) > 0) {
2410
-                $condition_lp =" AND id IN(".implode(',',$lp_ids).") ";
2410
+                $condition_lp = " AND id IN(".implode(',', $lp_ids).") ";
2411 2411
             }
2412 2412
 
2413 2413
             // Compose a filter based on optional session id
@@ -2447,9 +2447,9 @@  discard block
 block discarded – undo
2447 2447
             // prepare filter on users
2448 2448
             if (is_array($student_id)) {
2449 2449
                 array_walk($student_id, 'intval');
2450
-                $condition_user1 =" AND user_id IN (".implode(',', $student_id).") ";
2450
+                $condition_user1 = " AND user_id IN (".implode(',', $student_id).") ";
2451 2451
             } else {
2452
-                $condition_user1 =" AND user_id = $student_id ";
2452
+                $condition_user1 = " AND user_id = $student_id ";
2453 2453
             }
2454 2454
 
2455 2455
             if ($count_row_lp > 0 && !empty($student_id)) {
@@ -2492,7 +2492,7 @@  discard block
 block discarded – undo
2492 2492
                                     ORDER BY lp_item_id";
2493 2493
                             $res_lp_item = Database::query($sql);
2494 2494
 
2495
-                            while ($row_lp_item = Database::fetch_array($res_lp_item,'ASSOC')) {
2495
+                            while ($row_lp_item = Database::fetch_array($res_lp_item, 'ASSOC')) {
2496 2496
                                 $my_lp_item_id = $row_lp_item['lp_item_id'];
2497 2497
 
2498 2498
                                 // Getting the most recent attempt
@@ -2515,8 +2515,8 @@  discard block
 block discarded – undo
2515 2515
                                         ORDER BY view_count DESC
2516 2516
                                         LIMIT 1";
2517 2517
                                 $res_lp_item_result = Database::query($sql);
2518
-                                while ($row_max_score = Database::fetch_array($res_lp_item_result,'ASSOC')) {
2519
-                                    $list[]= $row_max_score;
2518
+                                while ($row_max_score = Database::fetch_array($res_lp_item_result, 'ASSOC')) {
2519
+                                    $list[] = $row_max_score;
2520 2520
                                 }
2521 2521
                             }
2522 2522
                         } else {
@@ -2540,8 +2540,8 @@  discard block
 block discarded – undo
2540 2540
                             if ($debug) echo $sql.'<br />';
2541 2541
                             $res_max_score = Database::query($sql);
2542 2542
 
2543
-                            while ($row_max_score = Database::fetch_array($res_max_score,'ASSOC')) {
2544
-                                $list[]= $row_max_score;
2543
+                            while ($row_max_score = Database::fetch_array($res_max_score, 'ASSOC')) {
2544
+                                $list[] = $row_max_score;
2545 2545
                             }
2546 2546
                         }
2547 2547
 
@@ -2556,7 +2556,7 @@  discard block
 block discarded – undo
2556 2556
                             $max_score_item_view = $row_max_score['max_score_item_view'];
2557 2557
                             $score = $row_max_score['score'];
2558 2558
 
2559
-                            if ($debug) echo '<h3>Item Type: ' .$row_max_score['item_type'].'</h3>';
2559
+                            if ($debug) echo '<h3>Item Type: '.$row_max_score['item_type'].'</h3>';
2560 2560
 
2561 2561
                             if ($row_max_score['item_type'] == 'sco') {
2562 2562
                                 /* Check if it is sco (easier to get max_score)
@@ -2574,7 +2574,7 @@  discard block
 block discarded – undo
2574 2574
                                 }
2575 2575
                                 // Avoid division by zero errors
2576 2576
                                 if (!empty($max_score)) {
2577
-                                    $lp_partial_total += $score/$max_score;
2577
+                                    $lp_partial_total += $score / $max_score;
2578 2578
                                 }
2579 2579
                                 if ($debug) echo '<b>$lp_partial_total, $score, $max_score '.$lp_partial_total.' '.$score.' '.$max_score.'</b><br />';
2580 2580
                             } else {
@@ -2598,10 +2598,10 @@  discard block
 block discarded – undo
2598 2598
                                         ORDER BY exe_date DESC
2599 2599
                                         LIMIT 1";
2600 2600
 
2601
-                                if ($debug) echo $sql .'<br />';
2601
+                                if ($debug) echo $sql.'<br />';
2602 2602
                                 $result_last_attempt = Database::query($sql);
2603 2603
                                 $num = Database :: num_rows($result_last_attempt);
2604
-                                if ($num > 0 ) {
2604
+                                if ($num > 0) {
2605 2605
                                     $id_last_attempt = Database :: result($result_last_attempt, 0, 0);
2606 2606
                                     if ($debug) echo $id_last_attempt.'<br />';
2607 2607
 
@@ -2630,13 +2630,13 @@  discard block
 block discarded – undo
2630 2630
                                         $max_score = $row_max_score_bis['maxscore'];
2631 2631
                                     }
2632 2632
                                     if (!empty($max_score) && floatval($max_score) > 0) {
2633
-                                        $lp_partial_total += $score/$max_score;
2633
+                                        $lp_partial_total += $score / $max_score;
2634 2634
                                     }
2635 2635
                                     if ($debug) echo '$lp_partial_total, $score, $max_score <b>'.$lp_partial_total.' '.$score.' '.$max_score.'</b><br />';
2636 2636
                                 }
2637 2637
                             }
2638 2638
 
2639
-                            if (in_array($row_max_score['item_type'], array('quiz','sco'))) {
2639
+                            if (in_array($row_max_score['item_type'], array('quiz', 'sco'))) {
2640 2640
                                 // Normal way
2641 2641
                                 if ($use_max_score[$lp_id]) {
2642 2642
                                     $count_items++;
@@ -2671,8 +2671,8 @@  discard block
 block discarded – undo
2671 2671
                     if ($debug) echo $sql;
2672 2672
                     $result_have_quiz = Database::query($sql);
2673 2673
 
2674
-                    if (Database::num_rows($result_have_quiz) > 0 ) {
2675
-                        $row = Database::fetch_array($result_have_quiz,'ASSOC');
2674
+                    if (Database::num_rows($result_have_quiz) > 0) {
2675
+                        $row = Database::fetch_array($result_have_quiz, 'ASSOC');
2676 2676
                         if (is_numeric($row['count']) && $row['count'] != 0) {
2677 2677
                             $lp_with_quiz++;
2678 2678
                         }
@@ -2684,7 +2684,7 @@  discard block
 block discarded – undo
2684 2684
 
2685 2685
                 if ($lp_with_quiz != 0) {
2686 2686
                     if (!$return_array) {
2687
-                        $score_of_scorm_calculate = round(($global_result/$lp_with_quiz),2);
2687
+                        $score_of_scorm_calculate = round(($global_result / $lp_with_quiz), 2);
2688 2688
                         if ($debug) var_dump($score_of_scorm_calculate);
2689 2689
                         if (empty($lp_ids)) {
2690 2690
                             if ($debug) echo '<h2>All lps fix: '.$score_of_scorm_calculate.'</h2>';
@@ -2758,9 +2758,9 @@  discard block
 block discarded – undo
2758 2758
 
2759 2759
         if (is_array($student_id)) {
2760 2760
             array_walk($student_id, 'intval');
2761
-            $conditions[] =" lp_view.user_id IN (".implode(',', $student_id).") ";
2761
+            $conditions[] = " lp_view.user_id IN (".implode(',', $student_id).") ";
2762 2762
         } else {
2763
-            $conditions[] =" lp_view.user_id = $student_id ";
2763
+            $conditions[] = " lp_view.user_id = $student_id ";
2764 2764
         }
2765 2765
 
2766 2766
         $conditionsToString = implode('AND ', $conditions);
@@ -2814,7 +2814,7 @@  discard block
 block discarded – undo
2814 2814
             // Compose a filter based on optional learning paths list given
2815 2815
             $condition_lp = "";
2816 2816
             if (count($lp_ids) > 0) {
2817
-                $condition_lp =" AND id IN(".implode(',',$lp_ids).") ";
2817
+                $condition_lp = " AND id IN(".implode(',', $lp_ids).") ";
2818 2818
             }
2819 2819
 
2820 2820
             // Compose a filter based on optional session id
@@ -2876,7 +2876,7 @@  discard block
 block discarded – undo
2876 2876
 
2877 2877
         if (!empty($course)) {
2878 2878
 
2879
-            $course_id	 = $course['real_id'];
2879
+            $course_id = $course['real_id'];
2880 2880
 
2881 2881
             $lp_table    = Database :: get_course_table(TABLE_LP_MAIN);
2882 2882
             $t_lpv       = Database :: get_course_table(TABLE_LP_VIEW);
@@ -2890,8 +2890,8 @@  discard block
 block discarded – undo
2890 2890
             // calculates last connection time
2891 2891
             if ($count_row_lp > 0) {
2892 2892
                 $sql = 'SELECT MAX(start_time)
2893
-                        FROM ' . $t_lpiv . ' AS item_view
2894
-                        INNER JOIN ' . $t_lpv . ' AS view
2893
+                        FROM ' . $t_lpiv.' AS item_view
2894
+                        INNER JOIN ' . $t_lpv.' AS view
2895 2895
                             ON item_view.lp_view_id = view.id
2896 2896
                         WHERE
2897 2897
                             item_view.c_id 		= '.$course_id.' AND
@@ -2927,15 +2927,15 @@  discard block
 block discarded – undo
2927 2927
 
2928 2928
         // At first, courses where $coach_id is coach of the course //
2929 2929
         $sql = 'SELECT session_id, c_id
2930
-                FROM ' . $tbl_session_course_user . '
2930
+                FROM ' . $tbl_session_course_user.'
2931 2931
                 WHERE user_id=' . $coach_id.' AND status=2';
2932 2932
 
2933 2933
         if (api_is_multiple_url_enabled()) {
2934
-            $tbl_session_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
2934
+            $tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
2935 2935
             $access_url_id = api_get_current_access_url_id();
2936 2936
             if ($access_url_id != -1) {
2937 2937
                 $sql = 'SELECT scu.session_id, scu.c_id
2938
-                    FROM ' . $tbl_session_course_user . ' scu
2938
+                    FROM ' . $tbl_session_course_user.' scu
2939 2939
                     INNER JOIN '.$tbl_session_rel_access_url.'  sru
2940 2940
                     ON (scu.session_id=sru.session_id)
2941 2941
                     WHERE
@@ -2969,28 +2969,28 @@  discard block
 block discarded – undo
2969 2969
 
2970 2970
         // Then, courses where $coach_id is coach of the session    //
2971 2971
         $sql = 'SELECT session_course_user.user_id
2972
-                FROM ' . $tbl_session_course_user . ' as session_course_user
2972
+                FROM ' . $tbl_session_course_user.' as session_course_user
2973 2973
                 INNER JOIN     '.$tbl_session_user.' sru
2974 2974
                 ON session_course_user.user_id = sru.user_id AND session_course_user.session_id = sru.session_id
2975
-                INNER JOIN ' . $tbl_session_course . ' as session_course
2975
+                INNER JOIN ' . $tbl_session_course.' as session_course
2976 2976
                 ON session_course.c_id = session_course_user.c_id
2977 2977
                 AND session_course_user.session_id = session_course.session_id
2978
-                INNER JOIN ' . $tbl_session . ' as session
2978
+                INNER JOIN ' . $tbl_session.' as session
2979 2979
                 ON session.id = session_course.session_id
2980 2980
                 AND session.id_coach = ' . $coach_id;
2981 2981
         if (api_is_multiple_url_enabled()) {
2982
-            $tbl_session_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
2982
+            $tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
2983 2983
             $access_url_id = api_get_current_access_url_id();
2984
-            if ($access_url_id != -1){
2984
+            if ($access_url_id != -1) {
2985 2985
                 $sql = 'SELECT session_course_user.user_id
2986
-                        FROM ' . $tbl_session_course_user . ' as session_course_user
2986
+                        FROM ' . $tbl_session_course_user.' as session_course_user
2987 2987
                         INNER JOIN     '.$tbl_session_user.' sru
2988 2988
                             ON session_course_user.user_id = sru.user_id AND
2989 2989
                                session_course_user.session_id = sru.session_id
2990
-                        INNER JOIN ' . $tbl_session_course . ' as session_course
2990
+                        INNER JOIN ' . $tbl_session_course.' as session_course
2991 2991
                             ON session_course.c_id = session_course_user.c_id AND
2992 2992
                             session_course_user.session_id = session_course.session_id
2993
-                        INNER JOIN ' . $tbl_session . ' as session
2993
+                        INNER JOIN ' . $tbl_session.' as session
2994 2994
                             ON session.id = session_course.session_id AND
2995 2995
                             session.id_coach = ' . $coach_id.'
2996 2996
                         INNER JOIN '.$tbl_session_rel_access_url.' session_rel_url
@@ -3020,8 +3020,8 @@  discard block
 block discarded – undo
3020 3020
 
3021 3021
         $students = [];
3022 3022
         // At first, courses where $coach_id is coach of the course //
3023
-        $sql = 'SELECT c_id FROM ' . $tbl_session_course_user . '
3024
-                WHERE session_id="' . $id_session . '" AND user_id=' . $coach_id.' AND status=2';
3023
+        $sql = 'SELECT c_id FROM '.$tbl_session_course_user.'
3024
+                WHERE session_id="' . $id_session.'" AND user_id='.$coach_id.' AND status=2';
3025 3025
         $result = Database::query($sql);
3026 3026
 
3027 3027
         while ($a_courses = Database::fetch_array($result)) {
@@ -3031,7 +3031,7 @@  discard block
 block discarded – undo
3031 3031
                     FROM $tbl_session_course_user AS srcru
3032 3032
                     WHERE
3033 3033
                         c_id = '$courseId' AND
3034
-                        session_id = '" . $id_session . "'";
3034
+                        session_id = '".$id_session."'";
3035 3035
             $rs = Database::query($sql);
3036 3036
             while ($row = Database::fetch_array($rs)) {
3037 3037
                 $students[$row['user_id']] = $row['user_id'];
@@ -3039,15 +3039,15 @@  discard block
 block discarded – undo
3039 3039
         }
3040 3040
 
3041 3041
         // Then, courses where $coach_id is coach of the session
3042
-        $sql = 'SELECT id_coach FROM ' . $tbl_session . '
3043
-                WHERE id="' . $id_session.'" AND id_coach="' . $coach_id . '"';
3042
+        $sql = 'SELECT id_coach FROM '.$tbl_session.'
3043
+                WHERE id="' . $id_session.'" AND id_coach="'.$coach_id.'"';
3044 3044
         $result = Database::query($sql);
3045 3045
 
3046 3046
         //He is the session_coach so we select all the users in the session
3047 3047
         if (Database::num_rows($result) > 0) {
3048 3048
             $sql = 'SELECT DISTINCT srcru.user_id
3049
-                    FROM ' . $tbl_session_course_user . ' AS srcru
3050
-                    WHERE session_id="' . $id_session . '"';
3049
+                    FROM ' . $tbl_session_course_user.' AS srcru
3050
+                    WHERE session_id="' . $id_session.'"';
3051 3051
             $result = Database::query($sql);
3052 3052
             while ($row = Database::fetch_array($result)) {
3053 3053
                 $students[$row['user_id']] = $row['user_id'];
@@ -3074,8 +3074,8 @@  discard block
 block discarded – undo
3074 3074
 
3075 3075
         // At first, courses where $coach_id is coach of the course //
3076 3076
 
3077
-        $sql = 'SELECT 1 FROM ' . $tbl_session_course_user . '
3078
-                WHERE user_id=' . $coach_id .' AND status=2';
3077
+        $sql = 'SELECT 1 FROM '.$tbl_session_course_user.'
3078
+                WHERE user_id=' . $coach_id.' AND status=2';
3079 3079
         $result = Database::query($sql);
3080 3080
         if (Database::num_rows($result) > 0) {
3081 3081
             return true;
@@ -3083,12 +3083,12 @@  discard block
 block discarded – undo
3083 3083
 
3084 3084
         // Then, courses where $coach_id is coach of the session
3085 3085
         $sql = 'SELECT session_course_user.user_id
3086
-                FROM ' . $tbl_session_course_user . ' as session_course_user
3087
-                INNER JOIN ' . $tbl_session_course . ' as session_course
3086
+                FROM ' . $tbl_session_course_user.' as session_course_user
3087
+                INNER JOIN ' . $tbl_session_course.' as session_course
3088 3088
                     ON session_course.c_id = session_course_user.c_id
3089
-                INNER JOIN ' . $tbl_session . ' as session
3089
+                INNER JOIN ' . $tbl_session.' as session
3090 3090
                     ON session.id = session_course.session_id
3091
-                    AND session.id_coach = ' . $coach_id . '
3091
+                    AND session.id_coach = ' . $coach_id.'
3092 3092
                 WHERE user_id = ' . $student_id;
3093 3093
         $result = Database::query($sql);
3094 3094
         if (Database::num_rows($result) > 0) {
@@ -3120,16 +3120,16 @@  discard block
 block discarded – undo
3120 3120
         // At first, courses where $coach_id is coach of the course.
3121 3121
 
3122 3122
         $sql = 'SELECT DISTINCT c.code
3123
-                FROM ' . $tbl_session_course_user . ' sc
3123
+                FROM ' . $tbl_session_course_user.' sc
3124 3124
                 INNER JOIN '.$tbl_course.' c
3125 3125
                 ON (c.id = sc.c_id)
3126 3126
                 WHERE user_id = ' . $coach_id.' AND status = 2';
3127 3127
 
3128 3128
         if (api_is_multiple_url_enabled()) {
3129 3129
             $access_url_id = api_get_current_access_url_id();
3130
-            if ($access_url_id != -1){
3130
+            if ($access_url_id != -1) {
3131 3131
                 $sql = 'SELECT DISTINCT c.code
3132
-                        FROM ' . $tbl_session_course_user . ' scu
3132
+                        FROM ' . $tbl_session_course_user.' scu
3133 3133
                         INNER JOIN '.$tbl_course.' c
3134 3134
                         ON (c.code = scu.c_id)
3135 3135
                         INNER JOIN '.$tbl_course_rel_access_url.' cru
@@ -3142,7 +3142,7 @@  discard block
 block discarded – undo
3142 3142
         }
3143 3143
 
3144 3144
         if (!empty($id_session)) {
3145
-            $sql .= ' AND session_id=' . $id_session;
3145
+            $sql .= ' AND session_id='.$id_session;
3146 3146
         }
3147 3147
 
3148 3148
         $courseList = array();
@@ -3154,25 +3154,25 @@  discard block
 block discarded – undo
3154 3154
         // Then, courses where $coach_id is coach of the session
3155 3155
 
3156 3156
         $sql = 'SELECT DISTINCT course.code
3157
-                FROM ' . $tbl_session_course . ' as session_course
3158
-                INNER JOIN ' . $tbl_session . ' as session
3157
+                FROM ' . $tbl_session_course.' as session_course
3158
+                INNER JOIN ' . $tbl_session.' as session
3159 3159
                     ON session.id = session_course.session_id
3160
-                    AND session.id_coach = ' . $coach_id . '
3161
-                INNER JOIN ' . $tbl_course . ' as course
3160
+                    AND session.id_coach = ' . $coach_id.'
3161
+                INNER JOIN ' . $tbl_course.' as course
3162 3162
                     ON course.id = session_course.c_id';
3163 3163
 
3164 3164
         if (api_is_multiple_url_enabled()) {
3165 3165
             $tbl_course_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
3166 3166
             $access_url_id = api_get_current_access_url_id();
3167
-            if ($access_url_id != -1){
3167
+            if ($access_url_id != -1) {
3168 3168
                 $sql = 'SELECT DISTINCT c.code
3169
-                    FROM ' . $tbl_session_course . ' as session_course
3169
+                    FROM ' . $tbl_session_course.' as session_course
3170 3170
                     INNER JOIN '.$tbl_course.' c
3171 3171
                     ON (c.id = session_course.c_id)
3172
-                    INNER JOIN ' . $tbl_session . ' as session
3172
+                    INNER JOIN ' . $tbl_session.' as session
3173 3173
                     ON session.id = session_course.session_id
3174
-                        AND session.id_coach = ' . $coach_id . '
3175
-                    INNER JOIN ' . $tbl_course . ' as course
3174
+                        AND session.id_coach = ' . $coach_id.'
3175
+                    INNER JOIN ' . $tbl_course.' as course
3176 3176
                         ON course.id = session_course.c_id
3177 3177
                      INNER JOIN '.$tbl_course_rel_access_url.' course_rel_url
3178 3178
                     ON (course_rel_url.c_id = c.id)';
@@ -3180,12 +3180,12 @@  discard block
 block discarded – undo
3180 3180
         }
3181 3181
 
3182 3182
         if (!empty ($id_session)) {
3183
-            $sql .= ' WHERE session_course.session_id=' . $id_session;
3183
+            $sql .= ' WHERE session_course.session_id='.$id_session;
3184 3184
             if (api_is_multiple_url_enabled())
3185
-            $sql .=  ' AND access_url_id = '.$access_url_id;
3186
-        }  else {
3185
+            $sql .= ' AND access_url_id = '.$access_url_id;
3186
+        } else {
3187 3187
             if (api_is_multiple_url_enabled())
3188
-            $sql .=  ' WHERE access_url_id = '.$access_url_id;
3188
+            $sql .= ' WHERE access_url_id = '.$access_url_id;
3189 3189
         }
3190 3190
 
3191 3191
         $result = Database::query($sql);
@@ -3241,7 +3241,7 @@  discard block
 block discarded – undo
3241 3241
             }
3242 3242
         }
3243 3243
 
3244
-        $tbl_session_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
3244
+        $tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
3245 3245
         $access_url_id = api_get_current_access_url_id();
3246 3246
 
3247 3247
         $sql = "
@@ -3365,7 +3365,7 @@  discard block
 block discarded – undo
3365 3365
             // table definition
3366 3366
             $tbl_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
3367 3367
             $tbl_document = Database :: get_course_table(TABLE_DOCUMENT);
3368
-            $course_id	 = $a_course['real_id'];
3368
+            $course_id = $a_course['real_id'];
3369 3369
             if (is_array($student_id)) {
3370 3370
                 $studentList = array_map('intval', $student_id);
3371 3371
                 $condition_user = " AND ip.insert_user_id IN ('".implode(',', $studentList)."') ";
@@ -3418,7 +3418,7 @@  discard block
 block discarded – undo
3418 3418
         $a_course = CourseManager::get_course_information($course_code);
3419 3419
         if (!empty($a_course)) {
3420 3420
             $course_id = $a_course['real_id'];
3421
-            $conditions[]= " ip.c_id  = $course_id AND pub.c_id  = $course_id ";
3421
+            $conditions[] = " ip.c_id  = $course_id AND pub.c_id  = $course_id ";
3422 3422
         }
3423 3423
 
3424 3424
         // table definition
@@ -3427,14 +3427,14 @@  discard block
 block discarded – undo
3427 3427
 
3428 3428
         if (is_array($student_id)) {
3429 3429
             $studentList = array_map('intval', $student_id);
3430
-            $conditions[]= " ip.insert_user_id IN ('".implode("','", $studentList)."') ";
3430
+            $conditions[] = " ip.insert_user_id IN ('".implode("','", $studentList)."') ";
3431 3431
         } else {
3432 3432
             $student_id = intval($student_id);
3433
-            $conditions[]= " ip.insert_user_id = '$student_id' ";
3433
+            $conditions[] = " ip.insert_user_id = '$student_id' ";
3434 3434
         }
3435 3435
         if (isset($session_id)) {
3436 3436
             $session_id = intval($session_id);
3437
-            $conditions[]= " pub.session_id = $session_id ";
3437
+            $conditions[] = " pub.session_id = $session_id ";
3438 3438
         }
3439 3439
         $conditionToString = implode('AND', $conditions);
3440 3440
 
@@ -3471,10 +3471,10 @@  discard block
 block discarded – undo
3471 3471
         $conditions = array();
3472 3472
         if (is_array($student_id)) {
3473 3473
             $studentList = array_map('intval', $student_id);
3474
-            $conditions[]= " post.poster_id IN ('".implode("','", $studentList)."') ";
3474
+            $conditions[] = " post.poster_id IN ('".implode("','", $studentList)."') ";
3475 3475
         } else {
3476 3476
             $student_id = intval($student_id);
3477
-            $conditions[]= " post.poster_id = '$student_id' ";
3477
+            $conditions[] = " post.poster_id = '$student_id' ";
3478 3478
         }
3479 3479
 
3480 3480
         $conditionsToString = implode('AND ', $conditions);
@@ -3499,13 +3499,13 @@  discard block
 block discarded – undo
3499 3499
         if (!empty($courseInfo)) {
3500 3500
             $forums = get_forums('', $courseCode, true, $session_id);
3501 3501
             $course_id = $courseInfo['real_id'];
3502
-            $conditions[]= " post.c_id  = $course_id ";
3502
+            $conditions[] = " post.c_id  = $course_id ";
3503 3503
         }
3504 3504
 
3505 3505
         if (!empty($forums)) {
3506 3506
             $idList = array_column($forums, 'forum_id');
3507 3507
             $idListToString = implode("', '", $idList);
3508
-            $conditions[]= " post.forum_id  IN ('$idListToString')";
3508
+            $conditions[] = " post.forum_id  IN ('$idListToString')";
3509 3509
         }
3510 3510
 
3511 3511
         $conditionsToString = implode('AND ', $conditions);
@@ -3540,7 +3540,7 @@  discard block
 block discarded – undo
3540 3540
             $condition_session = '';
3541 3541
             if (isset($session_id)) {
3542 3542
                 $session_id = intval($session_id);
3543
-                $condition_session = api_get_session_condition($session_id, true,  false, 'f.session_id');
3543
+                $condition_session = api_get_session_condition($session_id, true, false, 'f.session_id');
3544 3544
             }
3545 3545
 
3546 3546
             $course_id = $courseInfo['real_id'];
@@ -3596,7 +3596,7 @@  discard block
 block discarded – undo
3596 3596
         $condition_session = '';
3597 3597
         if (isset($session_id)) {
3598 3598
             $session_id = intval($session_id);
3599
-            $condition_session = ' AND f.session_id = '. $session_id;
3599
+            $condition_session = ' AND f.session_id = '.$session_id;
3600 3600
         }
3601 3601
 
3602 3602
         $groupId = intval($groupId);
@@ -3657,7 +3657,7 @@  discard block
 block discarded – undo
3657 3657
         $condition_session = '';
3658 3658
         if (isset($session_id)) {
3659 3659
              $session_id = intval($session_id);
3660
-             $condition_session = ' AND f.session_id = '. $session_id;
3660
+             $condition_session = ' AND f.session_id = '.$session_id;
3661 3661
         }
3662 3662
 
3663 3663
         $groupId = intval($groupId);
@@ -3736,7 +3736,7 @@  discard block
 block discarded – undo
3736 3736
     {
3737 3737
         $student_id = intval($student_id);
3738 3738
         $courseId = intval($courseId);
3739
-        $session_id    = intval($session_id);
3739
+        $session_id = intval($session_id);
3740 3740
         $date_time  = '';
3741 3741
 
3742 3742
         // table definition
@@ -3805,7 +3805,7 @@  discard block
 block discarded – undo
3805 3805
         $table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
3806 3806
 
3807 3807
         $sql = 'SELECT 1
3808
-                FROM ' . $table . '
3808
+                FROM ' . $table.'
3809 3809
                 WHERE down_user_id = '.$student_id.'
3810 3810
                 AND c_id  = "'.$courseId.'"
3811 3811
                 AND down_session_id = '.$session_id.' ';
@@ -3883,30 +3883,30 @@  discard block
 block discarded – undo
3883 3883
                 '.$inner.'
3884 3884
                 WHERE c.id = '.$courseId.'
3885 3885
                 GROUP BY stats_login.user_id
3886
-                HAVING DATE_SUB( "' . $now . '", INTERVAL '.$since.' DAY) > max_date ';
3886
+                HAVING DATE_SUB( "' . $now.'", INTERVAL '.$since.' DAY) > max_date ';
3887 3887
 
3888 3888
         if ($since == 'never') {
3889 3889
             if (empty($session_id)) {
3890 3890
                 $sql = 'SELECT course_user.user_id
3891
-                        FROM ' . $table_course_rel_user . ' course_user
3892
-                        LEFT JOIN ' . $tbl_track_login . ' stats_login
3891
+                        FROM ' . $table_course_rel_user.' course_user
3892
+                        LEFT JOIN ' . $tbl_track_login.' stats_login
3893 3893
                         ON course_user.user_id = stats_login.user_id AND
3894
-                        relation_type<>' . COURSE_RELATION_TYPE_RRHH . '
3895
-                        INNER JOIN ' . $tableCourse . ' c
3894
+                        relation_type<>' . COURSE_RELATION_TYPE_RRHH.'
3895
+                        INNER JOIN ' . $tableCourse.' c
3896 3896
                         ON (c.id = course_user.c_id)
3897 3897
                         WHERE
3898
-                            course_user.c_id = ' . $courseId . ' AND
3898
+                            course_user.c_id = ' . $courseId.' AND
3899 3899
                             stats_login.login_course_date IS NULL
3900 3900
                         GROUP BY course_user.user_id';
3901 3901
             } else {
3902 3902
                 $sql = 'SELECT session_course_user.user_id
3903 3903
                         FROM '.$tbl_session_course_user.' session_course_user
3904
-                        LEFT JOIN ' . $tbl_track_login . ' stats_login
3904
+                        LEFT JOIN ' . $tbl_track_login.' stats_login
3905 3905
                         ON session_course_user.user_id = stats_login.user_id
3906
-                        INNER JOIN ' . $tableCourse . ' c
3906
+                        INNER JOIN ' . $tableCourse.' c
3907 3907
                         ON (c.id = session_course_user.c_id)
3908 3908
                         WHERE
3909
-                            session_course_user.c_id = ' . $courseId . ' AND
3909
+                            session_course_user.c_id = ' . $courseId.' AND
3910 3910
                             stats_login.login_course_date IS NULL
3911 3911
                         GROUP BY session_course_user.user_id';
3912 3912
             }
@@ -3914,7 +3914,7 @@  discard block
 block discarded – undo
3914 3914
 
3915 3915
         $rs = Database::query($sql);
3916 3916
         $inactive_users = array();
3917
-        while($user = Database::fetch_array($rs)) {
3917
+        while ($user = Database::fetch_array($rs)) {
3918 3918
             $inactive_users[] = $user['user_id'];
3919 3919
         }
3920 3920
 
@@ -3936,10 +3936,10 @@  discard block
 block discarded – undo
3936 3936
         $table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
3937 3937
 
3938 3938
         $sql = 'SELECT '.$student_id.'
3939
-                FROM ' . $table . '
3939
+                FROM ' . $table.'
3940 3940
                 WHERE
3941
-                    access_user_id=' . $student_id . ' AND
3942
-                    c_id="' . $courseId . '" AND
3941
+                    access_user_id=' . $student_id.' AND
3942
+                    c_id="' . $courseId.'" AND
3943 3943
                     access_session_id = "'.$session_id.'" ';
3944 3944
 
3945 3945
         $rs = Database::query($sql);
@@ -3957,13 +3957,13 @@  discard block
 block discarded – undo
3957 3957
     {
3958 3958
         $hr_dept_id = intval($hr_dept_id);
3959 3959
         $a_students = array();
3960
-        $tbl_user     = Database :: get_main_table(TABLE_MAIN_USER);
3960
+        $tbl_user = Database :: get_main_table(TABLE_MAIN_USER);
3961 3961
 
3962 3962
         $sql = 'SELECT DISTINCT user_id FROM '.$tbl_user.' as user
3963 3963
                 WHERE hr_dept_id='.$hr_dept_id;
3964 3964
         $rs = Database::query($sql);
3965 3965
 
3966
-        while($user = Database :: fetch_array($rs)) {
3966
+        while ($user = Database :: fetch_array($rs)) {
3967 3967
             $a_students[$user['user_id']] = $user['user_id'];
3968 3968
         }
3969 3969
 
@@ -3988,7 +3988,7 @@  discard block
 block discarded – undo
3988 3988
         $condition_session     = '';
3989 3989
         if (isset($session_id)) {
3990 3990
             $session_id = intval($session_id);
3991
-            $condition_session = ' AND access_session_id = '. $session_id;
3991
+            $condition_session = ' AND access_session_id = '.$session_id;
3992 3992
         }
3993 3993
         $sql = "SELECT
3994 3994
                     access_tool,
@@ -4100,7 +4100,7 @@  discard block
 block discarded – undo
4100 4100
             if (!empty($date_from) && !empty($date_to)) {
4101 4101
                 $fieldStartDate = $fields['start_date'];
4102 4102
                 if (!isset($fields['end_date'])) {
4103
-                    $where .= sprintf(" AND ($fieldStartDate BETWEEN '%s' AND '%s' )", $date_from, $date_to) ;
4103
+                    $where .= sprintf(" AND ($fieldStartDate BETWEEN '%s' AND '%s' )", $date_from, $date_to);
4104 4104
                 } else {
4105 4105
                     $fieldEndDate = $fields['end_date'];
4106 4106
                     $where .= sprintf(" AND fieldStartDate >= '%s'
@@ -4116,12 +4116,12 @@  discard block
 block discarded – undo
4116 4116
                 $where
4117 4117
                 GROUP BY %s";
4118 4118
             $sql = sprintf($sql,
4119
-                $fields['user'],    //user field
4120
-                $tableName,         //FROM
4121
-                $fields['course'],  //course condition
4122
-                $course['real_id'],    //course condition
4123
-                $fields['user'],    //user condition
4124
-                $userId,            //user condition
4119
+                $fields['user'], //user field
4120
+                $tableName, //FROM
4121
+                $fields['course'], //course condition
4122
+                $course['real_id'], //course condition
4123
+                $fields['user'], //user condition
4124
+                $userId, //user condition
4125 4125
                 $fields['user']     //GROUP BY
4126 4126
                 );
4127 4127
             $rs = Database::query($sql);
@@ -4129,7 +4129,7 @@  discard block
 block discarded – undo
4129 4129
             //iterate query
4130 4130
             if (Database::num_rows($rs) > 0) {
4131 4131
                 while ($row = Database::fetch_array($rs)) {
4132
-                    $data[$row['user']] = (isset($data[$row['user']])) ?  $data[$row['user']] + $row[total]: $row['total'];
4132
+                    $data[$row['user']] = (isset($data[$row['user']])) ? $data[$row['user']] + $row[total] : $row['total'];
4133 4133
                 }
4134 4134
             }
4135 4135
         }
@@ -4152,11 +4152,11 @@  discard block
 block discarded – undo
4152 4152
         $courseId = api_get_course_int_id($course_code);
4153 4153
         $data = array();
4154 4154
 
4155
-        $TABLETRACK_DOWNLOADS   = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
4155
+        $TABLETRACK_DOWNLOADS = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
4156 4156
         $condition_session = '';
4157 4157
         $session_id = intval($session_id);
4158 4158
         if (!empty($session_id)) {
4159
-            $condition_session = ' AND down_session_id = '. $session_id;
4159
+            $condition_session = ' AND down_session_id = '.$session_id;
4160 4160
         }
4161 4161
         $sql = "SELECT 
4162 4162
                     down_doc_path, 
@@ -4344,7 +4344,7 @@  discard block
 block discarded – undo
4344 4344
 
4345 4345
             $final_course_data = array();
4346 4346
 
4347
-            foreach($my_course_data as $course_id => $value) {
4347
+            foreach ($my_course_data as $course_id => $value) {
4348 4348
                 $final_course_data[$course_id] = $course_list[$course_id];
4349 4349
             }
4350 4350
             $course_in_session[$my_session_id]['course_list'] = $final_course_data;
@@ -4367,7 +4367,7 @@  discard block
 block discarded – undo
4367 4367
                           '.Display::tag('th', get_lang('Course'), array('width'=>'300px')).'
4368 4368
                           '.Display::tag('th', get_lang('TimeSpentInTheCourse'), array('class'=>'head')).'
4369 4369
                           '.Display::tag('th', get_lang('Progress'), array('class'=>'head')).'
4370
-                          '.Display::tag('th', get_lang('Score').Display::return_icon('info3.gif', get_lang('ScormAndLPTestTotalAverage'), array('align' => 'absmiddle', 'hspace' => '3px')),array('class'=>'head')).'
4370
+                          '.Display::tag('th', get_lang('Score').Display::return_icon('info3.gif', get_lang('ScormAndLPTestTotalAverage'), array('align' => 'absmiddle', 'hspace' => '3px')), array('class'=>'head')).'
4371 4371
                           '.Display::tag('th', get_lang('LastConnexion'), array('class'=>'head')).'
4372 4372
                           '.Display::tag('th', get_lang('Details'), array('class'=>'head')).'
4373 4373
                         </tr>';
@@ -4456,7 +4456,7 @@  discard block
 block discarded – undo
4456 4456
             $all_exercise_start_time = array();
4457 4457
 
4458 4458
             foreach ($course_in_session as $my_session_id => $session_data) {
4459
-                $course_list  = $session_data['course_list'];
4459
+                $course_list = $session_data['course_list'];
4460 4460
                 $user_count = count(SessionManager::get_users_by_session($my_session_id));
4461 4461
                 $exercise_graph_name_list = array();
4462 4462
                 //$user_results = array();
@@ -4501,20 +4501,20 @@  discard block
 block discarded – undo
4501 4501
 
4502 4502
                             $score = 0;
4503 4503
                             if (!empty($user_result_data['exe_weighting']) && intval($user_result_data['exe_weighting']) != 0) {
4504
-                                $score = intval($user_result_data['exe_result']/$user_result_data['exe_weighting'] * 100);
4504
+                                $score = intval($user_result_data['exe_result'] / $user_result_data['exe_weighting'] * 100);
4505 4505
                             }
4506 4506
                             $time = api_strtotime($exercise_data['start_time']) ? api_strtotime($exercise_data['start_time'], 'UTC') : 0;
4507 4507
                             $all_exercise_start_time[] = $time;
4508 4508
                             $my_results[] = $score;
4509
-                            if (count($exercise_list)<=10) {
4509
+                            if (count($exercise_list) <= 10) {
4510 4510
                                 $title = cut($course_data['title'], 30)." \n ".cut($exercise_data['title'], 30);
4511
-                                $exercise_graph_name_list[]= $title;
4511
+                                $exercise_graph_name_list[] = $title;
4512 4512
                                 $all_exercise_graph_name_list[] = $title;
4513 4513
                             } else {
4514 4514
                                 // if there are more than 10 results, space becomes difficult to find, so only show the title of the exercise, not the tool
4515 4515
                                 $title = cut($exercise_data['title'], 30);
4516
-                                $exercise_graph_name_list[]= $title;
4517
-                                $all_exercise_graph_name_list[]= $title;
4516
+                                $exercise_graph_name_list[] = $title;
4517
+                                $all_exercise_graph_name_list[] = $title;
4518 4518
                             }
4519 4519
                         }
4520 4520
                     }
@@ -4547,7 +4547,7 @@  discard block
 block discarded – undo
4547 4547
             }
4548 4548
 
4549 4549
             $html .= Display::page_subheader(
4550
-                Display::return_icon('session.png', get_lang('Sessions'), array(), ICON_SIZE_SMALL) . ' ' . get_lang('Sessions')
4550
+                Display::return_icon('session.png', get_lang('Sessions'), array(), ICON_SIZE_SMALL).' '.get_lang('Sessions')
4551 4551
             );
4552 4552
 
4553 4553
             $html .= '<div class="table-responsive">';
@@ -4601,7 +4601,7 @@  discard block
 block discarded – undo
4601 4601
                                 $courseInfo['real_id'],
4602 4602
                                 $my_session_id
4603 4603
                             );
4604
-                            if ($attempts > 1)  {
4604
+                            if ($attempts > 1) {
4605 4605
                                 $answered_exercises++;
4606 4606
                             }
4607 4607
                         }
@@ -4614,7 +4614,7 @@  discard block
 block discarded – undo
4614 4614
                     $all_average += $average;
4615 4615
                 }
4616 4616
 
4617
-                $all_average = $all_average /  count($course_list);
4617
+                $all_average = $all_average / count($course_list);
4618 4618
 
4619 4619
                 if (isset($_GET['session_id']) && $my_session_id == $_GET['session_id']) {
4620 4620
                     $html .= '<tr style="background-color:#FBF09D">';
@@ -4640,16 +4640,16 @@  discard block
 block discarded – undo
4640 4640
             }
4641 4641
             $html .= '</tbody>';
4642 4642
             $html .= '</table></div><br />';
4643
-            $html .= Display::div($main_session_graph, array('id'=>'session_graph','class'=>'chart-session', 'style'=>'position:relative; text-align: center;') );
4643
+            $html .= Display::div($main_session_graph, array('id'=>'session_graph', 'class'=>'chart-session', 'style'=>'position:relative; text-align: center;'));
4644 4644
 
4645 4645
             // Checking selected session.
4646 4646
 
4647 4647
             if (isset($_GET['session_id'])) {
4648 4648
                 $session_id_from_get = intval($_GET['session_id']);
4649
-                $session_data 	= $course_in_session[$session_id_from_get];
4650
-                $course_list 	= $session_data['course_list'];
4649
+                $session_data = $course_in_session[$session_id_from_get];
4650
+                $course_list = $session_data['course_list'];
4651 4651
 
4652
-                $html .= Display::tag('h3',$session_data['name'].' - '.get_lang('CourseList'));
4652
+                $html .= Display::tag('h3', $session_data['name'].' - '.get_lang('CourseList'));
4653 4653
 
4654 4654
                 $html .= '<div class="table-responsive">';
4655 4655
                 $html .= '<table class="table table-hover table-striped">';
@@ -4658,15 +4658,15 @@  discard block
 block discarded – undo
4658 4658
                     <thead>
4659 4659
                     <tr>
4660 4660
                       <th width="300px">'.get_lang('Course').'</th>
4661
-                      '.Display::tag('th', get_lang('PublishedExercises'),    	array('class'=>'head')).'
4662
-                      '.Display::tag('th', get_lang('NewExercises'),    		array('class'=>'head')).'
4663
-                      '.Display::tag('th', get_lang('MyAverage'), 				array('class'=>'head')).'
4664
-                      '.Display::tag('th', get_lang('AverageExerciseResult'), 	array('class'=>'head')).'
4665
-                      '.Display::tag('th', get_lang('TimeSpentInTheCourse'),    array('class'=>'head')).'
4666
-                      '.Display::tag('th', get_lang('LPProgress')     ,      	array('class'=>'head')).'
4667
-                      '.Display::tag('th', get_lang('Score').Display::return_icon('info3.gif', get_lang('ScormAndLPTestTotalAverage'), array ('align' => 'absmiddle', 'hspace' => '3px')), array('class'=>'head')).'
4668
-                      '.Display::tag('th', get_lang('LastConnexion'),         	array('class'=>'head')).'
4669
-                      '.Display::tag('th', get_lang('Details'),               	array('class'=>'head')).'
4661
+                      '.Display::tag('th', get_lang('PublishedExercises'), array('class'=>'head')).'
4662
+                      '.Display::tag('th', get_lang('NewExercises'), array('class'=>'head')).'
4663
+                      '.Display::tag('th', get_lang('MyAverage'), array('class'=>'head')).'
4664
+                      '.Display::tag('th', get_lang('AverageExerciseResult'), array('class'=>'head')).'
4665
+                      '.Display::tag('th', get_lang('TimeSpentInTheCourse'), array('class'=>'head')).'
4666
+                      '.Display::tag('th', get_lang('LPProgress'), array('class'=>'head')).'
4667
+                      '.Display::tag('th', get_lang('Score').Display::return_icon('info3.gif', get_lang('ScormAndLPTestTotalAverage'), array('align' => 'absmiddle', 'hspace' => '3px')), array('class'=>'head')).'
4668
+                      '.Display::tag('th', get_lang('LastConnexion'), array('class'=>'head')).'
4669
+                      '.Display::tag('th', get_lang('Details'), array('class'=>'head')).'
4670 4670
                     </tr>
4671 4671
                     </thead>
4672 4672
                     <tbody>
@@ -4685,14 +4685,14 @@  discard block
 block discarded – undo
4685 4685
                         $count_exercises = count($exercises);
4686 4686
                     }
4687 4687
                     $answered_exercises = 0;
4688
-                    foreach($exercises as $exercise_item) {
4688
+                    foreach ($exercises as $exercise_item) {
4689 4689
                         $attempts = Event::count_exercise_attempts_by_user(
4690 4690
                             api_get_user_id(),
4691 4691
                             $exercise_item['id'],
4692 4692
                             $courseId,
4693 4693
                             $session_id_from_get
4694 4694
                         );
4695
-                        if ($attempts > 1)  {
4695
+                        if ($attempts > 1) {
4696 4696
                             $answered_exercises++;
4697 4697
                         }
4698 4698
                     }
@@ -4701,7 +4701,7 @@  discard block
 block discarded – undo
4701 4701
 
4702 4702
                     // Average
4703 4703
                     $average = ExerciseLib::get_average_score_by_course($courseId, $session_id_from_get);
4704
-                    $my_average	= ExerciseLib::get_average_score_by_course_by_user(api_get_user_id(), $courseId, $session_id_from_get);
4704
+                    $my_average = ExerciseLib::get_average_score_by_course_by_user(api_get_user_id(), $courseId, $session_id_from_get);
4705 4705
 
4706 4706
                     $stats_array[$course_code] = array(
4707 4707
                         'exercises' => $count_exercises,
@@ -4778,7 +4778,7 @@  discard block
 block discarded – undo
4778 4778
 
4779 4779
                     if ($course_code == $courseCodeFromGet && $_GET['session_id'] == $session_id_from_get) {
4780 4780
                         $details = '<a href="#">';
4781
-                        $details .=Display::return_icon('2rightarrow_na.png', get_lang('Details'));
4781
+                        $details .= Display::return_icon('2rightarrow_na.png', get_lang('Details'));
4782 4782
                     } else {
4783 4783
                         $details = '<a href="'.api_get_self().'?course='.$course_code.'&session_id='.$session_id_from_get.$extra_params.'">';
4784 4784
                         $details .= Display::return_icon('2rightarrow.png', get_lang('Details'));
@@ -4878,7 +4878,7 @@  discard block
 block discarded – undo
4878 4878
                     );
4879 4879
 
4880 4880
                     $html .= '<tr class="row_even">';
4881
-                    $url = api_get_path(WEB_CODE_PATH) . "exercise/overview.php?cidReq={$course_info['code']}&id_session=$session_id&exerciseId={$exercices['id']}";
4881
+                    $url = api_get_path(WEB_CODE_PATH)."exercise/overview.php?cidReq={$course_info['code']}&id_session=$session_id&exerciseId={$exercices['id']}";
4882 4882
 
4883 4883
                     if ($visible_return['value'] == true) {
4884 4884
                         $exercices['title'] = Display::url(
@@ -4907,7 +4907,7 @@  discard block
 block discarded – undo
4907 4907
                         );
4908 4908
 
4909 4909
                         $latest_attempt_url = '';
4910
-                        $best_score = $position = $percentage_score_result  = '-';
4910
+                        $best_score = $position = $percentage_score_result = '-';
4911 4911
                         $graph = $normal_graph = null;
4912 4912
 
4913 4913
                         // Getting best results
@@ -4939,11 +4939,11 @@  discard block
 block discarded – undo
4939 4939
                                 $weighting      = $exercise_stat['exe_weighting'];
4940 4940
                                 $exe_id         = $exercise_stat['exe_id'];
4941 4941
 
4942
-                                $latest_attempt_url .= api_get_path(WEB_CODE_PATH) . 'exercise/result.php?id='.$exe_id.'&cidReq='.$course_info['code'].'&show_headers=1&id_session='.$session_id;
4942
+                                $latest_attempt_url .= api_get_path(WEB_CODE_PATH).'exercise/result.php?id='.$exe_id.'&cidReq='.$course_info['code'].'&show_headers=1&id_session='.$session_id;
4943 4943
                                 $percentage_score_result = Display::url(ExerciseLib::show_score($score, $weighting), $latest_attempt_url);
4944 4944
                                 $my_score = 0;
4945 4945
                                 if (!empty($weighting) && intval($weighting) != 0) {
4946
-                                    $my_score = $score/$weighting;
4946
+                                    $my_score = $score / $weighting;
4947 4947
                                 }
4948 4948
                                 //@todo this function slows the page
4949 4949
                                 if (is_int($user_list)) {
@@ -4957,14 +4957,14 @@  discard block
 block discarded – undo
4957 4957
                         }
4958 4958
                         $html .= Display::div(
4959 4959
                             $normal_graph,
4960
-                            array('id'=>'main_graph_'.$exercices['id'],'class'=>'dialog', 'style'=>'display:none')
4960
+                            array('id'=>'main_graph_'.$exercices['id'], 'class'=>'dialog', 'style'=>'display:none')
4961 4961
                         );
4962 4962
 
4963 4963
                         if (empty($graph)) {
4964 4964
                             $graph = '-';
4965 4965
                         } else {
4966 4966
                             $graph = Display::url(
4967
-                                '<img src="' . $graph . '" >',
4967
+                                '<img src="'.$graph.'" >',
4968 4968
                                 $normal_graph,
4969 4969
                                 array(
4970 4970
                                     'id' => $exercices['id'],
@@ -4998,7 +4998,7 @@  discard block
 block discarded – undo
4998 4998
 
4999 4999
             // LP table results
5000 5000
             $html .= '<div class="table-responsive">';
5001
-            $html .='<table class="table table-striped table-hover">';
5001
+            $html .= '<table class="table table-striped table-hover">';
5002 5002
             $html .= '<thead><tr>';
5003 5003
             $html .= Display::tag('th', get_lang('Learnpaths'), array('class'=>'head', 'style'=>'color:#000'));
5004 5004
             $html .= Display::tag('th', get_lang('LatencyTimeSpent'), array('class'=>'head', 'style'=>'color:#000'));
@@ -5034,7 +5034,7 @@  discard block
 block discarded – undo
5034 5034
                     $time_spent_in_lp = api_time_to_hms($time_spent_in_lp);
5035 5035
 
5036 5036
                     $html .= '<tr class="row_even">';
5037
-                    $url = api_get_path(WEB_CODE_PATH) . "lp/lp_controller.php?cidReq={$course_code}&id_session=$session_id&lp_id=$lp_id&action=view";
5037
+                    $url = api_get_path(WEB_CODE_PATH)."lp/lp_controller.php?cidReq={$course_code}&id_session=$session_id&lp_id=$lp_id&action=view";
5038 5038
 
5039 5039
                     if ($learnpath['lp_visibility'] == 0) {
5040 5040
                         $html .= Display::tag('td', $learnpath['lp_name']);
@@ -5053,7 +5053,7 @@  discard block
 block discarded – undo
5053 5053
                     if (!empty($last_connection_in_lp)) {
5054 5054
                         $last_connection = api_convert_and_format_date($last_connection_in_lp, DATE_TIME_FORMAT_LONG);
5055 5055
                     }
5056
-                    $html .= Display::tag('td', $last_connection, array('align'=>'center','width'=>'180px'));
5056
+                    $html .= Display::tag('td', $last_connection, array('align'=>'center', 'width'=>'180px'));
5057 5057
                     $html .= "</tr>";
5058 5058
                 }
5059 5059
             } else {
@@ -5063,7 +5063,7 @@  discard block
 block discarded – undo
5063 5063
                         </td>
5064 5064
                       </tr>';
5065 5065
             }
5066
-            $html .='</tbody></table></div>';
5066
+            $html .= '</tbody></table></div>';
5067 5067
 
5068 5068
             $html .= self::displayUserSkills($user_id, $course_info['id'], $session_id);
5069 5069
         }
@@ -5092,7 +5092,7 @@  discard block
 block discarded – undo
5092 5092
         $myData->setSerieDescription('Serie1', get_lang('MyResults'));
5093 5093
         $myData->setSerieDescription('Serie2', get_lang('AverageScore'));
5094 5094
         $myData->setAxisUnit(0, '%');
5095
-        $myData->loadPalette(api_get_path(SYS_CODE_PATH) . 'palettes/pchart/default.color', true);
5095
+        $myData->loadPalette(api_get_path(SYS_CODE_PATH).'palettes/pchart/default.color', true);
5096 5096
         // Cache definition
5097 5097
         $cachePath = api_get_path(SYS_ARCHIVE_PATH);
5098 5098
         $myCache = new pCache(array('CacheFolder' => substr($cachePath, 0, strlen($cachePath) - 1)));
@@ -5100,9 +5100,9 @@  discard block
 block discarded – undo
5100 5100
 
5101 5101
         if ($myCache->isInCache($chartHash)) {
5102 5102
             //if we already created the img
5103
-            $imgPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash;
5103
+            $imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
5104 5104
             $myCache->saveFromCache($chartHash, $imgPath);
5105
-            $imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash;
5105
+            $imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
5106 5106
         } else {
5107 5107
             /* Define width, height and angle */
5108 5108
             $mainWidth = 860;
@@ -5131,7 +5131,7 @@  discard block
 block discarded – undo
5131 5131
             /* Set the default font */
5132 5132
             $myPicture->setFontProperties(
5133 5133
                 array(
5134
-                    'FontName' => api_get_path(SYS_FONTS_PATH) . 'opensans/OpenSans-Regular.ttf',
5134
+                    'FontName' => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf',
5135 5135
                     'FontSize' => 10)
5136 5136
             );
5137 5137
             /* Write the chart title */
@@ -5148,7 +5148,7 @@  discard block
 block discarded – undo
5148 5148
             /* Set the default font */
5149 5149
             $myPicture->setFontProperties(
5150 5150
                 array(
5151
-                    'FontName' => api_get_path(SYS_FONTS_PATH) . 'opensans/OpenSans-Regular.ttf',
5151
+                    'FontName' => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf',
5152 5152
                     'FontSize' => 6
5153 5153
                 )
5154 5154
             );
@@ -5190,7 +5190,7 @@  discard block
 block discarded – undo
5190 5190
             /* Draw the line chart */
5191 5191
             $myPicture->setFontProperties(
5192 5192
                 array(
5193
-                    'FontName' => api_get_path(SYS_FONTS_PATH) . 'opensans/OpenSans-Regular.ttf',
5193
+                    'FontName' => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf',
5194 5194
                     'FontSize' => 10
5195 5195
                 )
5196 5196
             );
@@ -5223,12 +5223,12 @@  discard block
 block discarded – undo
5223 5223
             );
5224 5224
 
5225 5225
             $myCache->writeToCache($chartHash, $myPicture);
5226
-            $imgPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash;
5226
+            $imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
5227 5227
             $myCache->saveFromCache($chartHash, $imgPath);
5228
-            $imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash;
5228
+            $imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
5229 5229
         }
5230 5230
 
5231
-        $html = '<img src="' . $imgPath . '">';
5231
+        $html = '<img src="'.$imgPath.'">';
5232 5232
 
5233 5233
         return $html;
5234 5234
     }
@@ -5249,12 +5249,12 @@  discard block
 block discarded – undo
5249 5249
 
5250 5250
         foreach ($attempts as $attempt) {
5251 5251
             if (api_get_user_id() == $attempt['exe_user_id']) {
5252
-                if ($attempt['exe_weighting'] != 0 ) {
5253
-                    $my_exercise_result_array[]= $attempt['exe_result']/$attempt['exe_weighting'];
5252
+                if ($attempt['exe_weighting'] != 0) {
5253
+                    $my_exercise_result_array[] = $attempt['exe_result'] / $attempt['exe_weighting'];
5254 5254
                 }
5255 5255
             } else {
5256
-                if ($attempt['exe_weighting'] != 0 ) {
5257
-                    $exercise_result[]=  $attempt['exe_result']/$attempt['exe_weighting'];
5256
+                if ($attempt['exe_weighting'] != 0) {
5257
+                    $exercise_result[] = $attempt['exe_result'] / $attempt['exe_weighting'];
5258 5258
                 }
5259 5259
             }
5260 5260
         }
@@ -5263,27 +5263,27 @@  discard block
 block discarded – undo
5263 5263
         rsort($my_exercise_result_array);
5264 5264
         $my_exercise_result = 0;
5265 5265
         if (isset($my_exercise_result_array[0])) {
5266
-            $my_exercise_result = $my_exercise_result_array[0] *100;
5266
+            $my_exercise_result = $my_exercise_result_array[0] * 100;
5267 5267
         }
5268 5268
 
5269 5269
         $max     = 100;
5270
-        $pieces  = 5 ;
5270
+        $pieces  = 5;
5271 5271
         $part    = round($max / $pieces);
5272 5272
         $x_axis = array();
5273 5273
         $final_array = array();
5274 5274
         $my_final_array = array();
5275 5275
 
5276
-        for ($i=1; $i <=$pieces; $i++) {
5276
+        for ($i = 1; $i <= $pieces; $i++) {
5277 5277
             $sum = 1;
5278 5278
             if ($i == 1) {
5279 5279
                 $sum = 0;
5280 5280
             }
5281
-            $min = ($i-1)*$part + $sum;
5282
-            $max = ($i)*$part;
5283
-            $x_axis[]= $min." - ".$max;
5281
+            $min = ($i - 1) * $part + $sum;
5282
+            $max = ($i) * $part;
5283
+            $x_axis[] = $min." - ".$max;
5284 5284
             $count = 0;
5285
-            foreach($exercise_result as $result) {
5286
-                $percentage = $result*100;
5285
+            foreach ($exercise_result as $result) {
5286
+                $percentage = $result * 100;
5287 5287
                 //echo $percentage.' - '.$min.' - '.$max."<br />";
5288 5288
                 if ($percentage >= $min && $percentage <= $max) {
5289 5289
                     //echo ' is > ';
@@ -5291,7 +5291,7 @@  discard block
 block discarded – undo
5291 5291
                 }
5292 5292
             }
5293 5293
             //echo '<br />';
5294
-            $final_array[]= $count;
5294
+            $final_array[] = $count;
5295 5295
 
5296 5296
             if ($my_exercise_result >= $min && $my_exercise_result <= $max) {
5297 5297
                 $my_final_array[] = 1;
@@ -5301,9 +5301,9 @@  discard block
 block discarded – undo
5301 5301
         }
5302 5302
 
5303 5303
         //Fix to remove the data of the user with my data
5304
-        for($i = 0; $i<=count($my_final_array); $i++) {
5304
+        for ($i = 0; $i <= count($my_final_array); $i++) {
5305 5305
             if (!empty($my_final_array[$i])) {
5306
-                $my_final_array[$i] =  $final_array[$i] + 1; //Add my result
5306
+                $my_final_array[$i] = $final_array[$i] + 1; //Add my result
5307 5307
                 $final_array[$i] = 0;
5308 5308
             }
5309 5309
         }
@@ -5313,16 +5313,16 @@  discard block
 block discarded – undo
5313 5313
         $dataSet->addPoints($final_array, 'Serie1');
5314 5314
         $dataSet->addPoints($my_final_array, 'Serie2');
5315 5315
         $dataSet->normalize(100, "%");
5316
-        $dataSet->loadPalette(api_get_path(SYS_CODE_PATH) . 'palettes/pchart/default.color', true);
5316
+        $dataSet->loadPalette(api_get_path(SYS_CODE_PATH).'palettes/pchart/default.color', true);
5317 5317
 
5318 5318
         // Cache definition
5319 5319
         $cachePath = api_get_path(SYS_ARCHIVE_PATH);
5320 5320
         $myCache = new pCache(array('CacheFolder' => substr($cachePath, 0, strlen($cachePath) - 1)));
5321 5321
         $chartHash = $myCache->getHash($dataSet);
5322 5322
         if ($myCache->isInCache($chartHash)) {
5323
-            $imgPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash;
5323
+            $imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
5324 5324
             $myCache->saveFromCache($chartHash, $imgPath);
5325
-            $imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash;
5325
+            $imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
5326 5326
         } else {
5327 5327
             /* Create the pChart object */
5328 5328
             $widthSize = 80;
@@ -5338,7 +5338,7 @@  discard block
 block discarded – undo
5338 5338
             $myPicture->drawRectangle(0, 0, $widthSize - 1, $heightSize - 1, array('R' => 0, 'G' => 0, 'B' => 0));
5339 5339
 
5340 5340
             /* Set the default font */
5341
-            $myPicture->setFontProperties(array('FontName' => api_get_path(SYS_FONTS_PATH) . 'opensans/OpenSans-Regular.ttf', 'FontSize' => $fontSize));
5341
+            $myPicture->setFontProperties(array('FontName' => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf', 'FontSize' => $fontSize));
5342 5342
 
5343 5343
             /* Do not write the chart title */
5344 5344
 
@@ -5402,9 +5402,9 @@  discard block
 block discarded – undo
5402 5402
 
5403 5403
             /* Save and write in cache */
5404 5404
             $myCache->writeToCache($chartHash, $myPicture);
5405
-            $imgPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash;
5405
+            $imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
5406 5406
             $myCache->saveFromCache($chartHash, $imgPath);
5407
-            $imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash;
5407
+            $imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
5408 5408
         }
5409 5409
 
5410 5410
         return $imgPath;
@@ -5424,12 +5424,12 @@  discard block
 block discarded – undo
5424 5424
         }
5425 5425
         foreach ($attempts as $attempt) {
5426 5426
             if (api_get_user_id() == $attempt['exe_user_id']) {
5427
-                if ($attempt['exe_weighting'] != 0 ) {
5428
-                    $my_exercise_result_array[]= $attempt['exe_result']/$attempt['exe_weighting'];
5427
+                if ($attempt['exe_weighting'] != 0) {
5428
+                    $my_exercise_result_array[] = $attempt['exe_result'] / $attempt['exe_weighting'];
5429 5429
                 }
5430 5430
             } else {
5431
-                if ($attempt['exe_weighting'] != 0 ) {
5432
-                    $exercise_result[]=  $attempt['exe_result']/$attempt['exe_weighting'];
5431
+                if ($attempt['exe_weighting'] != 0) {
5432
+                    $exercise_result[] = $attempt['exe_result'] / $attempt['exe_weighting'];
5433 5433
                 }
5434 5434
             }
5435 5435
         }
@@ -5438,32 +5438,32 @@  discard block
 block discarded – undo
5438 5438
         rsort($my_exercise_result_array);
5439 5439
         $my_exercise_result = 0;
5440 5440
         if (isset($my_exercise_result_array[0])) {
5441
-            $my_exercise_result = $my_exercise_result_array[0] *100;
5441
+            $my_exercise_result = $my_exercise_result_array[0] * 100;
5442 5442
         }
5443 5443
 
5444 5444
         $max = 100;
5445
-        $pieces = 5 ;
5445
+        $pieces = 5;
5446 5446
         $part = round($max / $pieces);
5447 5447
         $x_axis = array();
5448 5448
         $final_array = array();
5449 5449
         $my_final_array = array();
5450 5450
 
5451
-        for ($i=1; $i <=$pieces; $i++) {
5451
+        for ($i = 1; $i <= $pieces; $i++) {
5452 5452
             $sum = 1;
5453 5453
             if ($i == 1) {
5454 5454
                 $sum = 0;
5455 5455
             }
5456
-            $min = ($i-1)*$part + $sum;
5457
-            $max = ($i)*$part;
5458
-            $x_axis[]= $min." - ".$max;
5456
+            $min = ($i - 1) * $part + $sum;
5457
+            $max = ($i) * $part;
5458
+            $x_axis[] = $min." - ".$max;
5459 5459
             $count = 0;
5460
-            foreach($exercise_result as $result) {
5461
-                $percentage = $result*100;
5460
+            foreach ($exercise_result as $result) {
5461
+                $percentage = $result * 100;
5462 5462
                 if ($percentage >= $min && $percentage <= $max) {
5463 5463
                     $count++;
5464 5464
                 }
5465 5465
             }
5466
-            $final_array[]= $count;
5466
+            $final_array[] = $count;
5467 5467
 
5468 5468
             if ($my_exercise_result >= $min && $my_exercise_result <= $max) {
5469 5469
                 $my_final_array[] = 1;
@@ -5474,9 +5474,9 @@  discard block
 block discarded – undo
5474 5474
 
5475 5475
         //Fix to remove the data of the user with my data
5476 5476
 
5477
-        for($i = 0; $i<=count($my_final_array); $i++) {
5477
+        for ($i = 0; $i <= count($my_final_array); $i++) {
5478 5478
             if (!empty($my_final_array[$i])) {
5479
-                $my_final_array[$i] =  $final_array[$i] + 1; //Add my result
5479
+                $my_final_array[$i] = $final_array[$i] + 1; //Add my result
5480 5480
                 $final_array[$i] = 0;
5481 5481
             }
5482 5482
         }
@@ -5494,7 +5494,7 @@  discard block
 block discarded – undo
5494 5494
         $dataSet->setXAxisName(get_lang('Score'));
5495 5495
         $dataSet->normalize(100, "%");
5496 5496
 
5497
-        $dataSet->loadPalette(api_get_path(SYS_CODE_PATH) . 'palettes/pchart/default.color', true);
5497
+        $dataSet->loadPalette(api_get_path(SYS_CODE_PATH).'palettes/pchart/default.color', true);
5498 5498
 
5499 5499
         // Cache definition
5500 5500
         $cachePath = api_get_path(SYS_ARCHIVE_PATH);
@@ -5502,9 +5502,9 @@  discard block
 block discarded – undo
5502 5502
         $chartHash = $myCache->getHash($dataSet);
5503 5503
 
5504 5504
         if ($myCache->isInCache($chartHash)) {
5505
-            $imgPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash;
5505
+            $imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
5506 5506
             $myCache->saveFromCache($chartHash, $imgPath);
5507
-            $imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash;
5507
+            $imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
5508 5508
         } else {
5509 5509
             /* Create the pChart object */
5510 5510
             $widthSize = 480;
@@ -5520,7 +5520,7 @@  discard block
 block discarded – undo
5520 5520
             $myPicture->drawRectangle(0, 0, $widthSize - 1, $heightSize - 1, array('R' => 0, 'G' => 0, 'B' => 0));
5521 5521
 
5522 5522
             /* Set the default font */
5523
-            $myPicture->setFontProperties(array('FontName' => api_get_path(SYS_FONTS_PATH) . 'opensans/OpenSans-Regular.ttf', 'FontSize' => 10));
5523
+            $myPicture->setFontProperties(array('FontName' => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf', 'FontSize' => 10));
5524 5524
 
5525 5525
             /* Write the chart title */
5526 5526
             $myPicture->drawText(
@@ -5579,9 +5579,9 @@  discard block
 block discarded – undo
5579 5579
 
5580 5580
             /* Write and save into cache */
5581 5581
             $myCache->writeToCache($chartHash, $myPicture);
5582
-            $imgPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash;
5582
+            $imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
5583 5583
             $myCache->saveFromCache($chartHash, $imgPath);
5584
-            $imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash;
5584
+            $imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
5585 5585
         }
5586 5586
 
5587 5587
         return $imgPath;
@@ -5656,7 +5656,7 @@  discard block
 block discarded – undo
5656 5656
         $tquiz_answer = Database::get_course_table(TABLE_QUIZ_ANSWER);
5657 5657
         $tquiz_question = Database::get_course_table(TABLE_QUIZ_QUESTION);
5658 5658
         $tquiz_rel_question = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
5659
-        $ttrack_exercises  = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
5659
+        $ttrack_exercises = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
5660 5660
         $ttrack_attempt = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
5661 5661
 
5662 5662
         $sessions = array();
@@ -5708,7 +5708,7 @@  discard block
 block discarded – undo
5708 5708
                         $whereSessionParams .= $sessionIdx.',';
5709 5709
                     }
5710 5710
                 }
5711
-                $whereSessionParams = substr($whereSessionParams,0,-1);
5711
+                $whereSessionParams = substr($whereSessionParams, 0, -1);
5712 5712
             }
5713 5713
 
5714 5714
             if (!empty($exerciseId)) {
@@ -5772,7 +5772,7 @@  discard block
 block discarded – undo
5772 5772
                     qq.position = rq.question_order AND
5773 5773
                     ta.question_id = rq.question_id
5774 5774
                 WHERE
5775
-                    te.c_id = $courseIdx ".(empty($whereSessionParams)?'':"AND te.session_id IN ($whereSessionParams)")."
5775
+                    te.c_id = $courseIdx ".(empty($whereSessionParams) ? '' : "AND te.session_id IN ($whereSessionParams)")."
5776 5776
                     AND q.c_id = $courseIdx
5777 5777
                     $where $order $limit";
5778 5778
             $sql_query = vsprintf($sql, $whereParams);
@@ -5820,7 +5820,7 @@  discard block
 block discarded – undo
5820 5820
             // Now fill users data
5821 5821
             $sqlUsers = "SELECT user_id, username, lastname, firstname
5822 5822
                          FROM $tuser
5823
-                         WHERE user_id IN (".implode(',',$userIds).")";
5823
+                         WHERE user_id IN (".implode(',', $userIds).")";
5824 5824
             $resUsers = Database::query($sqlUsers);
5825 5825
             while ($rowUser = Database::fetch_assoc($resUsers)) {
5826 5826
                 $users[$rowUser['user_id']] = $rowUser;
@@ -5924,7 +5924,7 @@  discard block
 block discarded – undo
5924 5924
                 <table class="table" id="skillList">
5925 5925
                     <thead>
5926 5926
                         <tr>
5927
-                            <th>' . get_lang('AchievedSkills') . '</th>
5927
+                            <th>' . get_lang('AchievedSkills').'</th>
5928 5928
                         </tr>
5929 5929
                     </thead>
5930 5930
                     <tbody>
@@ -5943,10 +5943,10 @@  discard block
 block discarded – undo
5943 5943
 
5944 5944
                 $html .= '
5945 5945
                                             <li class="thumbnail">
5946
-                                                <a href="' . api_get_path(WEB_PATH) . 'badge/' . $userSkill->getId() . '/user/' . $userId . '" target="_blank">
5947
-                                                    <img class="img-responsive" title="' . $skill->getName() . '" src="' . $skill->getWebIconPath() . '" width="64" height="64">
5946
+                                                <a href="' . api_get_path(WEB_PATH).'badge/'.$userSkill->getId().'/user/'.$userId.'" target="_blank">
5947
+                                                    <img class="img-responsive" title="' . $skill->getName().'" src="'.$skill->getWebIconPath().'" width="64" height="64">
5948 5948
                                                     <div class="caption">
5949
-                                                        <p class="text-center">' . $skill->getName() . '</p>
5949
+                                                        <p class="text-center">' . $skill->getName().'</p>
5950 5950
                                                     </div>
5951 5951
                                                 </a>
5952 5952
                                             </li>
@@ -5996,7 +5996,7 @@  discard block
 block discarded – undo
5996 5996
     	        WHERE
5997 5997
                     track_resource.c_id = $course_id AND
5998 5998
                     track_resource.insert_user_id = user.user_id AND
5999
-                    session_id " .(empty($session_id) ? ' IS NULL ' : " = $session_id ");
5999
+                    session_id ".(empty($session_id) ? ' IS NULL ' : " = $session_id ");
6000 6000
 
6001 6001
     	if (isset($_GET['keyword'])) {
6002 6002
     		$keyword = Database::escape_string(trim($_GET['keyword']));
@@ -6054,7 +6054,7 @@  discard block
 block discarded – undo
6054 6054
                 WHERE
6055 6055
                   track_resource.c_id = $course_id AND
6056 6056
                   track_resource.insert_user_id = user.user_id AND
6057
-                  session_id " .(empty($session_id) ? ' IS NULL ' : " = $session_id ");
6057
+                  session_id ".(empty($session_id) ? ' IS NULL ' : " = $session_id ");
6058 6058
 
6059 6059
     	if (isset($_GET['keyword'])) {
6060 6060
     		$keyword = Database::escape_string(trim($_GET['keyword']));
@@ -6354,7 +6354,7 @@  discard block
 block discarded – undo
6354 6354
     public static function display_additional_profile_fields()
6355 6355
     {
6356 6356
     	// getting all the extra profile fields that are defined by the platform administrator
6357
-    	$extra_fields = UserManager :: get_extra_fields(0,50,5,'ASC');
6357
+    	$extra_fields = UserManager :: get_extra_fields(0, 50, 5, 'ASC');
6358 6358
 
6359 6359
     	// creating the form
6360 6360
     	$return = '<form action="courseLog.php" method="get" name="additional_profile_field_form" id="additional_profile_field_form">';
@@ -6366,8 +6366,8 @@  discard block
 block discarded – undo
6366 6366
     	$extra_fields_to_show = 0;
6367 6367
     	foreach ($extra_fields as $key=>$field) {
6368 6368
     		// show only extra fields that are visible + and can be filtered, added by J.Montoya
6369
-    		if ($field[6]==1 && $field[8] == 1) {
6370
-    			if (isset($_GET['additional_profile_field']) && $field[0] == $_GET['additional_profile_field'] ) {
6369
+    		if ($field[6] == 1 && $field[8] == 1) {
6370
+    			if (isset($_GET['additional_profile_field']) && $field[0] == $_GET['additional_profile_field']) {
6371 6371
     				$selected = 'selected="selected"';
6372 6372
     			} else {
6373 6373
     				$selected = '';
@@ -6379,8 +6379,8 @@  discard block
 block discarded – undo
6379 6379
     	$return .= '</select>';
6380 6380
 
6381 6381
     	// the form elements for the $_GET parameters (because the form is passed through GET
6382
-    	foreach ($_GET as $key=>$value){
6383
-    		if ($key <> 'additional_profile_field')    {
6382
+    	foreach ($_GET as $key=>$value) {
6383
+    		if ($key <> 'additional_profile_field') {
6384 6384
     			$return .= '<input type="hidden" name="'.Security::remove_XSS($key).'" value="'.Security::remove_XSS($value).'" />';
6385 6385
     		}
6386 6386
     	}
@@ -6417,21 +6417,21 @@  discard block
 block discarded – undo
6417 6417
     	$result_extra_field = UserManager::get_extra_field_information($field_id);
6418 6418
 
6419 6419
     	if (!empty($users)) {
6420
-    		if ($result_extra_field['field_type'] == UserManager::USER_FIELD_TYPE_TAG ) {
6421
-    			foreach($users as $user_id) {
6420
+    		if ($result_extra_field['field_type'] == UserManager::USER_FIELD_TYPE_TAG) {
6421
+    			foreach ($users as $user_id) {
6422 6422
     				$user_result = UserManager::get_user_tags($user_id, $field_id);
6423 6423
     				$tag_list = array();
6424
-    				foreach($user_result as $item) {
6424
+    				foreach ($user_result as $item) {
6425 6425
     					$tag_list[] = $item['tag'];
6426 6426
     				}
6427
-    				$return[$user_id][] = implode(', ',$tag_list);
6427
+    				$return[$user_id][] = implode(', ', $tag_list);
6428 6428
     			}
6429 6429
     		} else {
6430 6430
     			$new_user_array = array();
6431 6431
     			foreach ($users as $user_id) {
6432
-    				$new_user_array[]= "'".$user_id."'";
6432
+    				$new_user_array[] = "'".$user_id."'";
6433 6433
     			}
6434
-    			$users = implode(',',$new_user_array);
6434
+    			$users = implode(',', $new_user_array);
6435 6435
                 $extraFieldType = EntityExtraField::USER_FIELD_TYPE;
6436 6436
     			// Selecting only the necessary information NOT ALL the user list
6437 6437
     			$sql = "SELECT user.user_id, v.value
@@ -6446,7 +6446,7 @@  discard block
 block discarded – undo
6446 6446
                             user.user_id IN ($users)";
6447 6447
 
6448 6448
     			$result = Database::query($sql);
6449
-    			while($row = Database::fetch_array($result)) {
6449
+    			while ($row = Database::fetch_array($result)) {
6450 6450
     				// get option value for field type double select by id
6451 6451
     				if (!empty($row['value'])) {
6452 6452
     					if ($result_extra_field['field_type'] ==
@@ -6485,7 +6485,7 @@  discard block
 block discarded – undo
6485 6485
 
6486 6486
     public function sort_users_desc($a, $b)
6487 6487
     {
6488
-    	return strcmp( trim(api_strtolower($b[$_SESSION['tracking_column']])), trim(api_strtolower($a[$_SESSION['tracking_column']])));
6488
+    	return strcmp(trim(api_strtolower($b[$_SESSION['tracking_column']])), trim(api_strtolower($a[$_SESSION['tracking_column']])));
6489 6489
     }
6490 6490
 
6491 6491
     /**
@@ -6520,7 +6520,7 @@  discard block
 block discarded – undo
6520 6520
     	// get all users data from a course for sortable with limit
6521 6521
     	if (is_array($user_ids)) {
6522 6522
     		$user_ids = array_map('intval', $user_ids);
6523
-    		$condition_user = " WHERE user.user_id IN (".implode(',',$user_ids).") ";
6523
+    		$condition_user = " WHERE user.user_id IN (".implode(',', $user_ids).") ";
6524 6524
     	} else {
6525 6525
     		$user_ids = intval($user_ids);
6526 6526
     		$condition_user = " WHERE user.user_id = $user_ids ";
@@ -6528,7 +6528,7 @@  discard block
 block discarded – undo
6528 6528
 
6529 6529
     	if (!empty($_GET['user_keyword'])) {
6530 6530
     		$keyword = trim(Database::escape_string($_GET['user_keyword']));
6531
-    		$condition_user .=  " AND (
6531
+    		$condition_user .= " AND (
6532 6532
                 user.firstname LIKE '%".$keyword."%' OR
6533 6533
                 user.lastname LIKE '%".$keyword."%'  OR
6534 6534
                 user.username LIKE '%".$keyword."%'  OR
@@ -6546,7 +6546,7 @@  discard block
 block discarded – undo
6546 6546
         $invitedUsersCondition = '';
6547 6547
 
6548 6548
         if (!$includeInvitedUsers) {
6549
-            $invitedUsersCondition = " AND user.status != " . INVITEE;
6549
+            $invitedUsersCondition = " AND user.status != ".INVITEE;
6550 6550
         }
6551 6551
 
6552 6552
     	$sql = "SELECT  user.user_id as user_id,
@@ -6557,7 +6557,7 @@  discard block
 block discarded – undo
6557 6557
                 FROM $tbl_user as user $url_table
6558 6558
     	        $condition_user $url_condition $invitedUsersCondition";
6559 6559
 
6560
-    	if (!in_array($direction, array('ASC','DESC'))) {
6560
+    	if (!in_array($direction, array('ASC', 'DESC'))) {
6561 6561
     		$direction = 'ASC';
6562 6562
     	}
6563 6563
 
@@ -6693,7 +6693,7 @@  discard block
 block discarded – undo
6693 6693
     		}
6694 6694
 
6695 6695
             if (empty($session_id)) {
6696
-                $user['survey'] = (isset($survey_user_list[$user['user_id']]) ? $survey_user_list[$user['user_id']] : 0) .' / '.$total_surveys;
6696
+                $user['survey'] = (isset($survey_user_list[$user['user_id']]) ? $survey_user_list[$user['user_id']] : 0).' / '.$total_surveys;
6697 6697
             }
6698 6698
 
6699 6699
     		$user['link'] = '<center>
@@ -6705,37 +6705,37 @@  discard block
 block discarded – undo
6705 6705
     		// store columns in array $users
6706 6706
     		$is_western_name_order = api_is_western_name_order();
6707 6707
             $user_row = array();
6708
-            $user_row[]= $user['official_code']; //0
6708
+            $user_row[] = $user['official_code']; //0
6709 6709
             if ($is_western_name_order) {
6710
-                $user_row[]= $user['firstname'];
6711
-                $user_row[]= $user['lastname'];
6710
+                $user_row[] = $user['firstname'];
6711
+                $user_row[] = $user['lastname'];
6712 6712
             } else {
6713
-                $user_row[]= $user['lastname'];
6714
-                $user_row[]= $user['firstname'];
6713
+                $user_row[] = $user['lastname'];
6714
+                $user_row[] = $user['firstname'];
6715 6715
             }
6716
-            $user_row[]= $user['username'];
6717
-            $user_row[]= $user['time'];
6718
-            $user_row[]= $user['average_progress'];
6719
-            $user_row[]= $user['exercise_progress'];
6720
-            $user_row[]= $user['exercise_average_best_attempt'];
6721
-            $user_row[]= $user['student_score'];
6722
-            $user_row[]= $user['count_assignments'];
6723
-            $user_row[]= $user['count_messages'];
6716
+            $user_row[] = $user['username'];
6717
+            $user_row[] = $user['time'];
6718
+            $user_row[] = $user['average_progress'];
6719
+            $user_row[] = $user['exercise_progress'];
6720
+            $user_row[] = $user['exercise_average_best_attempt'];
6721
+            $user_row[] = $user['student_score'];
6722
+            $user_row[] = $user['count_assignments'];
6723
+            $user_row[] = $user['count_messages'];
6724 6724
 
6725 6725
             $userGroupManager = new UserGroup();
6726 6726
             $user_row[] = $userGroupManager->getLabelsFromNameList($user['user_id'], UserGroup::NORMAL_CLASS);
6727 6727
 
6728 6728
             if (empty($session_id)) {
6729
-                $user_row[]= $user['survey'];
6729
+                $user_row[] = $user['survey'];
6730 6730
             }
6731 6731
 
6732
-            $user_row[]= $user['first_connection'];
6733
-            $user_row[]= $user['last_connection'];
6732
+            $user_row[] = $user['first_connection'];
6733
+            $user_row[] = $user['last_connection'];
6734 6734
             if (isset($_GET['additional_profile_field']) && is_numeric($_GET['additional_profile_field'])) {
6735
-                $user_row[]= $user['additional'];
6735
+                $user_row[] = $user['additional'];
6736 6736
             }
6737 6737
 
6738
-            $user_row[]= $user['link'];
6738
+            $user_row[] = $user['link'];
6739 6739
 
6740 6740
             $users[] = $user_row;
6741 6741
 
@@ -6780,8 +6780,8 @@  discard block
 block discarded – undo
6780 6780
 
6781 6781
     	$track_access_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
6782 6782
     	$tempView = $view;
6783
-    	if(substr($view,0,1) == '1') {
6784
-    		$new_view = substr_replace($view,'0',0,1);
6783
+    	if (substr($view, 0, 1) == '1') {
6784
+    		$new_view = substr_replace($view, '0', 0, 1);
6785 6785
     		echo "
6786 6786
                 <tr>
6787 6787
                     <td valign='top'>
@@ -6814,9 +6814,9 @@  discard block
 block discarded – undo
6814 6814
                 </tr>";
6815 6815
     		$total = 0;
6816 6816
     		if (is_array($results)) {
6817
-    			for($j = 0 ; $j < count($results) ; $j++) {
6817
+    			for ($j = 0; $j < count($results); $j++) {
6818 6818
     				echo "<tr>";
6819
-    				echo "<td class='content'><a href='logins_details.php?uInfo=".$user_id."&reqdate=".$results[$j][0]."&view=".Security::remove_XSS($view)."'>".$MonthsLong[date('n', $results[$j][0])-1].' '.date('Y', $results[$j][0])."</a></td>";
6819
+    				echo "<td class='content'><a href='logins_details.php?uInfo=".$user_id."&reqdate=".$results[$j][0]."&view=".Security::remove_XSS($view)."'>".$MonthsLong[date('n', $results[$j][0]) - 1].' '.date('Y', $results[$j][0])."</a></td>";
6820 6820
     				echo "<td valign='top' align='right' class='content'>".$results[$j][1]."</td>";
6821 6821
     				echo"</tr>";
6822 6822
     				$total = $total + $results[$j][1];
@@ -6833,7 +6833,7 @@  discard block
 block discarded – undo
6833 6833
     		echo "</table>";
6834 6834
     		echo "</td></tr>";
6835 6835
     	} else {
6836
-    		$new_view = substr_replace($view,'1',0,1);
6836
+    		$new_view = substr_replace($view, '1', 0, 1);
6837 6837
     		echo "
6838 6838
                 <tr>
6839 6839
                     <td valign='top'>
@@ -6856,8 +6856,8 @@  discard block
 block discarded – undo
6856 6856
     {
6857 6857
     	global $TBL_TRACK_HOTPOTATOES, $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $dateTimeFormatLong;
6858 6858
         $courseId = api_get_course_int_id($courseCode);
6859
-    	if(substr($view,1,1) == '1') {
6860
-    		$new_view = substr_replace($view,'0',1,1);
6859
+    	if (substr($view, 1, 1) == '1') {
6860
+    		$new_view = substr_replace($view, '0', 1, 1);
6861 6861
     		echo "<tr>
6862 6862
                     <td valign='top'>
6863 6863
                         <font color='#0000FF'>-&nbsp;&nbsp;&nbsp;</font><b>".get_lang('ExercicesResults')."</b>&nbsp;&nbsp;&nbsp;[<a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."'>".get_lang('Close')."</a>]&nbsp;&nbsp;&nbsp;[<a href='userLogCSV.php?".api_get_cidreq()."&uInfo=".Security::remove_XSS($_GET['uInfo'])."&view=01000'>".get_lang('ExportAsCSV')."</a>]
@@ -6899,7 +6899,7 @@  discard block
 block discarded – undo
6899 6899
                 </tr>";
6900 6900
 
6901 6901
     		if (is_array($results)) {
6902
-    			for($i = 0; $i < sizeof($results); $i++) {
6902
+    			for ($i = 0; $i < sizeof($results); $i++) {
6903 6903
     				$display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get());
6904 6904
     				echo "<tr>\n";
6905 6905
     				echo "<td class='content'>".$results[$i][0]."</td>\n";
@@ -6914,8 +6914,8 @@  discard block
 block discarded – undo
6914 6914
 
6915 6915
     		// The Result of Tests
6916 6916
     		if (is_array($hpresults)) {
6917
-    			for($i = 0; $i < sizeof($hpresults); $i++) {
6918
-    				$title = GetQuizName($hpresults[$i][0],'');
6917
+    			for ($i = 0; $i < sizeof($hpresults); $i++) {
6918
+    				$title = GetQuizName($hpresults[$i][0], '');
6919 6919
     				if ($title == '')
6920 6920
     				$title = basename($hpresults[$i][0]);
6921 6921
     				$display_date = api_convert_and_format_date($hpresults[$i][3], null, date_default_timezone_get());
@@ -6941,7 +6941,7 @@  discard block
 block discarded – undo
6941 6941
     		echo "</table>";
6942 6942
     		echo "</td>\n</tr>\n";
6943 6943
     	} else {
6944
-    		$new_view = substr_replace($view,'1',1,1);
6944
+    		$new_view = substr_replace($view, '1', 1, 1);
6945 6945
     		echo "
6946 6946
                 <tr>
6947 6947
                     <td valign='top'>
@@ -6960,8 +6960,8 @@  discard block
 block discarded – undo
6960 6960
     	global $TABLETRACK_UPLOADS, $TABLECOURSE_WORK;
6961 6961
         $_course = api_get_course_info_by_id($course_id);
6962 6962
 
6963
-    	if (substr($view,2,1) == '1') {
6964
-    		$new_view = substr_replace($view,'0',2,1);
6963
+    	if (substr($view, 2, 1) == '1') {
6964
+    		$new_view = substr_replace($view, '0', 2, 1);
6965 6965
     		echo "<tr>
6966 6966
                     <td valign='top'>
6967 6967
                     <font color='#0000FF'>-&nbsp;&nbsp;&nbsp;</font><b>".get_lang('WorkUploads')."</b>&nbsp;&nbsp;&nbsp;[<a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."'>".get_lang('Close')."</a>]&nbsp;&nbsp;&nbsp;[<a href='userLogCSV.php?".api_get_cidreq()."&uInfo=".Security::remove_XSS($_GET['uInfo'])."&view=00100'>".get_lang('ExportAsCSV')."</a>]
@@ -6975,7 +6975,7 @@  discard block
 block discarded – undo
6975 6975
                         AND u.c_id = '".intval($course_id)."'
6976 6976
                     ORDER BY u.upload_date DESC";
6977 6977
     		echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6978
-    		$results = StatsUtils::getManyResultsXCol($sql,4);
6978
+    		$results = StatsUtils::getManyResultsXCol($sql, 4);
6979 6979
     		echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
6980 6980
     		echo "<tr>
6981 6981
                     <td class='secLine' width='40%'>
@@ -6989,7 +6989,7 @@  discard block
 block discarded – undo
6989 6989
                     </td>
6990 6990
                 </tr>";
6991 6991
     		if (is_array($results)) {
6992
-    			for($j = 0 ; $j < count($results) ; $j++) {
6992
+    			for ($j = 0; $j < count($results); $j++) {
6993 6993
     				$pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3];
6994 6994
     				$beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get());
6995 6995
     				echo "<tr>";
@@ -7008,7 +7008,7 @@  discard block
 block discarded – undo
7008 7008
     		echo "</table>";
7009 7009
     		echo "</td></tr>";
7010 7010
     	} else {
7011
-    		$new_view = substr_replace($view,'1',2,1);
7011
+    		$new_view = substr_replace($view, '1', 2, 1);
7012 7012
     		echo "
7013 7013
                 <tr>
7014 7014
                     <td valign='top'>
@@ -7027,8 +7027,8 @@  discard block
 block discarded – undo
7027 7027
     {
7028 7028
     	global $TABLETRACK_LINKS, $TABLECOURSE_LINKS;
7029 7029
         $courseId = api_get_course_int_id($courseCode);
7030
-    	if (substr($view,3,1) == '1') {
7031
-    		$new_view = substr_replace($view,'0',3,1);
7030
+    	if (substr($view, 3, 1) == '1') {
7031
+    		$new_view = substr_replace($view, '0', 3, 1);
7032 7032
     		echo "
7033 7033
                 <tr>
7034 7034
                         <td valign='top'>
@@ -7052,7 +7052,7 @@  discard block
 block discarded – undo
7052 7052
                     </td>
7053 7053
                 </tr>";
7054 7054
     		if (is_array($results)) {
7055
-    			for($j = 0 ; $j < count($results) ; $j++) {
7055
+    			for ($j = 0; $j < count($results); $j++) {
7056 7056
     				echo "<tr>";
7057 7057
     				echo "<td class='content'><a href='".$results[$j][1]."'>".$results[$j][0]."</a></td>";
7058 7058
     				echo"</tr>";
@@ -7065,7 +7065,7 @@  discard block
 block discarded – undo
7065 7065
     		echo "</table>";
7066 7066
     		echo "</td></tr>";
7067 7067
     	} else {
7068
-    		$new_view = substr_replace($view,'1',3,1);
7068
+    		$new_view = substr_replace($view, '1', 3, 1);
7069 7069
     		echo "
7070 7070
                 <tr>
7071 7071
                     <td valign='top'>
@@ -7092,8 +7092,8 @@  discard block
 block discarded – undo
7092 7092
     	$session_id = intval($session_id);
7093 7093
 
7094 7094
     	$downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
7095
-    	if(substr($view,4,1) == '1') {
7096
-    		$new_view = substr_replace($view,'0',4,1);
7095
+    	if (substr($view, 4, 1) == '1') {
7096
+    		$new_view = substr_replace($view, '0', 4, 1);
7097 7097
     		echo "
7098 7098
                 <tr>
7099 7099
                     <td valign='top'>
@@ -7119,7 +7119,7 @@  discard block
 block discarded – undo
7119 7119
                     </td>
7120 7120
                 </tr>";
7121 7121
     		if (is_array($results)) {
7122
-    			for($j = 0 ; $j < count($results) ; $j++) {
7122
+    			for ($j = 0; $j < count($results); $j++) {
7123 7123
     				echo "<tr>";
7124 7124
     				echo "<td class='content'>".$results[$j]."</td>";
7125 7125
     				echo"</tr>";
@@ -7132,7 +7132,7 @@  discard block
 block discarded – undo
7132 7132
     		echo "</table>";
7133 7133
     		echo "</td></tr>";
7134 7134
     	} else {
7135
-    		$new_view = substr_replace($view,'1',4,1);
7135
+    		$new_view = substr_replace($view, '1', 4, 1);
7136 7136
     		echo "
7137 7137
                 <tr>
7138 7138
                     <td valign='top'>
@@ -7166,11 +7166,11 @@  discard block
 block discarded – undo
7166 7166
                    ORDER BY login_date DESC LIMIT 1";
7167 7167
         $ip = '';
7168 7168
         $res_ip = Database::query($sql_ip);
7169
-        if ($res_ip !== false && Database::num_rows($res_ip)>0) {
7169
+        if ($res_ip !== false && Database::num_rows($res_ip) > 0) {
7170 7170
             $row_ip = Database::fetch_row($res_ip);
7171 7171
             if ($return_as_link) {
7172 7172
                 $ip = Display::url(
7173
-                    (empty($body_replace)?$row_ip[1]:$body_replace), 'http://www.whatsmyip.org/ip-geo-location/?ip='.$row_ip[1],
7173
+                    (empty($body_replace) ? $row_ip[1] : $body_replace), 'http://www.whatsmyip.org/ip-geo-location/?ip='.$row_ip[1],
7174 7174
                     array('title'=>get_lang('TraceIP'), 'target'=>'_blank')
7175 7175
                 );
7176 7176
             } else {
@@ -7206,9 +7206,9 @@  discard block
 block discarded – undo
7206 7206
     	$course_id  = intval($course_id);
7207 7207
 
7208 7208
     	$tempView = $view;
7209
-    	if (substr($view,0,1) == '1') {
7210
-    		$new_view = substr_replace($view,'0',0,1);
7211
-    		$title[1]= get_lang('LoginsAndAccessTools').get_lang('LoginsDetails');
7209
+    	if (substr($view, 0, 1) == '1') {
7210
+    		$new_view = substr_replace($view, '0', 0, 1);
7211
+    		$title[1] = get_lang('LoginsAndAccessTools').get_lang('LoginsDetails');
7212 7212
     		$sql = "SELECT UNIX_TIMESTAMP(access_date), count(access_date)
7213 7213
                     FROM $track_access_table
7214 7214
                     WHERE access_user_id = $user_id
@@ -7218,20 +7218,20 @@  discard block
 block discarded – undo
7218 7218
                     ORDER BY YEAR(access_date),MONTH(access_date) ASC";
7219 7219
     		//$results = getManyResults2Col($sql);
7220 7220
     		$results = getManyResults3Col($sql);
7221
-    		$title_line= get_lang('LoginsTitleMonthColumn').';'.get_lang('LoginsTitleCountColumn')."\n";
7222
-    		$line='';
7221
+    		$title_line = get_lang('LoginsTitleMonthColumn').';'.get_lang('LoginsTitleCountColumn')."\n";
7222
+    		$line = '';
7223 7223
     		$total = 0;
7224 7224
     		if (is_array($results)) {
7225
-    			for($j = 0 ; $j < count($results) ; $j++) {
7225
+    			for ($j = 0; $j < count($results); $j++) {
7226 7226
     				$line .= $results[$j][0].';'.$results[$j][1]."\n";
7227 7227
     				$total = $total + $results[$j][1];
7228 7228
     			}
7229 7229
     			$line .= get_lang('Total').";".$total."\n";
7230 7230
     		} else {
7231
-    			$line= get_lang('NoResult')."</center></td>";
7231
+    			$line = get_lang('NoResult')."</center></td>";
7232 7232
     		}
7233 7233
     	} else {
7234
-    		$new_view = substr_replace($view,'1',0,1);
7234
+    		$new_view = substr_replace($view, '1', 0, 1);
7235 7235
     	}
7236 7236
     	return array($title_line, $line);
7237 7237
     }
@@ -7249,8 +7249,8 @@  discard block
 block discarded – undo
7249 7249
     	global $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $TABLETRACK_HOTPOTATOES, $dateTimeFormatLong;
7250 7250
         $courseId = api_get_course_int_id($courseCode);
7251 7251
         $userId = intval($userId);
7252
-    	if (substr($view,1,1) == '1') {
7253
-    		$new_view = substr_replace($view,'0',1,1);
7252
+    	if (substr($view, 1, 1) == '1') {
7253
+    		$new_view = substr_replace($view, '0', 1, 1);
7254 7254
     		$title[1] = get_lang('ExercicesDetails');
7255 7255
     		$line = '';
7256 7256
     		$sql = "SELECT ce.title, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
@@ -7274,7 +7274,7 @@  discard block
 block discarded – undo
7274 7274
     		$title_line = get_lang('ExercicesTitleExerciceColumn').";".get_lang('Date').';'.get_lang('ExercicesTitleScoreColumn')."\n";
7275 7275
 
7276 7276
     		if (is_array($results)) {
7277
-    			for($i = 0; $i < sizeof($results); $i++)
7277
+    			for ($i = 0; $i < sizeof($results); $i++)
7278 7278
     			{
7279 7279
     				$display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get());
7280 7280
     				$line .= $results[$i][0].";".$display_date.";".$results[$i][1]." / ".$results[$i][2]."\n";
@@ -7286,8 +7286,8 @@  discard block
 block discarded – undo
7286 7286
 
7287 7287
     		// The Result of Tests
7288 7288
     		if (is_array($hpresults)) {
7289
-    			for($i = 0; $i < sizeof($hpresults); $i++) {
7290
-    				$title = GetQuizName($hpresults[$i][0],'');
7289
+    			for ($i = 0; $i < sizeof($hpresults); $i++) {
7290
+    				$title = GetQuizName($hpresults[$i][0], '');
7291 7291
 
7292 7292
     				if ($title == '')
7293 7293
     				$title = basename($hpresults[$i][0]);
@@ -7301,10 +7301,10 @@  discard block
 block discarded – undo
7301 7301
     		}
7302 7302
 
7303 7303
     		if ($NoTestRes == 1 && $NoHPTestRes == 1) {
7304
-    			$line=get_lang('NoResult');
7304
+    			$line = get_lang('NoResult');
7305 7305
     		}
7306 7306
     	} else {
7307
-    		$new_view = substr_replace($view,'1',1,1);
7307
+    		$new_view = substr_replace($view, '1', 1, 1);
7308 7308
     	}
7309 7309
     	return array($title_line, $line);
7310 7310
     }
@@ -7320,7 +7320,7 @@  discard block
 block discarded – undo
7320 7320
         $user_id = intval($user_id);
7321 7321
         $course_id = intval($course_id);
7322 7322
 
7323
-    	if (substr($view,2,1) == '1') {
7323
+    	if (substr($view, 2, 1) == '1') {
7324 7324
     		$sql = "SELECT u.upload_date, w.title, w.author, w.url
7325 7325
                     FROM $TABLETRACK_UPLOADS u , $TABLECOURSE_WORK w
7326 7326
                     WHERE
@@ -7328,21 +7328,21 @@  discard block
 block discarded – undo
7328 7328
                         u.upload_user_id = '$user_id' AND
7329 7329
                         u.c_id = '$course_id'
7330 7330
                     ORDER BY u.upload_date DESC";
7331
-    		$results = StatsUtils::getManyResultsXCol($sql,4);
7331
+    		$results = StatsUtils::getManyResultsXCol($sql, 4);
7332 7332
 
7333
-    		$title[1]=get_lang('WorksDetails');
7334
-    		$line='';
7335
-    		$title_line=get_lang('WorkTitle').";".get_lang('WorkAuthors').";".get_lang('Date')."\n";
7333
+    		$title[1] = get_lang('WorksDetails');
7334
+    		$line = '';
7335
+    		$title_line = get_lang('WorkTitle').";".get_lang('WorkAuthors').";".get_lang('Date')."\n";
7336 7336
 
7337 7337
     		if (is_array($results)) {
7338
-    			for($j = 0 ; $j < count($results) ; $j++) {
7338
+    			for ($j = 0; $j < count($results); $j++) {
7339 7339
     				$pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3];
7340 7340
     				$beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get());
7341 7341
     				$line .= $results[$j][1].";".$results[$j][2].";".$beautifulDate."\n";
7342 7342
     			}
7343 7343
 
7344 7344
     		} else {
7345
-    			$line= get_lang('NoResult');
7345
+    			$line = get_lang('NoResult');
7346 7346
     		}
7347 7347
     	}
7348 7348
     	return array($title_line, $line);
@@ -7358,9 +7358,9 @@  discard block
 block discarded – undo
7358 7358
         $courseId = api_get_course_int_id($courseCode);
7359 7359
         $userId = intval($userId);
7360 7360
         $line = null;
7361
-    	if (substr($view,3,1) == '1') {
7362
-    		$new_view = substr_replace($view,'0',3,1);
7363
-    		$title[1]=get_lang('LinksDetails');
7361
+    	if (substr($view, 3, 1) == '1') {
7362
+    		$new_view = substr_replace($view, '0', 3, 1);
7363
+    		$title[1] = get_lang('LinksDetails');
7364 7364
     		$sql = "SELECT cl.title, cl.url
7365 7365
                         FROM $TABLETRACK_LINKS AS sl, $TABLECOURSE_LINKS AS cl
7366 7366
                         WHERE sl.links_link_id = cl.id
@@ -7368,16 +7368,16 @@  discard block
 block discarded – undo
7368 7368
                             AND sl.links_user_id = $userId
7369 7369
                         GROUP BY cl.title, cl.url";
7370 7370
     		$results = StatsUtils::getManyResults2Col($sql);
7371
-    		$title_line= get_lang('LinksTitleLinkColumn')."\n";
7371
+    		$title_line = get_lang('LinksTitleLinkColumn')."\n";
7372 7372
     		if (is_array($results)) {
7373
-    			for ($j = 0 ; $j < count($results) ; $j++) {
7373
+    			for ($j = 0; $j < count($results); $j++) {
7374 7374
     				$line .= $results[$j][0]."\n";
7375 7375
     			}
7376 7376
     		} else {
7377
-    			$line=get_lang('NoResult');
7377
+    			$line = get_lang('NoResult');
7378 7378
     		}
7379 7379
     	} else {
7380
-    		$new_view = substr_replace($view,'1',3,1);
7380
+    		$new_view = substr_replace($view, '1', 3, 1);
7381 7381
     	}
7382 7382
     	return array($title_line, $line);
7383 7383
     }
@@ -7399,9 +7399,9 @@  discard block
 block discarded – undo
7399 7399
 
7400 7400
     	$downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
7401 7401
 
7402
-    	if (substr($view,4,1) == '1') {
7403
-    		$new_view = substr_replace($view,'0',4,1);
7404
-    		$title[1]= get_lang('DocumentsDetails');
7402
+    	if (substr($view, 4, 1) == '1') {
7403
+    		$new_view = substr_replace($view, '0', 4, 1);
7404
+    		$title[1] = get_lang('DocumentsDetails');
7405 7405
 
7406 7406
     		$sql = "SELECT down_doc_path
7407 7407
                         FROM $downloads_table
@@ -7414,14 +7414,14 @@  discard block
 block discarded – undo
7414 7414
     		$title_line = get_lang('DocumentsTitleDocumentColumn')."\n";
7415 7415
             $line = null;
7416 7416
     		if (is_array($results)) {
7417
-    			for ($j = 0 ; $j < count($results) ; $j++) {
7417
+    			for ($j = 0; $j < count($results); $j++) {
7418 7418
     				$line .= $results[$j]."\n";
7419 7419
     			}
7420 7420
     		} else {
7421 7421
     			$line = get_lang('NoResult');
7422 7422
     		}
7423 7423
     	} else {
7424
-    		$new_view = substr_replace($view,'1',4,1);
7424
+    		$new_view = substr_replace($view, '1', 4, 1);
7425 7425
     	}
7426 7426
     	return array($title_line, $line);
7427 7427
     }
Please login to merge, or discard this patch.
main/inc/lib/fileUpload.lib.php 2 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -993,7 +993,9 @@
 block discarded – undo
993 993
                     if ($file != '.' && $file != '..') {
994 994
 
995 995
                         $filetype = 'file';
996
-                        if (is_dir($base_work_dir.$upload_path.'/'.$file)) $filetype = 'folder';
996
+                        if (is_dir($base_work_dir.$upload_path.'/'.$file)) {
997
+                            $filetype = 'folder';
998
+                        }
997 999
 
998 1000
                         $safe_file = api_replace_dangerous_char($file, 'strict');
999 1001
                         @rename($base_work_dir.$upload_path.'/'.$file,$base_work_dir.$upload_path.'/'.$safe_file);
Please login to merge, or discard this patch.
Spacing   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
                 // (e.g. image upload in html editor).
90 90
                 $max_file_size = intval($_POST['MAX_FILE_SIZE']);
91 91
                 if ($show_output) {
92
-                    Display::display_error_message(get_lang('UplExceedMaxPostSize'). format_file_size($max_file_size));
92
+                    Display::display_error_message(get_lang('UplExceedMaxPostSize').format_file_size($max_file_size));
93 93
                 }
94 94
 
95 95
                 return false;
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
             case 4:
104 104
                 // No file was uploaded.
105 105
                 if ($show_output) {
106
-                    Display::display_error_message(get_lang('UplNoFileUploaded').' '. get_lang('UplSelectFileFirst'));
106
+                    Display::display_error_message(get_lang('UplNoFileUploaded').' '.get_lang('UplSelectFileFirst'));
107 107
                 }
108 108
 
109 109
                 return false;
@@ -447,7 +447,7 @@  discard block
 block discarded – undo
447 447
                             if ($output) {
448 448
                                 Display::addFlash(
449 449
                                     Display::return_message(
450
-                                        get_lang('UplUploadSucceeded') . '<br /> ' . $documentTitle . ' ' . get_lang('UplFileOverwritten'),
450
+                                        get_lang('UplUploadSucceeded').'<br /> '.$documentTitle.' '.get_lang('UplFileOverwritten'),
451 451
                                         'confirmation',
452 452
                                         false
453 453
                                     )
@@ -586,14 +586,14 @@  discard block
 block discarded – undo
586 586
                             if (isset($_POST['moodle_import'])) {
587 587
                                 Display::addFlash(
588 588
                                     Display::display_confirmation_message(
589
-                                        get_lang('UplUploadSucceeded') . '<br />' . get_lang('UplFileSavedAs') . ' ' . $documentTitle,
589
+                                        get_lang('UplUploadSucceeded').'<br />'.get_lang('UplFileSavedAs').' '.$documentTitle,
590 590
                                         false,
591 591
                                         true
592 592
                                     )
593 593
                                 );
594 594
                             } else {
595 595
                                 Display::display_confirmation_message(
596
-                                    get_lang('UplUploadSucceeded') . '<br />' . get_lang('UplFileSavedAs') . ' ' . $documentTitle,
596
+                                    get_lang('UplUploadSucceeded').'<br />'.get_lang('UplFileSavedAs').' '.$documentTitle,
597 597
                                     false
598 598
                                 );
599 599
                             }
@@ -670,7 +670,7 @@  discard block
 block discarded – undo
670 670
                                 if (isset($_POST['moodle_import'])) {
671 671
                                     Display::addFlash(
672 672
                                         Display::display_confirmation_message(
673
-                                            get_lang('UplUploadSucceeded') . '<br /> ' . $documentTitle,
673
+                                            get_lang('UplUploadSucceeded').'<br /> '.$documentTitle,
674 674
                                             false,
675 675
                                             true
676 676
                                         )
@@ -765,12 +765,12 @@  discard block
 block discarded – undo
765 765
 function dir_total_space($dir_path)
766 766
 {
767 767
     $save_dir = getcwd();
768
-    chdir($dir_path) ;
768
+    chdir($dir_path);
769 769
     $handle = opendir($dir_path);
770 770
     $sumSize = 0;
771 771
     $dirList = array();
772 772
     while ($element = readdir($handle)) {
773
-        if ( $element == '.' || $element == '..') {
773
+        if ($element == '.' || $element == '..') {
774 774
             continue; // Skip the current and parent directories
775 775
         }
776 776
         if (is_file($element)) {
@@ -781,11 +781,11 @@  discard block
 block discarded – undo
781 781
         }
782 782
     }
783 783
 
784
-    closedir($handle) ;
784
+    closedir($handle);
785 785
 
786 786
     if (sizeof($dirList) > 0) {
787 787
         foreach ($dirList as $j) {
788
-            $sizeDir = dir_total_space($j);	// Recursivity
788
+            $sizeDir = dir_total_space($j); // Recursivity
789 789
             $sumSize += $sizeDir;
790 790
         }
791 791
     }
@@ -819,63 +819,63 @@  discard block
 block discarded – undo
819 819
 
820 820
         static $mime_type = array();
821 821
 
822
-        $mime_type[] = 'application/msword';             $extension[] = '.doc';
823
-        $mime_type[] = 'application/rtf';                $extension[] = '.rtf';
824
-        $mime_type[] = 'application/vnd.ms-powerpoint';  $extension[] = '.ppt';
825
-        $mime_type[] = 'application/vnd.ms-excel';       $extension[] = '.xls';
826
-        $mime_type[] = 'application/pdf';                $extension[] = '.pdf';
827
-        $mime_type[] = 'application/postscript';         $extension[] = '.ps';
828
-        $mime_type[] = 'application/mac-binhex40';       $extension[] = '.hqx';
829
-        $mime_type[] = 'application/x-gzip';             $extension[] = 'tar.gz';
830
-        $mime_type[] = 'application/x-shockwave-flash';  $extension[] = '.swf';
831
-        $mime_type[] = 'application/x-stuffit';          $extension[] = '.sit';
832
-        $mime_type[] = 'application/x-tar';              $extension[] = '.tar';
833
-        $mime_type[] = 'application/zip';                $extension[] = '.zip';
834
-        $mime_type[] = 'application/x-tar';              $extension[] = '.tar';
835
-        $mime_type[] = 'text/html';                      $extension[] = '.html';
836
-        $mime_type[] = 'text/plain';                     $extension[] = '.txt';
837
-        $mime_type[] = 'text/rtf';                       $extension[] = '.rtf';
838
-        $mime_type[] = 'img/gif';                        $extension[] = '.gif';
839
-        $mime_type[] = 'img/jpeg';                       $extension[] = '.jpg';
840
-        $mime_type[] = 'img/png';                        $extension[] = '.png';
841
-        $mime_type[] = 'audio/midi';                     $extension[] = '.mid';
842
-        $mime_type[] = 'audio/mpeg';                     $extension[] = '.mp3';
843
-        $mime_type[] = 'audio/x-aiff';                   $extension[] = '.aif';
844
-        $mime_type[] = 'audio/x-pn-realaudio';           $extension[] = '.rm';
845
-        $mime_type[] = 'audio/x-pn-realaudio-plugin';    $extension[] = '.rpm';
846
-        $mime_type[] = 'audio/x-wav';                    $extension[] = '.wav';
847
-        $mime_type[] = 'video/mpeg';                     $extension[] = '.mpg';
848
-        $mime_type[] = 'video/mpeg4-generic';            $extension[] = '.mp4';
849
-        $mime_type[] = 'video/quicktime';                $extension[] = '.mov';
850
-        $mime_type[] = 'video/x-msvideo';                $extension[] = '.avi';
851
-
852
-        $mime_type[] = 'video/x-ms-wmv';                 $extension[] = '.wmv';
853
-        $mime_type[] = 'video/x-flv';                    $extension[] = '.flv';
854
-        $mime_type[] = 'image/svg+xml';                  $extension[] = '.svg';
855
-        $mime_type[] = 'image/svg+xml';                  $extension[] = '.svgz';
856
-        $mime_type[] = 'video/ogg';                  	 $extension[] = '.ogv';
857
-        $mime_type[] = 'audio/ogg';                  	 $extension[] = '.oga';
858
-        $mime_type[] = 'application/ogg';                $extension[] = '.ogg';
859
-        $mime_type[] = 'application/ogg';                $extension[] = '.ogx';
860
-        $mime_type[] = 'application/x-freemind';         $extension[] = '.mm';
861
-
862
-        $mime_type[] = 'application/vnd.ms-word.document.macroEnabled.12';							$extension[] = '.docm';
863
-        $mime_type[] = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';	$extension[] = '.docx';
864
-        $mime_type[] = 'application/vnd.ms-word.template.macroEnabled.12';							$extension[] = '.dotm';
865
-        $mime_type[] = 'application/vnd.openxmlformats-officedocument.wordprocessingml.template';	$extension[] = '.dotx';
866
-        $mime_type[] = 'application/vnd.ms-powerpoint.template.macroEnabled.12';					$extension[] = '.potm';
867
-        $mime_type[] = 'application/vnd.openxmlformats-officedocument.presentationml.template';		$extension[] = '.potx';
868
-        $mime_type[] = 'application/vnd.ms-powerpoint.addin.macroEnabled.12';						$extension[] = '.ppam';
869
-        $mime_type[] = 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12';					$extension[] = '.ppsm';
870
-        $mime_type[] = 'application/vnd.openxmlformats-officedocument.presentationml.slideshow';	$extension[] = '.ppsx';
871
-        $mime_type[] = 'application/vnd.ms-powerpoint.presentation.macroEnabled.12';				$extension[] = '.pptm';
872
-        $mime_type[] = 'application/vnd.openxmlformats-officedocument.presentationml.presentation';	$extension[] = '.pptx';
873
-        $mime_type[] = 'application/vnd.ms-excel.addin.macroEnabled.12';							$extension[] = '.xlam';
874
-        $mime_type[] = 'application/vnd.ms-excel.sheet.binary.macroEnabled.12';						$extension[] = '.xlsb';
875
-        $mime_type[] = 'application/vnd.ms-excel.sheet.macroEnabled.12';							$extension[] = '.xlsm';
876
-        $mime_type[] = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';			$extension[] = '.xlsx';
877
-        $mime_type[] = 'application/vnd.ms-excel.template.macroEnabled.12';							$extension[] = '.xltm';
878
-        $mime_type[] = 'application/vnd.openxmlformats-officedocument.spreadsheetml.template';		$extension[] = '.xltx';
822
+        $mime_type[] = 'application/msword'; $extension[] = '.doc';
823
+        $mime_type[] = 'application/rtf'; $extension[] = '.rtf';
824
+        $mime_type[] = 'application/vnd.ms-powerpoint'; $extension[] = '.ppt';
825
+        $mime_type[] = 'application/vnd.ms-excel'; $extension[] = '.xls';
826
+        $mime_type[] = 'application/pdf'; $extension[] = '.pdf';
827
+        $mime_type[] = 'application/postscript'; $extension[] = '.ps';
828
+        $mime_type[] = 'application/mac-binhex40'; $extension[] = '.hqx';
829
+        $mime_type[] = 'application/x-gzip'; $extension[] = 'tar.gz';
830
+        $mime_type[] = 'application/x-shockwave-flash'; $extension[] = '.swf';
831
+        $mime_type[] = 'application/x-stuffit'; $extension[] = '.sit';
832
+        $mime_type[] = 'application/x-tar'; $extension[] = '.tar';
833
+        $mime_type[] = 'application/zip'; $extension[] = '.zip';
834
+        $mime_type[] = 'application/x-tar'; $extension[] = '.tar';
835
+        $mime_type[] = 'text/html'; $extension[] = '.html';
836
+        $mime_type[] = 'text/plain'; $extension[] = '.txt';
837
+        $mime_type[] = 'text/rtf'; $extension[] = '.rtf';
838
+        $mime_type[] = 'img/gif'; $extension[] = '.gif';
839
+        $mime_type[] = 'img/jpeg'; $extension[] = '.jpg';
840
+        $mime_type[] = 'img/png'; $extension[] = '.png';
841
+        $mime_type[] = 'audio/midi'; $extension[] = '.mid';
842
+        $mime_type[] = 'audio/mpeg'; $extension[] = '.mp3';
843
+        $mime_type[] = 'audio/x-aiff'; $extension[] = '.aif';
844
+        $mime_type[] = 'audio/x-pn-realaudio'; $extension[] = '.rm';
845
+        $mime_type[] = 'audio/x-pn-realaudio-plugin'; $extension[] = '.rpm';
846
+        $mime_type[] = 'audio/x-wav'; $extension[] = '.wav';
847
+        $mime_type[] = 'video/mpeg'; $extension[] = '.mpg';
848
+        $mime_type[] = 'video/mpeg4-generic'; $extension[] = '.mp4';
849
+        $mime_type[] = 'video/quicktime'; $extension[] = '.mov';
850
+        $mime_type[] = 'video/x-msvideo'; $extension[] = '.avi';
851
+
852
+        $mime_type[] = 'video/x-ms-wmv'; $extension[] = '.wmv';
853
+        $mime_type[] = 'video/x-flv'; $extension[] = '.flv';
854
+        $mime_type[] = 'image/svg+xml'; $extension[] = '.svg';
855
+        $mime_type[] = 'image/svg+xml'; $extension[] = '.svgz';
856
+        $mime_type[] = 'video/ogg'; $extension[] = '.ogv';
857
+        $mime_type[] = 'audio/ogg'; $extension[] = '.oga';
858
+        $mime_type[] = 'application/ogg'; $extension[] = '.ogg';
859
+        $mime_type[] = 'application/ogg'; $extension[] = '.ogx';
860
+        $mime_type[] = 'application/x-freemind'; $extension[] = '.mm';
861
+
862
+        $mime_type[] = 'application/vnd.ms-word.document.macroEnabled.12'; $extension[] = '.docm';
863
+        $mime_type[] = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'; $extension[] = '.docx';
864
+        $mime_type[] = 'application/vnd.ms-word.template.macroEnabled.12'; $extension[] = '.dotm';
865
+        $mime_type[] = 'application/vnd.openxmlformats-officedocument.wordprocessingml.template'; $extension[] = '.dotx';
866
+        $mime_type[] = 'application/vnd.ms-powerpoint.template.macroEnabled.12'; $extension[] = '.potm';
867
+        $mime_type[] = 'application/vnd.openxmlformats-officedocument.presentationml.template'; $extension[] = '.potx';
868
+        $mime_type[] = 'application/vnd.ms-powerpoint.addin.macroEnabled.12'; $extension[] = '.ppam';
869
+        $mime_type[] = 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12'; $extension[] = '.ppsm';
870
+        $mime_type[] = 'application/vnd.openxmlformats-officedocument.presentationml.slideshow'; $extension[] = '.ppsx';
871
+        $mime_type[] = 'application/vnd.ms-powerpoint.presentation.macroEnabled.12'; $extension[] = '.pptm';
872
+        $mime_type[] = 'application/vnd.openxmlformats-officedocument.presentationml.presentation'; $extension[] = '.pptx';
873
+        $mime_type[] = 'application/vnd.ms-excel.addin.macroEnabled.12'; $extension[] = '.xlam';
874
+        $mime_type[] = 'application/vnd.ms-excel.sheet.binary.macroEnabled.12'; $extension[] = '.xlsb';
875
+        $mime_type[] = 'application/vnd.ms-excel.sheet.macroEnabled.12'; $extension[] = '.xlsm';
876
+        $mime_type[] = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'; $extension[] = '.xlsx';
877
+        $mime_type[] = 'application/vnd.ms-excel.template.macroEnabled.12'; $extension[] = '.xltm';
878
+        $mime_type[] = 'application/vnd.openxmlformats-officedocument.spreadsheetml.template'; $extension[] = '.xltx';
879 879
 
880 880
         // Test on PC (files with no extension get application/octet-stream)
881 881
         //$mime_type[] = 'application/octet-stream';      $extension[] = '.ext';
@@ -884,7 +884,7 @@  discard block
 block discarded – undo
884 884
 
885 885
         foreach ($mime_type as $key => & $type) {
886 886
             if ($type == $file_type) {
887
-                $file_name .=  $extension[$key];
887
+                $file_name .= $extension[$key];
888 888
                 break;
889 889
             }
890 890
         }
@@ -960,12 +960,12 @@  discard block
 block discarded – undo
960 960
         }
961 961
 
962 962
         // It happens on Linux that $upload_path sometimes doesn't start with '/'
963
-        if ($upload_path[0] != '/' && substr($base_work_dir,-1,1) != '/') {
963
+        if ($upload_path[0] != '/' && substr($base_work_dir, -1, 1) != '/') {
964 964
             $upload_path = '/'.$upload_path;
965 965
         }
966 966
 
967 967
         if ($upload_path[strlen($upload_path) - 1] == '/') {
968
-            $upload_path=substr($upload_path, 0, -1);
968
+            $upload_path = substr($upload_path, 0, -1);
969 969
         }
970 970
 
971 971
         /*	Uncompressing phase */
@@ -977,15 +977,15 @@  discard block
 block discarded – undo
977 977
             - add it to the database
978 978
             - parse & change relative html links
979 979
         */
980
-        if (PHP_OS == 'Linux' && ! get_cfg_var('safe_mode') && false) { // *** UGent, changed by OC ***
980
+        if (PHP_OS == 'Linux' && !get_cfg_var('safe_mode') && false) { // *** UGent, changed by OC ***
981 981
             // Shell Method - if this is possible, it gains some speed
982
-            exec("unzip -d \"".$base_work_dir.$upload_path."/\"".$uploaded_file['name']." " .$uploaded_file['tmp_name']);
982
+            exec("unzip -d \"".$base_work_dir.$upload_path."/\"".$uploaded_file['name']." ".$uploaded_file['tmp_name']);
983 983
         } else {
984 984
             // PHP method - slower...
985 985
             $save_dir = getcwd();
986 986
             chdir($base_work_dir.$upload_path);
987 987
             $unzippingState = $zip_file->extract();
988
-            for ($j=0; $j < count($unzippingState); $j++) {
988
+            for ($j = 0; $j < count($unzippingState); $j++) {
989 989
                 $state = $unzippingState[$j];
990 990
 
991 991
                 // Fix relative links in html files
@@ -999,8 +999,8 @@  discard block
 block discarded – undo
999 999
                         if (is_dir($base_work_dir.$upload_path.'/'.$file)) $filetype = 'folder';
1000 1000
 
1001 1001
                         $safe_file = api_replace_dangerous_char($file);
1002
-                        @rename($base_work_dir.$upload_path.'/'.$file,$base_work_dir.$upload_path.'/'.$safe_file);
1003
-                        set_default_settings($upload_path, $safe_file,$filetype);
1002
+                        @rename($base_work_dir.$upload_path.'/'.$file, $base_work_dir.$upload_path.'/'.$safe_file);
1003
+                        set_default_settings($upload_path, $safe_file, $filetype);
1004 1004
                     }
1005 1005
                 }
1006 1006
 
@@ -1050,7 +1050,7 @@  discard block
 block discarded – undo
1050 1050
     $zip = new PclZip($uploaded_file['tmp_name']);
1051 1051
 
1052 1052
     // Check the zip content (real size and file extension)
1053
-    $zip_content_array = (array)$zip->listContent();
1053
+    $zip_content_array = (array) $zip->listContent();
1054 1054
 
1055 1055
     $realSize = 0;
1056 1056
     foreach ($zip_content_array as & $this_content) {
@@ -1152,7 +1152,7 @@  discard block
 block discarded – undo
1152 1152
 function filter_extension(&$filename)
1153 1153
 {
1154 1154
     if (substr($filename, -1) == '/') {
1155
-        return 1;  // Authorize directories
1155
+        return 1; // Authorize directories
1156 1156
     }
1157 1157
     $blacklist = api_get_setting('upload_extensions_list_type');
1158 1158
     if ($blacklist != 'whitelist') { // if = blacklist
@@ -1378,9 +1378,9 @@  discard block
 block discarded – undo
1378 1378
     $upload_path = str_replace('//', '/', $upload_path);
1379 1379
 
1380 1380
     if ($upload_path == '/') {
1381
-        $upload_path='';
1381
+        $upload_path = '';
1382 1382
     } elseif (!empty($upload_path) && $upload_path[0] != '/') {
1383
-        $upload_path="/$upload_path";
1383
+        $upload_path = "/$upload_path";
1384 1384
     }
1385 1385
 
1386 1386
     $endchar = substr($filename, strlen($filename) - 1, 1);
@@ -1418,7 +1418,7 @@  discard block
 block discarded – undo
1418 1418
     $img_path_list = array();
1419 1419
 
1420 1420
     if (!$fp = fopen($html_file, 'r')) {
1421
-        return ;
1421
+        return;
1422 1422
     }
1423 1423
 
1424 1424
     // Aearch and store occurences of the <img> tag in an array
@@ -1438,7 +1438,7 @@  discard block
 block discarded – undo
1438 1438
         $img_tag_list = $matches[0];
1439 1439
     }
1440 1440
 
1441
-    fclose ($fp);
1441
+    fclose($fp);
1442 1442
     unset($buffer);
1443 1443
 
1444 1444
     // Search the image file path from all the <IMG> tag detected
@@ -1537,7 +1537,7 @@  discard block
 block discarded – undo
1537 1537
 
1538 1538
     if (!is_dir($base_work_dir.$systemFolderName)) {
1539 1539
         $result = mkdir(
1540
-            $base_work_dir . $systemFolderName,
1540
+            $base_work_dir.$systemFolderName,
1541 1541
             api_get_permissions_for_new_directories(),
1542 1542
             true
1543 1543
         );
@@ -1550,7 +1550,7 @@  discard block
 block discarded – undo
1550 1550
                     WHERE
1551 1551
                         c_id = $course_id AND
1552 1552
                         (
1553
-                            path = '" . Database::escape_string($systemFolderName). "'
1553
+                            path = '".Database::escape_string($systemFolderName)."'
1554 1554
                         )
1555 1555
             ";
1556 1556
 
@@ -1701,7 +1701,7 @@  discard block
 block discarded – undo
1701 1701
 
1702 1702
     // Fix the image tags
1703 1703
 
1704
-    for ($i = 0, $fileNb = count($original_img_path); $i < $fileNb ; $i++) {
1704
+    for ($i = 0, $fileNb = count($original_img_path); $i < $fileNb; $i++) {
1705 1705
         $replace_what = $original_img_path[$i];
1706 1706
         // We only need the directory and the filename /path/to/file_html_files/missing_file.gif -> file_html_files/missing_file.gif
1707 1707
         $exploded_file_path = explode('/', $new_img_path[$i]);
@@ -1742,7 +1742,7 @@  discard block
 block discarded – undo
1742 1742
         .'</body>'
1743 1743
         .'</html>';
1744 1744
     if (file_exists($file_path)) {
1745
-        if (!($fp = fopen ($file_path, 'w'))) {
1745
+        if (!($fp = fopen($file_path, 'w'))) {
1746 1746
             return false;
1747 1747
         }
1748 1748
         return fwrite($fp, $file_content);
@@ -1779,7 +1779,7 @@  discard block
 block discarded – undo
1779 1779
 {
1780 1780
     // Do we need a / or not?
1781 1781
     $added_slash = ($upload_path == '/') ? '' : '/';
1782
-    $folder_id      = DocumentManager::get_document_id(api_get_course_info(), $upload_path);
1782
+    $folder_id = DocumentManager::get_document_id(api_get_course_info(), $upload_path);
1783 1783
     // Build the form
1784 1784
     $form = "<p><strong>".get_lang('MissingImagesDetected')."</strong></p>"
1785 1785
         ."<form method=\"post\" action=\"".api_get_self()."\" enctype=\"multipart/form-data\">"
Please login to merge, or discard this patch.
main/inc/lib/usergroup.lib.php 2 patches
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1906,8 +1906,9 @@
 block discarded – undo
1906 1906
                 $new_relation_type[] ="'$rel'";
1907 1907
             }
1908 1908
             $relation_type = implode(',', $new_relation_type);
1909
-            if (!empty($relation_type))
1910
-                $where_relation_condition = "AND gu.relation_type IN ($relation_type) ";
1909
+            if (!empty($relation_type)) {
1910
+                            $where_relation_condition = "AND gu.relation_type IN ($relation_type) ";
1911
+            }
1911 1912
         }
1912 1913
 
1913 1914
         $sql = "SELECT picture_uri as image, u.id, u.firstname, u.lastname, relation_type
Please login to merge, or discard this patch.
Spacing   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
             ";
83 83
             $result = Database::query($sql);
84 84
             if (Database::num_rows($result)) {
85
-                $row  = Database::fetch_array($result);
85
+                $row = Database::fetch_array($result);
86 86
 
87 87
                 return $row['count'];
88 88
             }
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
             ";
103 103
             $result = Database::query($sql);
104 104
             if (Database::num_rows($result)) {
105
-                $row  = Database::fetch_array($result);
105
+                $row = Database::fetch_array($result);
106 106
                 return $row['count'];
107 107
             }
108 108
         }
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
             ";
128 128
             $result = Database::query($sql);
129 129
             if (Database::num_rows($result)) {
130
-                $row  = Database::fetch_array($result);
130
+                $row = Database::fetch_array($result);
131 131
                 return $row['count'];
132 132
             }
133 133
 
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
             ";
149 149
             $result = Database::query($sql);
150 150
             if (Database::num_rows($result)) {
151
-                $row  = Database::fetch_array($result);
151
+                $row = Database::fetch_array($result);
152 152
                 return $row['count'];
153 153
             }
154 154
 
@@ -529,13 +529,13 @@  discard block
 block discarded – undo
529 529
                 INNER JOIN {$this->table} g
530 530
                 ON (u.usergroup_id = g.id)
531 531
                 ";
532
-            $where =  array('where' => array('user_id = ? AND access_url_id = ? ' => array($userId, $urlId)));
532
+            $where = array('where' => array('user_id = ? AND access_url_id = ? ' => array($userId, $urlId)));
533 533
         } else {
534 534
             $from = $this->usergroup_rel_user_table." u
535 535
                 INNER JOIN {$this->table} g
536 536
                 ON (u.usergroup_id = g.id)
537 537
                 ";
538
-            $where =  array('where' => array('user_id = ?' => $userId));
538
+            $where = array('where' => array('user_id = ?' => $userId));
539 539
         }
540 540
 
541 541
         if ($filterByType !== null) {
@@ -568,10 +568,10 @@  discard block
 block discarded – undo
568 568
             $urlId = api_get_current_access_url_id();
569 569
             $from = $this->usergroup_rel_user_table." u
570 570
                     INNER JOIN {$this->access_url_rel_usergroup} a ON (a.usergroup_id AND u.usergroup_id)";
571
-            $where =  array('where' => array('user_id = ? AND access_url_id = ? ' => array($userId, $urlId)));
571
+            $where = array('where' => array('user_id = ? AND access_url_id = ? ' => array($userId, $urlId)));
572 572
         } else {
573 573
             $from = $this->usergroup_rel_user_table." u ";
574
-            $where =  array('where' => array('user_id = ?' => $userId));
574
+            $where = array('where' => array('user_id = ?' => $userId));
575 575
         }
576 576
 
577 577
         $results = Database::select(
@@ -858,7 +858,7 @@  discard block
 block discarded – undo
858 858
             }
859 859
             $result = $new_result;
860 860
         }
861
-        $columns = array('name', 'users', 'courses','sessions', 'group_type');
861
+        $columns = array('name', 'users', 'courses', 'sessions', 'group_type');
862 862
 
863 863
         if (!in_array($sidx, $columns)) {
864 864
             $sidx = 'name';
@@ -1263,7 +1263,7 @@  discard block
 block discarded – undo
1263 1263
                 }
1264 1264
             }
1265 1265
         }
1266
-        $response->addAssign('ajax_list_courses','innerHTML', api_utf8_encode($return));
1266
+        $response->addAssign('ajax_list_courses', 'innerHTML', api_utf8_encode($return));
1267 1267
 
1268 1268
         return $response;
1269 1269
     }
@@ -1371,7 +1371,7 @@  discard block
 block discarded – undo
1371 1371
      * @param string style css
1372 1372
      * @return array with the file and the style of an image i.e $array['file'] $array['style']
1373 1373
      */
1374
-    public function get_picture_group($id, $picture_file, $height, $size_picture = GROUP_IMAGE_SIZE_MEDIUM , $style = '')
1374
+    public function get_picture_group($id, $picture_file, $height, $size_picture = GROUP_IMAGE_SIZE_MEDIUM, $style = '')
1375 1375
     {
1376 1376
         $picture = array();
1377 1377
         //$picture['style'] = $style;
@@ -1414,7 +1414,7 @@  discard block
 block discarded – undo
1414 1414
             if (file_exists($file) && !is_dir($file)) {
1415 1415
                 $picture['file'] = $image_array['dir'].$picture_file;
1416 1416
             } else {
1417
-                $picture['file'] = Display::returnIconPath('group_na.png',64);
1417
+                $picture['file'] = Display::returnIconPath('group_na.png', 64);
1418 1418
             }
1419 1419
         }
1420 1420
         return $picture;
@@ -1518,7 +1518,7 @@  discard block
 block discarded – undo
1518 1518
         if (empty($user_id)) {
1519 1519
             $user_id = api_get_user_id();
1520 1520
         }
1521
-        $user_role	= $this->get_user_group_role($user_id, $group_id);
1521
+        $user_role = $this->get_user_group_role($user_id, $group_id);
1522 1522
         if (in_array($user_role, array(GROUP_USER_PERMISSION_ADMIN))) {
1523 1523
             return true;
1524 1524
         } else {
@@ -1536,7 +1536,7 @@  discard block
 block discarded – undo
1536 1536
         if (empty($user_id)) {
1537 1537
             $user_id = api_get_user_id();
1538 1538
         }
1539
-        $user_role	= $this->get_user_group_role($user_id, $group_id);
1539
+        $user_role = $this->get_user_group_role($user_id, $group_id);
1540 1540
         if (in_array($user_role, array(GROUP_USER_PERMISSION_ADMIN, GROUP_USER_PERMISSION_MODERATOR))) {
1541 1541
             return true;
1542 1542
         } else {
@@ -1563,7 +1563,7 @@  discard block
 block discarded – undo
1563 1563
             GROUP_USER_PERMISSION_READER,
1564 1564
             GROUP_USER_PERMISSION_HRM,
1565 1565
         );
1566
-        $user_role	= self::get_user_group_role($user_id, $group_id);
1566
+        $user_role = self::get_user_group_role($user_id, $group_id);
1567 1567
         if (in_array($user_role, $roles)) {
1568 1568
             return true;
1569 1569
         } else {
@@ -1580,7 +1580,7 @@  discard block
 block discarded – undo
1580 1580
      * */
1581 1581
     public function get_user_group_role($user_id, $group_id)
1582 1582
     {
1583
-        $table_group_rel_user= $this->usergroup_rel_user_table;
1583
+        $table_group_rel_user = $this->usergroup_rel_user_table;
1584 1584
         $return_value = 0;
1585 1585
         if (!empty($user_id) && !empty($group_id)) {
1586 1586
             $sql = "SELECT relation_type FROM $table_group_rel_user
@@ -1588,8 +1588,8 @@  discard block
 block discarded – undo
1588 1588
                         usergroup_id = ".intval($group_id)." AND
1589 1589
                         user_id = ".intval($user_id)." ";
1590 1590
             $result = Database::query($sql);
1591
-            if (Database::num_rows($result)>0) {
1592
-                $row = Database::fetch_array($result,'ASSOC');
1591
+            if (Database::num_rows($result) > 0) {
1592
+                $row = Database::fetch_array($result, 'ASSOC');
1593 1593
                 $return_value = $row['relation_type'];
1594 1594
             }
1595 1595
         }
@@ -1644,7 +1644,7 @@  discard block
 block discarded – undo
1644 1644
         if (is_array($user_list) && is_array($group_list)) {
1645 1645
             foreach ($group_list as $group_id) {
1646 1646
                 foreach ($user_list as $user_id) {
1647
-                    $role = self::get_user_group_role($user_id,$group_id);
1647
+                    $role = self::get_user_group_role($user_id, $group_id);
1648 1648
                     if ($role == 0) {
1649 1649
                         $sql = "INSERT INTO $table_url_rel_group
1650 1650
 		               			SET
@@ -1675,7 +1675,7 @@  discard block
 block discarded – undo
1675 1675
     public function delete_user_rel_group($user_id, $group_id)
1676 1676
     {
1677 1677
         $table = $this->usergroup_rel_user_table;
1678
-        $sql= "DELETE FROM $table
1678
+        $sql = "DELETE FROM $table
1679 1679
                WHERE
1680 1680
                 user_id = ".intval($user_id)." AND
1681 1681
                 usergroup_id = ".intval($group_id)."  ";
@@ -1731,7 +1731,7 @@  discard block
 block discarded – undo
1731 1731
 
1732 1732
         $sql = "UPDATE $table_group_rel_user
1733 1733
    				SET relation_type = ".intval($relation_type)."
1734
-                WHERE user_id = $user_id AND usergroup_id = $group_id" ;
1734
+                WHERE user_id = $user_id AND usergroup_id = $group_id";
1735 1735
         Database::query($sql);
1736 1736
     }
1737 1737
 
@@ -1773,7 +1773,7 @@  discard block
 block discarded – undo
1773 1773
         if (Database::num_rows($result) > 0) {
1774 1774
             while ($row = Database::fetch_array($result, 'ASSOC')) {
1775 1775
                 if ($with_image) {
1776
-                    $picture = self::get_picture_group($row['id'], $row['picture'],80);
1776
+                    $picture = self::get_picture_group($row['id'], $row['picture'], 80);
1777 1777
                     $img = '<img src="'.$picture['file'].'" />';
1778 1778
                     $row['picture'] = $img;
1779 1779
                 }
@@ -1809,11 +1809,11 @@  discard block
 block discarded – undo
1809 1809
 				ORDER BY count DESC
1810 1810
 				LIMIT $num";
1811 1811
 
1812
-        $result=Database::query($sql);
1812
+        $result = Database::query($sql);
1813 1813
         $array = array();
1814 1814
         while ($row = Database::fetch_array($result, 'ASSOC')) {
1815 1815
             if ($with_image) {
1816
-                $picture = self::get_picture_group($row['id'], $row['picture'],80);
1816
+                $picture = self::get_picture_group($row['id'], $row['picture'], 80);
1817 1817
                 $img = '<img src="'.$picture['file'].'" />';
1818 1818
                 $row['picture'] = $img;
1819 1819
             }
@@ -1858,11 +1858,11 @@  discard block
 block discarded – undo
1858 1858
                 ORDER BY created_at DESC
1859 1859
                 LIMIT $num ";
1860 1860
 
1861
-        $result=Database::query($sql);
1861
+        $result = Database::query($sql);
1862 1862
         $array = array();
1863 1863
         while ($row = Database::fetch_array($result, 'ASSOC')) {
1864 1864
             if ($with_image) {
1865
-                $picture = self::get_picture_group($row['id'], $row['picture'],80);
1865
+                $picture = self::get_picture_group($row['id'], $row['picture'], 80);
1866 1866
                 $img = '<img src="'.$picture['file'].'" />';
1867 1867
                 $row['picture'] = $img;
1868 1868
             }
@@ -1896,7 +1896,7 @@  discard block
 block discarded – undo
1896 1896
         $tbl_user = Database::get_main_table(TABLE_MAIN_USER);
1897 1897
         $group_id = intval($group_id);
1898 1898
 
1899
-        if (empty($group_id)){
1899
+        if (empty($group_id)) {
1900 1900
             return array();
1901 1901
         }
1902 1902
 
@@ -1911,9 +1911,9 @@  discard block
 block discarded – undo
1911 1911
             $where_relation_condition = '';
1912 1912
         } else {
1913 1913
             $new_relation_type = array();
1914
-            foreach($relation_type as $rel) {
1914
+            foreach ($relation_type as $rel) {
1915 1915
                 $rel = intval($rel);
1916
-                $new_relation_type[] ="'$rel'";
1916
+                $new_relation_type[] = "'$rel'";
1917 1917
             }
1918 1918
             $relation_type = implode(',', $new_relation_type);
1919 1919
             if (!empty($relation_type))
@@ -1957,7 +1957,7 @@  discard block
 block discarded – undo
1957 1957
         $tbl_user = Database::get_main_table(TABLE_MAIN_USER);
1958 1958
         $group_id = intval($group_id);
1959 1959
 
1960
-        if (empty($group_id)){
1960
+        if (empty($group_id)) {
1961 1961
             return array();
1962 1962
         }
1963 1963
 
@@ -1968,7 +1968,7 @@  discard block
 block discarded – undo
1968 1968
 			    WHERE gu.usergroup_id= $group_id
1969 1969
 			    ORDER BY relation_type, firstname";
1970 1970
 
1971
-        $result=Database::query($sql);
1971
+        $result = Database::query($sql);
1972 1972
         $array = array();
1973 1973
         while ($row = Database::fetch_array($result, 'ASSOC')) {
1974 1974
             $array[$row['id']] = $row;
@@ -1996,33 +1996,33 @@  discard block
 block discarded – undo
1996 1996
             case GROUP_USER_PERMISSION_READER:
1997 1997
                 // I'm just a reader
1998 1998
                 $relation_group_title = get_lang('IAmAReader');
1999
-                $links .=  '<li class="'. ($show == 'invite_friends' ? 'active' : '') .'"><a href="group_invitation.php?id='.$group_id.'">'.
2000
-                            Display::return_icon('invitation_friend.png', get_lang('InviteFriends')) . get_lang('InviteFriends') . '</a></li>';
2001
-                $links .=  '<li><a href="group_view.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'.
2002
-                            Display::return_icon('group_leave.png', get_lang('LeaveGroup')) . get_lang('LeaveGroup') . '</a></li>';
1999
+                $links .= '<li class="'.($show == 'invite_friends' ? 'active' : '').'"><a href="group_invitation.php?id='.$group_id.'">'.
2000
+                            Display::return_icon('invitation_friend.png', get_lang('InviteFriends')).get_lang('InviteFriends').'</a></li>';
2001
+                $links .= '<li><a href="group_view.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'.
2002
+                            Display::return_icon('group_leave.png', get_lang('LeaveGroup')).get_lang('LeaveGroup').'</a></li>';
2003 2003
                 if (UserGroup::canLeave($group_info)) {
2004
-                    $links .=  '<li><a href="group_view.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'.
2005
-                        Display::return_icon('group_leave.png', get_lang('LeaveGroup')) . get_lang('LeaveGroup') . '</a></li>';
2004
+                    $links .= '<li><a href="group_view.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'.
2005
+                        Display::return_icon('group_leave.png', get_lang('LeaveGroup')).get_lang('LeaveGroup').'</a></li>';
2006 2006
                 }
2007 2007
                 break;
2008 2008
             case GROUP_USER_PERMISSION_ADMIN:
2009 2009
                 $relation_group_title = get_lang('IAmAnAdmin');
2010
-                $links .=  '<li class="'. ($show == 'group_edit' ? 'active' : '') .'"><a href="group_edit.php?id='.$group_id.'">'.
2011
-                            Display::return_icon('group_edit.png', get_lang('EditGroup')) . get_lang('EditGroup') . '</a></li>';
2012
-                $links .=  '<li class="'. ($show == 'member_list' ? 'active' : '') .'"><a href="group_waiting_list.php?id='.$group_id.'">'.
2013
-                            Display::return_icon('waiting_list.png', get_lang('WaitingList')) . get_lang('WaitingList') . '</a></li>';
2014
-                $links .=  '<li class="'. ($show == 'invite_friends' ? 'active' : '') .'"><a href="group_invitation.php?id='.$group_id.'">'.
2015
-                            Display::return_icon('invitation_friend.png', get_lang('InviteFriends')) . get_lang('InviteFriends') . '</a></li>';
2010
+                $links .= '<li class="'.($show == 'group_edit' ? 'active' : '').'"><a href="group_edit.php?id='.$group_id.'">'.
2011
+                            Display::return_icon('group_edit.png', get_lang('EditGroup')).get_lang('EditGroup').'</a></li>';
2012
+                $links .= '<li class="'.($show == 'member_list' ? 'active' : '').'"><a href="group_waiting_list.php?id='.$group_id.'">'.
2013
+                            Display::return_icon('waiting_list.png', get_lang('WaitingList')).get_lang('WaitingList').'</a></li>';
2014
+                $links .= '<li class="'.($show == 'invite_friends' ? 'active' : '').'"><a href="group_invitation.php?id='.$group_id.'">'.
2015
+                            Display::return_icon('invitation_friend.png', get_lang('InviteFriends')).get_lang('InviteFriends').'</a></li>';
2016 2016
                 if (UserGroup::canLeave($group_info)) {
2017 2017
                     $links .= '<li><a href="group_view.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'.
2018
-                        Display::return_icon('group_leave.png', get_lang('LeaveGroup')) . get_lang('LeaveGroup') . '</a></li>';
2018
+                        Display::return_icon('group_leave.png', get_lang('LeaveGroup')).get_lang('LeaveGroup').'</a></li>';
2019 2019
                 }
2020 2020
                 break;
2021 2021
             case GROUP_USER_PERMISSION_PENDING_INVITATION:
2022 2022
 //				$links .=  '<li><a href="groups.php?id='.$group_id.'&action=join&u='.api_get_user_id().'">'.Display::return_icon('addd.gif', get_lang('YouHaveBeenInvitedJoinNow'), array('hspace'=>'6')).'<span class="social-menu-text4" >'.get_lang('YouHaveBeenInvitedJoinNow').'</span></a></li>';
2023 2023
                 break;
2024 2024
             case GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER:
2025
-                $relation_group_title =  get_lang('WaitingForAdminResponse');
2025
+                $relation_group_title = get_lang('WaitingForAdminResponse');
2026 2026
                 break;
2027 2027
             case GROUP_USER_PERMISSION_MODERATOR:
2028 2028
                 $relation_group_title = get_lang('IAmAModerator');
@@ -2030,28 +2030,28 @@  discard block
 block discarded – undo
2030 2030
                 //$links .=  '<li><a href="groups.php?id='.$group_id.'">'.				Display::return_icon('message_list.png', get_lang('MessageList'), array('hspace'=>'6')).'<span class="'.($show=='messages_list'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('MessageList').'</span></a></li>';
2031 2031
                 //$links .=  '<li><a href="group_members.php?id='.$group_id.'">'.		Display::return_icon('member_list.png', get_lang('MemberList'), array('hspace'=>'6')).'<span class="'.($show=='member_list'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('MemberList').'</span></a></li>';
2032 2032
                 if ($group_info['visibility'] == GROUP_PERMISSION_CLOSED) {
2033
-                    $links .=  '<li><a href="group_waiting_list.php?id='.$group_id.'">'.
2034
-                                Display::return_icon('waiting_list.png', get_lang('WaitingList')) . get_lang('WaitingList') . '</a></li>';
2033
+                    $links .= '<li><a href="group_waiting_list.php?id='.$group_id.'">'.
2034
+                                Display::return_icon('waiting_list.png', get_lang('WaitingList')).get_lang('WaitingList').'</a></li>';
2035 2035
                 }
2036
-                $links .=  '<li><a href="group_invitation.php?id='.$group_id.'">'.
2037
-                            Display::return_icon('invitation_friend.png', get_lang('InviteFriends')) . get_lang('InviteFriends') . '</a></li>';
2036
+                $links .= '<li><a href="group_invitation.php?id='.$group_id.'">'.
2037
+                            Display::return_icon('invitation_friend.png', get_lang('InviteFriends')).get_lang('InviteFriends').'</a></li>';
2038 2038
                 if (UserGroup::canLeave($group_info)) {
2039
-                    $links .=  '<li><a href="group_view.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'.
2040
-                        Display::return_icon('group_leave.png', get_lang('LeaveGroup')) . get_lang('LeaveGroup') . '</a></li>';
2039
+                    $links .= '<li><a href="group_view.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'.
2040
+                        Display::return_icon('group_leave.png', get_lang('LeaveGroup')).get_lang('LeaveGroup').'</a></li>';
2041 2041
                 }
2042 2042
                 break;
2043 2043
             case GROUP_USER_PERMISSION_HRM:
2044 2044
                 $relation_group_title = get_lang('IAmAHRM');
2045 2045
                 $links .= '<li><a href="'.api_get_path(WEB_CODE_PATH).'social/message_for_group_form.inc.php?view_panel=1&height=400&width=610&&user_friend='.api_get_user_id().'&group_id='.$group_id.'&action=add_message_group" class="ajax" title="'.get_lang('ComposeMessage').'" data-size="lg" data-title="'.get_lang('ComposeMessage').'">'.
2046
-                            Display::return_icon('new-message.png', get_lang('NewTopic')) . get_lang('NewTopic') . '</a></li>';
2047
-                $links .=  '<li><a href="group_view.php?id='.$group_id.'">'.
2048
-                            Display::return_icon('message_list.png', get_lang('MessageList')) . get_lang('MessageList') . '</a></li>';
2049
-                $links .=  '<li><a href="group_invitation.php?id='.$group_id.'">'.
2050
-                            Display::return_icon('invitation_friend.png', get_lang('InviteFriends')) . get_lang('InviteFriends') . '</a></li>';
2051
-                $links .=  '<li><a href="group_members.php?id='.$group_id.'">'.
2052
-                            Display::return_icon('member_list.png', get_lang('MemberList')) . get_lang('MemberList') . '</a></li>';
2053
-                $links .=  '<li><a href="group_view.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'.
2054
-                            Display::return_icon('delete_data.gif', get_lang('LeaveGroup')) . get_lang('LeaveGroup') . '</a></li>';
2046
+                            Display::return_icon('new-message.png', get_lang('NewTopic')).get_lang('NewTopic').'</a></li>';
2047
+                $links .= '<li><a href="group_view.php?id='.$group_id.'">'.
2048
+                            Display::return_icon('message_list.png', get_lang('MessageList')).get_lang('MessageList').'</a></li>';
2049
+                $links .= '<li><a href="group_invitation.php?id='.$group_id.'">'.
2050
+                            Display::return_icon('invitation_friend.png', get_lang('InviteFriends')).get_lang('InviteFriends').'</a></li>';
2051
+                $links .= '<li><a href="group_members.php?id='.$group_id.'">'.
2052
+                            Display::return_icon('member_list.png', get_lang('MemberList')).get_lang('MemberList').'</a></li>';
2053
+                $links .= '<li><a href="group_view.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'.
2054
+                            Display::return_icon('delete_data.gif', get_lang('LeaveGroup')).get_lang('LeaveGroup').'</a></li>';
2055 2055
                 break;
2056 2056
             default:
2057 2057
                 //$links .=  '<li><a href="groups.php?id='.$group_id.'&action=join&u='.api_get_user_id().'">'.Display::return_icon('addd.gif', get_lang('JoinGroup'), array('hspace'=>'6')).'<span class="social-menu-text4" >'.get_lang('JoinGroup').'</a></span></li>';
@@ -2143,7 +2143,7 @@  discard block
 block discarded – undo
2143 2143
         }
2144 2144
 
2145 2145
         $direction = 'ASC';
2146
-        if (!in_array($direction, array('ASC','DESC'))) {
2146
+        if (!in_array($direction, array('ASC', 'DESC'))) {
2147 2147
             $direction = 'ASC';
2148 2148
         }
2149 2149
 
@@ -2154,8 +2154,8 @@  discard block
 block discarded – undo
2154 2154
         $sql .= " LIMIT $from,$number_of_items";
2155 2155
 
2156 2156
         $res = Database::query($sql);
2157
-        if (Database::num_rows($res)> 0) {
2158
-            while ($row = Database::fetch_array($res,'ASSOC')) {
2157
+        if (Database::num_rows($res) > 0) {
2158
+            while ($row = Database::fetch_array($res, 'ASSOC')) {
2159 2159
                 if (!in_array($row['id'], $return)) {
2160 2160
                     $return[$row['id']] = $row;
2161 2161
                 }
@@ -2180,7 +2180,7 @@  discard block
 block discarded – undo
2180 2180
             if ($i == $max_level) {
2181 2181
                 $select_part .= "rg$rg_number.group_id as id_$rg_number ";
2182 2182
             } else {
2183
-                $select_part .="rg$rg_number.group_id as id_$rg_number, ";
2183
+                $select_part .= "rg$rg_number.group_id as id_$rg_number, ";
2184 2184
             }
2185 2185
             if ($i == 1) {
2186 2186
                 $cond_part .= "FROM $t_rel_group rg0 LEFT JOIN $t_rel_group rg$i on rg$rg_number.group_id = rg$i.subgroup_id ";
@@ -2365,7 +2365,7 @@  discard block
 block discarded – undo
2365 2365
         $nameList = '<ul class="list-unstyled">';
2366 2366
 
2367 2367
         foreach ($groupsNameListParsed as $name) {
2368
-            $nameList .= '<li>' . Display::span($name, ['class' => 'label label-info']) . '</li>';
2368
+            $nameList .= '<li>'.Display::span($name, ['class' => 'label label-info']).'</li>';
2369 2369
         }
2370 2370
 
2371 2371
         $nameList .= '</ul>';
Please login to merge, or discard this patch.
main/inc/lib/agenda.lib.php 2 patches
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -3122,8 +3122,9 @@
 block discarded – undo
3122 3122
         global $DaysShort, $course_path;
3123 3123
         //Handle leap year
3124 3124
         $numberofdays = array (0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
3125
-        if (($year % 400 == 0) or ($year % 4 == 0 and $year % 100 <> 0))
3126
-            $numberofdays[2] = 29;
3125
+        if (($year % 400 == 0) or ($year % 4 == 0 and $year % 100 <> 0)) {
3126
+                    $numberofdays[2] = 29;
3127
+        }
3127 3128
         //Get the first day of the month
3128 3129
         $dayone = getdate(mktime(0, 0, 0, $month, 1, $year));
3129 3130
         //Start the week on monday
Please login to merge, or discard this patch.
Spacing   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -1536,12 +1536,12 @@  discard block
 block discarded – undo
1536 1536
             }
1537 1537
 
1538 1538
             if (empty($session_id)) {
1539
-                $sessionCondition =  "
1539
+                $sessionCondition = "
1540 1540
                 (
1541 1541
                     agenda.session_id = 0 AND (ip.session_id IS NULL OR ip.session_id = 0)
1542 1542
                 ) ";
1543 1543
             } else {
1544
-                $sessionCondition =  "
1544
+                $sessionCondition = "
1545 1545
                 (
1546 1546
                     agenda.session_id = $session_id AND
1547 1547
                     ip.session_id = $session_id
@@ -1584,13 +1584,13 @@  discard block
 block discarded – undo
1584 1584
             }
1585 1585
 
1586 1586
             if (empty($session_id)) {
1587
-                $sessionCondition =  "
1587
+                $sessionCondition = "
1588 1588
                 (
1589 1589
                     agenda.session_id = 0 AND
1590 1590
                     (ip.session_id IS NULL OR ip.session_id = 0)
1591 1591
                 ) ";
1592 1592
             } else {
1593
-                $sessionCondition =  "
1593
+                $sessionCondition = "
1594 1594
                 (
1595 1595
                     agenda.session_id = $session_id AND
1596 1596
                     ip.session_id = $session_id
@@ -1642,7 +1642,7 @@  discard block
 block discarded – undo
1642 1642
             while ($row = Database::fetch_array($result, 'ASSOC')) {
1643 1643
                 $event = array();
1644 1644
                 $event['id'] = 'course_'.$row['id'];
1645
-                $event['unique_id']  = $row['iid'];
1645
+                $event['unique_id'] = $row['iid'];
1646 1646
                 // To avoid doubles
1647 1647
                 if (in_array($event['unique_id'], $eventsAdded)) {
1648 1648
                     continue;
@@ -2144,7 +2144,7 @@  discard block
 block discarded – undo
2144 2144
                 '<span id="link-more-attach">
2145 2145
                     <a href="javascript://" onclick="return add_image_form()">'.
2146 2146
                         get_lang('AddOneMoreFile').'</a>
2147
-                 </span>&nbsp;('.sprintf(get_lang('MaximunFileSizeX'),format_file_size(api_get_setting('message_max_upload_filesize'))).')'
2147
+                 </span>&nbsp;('.sprintf(get_lang('MaximunFileSizeX'), format_file_size(api_get_setting('message_max_upload_filesize'))).')'
2148 2148
             );
2149 2149
 
2150 2150
             if (isset($params['attachment']) && !empty($params['attachment'])) {
@@ -2740,8 +2740,8 @@  discard block
 block discarded – undo
2740 2740
                     $currentTimeZone,
2741 2741
                     $end->format('e')
2742 2742
                 );
2743
-                $title = api_convert_encoding((string)$event->summary, $charset, 'UTF-8');
2744
-                $description = api_convert_encoding((string)$event->description, $charset, 'UTF-8');
2743
+                $title = api_convert_encoding((string) $event->summary, $charset, 'UTF-8');
2744
+                $description = api_convert_encoding((string) $event->description, $charset, 'UTF-8');
2745 2745
 
2746 2746
                 $id = $this->addEvent(
2747 2747
                     $startDateTime,
@@ -2882,7 +2882,7 @@  discard block
 block discarded – undo
2882 2882
 							ORDER BY start_date ";
2883 2883
             } else {
2884 2884
                 // if the user is not an administrator of that course
2885
-                if (is_array($group_memberships) && count($group_memberships)>0) {
2885
+                if (is_array($group_memberships) && count($group_memberships) > 0) {
2886 2886
                     $sqlquery = "SELECT	agenda.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.ref
2887 2887
 								FROM ".$TABLEAGENDA." agenda,
2888 2888
 									".$TABLE_ITEMPROPERTY." ip
@@ -2912,14 +2912,14 @@  discard block
 block discarded – undo
2912 2912
                 $agendaday = -1;
2913 2913
                 if (!empty($item['start_date'])) {
2914 2914
                     $item['start_date'] = api_get_local_time($item['start_date']);
2915
-                    $item['start_date_tms']  = api_strtotime($item['start_date']);
2915
+                    $item['start_date_tms'] = api_strtotime($item['start_date']);
2916 2916
                     $agendaday = date("j", $item['start_date_tms']);
2917 2917
                 }
2918 2918
                 if (!empty($item['end_date'])) {
2919 2919
                     $item['end_date'] = api_get_local_time($item['end_date']);
2920 2920
                 }
2921 2921
 
2922
-                $url  = api_get_path(WEB_CODE_PATH)."calendar/agenda.php?cidReq=".urlencode($array_course_info["code"])."&day=$agendaday&month=$month&year=$year#$agendaday";
2922
+                $url = api_get_path(WEB_CODE_PATH)."calendar/agenda.php?cidReq=".urlencode($array_course_info["code"])."&day=$agendaday&month=$month&year=$year#$agendaday";
2923 2923
 
2924 2924
                 $item['url'] = $url;
2925 2925
                 $item['course_name'] = $array_course_info['title'];
@@ -2931,9 +2931,9 @@  discard block
 block discarded – undo
2931 2931
         }
2932 2932
 
2933 2933
         // sorting by hour for every day
2934
-        $agendaitems = array ();
2934
+        $agendaitems = array();
2935 2935
         while (list ($agendaday, $tmpitems) = each($items)) {
2936
-            if(!isset($agendaitems[$agendaday])) {
2936
+            if (!isset($agendaitems[$agendaday])) {
2937 2937
                 $agendaitems[$agendaday] = '';
2938 2938
             }
2939 2939
             sort($tmpitems);
@@ -3107,9 +3107,9 @@  discard block
 block discarded – undo
3107 3107
             $end_year = $start_end_day_of_week['end']['year'];
3108 3108
             // in sql statements you have to use year-month-day for date calculations
3109 3109
             $start_filter = $start_year."-".$start_month."-".$start_day." 00:00:00";
3110
-            $start_filter  = api_get_utc_datetime($start_filter);
3110
+            $start_filter = api_get_utc_datetime($start_filter);
3111 3111
             $end_filter = $end_year."-".$end_month."-".$end_day." 23:59:59";
3112
-            $end_filter  = api_get_utc_datetime($end_filter);
3112
+            $end_filter = api_get_utc_datetime($end_filter);
3113 3113
             $sql = " SELECT * FROM ".$tbl_personal_agenda." WHERE user='".$user_id."' AND date>='".$start_filter."' AND date<='".$end_filter."'";
3114 3114
         }
3115 3115
         // 3. creating the SQL statement for getting the personal agenda items in DAY view
@@ -3117,18 +3117,18 @@  discard block
 block discarded – undo
3117 3117
             // we are in day view
3118 3118
             // we could use mysql date() function but this is only available from 4.1 and higher
3119 3119
             $start_filter = $year."-".$month."-".$day." 00:00:00";
3120
-            $start_filter  = api_get_utc_datetime($start_filter);
3120
+            $start_filter = api_get_utc_datetime($start_filter);
3121 3121
             $end_filter = $year."-".$month."-".$day." 23:59:59";
3122
-            $end_filter  = api_get_utc_datetime($end_filter);
3122
+            $end_filter = api_get_utc_datetime($end_filter);
3123 3123
             $sql = " SELECT * FROM ".$tbl_personal_agenda." WHERE user='".$user_id."' AND date>='".$start_filter."' AND date<='".$end_filter."'";
3124 3124
         }
3125 3125
 
3126 3126
         $result = Database::query($sql);
3127 3127
         while ($item = Database::fetch_array($result, 'ASSOC')) {
3128 3128
 
3129
-            $time_minute 	= api_convert_and_format_date($item['date'], TIME_NO_SEC_FORMAT);
3130
-            $item['date']   = api_get_local_time($item['date']);
3131
-            $item['start_date_tms']  = api_strtotime($item['date']);
3129
+            $time_minute = api_convert_and_format_date($item['date'], TIME_NO_SEC_FORMAT);
3130
+            $item['date'] = api_get_local_time($item['date']);
3131
+            $item['start_date_tms'] = api_strtotime($item['date']);
3132 3132
             $item['content'] = $item['text'];
3133 3133
 
3134 3134
             // we break the date field in the database into a date and a time part
@@ -3148,7 +3148,7 @@  discard block
 block discarded – undo
3148 3148
             $second = $agendatime[2];
3149 3149
 
3150 3150
             if ($type == 'month_view') {
3151
-                $item['calendar_type']  = 'personal';
3151
+                $item['calendar_type'] = 'personal';
3152 3152
                 $item['start_date']  	= $item['date'];
3153 3153
                 $agendaitems[$day][] 	= $item;
3154 3154
                 continue;
@@ -3173,7 +3173,7 @@  discard block
 block discarded – undo
3173 3173
                 // this is the array construction for the DAY view
3174 3174
                 $halfhour = 2 * $agendatime['0'];
3175 3175
                 if ($agendatime['1'] >= '30') {
3176
-                    $halfhour = $halfhour +1;
3176
+                    $halfhour = $halfhour + 1;
3177 3177
                 }
3178 3178
 
3179 3179
                 //Display events by list
@@ -3197,22 +3197,22 @@  discard block
 block discarded – undo
3197 3197
     {
3198 3198
         global $DaysShort, $course_path;
3199 3199
         //Handle leap year
3200
-        $numberofdays = array (0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
3200
+        $numberofdays = array(0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
3201 3201
         if (($year % 400 == 0) or ($year % 4 == 0 and $year % 100 <> 0))
3202 3202
             $numberofdays[2] = 29;
3203 3203
         //Get the first day of the month
3204 3204
         $dayone = getdate(mktime(0, 0, 0, $month, 1, $year));
3205 3205
         //Start the week on monday
3206 3206
         $startdayofweek = $dayone['wday'] <> 0 ? ($dayone['wday'] - 1) : 6;
3207
-        $g_cc = (isset($_GET['courseCode'])?$_GET['courseCode']:'');
3207
+        $g_cc = (isset($_GET['courseCode']) ? $_GET['courseCode'] : '');
3208 3208
 
3209
-        $next_month = ($month == 1 ? 12 : $month -1);
3210
-        $prev_month = ($month == 12 ? 1 : $month +1);
3209
+        $next_month = ($month == 1 ? 12 : $month - 1);
3210
+        $prev_month = ($month == 12 ? 1 : $month + 1);
3211 3211
 
3212
-        $next_year = ($month == 1 ? $year -1 : $year);
3213
-        $prev_year = ($month == 12 ? $year +1 : $year);
3212
+        $next_year = ($month == 1 ? $year - 1 : $year);
3213
+        $prev_year = ($month == 12 ? $year + 1 : $year);
3214 3214
 
3215
-        if ($show_content)  {
3215
+        if ($show_content) {
3216 3216
             $back_url = Display::url(get_lang('Previous'), api_get_self()."?coursePath=".urlencode($course_path)."&courseCode=".Security::remove_XSS($g_cc)."&action=view&view=month&month=".$next_month."&year=".$next_year);
3217 3217
             $next_url = Display::url(get_lang('Next'), api_get_self()."?coursePath=".urlencode($course_path)."&courseCode=".Security::remove_XSS($g_cc)."&action=view&view=month&month=".$prev_month."&year=".$prev_year);
3218 3218
         } else {
@@ -3229,7 +3229,7 @@  discard block
 block discarded – undo
3229 3229
         $html .= '</div>';
3230 3230
         $html .= '<table id="agenda_list2" class="table table-bordered">';
3231 3231
         $html .= '<tr>';
3232
-        for ($ii = 1; $ii < 8; $ii ++) {
3232
+        for ($ii = 1; $ii < 8; $ii++) {
3233 3233
             $html .= '<td class="weekdays">'.$DaysShort[$ii % 7].'</td>';
3234 3234
         }
3235 3235
         $html .= '</tr>';
@@ -3238,7 +3238,7 @@  discard block
 block discarded – undo
3238 3238
         $today = getdate();
3239 3239
         while ($curday <= $numberofdays[$month]) {
3240 3240
             $html .= "<tr>";
3241
-            for ($ii = 0; $ii < 7; $ii ++) {
3241
+            for ($ii = 0; $ii < 7; $ii++) {
3242 3242
                 if (($curday == -1) && ($ii == $startdayofweek)) {
3243 3243
                     $curday = 1;
3244 3244
                 }
@@ -3252,21 +3252,21 @@  discard block
 block discarded – undo
3252 3252
                     $html .= "<td ".$class.">".$dayheader;
3253 3253
 
3254 3254
                     if (!empty($agendaitems[$curday])) {
3255
-                        $items =  $agendaitems[$curday];
3256
-                        $items =  msort($items, 'start_date_tms');
3255
+                        $items = $agendaitems[$curday];
3256
+                        $items = msort($items, 'start_date_tms');
3257 3257
 
3258
-                        foreach($items  as $value) {
3258
+                        foreach ($items  as $value) {
3259 3259
                             $value['title'] = Security::remove_XSS($value['title']);
3260 3260
                             $start_time = api_format_date($value['start_date'], TIME_NO_SEC_FORMAT);
3261 3261
                             $end_time = '';
3262 3262
 
3263 3263
                             if (!empty($value['end_date'])) {
3264
-                                $end_time    = '-&nbsp;<i>'.api_format_date($value['end_date'], DATE_TIME_FORMAT_LONG).'</i>';
3264
+                                $end_time = '-&nbsp;<i>'.api_format_date($value['end_date'], DATE_TIME_FORMAT_LONG).'</i>';
3265 3265
                             }
3266 3266
                             $complete_time = '<i>'.api_format_date($value['start_date'], DATE_TIME_FORMAT_LONG).'</i>&nbsp;'.$end_time;
3267 3267
                             $time = '<i>'.$start_time.'</i>';
3268 3268
 
3269
-                            switch($value['calendar_type']) {
3269
+                            switch ($value['calendar_type']) {
3270 3270
                                 case 'personal':
3271 3271
                                     $bg_color = '#D0E7F4';
3272 3272
                                     $icon = Display::return_icon('user.png', get_lang('MyAgenda'), array(), ICON_SIZE_SMALL);
@@ -3318,7 +3318,7 @@  discard block
 block discarded – undo
3318 3318
                         }
3319 3319
                     }
3320 3320
                     $html .= "</td>";
3321
-                    $curday ++;
3321
+                    $curday++;
3322 3322
                 } else {
3323 3323
                     $html .= "<td></td>";
3324 3324
                 }
@@ -3340,18 +3340,18 @@  discard block
 block discarded – undo
3340 3340
      * where datestart and dateend are in yyyyMMddhhmmss format.
3341 3341
      * @TODO Implement really personal events (from user DB) and global events (from main DB)
3342 3342
      */
3343
-    public static function get_personal_agenda_items_between_dates($user_id, $date_start='', $date_end='')
3343
+    public static function get_personal_agenda_items_between_dates($user_id, $date_start = '', $date_end = '')
3344 3344
     {
3345
-        $items = array ();
3345
+        $items = array();
3346 3346
         if ($user_id != strval(intval($user_id))) { return $items; }
3347
-        if (empty($date_start)) { $date_start = date('Y-m-d H:i:s');}
3348
-        if (empty($date_end))   { $date_end = date('Y-m-d H:i:s',mktime(0, 0, 0, date("m"),   date("d"),   date("Y")+1));}
3347
+        if (empty($date_start)) { $date_start = date('Y-m-d H:i:s'); }
3348
+        if (empty($date_end)) { $date_end = date('Y-m-d H:i:s', mktime(0, 0, 0, date("m"), date("d"), date("Y") + 1)); }
3349 3349
         $expr = '/\d{4}-\d{2}-\d{2}\ \d{2}:\d{2}:\d{2}/';
3350
-        if(!preg_match($expr,$date_start)) { return $items; }
3351
-        if(!preg_match($expr,$date_end)) { return $items; }
3350
+        if (!preg_match($expr, $date_start)) { return $items; }
3351
+        if (!preg_match($expr, $date_end)) { return $items; }
3352 3352
 
3353 3353
         // get agenda-items for every course
3354
-        $courses = api_get_user_courses($user_id,false);
3354
+        $courses = api_get_user_courses($user_id, false);
3355 3355
         foreach ($courses as $id => $course) {
3356 3356
             $c = api_get_course_info_by_id($course['real_id']);
3357 3357
             //databases of the courses
@@ -3375,9 +3375,9 @@  discard block
 block discarded – undo
3375 3375
                     " ORDER BY start_date ";
3376 3376
             } else {
3377 3377
                 // if the user is not an administrator of that course, then...
3378
-                if (is_array($group_memberships) && count($group_memberships)>0)
3378
+                if (is_array($group_memberships) && count($group_memberships) > 0)
3379 3379
                 {
3380
-                    $sqlquery = "SELECT " .
3380
+                    $sqlquery = "SELECT ".
3381 3381
                         "DISTINCT agenda.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.ref ".
3382 3382
                         " FROM ".$t_a." agenda, ".
3383 3383
                         $t_ip." ip ".
@@ -3405,13 +3405,13 @@  discard block
 block discarded – undo
3405 3405
 
3406 3406
             $result = Database::query($sqlquery);
3407 3407
             while ($item = Database::fetch_array($result)) {
3408
-                $agendaday = date("j",strtotime($item['start_date']));
3409
-                $month = date("n",strtotime($item['start_date']));
3410
-                $year = date("Y",strtotime($item['start_date']));
3408
+                $agendaday = date("j", strtotime($item['start_date']));
3409
+                $month = date("n", strtotime($item['start_date']));
3410
+                $year = date("Y", strtotime($item['start_date']));
3411 3411
                 $URL = api_get_path(WEB_PATH)."main/calendar/agenda.php?cidReq=".urlencode($course["code"])."&day=$agendaday&month=$month&year=$year#$agendaday";
3412
-                list($year,$month,$day,$hour,$min,$sec) = split('[-: ]',$item['start_date']);
3412
+                list($year, $month, $day, $hour, $min, $sec) = split('[-: ]', $item['start_date']);
3413 3413
                 $start_date = $year.$month.$day.$hour.$min;
3414
-                list($year,$month,$day,$hour,$min,$sec) = split('[-: ]',$item['end_date']);
3414
+                list($year, $month, $day, $hour, $min, $sec) = split('[-: ]', $item['end_date']);
3415 3415
                 $end_date = $year.$month.$day.$hour.$min;
3416 3416
 
3417 3417
                 $items[] = array(
@@ -3439,7 +3439,7 @@  discard block
 block discarded – undo
3439 3439
         $user = api_get_user_id();
3440 3440
         $sql = " SELECT * FROM ".$tbl_personal_agenda." WHERE id=".$id." AND user = ".$user;
3441 3441
         $result = Database::query($sql);
3442
-        if(Database::num_rows($result)==1) {
3442
+        if (Database::num_rows($result) == 1) {
3443 3443
             $item = Database::fetch_array($result);
3444 3444
         } else {
3445 3445
             $item = null;
@@ -3460,9 +3460,9 @@  discard block
 block discarded – undo
3460 3460
         // step 2: we which day this is (0=sunday, 1=monday, ...)
3461 3461
         $number_day_in_week = date('w', $random_day_in_week);
3462 3462
         // step 3: we calculate the timestamp of the monday of the week we are in
3463
-        $start_timestamp = $random_day_in_week - (($number_day_in_week -1) * 24 * 60 * 60);
3463
+        $start_timestamp = $random_day_in_week - (($number_day_in_week - 1) * 24 * 60 * 60);
3464 3464
         // step 4: we calculate the timestamp of the sunday of the week we are in
3465
-        $end_timestamp = $random_day_in_week + ((7 - $number_day_in_week +1) * 24 * 60 * 60) - 3600;
3465
+        $end_timestamp = $random_day_in_week + ((7 - $number_day_in_week + 1) * 24 * 60 * 60) - 3600;
3466 3466
         // step 5: calculating the start_day, end_day, start_month, end_month, start_year, end_year
3467 3467
         $start_day = date('j', $start_timestamp);
3468 3468
         $start_month = date('n', $start_timestamp);
Please login to merge, or discard this patch.
main/inc/lib/zombie/zombie_manager.class.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
         $count = intval($count);
80 80
         $from = intval($from);
81 81
 
82
-        $sql .=  " ORDER BY $column $direction";
82
+        $sql .= " ORDER BY $column $direction";
83 83
         $sql .= " LIMIT $count, $from ";
84 84
 
85 85
         $result = Database::query($sql);
@@ -93,8 +93,8 @@  discard block
 block discarded – undo
93 93
     static function deactivate_zombies($ceiling)
94 94
     {
95 95
         $zombies = self::list_zombies($ceiling);
96
-        $ids  = array();
97
-        foreach($zombies as $zombie) {
96
+        $ids = array();
97
+        foreach ($zombies as $zombie) {
98 98
             $ids[] = $zombie['user_id'];
99 99
         }
100 100
         UserManager::deactivate_users($ids);
Please login to merge, or discard this patch.