Completed
Push — 1.10.x ( 2be62b...254ea6 )
by Angel Fernando Quiroz
133:23 queued 88:52
created
main/inc/lib/tracking.lib.php 4 patches
Doc Comments   +13 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1287,6 +1287,8 @@  discard block
 block discarded – undo
1287 1287
      * @param   string type of time filter: 'last_week' or 'custom'
1288 1288
      * @param   string  start date date('Y-m-d H:i:s')
1289 1289
      * @param   string  end date date('Y-m-d H:i:s')
1290
+     * @param string $start_date
1291
+     * @param string $end_date
1290 1292
      * @return timestamp $nb_seconds
1291 1293
      */
1292 1294
     public static function get_time_spent_on_the_platform(
@@ -1390,7 +1392,7 @@  discard block
 block discarded – undo
1390 1392
      * Get first connection date for a student
1391 1393
      * @param    int $student_id
1392 1394
      *
1393
-     * @return    string|bool Date format long without day or false if there are no connections
1395
+     * @return    string|false Date format long without day or false if there are no connections
1394 1396
      */
1395 1397
     public static function get_first_connection_date($student_id)
1396 1398
     {
@@ -1420,7 +1422,7 @@  discard block
 block discarded – undo
1420 1422
      * @param int $student_id
1421 1423
      * @param bool $warning_message Show a warning message (optional)
1422 1424
      * @param bool $return_timestamp True for returning results in timestamp (optional)
1423
-     * @return string|int|bool Date format long without day, false if there are no connections or
1425
+     * @return string Date format long without day, false if there are no connections or
1424 1426
      * timestamp if parameter $return_timestamp is true
1425 1427
      */
1426 1428
     public static function get_last_connection_date($student_id, $warning_message = false, $return_timestamp = false)
@@ -2667,6 +2669,9 @@  discard block
 block discarded – undo
2667 2669
      * @param     array         Limit average to listed lp ids
2668 2670
      * @param     int            Session id (optional), if param $session_id is
2669 2671
      * null(default) it'll return results including sessions, 0 = session is not filtered
2672
+     * @param integer $student_id
2673
+     * @param string $course_code
2674
+     * @param integer $session_id
2670 2675
      * @return     int         Total time
2671 2676
      */
2672 2677
     public static function get_time_spent_in_lp($student_id, $course_code, $lp_ids = array(), $session_id = null)
@@ -2733,6 +2738,8 @@  discard block
 block discarded – undo
2733 2738
      * @param     int|array    Student id(s)
2734 2739
      * @param     string         Course code
2735 2740
      * @param     int         Learning path id
2741
+     * @param integer $student_id
2742
+     * @param string $course_code
2736 2743
      * @return     int         Total time
2737 2744
      */
2738 2745
     public static function get_last_connection_time_in_lp($student_id, $course_code, $lp_id, $session_id = 0)
@@ -5400,7 +5407,7 @@  discard block
 block discarded – undo
5400 5407
 
5401 5408
     /**
5402 5409
     * @param FormValidator $form
5403
-    * @return mixed
5410
+    * @return FormValidator
5404 5411
     */
5405 5412
     public static function setUserSearchForm($form)
5406 5413
     {
@@ -5439,7 +5446,6 @@  discard block
 block discarded – undo
5439 5446
      * @param   int $sessionId  The session ID (session.id)
5440 5447
      * @param   int $courseId   The course ID (course.id)
5441 5448
      * @param   int $exerciseId The quiz ID (c_quiz.id)
5442
-     * @param   int $answer     The answer status (0 = incorrect, 1 = correct, 2 = both)
5443 5449
      * @param   array   $options    An array of options you can pass to the query (limit, where and order)
5444 5450
      * @return array An array with the data of exercise(s) progress
5445 5451
      */
@@ -6876,7 +6882,7 @@  discard block
 block discarded – undo
6876 6882
      * @param int $user_id
6877 6883
      * @param int $course_id
6878 6884
      * @param int $session_id
6879
-     * @return array
6885
+     * @return string[]
6880 6886
      */
6881 6887
     public function display_login_tracking_info($view, $user_id, $course_id, $session_id = 0)
6882 6888
     {
@@ -6922,9 +6928,9 @@  discard block
 block discarded – undo
6922 6928
     /**
6923 6929
      * Displays the exercise results for a specific user in a specific course.
6924 6930
      * @param   string $view
6925
-     * @param   int $user_id    User ID
6931
+     * @param   int $userId    User ID
6926 6932
      * @param   string  $courseCode Course code
6927
-     * @return array
6933
+     * @return string[]
6928 6934
      * @todo remove globals
6929 6935
      */
6930 6936
     public function display_exercise_tracking_info($view, $userId, $courseCode)
Please login to merge, or discard this patch.
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   +862 added lines, -862 removed lines patch added patch discarded remove patch
@@ -311,8 +311,8 @@  discard block
 block discarded – undo
311 311
                     $extend_link = '';
312 312
                     if (!empty($inter_num)) {
313 313
                         $extend_link = Display::url(
314
-                              Display::return_icon('visible.gif', get_lang('HideAttemptView')),
315
-                              api_get_self() . '?action=stats&fold_id=' . $my_item_id . $url_suffix
314
+                                Display::return_icon('visible.gif', get_lang('HideAttemptView')),
315
+                                api_get_self() . '?action=stats&fold_id=' . $my_item_id . $url_suffix
316 316
                         );
317 317
                     }
318 318
                     $title = $row['mytitle'];
@@ -1319,7 +1319,7 @@  discard block
 block discarded – undo
1319 1319
             case 'last_30_days':
1320 1320
                 $new_date = date('Y-m-d H:i:s', strtotime('-30 day'));
1321 1321
                 $condition_time = ' AND (login_date >= "'.$new_date.'" AND logout_date <= "'.$today.'") ';
1322
-               break;
1322
+                break;
1323 1323
             case 'custom':
1324 1324
                 if (!empty($start_date) && !empty($end_date)) {
1325 1325
                     $start_date = Database::escape_string($start_date);
@@ -1329,10 +1329,10 @@  discard block
 block discarded – undo
1329 1329
                 break;
1330 1330
         }
1331 1331
 
1332
-    	$sql = 'SELECT SUM(TIMESTAMPDIFF(SECOND, login_date, logout_date)) diff
1332
+        $sql = 'SELECT SUM(TIMESTAMPDIFF(SECOND, login_date, logout_date)) diff
1333 1333
     	        FROM '.$tbl_track_login.'
1334 1334
                 WHERE '.$userCondition.$condition_time;
1335
-    	$rs = Database::query($sql);
1335
+        $rs = Database::query($sql);
1336 1336
         $row = Database::fetch_array($rs, 'ASSOC');
1337 1337
         $diff = $row['diff'];
1338 1338
 
@@ -1354,18 +1354,18 @@  discard block
 block discarded – undo
1354 1354
     public static function get_time_spent_on_the_course($user_id, $courseId, $session_id = 0)
1355 1355
     {
1356 1356
         $courseId = intval($courseId);
1357
-    	$session_id  = intval($session_id);
1358
-
1359
-    	$tbl_track_course = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1360
-    	if (is_array($user_id)) {
1361
-    	    $user_id = array_map('intval', $user_id);
1362
-    		$condition_user = " AND user_id IN (".implode(',',$user_id).") ";
1363
-    	} else {
1364
-    		$user_id = intval($user_id);
1365
-    		$condition_user = " AND user_id = $user_id ";
1366
-    	}
1367
-
1368
-    	$sql = "SELECT
1357
+        $session_id  = intval($session_id);
1358
+
1359
+        $tbl_track_course = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1360
+        if (is_array($user_id)) {
1361
+            $user_id = array_map('intval', $user_id);
1362
+            $condition_user = " AND user_id IN (".implode(',',$user_id).") ";
1363
+        } else {
1364
+            $user_id = intval($user_id);
1365
+            $condition_user = " AND user_id = $user_id ";
1366
+        }
1367
+
1368
+        $sql = "SELECT
1369 1369
     	        SUM(UNIX_TIMESTAMP(logout_course_date) - UNIX_TIMESTAMP(login_course_date)) as nb_seconds
1370 1370
                 FROM $tbl_track_course
1371 1371
                 WHERE UNIX_TIMESTAMP(logout_course_date) > UNIX_TIMESTAMP(login_course_date) ";
@@ -1381,9 +1381,9 @@  discard block
 block discarded – undo
1381 1381
         $sql .= $condition_user;
1382 1382
 
1383 1383
         $rs = Database::query($sql);
1384
-    	$row = Database::fetch_array($rs);
1384
+        $row = Database::fetch_array($rs);
1385 1385
 
1386
-    	return $row['nb_seconds'];
1386
+        return $row['nb_seconds'];
1387 1387
     }
1388 1388
 
1389 1389
     /**
@@ -1394,25 +1394,25 @@  discard block
 block discarded – undo
1394 1394
      */
1395 1395
     public static function get_first_connection_date($student_id)
1396 1396
     {
1397
-    	$tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
1398
-    	$sql = 'SELECT login_date
1397
+        $tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
1398
+        $sql = 'SELECT login_date
1399 1399
     	        FROM ' . $tbl_track_login . '
1400 1400
                 WHERE login_user_id = ' . intval($student_id) . '
1401 1401
                 ORDER BY login_date ASC
1402 1402
                 LIMIT 0,1';
1403 1403
 
1404
-    	$rs = Database::query($sql);
1405
-    	if (Database::num_rows($rs)>0) {
1406
-    		if ($first_login_date = Database::result($rs, 0, 0)) {
1404
+        $rs = Database::query($sql);
1405
+        if (Database::num_rows($rs)>0) {
1406
+            if ($first_login_date = Database::result($rs, 0, 0)) {
1407 1407
                 return api_convert_and_format_date(
1408 1408
                     $first_login_date,
1409 1409
                     DATE_FORMAT_SHORT,
1410 1410
                     date_default_timezone_get()
1411 1411
                 );
1412
-    		}
1413
-    	}
1412
+            }
1413
+        }
1414 1414
 
1415
-    	return false;
1415
+        return false;
1416 1416
     }
1417 1417
 
1418 1418
     /**
@@ -1425,38 +1425,38 @@  discard block
 block discarded – undo
1425 1425
      */
1426 1426
     public static function get_last_connection_date($student_id, $warning_message = false, $return_timestamp = false)
1427 1427
     {
1428
-    	$table = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
1429
-    	$sql = 'SELECT login_date
1428
+        $table = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
1429
+        $sql = 'SELECT login_date
1430 1430
     	        FROM ' . $table . '
1431 1431
                 WHERE login_user_id = ' . intval($student_id) . '
1432 1432
                 ORDER BY login_date
1433 1433
                 DESC LIMIT 0,1';
1434 1434
 
1435
-    	$rs = Database::query($sql);
1436
-    	if (Database::num_rows($rs) > 0) {
1437
-    		if ($last_login_date = Database::result($rs, 0, 0)) {
1438
-    			$last_login_date = api_get_local_time($last_login_date);
1439
-    			if ($return_timestamp) {
1440
-    				return api_strtotime($last_login_date,'UTC');
1441
-    			} else {
1442
-    				if (!$warning_message) {
1443
-    					return api_format_date($last_login_date, DATE_FORMAT_SHORT);
1444
-    				} else {
1445
-    					$timestamp = api_strtotime($last_login_date,'UTC');
1446
-    					$currentTimestamp = time();
1447
-
1448
-    					//If the last connection is > than 7 days, the text is red
1449
-    					//345600 = 7 days in seconds
1450
-    					if ($currentTimestamp - $timestamp > 604800) {
1451
-    						return '<span style="color: #F00;">' . api_format_date($last_login_date, DATE_FORMAT_SHORT) . '</span>';
1452
-    					} else {
1453
-    						return api_format_date($last_login_date, DATE_FORMAT_SHORT);
1454
-    					}
1455
-    				}
1456
-    			}
1457
-    		}
1458
-    	}
1459
-    	return false;
1435
+        $rs = Database::query($sql);
1436
+        if (Database::num_rows($rs) > 0) {
1437
+            if ($last_login_date = Database::result($rs, 0, 0)) {
1438
+                $last_login_date = api_get_local_time($last_login_date);
1439
+                if ($return_timestamp) {
1440
+                    return api_strtotime($last_login_date,'UTC');
1441
+                } else {
1442
+                    if (!$warning_message) {
1443
+                        return api_format_date($last_login_date, DATE_FORMAT_SHORT);
1444
+                    } else {
1445
+                        $timestamp = api_strtotime($last_login_date,'UTC');
1446
+                        $currentTimestamp = time();
1447
+
1448
+                        //If the last connection is > than 7 days, the text is red
1449
+                        //345600 = 7 days in seconds
1450
+                        if ($currentTimestamp - $timestamp > 604800) {
1451
+                            return '<span style="color: #F00;">' . api_format_date($last_login_date, DATE_FORMAT_SHORT) . '</span>';
1452
+                        } else {
1453
+                            return api_format_date($last_login_date, DATE_FORMAT_SHORT);
1454
+                        }
1455
+                    }
1456
+                }
1457
+            }
1458
+        }
1459
+        return false;
1460 1460
     }
1461 1461
 
1462 1462
     /**
@@ -1510,30 +1510,30 @@  discard block
 block discarded – undo
1510 1510
         $session_id = 0,
1511 1511
         $convert_date = true
1512 1512
     ) {
1513
-    	$student_id  = intval($student_id);
1513
+        $student_id  = intval($student_id);
1514 1514
         $courseId = intval($courseId);
1515
-    	$session_id  = intval($session_id);
1515
+        $session_id  = intval($session_id);
1516 1516
 
1517
-    	$tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1518
-    	$sql = 'SELECT login_course_date
1517
+        $tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1518
+        $sql = 'SELECT login_course_date
1519 1519
     	        FROM '.$tbl_track_login.'
1520 1520
                 WHERE
1521 1521
                     user_id = '.$student_id.' AND
1522 1522
                     c_id = '.$courseId.' AND
1523 1523
                     session_id = '.$session_id.'
1524 1524
                 ORDER BY login_course_date ASC LIMIT 0,1';
1525
-    	$rs = Database::query($sql);
1526
-    	if (Database::num_rows($rs) > 0) {
1527
-    		if ($first_login_date = Database::result($rs, 0, 0)) {
1528
-    			if ($convert_date) {
1529
-    				return api_convert_and_format_date($first_login_date, DATE_FORMAT_SHORT);
1530
-    			} else {
1531
-    				return $first_login_date;
1532
-    			}
1533
-    		}
1534
-    	}
1535
-
1536
-    	return false;
1525
+        $rs = Database::query($sql);
1526
+        if (Database::num_rows($rs) > 0) {
1527
+            if ($first_login_date = Database::result($rs, 0, 0)) {
1528
+                if ($convert_date) {
1529
+                    return api_convert_and_format_date($first_login_date, DATE_FORMAT_SHORT);
1530
+                } else {
1531
+                    return $first_login_date;
1532
+                }
1533
+            }
1534
+        }
1535
+
1536
+        return false;
1537 1537
     }
1538 1538
 
1539 1539
     /**
@@ -1549,13 +1549,13 @@  discard block
 block discarded – undo
1549 1549
         $session_id = 0,
1550 1550
         $convert_date = true
1551 1551
     ) {
1552
-    	// protect data
1553
-    	$student_id  = intval($student_id);
1552
+        // protect data
1553
+        $student_id  = intval($student_id);
1554 1554
         $courseId = $courseInfo['real_id'];
1555
-    	$session_id  = intval($session_id);
1555
+        $session_id  = intval($session_id);
1556 1556
 
1557
-    	$tbl_track_e_access = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
1558
-    	$sql = 'SELECT access_date
1557
+        $tbl_track_e_access = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
1558
+        $sql = 'SELECT access_date
1559 1559
                 FROM '.$tbl_track_e_access.'
1560 1560
                 WHERE   access_user_id = '.$student_id.' AND
1561 1561
                         c_id = "'.$courseId.'" AND
@@ -1563,39 +1563,39 @@  discard block
 block discarded – undo
1563 1563
                 ORDER BY access_date DESC
1564 1564
                 LIMIT 0,1';
1565 1565
 
1566
-    	$rs = Database::query($sql);
1567
-    	if (Database::num_rows($rs) > 0) {
1568
-    		if ($last_login_date = Database::result($rs, 0, 0)) {
1566
+        $rs = Database::query($sql);
1567
+        if (Database::num_rows($rs) > 0) {
1568
+            if ($last_login_date = Database::result($rs, 0, 0)) {
1569 1569
                 if (empty($last_login_date) || $last_login_date == '0000-00-00 00:00:00') {
1570 1570
                     return false;
1571 1571
                 }
1572 1572
                 //see #5736
1573 1573
                 $last_login_date_timestamp = api_strtotime($last_login_date);
1574
-    			$now = time();
1575
-    			//If the last connection is > than 7 days, the text is red
1576
-    			//345600 = 7 days in seconds
1577
-    			if ($now - $last_login_date_timestamp > 604800) {
1578
-    				if ($convert_date) {
1574
+                $now = time();
1575
+                //If the last connection is > than 7 days, the text is red
1576
+                //345600 = 7 days in seconds
1577
+                if ($now - $last_login_date_timestamp > 604800) {
1578
+                    if ($convert_date) {
1579 1579
                         $last_login_date = api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT);
1580 1580
                         $icon = api_is_allowed_to_edit() ?
1581 1581
                             '<a href="'.api_get_path(REL_CODE_PATH).'announcements/announcements.php?action=add&remind_inactive='.$student_id.'&cidReq='.$courseInfo['code'].'" title="'.get_lang('RemindInactiveUser').'">
1582 1582
                               '.Display::return_icon('messagebox_warning.gif').'
1583 1583
                              </a>'
1584 1584
                             : null;
1585
-    					return $icon. Display::label($last_login_date, 'warning');
1586
-    				} else {
1587
-    					return $last_login_date;
1588
-    				}
1589
-    			} else {
1590
-    				if ($convert_date) {
1591
-    					return api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT);
1592
-    				} else {
1593
-    					return $last_login_date;
1594
-    				}
1595
-    			}
1596
-    		}
1597
-    	}
1598
-    	return false;
1585
+                        return $icon. Display::label($last_login_date, 'warning');
1586
+                    } else {
1587
+                        return $last_login_date;
1588
+                    }
1589
+                } else {
1590
+                    if ($convert_date) {
1591
+                        return api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT);
1592
+                    } else {
1593
+                        return $last_login_date;
1594
+                    }
1595
+                }
1596
+            }
1597
+        }
1598
+        return false;
1599 1599
     }
1600 1600
 
1601 1601
     /**
@@ -1608,36 +1608,36 @@  discard block
 block discarded – undo
1608 1608
      */
1609 1609
     public static function get_course_connections_count($courseId, $session_id = 0, $start = 0, $stop = null)
1610 1610
     {
1611
-    	if ($start < 0) {
1612
-    		$start = 0;
1613
-    	}
1614
-    	if (!isset($stop) or ($stop < 0)) {
1615
-    		$stop = api_get_utc_datetime();
1616
-    	}
1611
+        if ($start < 0) {
1612
+            $start = 0;
1613
+        }
1614
+        if (!isset($stop) or ($stop < 0)) {
1615
+            $stop = api_get_utc_datetime();
1616
+        }
1617 1617
 
1618 1618
         $start = Database::escape_string($start);
1619 1619
         $stop = Database::escape_string($stop);
1620 1620
 
1621
-    	$month_filter = " AND login_course_date > '$start' AND login_course_date < '$stop' ";
1621
+        $month_filter = " AND login_course_date > '$start' AND login_course_date < '$stop' ";
1622 1622
 
1623 1623
         $courseId = intval($courseId);
1624
-    	$session_id  = intval($session_id);
1625
-    	$count = 0;
1624
+        $session_id  = intval($session_id);
1625
+        $count = 0;
1626 1626
 
1627
-    	$tbl_track_e_course_access = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1628
-    	$sql = "SELECT count(*) as count_connections
1627
+        $tbl_track_e_course_access = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1628
+        $sql = "SELECT count(*) as count_connections
1629 1629
                 FROM $tbl_track_e_course_access
1630 1630
                 WHERE
1631 1631
                     c_id = $courseId AND
1632 1632
                     session_id = $session_id
1633 1633
                     $month_filter";
1634
-    	$rs = Database::query($sql);
1635
-    	if (Database::num_rows($rs)>0) {
1636
-    		$row = Database::fetch_object($rs);
1637
-    		$count = $row->count_connections;
1638
-    	}
1634
+        $rs = Database::query($sql);
1635
+        if (Database::num_rows($rs)>0) {
1636
+            $row = Database::fetch_object($rs);
1637
+            $count = $row->count_connections;
1638
+        }
1639 1639
 
1640
-    	return $count;
1640
+        return $count;
1641 1641
     }
1642 1642
 
1643 1643
     /**
@@ -1648,25 +1648,25 @@  discard block
 block discarded – undo
1648 1648
      */
1649 1649
     public static function count_course_per_student($user_id, $include_sessions = true)
1650 1650
     {
1651
-    	$user_id = intval($user_id);
1652
-    	$tbl_course_rel_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
1653
-    	$tbl_session_course_rel_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
1651
+        $user_id = intval($user_id);
1652
+        $tbl_course_rel_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
1653
+        $tbl_session_course_rel_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
1654 1654
 
1655
-    	$sql = 'SELECT DISTINCT c_id
1655
+        $sql = 'SELECT DISTINCT c_id
1656 1656
                 FROM ' . $tbl_course_rel_user . '
1657 1657
                 WHERE user_id = ' . $user_id.' AND relation_type<>'.COURSE_RELATION_TYPE_RRHH;
1658
-    	$rs = Database::query($sql);
1659
-    	$nb_courses = Database::num_rows($rs);
1658
+        $rs = Database::query($sql);
1659
+        $nb_courses = Database::num_rows($rs);
1660 1660
 
1661
-    	if ($include_sessions) {
1662
-    		$sql = 'SELECT DISTINCT c_id
1661
+        if ($include_sessions) {
1662
+            $sql = 'SELECT DISTINCT c_id
1663 1663
                     FROM ' . $tbl_session_course_rel_user . '
1664 1664
                     WHERE user_id = ' . $user_id;
1665
-    		$rs = Database::query($sql);
1666
-    		$nb_courses += Database::num_rows($rs);
1667
-    	}
1665
+            $rs = Database::query($sql);
1666
+            $nb_courses += Database::num_rows($rs);
1667
+        }
1668 1668
 
1669
-    	return $nb_courses;
1669
+        return $nb_courses;
1670 1670
     }
1671 1671
 
1672 1672
     /**
@@ -1697,25 +1697,25 @@  discard block
 block discarded – undo
1697 1697
         $into_lp = 0
1698 1698
     ) {
1699 1699
         $course_code = Database::escape_string($course_code);
1700
-    	$course_info = api_get_course_info($course_code);
1701
-    	if (!empty($course_info)) {
1702
-    		// table definition
1703
-    		$tbl_course_quiz     = Database::get_course_table(TABLE_QUIZ_TEST);
1704
-    		$tbl_stats_exercise  = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
1705
-
1706
-    		// Compose a filter based on optional exercise given
1707
-    		$condition_quiz = "";
1708
-    		if (!empty($exercise_id)) {
1709
-    			$exercise_id = intval($exercise_id);
1710
-    			$condition_quiz =" AND id = $exercise_id ";
1711
-    		}
1712
-
1713
-    		// Compose a filter based on optional session id given
1714
-    		$condition_session = "";
1715
-    		if (isset($session_id)) {
1716
-    			$session_id = intval($session_id);
1717
-    			$condition_session = " AND session_id = $session_id ";
1718
-    		}
1700
+        $course_info = api_get_course_info($course_code);
1701
+        if (!empty($course_info)) {
1702
+            // table definition
1703
+            $tbl_course_quiz     = Database::get_course_table(TABLE_QUIZ_TEST);
1704
+            $tbl_stats_exercise  = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
1705
+
1706
+            // Compose a filter based on optional exercise given
1707
+            $condition_quiz = "";
1708
+            if (!empty($exercise_id)) {
1709
+                $exercise_id = intval($exercise_id);
1710
+                $condition_quiz =" AND id = $exercise_id ";
1711
+            }
1712
+
1713
+            // Compose a filter based on optional session id given
1714
+            $condition_session = "";
1715
+            if (isset($session_id)) {
1716
+                $session_id = intval($session_id);
1717
+                $condition_session = " AND session_id = $session_id ";
1718
+            }
1719 1719
             if ($active_filter == 1) {
1720 1720
                 $condition_active = 'AND active <> -1';
1721 1721
             } elseif ($active_filter == 0) {
@@ -1731,25 +1731,25 @@  discard block
 block discarded – undo
1731 1731
                 $select_lp_id = ', orig_lp_id as lp_id ';
1732 1732
             }
1733 1733
 
1734
-    		$sql = "SELECT count(id) FROM $tbl_course_quiz
1734
+            $sql = "SELECT count(id) FROM $tbl_course_quiz
1735 1735
     				WHERE c_id = {$course_info['real_id']} $condition_active $condition_quiz ";
1736
-    		$count_quiz = Database::fetch_row(Database::query($sql));
1736
+            $count_quiz = Database::fetch_row(Database::query($sql));
1737 1737
 
1738
-    		if (!empty($count_quiz[0]) && !empty($student_id)) {
1739
-    			if (is_array($student_id)) {
1738
+            if (!empty($count_quiz[0]) && !empty($student_id)) {
1739
+                if (is_array($student_id)) {
1740 1740
                     $student_id = array_map('intval', $student_id);
1741
-    				$condition_user = " AND exe_user_id IN (".implode(',', $student_id).") ";
1742
-    			} else {
1741
+                    $condition_user = " AND exe_user_id IN (".implode(',', $student_id).") ";
1742
+                } else {
1743 1743
                     $student_id = intval($student_id);
1744
-    				$condition_user = " AND exe_user_id = '$student_id' ";
1745
-    			}
1744
+                    $condition_user = " AND exe_user_id = '$student_id' ";
1745
+                }
1746 1746
 
1747
-    			if (empty($exercise_id)) {
1748
-    				$sql = "SELECT id FROM $tbl_course_quiz
1747
+                if (empty($exercise_id)) {
1748
+                    $sql = "SELECT id FROM $tbl_course_quiz
1749 1749
     						WHERE c_id = {$course_info['real_id']} $condition_active $condition_quiz";
1750 1750
                     $result = Database::query($sql);
1751 1751
                     $exercise_list = array();
1752
-    				$exercise_id = null;
1752
+                    $exercise_id = null;
1753 1753
                     if (Database::num_rows($result)) {
1754 1754
                         while ($row = Database::fetch_array($result)) {
1755 1755
                             $exercise_list[] = $row['id'];
@@ -1758,11 +1758,11 @@  discard block
 block discarded – undo
1758 1758
                     if (!empty($exercise_list)) {
1759 1759
                         $exercise_id = implode("','",$exercise_list);
1760 1760
                     }
1761
-    			}
1761
+                }
1762 1762
 
1763
-    			$count_quiz = Database::fetch_row(Database::query($sql));
1763
+                $count_quiz = Database::fetch_row(Database::query($sql));
1764 1764
 
1765
-    			$sql = "SELECT
1765
+                $sql = "SELECT
1766 1766
     			        SUM(exe_result/exe_weighting*100) as avg_score,
1767 1767
     			        COUNT(*) as num_attempts
1768 1768
     			        $select_lp_id
@@ -1776,20 +1776,20 @@  discard block
 block discarded – undo
1776 1776
                             $condition_into_lp
1777 1777
                         ORDER BY exe_date DESC";
1778 1778
 
1779
-    			$res = Database::query($sql);
1780
-    			$row = Database::fetch_array($res);
1781
-    			$quiz_avg_score = null;
1779
+                $res = Database::query($sql);
1780
+                $row = Database::fetch_array($res);
1781
+                $quiz_avg_score = null;
1782 1782
 
1783
-    			if (!empty($row['avg_score'])) {
1784
-    				$quiz_avg_score = round($row['avg_score'],2);
1785
-    			}
1783
+                if (!empty($row['avg_score'])) {
1784
+                    $quiz_avg_score = round($row['avg_score'],2);
1785
+                }
1786 1786
 
1787
-    			if(!empty($row['num_attempts'])) {
1788
-    				$quiz_avg_score = round($quiz_avg_score / $row['num_attempts'], 2);
1789
-    			}
1790
-    			if (is_array($student_id)) {
1791
-    				$quiz_avg_score = round($quiz_avg_score / count($student_id), 2);
1792
-    			}
1787
+                if(!empty($row['num_attempts'])) {
1788
+                    $quiz_avg_score = round($quiz_avg_score / $row['num_attempts'], 2);
1789
+                }
1790
+                if (is_array($student_id)) {
1791
+                    $quiz_avg_score = round($quiz_avg_score / count($student_id), 2);
1792
+                }
1793 1793
                 if ($into_lp == 0) {
1794 1794
                     return $quiz_avg_score;
1795 1795
                 } else {
@@ -1812,9 +1812,9 @@  discard block
 block discarded – undo
1812 1812
                         return array($quiz_avg_score, null);
1813 1813
                     }
1814 1814
                 }
1815
-    		}
1816
-    	}
1817
-    	return null;
1815
+            }
1816
+        }
1817
+        return null;
1818 1818
     }
1819 1819
 
1820 1820
     /**
@@ -1847,15 +1847,15 @@  discard block
 block discarded – undo
1847 1847
         $find_all_lp = 0
1848 1848
     ) {
1849 1849
         $courseId = intval($courseId);
1850
-    	$student_id  = intval($student_id);
1851
-    	$exercise_id = intval($exercise_id);
1852
-    	$session_id  = intval($session_id);
1850
+        $student_id  = intval($student_id);
1851
+        $exercise_id = intval($exercise_id);
1852
+        $session_id  = intval($session_id);
1853 1853
 
1854
-    	$lp_id = intval($lp_id);
1854
+        $lp_id = intval($lp_id);
1855 1855
         $lp_item_id = intval($lp_item_id);
1856
-    	$tbl_stats_exercises = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
1856
+        $tbl_stats_exercises = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
1857 1857
 
1858
-    	$sql = "SELECT COUNT(ex.exe_id) as essais FROM $tbl_stats_exercises AS ex
1858
+        $sql = "SELECT COUNT(ex.exe_id) as essais FROM $tbl_stats_exercises AS ex
1859 1859
                 WHERE  ex.c_id = $courseId
1860 1860
                 AND ex.exe_exo_id = $exercise_id
1861 1861
                 AND status = ''
@@ -1870,11 +1870,11 @@  discard block
 block discarded – undo
1870 1870
                 AND orig_lp_item_id = $lp_item_id";
1871 1871
         }
1872 1872
 
1873
-    	$rs = Database::query($sql);
1874
-    	$row = Database::fetch_row($rs);
1875
-    	$count_attempts = $row[0];
1873
+        $rs = Database::query($sql);
1874
+        $row = Database::fetch_row($rs);
1875
+        $count_attempts = $row[0];
1876 1876
 
1877
-    	return $count_attempts;
1877
+        return $count_attempts;
1878 1878
     }
1879 1879
 
1880 1880
     /**
@@ -1884,7 +1884,7 @@  discard block
 block discarded – undo
1884 1884
      * @param int    $user_id
1885 1885
      * @param int    $courseId
1886 1886
      * @param int    $session_id
1887
-    */
1887
+     */
1888 1888
     public static function get_exercise_student_progress($exercise_list, $user_id, $courseId, $session_id)
1889 1889
     {
1890 1890
         $courseId = intval($courseId);
@@ -3500,8 +3500,8 @@  discard block
 block discarded – undo
3500 3500
 
3501 3501
         $condition_session = '';
3502 3502
         if (isset($session_id)) {
3503
-             $session_id = intval($session_id);
3504
-             $condition_session = ' AND f.session_id = '. $session_id;
3503
+                $session_id = intval($session_id);
3504
+                $condition_session = ' AND f.session_id = '. $session_id;
3505 3505
         }
3506 3506
 
3507 3507
         $groupId = intval($groupId);
@@ -5400,9 +5400,9 @@  discard block
 block discarded – undo
5400 5400
     }
5401 5401
 
5402 5402
     /**
5403
-    * @param FormValidator $form
5404
-    * @return mixed
5405
-    */
5403
+     * @param FormValidator $form
5404
+     * @return mixed
5405
+     */
5406 5406
     public static function setUserSearchForm($form)
5407 5407
     {
5408 5408
         global $_configuration;
@@ -5681,26 +5681,26 @@  discard block
 block discarded – undo
5681 5681
         $session_id = api_get_session_id();
5682 5682
         $course_id = api_get_course_int_id();
5683 5683
 
5684
-    	$table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
5685
-    	$table_user = Database :: get_main_table(TABLE_MAIN_USER);
5684
+        $table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
5685
+        $table_user = Database :: get_main_table(TABLE_MAIN_USER);
5686 5686
 
5687
-    	$sql = "SELECT count(tool) AS total_number_of_items
5687
+        $sql = "SELECT count(tool) AS total_number_of_items
5688 5688
     	        FROM $table_item_property track_resource, $table_user user
5689 5689
     	        WHERE
5690 5690
                     track_resource.c_id = $course_id AND
5691 5691
                     track_resource.insert_user_id = user.user_id AND
5692 5692
                     session_id " .(empty($session_id) ? ' IS NULL ' : " = $session_id ");
5693 5693
 
5694
-    	if (isset($_GET['keyword'])) {
5695
-    		$keyword = Database::escape_string(trim($_GET['keyword']));
5696
-    		$sql .= " AND (
5694
+        if (isset($_GET['keyword'])) {
5695
+            $keyword = Database::escape_string(trim($_GET['keyword']));
5696
+            $sql .= " AND (
5697 5697
     		            user.username LIKE '%".$keyword."%' OR
5698 5698
     		            lastedit_type LIKE '%".$keyword."%' OR
5699 5699
     		            tool LIKE '%".$keyword."%'
5700 5700
                     )";
5701
-    	}
5701
+        }
5702 5702
 
5703
-    	$sql .= " AND tool IN (
5703
+        $sql .= " AND tool IN (
5704 5704
     	            'document',
5705 5705
     	            'learnpath',
5706 5706
     	            'quiz',
@@ -5712,10 +5712,10 @@  discard block
 block discarded – undo
5712 5712
     	            'thematic_advance',
5713 5713
     	            'thematic_plan'
5714 5714
                 )";
5715
-    	$res = Database::query($sql);
5716
-    	$obj = Database::fetch_object($res);
5715
+        $res = Database::query($sql);
5716
+        $obj = Database::fetch_object($res);
5717 5717
 
5718
-    	return $obj->total_number_of_items;
5718
+        return $obj->total_number_of_items;
5719 5719
     }
5720 5720
 
5721 5721
     /**
@@ -5730,12 +5730,12 @@  discard block
 block discarded – undo
5730 5730
         $session_id = api_get_session_id();
5731 5731
         $course_id = api_get_course_int_id();
5732 5732
 
5733
-    	$table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
5734
-    	$table_user = Database :: get_main_table(TABLE_MAIN_USER);
5735
-    	$table_session = Database :: get_main_table(TABLE_MAIN_SESSION);
5736
-    	$session_id = intval($session_id);
5733
+        $table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
5734
+        $table_user = Database :: get_main_table(TABLE_MAIN_USER);
5735
+        $table_session = Database :: get_main_table(TABLE_MAIN_SESSION);
5736
+        $session_id = intval($session_id);
5737 5737
 
5738
-    	$sql = "SELECT
5738
+        $sql = "SELECT
5739 5739
                     tool as col0,
5740 5740
                     lastedit_type as col1,
5741 5741
                     ref as ref,
@@ -5749,16 +5749,16 @@  discard block
 block discarded – undo
5749 5749
                   track_resource.insert_user_id = user.user_id AND
5750 5750
                   session_id " .(empty($session_id) ? ' IS NULL ' : " = $session_id ");
5751 5751
 
5752
-    	if (isset($_GET['keyword'])) {
5753
-    		$keyword = Database::escape_string(trim($_GET['keyword']));
5754
-    		$sql .= " AND (
5752
+        if (isset($_GET['keyword'])) {
5753
+            $keyword = Database::escape_string(trim($_GET['keyword']));
5754
+            $sql .= " AND (
5755 5755
     		            user.username LIKE '%".$keyword."%' OR
5756 5756
     		            lastedit_type LIKE '%".$keyword."%' OR
5757 5757
     		            tool LIKE '%".$keyword."%'
5758 5758
                      ) ";
5759
-    	}
5759
+        }
5760 5760
 
5761
-    	$sql .= " AND tool IN (
5761
+        $sql .= " AND tool IN (
5762 5762
     	            'document',
5763 5763
     	            'learnpath',
5764 5764
     	            'quiz',
@@ -5771,41 +5771,41 @@  discard block
 block discarded – undo
5771 5771
     	            'thematic_plan'
5772 5772
                 )";
5773 5773
 
5774
-    	if ($column == 0) {
5775
-    		$column = '0';
5776
-    	}
5777
-    	if ($column != '' && $direction != '') {
5778
-    		if ($column != 2 && $column != 4) {
5779
-    			$sql .= " ORDER BY col$column $direction";
5780
-    		}
5781
-    	} else {
5782
-    		$sql .= " ORDER BY col5 DESC ";
5783
-    	}
5774
+        if ($column == 0) {
5775
+            $column = '0';
5776
+        }
5777
+        if ($column != '' && $direction != '') {
5778
+            if ($column != 2 && $column != 4) {
5779
+                $sql .= " ORDER BY col$column $direction";
5780
+            }
5781
+        } else {
5782
+            $sql .= " ORDER BY col5 DESC ";
5783
+        }
5784 5784
 
5785 5785
         $from = intval($from);
5786 5786
         $number_of_items = intval($number_of_items);
5787 5787
 
5788
-    	$sql .= " LIMIT $from, $number_of_items ";
5789
-
5790
-    	$res = Database::query($sql);
5791
-    	$resources = array();
5792
-    	$thematic_tools = array('thematic', 'thematic_advance', 'thematic_plan');
5793
-    	while ($row = Database::fetch_array($res)) {
5794
-    		$ref = $row['ref'];
5795
-    		$table_name = TrackingCourseLog::get_tool_name_table($row['col0']);
5796
-    		$table_tool = Database :: get_course_table($table_name['table_name']);
5797
-
5798
-    		$id = $table_name['id_tool'];
5799
-    		$recorset = false;
5788
+        $sql .= " LIMIT $from, $number_of_items ";
5800 5789
 
5801
-    		if (in_array($row['col0'], array('thematic_plan', 'thematic_advance'))) {
5802
-    			$tbl_thematic = Database :: get_course_table(TABLE_THEMATIC);
5803
-    			$sql = "SELECT thematic_id FROM $table_tool
5790
+        $res = Database::query($sql);
5791
+        $resources = array();
5792
+        $thematic_tools = array('thematic', 'thematic_advance', 'thematic_plan');
5793
+        while ($row = Database::fetch_array($res)) {
5794
+            $ref = $row['ref'];
5795
+            $table_name = TrackingCourseLog::get_tool_name_table($row['col0']);
5796
+            $table_tool = Database :: get_course_table($table_name['table_name']);
5797
+
5798
+            $id = $table_name['id_tool'];
5799
+            $recorset = false;
5800
+
5801
+            if (in_array($row['col0'], array('thematic_plan', 'thematic_advance'))) {
5802
+                $tbl_thematic = Database :: get_course_table(TABLE_THEMATIC);
5803
+                $sql = "SELECT thematic_id FROM $table_tool
5804 5804
     			        WHERE c_id = $course_id AND id = $ref";
5805
-    			$rs_thematic  = Database::query($sql);
5806
-    			if (Database::num_rows($rs_thematic)) {
5807
-    				$row_thematic = Database::fetch_array($rs_thematic);
5808
-    				$thematic_id = $row_thematic['thematic_id'];
5805
+                $rs_thematic  = Database::query($sql);
5806
+                if (Database::num_rows($rs_thematic)) {
5807
+                    $row_thematic = Database::fetch_array($rs_thematic);
5808
+                    $thematic_id = $row_thematic['thematic_id'];
5809 5809
 
5810 5810
                     $sql = "SELECT session.id, session.name, user.username
5811 5811
                             FROM $tbl_thematic t, $table_session session, $table_user user
@@ -5814,9 +5814,9 @@  discard block
 block discarded – undo
5814 5814
                               t.session_id = session.id AND
5815 5815
                               session.id_coach = user.user_id AND
5816 5816
                               t.id = $thematic_id";
5817
-    				$recorset = Database::query($sql);
5818
-    			}
5819
-    		} else {
5817
+                    $recorset = Database::query($sql);
5818
+                }
5819
+            } else {
5820 5820
                 $sql = "SELECT session.id, session.name, user.username
5821 5821
                           FROM $table_tool tool, $table_session session, $table_user user
5822 5822
     			          WHERE
@@ -5824,127 +5824,127 @@  discard block
 block discarded – undo
5824 5824
     			              tool.session_id = session.id AND
5825 5825
     			              session.id_coach = user.user_id AND
5826 5826
     			              tool.$id = $ref";
5827
-    			$recorset = Database::query($sql);
5828
-    		}
5829
-
5830
-    		if (!empty($recorset)) {
5831
-    			$obj = Database::fetch_object($recorset);
5832
-
5833
-    			$name_session = '';
5834
-    			$coach_name = '';
5835
-    			if (!empty($obj)) {
5836
-    				$name_session = $obj->name;
5837
-    				$coach_name   = $obj->username;
5838
-    			}
5839
-
5840
-    			$url_tool = api_get_path(WEB_CODE_PATH).$table_name['link_tool'];
5841
-    			$row[0] = '';
5842
-    			if ($row['col6'] != 2) {
5843
-    				if (in_array($row['col0'], $thematic_tools)) {
5844
-
5845
-    					$exp_thematic_tool = explode('_', $row['col0']);
5846
-    					$thematic_tool_title = '';
5847
-    					if (is_array($exp_thematic_tool)) {
5848
-    						foreach ($exp_thematic_tool as $exp) {
5849
-    							$thematic_tool_title .= api_ucfirst($exp);
5850
-    						}
5851
-    					} else {
5852
-    						$thematic_tool_title = api_ucfirst($row['col0']);
5853
-    					}
5854
-
5855
-    					$row[0] = '<a href="'.$url_tool.'?'.api_get_cidreq().'&action=thematic_details">'.get_lang($thematic_tool_title).'</a>';
5856
-    				} else {
5857
-    					$row[0] = '<a href="'.$url_tool.'?'.api_get_cidreq().'">'.get_lang('Tool'.api_ucfirst($row['col0'])).'</a>';
5858
-    				}
5859
-    			} else {
5860
-    				$row[0] = api_ucfirst($row['col0']);
5861
-    			}
5862
-    			$row[1] = get_lang($row[1]);
5863
-    			$row[6] = api_convert_and_format_date($row['col5'], null, date_default_timezone_get());
5864
-    			$row[5] = '';
5865
-    			//@todo Improve this code please
5866
-    			switch ($table_name['table_name']) {
5867
-    				case 'document' :
5868
-    					$sql = "SELECT tool.title as title FROM $table_tool tool
5827
+                $recorset = Database::query($sql);
5828
+            }
5829
+
5830
+            if (!empty($recorset)) {
5831
+                $obj = Database::fetch_object($recorset);
5832
+
5833
+                $name_session = '';
5834
+                $coach_name = '';
5835
+                if (!empty($obj)) {
5836
+                    $name_session = $obj->name;
5837
+                    $coach_name   = $obj->username;
5838
+                }
5839
+
5840
+                $url_tool = api_get_path(WEB_CODE_PATH).$table_name['link_tool'];
5841
+                $row[0] = '';
5842
+                if ($row['col6'] != 2) {
5843
+                    if (in_array($row['col0'], $thematic_tools)) {
5844
+
5845
+                        $exp_thematic_tool = explode('_', $row['col0']);
5846
+                        $thematic_tool_title = '';
5847
+                        if (is_array($exp_thematic_tool)) {
5848
+                            foreach ($exp_thematic_tool as $exp) {
5849
+                                $thematic_tool_title .= api_ucfirst($exp);
5850
+                            }
5851
+                        } else {
5852
+                            $thematic_tool_title = api_ucfirst($row['col0']);
5853
+                        }
5854
+
5855
+                        $row[0] = '<a href="'.$url_tool.'?'.api_get_cidreq().'&action=thematic_details">'.get_lang($thematic_tool_title).'</a>';
5856
+                    } else {
5857
+                        $row[0] = '<a href="'.$url_tool.'?'.api_get_cidreq().'">'.get_lang('Tool'.api_ucfirst($row['col0'])).'</a>';
5858
+                    }
5859
+                } else {
5860
+                    $row[0] = api_ucfirst($row['col0']);
5861
+                }
5862
+                $row[1] = get_lang($row[1]);
5863
+                $row[6] = api_convert_and_format_date($row['col5'], null, date_default_timezone_get());
5864
+                $row[5] = '';
5865
+                //@todo Improve this code please
5866
+                switch ($table_name['table_name']) {
5867
+                    case 'document' :
5868
+                        $sql = "SELECT tool.title as title FROM $table_tool tool
5869 5869
                                 WHERE c_id = $course_id AND id = $ref";
5870
-    					$rs_document = Database::query($sql);
5871
-    					$obj_document = Database::fetch_object($rs_document);
5872
-    					$row[5] = $obj_document->title;
5870
+                        $rs_document = Database::query($sql);
5871
+                        $obj_document = Database::fetch_object($rs_document);
5872
+                        $row[5] = $obj_document->title;
5873 5873
 
5874
-    					break;
5875
-    				case 'announcement':
5874
+                        break;
5875
+                    case 'announcement':
5876 5876
                         $sql = "SELECT title FROM $table_tool
5877 5877
                                 WHERE c_id = $course_id AND id = $ref";
5878
-    					$rs_document = Database::query($sql);
5879
-    					$obj_document = Database::fetch_object($rs_document);
5878
+                        $rs_document = Database::query($sql);
5879
+                        $obj_document = Database::fetch_object($rs_document);
5880 5880
                         if ($obj_document) {
5881 5881
                             $row[5] = $obj_document->title;
5882 5882
                         }
5883
-    					break;
5884
-    				case 'glossary':
5883
+                        break;
5884
+                    case 'glossary':
5885 5885
                         $sql = "SELECT name FROM $table_tool
5886 5886
     					        WHERE c_id = $course_id AND glossary_id = $ref";
5887
-    					$rs_document = Database::query($sql);
5888
-    					$obj_document = Database::fetch_object($rs_document);
5887
+                        $rs_document = Database::query($sql);
5888
+                        $obj_document = Database::fetch_object($rs_document);
5889 5889
                         if ($obj_document) {
5890 5890
                             $row[5] = $obj_document->name;
5891 5891
                         }
5892
-    					break;
5893
-    				case 'lp':
5892
+                        break;
5893
+                    case 'lp':
5894 5894
                         $sql = "SELECT name
5895 5895
                                 FROM $table_tool WHERE c_id = $course_id AND id = $ref";
5896
-    					$rs_document = Database::query($sql);
5897
-    					$obj_document = Database::fetch_object($rs_document);
5898
-    					$row[5] = $obj_document->name;
5899
-    					break;
5900
-    				case 'quiz':
5896
+                        $rs_document = Database::query($sql);
5897
+                        $obj_document = Database::fetch_object($rs_document);
5898
+                        $row[5] = $obj_document->name;
5899
+                        break;
5900
+                    case 'quiz':
5901 5901
                         $sql = "SELECT title FROM $table_tool
5902 5902
                                 WHERE c_id = $course_id AND id = $ref";
5903
-    					$rs_document = Database::query($sql);
5904
-    					$obj_document = Database::fetch_object($rs_document);
5903
+                        $rs_document = Database::query($sql);
5904
+                        $obj_document = Database::fetch_object($rs_document);
5905 5905
                         if ($obj_document) {
5906 5906
                             $row[5] = $obj_document->title;
5907 5907
                         }
5908
-    					break;
5909
-    				case 'course_description':
5908
+                        break;
5909
+                    case 'course_description':
5910 5910
                         $sql = "SELECT title FROM $table_tool
5911 5911
                                 WHERE c_id = $course_id AND id = $ref";
5912
-    					$rs_document = Database::query($sql);
5913
-    					$obj_document = Database::fetch_object($rs_document);
5912
+                        $rs_document = Database::query($sql);
5913
+                        $obj_document = Database::fetch_object($rs_document);
5914 5914
                         if ($obj_document) {
5915 5915
                             $row[5] = $obj_document->title;
5916 5916
                         }
5917
-    					break;
5918
-    				case 'thematic':
5919
-    					$rs = Database::query("SELECT title FROM $table_tool WHERE c_id = $course_id AND id = $ref");
5920
-    					if (Database::num_rows($rs) > 0) {
5921
-    						$obj = Database::fetch_object($rs);
5922
-    						$row[5] = $obj->title;
5923
-    					}
5924
-    					break;
5925
-    				case 'thematic_advance':
5926
-    					$rs = Database::query("SELECT content FROM $table_tool WHERE c_id = $course_id AND id = $ref");
5927
-    					if (Database::num_rows($rs) > 0) {
5928
-    						$obj = Database::fetch_object($rs);
5929
-    						$row[5] = $obj->content;
5930
-    					}
5931
-    					break;
5932
-    				case 'thematic_plan':
5933
-    					$rs = Database::query("SELECT title FROM $table_tool WHERE c_id = $course_id AND id = $ref");
5934
-    					if (Database::num_rows($rs) > 0) {
5935
-    						$obj = Database::fetch_object($rs);
5936
-    						$row[5] = $obj->title;
5937
-    					}
5938
-    					break;
5939
-    				default:
5940
-    					break;
5941
-    			}
5942
-
5943
-    			$row2 = $name_session;
5944
-    			if (!empty($coach_name)) {
5945
-    				$row2 .= '<br />'.get_lang('Coach').': '.$coach_name;
5946
-    			}
5947
-    			$row[2] = $row2;
5917
+                        break;
5918
+                    case 'thematic':
5919
+                        $rs = Database::query("SELECT title FROM $table_tool WHERE c_id = $course_id AND id = $ref");
5920
+                        if (Database::num_rows($rs) > 0) {
5921
+                            $obj = Database::fetch_object($rs);
5922
+                            $row[5] = $obj->title;
5923
+                        }
5924
+                        break;
5925
+                    case 'thematic_advance':
5926
+                        $rs = Database::query("SELECT content FROM $table_tool WHERE c_id = $course_id AND id = $ref");
5927
+                        if (Database::num_rows($rs) > 0) {
5928
+                            $obj = Database::fetch_object($rs);
5929
+                            $row[5] = $obj->content;
5930
+                        }
5931
+                        break;
5932
+                    case 'thematic_plan':
5933
+                        $rs = Database::query("SELECT title FROM $table_tool WHERE c_id = $course_id AND id = $ref");
5934
+                        if (Database::num_rows($rs) > 0) {
5935
+                            $obj = Database::fetch_object($rs);
5936
+                            $row[5] = $obj->title;
5937
+                        }
5938
+                        break;
5939
+                    default:
5940
+                        break;
5941
+                }
5942
+
5943
+                $row2 = $name_session;
5944
+                if (!empty($coach_name)) {
5945
+                    $row2 .= '<br />'.get_lang('Coach').': '.$coach_name;
5946
+                }
5947
+                $row[2] = $row2;
5948 5948
                 if (!empty($row['col3'])) {
5949 5949
                     $userInfo = api_get_user_info($row['user_id']);
5950 5950
 
@@ -5961,11 +5961,11 @@  discard block
 block discarded – undo
5961 5961
                     $row[4] = $ip;
5962 5962
                 }
5963 5963
 
5964
-    			$resources[] = $row;
5965
-    		}
5966
-    	}
5964
+                $resources[] = $row;
5965
+            }
5966
+        }
5967 5967
 
5968
-    	return $resources;
5968
+        return $resources;
5969 5969
     }
5970 5970
 
5971 5971
     /**
@@ -5975,63 +5975,63 @@  discard block
 block discarded – undo
5975 5975
      */
5976 5976
     public static function get_tool_name_table($tool)
5977 5977
     {
5978
-    	switch ($tool) {
5979
-    		case 'document':
5980
-    			$table_name = TABLE_DOCUMENT;
5981
-    			$link_tool = 'document/document.php';
5982
-    			$id_tool = 'id';
5983
-    			break;
5984
-    		case 'learnpath':
5985
-    			$table_name = TABLE_LP_MAIN;
5986
-    			$link_tool = 'newscorm/lp_controller.php';
5987
-    			$id_tool = 'id';
5988
-    			break;
5989
-    		case 'quiz':
5990
-    			$table_name = TABLE_QUIZ_TEST;
5991
-    			$link_tool = 'exercice/exercice.php';
5992
-    			$id_tool = 'id';
5993
-    			break;
5994
-    		case 'glossary':
5995
-    			$table_name = TABLE_GLOSSARY;
5996
-    			$link_tool = 'glossary/index.php';
5997
-    			$id_tool = 'glossary_id';
5998
-    			break;
5999
-    		case 'link':
6000
-    			$table_name = TABLE_LINK;
6001
-    			$link_tool = 'link/link.php';
6002
-    			$id_tool = 'id';
6003
-    			break;
6004
-    		case 'course_description':
6005
-    			$table_name = TABLE_COURSE_DESCRIPTION;
6006
-    			$link_tool = 'course_description/';
6007
-    			$id_tool = 'id';
6008
-    			break;
6009
-    		case 'announcement':
6010
-    			$table_name = TABLE_ANNOUNCEMENT;
6011
-    			$link_tool = 'announcements/announcements.php';
6012
-    			$id_tool = 'id';
6013
-    			break;
6014
-    		case 'thematic':
6015
-    			$table_name = TABLE_THEMATIC;
6016
-    			$link_tool = 'course_progress/index.php';
6017
-    			$id_tool = 'id';
6018
-    			break;
6019
-    		case 'thematic_advance':
6020
-    			$table_name = TABLE_THEMATIC_ADVANCE;
6021
-    			$link_tool = 'course_progress/index.php';
6022
-    			$id_tool = 'id';
6023
-    			break;
6024
-    		case 'thematic_plan':
6025
-    			$table_name = TABLE_THEMATIC_PLAN;
6026
-    			$link_tool = 'course_progress/index.php';
6027
-    			$id_tool = 'id';
6028
-    			break;
6029
-    		default:
6030
-    			$table_name = $tool;
6031
-    		break;
6032
-    	}
6033
-
6034
-    	return array(
5978
+        switch ($tool) {
5979
+            case 'document':
5980
+                $table_name = TABLE_DOCUMENT;
5981
+                $link_tool = 'document/document.php';
5982
+                $id_tool = 'id';
5983
+                break;
5984
+            case 'learnpath':
5985
+                $table_name = TABLE_LP_MAIN;
5986
+                $link_tool = 'newscorm/lp_controller.php';
5987
+                $id_tool = 'id';
5988
+                break;
5989
+            case 'quiz':
5990
+                $table_name = TABLE_QUIZ_TEST;
5991
+                $link_tool = 'exercice/exercice.php';
5992
+                $id_tool = 'id';
5993
+                break;
5994
+            case 'glossary':
5995
+                $table_name = TABLE_GLOSSARY;
5996
+                $link_tool = 'glossary/index.php';
5997
+                $id_tool = 'glossary_id';
5998
+                break;
5999
+            case 'link':
6000
+                $table_name = TABLE_LINK;
6001
+                $link_tool = 'link/link.php';
6002
+                $id_tool = 'id';
6003
+                break;
6004
+            case 'course_description':
6005
+                $table_name = TABLE_COURSE_DESCRIPTION;
6006
+                $link_tool = 'course_description/';
6007
+                $id_tool = 'id';
6008
+                break;
6009
+            case 'announcement':
6010
+                $table_name = TABLE_ANNOUNCEMENT;
6011
+                $link_tool = 'announcements/announcements.php';
6012
+                $id_tool = 'id';
6013
+                break;
6014
+            case 'thematic':
6015
+                $table_name = TABLE_THEMATIC;
6016
+                $link_tool = 'course_progress/index.php';
6017
+                $id_tool = 'id';
6018
+                break;
6019
+            case 'thematic_advance':
6020
+                $table_name = TABLE_THEMATIC_ADVANCE;
6021
+                $link_tool = 'course_progress/index.php';
6022
+                $id_tool = 'id';
6023
+                break;
6024
+            case 'thematic_plan':
6025
+                $table_name = TABLE_THEMATIC_PLAN;
6026
+                $link_tool = 'course_progress/index.php';
6027
+                $id_tool = 'id';
6028
+                break;
6029
+            default:
6030
+                $table_name = $tool;
6031
+            break;
6032
+        }
6033
+
6034
+        return array(
6035 6035
             'table_name' => $table_name,
6036 6036
             'link_tool' => $link_tool,
6037 6037
             'id_tool' => $id_tool
@@ -6040,45 +6040,45 @@  discard block
 block discarded – undo
6040 6040
 
6041 6041
     public static function display_additional_profile_fields()
6042 6042
     {
6043
-    	// getting all the extra profile fields that are defined by the platform administrator
6044
-    	$extra_fields = UserManager :: get_extra_fields(0,50,5,'ASC');
6045
-
6046
-    	// creating the form
6047
-    	$return = '<form action="courseLog.php" method="get" name="additional_profile_field_form" id="additional_profile_field_form">';
6048
-
6049
-    	// the select field with the additional user profile fields (= this is where we select the field of which we want to see
6050
-    	// the information the users have entered or selected.
6051
-    	$return .= '<select name="additional_profile_field">';
6052
-    	$return .= '<option value="-">'.get_lang('SelectFieldToAdd').'</option>';
6053
-    	$extra_fields_to_show = 0;
6054
-    	foreach ($extra_fields as $key=>$field) {
6055
-    		// show only extra fields that are visible + and can be filtered, added by J.Montoya
6056
-    		if ($field[6]==1 && $field[8] == 1) {
6057
-    			if (isset($_GET['additional_profile_field']) && $field[0] == $_GET['additional_profile_field'] ) {
6058
-    				$selected = 'selected="selected"';
6059
-    			} else {
6060
-    				$selected = '';
6061
-    			}
6062
-    			$extra_fields_to_show++;
6063
-    			$return .= '<option value="'.$field[0].'" '.$selected.'>'.$field[3].'</option>';
6064
-    		}
6065
-    	}
6066
-    	$return .= '</select>';
6067
-
6068
-    	// the form elements for the $_GET parameters (because the form is passed through GET
6069
-    	foreach ($_GET as $key=>$value){
6070
-    		if ($key <> 'additional_profile_field')    {
6071
-    			$return .= '<input type="hidden" name="'.Security::remove_XSS($key).'" value="'.Security::remove_XSS($value).'" />';
6072
-    		}
6073
-    	}
6074
-    	// the submit button
6075
-    	$return .= '<button class="save" type="submit">'.get_lang('AddAdditionalProfileField').'</button>';
6076
-    	$return .= '</form>';
6077
-    	if ($extra_fields_to_show > 0) {
6078
-    		return $return;
6079
-    	} else {
6080
-    		return '';
6081
-    	}
6043
+        // getting all the extra profile fields that are defined by the platform administrator
6044
+        $extra_fields = UserManager :: get_extra_fields(0,50,5,'ASC');
6045
+
6046
+        // creating the form
6047
+        $return = '<form action="courseLog.php" method="get" name="additional_profile_field_form" id="additional_profile_field_form">';
6048
+
6049
+        // the select field with the additional user profile fields (= this is where we select the field of which we want to see
6050
+        // the information the users have entered or selected.
6051
+        $return .= '<select name="additional_profile_field">';
6052
+        $return .= '<option value="-">'.get_lang('SelectFieldToAdd').'</option>';
6053
+        $extra_fields_to_show = 0;
6054
+        foreach ($extra_fields as $key=>$field) {
6055
+            // show only extra fields that are visible + and can be filtered, added by J.Montoya
6056
+            if ($field[6]==1 && $field[8] == 1) {
6057
+                if (isset($_GET['additional_profile_field']) && $field[0] == $_GET['additional_profile_field'] ) {
6058
+                    $selected = 'selected="selected"';
6059
+                } else {
6060
+                    $selected = '';
6061
+                }
6062
+                $extra_fields_to_show++;
6063
+                $return .= '<option value="'.$field[0].'" '.$selected.'>'.$field[3].'</option>';
6064
+            }
6065
+        }
6066
+        $return .= '</select>';
6067
+
6068
+        // the form elements for the $_GET parameters (because the form is passed through GET
6069
+        foreach ($_GET as $key=>$value){
6070
+            if ($key <> 'additional_profile_field')    {
6071
+                $return .= '<input type="hidden" name="'.Security::remove_XSS($key).'" value="'.Security::remove_XSS($value).'" />';
6072
+            }
6073
+        }
6074
+        // the submit button
6075
+        $return .= '<button class="save" type="submit">'.get_lang('AddAdditionalProfileField').'</button>';
6076
+        $return .= '</form>';
6077
+        if ($extra_fields_to_show > 0) {
6078
+            return $return;
6079
+        } else {
6080
+            return '';
6081
+        }
6082 6082
     }
6083 6083
 
6084 6084
     /**
@@ -6097,31 +6097,31 @@  discard block
 block discarded – undo
6097 6097
      */
6098 6098
     public static function get_addtional_profile_information_of_field_by_user($field_id, $users)
6099 6099
     {
6100
-    	// Database table definition
6101
-    	$table_user = Database::get_main_table(TABLE_MAIN_USER);
6102
-    	$table_user_field_values = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES);
6100
+        // Database table definition
6101
+        $table_user = Database::get_main_table(TABLE_MAIN_USER);
6102
+        $table_user_field_values = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES);
6103 6103
         $extraField = Database::get_main_table(TABLE_EXTRA_FIELD);
6104
-    	$result_extra_field = UserManager::get_extra_field_information($field_id);
6105
-
6106
-    	if (!empty($users)) {
6107
-    		if ($result_extra_field['field_type'] == UserManager::USER_FIELD_TYPE_TAG ) {
6108
-    			foreach($users as $user_id) {
6109
-    				$user_result = UserManager::get_user_tags($user_id, $field_id);
6110
-    				$tag_list = array();
6111
-    				foreach($user_result as $item) {
6112
-    					$tag_list[] = $item['tag'];
6113
-    				}
6114
-    				$return[$user_id][] = implode(', ',$tag_list);
6115
-    			}
6116
-    		} else {
6117
-    			$new_user_array = array();
6118
-    			foreach ($users as $user_id) {
6119
-    				$new_user_array[]= "'".$user_id."'";
6120
-    			}
6121
-    			$users = implode(',',$new_user_array);
6104
+        $result_extra_field = UserManager::get_extra_field_information($field_id);
6105
+
6106
+        if (!empty($users)) {
6107
+            if ($result_extra_field['field_type'] == UserManager::USER_FIELD_TYPE_TAG ) {
6108
+                foreach($users as $user_id) {
6109
+                    $user_result = UserManager::get_user_tags($user_id, $field_id);
6110
+                    $tag_list = array();
6111
+                    foreach($user_result as $item) {
6112
+                        $tag_list[] = $item['tag'];
6113
+                    }
6114
+                    $return[$user_id][] = implode(', ',$tag_list);
6115
+                }
6116
+            } else {
6117
+                $new_user_array = array();
6118
+                foreach ($users as $user_id) {
6119
+                    $new_user_array[]= "'".$user_id."'";
6120
+                }
6121
+                $users = implode(',',$new_user_array);
6122 6122
                 $extraFieldType = EntityExtraField::USER_FIELD_TYPE;
6123
-    			// Selecting only the necessary information NOT ALL the user list
6124
-    			$sql = "SELECT user.user_id, v.value
6123
+                // Selecting only the necessary information NOT ALL the user list
6124
+                $sql = "SELECT user.user_id, v.value
6125 6125
     			        FROM $table_user user
6126 6126
     			        INNER JOIN $table_user_field_values v
6127 6127
                         ON (user.user_id = v.item_id)
@@ -6132,27 +6132,27 @@  discard block
 block discarded – undo
6132 6132
                             v.field_id=".intval($field_id)." AND
6133 6133
                             user.user_id IN ($users)";
6134 6134
 
6135
-    			$result = Database::query($sql);
6136
-    			while($row = Database::fetch_array($result)) {
6137
-    				// get option value for field type double select by id
6138
-    				if (!empty($row['value'])) {
6139
-    					if ($result_extra_field['field_type'] ==
6135
+                $result = Database::query($sql);
6136
+                while($row = Database::fetch_array($result)) {
6137
+                    // get option value for field type double select by id
6138
+                    if (!empty($row['value'])) {
6139
+                        if ($result_extra_field['field_type'] ==
6140 6140
                             ExtraField::FIELD_TYPE_DOUBLE_SELECT
6141 6141
                         ) {
6142
-    						$id_double_select = explode(';', $row['value']);
6143
-    						if (is_array($id_double_select)) {
6144
-    							$value1 = $result_extra_field['options'][$id_double_select[0]]['option_value'];
6145
-    							$value2 = $result_extra_field['options'][$id_double_select[1]]['option_value'];
6146
-    							$row['value'] = ($value1.';'.$value2);
6147
-    						}
6148
-    					}
6149
-    				}
6150
-    				// get other value from extra field
6151
-    				$return[$row['user_id']][] = $row['value'];
6152
-    			}
6153
-    		}
6154
-    	}
6155
-    	return $return;
6142
+                            $id_double_select = explode(';', $row['value']);
6143
+                            if (is_array($id_double_select)) {
6144
+                                $value1 = $result_extra_field['options'][$id_double_select[0]]['option_value'];
6145
+                                $value2 = $result_extra_field['options'][$id_double_select[1]]['option_value'];
6146
+                                $row['value'] = ($value1.';'.$value2);
6147
+                            }
6148
+                        }
6149
+                    }
6150
+                    // get other value from extra field
6151
+                    $return[$row['user_id']][] = $row['value'];
6152
+                }
6153
+            }
6154
+        }
6155
+        return $return;
6156 6156
     }
6157 6157
 
6158 6158
     /**
@@ -6161,18 +6161,18 @@  discard block
 block discarded – undo
6161 6161
      */
6162 6162
     public function count_student_in_course()
6163 6163
     {
6164
-    	global $nbStudents;
6165
-    	return $nbStudents;
6164
+        global $nbStudents;
6165
+        return $nbStudents;
6166 6166
     }
6167 6167
 
6168 6168
     public function sort_users($a, $b)
6169 6169
     {
6170
-    	return strcmp(trim(api_strtolower($a[$_SESSION['tracking_column']])), trim(api_strtolower($b[$_SESSION['tracking_column']])));
6170
+        return strcmp(trim(api_strtolower($a[$_SESSION['tracking_column']])), trim(api_strtolower($b[$_SESSION['tracking_column']])));
6171 6171
     }
6172 6172
 
6173 6173
     public function sort_users_desc($a, $b)
6174 6174
     {
6175
-    	return strcmp( trim(api_strtolower($b[$_SESSION['tracking_column']])), trim(api_strtolower($a[$_SESSION['tracking_column']])));
6175
+        return strcmp( trim(api_strtolower($b[$_SESSION['tracking_column']])), trim(api_strtolower($a[$_SESSION['tracking_column']])));
6176 6176
     }
6177 6177
 
6178 6178
     /**
@@ -6181,8 +6181,8 @@  discard block
 block discarded – undo
6181 6181
      */
6182 6182
     public static function get_number_of_users()
6183 6183
     {
6184
-    	global $user_ids;
6185
-    	return count($user_ids);
6184
+        global $user_ids;
6185
+        return count($user_ids);
6186 6186
     }
6187 6187
 
6188 6188
     /**
@@ -6198,37 +6198,37 @@  discard block
 block discarded – undo
6198 6198
     {
6199 6199
         global $user_ids, $course_code, $additional_user_profile_info, $export_csv, $is_western_name_order, $csv_content, $session_id;
6200 6200
 
6201
-    	$course_code = Database::escape_string($course_code);
6202
-    	$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
6203
-    	$tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
6201
+        $course_code = Database::escape_string($course_code);
6202
+        $tbl_user = Database::get_main_table(TABLE_MAIN_USER);
6203
+        $tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
6204 6204
 
6205
-    	$access_url_id = api_get_current_access_url_id();
6205
+        $access_url_id = api_get_current_access_url_id();
6206 6206
 
6207
-    	// get all users data from a course for sortable with limit
6208
-    	if (is_array($user_ids)) {
6209
-    		$user_ids = array_map('intval', $user_ids);
6210
-    		$condition_user = " WHERE user.user_id IN (".implode(',',$user_ids).") ";
6211
-    	} else {
6212
-    		$user_ids = intval($user_ids);
6213
-    		$condition_user = " WHERE user.user_id = $user_ids ";
6214
-    	}
6207
+        // get all users data from a course for sortable with limit
6208
+        if (is_array($user_ids)) {
6209
+            $user_ids = array_map('intval', $user_ids);
6210
+            $condition_user = " WHERE user.user_id IN (".implode(',',$user_ids).") ";
6211
+        } else {
6212
+            $user_ids = intval($user_ids);
6213
+            $condition_user = " WHERE user.user_id = $user_ids ";
6214
+        }
6215 6215
 
6216
-    	if (!empty($_GET['user_keyword'])) {
6217
-    		$keyword = trim(Database::escape_string($_GET['user_keyword']));
6218
-    		$condition_user .=  " AND (
6216
+        if (!empty($_GET['user_keyword'])) {
6217
+            $keyword = trim(Database::escape_string($_GET['user_keyword']));
6218
+            $condition_user .=  " AND (
6219 6219
                 user.firstname LIKE '%".$keyword."%' OR
6220 6220
                 user.lastname LIKE '%".$keyword."%'  OR
6221 6221
                 user.username LIKE '%".$keyword."%'  OR
6222 6222
                 user.email LIKE '%".$keyword."%'
6223 6223
              ) ";
6224
-    	}
6224
+        }
6225 6225
 
6226 6226
         $url_table = null;
6227 6227
         $url_condition = null;
6228
-    	if (api_is_multiple_url_enabled()) {
6229
-    		$url_table = ", ".$tbl_url_rel_user." as url_users";
6230
-    		$url_condition = " AND user.user_id = url_users.user_id AND access_url_id='$access_url_id'";
6231
-    	}
6228
+        if (api_is_multiple_url_enabled()) {
6229
+            $url_table = ", ".$tbl_url_rel_user." as url_users";
6230
+            $url_condition = " AND user.user_id = url_users.user_id AND access_url_id='$access_url_id'";
6231
+        }
6232 6232
 
6233 6233
         $invitedUsersCondition = '';
6234 6234
 
@@ -6236,7 +6236,7 @@  discard block
 block discarded – undo
6236 6236
             $invitedUsersCondition = " AND user.status != " . INVITEE;
6237 6237
         }
6238 6238
 
6239
-    	$sql = "SELECT  user.user_id as user_id,
6239
+        $sql = "SELECT  user.user_id as user_id,
6240 6240
                     user.official_code  as col0,
6241 6241
                     user.lastname       as col1,
6242 6242
                     user.firstname      as col2,
@@ -6244,17 +6244,17 @@  discard block
 block discarded – undo
6244 6244
                 FROM $tbl_user as user $url_table
6245 6245
     	        $condition_user $url_condition $invitedUsersCondition";
6246 6246
 
6247
-    	if (!in_array($direction, array('ASC','DESC'))) {
6248
-    		$direction = 'ASC';
6249
-    	}
6247
+        if (!in_array($direction, array('ASC','DESC'))) {
6248
+            $direction = 'ASC';
6249
+        }
6250 6250
 
6251
-    	$column = intval($column);
6251
+        $column = intval($column);
6252 6252
 
6253
-    	$from = intval($from);
6254
-    	$number_of_items = intval($number_of_items);
6253
+        $from = intval($from);
6254
+        $number_of_items = intval($number_of_items);
6255 6255
 
6256
-    	$sql .= " ORDER BY col$column $direction ";
6257
-    	$sql .= " LIMIT $from,$number_of_items";
6256
+        $sql .= " ORDER BY col$column $direction ";
6257
+        $sql .= " LIMIT $from,$number_of_items";
6258 6258
 
6259 6259
         $res = Database::query($sql);
6260 6260
         $users = array();
@@ -6288,7 +6288,7 @@  discard block
 block discarded – undo
6288 6288
             }
6289 6289
         }
6290 6290
 
6291
-    	while ($user = Database::fetch_array($res, 'ASSOC')) {
6291
+        while ($user = Database::fetch_array($res, 'ASSOC')) {
6292 6292
             $courseInfo = api_get_course_info($course_code);
6293 6293
             $courseId = $courseInfo['real_id'];
6294 6294
 
@@ -6319,10 +6319,10 @@  discard block
 block discarded – undo
6319 6319
                 $session_id
6320 6320
             );
6321 6321
 
6322
-    		if (empty($avg_student_progress)) {
6322
+            if (empty($avg_student_progress)) {
6323 6323
                 $avg_student_progress = 0;
6324
-    		}
6325
-    		$user['average_progress'] = $avg_student_progress.'%';
6324
+            }
6325
+            $user['average_progress'] = $avg_student_progress.'%';
6326 6326
 
6327 6327
             $total_user_exercise = Tracking::get_exercise_student_progress(
6328 6328
                 $total_exercises,
@@ -6342,11 +6342,11 @@  discard block
 block discarded – undo
6342 6342
 
6343 6343
             $user['exercise_average_best_attempt'] = $total_user_exercise;
6344 6344
 
6345
-    		if (is_numeric($avg_student_score)) {
6346
-    			$user['student_score']  = $avg_student_score.'%';
6347
-    		} else {
6348
-    			$user['student_score']  = $avg_student_score;
6349
-    		}
6345
+            if (is_numeric($avg_student_score)) {
6346
+                $user['student_score']  = $avg_student_score.'%';
6347
+            } else {
6348
+                $user['student_score']  = $avg_student_score;
6349
+            }
6350 6350
 
6351 6351
             $user['count_assignments'] = Tracking::count_student_assignments(
6352 6352
                 $user['user_id'],
@@ -6369,29 +6369,29 @@  discard block
 block discarded – undo
6369 6369
                 $session_id
6370 6370
             );
6371 6371
 
6372
-    		// we need to display an additional profile field
6373
-    		$user['additional'] = '';
6372
+            // we need to display an additional profile field
6373
+            $user['additional'] = '';
6374 6374
 
6375
-    		if (isset($_GET['additional_profile_field']) && is_numeric($_GET['additional_profile_field'])) {
6376
-    			if (isset($additional_user_profile_info[$user['user_id']]) &&
6375
+            if (isset($_GET['additional_profile_field']) && is_numeric($_GET['additional_profile_field'])) {
6376
+                if (isset($additional_user_profile_info[$user['user_id']]) &&
6377 6377
                     is_array($additional_user_profile_info[$user['user_id']])
6378 6378
                 ) {
6379
-    				$user['additional'] = implode(', ', $additional_user_profile_info[$user['user_id']]);
6380
-    			}
6381
-    		}
6379
+                    $user['additional'] = implode(', ', $additional_user_profile_info[$user['user_id']]);
6380
+                }
6381
+            }
6382 6382
 
6383 6383
             if (empty($session_id)) {
6384 6384
                 $user['survey'] = (isset($survey_user_list[$user['user_id']]) ? $survey_user_list[$user['user_id']] : 0) .' / '.$total_surveys;
6385 6385
             }
6386 6386
 
6387
-    		$user['link'] = '<center>
6387
+            $user['link'] = '<center>
6388 6388
                              <a href="../mySpace/myStudents.php?student='.$user['user_id'].'&details=true&course='.$course_code.'&origin=tracking_course&id_session='.$session_id.'">
6389 6389
     		                 '.Display::return_icon('2rightarrow.png').'
6390 6390
     		                 </a>
6391 6391
                          </center>';
6392 6392
 
6393
-    		// store columns in array $users
6394
-    		$is_western_name_order = api_is_western_name_order();
6393
+            // store columns in array $users
6394
+            $is_western_name_order = api_is_western_name_order();
6395 6395
             $user_row = array();
6396 6396
             $user_row[]= $user['official_code']; //0
6397 6397
             if ($is_western_name_order) {
@@ -6424,21 +6424,21 @@  discard block
 block discarded – undo
6424 6424
 
6425 6425
             $users[] = $user_row;
6426 6426
 
6427
-    		if ($export_csv) {
6428
-    		    if (empty($session_id)) {
6427
+            if ($export_csv) {
6428
+                if (empty($session_id)) {
6429 6429
                     $user_row = array_map('strip_tags', $user_row);
6430
-    			    unset($user_row[14]);
6431
-    			    unset($user_row[15]);
6430
+                    unset($user_row[14]);
6431
+                    unset($user_row[15]);
6432 6432
                 } else {
6433 6433
                     $user_row = array_map('strip_tags', $user_row);
6434 6434
                     unset($user_row[13]);
6435 6435
                     unset($user_row[14]);
6436 6436
                 }
6437 6437
 
6438
-    			$csv_content[] = $user_row;
6439
-    		}
6440
-    	}
6441
-    	return $users;
6438
+                $csv_content[] = $user_row;
6439
+            }
6440
+        }
6441
+        return $users;
6442 6442
     }
6443 6443
 }
6444 6444
 
@@ -6456,18 +6456,18 @@  discard block
 block discarded – undo
6456 6456
      */
6457 6457
     public function display_login_tracking_info($view, $user_id, $course_id, $session_id = 0)
6458 6458
     {
6459
-    	$MonthsLong = $GLOBALS['MonthsLong'];
6460
-
6461
-    	// protected data
6462
-    	$user_id = intval($user_id);
6463
-    	$session_id = intval($session_id);
6464
-    	$course_id = Database::escape_string($course_id);
6465
-
6466
-    	$track_access_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
6467
-    	$tempView = $view;
6468
-    	if(substr($view,0,1) == '1') {
6469
-    		$new_view = substr_replace($view,'0',0,1);
6470
-    		echo "
6459
+        $MonthsLong = $GLOBALS['MonthsLong'];
6460
+
6461
+        // protected data
6462
+        $user_id = intval($user_id);
6463
+        $session_id = intval($session_id);
6464
+        $course_id = Database::escape_string($course_id);
6465
+
6466
+        $track_access_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
6467
+        $tempView = $view;
6468
+        if(substr($view,0,1) == '1') {
6469
+            $new_view = substr_replace($view,'0',0,1);
6470
+            echo "
6471 6471
                 <tr>
6472 6472
                     <td valign='top'>
6473 6473
                     <font color='#0000FF'>-&nbsp;&nbsp;&nbsp;</font>" .
@@ -6475,9 +6475,9 @@  discard block
 block discarded – undo
6475 6475
                     </td>
6476 6476
                 </tr>
6477 6477
                 ";
6478
-    		echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('LoginsDetails')."<br>";
6478
+            echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('LoginsDetails')."<br>";
6479 6479
 
6480
-    		$sql = "SELECT UNIX_TIMESTAMP(access_date), count(access_date)
6480
+            $sql = "SELECT UNIX_TIMESTAMP(access_date), count(access_date)
6481 6481
                         FROM $track_access_table
6482 6482
                         WHERE access_user_id = $user_id
6483 6483
                         AND c_id = $course_id
@@ -6485,11 +6485,11 @@  discard block
 block discarded – undo
6485 6485
                         GROUP BY YEAR(access_date),MONTH(access_date)
6486 6486
                         ORDER BY YEAR(access_date),MONTH(access_date) ASC";
6487 6487
 
6488
-    		echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6489
-    		$results = getManyResults3Col($sql);
6488
+            echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6489
+            $results = getManyResults3Col($sql);
6490 6490
 
6491
-    		echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
6492
-    		echo "<tr>
6491
+            echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
6492
+            echo "<tr>
6493 6493
                     <td class='secLine'>
6494 6494
                     ".get_lang('LoginsTitleMonthColumn')."
6495 6495
                     </td>
@@ -6497,36 +6497,36 @@  discard block
 block discarded – undo
6497 6497
                     ".get_lang('LoginsTitleCountColumn')."
6498 6498
                     </td>
6499 6499
                 </tr>";
6500
-    		$total = 0;
6501
-    		if (is_array($results)) {
6502
-    			for($j = 0 ; $j < count($results) ; $j++) {
6503
-    				echo "<tr>";
6504
-    				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>";
6505
-    				echo "<td valign='top' align='right' class='content'>".$results[$j][1]."</td>";
6506
-    				echo"</tr>";
6507
-    				$total = $total + $results[$j][1];
6508
-    			}
6509
-    			echo "<tr>";
6510
-    			echo "<td>".get_lang('Total')."</td>";
6511
-    			echo "<td align='right' class='content'>".$total."</td>";
6512
-    			echo"</tr>";
6513
-    		} else {
6514
-    			echo "<tr>";
6515
-    			echo "<td colspan='2'><center>".get_lang('NoResult')."</center></td>";
6516
-    			echo"</tr>";
6517
-    		}
6518
-    		echo "</table>";
6519
-    		echo "</td></tr>";
6520
-    	} else {
6521
-    		$new_view = substr_replace($view,'1',0,1);
6522
-    		echo "
6500
+            $total = 0;
6501
+            if (is_array($results)) {
6502
+                for($j = 0 ; $j < count($results) ; $j++) {
6503
+                    echo "<tr>";
6504
+                    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>";
6505
+                    echo "<td valign='top' align='right' class='content'>".$results[$j][1]."</td>";
6506
+                    echo"</tr>";
6507
+                    $total = $total + $results[$j][1];
6508
+                }
6509
+                echo "<tr>";
6510
+                echo "<td>".get_lang('Total')."</td>";
6511
+                echo "<td align='right' class='content'>".$total."</td>";
6512
+                echo"</tr>";
6513
+            } else {
6514
+                echo "<tr>";
6515
+                echo "<td colspan='2'><center>".get_lang('NoResult')."</center></td>";
6516
+                echo"</tr>";
6517
+            }
6518
+            echo "</table>";
6519
+            echo "</td></tr>";
6520
+        } else {
6521
+            $new_view = substr_replace($view,'1',0,1);
6522
+            echo "
6523 6523
                 <tr>
6524 6524
                     <td valign='top'>
6525 6525
                     +<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>
6526 6526
                     </td>
6527 6527
                 </tr>
6528 6528
             ";
6529
-    	}
6529
+        }
6530 6530
     }
6531 6531
 
6532 6532
     /**
@@ -6539,38 +6539,38 @@  discard block
 block discarded – undo
6539 6539
      */
6540 6540
     public function display_exercise_tracking_info($view, $user_id, $courseCode)
6541 6541
     {
6542
-    	global $TBL_TRACK_HOTPOTATOES, $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $dateTimeFormatLong;
6542
+        global $TBL_TRACK_HOTPOTATOES, $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $dateTimeFormatLong;
6543 6543
         $courseId = api_get_course_int_id($courseCode);
6544
-    	if(substr($view,1,1) == '1') {
6545
-    		$new_view = substr_replace($view,'0',1,1);
6546
-    		echo "<tr>
6544
+        if(substr($view,1,1) == '1') {
6545
+            $new_view = substr_replace($view,'0',1,1);
6546
+            echo "<tr>
6547 6547
                     <td valign='top'>
6548 6548
                         <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>]
6549 6549
                     </td>
6550 6550
                 </tr>";
6551
-    		echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('ExercicesDetails')."<br />";
6551
+            echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('ExercicesDetails')."<br />";
6552 6552
 
6553
-    		$sql = "SELECT ce.title, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
6553
+            $sql = "SELECT ce.title, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
6554 6554
                     FROM $TABLECOURSE_EXERCICES AS ce , $TABLETRACK_EXERCICES AS te
6555 6555
                     WHERE te.c_id = $courseId
6556 6556
                         AND te.exe_user_id = ".intval($user_id)."
6557 6557
                         AND te.exe_exo_id = ce.id
6558 6558
                     ORDER BY ce.title ASC, te.exe_date ASC";
6559 6559
 
6560
-    		$hpsql = "SELECT te.exe_name, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
6560
+            $hpsql = "SELECT te.exe_name, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
6561 6561
                         FROM $TBL_TRACK_HOTPOTATOES AS te
6562 6562
                         WHERE te.exe_user_id = '".intval($user_id)."' AND te.c_id = $courseId
6563 6563
                         ORDER BY te.c_id ASC, te.exe_date ASC";
6564 6564
 
6565
-    		$hpresults = StatsUtils::getManyResultsXCol($hpsql, 4);
6565
+            $hpresults = StatsUtils::getManyResultsXCol($hpsql, 4);
6566 6566
 
6567
-    		$NoTestRes = 0;
6568
-    		$NoHPTestRes = 0;
6567
+            $NoTestRes = 0;
6568
+            $NoHPTestRes = 0;
6569 6569
 
6570
-    		echo "<tr>\n<td style='padding-left : 40px;padding-right : 40px;'>\n";
6571
-    		$results = StatsUtils::getManyResultsXCol($sql, 4);
6572
-    		echo "<table cellpadding='2' cellspacing='1' border='0' align='center'>\n";
6573
-    		echo "
6570
+            echo "<tr>\n<td style='padding-left : 40px;padding-right : 40px;'>\n";
6571
+            $results = StatsUtils::getManyResultsXCol($sql, 4);
6572
+            echo "<table cellpadding='2' cellspacing='1' border='0' align='center'>\n";
6573
+            echo "
6574 6574
                 <tr bgcolor='#E6E6E6'>
6575 6575
                     <td>
6576 6576
                     ".get_lang('ExercicesTitleExerciceColumn')."
@@ -6583,28 +6583,28 @@  discard block
 block discarded – undo
6583 6583
                     </td>
6584 6584
                 </tr>";
6585 6585
 
6586
-    		if (is_array($results)) {
6587
-    			for($i = 0; $i < sizeof($results); $i++) {
6588
-    				$display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get());
6589
-    				echo "<tr>\n";
6590
-    				echo "<td class='content'>".$results[$i][0]."</td>\n";
6591
-    				echo "<td class='content'>".$display_date."</td>\n";
6592
-    				echo "<td valign='top' align='right' class='content'>".$results[$i][1]." / ".$results[$i][2]."</td>\n";
6593
-    				echo "</tr>\n";
6594
-    			}
6595
-    		} else {
6596
-    			// istvan begin
6597
-    			$NoTestRes = 1;
6598
-    		}
6599
-
6600
-    		// The Result of Tests
6601
-    		if (is_array($hpresults)) {
6602
-    			for($i = 0; $i < sizeof($hpresults); $i++) {
6603
-    				$title = GetQuizName($hpresults[$i][0],'');
6604
-    				if ($title == '')
6605
-    				$title = basename($hpresults[$i][0]);
6606
-    				$display_date = api_convert_and_format_date($hpresults[$i][3], null, date_default_timezone_get());
6607
-    				?>
6586
+            if (is_array($results)) {
6587
+                for($i = 0; $i < sizeof($results); $i++) {
6588
+                    $display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get());
6589
+                    echo "<tr>\n";
6590
+                    echo "<td class='content'>".$results[$i][0]."</td>\n";
6591
+                    echo "<td class='content'>".$display_date."</td>\n";
6592
+                    echo "<td valign='top' align='right' class='content'>".$results[$i][1]." / ".$results[$i][2]."</td>\n";
6593
+                    echo "</tr>\n";
6594
+                }
6595
+            } else {
6596
+                // istvan begin
6597
+                $NoTestRes = 1;
6598
+            }
6599
+
6600
+            // The Result of Tests
6601
+            if (is_array($hpresults)) {
6602
+                for($i = 0; $i < sizeof($hpresults); $i++) {
6603
+                    $title = GetQuizName($hpresults[$i][0],'');
6604
+                    if ($title == '')
6605
+                    $title = basename($hpresults[$i][0]);
6606
+                    $display_date = api_convert_and_format_date($hpresults[$i][3], null, date_default_timezone_get());
6607
+                    ?>
6608 6608
                     <tr>
6609 6609
                         <td class="content"><?php echo $title; ?></td>
6610 6610
                         <td class="content" align="center"><?php echo $display_date; ?></td>
@@ -6614,26 +6614,26 @@  discard block
 block discarded – undo
6614 6614
 
6615 6615
                     <?php
6616 6616
                 }
6617
-    		} else {
6618
-    			$NoHPTestRes = 1;
6619
-    		}
6620
-
6621
-    		if ($NoTestRes == 1 && $NoHPTestRes == 1) {
6622
-    			echo "<tr>\n";
6623
-    			echo "<td colspan='3'><center>".get_lang('NoResult')."</center></td>\n";
6624
-    			echo "</tr>\n";
6625
-    		}
6626
-    		echo "</table>";
6627
-    		echo "</td>\n</tr>\n";
6628
-    	} else {
6629
-    		$new_view = substr_replace($view,'1',1,1);
6630
-    		echo "
6617
+            } else {
6618
+                $NoHPTestRes = 1;
6619
+            }
6620
+
6621
+            if ($NoTestRes == 1 && $NoHPTestRes == 1) {
6622
+                echo "<tr>\n";
6623
+                echo "<td colspan='3'><center>".get_lang('NoResult')."</center></td>\n";
6624
+                echo "</tr>\n";
6625
+            }
6626
+            echo "</table>";
6627
+            echo "</td>\n</tr>\n";
6628
+        } else {
6629
+            $new_view = substr_replace($view,'1',1,1);
6630
+            echo "
6631 6631
                 <tr>
6632 6632
                     <td valign='top'>
6633 6633
                         +<font color='#0000FF'>&nbsp;&nbsp;</font><a href='".api_get_self()."?uInfo=$user_id&view=".$new_view."' class='specialLink'>".get_lang('ExercicesResults')."</a>
6634 6634
                     </td>
6635 6635
                 </tr>";
6636
-    	}
6636
+        }
6637 6637
     }
6638 6638
 
6639 6639
     /**
@@ -6642,27 +6642,27 @@  discard block
 block discarded – undo
6642 6642
      */
6643 6643
     public function display_student_publications_tracking_info($view, $user_id, $course_id)
6644 6644
     {
6645
-    	global $TABLETRACK_UPLOADS, $TABLECOURSE_WORK;
6645
+        global $TABLETRACK_UPLOADS, $TABLECOURSE_WORK;
6646 6646
         $_course = api_get_course_info_by_id($course_id);
6647 6647
 
6648
-    	if (substr($view,2,1) == '1') {
6649
-    		$new_view = substr_replace($view,'0',2,1);
6650
-    		echo "<tr>
6648
+        if (substr($view,2,1) == '1') {
6649
+            $new_view = substr_replace($view,'0',2,1);
6650
+            echo "<tr>
6651 6651
                     <td valign='top'>
6652 6652
                     <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>]
6653 6653
                     </td>
6654 6654
                 </tr>";
6655
-    		echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('WorksDetails')."<br>";
6656
-    		$sql = "SELECT u.upload_date, w.title, w.author,w.url
6655
+            echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('WorksDetails')."<br>";
6656
+            $sql = "SELECT u.upload_date, w.title, w.author,w.url
6657 6657
                     FROM $TABLETRACK_UPLOADS u , $TABLECOURSE_WORK w
6658 6658
                     WHERE u.upload_work_id = w.id
6659 6659
                         AND u.upload_user_id = '".intval($user_id)."'
6660 6660
                         AND u.c_id = '".intval($course_id)."'
6661 6661
                     ORDER BY u.upload_date DESC";
6662
-    		echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6663
-    		$results = StatsUtils::getManyResultsXCol($sql,4);
6664
-    		echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
6665
-    		echo "<tr>
6662
+            echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6663
+            $results = StatsUtils::getManyResultsXCol($sql,4);
6664
+            echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
6665
+            echo "<tr>
6666 6666
                     <td class='secLine' width='40%'>
6667 6667
                     ".get_lang('WorkTitle')."
6668 6668
                     </td>
@@ -6673,35 +6673,35 @@  discard block
 block discarded – undo
6673 6673
                     ".get_lang('Date')."
6674 6674
                     </td>
6675 6675
                 </tr>";
6676
-    		if (is_array($results)) {
6677
-    			for($j = 0 ; $j < count($results) ; $j++) {
6678
-    				$pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3];
6679
-    				$beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get());
6680
-    				echo "<tr>";
6681
-    				echo "<td class='content'>"
6682
-    				."<a href ='".$pathToFile."'>".$results[$j][1]."</a>"
6683
-    				."</td>";
6684
-    				echo "<td class='content'>".$results[$j][2]."</td>";
6685
-    				echo "<td class='content'>".$beautifulDate."</td>";
6686
-    				echo"</tr>";
6687
-    			}
6688
-    		} else {
6689
-    			echo "<tr>";
6690
-    			echo "<td colspan='3'><center>".get_lang('NoResult')."</center></td>";
6691
-    			echo"</tr>";
6692
-    		}
6693
-    		echo "</table>";
6694
-    		echo "</td></tr>";
6695
-    	} else {
6696
-    		$new_view = substr_replace($view,'1',2,1);
6697
-    		echo "
6676
+            if (is_array($results)) {
6677
+                for($j = 0 ; $j < count($results) ; $j++) {
6678
+                    $pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3];
6679
+                    $beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get());
6680
+                    echo "<tr>";
6681
+                    echo "<td class='content'>"
6682
+                    ."<a href ='".$pathToFile."'>".$results[$j][1]."</a>"
6683
+                    ."</td>";
6684
+                    echo "<td class='content'>".$results[$j][2]."</td>";
6685
+                    echo "<td class='content'>".$beautifulDate."</td>";
6686
+                    echo"</tr>";
6687
+                }
6688
+            } else {
6689
+                echo "<tr>";
6690
+                echo "<td colspan='3'><center>".get_lang('NoResult')."</center></td>";
6691
+                echo"</tr>";
6692
+            }
6693
+            echo "</table>";
6694
+            echo "</td></tr>";
6695
+        } else {
6696
+            $new_view = substr_replace($view,'1',2,1);
6697
+            echo "
6698 6698
                 <tr>
6699 6699
                     <td valign='top'>
6700 6700
                     +<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>
6701 6701
                     </td>
6702 6702
                 </tr>
6703 6703
             ";
6704
-    	}
6704
+        }
6705 6705
     }
6706 6706
 
6707 6707
     /**
@@ -6710,55 +6710,55 @@  discard block
 block discarded – undo
6710 6710
      */
6711 6711
     public function display_links_tracking_info($view, $user_id, $courseCode)
6712 6712
     {
6713
-    	global $TABLETRACK_LINKS, $TABLECOURSE_LINKS;
6713
+        global $TABLETRACK_LINKS, $TABLECOURSE_LINKS;
6714 6714
         $courseId = api_get_course_int_id($courseCode);
6715
-    	if (substr($view,3,1) == '1') {
6716
-    		$new_view = substr_replace($view,'0',3,1);
6717
-    		echo "
6715
+        if (substr($view,3,1) == '1') {
6716
+            $new_view = substr_replace($view,'0',3,1);
6717
+            echo "
6718 6718
                 <tr>
6719 6719
                         <td valign='top'>
6720 6720
                         <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>]
6721 6721
                         </td>
6722 6722
                 </tr>
6723 6723
             ";
6724
-    		echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('LinksDetails')."<br>";
6725
-    		$sql = "SELECT cl.title, cl.url
6724
+            echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('LinksDetails')."<br>";
6725
+            $sql = "SELECT cl.title, cl.url
6726 6726
                     FROM $TABLETRACK_LINKS AS sl, $TABLECOURSE_LINKS AS cl
6727 6727
                     WHERE sl.links_link_id = cl.id
6728 6728
                         AND sl.c_id = $courseId
6729 6729
                         AND sl.links_user_id = ".intval($user_id)."
6730 6730
                     GROUP BY cl.title, cl.url";
6731
-    		echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6732
-    		$results = StatsUtils::getManyResults2Col($sql);
6733
-    		echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
6734
-    		echo "<tr>
6731
+            echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6732
+            $results = StatsUtils::getManyResults2Col($sql);
6733
+            echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
6734
+            echo "<tr>
6735 6735
                     <td class='secLine'>
6736 6736
                     ".get_lang('LinksTitleLinkColumn')."
6737 6737
                     </td>
6738 6738
                 </tr>";
6739
-    		if (is_array($results)) {
6740
-    			for($j = 0 ; $j < count($results) ; $j++) {
6741
-    				echo "<tr>";
6742
-    				echo "<td class='content'><a href='".$results[$j][1]."'>".$results[$j][0]."</a></td>";
6743
-    				echo"</tr>";
6744
-    			}
6745
-    		} else {
6746
-    			echo "<tr>";
6747
-    			echo "<td ><center>".get_lang('NoResult')."</center></td>";
6748
-    			echo"</tr>";
6749
-    		}
6750
-    		echo "</table>";
6751
-    		echo "</td></tr>";
6752
-    	} else {
6753
-    		$new_view = substr_replace($view,'1',3,1);
6754
-    		echo "
6739
+            if (is_array($results)) {
6740
+                for($j = 0 ; $j < count($results) ; $j++) {
6741
+                    echo "<tr>";
6742
+                    echo "<td class='content'><a href='".$results[$j][1]."'>".$results[$j][0]."</a></td>";
6743
+                    echo"</tr>";
6744
+                }
6745
+            } else {
6746
+                echo "<tr>";
6747
+                echo "<td ><center>".get_lang('NoResult')."</center></td>";
6748
+                echo"</tr>";
6749
+            }
6750
+            echo "</table>";
6751
+            echo "</td></tr>";
6752
+        } else {
6753
+            $new_view = substr_replace($view,'1',3,1);
6754
+            echo "
6755 6755
                 <tr>
6756 6756
                     <td valign='top'>
6757 6757
                     +<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>
6758 6758
                     </td>
6759 6759
                 </tr>
6760 6760
             ";
6761
-    	}
6761
+        }
6762 6762
     }
6763 6763
 
6764 6764
     /**
@@ -6771,61 +6771,61 @@  discard block
 block discarded – undo
6771 6771
      */
6772 6772
     public static function display_document_tracking_info($view, $user_id, $course_code, $session_id = 0)
6773 6773
     {
6774
-    	// protect data
6774
+        // protect data
6775 6775
         $user_id = intval($user_id);
6776 6776
         $courseId = api_get_course_int_id($course_code);
6777
-    	$session_id = intval($session_id);
6777
+        $session_id = intval($session_id);
6778 6778
 
6779
-    	$downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
6780
-    	if(substr($view,4,1) == '1') {
6781
-    		$new_view = substr_replace($view,'0',4,1);
6782
-    		echo "
6779
+        $downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
6780
+        if(substr($view,4,1) == '1') {
6781
+            $new_view = substr_replace($view,'0',4,1);
6782
+            echo "
6783 6783
                 <tr>
6784 6784
                     <td valign='top'>
6785 6785
                     <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>]
6786 6786
                     </td>
6787 6787
                 </tr>
6788 6788
             ";
6789
-    		echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('DocumentsDetails')."<br>";
6789
+            echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('DocumentsDetails')."<br>";
6790 6790
 
6791
-    		$sql = "SELECT down_doc_path
6791
+            $sql = "SELECT down_doc_path
6792 6792
                     FROM $downloads_table
6793 6793
                     WHERE c_id = $courseId
6794 6794
                         AND down_user_id = $user_id
6795 6795
                         AND down_session_id = $session_id
6796 6796
                     GROUP BY down_doc_path";
6797 6797
 
6798
-    		echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6799
-    		$results = StatsUtils::getManyResults1Col($sql);
6800
-    		echo "<table cellpadding='2' cellspacing='1' border='0' align='center'>";
6801
-    		echo "<tr>
6798
+            echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6799
+            $results = StatsUtils::getManyResults1Col($sql);
6800
+            echo "<table cellpadding='2' cellspacing='1' border='0' align='center'>";
6801
+            echo "<tr>
6802 6802
                     <td class='secLine'>
6803 6803
                     ".get_lang('DocumentsTitleDocumentColumn')."
6804 6804
                     </td>
6805 6805
                 </tr>";
6806
-    		if (is_array($results)) {
6807
-    			for($j = 0 ; $j < count($results) ; $j++) {
6808
-    				echo "<tr>";
6809
-    				echo "<td class='content'>".$results[$j]."</td>";
6810
-    				echo"</tr>";
6811
-    			}
6812
-    		} else {
6813
-    			echo "<tr>";
6814
-    			echo "<td><center>".get_lang('NoResult')."</center></td>";
6815
-    			echo"</tr>";
6816
-    		}
6817
-    		echo "</table>";
6818
-    		echo "</td></tr>";
6819
-    	} else {
6820
-    		$new_view = substr_replace($view,'1',4,1);
6821
-    		echo "
6806
+            if (is_array($results)) {
6807
+                for($j = 0 ; $j < count($results) ; $j++) {
6808
+                    echo "<tr>";
6809
+                    echo "<td class='content'>".$results[$j]."</td>";
6810
+                    echo"</tr>";
6811
+                }
6812
+            } else {
6813
+                echo "<tr>";
6814
+                echo "<td><center>".get_lang('NoResult')."</center></td>";
6815
+                echo"</tr>";
6816
+            }
6817
+            echo "</table>";
6818
+            echo "</td></tr>";
6819
+        } else {
6820
+            $new_view = substr_replace($view,'1',4,1);
6821
+            echo "
6822 6822
                 <tr>
6823 6823
                     <td valign='top'>
6824 6824
                     +<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>
6825 6825
                     </td>
6826 6826
                 </tr>
6827 6827
             ";
6828
-    	}
6828
+        }
6829 6829
     }
6830 6830
 
6831 6831
     /**
@@ -6882,43 +6882,43 @@  discard block
 block discarded – undo
6882 6882
      */
6883 6883
     public function display_login_tracking_info($view, $user_id, $course_id, $session_id = 0)
6884 6884
     {
6885
-    	$MonthsLong = $GLOBALS['MonthsLong'];
6886
-    	$track_access_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
6887
-
6888
-    	// protected data
6889
-    	$user_id    = intval($user_id);
6890
-    	$session_id = intval($session_id);
6891
-    	$course_id  = intval($course_id);
6892
-
6893
-    	$tempView = $view;
6894
-    	if (substr($view,0,1) == '1') {
6895
-    		$new_view = substr_replace($view,'0',0,1);
6896
-    		$title[1]= get_lang('LoginsAndAccessTools').get_lang('LoginsDetails');
6897
-    		$sql = "SELECT UNIX_TIMESTAMP(access_date), count(access_date)
6885
+        $MonthsLong = $GLOBALS['MonthsLong'];
6886
+        $track_access_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
6887
+
6888
+        // protected data
6889
+        $user_id    = intval($user_id);
6890
+        $session_id = intval($session_id);
6891
+        $course_id  = intval($course_id);
6892
+
6893
+        $tempView = $view;
6894
+        if (substr($view,0,1) == '1') {
6895
+            $new_view = substr_replace($view,'0',0,1);
6896
+            $title[1]= get_lang('LoginsAndAccessTools').get_lang('LoginsDetails');
6897
+            $sql = "SELECT UNIX_TIMESTAMP(access_date), count(access_date)
6898 6898
                     FROM $track_access_table
6899 6899
                     WHERE access_user_id = $user_id
6900 6900
                     AND c_id = $course_id
6901 6901
                     AND access_session_id = $session_id
6902 6902
                     GROUP BY YEAR(access_date),MONTH(access_date)
6903 6903
                     ORDER BY YEAR(access_date),MONTH(access_date) ASC";
6904
-    		//$results = getManyResults2Col($sql);
6905
-    		$results = getManyResults3Col($sql);
6906
-    		$title_line= get_lang('LoginsTitleMonthColumn').';'.get_lang('LoginsTitleCountColumn')."\n";
6907
-    		$line='';
6908
-    		$total = 0;
6909
-    		if (is_array($results)) {
6910
-    			for($j = 0 ; $j < count($results) ; $j++) {
6911
-    				$line .= $results[$j][0].';'.$results[$j][1]."\n";
6912
-    				$total = $total + $results[$j][1];
6913
-    			}
6914
-    			$line .= get_lang('Total').";".$total."\n";
6915
-    		} else {
6916
-    			$line= get_lang('NoResult')."</center></td>";
6917
-    		}
6918
-    	} else {
6919
-    		$new_view = substr_replace($view,'1',0,1);
6920
-    	}
6921
-    	return array($title_line, $line);
6904
+            //$results = getManyResults2Col($sql);
6905
+            $results = getManyResults3Col($sql);
6906
+            $title_line= get_lang('LoginsTitleMonthColumn').';'.get_lang('LoginsTitleCountColumn')."\n";
6907
+            $line='';
6908
+            $total = 0;
6909
+            if (is_array($results)) {
6910
+                for($j = 0 ; $j < count($results) ; $j++) {
6911
+                    $line .= $results[$j][0].';'.$results[$j][1]."\n";
6912
+                    $total = $total + $results[$j][1];
6913
+                }
6914
+                $line .= get_lang('Total').";".$total."\n";
6915
+            } else {
6916
+                $line= get_lang('NoResult')."</center></td>";
6917
+            }
6918
+        } else {
6919
+            $new_view = substr_replace($view,'1',0,1);
6920
+        }
6921
+        return array($title_line, $line);
6922 6922
     }
6923 6923
 
6924 6924
     /**
@@ -6931,67 +6931,67 @@  discard block
 block discarded – undo
6931 6931
      */
6932 6932
     public function display_exercise_tracking_info($view, $userId, $courseCode)
6933 6933
     {
6934
-    	global $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $TABLETRACK_HOTPOTATOES, $dateTimeFormatLong;
6934
+        global $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $TABLETRACK_HOTPOTATOES, $dateTimeFormatLong;
6935 6935
         $courseId = api_get_course_int_id($courseCode);
6936 6936
         $userId = intval($userId);
6937
-    	if (substr($view,1,1) == '1') {
6938
-    		$new_view = substr_replace($view,'0',1,1);
6939
-    		$title[1] = get_lang('ExercicesDetails');
6940
-    		$line = '';
6941
-    		$sql = "SELECT ce.title, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
6937
+        if (substr($view,1,1) == '1') {
6938
+            $new_view = substr_replace($view,'0',1,1);
6939
+            $title[1] = get_lang('ExercicesDetails');
6940
+            $line = '';
6941
+            $sql = "SELECT ce.title, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
6942 6942
                     FROM $TABLECOURSE_EXERCICES AS ce , $TABLETRACK_EXERCICES AS te
6943 6943
                     WHERE te.c_id = $courseId
6944 6944
                         AND te.exe_user_id = $userId
6945 6945
                         AND te.exe_exo_id = ce.id
6946 6946
                     ORDER BY ce.title ASC, te.exe_date ASC";
6947 6947
 
6948
-    		$hpsql = "SELECT te.exe_name, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
6948
+            $hpsql = "SELECT te.exe_name, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
6949 6949
                         FROM $TABLETRACK_HOTPOTATOES AS te
6950 6950
                         WHERE te.exe_user_id = '$userId' AND te.c_id = $courseId
6951 6951
                         ORDER BY te.c_id ASC, te.exe_date ASC";
6952 6952
 
6953
-    		$hpresults = StatsUtils::getManyResultsXCol($hpsql, 4);
6953
+            $hpresults = StatsUtils::getManyResultsXCol($hpsql, 4);
6954 6954
 
6955
-    		$NoTestRes = 0;
6956
-    		$NoHPTestRes = 0;
6955
+            $NoTestRes = 0;
6956
+            $NoHPTestRes = 0;
6957 6957
 
6958
-    		$results = StatsUtils::getManyResultsXCol($sql, 4);
6959
-    		$title_line = get_lang('ExercicesTitleExerciceColumn').";".get_lang('Date').';'.get_lang('ExercicesTitleScoreColumn')."\n";
6958
+            $results = StatsUtils::getManyResultsXCol($sql, 4);
6959
+            $title_line = get_lang('ExercicesTitleExerciceColumn').";".get_lang('Date').';'.get_lang('ExercicesTitleScoreColumn')."\n";
6960 6960
 
6961
-    		if (is_array($results)) {
6962
-    			for($i = 0; $i < sizeof($results); $i++)
6963
-    			{
6964
-    				$display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get());
6965
-    				$line .= $results[$i][0].";".$display_date.";".$results[$i][1]." / ".$results[$i][2]."\n";
6966
-    			}
6967
-    		} else {
6961
+            if (is_array($results)) {
6962
+                for($i = 0; $i < sizeof($results); $i++)
6963
+                {
6964
+                    $display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get());
6965
+                    $line .= $results[$i][0].";".$display_date.";".$results[$i][1]." / ".$results[$i][2]."\n";
6966
+                }
6967
+            } else {
6968 6968
                 // istvan begin
6969
-    			$NoTestRes = 1;
6970
-    		}
6971
-
6972
-    		// The Result of Tests
6973
-    		if (is_array($hpresults)) {
6974
-    			for($i = 0; $i < sizeof($hpresults); $i++) {
6975
-    				$title = GetQuizName($hpresults[$i][0],'');
6976
-
6977
-    				if ($title == '')
6978
-    				$title = basename($hpresults[$i][0]);
6979
-
6980
-    				$display_date = api_convert_and_format_date($hpresults[$i][3], null, date_default_timezone_get());
6981
-
6982
-    				$line .= $title.';'.$display_date.';'.$hpresults[$i][1].'/'.$hpresults[$i][2]."\n";
6983
-    			}
6984
-    		} else {
6985
-    			$NoHPTestRes = 1;
6986
-    		}
6987
-
6988
-    		if ($NoTestRes == 1 && $NoHPTestRes == 1) {
6989
-    			$line=get_lang('NoResult');
6990
-    		}
6991
-    	} else {
6992
-    		$new_view = substr_replace($view,'1',1,1);
6993
-    	}
6994
-    	return array($title_line, $line);
6969
+                $NoTestRes = 1;
6970
+            }
6971
+
6972
+            // The Result of Tests
6973
+            if (is_array($hpresults)) {
6974
+                for($i = 0; $i < sizeof($hpresults); $i++) {
6975
+                    $title = GetQuizName($hpresults[$i][0],'');
6976
+
6977
+                    if ($title == '')
6978
+                    $title = basename($hpresults[$i][0]);
6979
+
6980
+                    $display_date = api_convert_and_format_date($hpresults[$i][3], null, date_default_timezone_get());
6981
+
6982
+                    $line .= $title.';'.$display_date.';'.$hpresults[$i][1].'/'.$hpresults[$i][2]."\n";
6983
+                }
6984
+            } else {
6985
+                $NoHPTestRes = 1;
6986
+            }
6987
+
6988
+            if ($NoTestRes == 1 && $NoHPTestRes == 1) {
6989
+                $line=get_lang('NoResult');
6990
+            }
6991
+        } else {
6992
+            $new_view = substr_replace($view,'1',1,1);
6993
+        }
6994
+        return array($title_line, $line);
6995 6995
     }
6996 6996
 
6997 6997
     /**
@@ -7000,37 +7000,37 @@  discard block
 block discarded – undo
7000 7000
      */
7001 7001
     public function display_student_publications_tracking_info($view, $user_id, $course_id)
7002 7002
     {
7003
-    	global $TABLETRACK_UPLOADS, $TABLECOURSE_WORK;
7003
+        global $TABLETRACK_UPLOADS, $TABLECOURSE_WORK;
7004 7004
         $_course = api_get_course_info();
7005 7005
         $user_id = intval($user_id);
7006 7006
         $course_id = intval($course_id);
7007 7007
 
7008
-    	if (substr($view,2,1) == '1') {
7009
-    		$sql = "SELECT u.upload_date, w.title, w.author, w.url
7008
+        if (substr($view,2,1) == '1') {
7009
+            $sql = "SELECT u.upload_date, w.title, w.author, w.url
7010 7010
                     FROM $TABLETRACK_UPLOADS u , $TABLECOURSE_WORK w
7011 7011
                     WHERE
7012 7012
                         u.upload_work_id = w.id AND
7013 7013
                         u.upload_user_id = '$user_id' AND
7014 7014
                         u.c_id = '$course_id'
7015 7015
                     ORDER BY u.upload_date DESC";
7016
-    		$results = StatsUtils::getManyResultsXCol($sql,4);
7017
-
7018
-    		$title[1]=get_lang('WorksDetails');
7019
-    		$line='';
7020
-    		$title_line=get_lang('WorkTitle').";".get_lang('WorkAuthors').";".get_lang('Date')."\n";
7021
-
7022
-    		if (is_array($results)) {
7023
-    			for($j = 0 ; $j < count($results) ; $j++) {
7024
-    				$pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3];
7025
-    				$beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get());
7026
-    				$line .= $results[$j][1].";".$results[$j][2].";".$beautifulDate."\n";
7027
-    			}
7028
-
7029
-    		} else {
7030
-    			$line= get_lang('NoResult');
7031
-    		}
7032
-    	}
7033
-    	return array($title_line, $line);
7016
+            $results = StatsUtils::getManyResultsXCol($sql,4);
7017
+
7018
+            $title[1]=get_lang('WorksDetails');
7019
+            $line='';
7020
+            $title_line=get_lang('WorkTitle').";".get_lang('WorkAuthors').";".get_lang('Date')."\n";
7021
+
7022
+            if (is_array($results)) {
7023
+                for($j = 0 ; $j < count($results) ; $j++) {
7024
+                    $pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3];
7025
+                    $beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get());
7026
+                    $line .= $results[$j][1].";".$results[$j][2].";".$beautifulDate."\n";
7027
+                }
7028
+
7029
+            } else {
7030
+                $line= get_lang('NoResult');
7031
+            }
7032
+        }
7033
+        return array($title_line, $line);
7034 7034
     }
7035 7035
 
7036 7036
     /**
@@ -7039,32 +7039,32 @@  discard block
 block discarded – undo
7039 7039
      */
7040 7040
     public function display_links_tracking_info($view, $userId, $courseCode)
7041 7041
     {
7042
-    	global $TABLETRACK_LINKS, $TABLECOURSE_LINKS;
7042
+        global $TABLETRACK_LINKS, $TABLECOURSE_LINKS;
7043 7043
         $courseId = api_get_course_int_id($courseCode);
7044 7044
         $userId = intval($userId);
7045 7045
         $line = null;
7046
-    	if (substr($view,3,1) == '1') {
7047
-    		$new_view = substr_replace($view,'0',3,1);
7048
-    		$title[1]=get_lang('LinksDetails');
7049
-    		$sql = "SELECT cl.title, cl.url
7046
+        if (substr($view,3,1) == '1') {
7047
+            $new_view = substr_replace($view,'0',3,1);
7048
+            $title[1]=get_lang('LinksDetails');
7049
+            $sql = "SELECT cl.title, cl.url
7050 7050
                         FROM $TABLETRACK_LINKS AS sl, $TABLECOURSE_LINKS AS cl
7051 7051
                         WHERE sl.links_link_id = cl.id
7052 7052
                             AND sl.c_id = $courseId
7053 7053
                             AND sl.links_user_id = $userId
7054 7054
                         GROUP BY cl.title, cl.url";
7055
-    		$results = StatsUtils::getManyResults2Col($sql);
7056
-    		$title_line= get_lang('LinksTitleLinkColumn')."\n";
7057
-    		if (is_array($results)) {
7058
-    			for ($j = 0 ; $j < count($results) ; $j++) {
7059
-    				$line .= $results[$j][0]."\n";
7060
-    			}
7061
-    		} else {
7062
-    			$line=get_lang('NoResult');
7063
-    		}
7064
-    	} else {
7065
-    		$new_view = substr_replace($view,'1',3,1);
7066
-    	}
7067
-    	return array($title_line, $line);
7055
+            $results = StatsUtils::getManyResults2Col($sql);
7056
+            $title_line= get_lang('LinksTitleLinkColumn')."\n";
7057
+            if (is_array($results)) {
7058
+                for ($j = 0 ; $j < count($results) ; $j++) {
7059
+                    $line .= $results[$j][0]."\n";
7060
+                }
7061
+            } else {
7062
+                $line=get_lang('NoResult');
7063
+            }
7064
+        } else {
7065
+            $new_view = substr_replace($view,'1',3,1);
7066
+        }
7067
+        return array($title_line, $line);
7068 7068
     }
7069 7069
 
7070 7070
     /**
@@ -7077,38 +7077,38 @@  discard block
 block discarded – undo
7077 7077
      */
7078 7078
     public function display_document_tracking_info($view, $user_id, $courseCode, $session_id = 0)
7079 7079
     {
7080
-    	// protect data
7081
-    	$user_id     = intval($user_id);
7080
+        // protect data
7081
+        $user_id     = intval($user_id);
7082 7082
         $courseId = api_get_course_int_id($courseCode);
7083
-    	$session_id = intval($session_id);
7083
+        $session_id = intval($session_id);
7084 7084
 
7085
-    	$downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
7085
+        $downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
7086 7086
 
7087
-    	if (substr($view,4,1) == '1') {
7088
-    		$new_view = substr_replace($view,'0',4,1);
7089
-    		$title[1]= get_lang('DocumentsDetails');
7087
+        if (substr($view,4,1) == '1') {
7088
+            $new_view = substr_replace($view,'0',4,1);
7089
+            $title[1]= get_lang('DocumentsDetails');
7090 7090
 
7091
-    		$sql = "SELECT down_doc_path
7091
+            $sql = "SELECT down_doc_path
7092 7092
                         FROM $downloads_table
7093 7093
                         WHERE c_id = $courseId
7094 7094
                             AND down_user_id = $user_id
7095 7095
                             AND down_session_id = $session_id
7096 7096
                         GROUP BY down_doc_path";
7097 7097
 
7098
-    		$results = StatsUtils::getManyResults1Col($sql);
7099
-    		$title_line = get_lang('DocumentsTitleDocumentColumn')."\n";
7098
+            $results = StatsUtils::getManyResults1Col($sql);
7099
+            $title_line = get_lang('DocumentsTitleDocumentColumn')."\n";
7100 7100
             $line = null;
7101
-    		if (is_array($results)) {
7102
-    			for ($j = 0 ; $j < count($results) ; $j++) {
7103
-    				$line .= $results[$j]."\n";
7104
-    			}
7105
-    		} else {
7106
-    			$line = get_lang('NoResult');
7107
-    		}
7108
-    	} else {
7109
-    		$new_view = substr_replace($view,'1',4,1);
7110
-    	}
7111
-    	return array($title_line, $line);
7101
+            if (is_array($results)) {
7102
+                for ($j = 0 ; $j < count($results) ; $j++) {
7103
+                    $line .= $results[$j]."\n";
7104
+                }
7105
+            } else {
7106
+                $line = get_lang('NoResult');
7107
+            }
7108
+        } else {
7109
+            $new_view = substr_replace($view,'1',4,1);
7110
+        }
7111
+        return array($title_line, $line);
7112 7112
     }
7113 7113
 
7114 7114
     /**
Please login to merge, or discard this patch.
Spacing   +423 added lines, -423 removed lines patch added patch discarded remove patch
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
         $extendedAttempt = null,
112 112
         $extendedAll = null,
113 113
         $type = 'classic',
114
-        $allowExtend =  true
114
+        $allowExtend = true
115 115
     ) {
116 116
         if (empty($courseInfo) || empty($lp_id)) {
117 117
             return null;
@@ -135,22 +135,22 @@  discard block
 block discarded – undo
135 135
         $extend_all = 0;
136 136
 
137 137
         if ($origin == 'tracking') {
138
-            $url_suffix = '&session_id=' . $session_id . '&course=' . $courseCode . '&student_id=' . $user_id . '&lp_id=' . $lp_id . '&origin=' . $origin;
138
+            $url_suffix = '&session_id='.$session_id.'&course='.$courseCode.'&student_id='.$user_id.'&lp_id='.$lp_id.'&origin='.$origin;
139 139
         } else {
140
-            $url_suffix = '&lp_id=' . $lp_id;
140
+            $url_suffix = '&lp_id='.$lp_id;
141 141
         }
142 142
 
143 143
         if (!empty($extendedAll)) {
144 144
             $extend_all_link = Display::url(
145 145
                 Display::return_icon('view_less_stats.gif', get_lang('HideAllAttempts')),
146
-                api_get_self() . '?action=stats' . $url_suffix
146
+                api_get_self().'?action=stats'.$url_suffix
147 147
             );
148 148
 
149 149
             $extend_all = 1;
150 150
         } else {
151 151
             $extend_all_link = Display::url(
152 152
                 Display::return_icon('view_more_stats.gif', get_lang('ShowAllAttempts')),
153
-                api_get_self() . '?action=stats&extend_all=1' . $url_suffix
153
+                api_get_self().'?action=stats&extend_all=1'.$url_suffix
154 154
             );
155 155
         }
156 156
 
@@ -162,24 +162,24 @@  discard block
 block discarded – undo
162 162
 
163 163
         $actionColumn = null;
164 164
         if ($type == 'classic') {
165
-            $actionColumn = ' <th>' . get_lang('Actions') . '</th>';
165
+            $actionColumn = ' <th>'.get_lang('Actions').'</th>';
166 166
         }
167 167
         $output .= '<div class="table-responsive">';
168 168
         $output .= '<table class="table tracking">
169 169
             <thead>
170 170
             <tr class="table-header">
171
-                <th width="16">' . ($allowExtend == true ? $extend_all_link : '&nbsp;') . '</th>
171
+                <th width="16">' . ($allowExtend == true ? $extend_all_link : '&nbsp;').'</th>
172 172
                 <th colspan="4">
173
-                    ' . get_lang('ScormLessonTitle') .'
173
+                    ' . get_lang('ScormLessonTitle').'
174 174
                 </th>
175 175
                 <th colspan="2">
176
-                    ' . get_lang('ScormStatus') . '
176
+                    ' . get_lang('ScormStatus').'
177 177
                 </th>
178 178
                 <th colspan="2">
179
-                    ' . get_lang('ScormScore') . '
179
+                    ' . get_lang('ScormScore').'
180 180
                 </th>
181 181
                 <th colspan="2">
182
-                    ' . get_lang('ScormTime') . '
182
+                    ' . get_lang('ScormTime').'
183 183
                 </th>
184 184
                 '.$actionColumn.'
185 185
                 </tr>
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
                 // Prepare statement to go through each attempt.
243 243
                 $viewCondition = null;
244 244
                 if (!empty($view)) {
245
-                    $viewCondition =  " AND v.view_count = $view  ";
245
+                    $viewCondition = " AND v.view_count = $view  ";
246 246
                 }
247 247
 
248 248
                 $sql = "SELECT
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
                                 FROM $TBL_QUIZ
291 291
                                 WHERE
292 292
                                     c_id = $course_id AND
293
-                                    id ='" . $my_path . "'";
293
+                                    id ='".$my_path."'";
294 294
                         $res_result_disabled = Database::query($sql);
295 295
                         $row_result_disabled = Database::fetch_row($res_result_disabled);
296 296
 
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
                     if (!empty($inter_num)) {
313 313
                         $extend_link = Display::url(
314 314
                               Display::return_icon('visible.gif', get_lang('HideAttemptView')),
315
-                              api_get_self() . '?action=stats&fold_id=' . $my_item_id . $url_suffix
315
+                              api_get_self().'?action=stats&fold_id='.$my_item_id.$url_suffix
316 316
                         );
317 317
                     }
318 318
                     $title = $row['mytitle'];
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
 
331 331
                     $action = null;
332 332
                     if ($type == 'classic') {
333
-                        $action =  '<td></td>';
333
+                        $action = '<td></td>';
334 334
                     }
335 335
 
336 336
                     if (in_array($row['item_type'], $chapterTypes)) {
@@ -374,13 +374,13 @@  discard block
 block discarded – undo
374 374
                                 $extend_this_attempt = 1;
375 375
                                 $extend_attempt_link = Display::url(
376 376
                                     Display::return_icon('visible.gif', get_lang('HideAttemptView')),
377
-                                    api_get_self() . '?action=stats&extend_id=' . $my_item_id . '&fold_attempt_id=' . $row['iv_id'] . $url_suffix
377
+                                    api_get_self().'?action=stats&extend_id='.$my_item_id.'&fold_attempt_id='.$row['iv_id'].$url_suffix
378 378
                                 );
379 379
                             } else { // Same case if fold_attempt_id is set, so not implemented explicitly.
380 380
                                 // The extend button for this attempt has not been clicked.
381 381
                                 $extend_attempt_link = Display::url(
382 382
                                     Display::return_icon('invisible.gif', get_lang('ExtendAttemptView')),
383
-                                    api_get_self() . '?action=stats&extend_id=' . $my_item_id . '&extend_attempt_id=' . $row['iv_id'] . $url_suffix
383
+                                    api_get_self().'?action=stats&extend_id='.$my_item_id.'&extend_attempt_id='.$row['iv_id'].$url_suffix
384 384
                                 );
385 385
                             }
386 386
                         }
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
                         }
414 414
 
415 415
                         // Remove "NaN" if any (@todo: locate the source of these NaN)
416
-                        $time = str_replace('NaN', '00' . $h . '00\'00"', $time);
416
+                        $time = str_replace('NaN', '00'.$h.'00\'00"', $time);
417 417
 
418 418
                         if ($row['item_type'] != 'dokeos_chapter') {
419 419
                             if (!$is_allowed_to_edit && $result_disabled_ext_all) {
@@ -441,13 +441,13 @@  discard block
 block discarded – undo
441 441
                                 $action = '<td></td>';
442 442
                             }
443 443
 
444
-                            $output .= '<tr class="' . $oddclass . '">
444
+                            $output .= '<tr class="'.$oddclass.'">
445 445
                                     <td></td>
446
-                                    <td>' . $extend_attempt_link . '</td>
447
-                                    <td colspan="3">' . get_lang('Attempt') . ' ' . $attemptCount . '</td>
448
-                                    <td colspan="2">' . learnpathItem::humanize_status($lesson_status, true, $type) . '</td>
449
-                                    <td colspan="2">' . $view_score . '</td>
450
-                                    <td colspan="2">' . $time . '</td>
446
+                                    <td>' . $extend_attempt_link.'</td>
447
+                                    <td colspan="3">' . get_lang('Attempt').' '.$attemptCount.'</td>
448
+                                    <td colspan="2">' . learnpathItem::humanize_status($lesson_status, true, $type).'</td>
449
+                                    <td colspan="2">' . $view_score.'</td>
450
+                                    <td colspan="2">' . $time.'</td>
451 451
                                     '.$action.'
452 452
                                 </tr>';
453 453
                             $attemptCount++;
@@ -460,10 +460,10 @@  discard block
 block discarded – undo
460 460
                                     if (!$is_allowed_to_edit && $result_disabled_ext_all) {
461 461
                                         $temp[] = '/';
462 462
                                     } else {
463
-                                        $temp[] = ($score == 0 ? '0/' . $maxscore : ($maxscore == 0 ? $score : $score . '/' . float_format($maxscore, 1)));
463
+                                        $temp[] = ($score == 0 ? '0/'.$maxscore : ($maxscore == 0 ? $score : $score.'/'.float_format($maxscore, 1)));
464 464
                                     }
465 465
                                 } else {
466
-                                    $temp[] = ($score == 0 ? '/' : ($maxscore == 0 ? $score : $score . '/' . float_format($maxscore, 1)));
466
+                                    $temp[] = ($score == 0 ? '/' : ($maxscore == 0 ? $score : $score.'/'.float_format($maxscore, 1)));
467 467
                                 }
468 468
                                 $temp[] = $time;
469 469
                                 $csv_content[] = $temp;
@@ -500,13 +500,13 @@  discard block
 block discarded – undo
500 500
                                         <td></td>
501 501
                                         <td></td>
502 502
                                         <td></td>
503
-                                        <td>'.$interaction['order_id'] . '</td>
504
-                                        <td>'.$interaction['id'] . '</td>
503
+                                        <td>'.$interaction['order_id'].'</td>
504
+                                        <td>'.$interaction['id'].'</td>
505 505
                                         <td colspan="2">' . $interaction['type'].'</td>
506
-                                        <td>'.$student_response . '</td>
507
-                                        <td>'.$interaction['result'] . '</td>
508
-                                        <td>'.$interaction['latency'] . '</td>
509
-                                        <td>'.$interaction['time'] . '</td>
506
+                                        <td>'.$student_response.'</td>
507
+                                        <td>'.$interaction['result'].'</td>
508
+                                        <td>'.$interaction['latency'].'</td>
509
+                                        <td>'.$interaction['time'].'</td>
510 510
                                         '.$action.'
511 511
                                     </tr>';
512 512
                                 $counter++;
@@ -523,12 +523,12 @@  discard block
 block discarded – undo
523 523
                                         <td></td>
524 524
                                         <td></td>
525 525
                                         <td></td>
526
-                                        <td>' . $interaction['order_id'] . '</td>
527
-                                        <td colspan="2">' . $interaction['objective_id'] . '</td>
528
-                                        <td colspan="2">' . $interaction['status'] .'</td>
529
-                                        <td>' . $interaction['score_raw'] . '</td>
530
-                                        <td>' . $interaction['score_max'] . '</td>
531
-                                        <td>' . $interaction['score_min'] . '</td>
526
+                                        <td>' . $interaction['order_id'].'</td>
527
+                                        <td colspan="2">' . $interaction['objective_id'].'</td>
528
+                                        <td colspan="2">' . $interaction['status'].'</td>
529
+                                        <td>' . $interaction['score_raw'].'</td>
530
+                                        <td>' . $interaction['score_max'].'</td>
531
+                                        <td>' . $interaction['score_min'].'</td>
532 532
                                         '.$action.'
533 533
                                      </tr>';
534 534
                                 $counter++;
@@ -551,7 +551,7 @@  discard block
 block discarded – undo
551 551
                         $my_path = Database::escape_string($my_path);
552 552
                         $sql = "SELECT results_disabled
553 553
                                 FROM $TBL_QUIZ
554
-                                WHERE c_id = $course_id AND id ='" . $my_path . "'";
554
+                                WHERE c_id = $course_id AND id ='".$my_path."'";
555 555
                         $res_result_disabled = Database::query($sql);
556 556
                         $row_result_disabled = Database::fetch_row($res_result_disabled);
557 557
 
@@ -575,14 +575,14 @@  discard block
 block discarded – undo
575 575
                             $extend_this_attempt = 1;
576 576
                             $extend_attempt_link = Display::url(
577 577
                                 Display::return_icon('visible.gif', get_lang('HideAttemptView')),
578
-                                api_get_self() . '?action=stats&extend_id=' . $my_item_id . '&fold_attempt_id=' . $row['iv_id'] . $url_suffix
578
+                                api_get_self().'?action=stats&extend_id='.$my_item_id.'&fold_attempt_id='.$row['iv_id'].$url_suffix
579 579
                             );
580 580
                         } else {
581 581
                             // Same case if fold_attempt_id is set, so not implemented explicitly.
582 582
                             // The extend button for this attempt has not been clicked.
583 583
                             $extend_attempt_link = Display::url(
584 584
                                 Display::return_icon('invisible.gif', get_lang('ExtendAttemptView')),
585
-                                api_get_self() . '?action=stats&extend_id=' . $my_item_id . '&extend_attempt_id=' . $row['iv_id'] . $url_suffix
585
+                                api_get_self().'?action=stats&extend_id='.$my_item_id.'&extend_attempt_id='.$row['iv_id'].$url_suffix
586 586
                             );
587 587
                         }
588 588
                     }
@@ -597,7 +597,7 @@  discard block
 block discarded – undo
597 597
                     if ($inter_num > 1) {
598 598
                         $extend_link = Display::url(
599 599
                             Display::return_icon('invisible.gif', get_lang('ExtendAttemptView')),
600
-                            api_get_self() . '?action=stats&extend_id=' . $my_item_id . '&extend_attempt_id=' . $row['iv_id'] . $url_suffix
600
+                            api_get_self().'?action=stats&extend_id='.$my_item_id.'&extend_attempt_id='.$row['iv_id'].$url_suffix
601 601
                         );
602 602
                     }
603 603
 
@@ -613,15 +613,15 @@  discard block
 block discarded – undo
613 613
 
614 614
                     // Selecting the exe_id from stats attempts tables in order to look the max score value.
615 615
 
616
-                    $sql = 'SELECT * FROM ' . $tbl_stats_exercices . '
616
+                    $sql = 'SELECT * FROM '.$tbl_stats_exercices.'
617 617
                              WHERE
618
-                                exe_exo_id="' . $row['path'] . '" AND
619
-                                exe_user_id="' . $user_id . '" AND
620
-                                orig_lp_id = "' . $lp_id . '" AND
621
-                                orig_lp_item_id = "' . $row['myid'] . '" AND
622
-                                c_id = ' . $course_id . ' AND
618
+                                exe_exo_id="' . $row['path'].'" AND
619
+                                exe_user_id="' . $user_id.'" AND
620
+                                orig_lp_id = "' . $lp_id.'" AND
621
+                                orig_lp_item_id = "' . $row['myid'].'" AND
622
+                                c_id = ' . $course_id.' AND
623 623
                                 status <> "incomplete" AND
624
-                                session_id = ' . $session_id . '
624
+                                session_id = ' . $session_id.'
625 625
                              ORDER BY exe_date DESC
626 626
                              LIMIT 1';
627 627
 
@@ -652,8 +652,8 @@  discard block
 block discarded – undo
652 652
                                         FROM $TBL_LP_ITEM_VIEW
653 653
                                         WHERE
654 654
                                             c_id = $course_id AND
655
-                                            lp_item_id = '" . (int) $my_id . "' AND
656
-                                            lp_view_id = '" . (int) $my_lp_view_id . "'
655
+                                            lp_item_id = '".(int) $my_id."' AND
656
+                                            lp_view_id = '" . (int) $my_lp_view_id."'
657 657
                                         ORDER BY view_count DESC limit 1";
658 658
                                 $res_score = Database::query($sql);
659 659
                                 $row_score = Database::fetch_array($res_score);
@@ -662,8 +662,8 @@  discard block
 block discarded – undo
662 662
                                         FROM $TBL_LP_ITEM_VIEW
663 663
                                         WHERE
664 664
                                             c_id = $course_id AND
665
-                                            lp_item_id = '" . (int) $my_id . "' AND
666
-                                            lp_view_id = '" . (int) $my_lp_view_id . "'";
665
+                                            lp_item_id = '".(int) $my_id."' AND
666
+                                            lp_view_id = '" . (int) $my_lp_view_id."'";
667 667
                                 $res_time = Database::query($sql);
668 668
                                 $row_time = Database::fetch_array($res_time);
669 669
 
@@ -722,16 +722,16 @@  discard block
 block discarded – undo
722 722
                     } else {
723 723
                         $correct_test_link = '-';
724 724
                         if ($row['item_type'] == 'quiz') {
725
-                            $my_url_suffix = '&course=' . $courseCode . '&student_id=' . $user_id . '&lp_id=' . intval($row['mylpid']) . '&origin=' . $origin;
726
-                            $sql = 'SELECT * FROM ' . $tbl_stats_exercices . '
725
+                            $my_url_suffix = '&course='.$courseCode.'&student_id='.$user_id.'&lp_id='.intval($row['mylpid']).'&origin='.$origin;
726
+                            $sql = 'SELECT * FROM '.$tbl_stats_exercices.'
727 727
                                      WHERE
728
-                                        exe_exo_id="' . $row['path'] . '" AND
729
-                                        exe_user_id="' . $user_id . '" AND
730
-                                        orig_lp_id = "' . $lp_id . '" AND
731
-                                        orig_lp_item_id = "' . $row['myid'] . '" AND
732
-                                        c_id = ' . $course_id . ' AND
728
+                                        exe_exo_id="' . $row['path'].'" AND
729
+                                        exe_user_id="' . $user_id.'" AND
730
+                                        orig_lp_id = "' . $lp_id.'" AND
731
+                                        orig_lp_item_id = "' . $row['myid'].'" AND
732
+                                        c_id = ' . $course_id.' AND
733 733
                                         status <> "incomplete" AND
734
-                                        session_id = ' . $session_id . '
734
+                                        session_id = ' . $session_id.'
735 735
                                      ORDER BY exe_date DESC ';
736 736
 
737 737
                             $resultLastAttempt = Database::query($sql);
@@ -743,12 +743,12 @@  discard block
 block discarded – undo
743 743
                                 ) {
744 744
                                     $correct_test_link = Display::url(
745 745
                                         Display::return_icon('view_less_stats.gif', get_lang('HideAllAttempts')),
746
-                                        api_get_self() . '?action=stats' . $my_url_suffix . '&session_id=' . $session_id . '&lp_item_id=' . $my_id
746
+                                        api_get_self().'?action=stats'.$my_url_suffix.'&session_id='.$session_id.'&lp_item_id='.$my_id
747 747
                                     );
748 748
                                 } else {
749 749
                                     $correct_test_link = Display::url(
750 750
                                         Display::return_icon('view_more_stats.gif', get_lang('ShowAllAttemptsByExercise')),
751
-                                        api_get_self() . '?action=stats&extend_attempt=1' . $my_url_suffix . '&session_id=' . $session_id . '&lp_item_id=' . $my_id
751
+                                        api_get_self().'?action=stats&extend_attempt=1'.$my_url_suffix.'&session_id='.$session_id.'&lp_item_id='.$my_id
752 752
                                     );
753 753
                                 }
754 754
                             }
@@ -758,14 +758,14 @@  discard block
 block discarded – undo
758 758
 
759 759
                         $action = null;
760 760
                         if ($type == 'classic') {
761
-                            $action =  '<td>' . $correct_test_link . '</td>';
761
+                            $action = '<td>'.$correct_test_link.'</td>';
762 762
                         }
763 763
 
764 764
                         if ($lp_id == $my_lp_id && false) {
765 765
 
766
-                            $output .= '<tr class =' . $oddclass . '>
767
-                                    <td>' . $extend_link . '</td>
768
-                                    <td colspan="4">' . $title . '</td>
766
+                            $output .= '<tr class ='.$oddclass.'>
767
+                                    <td>' . $extend_link.'</td>
768
+                                    <td colspan="4">' . $title.'</td>
769 769
                                     <td colspan="2">&nbsp;</td>
770 770
                                     <td colspan="2">&nbsp;</td>
771 771
                                     <td colspan="2">&nbsp;</td>
@@ -790,13 +790,13 @@  discard block
 block discarded – undo
790 790
                                     $scoreItem .= ExerciseLib::show_score($score, $maxscore, false);
791 791
                                 }
792 792
                             } else {
793
-                                $scoreItem .= $score == 0 ? '/' : ($maxscore == 0 ? $score : $score . '/' . $maxscore);
793
+                                $scoreItem .= $score == 0 ? '/' : ($maxscore == 0 ? $score : $score.'/'.$maxscore);
794 794
                             }
795 795
 
796 796
                             $output .= '
797 797
                                 <td>'.$extend_link.'</td>
798
-                                <td colspan="4">' . $title . '</td>
799
-                                <td colspan="2">' . learnpathitem::humanize_status($lesson_status) .'</td>
798
+                                <td colspan="4">' . $title.'</td>
799
+                                <td colspan="2">' . learnpathitem::humanize_status($lesson_status).'</td>
800 800
                                 <td colspan="2">'.$scoreItem.'</td>
801 801
                                 <td colspan="2">'.$time.'</td>
802 802
                                 '.$action.'
@@ -813,10 +813,10 @@  discard block
 block discarded – undo
813 813
                                 if (!$is_allowed_to_edit && $result_disabled_ext_all) {
814 814
                                     $temp[] = '/';
815 815
                                 } else {
816
-                                    $temp[] = ($score == 0 ? '0/' . $maxscore : ($maxscore == 0 ? $score : $score . '/' . float_format($maxscore, 1)));
816
+                                    $temp[] = ($score == 0 ? '0/'.$maxscore : ($maxscore == 0 ? $score : $score.'/'.float_format($maxscore, 1)));
817 817
                                 }
818 818
                             } else {
819
-                                $temp[] = ($score == 0 ? '/' : ($maxscore == 0 ? $score : $score . '/' . float_format($maxscore, 1)));
819
+                                $temp[] = ($score == 0 ? '/' : ($maxscore == 0 ? $score : $score.'/'.float_format($maxscore, 1)));
820 820
                             }
821 821
                             $temp[] = $time;
822 822
                             $csv_content[] = $temp;
@@ -827,7 +827,7 @@  discard block
 block discarded – undo
827 827
 
828 828
                     $action = null;
829 829
                     if ($type == 'classic') {
830
-                        $action =  '<td></td>';
830
+                        $action = '<td></td>';
831 831
                     }
832 832
 
833 833
                     if ($extend_this_attempt || $extend_all) {
@@ -864,11 +864,11 @@  discard block
 block discarded – undo
864 864
                                     <td></td>
865 865
                                     <td></td>
866 866
                                     <td></td>
867
-                                    <td>' . $interaction['order_id'] . '</td>
868
-                                    <td colspan="2">'.$interaction['objective_id'] . '</td>
869
-                                    <td colspan="2">' . $interaction['status'] . '</td>
867
+                                    <td>' . $interaction['order_id'].'</td>
868
+                                    <td colspan="2">'.$interaction['objective_id'].'</td>
869
+                                    <td colspan="2">' . $interaction['status'].'</td>
870 870
                                     <td>' . $interaction['score_raw'].'</td>
871
-                                    <td>' . $interaction['score_max'] .'</td>
871
+                                    <td>' . $interaction['score_max'].'</td>
872 872
                                     <td>' . $interaction['score_min'].'</td>
873 873
                                     '.$action.'
874 874
                                </tr>';
@@ -877,7 +877,7 @@  discard block
 block discarded – undo
877 877
                     }
878 878
 
879 879
                     // Attempts listing by exercise.
880
-                    if ($lp_id == $my_lp_id && $lp_item_id== $my_id && $extendedAttempt) {
880
+                    if ($lp_id == $my_lp_id && $lp_item_id == $my_id && $extendedAttempt) {
881 881
                         // Get attempts of a exercise.
882 882
                         if (!empty($lp_id) &&
883 883
                             !empty($lp_item_id) &&
@@ -892,15 +892,15 @@  discard block
 block discarded – undo
892 892
                             $row_path = Database::fetch_array($res_path);
893 893
 
894 894
                             if (Database::num_rows($res_path) > 0) {
895
-                                $sql = 'SELECT * FROM ' . $tbl_stats_exercices . '
895
+                                $sql = 'SELECT * FROM '.$tbl_stats_exercices.'
896 896
                                         WHERE
897
-                                            exe_exo_id="' . (int) $row_path['path'] . '" AND
897
+                                            exe_exo_id="' . (int) $row_path['path'].'" AND
898 898
                                             status <> "incomplete" AND
899
-                                            exe_user_id="' . $user_id . '" AND
900
-                                            orig_lp_id = "' . (int) $lp_id . '" AND
901
-                                            orig_lp_item_id = "' . (int) $lp_item_id . '" AND
902
-                                            c_id = ' . $course_id . '  AND
903
-                                            session_id = ' . $session_id . '
899
+                                            exe_user_id="' . $user_id.'" AND
900
+                                            orig_lp_id = "' . (int) $lp_id.'" AND
901
+                                            orig_lp_item_id = "' . (int) $lp_item_id.'" AND
902
+                                            c_id = ' . $course_id.'  AND
903
+                                            session_id = ' . $session_id.'
904 904
                                         ORDER BY exe_date';
905 905
                                 $res_attempts = Database::query($sql);
906 906
                                 $num_attempts = Database::num_rows($res_attempts);
@@ -918,7 +918,7 @@  discard block
 block discarded – undo
918 918
                                         if ($mktime_start_date && $mktime_exe_date) {
919 919
                                             $mytime = ((int) $mktime_exe_date - (int) $mktime_start_date);
920 920
                                             $time_attemp = learnpathItem :: getScormTimeFromParameter('js', $mytime);
921
-                                            $time_attemp = str_replace('NaN', '00' . $h . '00\'00"', $time_attemp);
921
+                                            $time_attemp = str_replace('NaN', '00'.$h.'00\'00"', $time_attemp);
922 922
                                         } else {
923 923
                                             $time_attemp = ' - ';
924 924
                                         }
@@ -944,33 +944,33 @@  discard block
 block discarded – undo
944 944
                                             $my_lesson_status = learnpathitem::humanize_status('incomplete');
945 945
                                         }
946 946
 
947
-                                        $output .= '<tr class="' . $oddclass . '" >
947
+                                        $output .= '<tr class="'.$oddclass.'" >
948 948
                                         <td></td>
949
-                                        <td>' . $extend_attempt_link . '</td>
950
-                                        <td colspan="3">' . get_lang('Attempt').' '. $n.'</td>
951
-                                        <td colspan="2">' . $my_lesson_status . '</td>
952
-                                        <td colspan="2">'.$view_score . '</td>
953
-                                        <td colspan="2">'.$time_attemp . '</td>';
949
+                                        <td>' . $extend_attempt_link.'</td>
950
+                                        <td colspan="3">' . get_lang('Attempt').' '.$n.'</td>
951
+                                        <td colspan="2">' . $my_lesson_status.'</td>
952
+                                        <td colspan="2">'.$view_score.'</td>
953
+                                        <td colspan="2">'.$time_attemp.'</td>';
954 954
                                         if ($action == 'classic') {
955 955
                                             if ($origin != 'tracking') {
956 956
                                                 if (!$is_allowed_to_edit && $result_disabled_ext_all) {
957 957
                                                     $output .= '<td>
958
-                                                            <img src="' . Display::returnIconPath('quiz_na.gif').'" alt="' . get_lang('ShowAttempt') . '" title="' . get_lang('ShowAttempt') . '">
958
+                                                            <img src="' . Display::returnIconPath('quiz_na.gif').'" alt="'.get_lang('ShowAttempt').'" title="'.get_lang('ShowAttempt').'">
959 959
                                                             </td>';
960 960
                                                 } else {
961 961
                                                     $output .= '<td>
962
-                                                            <a href="../exercice/exercise_show.php?origin=' . $origin . '&id=' . $my_exe_id . '&cidReq=' . $courseCode . '" target="_parent">
963
-                                                            <img src="' . Display::returnIconPath('quiz.gif').'" alt="' . get_lang('ShowAttempt') . '" title="' . get_lang('ShowAttempt') . '">
962
+                                                            <a href="../exercice/exercise_show.php?origin=' . $origin.'&id='.$my_exe_id.'&cidReq='.$courseCode.'" target="_parent">
963
+                                                            <img src="' . Display::returnIconPath('quiz.gif').'" alt="'.get_lang('ShowAttempt').'" title="'.get_lang('ShowAttempt').'">
964 964
                                                             </a></td>';
965 965
                                                 }
966 966
                                             } else {
967 967
                                                 if (!$is_allowed_to_edit && $result_disabled_ext_all) {
968 968
                                                     $output .= '<td>
969
-                                                                <img src="' . Display::returnIconPath('quiz_na.gif').'" alt="' . get_lang('ShowAndQualifyAttempt') . '" title="' . get_lang('ShowAndQualifyAttempt') . '"></td>';
969
+                                                                <img src="' . Display::returnIconPath('quiz_na.gif').'" alt="'.get_lang('ShowAndQualifyAttempt').'" title="'.get_lang('ShowAndQualifyAttempt').'"></td>';
970 970
                                                 } else {
971 971
                                                     $output .= '<td>
972
-                                                                    <a href="../exercice/exercise_show.php?cidReq=' . $courseCode . '&origin=correct_exercise_in_lp&id=' . $my_exe_id . '" target="_parent">
973
-                                                                    <img src="' . Display::returnIconPath('quiz.gif').'" alt="' . get_lang('ShowAndQualifyAttempt') . '" title="' . get_lang('ShowAndQualifyAttempt') . '"></a></td>';
972
+                                                                    <a href="../exercice/exercise_show.php?cidReq=' . $courseCode.'&origin=correct_exercise_in_lp&id='.$my_exe_id.'" target="_parent">
973
+                                                                    <img src="' . Display::returnIconPath('quiz.gif').'" alt="'.get_lang('ShowAndQualifyAttempt').'" title="'.get_lang('ShowAndQualifyAttempt').'"></a></td>';
974 974
                                                 }
975 975
                                             }
976 976
                                         }
@@ -1029,13 +1029,13 @@  discard block
 block discarded – undo
1029 1029
         }
1030 1030
 
1031 1031
         $total_time = learnpathItem::getScormTimeFromParameter('js', $total_time);
1032
-        $total_time = str_replace('NaN', '00' . $h . '00\'00"', $total_time);
1032
+        $total_time = str_replace('NaN', '00'.$h.'00\'00"', $total_time);
1033 1033
 
1034 1034
         if (!$is_allowed_to_edit && $result_disabled_ext_all) {
1035 1035
             $final_score = Display::return_icon('invisible.gif', get_lang('ResultsHiddenByExerciseSetting'));
1036 1036
         } else {
1037 1037
             if (is_numeric($total_score)) {
1038
-                $final_score = $total_score . '%';
1038
+                $final_score = $total_score.'%';
1039 1039
             } else {
1040 1040
                 $final_score = $total_score;
1041 1041
             }
@@ -1051,19 +1051,19 @@  discard block
 block discarded – undo
1051 1051
 
1052 1052
         $action = null;
1053 1053
         if ($type == 'classic') {
1054
-            $action =  '<td></td>';
1054
+            $action = '<td></td>';
1055 1055
         }
1056 1056
 
1057 1057
         $output .= '<tr class="'.$oddclass.'">
1058 1058
                 <td></td>
1059 1059
                 <td colspan="4">
1060
-                    <i>' . get_lang('AccomplishedStepsTotal') .'</i>
1060
+                    <i>' . get_lang('AccomplishedStepsTotal').'</i>
1061 1061
                 </td>
1062 1062
                 <td colspan="2">'.$progress.'%</td>
1063 1063
                 <td colspan="2">
1064 1064
                     ' . $final_score.'
1065 1065
                 </td>
1066
-                <td colspan="2">' . $total_time . '</div>
1066
+                <td colspan="2">' . $total_time.'</div>
1067 1067
                 '.$action.'
1068 1068
            </tr>';
1069 1069
 
@@ -1359,7 +1359,7 @@  discard block
 block discarded – undo
1359 1359
     	$tbl_track_course = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1360 1360
     	if (is_array($user_id)) {
1361 1361
     	    $user_id = array_map('intval', $user_id);
1362
-    		$condition_user = " AND user_id IN (".implode(',',$user_id).") ";
1362
+    		$condition_user = " AND user_id IN (".implode(',', $user_id).") ";
1363 1363
     	} else {
1364 1364
     		$user_id = intval($user_id);
1365 1365
     		$condition_user = " AND user_id = $user_id ";
@@ -1396,13 +1396,13 @@  discard block
 block discarded – undo
1396 1396
     {
1397 1397
     	$tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
1398 1398
     	$sql = 'SELECT login_date
1399
-    	        FROM ' . $tbl_track_login . '
1400
-                WHERE login_user_id = ' . intval($student_id) . '
1399
+    	        FROM ' . $tbl_track_login.'
1400
+                WHERE login_user_id = ' . intval($student_id).'
1401 1401
                 ORDER BY login_date ASC
1402 1402
                 LIMIT 0,1';
1403 1403
 
1404 1404
     	$rs = Database::query($sql);
1405
-    	if (Database::num_rows($rs)>0) {
1405
+    	if (Database::num_rows($rs) > 0) {
1406 1406
     		if ($first_login_date = Database::result($rs, 0, 0)) {
1407 1407
                 return api_convert_and_format_date(
1408 1408
                     $first_login_date,
@@ -1427,8 +1427,8 @@  discard block
 block discarded – undo
1427 1427
     {
1428 1428
     	$table = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
1429 1429
     	$sql = 'SELECT login_date
1430
-    	        FROM ' . $table . '
1431
-                WHERE login_user_id = ' . intval($student_id) . '
1430
+    	        FROM ' . $table.'
1431
+                WHERE login_user_id = ' . intval($student_id).'
1432 1432
                 ORDER BY login_date
1433 1433
                 DESC LIMIT 0,1';
1434 1434
 
@@ -1437,18 +1437,18 @@  discard block
 block discarded – undo
1437 1437
     		if ($last_login_date = Database::result($rs, 0, 0)) {
1438 1438
     			$last_login_date = api_get_local_time($last_login_date);
1439 1439
     			if ($return_timestamp) {
1440
-    				return api_strtotime($last_login_date,'UTC');
1440
+    				return api_strtotime($last_login_date, 'UTC');
1441 1441
     			} else {
1442 1442
     				if (!$warning_message) {
1443 1443
     					return api_format_date($last_login_date, DATE_FORMAT_SHORT);
1444 1444
     				} else {
1445
-    					$timestamp = api_strtotime($last_login_date,'UTC');
1445
+    					$timestamp = api_strtotime($last_login_date, 'UTC');
1446 1446
     					$currentTimestamp = time();
1447 1447
 
1448 1448
     					//If the last connection is > than 7 days, the text is red
1449 1449
     					//345600 = 7 days in seconds
1450 1450
     					if ($currentTimestamp - $timestamp > 604800) {
1451
-    						return '<span style="color: #F00;">' . api_format_date($last_login_date, DATE_FORMAT_SHORT) . '</span>';
1451
+    						return '<span style="color: #F00;">'.api_format_date($last_login_date, DATE_FORMAT_SHORT).'</span>';
1452 1452
     					} else {
1453 1453
     						return api_format_date($last_login_date, DATE_FORMAT_SHORT);
1454 1454
     					}
@@ -1483,7 +1483,7 @@  discard block
 block discarded – undo
1483 1483
         $sql = "$select
1484 1484
                 FROM $tbl_track_login
1485 1485
                 WHERE
1486
-                    login_user_id IN (' ". implode("','", $studentList) . "' ) AND
1486
+                    login_user_id IN (' ".implode("','", $studentList)."' ) AND
1487 1487
                     login_date < '$date'
1488 1488
                 ";
1489 1489
         $rs = Database::query($sql);
@@ -1582,7 +1582,7 @@  discard block
 block discarded – undo
1582 1582
                               '.Display::return_icon('messagebox_warning.gif').'
1583 1583
                              </a>'
1584 1584
                             : null;
1585
-    					return $icon. Display::label($last_login_date, 'warning');
1585
+    					return $icon.Display::label($last_login_date, 'warning');
1586 1586
     				} else {
1587 1587
     					return $last_login_date;
1588 1588
     				}
@@ -1632,7 +1632,7 @@  discard block
 block discarded – undo
1632 1632
                     session_id = $session_id
1633 1633
                     $month_filter";
1634 1634
     	$rs = Database::query($sql);
1635
-    	if (Database::num_rows($rs)>0) {
1635
+    	if (Database::num_rows($rs) > 0) {
1636 1636
     		$row = Database::fetch_object($rs);
1637 1637
     		$count = $row->count_connections;
1638 1638
     	}
@@ -1653,14 +1653,14 @@  discard block
 block discarded – undo
1653 1653
     	$tbl_session_course_rel_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
1654 1654
 
1655 1655
     	$sql = 'SELECT DISTINCT c_id
1656
-                FROM ' . $tbl_course_rel_user . '
1656
+                FROM ' . $tbl_course_rel_user.'
1657 1657
                 WHERE user_id = ' . $user_id.' AND relation_type<>'.COURSE_RELATION_TYPE_RRHH;
1658 1658
     	$rs = Database::query($sql);
1659 1659
     	$nb_courses = Database::num_rows($rs);
1660 1660
 
1661 1661
     	if ($include_sessions) {
1662 1662
     		$sql = 'SELECT DISTINCT c_id
1663
-                    FROM ' . $tbl_session_course_rel_user . '
1663
+                    FROM ' . $tbl_session_course_rel_user.'
1664 1664
                     WHERE user_id = ' . $user_id;
1665 1665
     		$rs = Database::query($sql);
1666 1666
     		$nb_courses += Database::num_rows($rs);
@@ -1707,7 +1707,7 @@  discard block
 block discarded – undo
1707 1707
     		$condition_quiz = "";
1708 1708
     		if (!empty($exercise_id)) {
1709 1709
     			$exercise_id = intval($exercise_id);
1710
-    			$condition_quiz =" AND id = $exercise_id ";
1710
+    			$condition_quiz = " AND id = $exercise_id ";
1711 1711
     		}
1712 1712
 
1713 1713
     		// Compose a filter based on optional session id given
@@ -1756,7 +1756,7 @@  discard block
 block discarded – undo
1756 1756
                         }
1757 1757
                     }
1758 1758
                     if (!empty($exercise_list)) {
1759
-                        $exercise_id = implode("','",$exercise_list);
1759
+                        $exercise_id = implode("','", $exercise_list);
1760 1760
                     }
1761 1761
     			}
1762 1762
 
@@ -1781,10 +1781,10 @@  discard block
 block discarded – undo
1781 1781
     			$quiz_avg_score = null;
1782 1782
 
1783 1783
     			if (!empty($row['avg_score'])) {
1784
-    				$quiz_avg_score = round($row['avg_score'],2);
1784
+    				$quiz_avg_score = round($row['avg_score'], 2);
1785 1785
     			}
1786 1786
 
1787
-    			if(!empty($row['num_attempts'])) {
1787
+    			if (!empty($row['num_attempts'])) {
1788 1788
     				$quiz_avg_score = round($quiz_avg_score / $row['num_attempts'], 2);
1789 1789
     			}
1790 1790
     			if (is_array($student_id)) {
@@ -1914,7 +1914,7 @@  discard block
 block discarded – undo
1914 1914
             $row = Database::fetch_row($rs);
1915 1915
             $count = $row[0];
1916 1916
         }
1917
-        $count = ($count != 0 ) ? 100*round(intval($count)/count($exercise_list), 2) .'%' : '0%';
1917
+        $count = ($count != 0) ? 100 * round(intval($count) / count($exercise_list), 2).'%' : '0%';
1918 1918
         return $count;
1919 1919
     }
1920 1920
 
@@ -1939,7 +1939,7 @@  discard block
 block discarded – undo
1939 1939
                 );
1940 1940
 
1941 1941
                 if (!empty($best_attempt) && !empty($best_attempt['exe_weighting'])) {
1942
-                    $result += $best_attempt['exe_result']/$best_attempt['exe_weighting'];
1942
+                    $result += $best_attempt['exe_result'] / $best_attempt['exe_weighting'];
1943 1943
                 }
1944 1944
             }
1945 1945
             $result = $result / count($exercise_list);
@@ -1976,7 +1976,7 @@  discard block
 block discarded – undo
1976 1976
         $query = sprintf($sql, intval($courseId), $sessionId);
1977 1977
         $rs = Database::query($query);
1978 1978
         $teachers = array();
1979
-        while ($teacher = Database::fetch_array($rs,'ASSOC')) {
1979
+        while ($teacher = Database::fetch_array($rs, 'ASSOC')) {
1980 1980
             $teachers[] = $teacher;
1981 1981
         }
1982 1982
         $data = array();
@@ -2100,7 +2100,7 @@  discard block
 block discarded – undo
2100 2100
             $data[] = array(
2101 2101
                 'course' => $course['title'],
2102 2102
                 'session' => $teacher['name'],
2103
-                'tutor' => $tutor['username'] . ' - ' . $tutor['lastname'] . ' ' . $tutor['firstname'],
2103
+                'tutor' => $tutor['username'].' - '.$tutor['lastname'].' '.$tutor['firstname'],
2104 2104
                 'documents' => $totalDocuments,
2105 2105
                 'links' => $totalLinks,
2106 2106
                 'forums' => $totalForums,
@@ -2163,7 +2163,7 @@  discard block
 block discarded – undo
2163 2163
             for ($i = 0; $i < count($lpIdList); $i++) {
2164 2164
                 $placeHolders[] = '?';
2165 2165
             }
2166
-            $lpConditions['AND id IN(' . implode(', ', $placeHolders) . ') '] = $lpIdList;
2166
+            $lpConditions['AND id IN('.implode(', ', $placeHolders).') '] = $lpIdList;
2167 2167
         }
2168 2168
 
2169 2169
         if ($onlySeriousGame) {
@@ -2183,12 +2183,12 @@  discard block
 block discarded – undo
2183 2183
 
2184 2184
         $conditions = [
2185 2185
             " c_id = {$courseInfo['real_id']} ",
2186
-            " lp_view.lp_id IN(" . implode(', ', $filteredLP) . ") "
2186
+            " lp_view.lp_id IN(".implode(', ', $filteredLP).") "
2187 2187
         ];
2188 2188
 
2189 2189
         if (is_array($studentId)) {
2190 2190
             $studentId = array_map('intval', $studentId);
2191
-            $conditions[] = " lp_view.user_id IN (" . implode(',', $studentId) . ")  ";
2191
+            $conditions[] = " lp_view.user_id IN (".implode(',', $studentId).")  ";
2192 2192
 
2193 2193
             $groupBy = 'GROUP BY lp_id';
2194 2194
         } else {
@@ -2329,7 +2329,7 @@  discard block
 block discarded – undo
2329 2329
             // Compose a filter based on optional learning paths list given
2330 2330
             $condition_lp = "";
2331 2331
             if (count($lp_ids) > 0) {
2332
-                $condition_lp =" AND id IN(".implode(',',$lp_ids).") ";
2332
+                $condition_lp = " AND id IN(".implode(',', $lp_ids).") ";
2333 2333
             }
2334 2334
 
2335 2335
             // Compose a filter based on optional session id
@@ -2369,9 +2369,9 @@  discard block
 block discarded – undo
2369 2369
             // prepare filter on users
2370 2370
             if (is_array($student_id)) {
2371 2371
                 array_walk($student_id, 'intval');
2372
-                $condition_user1 =" AND user_id IN (".implode(',', $student_id).") ";
2372
+                $condition_user1 = " AND user_id IN (".implode(',', $student_id).") ";
2373 2373
             } else {
2374
-                $condition_user1 =" AND user_id = $student_id ";
2374
+                $condition_user1 = " AND user_id = $student_id ";
2375 2375
             }
2376 2376
 
2377 2377
             if ($count_row_lp > 0 && !empty($student_id)) {
@@ -2414,7 +2414,7 @@  discard block
 block discarded – undo
2414 2414
                                     ORDER BY lp_item_id";
2415 2415
                             $res_lp_item = Database::query($sql);
2416 2416
 
2417
-                            while ($row_lp_item = Database::fetch_array($res_lp_item,'ASSOC')) {
2417
+                            while ($row_lp_item = Database::fetch_array($res_lp_item, 'ASSOC')) {
2418 2418
                                 $my_lp_item_id = $row_lp_item['lp_item_id'];
2419 2419
 
2420 2420
                                 // Getting the most recent attempt
@@ -2437,8 +2437,8 @@  discard block
 block discarded – undo
2437 2437
                                         ORDER BY view_count DESC
2438 2438
                                         LIMIT 1";
2439 2439
                                 $res_lp_item_result = Database::query($sql);
2440
-                                while ($row_max_score = Database::fetch_array($res_lp_item_result,'ASSOC')) {
2441
-                                    $list[]= $row_max_score;
2440
+                                while ($row_max_score = Database::fetch_array($res_lp_item_result, 'ASSOC')) {
2441
+                                    $list[] = $row_max_score;
2442 2442
                                 }
2443 2443
                             }
2444 2444
                         } else {
@@ -2462,8 +2462,8 @@  discard block
 block discarded – undo
2462 2462
                             if ($debug) echo $sql.'<br />';
2463 2463
                             $res_max_score = Database::query($sql);
2464 2464
 
2465
-                            while ($row_max_score = Database::fetch_array($res_max_score,'ASSOC')) {
2466
-                                $list[]= $row_max_score;
2465
+                            while ($row_max_score = Database::fetch_array($res_max_score, 'ASSOC')) {
2466
+                                $list[] = $row_max_score;
2467 2467
                             }
2468 2468
                         }
2469 2469
 
@@ -2478,7 +2478,7 @@  discard block
 block discarded – undo
2478 2478
                             $max_score_item_view = $row_max_score['max_score_item_view'];
2479 2479
                             $score = $row_max_score['score'];
2480 2480
 
2481
-                            if ($debug) echo '<h3>Item Type: ' .$row_max_score['item_type'].'</h3>';
2481
+                            if ($debug) echo '<h3>Item Type: '.$row_max_score['item_type'].'</h3>';
2482 2482
 
2483 2483
                             if ($row_max_score['item_type'] == 'sco') {
2484 2484
                                 /* Check if it is sco (easier to get max_score)
@@ -2496,7 +2496,7 @@  discard block
 block discarded – undo
2496 2496
                                 }
2497 2497
                                 // Avoid division by zero errors
2498 2498
                                 if (!empty($max_score)) {
2499
-                                    $lp_partial_total += $score/$max_score;
2499
+                                    $lp_partial_total += $score / $max_score;
2500 2500
                                 }
2501 2501
                                 if ($debug) echo '<b>$lp_partial_total, $score, $max_score '.$lp_partial_total.' '.$score.' '.$max_score.'</b><br />';
2502 2502
                             } else {
@@ -2520,10 +2520,10 @@  discard block
 block discarded – undo
2520 2520
                                         ORDER BY exe_date DESC
2521 2521
                                         LIMIT 1";
2522 2522
 
2523
-                                if ($debug) echo $sql .'<br />';
2523
+                                if ($debug) echo $sql.'<br />';
2524 2524
                                 $result_last_attempt = Database::query($sql);
2525 2525
                                 $num = Database :: num_rows($result_last_attempt);
2526
-                                if ($num > 0 ) {
2526
+                                if ($num > 0) {
2527 2527
                                     $id_last_attempt = Database :: result($result_last_attempt, 0, 0);
2528 2528
                                     if ($debug) echo $id_last_attempt.'<br />';
2529 2529
 
@@ -2552,13 +2552,13 @@  discard block
 block discarded – undo
2552 2552
                                         $max_score = $row_max_score_bis['maxscore'];
2553 2553
                                     }
2554 2554
                                     if (!empty($max_score) && floatval($max_score) > 0) {
2555
-                                        $lp_partial_total += $score/$max_score;
2555
+                                        $lp_partial_total += $score / $max_score;
2556 2556
                                     }
2557 2557
                                     if ($debug) echo '$lp_partial_total, $score, $max_score <b>'.$lp_partial_total.' '.$score.' '.$max_score.'</b><br />';
2558 2558
                                 }
2559 2559
                             }
2560 2560
 
2561
-                            if (in_array($row_max_score['item_type'], array('quiz','sco'))) {
2561
+                            if (in_array($row_max_score['item_type'], array('quiz', 'sco'))) {
2562 2562
                                 // Normal way
2563 2563
                                 if ($use_max_score[$lp_id]) {
2564 2564
                                     $count_items++;
@@ -2593,8 +2593,8 @@  discard block
 block discarded – undo
2593 2593
                     if ($debug) echo $sql;
2594 2594
                     $result_have_quiz = Database::query($sql);
2595 2595
 
2596
-                    if (Database::num_rows($result_have_quiz) > 0 ) {
2597
-                        $row = Database::fetch_array($result_have_quiz,'ASSOC');
2596
+                    if (Database::num_rows($result_have_quiz) > 0) {
2597
+                        $row = Database::fetch_array($result_have_quiz, 'ASSOC');
2598 2598
                         if (is_numeric($row['count']) && $row['count'] != 0) {
2599 2599
                             $lp_with_quiz++;
2600 2600
                         }
@@ -2606,7 +2606,7 @@  discard block
 block discarded – undo
2606 2606
 
2607 2607
                 if ($lp_with_quiz != 0) {
2608 2608
                     if (!$return_array) {
2609
-                        $score_of_scorm_calculate = round(($global_result/$lp_with_quiz),2);
2609
+                        $score_of_scorm_calculate = round(($global_result / $lp_with_quiz), 2);
2610 2610
                         if ($debug) var_dump($score_of_scorm_calculate);
2611 2611
                         if (empty($lp_ids)) {
2612 2612
                             if ($debug) echo '<h2>All lps fix: '.$score_of_scorm_calculate.'</h2>';
@@ -2680,9 +2680,9 @@  discard block
 block discarded – undo
2680 2680
 
2681 2681
         if (is_array($student_id)) {
2682 2682
             array_walk($student_id, 'intval');
2683
-            $conditions[] =" lp_view.user_id IN (".implode(',', $student_id).") ";
2683
+            $conditions[] = " lp_view.user_id IN (".implode(',', $student_id).") ";
2684 2684
         } else {
2685
-            $conditions[] =" lp_view.user_id = $student_id ";
2685
+            $conditions[] = " lp_view.user_id = $student_id ";
2686 2686
         }
2687 2687
 
2688 2688
         $conditionsToString = implode('AND ', $conditions);
@@ -2706,7 +2706,7 @@  discard block
 block discarded – undo
2706 2706
             return 0;
2707 2707
         }
2708 2708
 
2709
-        return ($row['sum_score'] / $row['sum_max_score'])*100;
2709
+        return ($row['sum_score'] / $row['sum_max_score']) * 100;
2710 2710
 
2711 2711
     }
2712 2712
 
@@ -2736,7 +2736,7 @@  discard block
 block discarded – undo
2736 2736
             // Compose a filter based on optional learning paths list given
2737 2737
             $condition_lp = "";
2738 2738
             if (count($lp_ids) > 0) {
2739
-                $condition_lp =" AND id IN(".implode(',',$lp_ids).") ";
2739
+                $condition_lp = " AND id IN(".implode(',', $lp_ids).") ";
2740 2740
             }
2741 2741
 
2742 2742
             // Compose a filter based on optional session id
@@ -2795,7 +2795,7 @@  discard block
 block discarded – undo
2795 2795
 
2796 2796
         if (!empty($course)) {
2797 2797
 
2798
-            $course_id	 = $course['real_id'];
2798
+            $course_id = $course['real_id'];
2799 2799
 
2800 2800
             $lp_table    = Database :: get_course_table(TABLE_LP_MAIN);
2801 2801
             $t_lpv       = Database :: get_course_table(TABLE_LP_VIEW);
@@ -2809,8 +2809,8 @@  discard block
 block discarded – undo
2809 2809
             // calculates last connection time
2810 2810
             if ($count_row_lp > 0) {
2811 2811
                 $sql = 'SELECT MAX(start_time)
2812
-                        FROM ' . $t_lpiv . ' AS item_view
2813
-                        INNER JOIN ' . $t_lpv . ' AS view
2812
+                        FROM ' . $t_lpiv.' AS item_view
2813
+                        INNER JOIN ' . $t_lpv.' AS view
2814 2814
                             ON item_view.lp_view_id = view.id
2815 2815
                         WHERE
2816 2816
                             item_view.c_id 		= '.$course_id.' AND
@@ -2846,15 +2846,15 @@  discard block
 block discarded – undo
2846 2846
 
2847 2847
         // At first, courses where $coach_id is coach of the course //
2848 2848
         $sql = 'SELECT session_id, c_id
2849
-                FROM ' . $tbl_session_course_user . '
2849
+                FROM ' . $tbl_session_course_user.'
2850 2850
                 WHERE user_id=' . $coach_id.' AND status=2';
2851 2851
 
2852 2852
         if (api_is_multiple_url_enabled()) {
2853
-            $tbl_session_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
2853
+            $tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
2854 2854
             $access_url_id = api_get_current_access_url_id();
2855 2855
             if ($access_url_id != -1) {
2856 2856
                 $sql = 'SELECT scu.session_id, scu.c_id
2857
-                    FROM ' . $tbl_session_course_user . ' scu
2857
+                    FROM ' . $tbl_session_course_user.' scu
2858 2858
                     INNER JOIN '.$tbl_session_rel_access_url.'  sru
2859 2859
                     ON (scu.session_id=sru.session_id)
2860 2860
                     WHERE
@@ -2888,28 +2888,28 @@  discard block
 block discarded – undo
2888 2888
 
2889 2889
         // Then, courses where $coach_id is coach of the session    //
2890 2890
         $sql = 'SELECT session_course_user.user_id
2891
-                FROM ' . $tbl_session_course_user . ' as session_course_user
2891
+                FROM ' . $tbl_session_course_user.' as session_course_user
2892 2892
                 INNER JOIN     '.$tbl_session_user.' sru
2893 2893
                 ON session_course_user.user_id = sru.user_id AND session_course_user.session_id = sru.session_id
2894
-                INNER JOIN ' . $tbl_session_course . ' as session_course
2894
+                INNER JOIN ' . $tbl_session_course.' as session_course
2895 2895
                 ON session_course.c_id = session_course_user.c_id
2896 2896
                 AND session_course_user.session_id = session_course.session_id
2897
-                INNER JOIN ' . $tbl_session . ' as session
2897
+                INNER JOIN ' . $tbl_session.' as session
2898 2898
                 ON session.id = session_course.session_id
2899 2899
                 AND session.id_coach = ' . $coach_id;
2900 2900
         if (api_is_multiple_url_enabled()) {
2901
-            $tbl_session_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
2901
+            $tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
2902 2902
             $access_url_id = api_get_current_access_url_id();
2903
-            if ($access_url_id != -1){
2903
+            if ($access_url_id != -1) {
2904 2904
                 $sql = 'SELECT session_course_user.user_id
2905
-                        FROM ' . $tbl_session_course_user . ' as session_course_user
2905
+                        FROM ' . $tbl_session_course_user.' as session_course_user
2906 2906
                         INNER JOIN     '.$tbl_session_user.' sru
2907 2907
                             ON session_course_user.user_id = sru.user_id AND
2908 2908
                                session_course_user.session_id = sru.session_id
2909
-                        INNER JOIN ' . $tbl_session_course . ' as session_course
2909
+                        INNER JOIN ' . $tbl_session_course.' as session_course
2910 2910
                             ON session_course.c_id = session_course_user.c_id AND
2911 2911
                             session_course_user.session_id = session_course.session_id
2912
-                        INNER JOIN ' . $tbl_session . ' as session
2912
+                        INNER JOIN ' . $tbl_session.' as session
2913 2913
                             ON session.id = session_course.session_id AND
2914 2914
                             session.id_coach = ' . $coach_id.'
2915 2915
                         INNER JOIN '.$tbl_session_rel_access_url.' session_rel_url
@@ -2939,8 +2939,8 @@  discard block
 block discarded – undo
2939 2939
 
2940 2940
         $students = [];
2941 2941
         // At first, courses where $coach_id is coach of the course //
2942
-        $sql = 'SELECT c_id FROM ' . $tbl_session_course_user . '
2943
-                WHERE session_id="' . $id_session . '" AND user_id=' . $coach_id.' AND status=2';
2942
+        $sql = 'SELECT c_id FROM '.$tbl_session_course_user.'
2943
+                WHERE session_id="' . $id_session.'" AND user_id='.$coach_id.' AND status=2';
2944 2944
         $result = Database::query($sql);
2945 2945
 
2946 2946
         while ($a_courses = Database::fetch_array($result)) {
@@ -2950,7 +2950,7 @@  discard block
 block discarded – undo
2950 2950
                     FROM $tbl_session_course_user AS srcru
2951 2951
                     WHERE
2952 2952
                         c_id = '$courseId' AND
2953
-                        session_id = '" . $id_session . "'";
2953
+                        session_id = '".$id_session."'";
2954 2954
             $rs = Database::query($sql);
2955 2955
             while ($row = Database::fetch_array($rs)) {
2956 2956
                 $students[$row['user_id']] = $row['user_id'];
@@ -2958,15 +2958,15 @@  discard block
 block discarded – undo
2958 2958
         }
2959 2959
 
2960 2960
         // Then, courses where $coach_id is coach of the session
2961
-        $sql = 'SELECT id_coach FROM ' . $tbl_session . '
2962
-                WHERE id="' . $id_session.'" AND id_coach="' . $coach_id . '"';
2961
+        $sql = 'SELECT id_coach FROM '.$tbl_session.'
2962
+                WHERE id="' . $id_session.'" AND id_coach="'.$coach_id.'"';
2963 2963
         $result = Database::query($sql);
2964 2964
 
2965 2965
         //He is the session_coach so we select all the users in the session
2966 2966
         if (Database::num_rows($result) > 0) {
2967 2967
             $sql = 'SELECT DISTINCT srcru.user_id
2968
-                    FROM ' . $tbl_session_course_user . ' AS srcru
2969
-                    WHERE session_id="' . $id_session . '"';
2968
+                    FROM ' . $tbl_session_course_user.' AS srcru
2969
+                    WHERE session_id="' . $id_session.'"';
2970 2970
             $result = Database::query($sql);
2971 2971
             while ($row = Database::fetch_array($result)) {
2972 2972
                 $students[$row['user_id']] = $row['user_id'];
@@ -2993,8 +2993,8 @@  discard block
 block discarded – undo
2993 2993
 
2994 2994
         // At first, courses where $coach_id is coach of the course //
2995 2995
 
2996
-        $sql = 'SELECT 1 FROM ' . $tbl_session_course_user . '
2997
-                WHERE user_id=' . $coach_id .' AND status=2';
2996
+        $sql = 'SELECT 1 FROM '.$tbl_session_course_user.'
2997
+                WHERE user_id=' . $coach_id.' AND status=2';
2998 2998
         $result = Database::query($sql);
2999 2999
         if (Database::num_rows($result) > 0) {
3000 3000
             return true;
@@ -3002,12 +3002,12 @@  discard block
 block discarded – undo
3002 3002
 
3003 3003
         // Then, courses where $coach_id is coach of the session
3004 3004
         $sql = 'SELECT session_course_user.user_id
3005
-                FROM ' . $tbl_session_course_user . ' as session_course_user
3006
-                INNER JOIN ' . $tbl_session_course . ' as session_course
3005
+                FROM ' . $tbl_session_course_user.' as session_course_user
3006
+                INNER JOIN ' . $tbl_session_course.' as session_course
3007 3007
                     ON session_course.c_id = session_course_user.c_id
3008
-                INNER JOIN ' . $tbl_session . ' as session
3008
+                INNER JOIN ' . $tbl_session.' as session
3009 3009
                     ON session.id = session_course.session_id
3010
-                    AND session.id_coach = ' . $coach_id . '
3010
+                    AND session.id_coach = ' . $coach_id.'
3011 3011
                 WHERE user_id = ' . $student_id;
3012 3012
         $result = Database::query($sql);
3013 3013
         if (Database::num_rows($result) > 0) {
@@ -3039,16 +3039,16 @@  discard block
 block discarded – undo
3039 3039
         // At first, courses where $coach_id is coach of the course.
3040 3040
 
3041 3041
         $sql = 'SELECT DISTINCT c.code
3042
-                FROM ' . $tbl_session_course_user . ' sc
3042
+                FROM ' . $tbl_session_course_user.' sc
3043 3043
                 INNER JOIN '.$tbl_course.' c
3044 3044
                 ON (c.id = sc.c_id)
3045 3045
                 WHERE user_id = ' . $coach_id.' AND status = 2';
3046 3046
 
3047 3047
         if (api_is_multiple_url_enabled()) {
3048 3048
             $access_url_id = api_get_current_access_url_id();
3049
-            if ($access_url_id != -1){
3049
+            if ($access_url_id != -1) {
3050 3050
                 $sql = 'SELECT DISTINCT c.code
3051
-                        FROM ' . $tbl_session_course_user . ' scu
3051
+                        FROM ' . $tbl_session_course_user.' scu
3052 3052
                         INNER JOIN '.$tbl_course.' c
3053 3053
                         ON (c.code = scu.c_id)
3054 3054
                         INNER JOIN '.$tbl_course_rel_access_url.' cru
@@ -3061,7 +3061,7 @@  discard block
 block discarded – undo
3061 3061
         }
3062 3062
 
3063 3063
         if (!empty($id_session)) {
3064
-            $sql .= ' AND session_id=' . $id_session;
3064
+            $sql .= ' AND session_id='.$id_session;
3065 3065
         }
3066 3066
 
3067 3067
         $courseList = array();
@@ -3073,25 +3073,25 @@  discard block
 block discarded – undo
3073 3073
         // Then, courses where $coach_id is coach of the session
3074 3074
 
3075 3075
         $sql = 'SELECT DISTINCT course.code
3076
-                FROM ' . $tbl_session_course . ' as session_course
3077
-                INNER JOIN ' . $tbl_session . ' as session
3076
+                FROM ' . $tbl_session_course.' as session_course
3077
+                INNER JOIN ' . $tbl_session.' as session
3078 3078
                     ON session.id = session_course.session_id
3079
-                    AND session.id_coach = ' . $coach_id . '
3080
-                INNER JOIN ' . $tbl_course . ' as course
3079
+                    AND session.id_coach = ' . $coach_id.'
3080
+                INNER JOIN ' . $tbl_course.' as course
3081 3081
                     ON course.id = session_course.c_id';
3082 3082
 
3083 3083
         if (api_is_multiple_url_enabled()) {
3084 3084
             $tbl_course_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
3085 3085
             $access_url_id = api_get_current_access_url_id();
3086
-            if ($access_url_id != -1){
3086
+            if ($access_url_id != -1) {
3087 3087
                 $sql = 'SELECT DISTINCT c.code
3088
-                    FROM ' . $tbl_session_course . ' as session_course
3088
+                    FROM ' . $tbl_session_course.' as session_course
3089 3089
                     INNER JOIN '.$tbl_course.' c
3090 3090
                     ON (c.id = session_course.c_id)
3091
-                    INNER JOIN ' . $tbl_session . ' as session
3091
+                    INNER JOIN ' . $tbl_session.' as session
3092 3092
                     ON session.id = session_course.session_id
3093
-                        AND session.id_coach = ' . $coach_id . '
3094
-                    INNER JOIN ' . $tbl_course . ' as course
3093
+                        AND session.id_coach = ' . $coach_id.'
3094
+                    INNER JOIN ' . $tbl_course.' as course
3095 3095
                         ON course.id = session_course.c_id
3096 3096
                      INNER JOIN '.$tbl_course_rel_access_url.' course_rel_url
3097 3097
                     ON (course_rel_url.c_id = c.id)';
@@ -3099,12 +3099,12 @@  discard block
 block discarded – undo
3099 3099
         }
3100 3100
 
3101 3101
         if (!empty ($id_session)) {
3102
-            $sql .= ' WHERE session_course.session_id=' . $id_session;
3102
+            $sql .= ' WHERE session_course.session_id='.$id_session;
3103 3103
             if (api_is_multiple_url_enabled())
3104
-            $sql .=  ' AND access_url_id = '.$access_url_id;
3105
-        }  else {
3104
+            $sql .= ' AND access_url_id = '.$access_url_id;
3105
+        } else {
3106 3106
             if (api_is_multiple_url_enabled())
3107
-            $sql .=  ' WHERE access_url_id = '.$access_url_id;
3107
+            $sql .= ' WHERE access_url_id = '.$access_url_id;
3108 3108
         }
3109 3109
 
3110 3110
         $result = Database::query($sql);
@@ -3160,7 +3160,7 @@  discard block
 block discarded – undo
3160 3160
             }
3161 3161
         }
3162 3162
 
3163
-        $tbl_session_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
3163
+        $tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
3164 3164
         $access_url_id = api_get_current_access_url_id();
3165 3165
 
3166 3166
         $sql = "
@@ -3280,7 +3280,7 @@  discard block
 block discarded – undo
3280 3280
             // table definition
3281 3281
             $tbl_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
3282 3282
             $tbl_document = Database :: get_course_table(TABLE_DOCUMENT);
3283
-            $course_id	 = $a_course['real_id'];
3283
+            $course_id = $a_course['real_id'];
3284 3284
             if (is_array($student_id)) {
3285 3285
                 $studentList = array_map('intval', $student_id);
3286 3286
                 $condition_user = " AND ip.insert_user_id IN ('".implode(',', $studentList)."') ";
@@ -3331,7 +3331,7 @@  discard block
 block discarded – undo
3331 3331
         $a_course = CourseManager::get_course_information($course_code);
3332 3332
         if (!empty($a_course)) {
3333 3333
             $course_id = $a_course['real_id'];
3334
-            $conditions[]= " ip.c_id  = $course_id AND pub.c_id  = $course_id ";
3334
+            $conditions[] = " ip.c_id  = $course_id AND pub.c_id  = $course_id ";
3335 3335
         }
3336 3336
 
3337 3337
         // table definition
@@ -3340,14 +3340,14 @@  discard block
 block discarded – undo
3340 3340
 
3341 3341
         if (is_array($student_id)) {
3342 3342
             $studentList = array_map('intval', $student_id);
3343
-            $conditions[]= " ip.insert_user_id IN ('".implode("','", $studentList)."') ";
3343
+            $conditions[] = " ip.insert_user_id IN ('".implode("','", $studentList)."') ";
3344 3344
         } else {
3345 3345
             $student_id = intval($student_id);
3346
-            $conditions[]= " ip.insert_user_id = '$student_id' ";
3346
+            $conditions[] = " ip.insert_user_id = '$student_id' ";
3347 3347
         }
3348 3348
         if (isset($session_id)) {
3349 3349
             $session_id = intval($session_id);
3350
-            $conditions[]= " pub.session_id = $session_id ";
3350
+            $conditions[] = " pub.session_id = $session_id ";
3351 3351
         }
3352 3352
         $conditionToString = implode('AND', $conditions);
3353 3353
 
@@ -3380,8 +3380,8 @@  discard block
 block discarded – undo
3380 3380
         $courseCondition = null;
3381 3381
         $conditions = array();
3382 3382
         if (!empty($courseInfo)) {
3383
-            $course_id	    = $courseInfo['real_id'];
3384
-            $conditions[]= " post.c_id  = $course_id AND forum.c_id = $course_id ";
3383
+            $course_id = $courseInfo['real_id'];
3384
+            $conditions[] = " post.c_id  = $course_id AND forum.c_id = $course_id ";
3385 3385
         }
3386 3386
 
3387 3387
         // Table definition.
@@ -3390,15 +3390,15 @@  discard block
 block discarded – undo
3390 3390
 
3391 3391
         if (is_array($student_id)) {
3392 3392
             $studentList = array_map('intval', $student_id);
3393
-            $conditions[]= " post.poster_id IN ('".implode("','", $studentList)."') ";
3393
+            $conditions[] = " post.poster_id IN ('".implode("','", $studentList)."') ";
3394 3394
         } else {
3395 3395
             $student_id = intval($student_id);
3396
-            $conditions[]= " post.poster_id = '$student_id' ";
3396
+            $conditions[] = " post.poster_id = '$student_id' ";
3397 3397
         }
3398 3398
 
3399 3399
         if (isset($session_id)) {
3400 3400
             $session_id = intval($session_id);
3401
-            $conditions[]= " forum.session_id = $session_id";
3401
+            $conditions[] = " forum.session_id = $session_id";
3402 3402
         }
3403 3403
 
3404 3404
         $conditionsToString = implode('AND ', $conditions);
@@ -3433,7 +3433,7 @@  discard block
 block discarded – undo
3433 3433
             $condition_session = '';
3434 3434
             if (isset($session_id)) {
3435 3435
                 $session_id = intval($session_id);
3436
-                $condition_session = api_get_session_condition($session_id, true,  false, 'f.session_id');
3436
+                $condition_session = api_get_session_condition($session_id, true, false, 'f.session_id');
3437 3437
             }
3438 3438
 
3439 3439
             $course_id = $courseInfo['real_id'];
@@ -3489,7 +3489,7 @@  discard block
 block discarded – undo
3489 3489
         $condition_session = '';
3490 3490
         if (isset($session_id)) {
3491 3491
             $session_id = intval($session_id);
3492
-            $condition_session = ' AND f.session_id = '. $session_id;
3492
+            $condition_session = ' AND f.session_id = '.$session_id;
3493 3493
         }
3494 3494
 
3495 3495
         $groupId = intval($groupId);
@@ -3550,7 +3550,7 @@  discard block
 block discarded – undo
3550 3550
         $condition_session = '';
3551 3551
         if (isset($session_id)) {
3552 3552
              $session_id = intval($session_id);
3553
-             $condition_session = ' AND f.session_id = '. $session_id;
3553
+             $condition_session = ' AND f.session_id = '.$session_id;
3554 3554
         }
3555 3555
 
3556 3556
         $groupId = intval($groupId);
@@ -3629,7 +3629,7 @@  discard block
 block discarded – undo
3629 3629
     {
3630 3630
         $student_id = intval($student_id);
3631 3631
         $courseId = intval($courseId);
3632
-        $session_id    = intval($session_id);
3632
+        $session_id = intval($session_id);
3633 3633
         $date_time  = '';
3634 3634
 
3635 3635
         // table definition
@@ -3698,7 +3698,7 @@  discard block
 block discarded – undo
3698 3698
         $table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
3699 3699
 
3700 3700
         $sql = 'SELECT 1
3701
-                FROM ' . $table . '
3701
+                FROM ' . $table.'
3702 3702
                 WHERE down_user_id = '.$student_id.'
3703 3703
                 AND c_id  = "'.$courseId.'"
3704 3704
                 AND down_session_id = '.$session_id.' ';
@@ -3776,30 +3776,30 @@  discard block
 block discarded – undo
3776 3776
                 '.$inner.'
3777 3777
                 WHERE c.id = '.$courseId.'
3778 3778
                 GROUP BY stats_login.user_id
3779
-                HAVING DATE_SUB( "' . $now . '", INTERVAL '.$since.' DAY) > max_date ';
3779
+                HAVING DATE_SUB( "' . $now.'", INTERVAL '.$since.' DAY) > max_date ';
3780 3780
 
3781 3781
         if ($since == 'never') {
3782 3782
             if (empty($session_id)) {
3783 3783
                 $sql = 'SELECT course_user.user_id
3784
-                        FROM ' . $table_course_rel_user . ' course_user
3785
-                        LEFT JOIN ' . $tbl_track_login . ' stats_login
3784
+                        FROM ' . $table_course_rel_user.' course_user
3785
+                        LEFT JOIN ' . $tbl_track_login.' stats_login
3786 3786
                         ON course_user.user_id = stats_login.user_id AND
3787
-                        relation_type<>' . COURSE_RELATION_TYPE_RRHH . '
3788
-                        INNER JOIN ' . $tableCourse . ' c
3787
+                        relation_type<>' . COURSE_RELATION_TYPE_RRHH.'
3788
+                        INNER JOIN ' . $tableCourse.' c
3789 3789
                         ON (c.id = course_user.c_id)
3790 3790
                         WHERE
3791
-                            course_user.c_id = ' . $courseId . ' AND
3791
+                            course_user.c_id = ' . $courseId.' AND
3792 3792
                             stats_login.login_course_date IS NULL
3793 3793
                         GROUP BY course_user.user_id';
3794 3794
             } else {
3795 3795
                 $sql = 'SELECT session_course_user.user_id
3796 3796
                         FROM '.$tbl_session_course_user.' session_course_user
3797
-                        LEFT JOIN ' . $tbl_track_login . ' stats_login
3797
+                        LEFT JOIN ' . $tbl_track_login.' stats_login
3798 3798
                         ON session_course_user.user_id = stats_login.user_id
3799
-                        INNER JOIN ' . $tableCourse . ' c
3799
+                        INNER JOIN ' . $tableCourse.' c
3800 3800
                         ON (c.id = session_course_user.c_id)
3801 3801
                         WHERE
3802
-                            session_course_user.c_id = ' . $courseId . ' AND
3802
+                            session_course_user.c_id = ' . $courseId.' AND
3803 3803
                             stats_login.login_course_date IS NULL
3804 3804
                         GROUP BY session_course_user.user_id';
3805 3805
 
@@ -3808,7 +3808,7 @@  discard block
 block discarded – undo
3808 3808
 
3809 3809
         $rs = Database::query($sql);
3810 3810
         $inactive_users = array();
3811
-        while($user = Database::fetch_array($rs)) {
3811
+        while ($user = Database::fetch_array($rs)) {
3812 3812
             $inactive_users[] = $user['user_id'];
3813 3813
         }
3814 3814
 
@@ -3830,10 +3830,10 @@  discard block
 block discarded – undo
3830 3830
         $table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
3831 3831
 
3832 3832
         $sql = 'SELECT '.$student_id.'
3833
-                FROM ' . $table . '
3833
+                FROM ' . $table.'
3834 3834
                 WHERE
3835
-                    access_user_id=' . $student_id . ' AND
3836
-                    c_id="' . $courseId . '" AND
3835
+                    access_user_id=' . $student_id.' AND
3836
+                    c_id="' . $courseId.'" AND
3837 3837
                     access_session_id = "'.$session_id.'" ';
3838 3838
 
3839 3839
         $rs = Database::query($sql);
@@ -3851,13 +3851,13 @@  discard block
 block discarded – undo
3851 3851
     {
3852 3852
         $hr_dept_id = intval($hr_dept_id);
3853 3853
         $a_students = array();
3854
-        $tbl_user     = Database :: get_main_table(TABLE_MAIN_USER);
3854
+        $tbl_user = Database :: get_main_table(TABLE_MAIN_USER);
3855 3855
 
3856 3856
         $sql = 'SELECT DISTINCT user_id FROM '.$tbl_user.' as user
3857 3857
                 WHERE hr_dept_id='.$hr_dept_id;
3858 3858
         $rs = Database::query($sql);
3859 3859
 
3860
-        while($user = Database :: fetch_array($rs)) {
3860
+        while ($user = Database :: fetch_array($rs)) {
3861 3861
             $a_students[$user['user_id']] = $user['user_id'];
3862 3862
         }
3863 3863
 
@@ -3882,7 +3882,7 @@  discard block
 block discarded – undo
3882 3882
         $condition_session     = '';
3883 3883
         if (isset($session_id)) {
3884 3884
             $session_id = intval($session_id);
3885
-            $condition_session = ' AND access_session_id = '. $session_id;
3885
+            $condition_session = ' AND access_session_id = '.$session_id;
3886 3886
         }
3887 3887
         $sql = "SELECT
3888 3888
                     access_tool,
@@ -3994,7 +3994,7 @@  discard block
 block discarded – undo
3994 3994
             if (!empty($date_from) && !empty($date_to)) {
3995 3995
                 $fieldStartDate = $fields['start_date'];
3996 3996
                 if (!isset($fields['end_date'])) {
3997
-                    $where .= sprintf(" AND ($fieldStartDate BETWEEN '%s' AND '%s' )", $date_from, $date_to) ;
3997
+                    $where .= sprintf(" AND ($fieldStartDate BETWEEN '%s' AND '%s' )", $date_from, $date_to);
3998 3998
                 } else {
3999 3999
                     $fieldEndDate = $fields['end_date'];
4000 4000
                     $where .= sprintf(" AND fieldStartDate >= '%s'
@@ -4010,12 +4010,12 @@  discard block
 block discarded – undo
4010 4010
                 $where
4011 4011
                 GROUP BY %s";
4012 4012
             $sql = sprintf($sql,
4013
-                $fields['user'],    //user field
4014
-                $tableName,         //FROM
4015
-                $fields['course'],  //course condition
4016
-                $course['real_id'],    //course condition
4017
-                $fields['user'],    //user condition
4018
-                $userId,            //user condition
4013
+                $fields['user'], //user field
4014
+                $tableName, //FROM
4015
+                $fields['course'], //course condition
4016
+                $course['real_id'], //course condition
4017
+                $fields['user'], //user condition
4018
+                $userId, //user condition
4019 4019
                 $fields['user']     //GROUP BY
4020 4020
                 );
4021 4021
             $rs = Database::query($sql);
@@ -4023,7 +4023,7 @@  discard block
 block discarded – undo
4023 4023
             //iterate query
4024 4024
             if (Database::num_rows($rs) > 0) {
4025 4025
                 while ($row = Database::fetch_array($rs)) {
4026
-                    $data[$row['user']] = (isset($data[$row['user']])) ?  $data[$row['user']] + $row[total]: $row['total'];
4026
+                    $data[$row['user']] = (isset($data[$row['user']])) ? $data[$row['user']] + $row[total] : $row['total'];
4027 4027
                 }
4028 4028
             }
4029 4029
         }
@@ -4046,11 +4046,11 @@  discard block
 block discarded – undo
4046 4046
         $courseId = api_get_course_int_id($course_code);
4047 4047
         $data = array();
4048 4048
 
4049
-        $TABLETRACK_DOWNLOADS   = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
4049
+        $TABLETRACK_DOWNLOADS = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
4050 4050
         $condition_session = '';
4051 4051
         if (isset($session_id)) {
4052 4052
             $session_id = intval($session_id);
4053
-            $condition_session = ' AND down_session_id = '. $session_id;
4053
+            $condition_session = ' AND down_session_id = '.$session_id;
4054 4054
         }
4055 4055
         $sql = "SELECT down_doc_path, COUNT(DISTINCT down_user_id), COUNT(down_doc_path) as count_down
4056 4056
                 FROM $TABLETRACK_DOWNLOADS
@@ -4235,7 +4235,7 @@  discard block
 block discarded – undo
4235 4235
 
4236 4236
             $final_course_data = array();
4237 4237
 
4238
-            foreach($my_course_data as $course_id => $value) {
4238
+            foreach ($my_course_data as $course_id => $value) {
4239 4239
                 $final_course_data[$course_id] = $course_list[$course_id];
4240 4240
             }
4241 4241
             $course_in_session[$my_session_id]['course_list'] = $final_course_data;
@@ -4256,7 +4256,7 @@  discard block
 block discarded – undo
4256 4256
                           '.Display::tag('th', get_lang('Course'), array('width'=>'300px')).'
4257 4257
                           '.Display::tag('th', get_lang('TimeSpentInTheCourse'), array('class'=>'head')).'
4258 4258
                           '.Display::tag('th', get_lang('Progress'), array('class'=>'head')).'
4259
-                          '.Display::tag('th', get_lang('Score').Display::return_icon('info3.gif', get_lang('ScormAndLPTestTotalAverage'), array('align' => 'absmiddle', 'hspace' => '3px')),array('class'=>'head')).'
4259
+                          '.Display::tag('th', get_lang('Score').Display::return_icon('info3.gif', get_lang('ScormAndLPTestTotalAverage'), array('align' => 'absmiddle', 'hspace' => '3px')), array('class'=>'head')).'
4260 4260
                           '.Display::tag('th', get_lang('LastConnexion'), array('class'=>'head')).'
4261 4261
                           '.Display::tag('th', get_lang('Details'), array('class'=>'head')).'
4262 4262
                         </tr>';
@@ -4343,7 +4343,7 @@  discard block
 block discarded – undo
4343 4343
             $all_exercise_start_time = array();
4344 4344
 
4345 4345
             foreach ($course_in_session as $my_session_id => $session_data) {
4346
-                $course_list  = $session_data['course_list'];
4346
+                $course_list = $session_data['course_list'];
4347 4347
                 $user_count = count(SessionManager::get_users_by_session($my_session_id));
4348 4348
                 $exercise_graph_name_list = array();
4349 4349
                 //$user_results = array();
@@ -4388,20 +4388,20 @@  discard block
 block discarded – undo
4388 4388
 
4389 4389
                             $score = 0;
4390 4390
                             if (!empty($user_result_data['exe_weighting']) && intval($user_result_data['exe_weighting']) != 0) {
4391
-                                $score = intval($user_result_data['exe_result']/$user_result_data['exe_weighting'] * 100);
4391
+                                $score = intval($user_result_data['exe_result'] / $user_result_data['exe_weighting'] * 100);
4392 4392
                             }
4393 4393
                             $time = api_strtotime($exercise_data['start_time']) ? api_strtotime($exercise_data['start_time'], 'UTC') : 0;
4394 4394
                             $all_exercise_start_time[] = $time;
4395 4395
                             $my_results[] = $score;
4396
-                            if (count($exercise_list)<=10) {
4396
+                            if (count($exercise_list) <= 10) {
4397 4397
                                 $title = cut($course_data['title'], 30)." \n ".cut($exercise_data['title'], 30);
4398
-                                $exercise_graph_name_list[]= $title;
4398
+                                $exercise_graph_name_list[] = $title;
4399 4399
                                 $all_exercise_graph_name_list[] = $title;
4400 4400
                             } else {
4401 4401
                                 // if there are more than 10 results, space becomes difficult to find, so only show the title of the exercise, not the tool
4402 4402
                                 $title = cut($exercise_data['title'], 30);
4403
-                                $exercise_graph_name_list[]= $title;
4404
-                                $all_exercise_graph_name_list[]= $title;
4403
+                                $exercise_graph_name_list[] = $title;
4404
+                                $all_exercise_graph_name_list[] = $title;
4405 4405
                             }
4406 4406
                         }
4407 4407
                     }
@@ -4434,7 +4434,7 @@  discard block
 block discarded – undo
4434 4434
             }
4435 4435
 
4436 4436
             $html .= Display::page_subheader(
4437
-                Display::return_icon('session.png', get_lang('Sessions'), array(), ICON_SIZE_SMALL) . ' ' . get_lang('Sessions')
4437
+                Display::return_icon('session.png', get_lang('Sessions'), array(), ICON_SIZE_SMALL).' '.get_lang('Sessions')
4438 4438
             );
4439 4439
 
4440 4440
             $html .= '<table class="data_table" width="100%">';
@@ -4484,7 +4484,7 @@  discard block
 block discarded – undo
4484 4484
                                 $courseInfo['real_id'],
4485 4485
                                 $my_session_id
4486 4486
                             );
4487
-                            if ($attempts > 1)  {
4487
+                            if ($attempts > 1) {
4488 4488
                                 $answered_exercises++;
4489 4489
                             }
4490 4490
                         }
@@ -4497,7 +4497,7 @@  discard block
 block discarded – undo
4497 4497
                     $all_average += $average;
4498 4498
                 }
4499 4499
 
4500
-                $all_average = $all_average /  count($course_list);
4500
+                $all_average = $all_average / count($course_list);
4501 4501
 
4502 4502
                 if (isset($_GET['session_id']) && $my_session_id == $_GET['session_id']) {
4503 4503
                     $html .= '<tr style="background-color:#FBF09D">';
@@ -4522,31 +4522,31 @@  discard block
 block discarded – undo
4522 4522
                 $html .= '</tr>';
4523 4523
             }
4524 4524
             $html .= '</table><br />';
4525
-            $html .= Display::div($main_session_graph, array('id'=>'session_graph','class'=>'chart-session', 'style'=>'position:relative; text-align: center;') );
4525
+            $html .= Display::div($main_session_graph, array('id'=>'session_graph', 'class'=>'chart-session', 'style'=>'position:relative; text-align: center;'));
4526 4526
 
4527 4527
             // Checking selected session.
4528 4528
 
4529 4529
             if (isset($_GET['session_id'])) {
4530 4530
                 $session_id_from_get = intval($_GET['session_id']);
4531
-                $session_data 	= $course_in_session[$session_id_from_get];
4532
-                $course_list 	= $session_data['course_list'];
4531
+                $session_data = $course_in_session[$session_id_from_get];
4532
+                $course_list = $session_data['course_list'];
4533 4533
 
4534
-                $html .= Display::tag('h3',$session_data['name'].' - '.get_lang('CourseList'));
4534
+                $html .= Display::tag('h3', $session_data['name'].' - '.get_lang('CourseList'));
4535 4535
 
4536 4536
                 $html .= '<table class="data_table" width="100%">';
4537 4537
                 //'.Display::tag('th', get_lang('DoneExercises'),         array('class'=>'head')).'
4538 4538
                 $html .= '
4539 4539
                     <tr>
4540 4540
                       <th width="300px">'.get_lang('Course').'</th>
4541
-                      '.Display::tag('th', get_lang('PublishedExercises'),    	array('class'=>'head')).'
4542
-                      '.Display::tag('th', get_lang('NewExercises'),    		array('class'=>'head')).'
4543
-                      '.Display::tag('th', get_lang('MyAverage'), 				array('class'=>'head')).'
4544
-                      '.Display::tag('th', get_lang('AverageExerciseResult'), 	array('class'=>'head')).'
4545
-                      '.Display::tag('th', get_lang('TimeSpentInTheCourse'),    array('class'=>'head')).'
4546
-                      '.Display::tag('th', get_lang('LPProgress')     ,      	array('class'=>'head')).'
4547
-                      '.Display::tag('th', get_lang('Score').Display::return_icon('info3.gif', get_lang('ScormAndLPTestTotalAverage'), array ('align' => 'absmiddle', 'hspace' => '3px')), array('class'=>'head')).'
4548
-                      '.Display::tag('th', get_lang('LastConnexion'),         	array('class'=>'head')).'
4549
-                      '.Display::tag('th', get_lang('Details'),               	array('class'=>'head')).'
4541
+                      '.Display::tag('th', get_lang('PublishedExercises'), array('class'=>'head')).'
4542
+                      '.Display::tag('th', get_lang('NewExercises'), array('class'=>'head')).'
4543
+                      '.Display::tag('th', get_lang('MyAverage'), array('class'=>'head')).'
4544
+                      '.Display::tag('th', get_lang('AverageExerciseResult'), array('class'=>'head')).'
4545
+                      '.Display::tag('th', get_lang('TimeSpentInTheCourse'), array('class'=>'head')).'
4546
+                      '.Display::tag('th', get_lang('LPProgress'), array('class'=>'head')).'
4547
+                      '.Display::tag('th', get_lang('Score').Display::return_icon('info3.gif', get_lang('ScormAndLPTestTotalAverage'), array('align' => 'absmiddle', 'hspace' => '3px')), array('class'=>'head')).'
4548
+                      '.Display::tag('th', get_lang('LastConnexion'), array('class'=>'head')).'
4549
+                      '.Display::tag('th', get_lang('Details'), array('class'=>'head')).'
4550 4550
                     </tr>';
4551 4551
 
4552 4552
                 foreach ($course_list as $course_data) {
@@ -4562,14 +4562,14 @@  discard block
 block discarded – undo
4562 4562
                         $count_exercises = count($exercises);
4563 4563
                     }
4564 4564
                     $answered_exercises = 0;
4565
-                    foreach($exercises as $exercise_item) {
4565
+                    foreach ($exercises as $exercise_item) {
4566 4566
                         $attempts = Event::count_exercise_attempts_by_user(
4567 4567
                             api_get_user_id(),
4568 4568
                             $exercise_item['id'],
4569 4569
                             $courseId,
4570 4570
                             $session_id_from_get
4571 4571
                         );
4572
-                        if ($attempts > 1)  {
4572
+                        if ($attempts > 1) {
4573 4573
                             $answered_exercises++;
4574 4574
                         }
4575 4575
                     }
@@ -4578,7 +4578,7 @@  discard block
 block discarded – undo
4578 4578
 
4579 4579
                     // Average
4580 4580
                     $average = ExerciseLib::get_average_score_by_course($courseId, $session_id_from_get);
4581
-                    $my_average	= ExerciseLib::get_average_score_by_course_by_user(api_get_user_id(), $courseId, $session_id_from_get);
4581
+                    $my_average = ExerciseLib::get_average_score_by_course_by_user(api_get_user_id(), $courseId, $session_id_from_get);
4582 4582
 
4583 4583
                     $stats_array[$course_code] = array(
4584 4584
                         'exercises' => $count_exercises,
@@ -4648,11 +4648,11 @@  discard block
 block discarded – undo
4648 4648
                     }
4649 4649
                     //Score
4650 4650
                     $html .= Display::tag('td', $percentage_score, array('align'=>'center'));
4651
-                    $html .= Display::tag('td', $last_connection,  array('align'=>'center'));
4651
+                    $html .= Display::tag('td', $last_connection, array('align'=>'center'));
4652 4652
 
4653 4653
                     if ($course_code == $courseCodeFromGet && $_GET['session_id'] == $session_id_from_get) {
4654 4654
                         $details = '<a href="#">';
4655
-                        $details .=Display::return_icon('2rightarrow_na.png', get_lang('Details'));
4655
+                        $details .= Display::return_icon('2rightarrow_na.png', get_lang('Details'));
4656 4656
                     } else {
4657 4657
                         $details = '<a href="'.api_get_self().'?course='.$course_code.'&session_id='.$session_id_from_get.$extra_params.'">';
4658 4658
                         $details .= Display::return_icon('2rightarrow.png', get_lang('Details'));
@@ -4775,7 +4775,7 @@  discard block
 block discarded – undo
4775 4775
                         );
4776 4776
 
4777 4777
                         $latest_attempt_url = '';
4778
-                        $best_score = $position = $percentage_score_result  = '-';
4778
+                        $best_score = $position = $percentage_score_result = '-';
4779 4779
                         $graph = $normal_graph = null;
4780 4780
 
4781 4781
                         // Getting best results
@@ -4811,7 +4811,7 @@  discard block
 block discarded – undo
4811 4811
                                 $percentage_score_result = Display::url(ExerciseLib::show_score($score, $weighting), $latest_attempt_url);
4812 4812
                                 $my_score = 0;
4813 4813
                                 if (!empty($weighting) && intval($weighting) != 0) {
4814
-                                    $my_score = $score/$weighting;
4814
+                                    $my_score = $score / $weighting;
4815 4815
                                 }
4816 4816
                                 //@todo this function slows the page
4817 4817
                                 $position = ExerciseLib::get_exercise_result_ranking($my_score, $exe_id, $exercices['id'], $course_info['code'], $session_id, $user_list);
@@ -4822,14 +4822,14 @@  discard block
 block discarded – undo
4822 4822
                         }
4823 4823
                         $html .= Display::div(
4824 4824
                             $normal_graph,
4825
-                            array('id'=>'main_graph_'.$exercices['id'],'class'=>'dialog', 'style'=>'display:none')
4825
+                            array('id'=>'main_graph_'.$exercices['id'], 'class'=>'dialog', 'style'=>'display:none')
4826 4826
                         );
4827 4827
 
4828 4828
                         if (empty($graph)) {
4829 4829
                             $graph = '-';
4830 4830
                         } else {
4831 4831
                             $graph = Display::url(
4832
-                                '<img src="' . $graph . '" >',
4832
+                                '<img src="'.$graph.'" >',
4833 4833
                                 $normal_graph,
4834 4834
                                 array(
4835 4835
                                     'id' => $exercices['id'],
@@ -4862,7 +4862,7 @@  discard block
 block discarded – undo
4862 4862
 
4863 4863
 
4864 4864
             // LP table results
4865
-            $html .='<table class="data_table">';
4865
+            $html .= '<table class="data_table">';
4866 4866
             $html .= Display::tag('th', get_lang('Learnpaths'), array('class'=>'head', 'style'=>'color:#000'));
4867 4867
             $html .= Display::tag('th', get_lang('LatencyTimeSpent'), array('class'=>'head', 'style'=>'color:#000'));
4868 4868
             $html .= Display::tag('th', get_lang('Progress'), array('class'=>'head', 'style'=>'color:#000'));
@@ -4916,7 +4916,7 @@  discard block
 block discarded – undo
4916 4916
                     if (!empty($last_connection_in_lp)) {
4917 4917
                         $last_connection = api_convert_and_format_date($last_connection_in_lp, DATE_TIME_FORMAT_LONG);
4918 4918
                     }
4919
-                    $html .= Display::tag('td', $last_connection, array('align'=>'center','width'=>'180px'));
4919
+                    $html .= Display::tag('td', $last_connection, array('align'=>'center', 'width'=>'180px'));
4920 4920
                     $html .= "</tr>";
4921 4921
                 }
4922 4922
             } else {
@@ -4926,7 +4926,7 @@  discard block
 block discarded – undo
4926 4926
                         </td>
4927 4927
                       </tr>';
4928 4928
             }
4929
-            $html .='</table>';
4929
+            $html .= '</table>';
4930 4930
         }
4931 4931
 
4932 4932
         return $html;
@@ -4953,7 +4953,7 @@  discard block
 block discarded – undo
4953 4953
         $myData->setSerieDescription('Serie1', get_lang('MyResults'));
4954 4954
         $myData->setSerieDescription('Serie2', get_lang('AverageScore'));
4955 4955
         $myData->setAxisUnit(0, '%');
4956
-        $myData->loadPalette(api_get_path(SYS_CODE_PATH) . 'palettes/pchart/default.color', true);
4956
+        $myData->loadPalette(api_get_path(SYS_CODE_PATH).'palettes/pchart/default.color', true);
4957 4957
         // Cache definition
4958 4958
         $cachePath = api_get_path(SYS_ARCHIVE_PATH);
4959 4959
         $myCache = new pCache(array('CacheFolder' => substr($cachePath, 0, strlen($cachePath) - 1)));
@@ -4961,9 +4961,9 @@  discard block
 block discarded – undo
4961 4961
 
4962 4962
         if ($myCache->isInCache($chartHash)) {
4963 4963
             //if we already created the img
4964
-            $imgPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash;
4964
+            $imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
4965 4965
             $myCache->saveFromCache($chartHash, $imgPath);
4966
-            $imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash;
4966
+            $imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
4967 4967
         } else {
4968 4968
             /* Define width, height and angle */
4969 4969
             $mainWidth = 860;
@@ -4992,7 +4992,7 @@  discard block
 block discarded – undo
4992 4992
             /* Set the default font */
4993 4993
             $myPicture->setFontProperties(
4994 4994
                 array(
4995
-                    'FontName' => api_get_path(SYS_FONTS_PATH) . 'opensans/OpenSans-Regular.ttf',
4995
+                    'FontName' => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf',
4996 4996
                     'FontSize' => 10)
4997 4997
             );
4998 4998
             /* Write the chart title */
@@ -5009,7 +5009,7 @@  discard block
 block discarded – undo
5009 5009
             /* Set the default font */
5010 5010
             $myPicture->setFontProperties(
5011 5011
                 array(
5012
-                    'FontName' => api_get_path(SYS_FONTS_PATH) . 'opensans/OpenSans-Regular.ttf',
5012
+                    'FontName' => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf',
5013 5013
                     'FontSize' => 6
5014 5014
                 )
5015 5015
             );
@@ -5051,7 +5051,7 @@  discard block
 block discarded – undo
5051 5051
             /* Draw the line chart */
5052 5052
             $myPicture->setFontProperties(
5053 5053
                 array(
5054
-                    'FontName' => api_get_path(SYS_FONTS_PATH) . 'opensans/OpenSans-Regular.ttf',
5054
+                    'FontName' => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf',
5055 5055
                     'FontSize' => 10
5056 5056
                 )
5057 5057
             );
@@ -5084,12 +5084,12 @@  discard block
 block discarded – undo
5084 5084
             );
5085 5085
 
5086 5086
             $myCache->writeToCache($chartHash, $myPicture);
5087
-            $imgPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash;
5087
+            $imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
5088 5088
             $myCache->saveFromCache($chartHash, $imgPath);
5089
-            $imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash;
5089
+            $imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
5090 5090
         }
5091 5091
 
5092
-        $html = '<img src="' . $imgPath . '">';
5092
+        $html = '<img src="'.$imgPath.'">';
5093 5093
 
5094 5094
         return $html;
5095 5095
     }
@@ -5110,12 +5110,12 @@  discard block
 block discarded – undo
5110 5110
 
5111 5111
         foreach ($attempts as $attempt) {
5112 5112
             if (api_get_user_id() == $attempt['exe_user_id']) {
5113
-                if ($attempt['exe_weighting'] != 0 ) {
5114
-                    $my_exercise_result_array[]= $attempt['exe_result']/$attempt['exe_weighting'];
5113
+                if ($attempt['exe_weighting'] != 0) {
5114
+                    $my_exercise_result_array[] = $attempt['exe_result'] / $attempt['exe_weighting'];
5115 5115
                 }
5116 5116
             } else {
5117
-                if ($attempt['exe_weighting'] != 0 ) {
5118
-                    $exercise_result[]=  $attempt['exe_result']/$attempt['exe_weighting'];
5117
+                if ($attempt['exe_weighting'] != 0) {
5118
+                    $exercise_result[] = $attempt['exe_result'] / $attempt['exe_weighting'];
5119 5119
                 }
5120 5120
             }
5121 5121
         }
@@ -5124,27 +5124,27 @@  discard block
 block discarded – undo
5124 5124
         rsort($my_exercise_result_array);
5125 5125
         $my_exercise_result = 0;
5126 5126
         if (isset($my_exercise_result_array[0])) {
5127
-            $my_exercise_result = $my_exercise_result_array[0] *100;
5127
+            $my_exercise_result = $my_exercise_result_array[0] * 100;
5128 5128
         }
5129 5129
 
5130 5130
         $max     = 100;
5131
-        $pieces  = 5 ;
5131
+        $pieces  = 5;
5132 5132
         $part    = round($max / $pieces);
5133 5133
         $x_axis = array();
5134 5134
         $final_array = array();
5135 5135
         $my_final_array = array();
5136 5136
 
5137
-        for ($i=1; $i <=$pieces; $i++) {
5137
+        for ($i = 1; $i <= $pieces; $i++) {
5138 5138
             $sum = 1;
5139 5139
             if ($i == 1) {
5140 5140
                 $sum = 0;
5141 5141
             }
5142
-            $min = ($i-1)*$part + $sum;
5143
-            $max = ($i)*$part;
5144
-            $x_axis[]= $min." - ".$max;
5142
+            $min = ($i - 1) * $part + $sum;
5143
+            $max = ($i) * $part;
5144
+            $x_axis[] = $min." - ".$max;
5145 5145
             $count = 0;
5146
-            foreach($exercise_result as $result) {
5147
-                $percentage = $result*100;
5146
+            foreach ($exercise_result as $result) {
5147
+                $percentage = $result * 100;
5148 5148
                 //echo $percentage.' - '.$min.' - '.$max."<br />";
5149 5149
                 if ($percentage >= $min && $percentage <= $max) {
5150 5150
                     //echo ' is > ';
@@ -5152,7 +5152,7 @@  discard block
 block discarded – undo
5152 5152
                 }
5153 5153
             }
5154 5154
             //echo '<br />';
5155
-            $final_array[]= $count;
5155
+            $final_array[] = $count;
5156 5156
 
5157 5157
             if ($my_exercise_result >= $min && $my_exercise_result <= $max) {
5158 5158
                 $my_final_array[] = 1;
@@ -5162,9 +5162,9 @@  discard block
 block discarded – undo
5162 5162
         }
5163 5163
 
5164 5164
         //Fix to remove the data of the user with my data
5165
-        for($i = 0; $i<=count($my_final_array); $i++) {
5165
+        for ($i = 0; $i <= count($my_final_array); $i++) {
5166 5166
             if (!empty($my_final_array[$i])) {
5167
-                $my_final_array[$i] =  $final_array[$i] + 1; //Add my result
5167
+                $my_final_array[$i] = $final_array[$i] + 1; //Add my result
5168 5168
                 $final_array[$i] = 0;
5169 5169
             }
5170 5170
         }
@@ -5174,16 +5174,16 @@  discard block
 block discarded – undo
5174 5174
         $dataSet->addPoints($final_array, 'Serie1');
5175 5175
         $dataSet->addPoints($my_final_array, 'Serie2');
5176 5176
         $dataSet->normalize(100, "%");
5177
-        $dataSet->loadPalette(api_get_path(SYS_CODE_PATH) . 'palettes/pchart/default.color', true);
5177
+        $dataSet->loadPalette(api_get_path(SYS_CODE_PATH).'palettes/pchart/default.color', true);
5178 5178
 
5179 5179
         // Cache definition
5180 5180
         $cachePath = api_get_path(SYS_ARCHIVE_PATH);
5181 5181
         $myCache = new pCache(array('CacheFolder' => substr($cachePath, 0, strlen($cachePath) - 1)));
5182 5182
         $chartHash = $myCache->getHash($dataSet);
5183 5183
         if ($myCache->isInCache($chartHash)) {
5184
-            $imgPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash;
5184
+            $imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
5185 5185
             $myCache->saveFromCache($chartHash, $imgPath);
5186
-            $imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash;
5186
+            $imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
5187 5187
         } else {
5188 5188
             /* Create the pChart object */
5189 5189
             $widthSize = 80;
@@ -5199,7 +5199,7 @@  discard block
 block discarded – undo
5199 5199
             $myPicture->drawRectangle(0, 0, $widthSize - 1, $heightSize - 1, array('R' => 0, 'G' => 0, 'B' => 0));
5200 5200
 
5201 5201
             /* Set the default font */
5202
-            $myPicture->setFontProperties(array('FontName' => api_get_path(SYS_FONTS_PATH) . 'opensans/OpenSans-Regular.ttf', 'FontSize' => $fontSize));
5202
+            $myPicture->setFontProperties(array('FontName' => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf', 'FontSize' => $fontSize));
5203 5203
 
5204 5204
             /* Do not write the chart title */
5205 5205
 
@@ -5263,9 +5263,9 @@  discard block
 block discarded – undo
5263 5263
 
5264 5264
             /* Save and write in cache */
5265 5265
             $myCache->writeToCache($chartHash, $myPicture);
5266
-            $imgPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash;
5266
+            $imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
5267 5267
             $myCache->saveFromCache($chartHash, $imgPath);
5268
-            $imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash;
5268
+            $imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
5269 5269
         }
5270 5270
 
5271 5271
         return $imgPath;
@@ -5285,12 +5285,12 @@  discard block
 block discarded – undo
5285 5285
         }
5286 5286
         foreach ($attempts as $attempt) {
5287 5287
             if (api_get_user_id() == $attempt['exe_user_id']) {
5288
-                if ($attempt['exe_weighting'] != 0 ) {
5289
-                    $my_exercise_result_array[]= $attempt['exe_result']/$attempt['exe_weighting'];
5288
+                if ($attempt['exe_weighting'] != 0) {
5289
+                    $my_exercise_result_array[] = $attempt['exe_result'] / $attempt['exe_weighting'];
5290 5290
                 }
5291 5291
             } else {
5292
-                if ($attempt['exe_weighting'] != 0 ) {
5293
-                    $exercise_result[]=  $attempt['exe_result']/$attempt['exe_weighting'];
5292
+                if ($attempt['exe_weighting'] != 0) {
5293
+                    $exercise_result[] = $attempt['exe_result'] / $attempt['exe_weighting'];
5294 5294
                 }
5295 5295
             }
5296 5296
         }
@@ -5299,32 +5299,32 @@  discard block
 block discarded – undo
5299 5299
         rsort($my_exercise_result_array);
5300 5300
         $my_exercise_result = 0;
5301 5301
         if (isset($my_exercise_result_array[0])) {
5302
-            $my_exercise_result = $my_exercise_result_array[0] *100;
5302
+            $my_exercise_result = $my_exercise_result_array[0] * 100;
5303 5303
         }
5304 5304
 
5305 5305
         $max = 100;
5306
-        $pieces = 5 ;
5306
+        $pieces = 5;
5307 5307
         $part = round($max / $pieces);
5308 5308
         $x_axis = array();
5309 5309
         $final_array = array();
5310 5310
         $my_final_array = array();
5311 5311
 
5312
-        for ($i=1; $i <=$pieces; $i++) {
5312
+        for ($i = 1; $i <= $pieces; $i++) {
5313 5313
             $sum = 1;
5314 5314
             if ($i == 1) {
5315 5315
                 $sum = 0;
5316 5316
             }
5317
-            $min = ($i-1)*$part + $sum;
5318
-            $max = ($i)*$part;
5319
-            $x_axis[]= $min." - ".$max;
5317
+            $min = ($i - 1) * $part + $sum;
5318
+            $max = ($i) * $part;
5319
+            $x_axis[] = $min." - ".$max;
5320 5320
             $count = 0;
5321
-            foreach($exercise_result as $result) {
5322
-                $percentage = $result*100;
5321
+            foreach ($exercise_result as $result) {
5322
+                $percentage = $result * 100;
5323 5323
                 if ($percentage >= $min && $percentage <= $max) {
5324 5324
                     $count++;
5325 5325
                 }
5326 5326
             }
5327
-            $final_array[]= $count;
5327
+            $final_array[] = $count;
5328 5328
 
5329 5329
             if ($my_exercise_result >= $min && $my_exercise_result <= $max) {
5330 5330
                 $my_final_array[] = 1;
@@ -5335,9 +5335,9 @@  discard block
 block discarded – undo
5335 5335
 
5336 5336
         //Fix to remove the data of the user with my data
5337 5337
 
5338
-        for($i = 0; $i<=count($my_final_array); $i++) {
5338
+        for ($i = 0; $i <= count($my_final_array); $i++) {
5339 5339
             if (!empty($my_final_array[$i])) {
5340
-                $my_final_array[$i] =  $final_array[$i] + 1; //Add my result
5340
+                $my_final_array[$i] = $final_array[$i] + 1; //Add my result
5341 5341
                 $final_array[$i] = 0;
5342 5342
             }
5343 5343
         }
@@ -5355,7 +5355,7 @@  discard block
 block discarded – undo
5355 5355
         $dataSet->setXAxisName(get_lang('Score'));
5356 5356
         $dataSet->normalize(100, "%");
5357 5357
 
5358
-        $dataSet->loadPalette(api_get_path(SYS_CODE_PATH) . 'palettes/pchart/default.color', true);
5358
+        $dataSet->loadPalette(api_get_path(SYS_CODE_PATH).'palettes/pchart/default.color', true);
5359 5359
 
5360 5360
         // Cache definition
5361 5361
         $cachePath = api_get_path(SYS_ARCHIVE_PATH);
@@ -5363,9 +5363,9 @@  discard block
 block discarded – undo
5363 5363
         $chartHash = $myCache->getHash($dataSet);
5364 5364
 
5365 5365
         if ($myCache->isInCache($chartHash)) {
5366
-            $imgPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash;
5366
+            $imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
5367 5367
             $myCache->saveFromCache($chartHash, $imgPath);
5368
-            $imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash;
5368
+            $imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
5369 5369
         } else {
5370 5370
             /* Create the pChart object */
5371 5371
             $widthSize = 480;
@@ -5381,7 +5381,7 @@  discard block
 block discarded – undo
5381 5381
             $myPicture->drawRectangle(0, 0, $widthSize - 1, $heightSize - 1, array('R' => 0, 'G' => 0, 'B' => 0));
5382 5382
 
5383 5383
             /* Set the default font */
5384
-            $myPicture->setFontProperties(array('FontName' => api_get_path(SYS_FONTS_PATH) . 'opensans/OpenSans-Regular.ttf', 'FontSize' => 10));
5384
+            $myPicture->setFontProperties(array('FontName' => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf', 'FontSize' => 10));
5385 5385
 
5386 5386
             /* Write the chart title */
5387 5387
             $myPicture->drawText(
@@ -5440,9 +5440,9 @@  discard block
 block discarded – undo
5440 5440
 
5441 5441
             /* Write and save into cache */
5442 5442
             $myCache->writeToCache($chartHash, $myPicture);
5443
-            $imgPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash;
5443
+            $imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
5444 5444
             $myCache->saveFromCache($chartHash, $imgPath);
5445
-            $imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash;
5445
+            $imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
5446 5446
         }
5447 5447
 
5448 5448
         return $imgPath;
@@ -5568,7 +5568,7 @@  discard block
 block discarded – undo
5568 5568
                         $whereSessionParams .= $sessionIdx.',';
5569 5569
                     }
5570 5570
                 }
5571
-                $whereSessionParams = substr($whereSessionParams,0,-1);
5571
+                $whereSessionParams = substr($whereSessionParams, 0, -1);
5572 5572
             }
5573 5573
 
5574 5574
             if (!empty($exerciseId)) {
@@ -5629,7 +5629,7 @@  discard block
 block discarded – undo
5629 5629
                     qq.position = rq.question_order AND
5630 5630
                     ta.question_id = rq.question_id
5631 5631
                 WHERE
5632
-                    te.c_id = $courseIdx ".(empty($whereSessionParams)?'':"AND te.session_id IN ($whereSessionParams)")."
5632
+                    te.c_id = $courseIdx ".(empty($whereSessionParams) ? '' : "AND te.session_id IN ($whereSessionParams)")."
5633 5633
                     AND q.c_id = $courseIdx
5634 5634
                     $where $order $limit";
5635 5635
             $sql_query = vsprintf($sql, $whereParams);
@@ -5677,7 +5677,7 @@  discard block
 block discarded – undo
5677 5677
             // Now fill users data
5678 5678
             $sqlUsers = "SELECT user_id, username, lastname, firstname
5679 5679
                          FROM $tuser
5680
-                         WHERE user_id IN (".implode(',',$userIds).")";
5680
+                         WHERE user_id IN (".implode(',', $userIds).")";
5681 5681
             $resUsers = Database::query($sqlUsers);
5682 5682
             while ($rowUser = Database::fetch_assoc($resUsers)) {
5683 5683
                 $users[$rowUser['user_id']] = $rowUser;
@@ -5738,7 +5738,7 @@  discard block
 block discarded – undo
5738 5738
     	        WHERE
5739 5739
                     track_resource.c_id = $course_id AND
5740 5740
                     track_resource.insert_user_id = user.user_id AND
5741
-                    session_id " .(empty($session_id) ? ' IS NULL ' : " = $session_id ");
5741
+                    session_id ".(empty($session_id) ? ' IS NULL ' : " = $session_id ");
5742 5742
 
5743 5743
     	if (isset($_GET['keyword'])) {
5744 5744
     		$keyword = Database::escape_string(trim($_GET['keyword']));
@@ -5796,7 +5796,7 @@  discard block
 block discarded – undo
5796 5796
                 WHERE
5797 5797
                   track_resource.c_id = $course_id AND
5798 5798
                   track_resource.insert_user_id = user.user_id AND
5799
-                  session_id " .(empty($session_id) ? ' IS NULL ' : " = $session_id ");
5799
+                  session_id ".(empty($session_id) ? ' IS NULL ' : " = $session_id ");
5800 5800
 
5801 5801
     	if (isset($_GET['keyword'])) {
5802 5802
     		$keyword = Database::escape_string(trim($_GET['keyword']));
@@ -6090,7 +6090,7 @@  discard block
 block discarded – undo
6090 6090
     public static function display_additional_profile_fields()
6091 6091
     {
6092 6092
     	// getting all the extra profile fields that are defined by the platform administrator
6093
-    	$extra_fields = UserManager :: get_extra_fields(0,50,5,'ASC');
6093
+    	$extra_fields = UserManager :: get_extra_fields(0, 50, 5, 'ASC');
6094 6094
 
6095 6095
     	// creating the form
6096 6096
     	$return = '<form action="courseLog.php" method="get" name="additional_profile_field_form" id="additional_profile_field_form">';
@@ -6102,8 +6102,8 @@  discard block
 block discarded – undo
6102 6102
     	$extra_fields_to_show = 0;
6103 6103
     	foreach ($extra_fields as $key=>$field) {
6104 6104
     		// show only extra fields that are visible + and can be filtered, added by J.Montoya
6105
-    		if ($field[6]==1 && $field[8] == 1) {
6106
-    			if (isset($_GET['additional_profile_field']) && $field[0] == $_GET['additional_profile_field'] ) {
6105
+    		if ($field[6] == 1 && $field[8] == 1) {
6106
+    			if (isset($_GET['additional_profile_field']) && $field[0] == $_GET['additional_profile_field']) {
6107 6107
     				$selected = 'selected="selected"';
6108 6108
     			} else {
6109 6109
     				$selected = '';
@@ -6115,8 +6115,8 @@  discard block
 block discarded – undo
6115 6115
     	$return .= '</select>';
6116 6116
 
6117 6117
     	// the form elements for the $_GET parameters (because the form is passed through GET
6118
-    	foreach ($_GET as $key=>$value){
6119
-    		if ($key <> 'additional_profile_field')    {
6118
+    	foreach ($_GET as $key=>$value) {
6119
+    		if ($key <> 'additional_profile_field') {
6120 6120
     			$return .= '<input type="hidden" name="'.Security::remove_XSS($key).'" value="'.Security::remove_XSS($value).'" />';
6121 6121
     		}
6122 6122
     	}
@@ -6153,21 +6153,21 @@  discard block
 block discarded – undo
6153 6153
     	$result_extra_field = UserManager::get_extra_field_information($field_id);
6154 6154
 
6155 6155
     	if (!empty($users)) {
6156
-    		if ($result_extra_field['field_type'] == UserManager::USER_FIELD_TYPE_TAG ) {
6157
-    			foreach($users as $user_id) {
6156
+    		if ($result_extra_field['field_type'] == UserManager::USER_FIELD_TYPE_TAG) {
6157
+    			foreach ($users as $user_id) {
6158 6158
     				$user_result = UserManager::get_user_tags($user_id, $field_id);
6159 6159
     				$tag_list = array();
6160
-    				foreach($user_result as $item) {
6160
+    				foreach ($user_result as $item) {
6161 6161
     					$tag_list[] = $item['tag'];
6162 6162
     				}
6163
-    				$return[$user_id][] = implode(', ',$tag_list);
6163
+    				$return[$user_id][] = implode(', ', $tag_list);
6164 6164
     			}
6165 6165
     		} else {
6166 6166
     			$new_user_array = array();
6167 6167
     			foreach ($users as $user_id) {
6168
-    				$new_user_array[]= "'".$user_id."'";
6168
+    				$new_user_array[] = "'".$user_id."'";
6169 6169
     			}
6170
-    			$users = implode(',',$new_user_array);
6170
+    			$users = implode(',', $new_user_array);
6171 6171
                 $extraFieldType = EntityExtraField::USER_FIELD_TYPE;
6172 6172
     			// Selecting only the necessary information NOT ALL the user list
6173 6173
     			$sql = "SELECT user.user_id, v.value
@@ -6182,7 +6182,7 @@  discard block
 block discarded – undo
6182 6182
                             user.user_id IN ($users)";
6183 6183
 
6184 6184
     			$result = Database::query($sql);
6185
-    			while($row = Database::fetch_array($result)) {
6185
+    			while ($row = Database::fetch_array($result)) {
6186 6186
     				// get option value for field type double select by id
6187 6187
     				if (!empty($row['value'])) {
6188 6188
     					if ($result_extra_field['field_type'] ==
@@ -6221,7 +6221,7 @@  discard block
 block discarded – undo
6221 6221
 
6222 6222
     public function sort_users_desc($a, $b)
6223 6223
     {
6224
-    	return strcmp( trim(api_strtolower($b[$_SESSION['tracking_column']])), trim(api_strtolower($a[$_SESSION['tracking_column']])));
6224
+    	return strcmp(trim(api_strtolower($b[$_SESSION['tracking_column']])), trim(api_strtolower($a[$_SESSION['tracking_column']])));
6225 6225
     }
6226 6226
 
6227 6227
     /**
@@ -6256,7 +6256,7 @@  discard block
 block discarded – undo
6256 6256
     	// get all users data from a course for sortable with limit
6257 6257
     	if (is_array($user_ids)) {
6258 6258
     		$user_ids = array_map('intval', $user_ids);
6259
-    		$condition_user = " WHERE user.user_id IN (".implode(',',$user_ids).") ";
6259
+    		$condition_user = " WHERE user.user_id IN (".implode(',', $user_ids).") ";
6260 6260
     	} else {
6261 6261
     		$user_ids = intval($user_ids);
6262 6262
     		$condition_user = " WHERE user.user_id = $user_ids ";
@@ -6264,7 +6264,7 @@  discard block
 block discarded – undo
6264 6264
 
6265 6265
     	if (!empty($_GET['user_keyword'])) {
6266 6266
     		$keyword = trim(Database::escape_string($_GET['user_keyword']));
6267
-    		$condition_user .=  " AND (
6267
+    		$condition_user .= " AND (
6268 6268
                 user.firstname LIKE '%".$keyword."%' OR
6269 6269
                 user.lastname LIKE '%".$keyword."%'  OR
6270 6270
                 user.username LIKE '%".$keyword."%'  OR
@@ -6282,7 +6282,7 @@  discard block
 block discarded – undo
6282 6282
         $invitedUsersCondition = '';
6283 6283
 
6284 6284
         if (!$includeInvitedUsers) {
6285
-            $invitedUsersCondition = " AND user.status != " . INVITEE;
6285
+            $invitedUsersCondition = " AND user.status != ".INVITEE;
6286 6286
         }
6287 6287
 
6288 6288
     	$sql = "SELECT  user.user_id as user_id,
@@ -6293,7 +6293,7 @@  discard block
 block discarded – undo
6293 6293
                 FROM $tbl_user as user $url_table
6294 6294
     	        $condition_user $url_condition $invitedUsersCondition";
6295 6295
 
6296
-    	if (!in_array($direction, array('ASC','DESC'))) {
6296
+    	if (!in_array($direction, array('ASC', 'DESC'))) {
6297 6297
     		$direction = 'ASC';
6298 6298
     	}
6299 6299
 
@@ -6430,7 +6430,7 @@  discard block
 block discarded – undo
6430 6430
     		}
6431 6431
 
6432 6432
             if (empty($session_id)) {
6433
-                $user['survey'] = (isset($survey_user_list[$user['user_id']]) ? $survey_user_list[$user['user_id']] : 0) .' / '.$total_surveys;
6433
+                $user['survey'] = (isset($survey_user_list[$user['user_id']]) ? $survey_user_list[$user['user_id']] : 0).' / '.$total_surveys;
6434 6434
             }
6435 6435
 
6436 6436
     		$user['link'] = '<center>
@@ -6442,34 +6442,34 @@  discard block
 block discarded – undo
6442 6442
     		// store columns in array $users
6443 6443
     		$is_western_name_order = api_is_western_name_order();
6444 6444
             $user_row = array();
6445
-            $user_row[]= $user['official_code']; //0
6445
+            $user_row[] = $user['official_code']; //0
6446 6446
             if ($is_western_name_order) {
6447
-                $user_row[]= $user['firstname'];
6448
-                $user_row[]= $user['lastname'];
6447
+                $user_row[] = $user['firstname'];
6448
+                $user_row[] = $user['lastname'];
6449 6449
             } else {
6450
-                $user_row[]= $user['lastname'];
6451
-                $user_row[]= $user['firstname'];
6450
+                $user_row[] = $user['lastname'];
6451
+                $user_row[] = $user['firstname'];
6452 6452
             }
6453
-            $user_row[]= $user['username'];
6454
-            $user_row[]= $user['time'];
6455
-            $user_row[]= $user['average_progress'];
6456
-            $user_row[]= $user['exercise_progress'];
6457
-            $user_row[]= $user['exercise_average_best_attempt'];
6458
-            $user_row[]= $user['student_score'];
6459
-            $user_row[]= $user['count_assignments'];
6460
-            $user_row[]= $user['count_messages'];
6453
+            $user_row[] = $user['username'];
6454
+            $user_row[] = $user['time'];
6455
+            $user_row[] = $user['average_progress'];
6456
+            $user_row[] = $user['exercise_progress'];
6457
+            $user_row[] = $user['exercise_average_best_attempt'];
6458
+            $user_row[] = $user['student_score'];
6459
+            $user_row[] = $user['count_assignments'];
6460
+            $user_row[] = $user['count_messages'];
6461 6461
 
6462 6462
             if (empty($session_id)) {
6463
-                $user_row[]= $user['survey'];
6463
+                $user_row[] = $user['survey'];
6464 6464
             }
6465 6465
 
6466
-            $user_row[]= $user['first_connection'];
6467
-            $user_row[]= $user['last_connection'];
6466
+            $user_row[] = $user['first_connection'];
6467
+            $user_row[] = $user['last_connection'];
6468 6468
             if (isset($_GET['additional_profile_field']) && is_numeric($_GET['additional_profile_field'])) {
6469
-                $user_row[]= $user['additional'];
6469
+                $user_row[] = $user['additional'];
6470 6470
             }
6471 6471
 
6472
-            $user_row[]= $user['link'];
6472
+            $user_row[] = $user['link'];
6473 6473
 
6474 6474
             $users[] = $user_row;
6475 6475
 
@@ -6514,8 +6514,8 @@  discard block
 block discarded – undo
6514 6514
 
6515 6515
     	$track_access_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
6516 6516
     	$tempView = $view;
6517
-    	if(substr($view,0,1) == '1') {
6518
-    		$new_view = substr_replace($view,'0',0,1);
6517
+    	if (substr($view, 0, 1) == '1') {
6518
+    		$new_view = substr_replace($view, '0', 0, 1);
6519 6519
     		echo "
6520 6520
                 <tr>
6521 6521
                     <td valign='top'>
@@ -6548,9 +6548,9 @@  discard block
 block discarded – undo
6548 6548
                 </tr>";
6549 6549
     		$total = 0;
6550 6550
     		if (is_array($results)) {
6551
-    			for($j = 0 ; $j < count($results) ; $j++) {
6551
+    			for ($j = 0; $j < count($results); $j++) {
6552 6552
     				echo "<tr>";
6553
-    				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>";
6553
+    				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>";
6554 6554
     				echo "<td valign='top' align='right' class='content'>".$results[$j][1]."</td>";
6555 6555
     				echo"</tr>";
6556 6556
     				$total = $total + $results[$j][1];
@@ -6567,7 +6567,7 @@  discard block
 block discarded – undo
6567 6567
     		echo "</table>";
6568 6568
     		echo "</td></tr>";
6569 6569
     	} else {
6570
-    		$new_view = substr_replace($view,'1',0,1);
6570
+    		$new_view = substr_replace($view, '1', 0, 1);
6571 6571
     		echo "
6572 6572
                 <tr>
6573 6573
                     <td valign='top'>
@@ -6590,8 +6590,8 @@  discard block
 block discarded – undo
6590 6590
     {
6591 6591
     	global $TBL_TRACK_HOTPOTATOES, $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $dateTimeFormatLong;
6592 6592
         $courseId = api_get_course_int_id($courseCode);
6593
-    	if(substr($view,1,1) == '1') {
6594
-    		$new_view = substr_replace($view,'0',1,1);
6593
+    	if (substr($view, 1, 1) == '1') {
6594
+    		$new_view = substr_replace($view, '0', 1, 1);
6595 6595
     		echo "<tr>
6596 6596
                     <td valign='top'>
6597 6597
                         <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>]
@@ -6633,7 +6633,7 @@  discard block
 block discarded – undo
6633 6633
                 </tr>";
6634 6634
 
6635 6635
     		if (is_array($results)) {
6636
-    			for($i = 0; $i < sizeof($results); $i++) {
6636
+    			for ($i = 0; $i < sizeof($results); $i++) {
6637 6637
     				$display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get());
6638 6638
     				echo "<tr>\n";
6639 6639
     				echo "<td class='content'>".$results[$i][0]."</td>\n";
@@ -6648,8 +6648,8 @@  discard block
 block discarded – undo
6648 6648
 
6649 6649
     		// The Result of Tests
6650 6650
     		if (is_array($hpresults)) {
6651
-    			for($i = 0; $i < sizeof($hpresults); $i++) {
6652
-    				$title = GetQuizName($hpresults[$i][0],'');
6651
+    			for ($i = 0; $i < sizeof($hpresults); $i++) {
6652
+    				$title = GetQuizName($hpresults[$i][0], '');
6653 6653
     				if ($title == '')
6654 6654
     				$title = basename($hpresults[$i][0]);
6655 6655
     				$display_date = api_convert_and_format_date($hpresults[$i][3], null, date_default_timezone_get());
@@ -6675,7 +6675,7 @@  discard block
 block discarded – undo
6675 6675
     		echo "</table>";
6676 6676
     		echo "</td>\n</tr>\n";
6677 6677
     	} else {
6678
-    		$new_view = substr_replace($view,'1',1,1);
6678
+    		$new_view = substr_replace($view, '1', 1, 1);
6679 6679
     		echo "
6680 6680
                 <tr>
6681 6681
                     <td valign='top'>
@@ -6694,8 +6694,8 @@  discard block
 block discarded – undo
6694 6694
     	global $TABLETRACK_UPLOADS, $TABLECOURSE_WORK;
6695 6695
         $_course = api_get_course_info_by_id($course_id);
6696 6696
 
6697
-    	if (substr($view,2,1) == '1') {
6698
-    		$new_view = substr_replace($view,'0',2,1);
6697
+    	if (substr($view, 2, 1) == '1') {
6698
+    		$new_view = substr_replace($view, '0', 2, 1);
6699 6699
     		echo "<tr>
6700 6700
                     <td valign='top'>
6701 6701
                     <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>]
@@ -6709,7 +6709,7 @@  discard block
 block discarded – undo
6709 6709
                         AND u.c_id = '".intval($course_id)."'
6710 6710
                     ORDER BY u.upload_date DESC";
6711 6711
     		echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6712
-    		$results = StatsUtils::getManyResultsXCol($sql,4);
6712
+    		$results = StatsUtils::getManyResultsXCol($sql, 4);
6713 6713
     		echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
6714 6714
     		echo "<tr>
6715 6715
                     <td class='secLine' width='40%'>
@@ -6723,7 +6723,7 @@  discard block
 block discarded – undo
6723 6723
                     </td>
6724 6724
                 </tr>";
6725 6725
     		if (is_array($results)) {
6726
-    			for($j = 0 ; $j < count($results) ; $j++) {
6726
+    			for ($j = 0; $j < count($results); $j++) {
6727 6727
     				$pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3];
6728 6728
     				$beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get());
6729 6729
     				echo "<tr>";
@@ -6742,7 +6742,7 @@  discard block
 block discarded – undo
6742 6742
     		echo "</table>";
6743 6743
     		echo "</td></tr>";
6744 6744
     	} else {
6745
-    		$new_view = substr_replace($view,'1',2,1);
6745
+    		$new_view = substr_replace($view, '1', 2, 1);
6746 6746
     		echo "
6747 6747
                 <tr>
6748 6748
                     <td valign='top'>
@@ -6761,8 +6761,8 @@  discard block
 block discarded – undo
6761 6761
     {
6762 6762
     	global $TABLETRACK_LINKS, $TABLECOURSE_LINKS;
6763 6763
         $courseId = api_get_course_int_id($courseCode);
6764
-    	if (substr($view,3,1) == '1') {
6765
-    		$new_view = substr_replace($view,'0',3,1);
6764
+    	if (substr($view, 3, 1) == '1') {
6765
+    		$new_view = substr_replace($view, '0', 3, 1);
6766 6766
     		echo "
6767 6767
                 <tr>
6768 6768
                         <td valign='top'>
@@ -6786,7 +6786,7 @@  discard block
 block discarded – undo
6786 6786
                     </td>
6787 6787
                 </tr>";
6788 6788
     		if (is_array($results)) {
6789
-    			for($j = 0 ; $j < count($results) ; $j++) {
6789
+    			for ($j = 0; $j < count($results); $j++) {
6790 6790
     				echo "<tr>";
6791 6791
     				echo "<td class='content'><a href='".$results[$j][1]."'>".$results[$j][0]."</a></td>";
6792 6792
     				echo"</tr>";
@@ -6799,7 +6799,7 @@  discard block
 block discarded – undo
6799 6799
     		echo "</table>";
6800 6800
     		echo "</td></tr>";
6801 6801
     	} else {
6802
-    		$new_view = substr_replace($view,'1',3,1);
6802
+    		$new_view = substr_replace($view, '1', 3, 1);
6803 6803
     		echo "
6804 6804
                 <tr>
6805 6805
                     <td valign='top'>
@@ -6826,8 +6826,8 @@  discard block
 block discarded – undo
6826 6826
     	$session_id = intval($session_id);
6827 6827
 
6828 6828
     	$downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
6829
-    	if(substr($view,4,1) == '1') {
6830
-    		$new_view = substr_replace($view,'0',4,1);
6829
+    	if (substr($view, 4, 1) == '1') {
6830
+    		$new_view = substr_replace($view, '0', 4, 1);
6831 6831
     		echo "
6832 6832
                 <tr>
6833 6833
                     <td valign='top'>
@@ -6853,7 +6853,7 @@  discard block
 block discarded – undo
6853 6853
                     </td>
6854 6854
                 </tr>";
6855 6855
     		if (is_array($results)) {
6856
-    			for($j = 0 ; $j < count($results) ; $j++) {
6856
+    			for ($j = 0; $j < count($results); $j++) {
6857 6857
     				echo "<tr>";
6858 6858
     				echo "<td class='content'>".$results[$j]."</td>";
6859 6859
     				echo"</tr>";
@@ -6866,7 +6866,7 @@  discard block
 block discarded – undo
6866 6866
     		echo "</table>";
6867 6867
     		echo "</td></tr>";
6868 6868
     	} else {
6869
-    		$new_view = substr_replace($view,'1',4,1);
6869
+    		$new_view = substr_replace($view, '1', 4, 1);
6870 6870
     		echo "
6871 6871
                 <tr>
6872 6872
                     <td valign='top'>
@@ -6900,11 +6900,11 @@  discard block
 block discarded – undo
6900 6900
                    ORDER BY login_date DESC LIMIT 1";
6901 6901
         $ip = '';
6902 6902
         $res_ip = Database::query($sql_ip);
6903
-        if ($res_ip !== false && Database::num_rows($res_ip)>0) {
6903
+        if ($res_ip !== false && Database::num_rows($res_ip) > 0) {
6904 6904
             $row_ip = Database::fetch_row($res_ip);
6905 6905
             if ($return_as_link) {
6906 6906
                 $ip = Display::url(
6907
-                    (empty($body_replace)?$row_ip[1]:$body_replace), 'http://www.whatsmyip.org/ip-geo-location/?ip='.$row_ip[1],
6907
+                    (empty($body_replace) ? $row_ip[1] : $body_replace), 'http://www.whatsmyip.org/ip-geo-location/?ip='.$row_ip[1],
6908 6908
                     array('title'=>get_lang('TraceIP'), 'target'=>'_blank')
6909 6909
                 );
6910 6910
             } else {
@@ -6940,9 +6940,9 @@  discard block
 block discarded – undo
6940 6940
     	$course_id  = intval($course_id);
6941 6941
 
6942 6942
     	$tempView = $view;
6943
-    	if (substr($view,0,1) == '1') {
6944
-    		$new_view = substr_replace($view,'0',0,1);
6945
-    		$title[1]= get_lang('LoginsAndAccessTools').get_lang('LoginsDetails');
6943
+    	if (substr($view, 0, 1) == '1') {
6944
+    		$new_view = substr_replace($view, '0', 0, 1);
6945
+    		$title[1] = get_lang('LoginsAndAccessTools').get_lang('LoginsDetails');
6946 6946
     		$sql = "SELECT UNIX_TIMESTAMP(access_date), count(access_date)
6947 6947
                     FROM $track_access_table
6948 6948
                     WHERE access_user_id = $user_id
@@ -6952,20 +6952,20 @@  discard block
 block discarded – undo
6952 6952
                     ORDER BY YEAR(access_date),MONTH(access_date) ASC";
6953 6953
     		//$results = getManyResults2Col($sql);
6954 6954
     		$results = getManyResults3Col($sql);
6955
-    		$title_line= get_lang('LoginsTitleMonthColumn').';'.get_lang('LoginsTitleCountColumn')."\n";
6956
-    		$line='';
6955
+    		$title_line = get_lang('LoginsTitleMonthColumn').';'.get_lang('LoginsTitleCountColumn')."\n";
6956
+    		$line = '';
6957 6957
     		$total = 0;
6958 6958
     		if (is_array($results)) {
6959
-    			for($j = 0 ; $j < count($results) ; $j++) {
6959
+    			for ($j = 0; $j < count($results); $j++) {
6960 6960
     				$line .= $results[$j][0].';'.$results[$j][1]."\n";
6961 6961
     				$total = $total + $results[$j][1];
6962 6962
     			}
6963 6963
     			$line .= get_lang('Total').";".$total."\n";
6964 6964
     		} else {
6965
-    			$line= get_lang('NoResult')."</center></td>";
6965
+    			$line = get_lang('NoResult')."</center></td>";
6966 6966
     		}
6967 6967
     	} else {
6968
-    		$new_view = substr_replace($view,'1',0,1);
6968
+    		$new_view = substr_replace($view, '1', 0, 1);
6969 6969
     	}
6970 6970
     	return array($title_line, $line);
6971 6971
     }
@@ -6983,8 +6983,8 @@  discard block
 block discarded – undo
6983 6983
     	global $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $TABLETRACK_HOTPOTATOES, $dateTimeFormatLong;
6984 6984
         $courseId = api_get_course_int_id($courseCode);
6985 6985
         $userId = intval($userId);
6986
-    	if (substr($view,1,1) == '1') {
6987
-    		$new_view = substr_replace($view,'0',1,1);
6986
+    	if (substr($view, 1, 1) == '1') {
6987
+    		$new_view = substr_replace($view, '0', 1, 1);
6988 6988
     		$title[1] = get_lang('ExercicesDetails');
6989 6989
     		$line = '';
6990 6990
     		$sql = "SELECT ce.title, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
@@ -7008,7 +7008,7 @@  discard block
 block discarded – undo
7008 7008
     		$title_line = get_lang('ExercicesTitleExerciceColumn').";".get_lang('Date').';'.get_lang('ExercicesTitleScoreColumn')."\n";
7009 7009
 
7010 7010
     		if (is_array($results)) {
7011
-    			for($i = 0; $i < sizeof($results); $i++)
7011
+    			for ($i = 0; $i < sizeof($results); $i++)
7012 7012
     			{
7013 7013
     				$display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get());
7014 7014
     				$line .= $results[$i][0].";".$display_date.";".$results[$i][1]." / ".$results[$i][2]."\n";
@@ -7020,8 +7020,8 @@  discard block
 block discarded – undo
7020 7020
 
7021 7021
     		// The Result of Tests
7022 7022
     		if (is_array($hpresults)) {
7023
-    			for($i = 0; $i < sizeof($hpresults); $i++) {
7024
-    				$title = GetQuizName($hpresults[$i][0],'');
7023
+    			for ($i = 0; $i < sizeof($hpresults); $i++) {
7024
+    				$title = GetQuizName($hpresults[$i][0], '');
7025 7025
 
7026 7026
     				if ($title == '')
7027 7027
     				$title = basename($hpresults[$i][0]);
@@ -7035,10 +7035,10 @@  discard block
 block discarded – undo
7035 7035
     		}
7036 7036
 
7037 7037
     		if ($NoTestRes == 1 && $NoHPTestRes == 1) {
7038
-    			$line=get_lang('NoResult');
7038
+    			$line = get_lang('NoResult');
7039 7039
     		}
7040 7040
     	} else {
7041
-    		$new_view = substr_replace($view,'1',1,1);
7041
+    		$new_view = substr_replace($view, '1', 1, 1);
7042 7042
     	}
7043 7043
     	return array($title_line, $line);
7044 7044
     }
@@ -7054,7 +7054,7 @@  discard block
 block discarded – undo
7054 7054
         $user_id = intval($user_id);
7055 7055
         $course_id = intval($course_id);
7056 7056
 
7057
-    	if (substr($view,2,1) == '1') {
7057
+    	if (substr($view, 2, 1) == '1') {
7058 7058
     		$sql = "SELECT u.upload_date, w.title, w.author, w.url
7059 7059
                     FROM $TABLETRACK_UPLOADS u , $TABLECOURSE_WORK w
7060 7060
                     WHERE
@@ -7062,21 +7062,21 @@  discard block
 block discarded – undo
7062 7062
                         u.upload_user_id = '$user_id' AND
7063 7063
                         u.c_id = '$course_id'
7064 7064
                     ORDER BY u.upload_date DESC";
7065
-    		$results = StatsUtils::getManyResultsXCol($sql,4);
7065
+    		$results = StatsUtils::getManyResultsXCol($sql, 4);
7066 7066
 
7067
-    		$title[1]=get_lang('WorksDetails');
7068
-    		$line='';
7069
-    		$title_line=get_lang('WorkTitle').";".get_lang('WorkAuthors').";".get_lang('Date')."\n";
7067
+    		$title[1] = get_lang('WorksDetails');
7068
+    		$line = '';
7069
+    		$title_line = get_lang('WorkTitle').";".get_lang('WorkAuthors').";".get_lang('Date')."\n";
7070 7070
 
7071 7071
     		if (is_array($results)) {
7072
-    			for($j = 0 ; $j < count($results) ; $j++) {
7072
+    			for ($j = 0; $j < count($results); $j++) {
7073 7073
     				$pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3];
7074 7074
     				$beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get());
7075 7075
     				$line .= $results[$j][1].";".$results[$j][2].";".$beautifulDate."\n";
7076 7076
     			}
7077 7077
 
7078 7078
     		} else {
7079
-    			$line= get_lang('NoResult');
7079
+    			$line = get_lang('NoResult');
7080 7080
     		}
7081 7081
     	}
7082 7082
     	return array($title_line, $line);
@@ -7092,9 +7092,9 @@  discard block
 block discarded – undo
7092 7092
         $courseId = api_get_course_int_id($courseCode);
7093 7093
         $userId = intval($userId);
7094 7094
         $line = null;
7095
-    	if (substr($view,3,1) == '1') {
7096
-    		$new_view = substr_replace($view,'0',3,1);
7097
-    		$title[1]=get_lang('LinksDetails');
7095
+    	if (substr($view, 3, 1) == '1') {
7096
+    		$new_view = substr_replace($view, '0', 3, 1);
7097
+    		$title[1] = get_lang('LinksDetails');
7098 7098
     		$sql = "SELECT cl.title, cl.url
7099 7099
                         FROM $TABLETRACK_LINKS AS sl, $TABLECOURSE_LINKS AS cl
7100 7100
                         WHERE sl.links_link_id = cl.id
@@ -7102,16 +7102,16 @@  discard block
 block discarded – undo
7102 7102
                             AND sl.links_user_id = $userId
7103 7103
                         GROUP BY cl.title, cl.url";
7104 7104
     		$results = StatsUtils::getManyResults2Col($sql);
7105
-    		$title_line= get_lang('LinksTitleLinkColumn')."\n";
7105
+    		$title_line = get_lang('LinksTitleLinkColumn')."\n";
7106 7106
     		if (is_array($results)) {
7107
-    			for ($j = 0 ; $j < count($results) ; $j++) {
7107
+    			for ($j = 0; $j < count($results); $j++) {
7108 7108
     				$line .= $results[$j][0]."\n";
7109 7109
     			}
7110 7110
     		} else {
7111
-    			$line=get_lang('NoResult');
7111
+    			$line = get_lang('NoResult');
7112 7112
     		}
7113 7113
     	} else {
7114
-    		$new_view = substr_replace($view,'1',3,1);
7114
+    		$new_view = substr_replace($view, '1', 3, 1);
7115 7115
     	}
7116 7116
     	return array($title_line, $line);
7117 7117
     }
@@ -7133,9 +7133,9 @@  discard block
 block discarded – undo
7133 7133
 
7134 7134
     	$downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
7135 7135
 
7136
-    	if (substr($view,4,1) == '1') {
7137
-    		$new_view = substr_replace($view,'0',4,1);
7138
-    		$title[1]= get_lang('DocumentsDetails');
7136
+    	if (substr($view, 4, 1) == '1') {
7137
+    		$new_view = substr_replace($view, '0', 4, 1);
7138
+    		$title[1] = get_lang('DocumentsDetails');
7139 7139
 
7140 7140
     		$sql = "SELECT down_doc_path
7141 7141
                         FROM $downloads_table
@@ -7148,14 +7148,14 @@  discard block
 block discarded – undo
7148 7148
     		$title_line = get_lang('DocumentsTitleDocumentColumn')."\n";
7149 7149
             $line = null;
7150 7150
     		if (is_array($results)) {
7151
-    			for ($j = 0 ; $j < count($results) ; $j++) {
7151
+    			for ($j = 0; $j < count($results); $j++) {
7152 7152
     				$line .= $results[$j]."\n";
7153 7153
     			}
7154 7154
     		} else {
7155 7155
     			$line = get_lang('NoResult');
7156 7156
     		}
7157 7157
     	} else {
7158
-    		$new_view = substr_replace($view,'1',4,1);
7158
+    		$new_view = substr_replace($view, '1', 4, 1);
7159 7159
     	}
7160 7160
     	return array($title_line, $line);
7161 7161
     }
Please login to merge, or discard this patch.
main/inc/lib/urlmanager.lib.php 4 patches
Doc Comments   +16 added lines, -14 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
     * @param	string	$url The URL of the site
19 19
     * @param	string  $description The description of the site
20 20
     * @param	int		$active is active or not
21
-    * @return boolean if success
21
+    * @return Doctrine\DBAL\Driver\Statement|null if success
22 22
     */
23 23
     public static function add($url, $description, $active)
24 24
     {
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
     * @param	string 	$url
44 44
     * @param	string  $description The description of the site
45 45
     * @param	int		$active is active or not
46
-    * @return 	boolean if success
46
+    * @return 	Doctrine\DBAL\Driver\Statement|null if success
47 47
     */
48 48
     public static function update($url_id, $url, $description, $active)
49 49
     {
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
     * @author Julio Montoya
68 68
     * @param int $id url id
69 69
      *
70
-    * @return boolean true if success
70
+    * @return Doctrine\DBAL\Driver\Statement|null true if success
71 71
     * */
72 72
     public static function delete($id)
73 73
     {
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
     * @author Julio Montoya
367 367
     * @param int user id
368 368
     * @param int url id
369
-    * @return boolean true if success
369
+    * @return integer true if success
370 370
     * */
371 371
     public static function relation_url_user_exist($user_id, $url_id)
372 372
     {
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
     * @author Julio Montoya
385 385
     * @param int $courseId
386 386
     * @param int $urlId
387
-    * @return boolean true if success
387
+    * @return integer true if success
388 388
     * */
389 389
     public static function relation_url_course_exist($courseId, $urlId)
390 390
     {
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
      * @author Julio Montoya
406 406
      * @param int $userGroupId
407 407
      * @param int $urlId
408
-     * @return boolean true if success
408
+     * @return integer true if success
409 409
      * */
410 410
     public static function relationUrlUsergroupExist($userGroupId, $urlId)
411 411
     {
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
     * @author Julio Montoya
425 425
     * @param int user id
426 426
     * @param int url id
427
-    * @return boolean true if success
427
+    * @return integer true if success
428 428
     * */
429 429
     public static function relation_url_session_exist($session_id, $url_id)
430 430
     {
@@ -545,6 +545,8 @@  discard block
 block discarded – undo
545 545
      * @author Julio Montoya
546 546
      * @param  array of course ids
547 547
      * @param  array of url_ids
548
+     * @param integer[] $courseCategoryList
549
+     * @param integer[] $urlList
548 550
      * @return array
549 551
      **/
550 552
     public static function addCourseCategoryListToUrl($courseCategoryList, $urlList)
@@ -575,7 +577,7 @@  discard block
 block discarded – undo
575 577
      * @author Julio Montoya
576 578
      * @param int $categoryCourseId
577 579
      * @param int $urlId
578
-     * @return boolean true if success
580
+     * @return integer true if success
579 581
      * */
580 582
     public static function relationUrlCourseCategoryExist($categoryCourseId, $urlId)
581 583
     {
@@ -592,7 +594,7 @@  discard block
 block discarded – undo
592 594
     /**
593 595
      * @param int $userGroupId
594 596
      * @param int $urlId
595
-     * @return int
597
+     * @return string
596 598
      */
597 599
     public static function addUserGroupToUrl($userGroupId, $urlId)
598 600
     {
@@ -692,7 +694,7 @@  discard block
 block discarded – undo
692 694
      * @param int $courseId
693 695
      * @param int $url_id
694 696
      *
695
-     * @return resource
697
+     * @return boolean
696 698
      */
697 699
     public static function add_course_to_url($courseId, $url_id = 1)
698 700
     {
@@ -763,7 +765,7 @@  discard block
 block discarded – undo
763 765
     * @param  int  $courseId
764 766
     * @param  int  $urlId
765 767
      *
766
-    * @return boolean true if success
768
+    * @return Doctrine\DBAL\Driver\Statement|null true if success
767 769
     * */
768 770
     public static function delete_url_rel_course($courseId, $urlId)
769 771
     {
@@ -781,7 +783,7 @@  discard block
 block discarded – undo
781 783
      * @param  int $userGroupId
782 784
      * @param  int $urlId
783 785
      *
784
-     * @return boolean true if success
786
+     * @return Doctrine\DBAL\Driver\Statement|null true if success
785 787
      * */
786 788
     public static function delete_url_rel_usergroup($userGroupId, $urlId)
787 789
     {
@@ -800,7 +802,7 @@  discard block
 block discarded – undo
800 802
      * @param  int $userGroupId
801 803
      * @param  int $urlId
802 804
      *
803
-     * @return boolean true if success
805
+     * @return Doctrine\DBAL\Driver\Statement|null true if success
804 806
      * */
805 807
     public static function deleteUrlRelCourseCategory($userGroupId, $urlId)
806 808
     {
@@ -819,7 +821,7 @@  discard block
 block discarded – undo
819 821
     * @param  char  course code
820 822
     * @param  int url id
821 823
      *
822
-    * @return boolean true if success
824
+    * @return Doctrine\DBAL\Driver\Statement|null true if success
823 825
     * */
824 826
     public static function delete_url_rel_session($session_id, $url_id)
825 827
     {
Please login to merge, or discard this patch.
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.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -262,8 +262,9 @@
 block discarded – undo
262 262
         $table_url_rel_session = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
263 263
         $tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION);
264 264
 
265
-        if (!empty($access_url_id))
266
-            $where ="WHERE $table_url_rel_session.access_url_id = ".intval($access_url_id);
265
+        if (!empty($access_url_id)) {
266
+                    $where ="WHERE $table_url_rel_session.access_url_id = ".intval($access_url_id);
267
+        }
267 268
 
268 269
         $sql = "SELECT id, name, access_url_id
269 270
                 FROM $tbl_session u
Please login to merge, or discard this patch.
Spacing   +44 added lines, -44 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)."',
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
     {
74 74
         $id = intval($id);
75 75
         $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
76
-        $sql= "DELETE FROM $table WHERE id = ".$id;
76
+        $sql = "DELETE FROM $table WHERE id = ".$id;
77 77
         $result = Database::query($sql);
78 78
 
79 79
         return $result;
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
      */
87 87
     public static function url_exist($url)
88 88
     {
89
-        $table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
89
+        $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
90 90
         $sql = "SELECT id FROM $table
91 91
                 WHERE url = '".Database::escape_string($url)."' ";
92 92
         $res = Database::query($sql);
@@ -120,10 +120,10 @@  discard block
 block discarded – undo
120 120
      * */
121 121
     public static function url_count()
122 122
     {
123
-        $table_access_url= Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
123
+        $table_access_url = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
124 124
         $sql = "SELECT count(id) as count_result FROM $table_access_url";
125 125
         $res = Database::query($sql);
126
-        $url = Database::fetch_array($res,'ASSOC');
126
+        $url = Database::fetch_array($res, 'ASSOC');
127 127
         $result = $url['count_result'];
128 128
 
129 129
         return $result;
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
                 FROM $table
142 142
                 ORDER BY id";
143 143
         $res = Database::query($sql);
144
-        $urls = array ();
144
+        $urls = array();
145 145
         while ($url = Database::fetch_array($res)) {
146 146
             $urls[] = $url;
147 147
         }
@@ -258,12 +258,12 @@  discard block
 block discarded – undo
258 258
      **/
259 259
     public static function get_url_rel_session_data($access_url_id = null)
260 260
     {
261
-        $where ='';
261
+        $where = '';
262 262
         $table_url_rel_session = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
263 263
         $tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION);
264 264
 
265 265
         if (!empty($access_url_id))
266
-            $where ="WHERE $table_url_rel_session.access_url_id = ".intval($access_url_id);
266
+            $where = "WHERE $table_url_rel_session.access_url_id = ".intval($access_url_id);
267 267
 
268 268
         $sql = "SELECT id, name, access_url_id
269 269
                 FROM $tbl_session u
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
         $table_user_group = Database::get_main_table(TABLE_USERGROUP);
294 294
 
295 295
         if (!empty($access_url_id)) {
296
-            $where ="WHERE $table_url_rel_usergroup.access_url_id = ".intval($access_url_id);
296
+            $where = "WHERE $table_url_rel_usergroup.access_url_id = ".intval($access_url_id);
297 297
         }
298 298
 
299 299
         $sql = "SELECT id, name, access_url_id
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
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);
374
-        $sql= "SELECT user_id FROM $table
374
+        $sql = "SELECT user_id FROM $table
375 375
                WHERE access_url_id = ".intval($url_id)." AND user_id = ".intval($user_id)." ";
376 376
         $result = Database::query($sql);
377 377
         $num = Database::num_rows($result);
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
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);
392
-        $sql= "SELECT c_id FROM $table_url_rel_course
392
+        $sql = "SELECT c_id FROM $table_url_rel_course
393 393
                WHERE
394 394
                     access_url_id = ".intval($urlId)." AND
395 395
                     c_id = '".intval($courseId)."'";
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
     public static function relationUrlUsergroupExist($userGroupId, $urlId)
411 411
     {
412 412
         $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USERGROUP);
413
-        $sql= "SELECT usergroup_id FROM $table
413
+        $sql = "SELECT usergroup_id FROM $table
414 414
                WHERE access_url_id = ".intval($urlId)." AND
415 415
                      usergroup_id = ".intval($userGroupId);
416 416
         $result = Database::query($sql);
@@ -428,9 +428,9 @@  discard block
 block discarded – undo
428 428
     * */
429 429
     public static function relation_url_session_exist($session_id, $url_id)
430 430
     {
431
-        $table_url_rel_session= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
431
+        $table_url_rel_session = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
432 432
         $session_id = intval($session_id);
433
-        $url_id		= intval($url_id);
433
+        $url_id = intval($url_id);
434 434
         $sql = "SELECT session_id FROM $table_url_rel_session
435 435
                 WHERE
436 436
                     access_url_id = ".intval($url_id)." AND
@@ -453,11 +453,11 @@  discard block
 block discarded – undo
453 453
         $table_url_rel_user = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
454 454
         $result_array = array();
455 455
 
456
-        if (is_array($user_list) && is_array($url_list)){
456
+        if (is_array($user_list) && is_array($url_list)) {
457 457
             foreach ($url_list as $url_id) {
458 458
                 foreach ($user_list as $user_id) {
459
-                    $count = UrlManager::relation_url_user_exist($user_id,$url_id);
460
-                    if ($count==0) {
459
+                    $count = UrlManager::relation_url_user_exist($user_id, $url_id);
460
+                    if ($count == 0) {
461 461
                         $sql = "INSERT INTO $table_url_rel_user
462 462
                                 SET user_id = ".intval($user_id).", access_url_id = ".intval($url_id);
463 463
                         $result = Database::query($sql);
@@ -482,19 +482,19 @@  discard block
 block discarded – undo
482 482
      * @param  array of url_ids
483 483
      * @return array
484 484
      **/
485
-    public static function add_courses_to_urls($course_list,$url_list)
485
+    public static function add_courses_to_urls($course_list, $url_list)
486 486
     {
487 487
         $table_url_rel_course = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
488 488
         $result_array = array();
489 489
 
490
-        if (is_array($course_list) && is_array($url_list)){
490
+        if (is_array($course_list) && is_array($url_list)) {
491 491
             foreach ($url_list as $url_id) {
492 492
                 foreach ($course_list as $course_code) {
493 493
                     $courseInfo = api_get_course_info($course_code);
494 494
                     $courseId = $courseInfo['real_id'];
495 495
 
496 496
                     $count = self::relation_url_course_exist($courseId, $url_id);
497
-                    if ($count==0) {
497
+                    if ($count == 0) {
498 498
                         $sql = "INSERT INTO $table_url_rel_course
499 499
                                 SET c_id = '".$courseId."', access_url_id = ".intval($url_id);
500 500
                         $result = Database::query($sql);
@@ -580,7 +580,7 @@  discard block
 block discarded – undo
580 580
     public static function relationUrlCourseCategoryExist($categoryCourseId, $urlId)
581 581
     {
582 582
         $table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE_CATEGORY);
583
-        $sql= "SELECT course_category_id FROM $table
583
+        $sql = "SELECT course_category_id FROM $table
584 584
                WHERE access_url_id = ".intval($urlId)." AND
585 585
                      course_category_id = ".intval($categoryCourseId);
586 586
         $result = Database::query($sql);
@@ -749,7 +749,7 @@  discard block
 block discarded – undo
749 749
         $table_url_rel_user = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
750 750
         $result = true;
751 751
         if (!empty($user_id) && !empty($url_id)) {
752
-            $sql= "DELETE FROM $table_url_rel_user
752
+            $sql = "DELETE FROM $table_url_rel_user
753 753
                    WHERE user_id = ".intval($user_id)." AND access_url_id = ".intval($url_id);
754 754
             $result = Database::query($sql);
755 755
         }
@@ -769,7 +769,7 @@  discard block
 block discarded – undo
769 769
         $table_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
770 770
         $result = true;
771 771
         if (!empty($userId)) {
772
-            $sql= "DELETE FROM $table_url_rel_user
772
+            $sql = "DELETE FROM $table_url_rel_user
773 773
                    WHERE user_id = ".intval($userId);
774 774
             Database::query($sql);
775 775
         }
@@ -787,8 +787,8 @@  discard block
 block discarded – undo
787 787
     * */
788 788
     public static function delete_url_rel_course($courseId, $urlId)
789 789
     {
790
-        $table_url_rel_course= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
791
-        $sql= "DELETE FROM $table_url_rel_course
790
+        $table_url_rel_course = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
791
+        $sql = "DELETE FROM $table_url_rel_course
792 792
                WHERE c_id = '".intval($courseId)."' AND access_url_id=".intval($urlId)."  ";
793 793
         $result = Database::query($sql);
794 794
 
@@ -806,7 +806,7 @@  discard block
 block discarded – undo
806 806
     public static function delete_url_rel_usergroup($userGroupId, $urlId)
807 807
     {
808 808
         $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USERGROUP);
809
-        $sql= "DELETE FROM $table
809
+        $sql = "DELETE FROM $table
810 810
                WHERE usergroup_id = '".intval($userGroupId)."' AND
811 811
                      access_url_id=".intval($urlId)."  ";
812 812
         $result = Database::query($sql);
@@ -825,7 +825,7 @@  discard block
 block discarded – undo
825 825
     public static function deleteUrlRelCourseCategory($userGroupId, $urlId)
826 826
     {
827 827
         $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE_CATEGORY);
828
-        $sql= "DELETE FROM $table
828
+        $sql = "DELETE FROM $table
829 829
                WHERE course_category_id = '".intval($userGroupId)."' AND
830 830
                      access_url_id=".intval($urlId)."  ";
831 831
         $result = Database::query($sql);
@@ -844,9 +844,9 @@  discard block
 block discarded – undo
844 844
     public static function delete_url_rel_session($session_id, $url_id)
845 845
     {
846 846
         $table_url_rel_session = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
847
-        $sql= "DELETE FROM $table_url_rel_session
847
+        $sql = "DELETE FROM $table_url_rel_session
848 848
                WHERE session_id = ".intval($session_id)." AND access_url_id=".intval($url_id)."  ";
849
-        $result = Database::query($sql,'ASSOC');
849
+        $result = Database::query($sql, 'ASSOC');
850 850
 
851 851
         return $result;
852 852
     }
@@ -859,7 +859,7 @@  discard block
 block discarded – undo
859 859
      * */
860 860
     public static function update_urls_rel_user($user_list, $access_url_id)
861 861
     {
862
-        $table_url_rel_user	= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
862
+        $table_url_rel_user = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
863 863
         $sql = "SELECT user_id FROM $table_url_rel_user WHERE access_url_id = ".intval($access_url_id);
864 864
         $result = Database::query($sql);
865 865
         $existing_users = array();
@@ -913,7 +913,7 @@  discard block
 block discarded – undo
913 913
         $result = Database::query($sql);
914 914
 
915 915
         $existing_courses = array();
916
-        while ($row = Database::fetch_array($result)){
916
+        while ($row = Database::fetch_array($result)) {
917 917
             $existing_courses[] = $row['c_id'];
918 918
         }
919 919
 
@@ -946,7 +946,7 @@  discard block
 block discarded – undo
946 946
         $result = Database::query($sql);
947 947
         $existingItems = array();
948 948
 
949
-        while ($row = Database::fetch_array($result)){
949
+        while ($row = Database::fetch_array($result)) {
950 950
             $existingItems[] = $row['usergroup_id'];
951 951
         }
952 952
 
@@ -979,7 +979,7 @@  discard block
 block discarded – undo
979 979
         $result = Database::query($sql);
980 980
         $existingItems = array();
981 981
 
982
-        while ($row = Database::fetch_array($result)){
982
+        while ($row = Database::fetch_array($result)) {
983 983
             $existingItems[] = $row['course_category_id'];
984 984
         }
985 985
 
@@ -1020,15 +1020,15 @@  discard block
 block discarded – undo
1020 1020
      * @param array user list
1021 1021
      * @param int access_url_id
1022 1022
      * */
1023
-    public static function update_urls_rel_session($session_list,$access_url_id)
1023
+    public static function update_urls_rel_session($session_list, $access_url_id)
1024 1024
     {
1025
-        $table_url_rel_session	= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
1025
+        $table_url_rel_session = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
1026 1026
 
1027 1027
         $sql = "SELECT session_id FROM $table_url_rel_session WHERE access_url_id=".intval($access_url_id);
1028 1028
         $result = Database::query($sql);
1029 1029
         $existing_sessions = array();
1030 1030
 
1031
-        while ($row = Database::fetch_array($result)){
1031
+        while ($row = Database::fetch_array($result)) {
1032 1032
             $existing_sessions[] = $row['session_id'];
1033 1033
         }
1034 1034
 
@@ -1057,13 +1057,13 @@  discard block
 block discarded – undo
1057 1057
      */
1058 1058
     public static function get_access_url_from_user($user_id)
1059 1059
     {
1060
-        $table_url_rel_user	= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
1061
-        $table_url	= Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
1060
+        $table_url_rel_user = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
1061
+        $table_url = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
1062 1062
         $sql = "SELECT url, access_url_id FROM $table_url_rel_user url_rel_user INNER JOIN $table_url u
1063 1063
                 ON (url_rel_user.access_url_id = u.id)
1064 1064
                 WHERE user_id = ".intval($user_id);
1065 1065
         $result = Database::query($sql);
1066
-        $url_list = Database::store_result($result,'ASSOC');
1066
+        $url_list = Database::store_result($result, 'ASSOC');
1067 1067
         return $url_list;
1068 1068
     }
1069 1069
 
@@ -1073,14 +1073,14 @@  discard block
 block discarded – undo
1073 1073
      */
1074 1074
     public static function get_access_url_from_course($courseId)
1075 1075
     {
1076
-        $table	= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
1077
-        $table_url	= Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
1076
+        $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
1077
+        $table_url = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
1078 1078
         $sql = "SELECT url, access_url_id FROM $table c INNER JOIN $table_url u
1079 1079
                 ON (c.access_url_id = u.id)
1080 1080
                 WHERE c_id = ".intval($courseId);
1081 1081
 
1082 1082
         $result = Database::query($sql);
1083
-        $url_list = Database::store_result($result,'ASSOC');
1083
+        $url_list = Database::store_result($result, 'ASSOC');
1084 1084
         return $url_list;
1085 1085
     }
1086 1086
 
@@ -1091,7 +1091,7 @@  discard block
 block discarded – undo
1091 1091
     public static function get_access_url_from_session($session_id)
1092 1092
     {
1093 1093
         $table_url_rel_session = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
1094
-        $table_url  = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
1094
+        $table_url = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
1095 1095
         $sql = "SELECT url, access_url_id FROM $table_url_rel_session url_rel_session INNER JOIN $table_url u
1096 1096
                 ON (url_rel_session.access_url_id = u.id)
1097 1097
                 WHERE session_id = ".intval($session_id);
@@ -1107,7 +1107,7 @@  discard block
 block discarded – undo
1107 1107
      */
1108 1108
     public static function get_url_id($url)
1109 1109
     {
1110
-        $table_access_url= Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
1110
+        $table_access_url = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
1111 1111
         $sql = "SELECT id FROM $table_access_url WHERE url = '".Database::escape_string($url)."'";
1112 1112
         $result = Database::query($sql);
1113 1113
         $access_url_id = Database::result($result, 0, 0);
Please login to merge, or discard this patch.
main/inc/lib/usergroup.lib.php 3 patches
Doc Comments   +12 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1013,7 +1013,7 @@  discard block
 block discarded – undo
1013 1013
      * @param int    $groupId
1014 1014
      * @param string $picture
1015 1015
      *
1016
-     * @return bool|string
1016
+     * @return false|string
1017 1017
      */
1018 1018
     public function manageFileUpload($groupId, $picture)
1019 1019
     {
@@ -1155,7 +1155,7 @@  discard block
 block discarded – undo
1155 1155
     }
1156 1156
 
1157 1157
     /**
1158
-     * @return mixed
1158
+     * @return integer
1159 1159
      */
1160 1160
     public function getGroupType()
1161 1161
     {
@@ -1359,6 +1359,8 @@  discard block
 block discarded – undo
1359 1359
      * @param string height
1360 1360
      * @param string picture size it can be small_,  medium_  or  big_
1361 1361
      * @param string style css
1362
+     * @param integer $height
1363
+     * @param integer $size_picture
1362 1364
      * @return array with the file and the style of an image i.e $array['file'] $array['style']
1363 1365
      */
1364 1366
     public function get_picture_group($id, $picture_file, $height, $size_picture = GROUP_IMAGE_SIZE_MEDIUM , $style = '')
@@ -1420,7 +1422,7 @@  discard block
 block discarded – undo
1420 1422
      * @param	string	Type of path to return (can be 'none', 'system', 'rel', 'web')
1421 1423
      * @param	bool	Whether we want to have the directory name returned 'as if' there was a file or not (in the case we want to know which directory to create - otherwise no file means no split subdir)
1422 1424
      * @param	bool	If we want that the function returns the /main/img/unknown.jpg image set it at true
1423
-     * @return	array 	Array of 2 elements: 'dir' and 'file' which contain the dir and file as the name implies if image does not exist it will return the unknow image if anonymous parameter is true if not it returns an empty er's
1425
+     * @return	integer 	Array of 2 elements: 'dir' and 'file' which contain the dir and file as the name implies if image does not exist it will return the unknow image if anonymous parameter is true if not it returns an empty er's
1424 1426
      */
1425 1427
     public function get_group_picture_path_by_id($id, $type = 'none', $preview = false, $anonymous = false)
1426 1428
     {
@@ -1470,7 +1472,7 @@  discard block
 block discarded – undo
1470 1472
     }
1471 1473
 
1472 1474
     /**
1473
-     * @return array
1475
+     * @return string[]
1474 1476
      */
1475 1477
     public function getAllowedPictureExtensions()
1476 1478
     {
@@ -1660,7 +1662,7 @@  discard block
 block discarded – undo
1660 1662
      * @author Julio Montoya
1661 1663
      * @param  int  $user_id
1662 1664
      * @param  int $group_id
1663
-     * @return boolean true if success
1665
+     * @return Doctrine\DBAL\Driver\Statement|null true if success
1664 1666
      * */
1665 1667
     public function delete_user_rel_group($user_id, $group_id)
1666 1668
     {
@@ -1872,6 +1874,8 @@  discard block
 block discarded – undo
1872 1874
      * @param int from value
1873 1875
      * @param int limit
1874 1876
      * @param array image configuration, i.e array('height'=>'20px', 'size'=> '20px')
1877
+     * @param integer $from
1878
+     * @param integer $limit
1875 1879
      * @return array list of users in a group
1876 1880
      */
1877 1881
     public function get_users_by_group(
@@ -1970,6 +1974,8 @@  discard block
 block discarded – undo
1970 1974
      * Shows the left column of the group page
1971 1975
      * @param int group id
1972 1976
      * @param int user id
1977
+     * @param integer $group_id
1978
+     * @param integer $user_id
1973 1979
      *
1974 1980
      */
1975 1981
     public function show_group_column_information($group_id, $user_id, $show = '')
@@ -2323,7 +2329,7 @@  discard block
 block discarded – undo
2323 2329
      * @param int $group_id
2324 2330
      * @param int $parent_group_id if 0, we delete the parent_group association
2325 2331
      * @param int $relation_type
2326
-     * @return resource
2332
+     * @return Doctrine\DBAL\Driver\Statement|null
2327 2333
      **/
2328 2334
     public static function set_parent_group($group_id, $parent_group_id, $relation_type = 1)
2329 2335
     {
Please login to merge, or discard this patch.
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   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
             ";
82 82
             $result = Database::query($sql);
83 83
             if (Database::num_rows($result)) {
84
-                $row  = Database::fetch_array($result);
84
+                $row = Database::fetch_array($result);
85 85
 
86 86
                 return $row['count'];
87 87
             }
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
             ";
102 102
             $result = Database::query($sql);
103 103
             if (Database::num_rows($result)) {
104
-                $row  = Database::fetch_array($result);
104
+                $row = Database::fetch_array($result);
105 105
                 return $row['count'];
106 106
             }
107 107
         }
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
             ";
127 127
             $result = Database::query($sql);
128 128
             if (Database::num_rows($result)) {
129
-                $row  = Database::fetch_array($result);
129
+                $row = Database::fetch_array($result);
130 130
                 return $row['count'];
131 131
             }
132 132
 
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
             ";
148 148
             $result = Database::query($sql);
149 149
             if (Database::num_rows($result)) {
150
-                $row  = Database::fetch_array($result);
150
+                $row = Database::fetch_array($result);
151 151
                 return $row['count'];
152 152
             }
153 153
 
@@ -528,13 +528,13 @@  discard block
 block discarded – undo
528 528
                 INNER JOIN {$this->table} g
529 529
                 ON (u.usergroup_id = g.id)
530 530
                 ";
531
-            $where =  array('where' => array('user_id = ? AND access_url_id = ? ' => array($userId, $urlId)));
531
+            $where = array('where' => array('user_id = ? AND access_url_id = ? ' => array($userId, $urlId)));
532 532
         } else {
533 533
             $from = $this->usergroup_rel_user_table." u
534 534
                 INNER JOIN {$this->table} g
535 535
                 ON (u.usergroup_id = g.id)
536 536
                 ";
537
-            $where =  array('where' => array('user_id = ?' => $userId));
537
+            $where = array('where' => array('user_id = ?' => $userId));
538 538
         }
539 539
 
540 540
         if ($filterByType !== null) {
@@ -567,10 +567,10 @@  discard block
 block discarded – undo
567 567
             $urlId = api_get_current_access_url_id();
568 568
             $from = $this->usergroup_rel_user_table." u
569 569
                     INNER JOIN {$this->access_url_rel_usergroup} a ON (a.usergroup_id AND u.usergroup_id)";
570
-            $where =  array('where' => array('user_id = ? AND access_url_id = ? ' => array($userId, $urlId)));
570
+            $where = array('where' => array('user_id = ? AND access_url_id = ? ' => array($userId, $urlId)));
571 571
         } else {
572 572
             $from = $this->usergroup_rel_user_table." u ";
573
-            $where =  array('where' => array('user_id = ?' => $userId));
573
+            $where = array('where' => array('user_id = ?' => $userId));
574 574
         }
575 575
 
576 576
         $results = Database::select(
@@ -856,7 +856,7 @@  discard block
 block discarded – undo
856 856
             }
857 857
             $result = $new_result;
858 858
         }
859
-        $columns = array('name', 'users', 'courses','sessions', 'group_type');
859
+        $columns = array('name', 'users', 'courses', 'sessions', 'group_type');
860 860
 
861 861
         if (!in_array($sidx, $columns)) {
862 862
             $sidx = 'name';
@@ -1260,7 +1260,7 @@  discard block
 block discarded – undo
1260 1260
                 }
1261 1261
             }
1262 1262
         }
1263
-        $response->addAssign('ajax_list_courses','innerHTML', api_utf8_encode($return));
1263
+        $response->addAssign('ajax_list_courses', 'innerHTML', api_utf8_encode($return));
1264 1264
 
1265 1265
         return $response;
1266 1266
     }
@@ -1367,7 +1367,7 @@  discard block
 block discarded – undo
1367 1367
      * @param string style css
1368 1368
      * @return array with the file and the style of an image i.e $array['file'] $array['style']
1369 1369
      */
1370
-    public function get_picture_group($id, $picture_file, $height, $size_picture = GROUP_IMAGE_SIZE_MEDIUM , $style = '')
1370
+    public function get_picture_group($id, $picture_file, $height, $size_picture = GROUP_IMAGE_SIZE_MEDIUM, $style = '')
1371 1371
     {
1372 1372
         $picture = array();
1373 1373
         $picture['style'] = $style;
@@ -1480,7 +1480,7 @@  discard block
 block discarded – undo
1480 1480
      */
1481 1481
     public function getAllowedPictureExtensions()
1482 1482
     {
1483
-        return $allowed_picture_types = array ('jpg', 'jpeg', 'png', 'gif');
1483
+        return $allowed_picture_types = array('jpg', 'jpeg', 'png', 'gif');
1484 1484
     }
1485 1485
 
1486 1486
     /**
@@ -1514,7 +1514,7 @@  discard block
 block discarded – undo
1514 1514
         if (empty($user_id)) {
1515 1515
             $user_id = api_get_user_id();
1516 1516
         }
1517
-        $user_role	= $this->get_user_group_role($user_id, $group_id);
1517
+        $user_role = $this->get_user_group_role($user_id, $group_id);
1518 1518
         if (in_array($user_role, array(GROUP_USER_PERMISSION_ADMIN))) {
1519 1519
             return true;
1520 1520
         } else {
@@ -1532,7 +1532,7 @@  discard block
 block discarded – undo
1532 1532
         if (empty($user_id)) {
1533 1533
             $user_id = api_get_user_id();
1534 1534
         }
1535
-        $user_role	= $this->get_user_group_role($user_id, $group_id);
1535
+        $user_role = $this->get_user_group_role($user_id, $group_id);
1536 1536
         if (in_array($user_role, array(GROUP_USER_PERMISSION_ADMIN, GROUP_USER_PERMISSION_MODERATOR))) {
1537 1537
             return true;
1538 1538
         } else {
@@ -1559,7 +1559,7 @@  discard block
 block discarded – undo
1559 1559
             GROUP_USER_PERMISSION_READER,
1560 1560
             GROUP_USER_PERMISSION_HRM,
1561 1561
         );
1562
-        $user_role	= self::get_user_group_role($user_id, $group_id);
1562
+        $user_role = self::get_user_group_role($user_id, $group_id);
1563 1563
         if (in_array($user_role, $roles)) {
1564 1564
             return true;
1565 1565
         } else {
@@ -1576,7 +1576,7 @@  discard block
 block discarded – undo
1576 1576
      * */
1577 1577
     public function get_user_group_role($user_id, $group_id)
1578 1578
     {
1579
-        $table_group_rel_user= $this->usergroup_rel_user_table;
1579
+        $table_group_rel_user = $this->usergroup_rel_user_table;
1580 1580
         $return_value = 0;
1581 1581
         if (!empty($user_id) && !empty($group_id)) {
1582 1582
             $sql = "SELECT relation_type FROM $table_group_rel_user
@@ -1584,8 +1584,8 @@  discard block
 block discarded – undo
1584 1584
                         usergroup_id = ".intval($group_id)." AND
1585 1585
                         user_id = ".intval($user_id)." ";
1586 1586
             $result = Database::query($sql);
1587
-            if (Database::num_rows($result)>0) {
1588
-                $row = Database::fetch_array($result,'ASSOC');
1587
+            if (Database::num_rows($result) > 0) {
1588
+                $row = Database::fetch_array($result, 'ASSOC');
1589 1589
                 $return_value = $row['relation_type'];
1590 1590
             }
1591 1591
         }
@@ -1640,7 +1640,7 @@  discard block
 block discarded – undo
1640 1640
         if (is_array($user_list) && is_array($group_list)) {
1641 1641
             foreach ($group_list as $group_id) {
1642 1642
                 foreach ($user_list as $user_id) {
1643
-                    $role = self::get_user_group_role($user_id,$group_id);
1643
+                    $role = self::get_user_group_role($user_id, $group_id);
1644 1644
                     if ($role == 0) {
1645 1645
                         $sql = "INSERT INTO $table_url_rel_group
1646 1646
 		               			SET
@@ -1671,7 +1671,7 @@  discard block
 block discarded – undo
1671 1671
     public function delete_user_rel_group($user_id, $group_id)
1672 1672
     {
1673 1673
         $table = $this->usergroup_rel_user_table;
1674
-        $sql= "DELETE FROM $table
1674
+        $sql = "DELETE FROM $table
1675 1675
                WHERE
1676 1676
                 user_id = ".intval($user_id)." AND
1677 1677
                 usergroup_id = ".intval($group_id)."  ";
@@ -1727,7 +1727,7 @@  discard block
 block discarded – undo
1727 1727
 
1728 1728
         $sql = "UPDATE $table_group_rel_user
1729 1729
    				SET relation_type = ".intval($relation_type)."
1730
-                WHERE user_id = $user_id AND usergroup_id = $group_id" ;
1730
+                WHERE user_id = $user_id AND usergroup_id = $group_id";
1731 1731
         Database::query($sql);
1732 1732
     }
1733 1733
 
@@ -1769,7 +1769,7 @@  discard block
 block discarded – undo
1769 1769
         if (Database::num_rows($result) > 0) {
1770 1770
             while ($row = Database::fetch_array($result, 'ASSOC')) {
1771 1771
                 if ($with_image) {
1772
-                    $picture = self::get_picture_group($row['id'], $row['picture'],80);
1772
+                    $picture = self::get_picture_group($row['id'], $row['picture'], 80);
1773 1773
                     $img = '<img src="'.$picture['file'].'" />';
1774 1774
                     $row['picture'] = $img;
1775 1775
                 }
@@ -1805,11 +1805,11 @@  discard block
 block discarded – undo
1805 1805
 				ORDER BY count DESC
1806 1806
 				LIMIT $num";
1807 1807
 
1808
-        $result=Database::query($sql);
1808
+        $result = Database::query($sql);
1809 1809
         $array = array();
1810 1810
         while ($row = Database::fetch_array($result, 'ASSOC')) {
1811 1811
             if ($with_image) {
1812
-                $picture = self::get_picture_group($row['id'], $row['picture'],80);
1812
+                $picture = self::get_picture_group($row['id'], $row['picture'], 80);
1813 1813
                 $img = '<img src="'.$picture['file'].'" />';
1814 1814
                 $row['picture'] = $img;
1815 1815
             }
@@ -1854,11 +1854,11 @@  discard block
 block discarded – undo
1854 1854
                 ORDER BY created_at DESC
1855 1855
                 LIMIT $num ";
1856 1856
 
1857
-        $result=Database::query($sql);
1857
+        $result = Database::query($sql);
1858 1858
         $array = array();
1859 1859
         while ($row = Database::fetch_array($result, 'ASSOC')) {
1860 1860
             if ($with_image) {
1861
-                $picture = self::get_picture_group($row['id'], $row['picture'],80);
1861
+                $picture = self::get_picture_group($row['id'], $row['picture'], 80);
1862 1862
                 $img = '<img src="'.$picture['file'].'" />';
1863 1863
                 $row['picture'] = $img;
1864 1864
             }
@@ -1892,7 +1892,7 @@  discard block
 block discarded – undo
1892 1892
         $tbl_user = Database::get_main_table(TABLE_MAIN_USER);
1893 1893
         $group_id = intval($group_id);
1894 1894
 
1895
-        if (empty($group_id)){
1895
+        if (empty($group_id)) {
1896 1896
             return array();
1897 1897
         }
1898 1898
 
@@ -1907,9 +1907,9 @@  discard block
 block discarded – undo
1907 1907
             $where_relation_condition = '';
1908 1908
         } else {
1909 1909
             $new_relation_type = array();
1910
-            foreach($relation_type as $rel) {
1910
+            foreach ($relation_type as $rel) {
1911 1911
                 $rel = intval($rel);
1912
-                $new_relation_type[] ="'$rel'";
1912
+                $new_relation_type[] = "'$rel'";
1913 1913
             }
1914 1914
             $relation_type = implode(',', $new_relation_type);
1915 1915
             if (!empty($relation_type))
@@ -1953,7 +1953,7 @@  discard block
 block discarded – undo
1953 1953
         $tbl_user = Database::get_main_table(TABLE_MAIN_USER);
1954 1954
         $group_id = intval($group_id);
1955 1955
 
1956
-        if (empty($group_id)){
1956
+        if (empty($group_id)) {
1957 1957
             return array();
1958 1958
         }
1959 1959
 
@@ -1964,7 +1964,7 @@  discard block
 block discarded – undo
1964 1964
 			    WHERE gu.usergroup_id= $group_id
1965 1965
 			    ORDER BY relation_type, firstname";
1966 1966
 
1967
-        $result=Database::query($sql);
1967
+        $result = Database::query($sql);
1968 1968
         $array = array();
1969 1969
         while ($row = Database::fetch_array($result, 'ASSOC')) {
1970 1970
             $array[$row['id']] = $row;
@@ -1993,27 +1993,27 @@  discard block
 block discarded – undo
1993 1993
             case GROUP_USER_PERMISSION_READER:
1994 1994
                 // I'm just a reader
1995 1995
                 $relation_group_title = get_lang('IAmAReader');
1996
-                $links .=  '<li><a href="group_invitation.php?id='.$group_id.'">'.
1997
-                            Display::return_icon('invitation_friend.png', get_lang('InviteFriends'), array('hspace'=>'6')).'<span class="'.($show=='invite_friends'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('InviteFriends').'</span></a></li>';
1998
-                $links .=  '<li><a href="group_view.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'.
1996
+                $links .= '<li><a href="group_invitation.php?id='.$group_id.'">'.
1997
+                            Display::return_icon('invitation_friend.png', get_lang('InviteFriends'), array('hspace'=>'6')).'<span class="'.($show == 'invite_friends' ? 'social-menu-text-active' : 'social-menu-text4').'" >'.get_lang('InviteFriends').'</span></a></li>';
1998
+                $links .= '<li><a href="group_view.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'.
1999 1999
                             Display::return_icon('group_leave.png', get_lang('LeaveGroup'), array('hspace'=>'6')).'<span class="social-menu-text4" >'.get_lang('LeaveGroup').'</span></a></li>';
2000 2000
                 break;
2001 2001
             case GROUP_USER_PERMISSION_ADMIN:
2002 2002
                 $relation_group_title = get_lang('IAmAnAdmin');
2003
-                $links .=  '<li><a href="group_edit.php?id='.$group_id.'">'.
2004
-                            Display::return_icon('group_edit.png', get_lang('EditGroup'), array('hspace'=>'6')).'<span class="'.($show=='group_edit'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('EditGroup').'</span></a></li>';
2005
-                $links .=  '<li><a href="group_waiting_list.php?id='.$group_id.'">'.
2006
-                            Display::return_icon('waiting_list.png', get_lang('WaitingList'), array('hspace'=>'6')).'<span class="'.($show=='waiting_list'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('WaitingList').'</span></a></li>';
2007
-                $links .=  '<li><a href="group_invitation.php?id='.$group_id.'">'.
2008
-                            Display::return_icon('invitation_friend.png', get_lang('InviteFriends'), array('hspace'=>'6')).'<span class="'.($show=='invite_friends'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('InviteFriends').'</span></a></li>';
2009
-                $links .=  '<li><a href="group_view.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'.
2003
+                $links .= '<li><a href="group_edit.php?id='.$group_id.'">'.
2004
+                            Display::return_icon('group_edit.png', get_lang('EditGroup'), array('hspace'=>'6')).'<span class="'.($show == 'group_edit' ? 'social-menu-text-active' : 'social-menu-text4').'" >'.get_lang('EditGroup').'</span></a></li>';
2005
+                $links .= '<li><a href="group_waiting_list.php?id='.$group_id.'">'.
2006
+                            Display::return_icon('waiting_list.png', get_lang('WaitingList'), array('hspace'=>'6')).'<span class="'.($show == 'waiting_list' ? 'social-menu-text-active' : 'social-menu-text4').'" >'.get_lang('WaitingList').'</span></a></li>';
2007
+                $links .= '<li><a href="group_invitation.php?id='.$group_id.'">'.
2008
+                            Display::return_icon('invitation_friend.png', get_lang('InviteFriends'), array('hspace'=>'6')).'<span class="'.($show == 'invite_friends' ? 'social-menu-text-active' : 'social-menu-text4').'" >'.get_lang('InviteFriends').'</span></a></li>';
2009
+                $links .= '<li><a href="group_view.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'.
2010 2010
                             Display::return_icon('group_leave.png', get_lang('LeaveGroup'), array('hspace'=>'6')).'<span class="social-menu-text4" >'.get_lang('LeaveGroup').'</span></a></li>';
2011 2011
                 break;
2012 2012
             case GROUP_USER_PERMISSION_PENDING_INVITATION:
2013 2013
 //				$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>';
2014 2014
                 break;
2015 2015
             case GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER:
2016
-                $relation_group_title =  get_lang('WaitingForAdminResponse');
2016
+                $relation_group_title = get_lang('WaitingForAdminResponse');
2017 2017
                 break;
2018 2018
             case GROUP_USER_PERMISSION_MODERATOR:
2019 2019
                 $relation_group_title = get_lang('IAmAModerator');
@@ -2021,25 +2021,25 @@  discard block
 block discarded – undo
2021 2021
                 //$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>';
2022 2022
                 //$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>';
2023 2023
                 if ($group_info['visibility'] == GROUP_PERMISSION_CLOSED) {
2024
-                    $links .=  '<li><a href="group_waiting_list.php?id='.$group_id.'">'.
2025
-                                Display::return_icon('waiting_list.png', get_lang('WaitingList'), array('hspace'=>'6')).'<span class="'.($show=='waiting_list'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('WaitingList').'</span></a></li>';
2024
+                    $links .= '<li><a href="group_waiting_list.php?id='.$group_id.'">'.
2025
+                                Display::return_icon('waiting_list.png', get_lang('WaitingList'), array('hspace'=>'6')).'<span class="'.($show == 'waiting_list' ? 'social-menu-text-active' : 'social-menu-text4').'" >'.get_lang('WaitingList').'</span></a></li>';
2026 2026
                 }
2027
-                $links .=  '<li><a href="group_invitation.php?id='.$group_id.'">'.
2028
-                            Display::return_icon('invitation_friend.png', get_lang('InviteFriends'), array('hspace'=>'6')).'<span class="'.($show=='invite_friends'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('InviteFriends').'</span></a></li>';
2029
-                $links .=  '<li><a href="group_view.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'.
2027
+                $links .= '<li><a href="group_invitation.php?id='.$group_id.'">'.
2028
+                            Display::return_icon('invitation_friend.png', get_lang('InviteFriends'), array('hspace'=>'6')).'<span class="'.($show == 'invite_friends' ? 'social-menu-text-active' : 'social-menu-text4').'" >'.get_lang('InviteFriends').'</span></a></li>';
2029
+                $links .= '<li><a href="group_view.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'.
2030 2030
                             Display::return_icon('group_leave.png', get_lang('LeaveGroup'), array('hspace'=>'6')).'<span class="social-menu-text4" >'.get_lang('LeaveGroup').'</span></a></li>';
2031 2031
                 break;
2032 2032
             case GROUP_USER_PERMISSION_HRM:
2033 2033
                 $relation_group_title = get_lang('IAmAHRM');
2034 2034
                 $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').'">'.
2035 2035
                             Display::return_icon('new-message.png', get_lang('NewTopic'), array('hspace'=>'6')).'<span class="social-menu-text4" >'.get_lang('NewTopic').'</span></a></li>';
2036
-                $links .=  '<li><a href="group_view.php?id='.$group_id.'">'.
2037
-                            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>';
2038
-                $links .=  '<li><a href="group_invitation.php?id='.$group_id.'">'.
2039
-                            Display::return_icon('invitation_friend.png', get_lang('InviteFriends'), array('hspace'=>'6')).'<span class="'.($show=='invite_friends'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('InviteFriends').'</span></a></li>';
2040
-                $links .=  '<li><a href="group_members.php?id='.$group_id.'">'.
2041
-                            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>';
2042
-                $links .=  '<li><a href="group_view.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'.
2036
+                $links .= '<li><a href="group_view.php?id='.$group_id.'">'.
2037
+                            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>';
2038
+                $links .= '<li><a href="group_invitation.php?id='.$group_id.'">'.
2039
+                            Display::return_icon('invitation_friend.png', get_lang('InviteFriends'), array('hspace'=>'6')).'<span class="'.($show == 'invite_friends' ? 'social-menu-text-active' : 'social-menu-text4').'" >'.get_lang('InviteFriends').'</span></a></li>';
2040
+                $links .= '<li><a href="group_members.php?id='.$group_id.'">'.
2041
+                            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>';
2042
+                $links .= '<li><a href="group_view.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'.
2043 2043
                             Display::return_icon('delete_data.gif', get_lang('LeaveGroup'), array('hspace'=>'6')).'<span class="social-menu-text4" >'.get_lang('LeaveGroup').'</span></a></li>';
2044 2044
                 break;
2045 2045
             default:
@@ -2082,14 +2082,14 @@  discard block
 block discarded – undo
2082 2082
      */
2083 2083
     public function get_groups_by_user_count($user_id = '', $relation_type = GROUP_USER_PERMISSION_READER, $with_image = false)
2084 2084
     {
2085
-        $table_group_rel_user	= $this->usergroup_rel_user_table;
2086
-        $tbl_group				= $this->table;
2087
-        $user_id 				= intval($user_id);
2085
+        $table_group_rel_user = $this->usergroup_rel_user_table;
2086
+        $tbl_group = $this->table;
2087
+        $user_id = intval($user_id);
2088 2088
 
2089 2089
         if ($relation_type == 0) {
2090 2090
             $where_relation_condition = '';
2091 2091
         } else {
2092
-            $relation_type 			= intval($relation_type);
2092
+            $relation_type = intval($relation_type);
2093 2093
             $where_relation_condition = "AND gu.relation_type = $relation_type ";
2094 2094
         }
2095 2095
 
@@ -2162,7 +2162,7 @@  discard block
 block discarded – undo
2162 2162
         }
2163 2163
 
2164 2164
         $direction = 'ASC';
2165
-        if (!in_array($direction, array('ASC','DESC'))) {
2165
+        if (!in_array($direction, array('ASC', 'DESC'))) {
2166 2166
             $direction = 'ASC';
2167 2167
         }
2168 2168
 
@@ -2173,8 +2173,8 @@  discard block
 block discarded – undo
2173 2173
         $sql .= " LIMIT $from,$number_of_items";
2174 2174
 
2175 2175
         $res = Database::query($sql);
2176
-        if (Database::num_rows($res)> 0) {
2177
-            while ($row = Database::fetch_array($res,'ASSOC')) {
2176
+        if (Database::num_rows($res) > 0) {
2177
+            while ($row = Database::fetch_array($res, 'ASSOC')) {
2178 2178
                 if (!in_array($row['id'], $return)) {
2179 2179
                     $return[$row['id']] = $row;
2180 2180
                 }
@@ -2199,7 +2199,7 @@  discard block
 block discarded – undo
2199 2199
             if ($i == $max_level) {
2200 2200
                 $select_part .= "rg$rg_number.group_id as id_$rg_number ";
2201 2201
             } else {
2202
-                $select_part .="rg$rg_number.group_id as id_$rg_number, ";
2202
+                $select_part .= "rg$rg_number.group_id as id_$rg_number, ";
2203 2203
             }
2204 2204
             if ($i == 1) {
2205 2205
                 $cond_part .= "FROM $t_rel_group rg0 LEFT JOIN $t_rel_group rg$i on rg$rg_number.group_id = rg$i.subgroup_id ";
@@ -2387,7 +2387,7 @@  discard block
 block discarded – undo
2387 2387
         $nameList = '<ul class="list-unstyled">';
2388 2388
 
2389 2389
         foreach ($groupsNameListParsed as $name) {
2390
-            $nameList .= '<li>' . Display::span($name, ['class' => 'label label-info']) . '</li>';
2390
+            $nameList .= '<li>'.Display::span($name, ['class' => 'label label-info']).'</li>';
2391 2391
         }
2392 2392
 
2393 2393
         $nameList .= '</ul>';
Please login to merge, or discard this patch.
main/inc/lib/usermanager.lib.php 4 patches
Doc Comments   +31 added lines, -15 removed lines patch added patch discarded remove patch
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
     }
87 87
 
88 88
     /**
89
-     * @return bool|mixed
89
+     * @return string
90 90
      */
91 91
     public static function getPasswordEncryption()
92 92
     {
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
      * @param string $raw
162 162
      * @param User   $user
163 163
      *
164
-     * @return bool
164
+     * @return string
165 165
      */
166 166
     public static function encryptPassword($raw, User $user)
167 167
     {
@@ -965,6 +965,7 @@  discard block
 block discarded – undo
965 965
      * Disables or enables a user
966 966
      * @param int user_id
967 967
      * @param int Enable or disable
968
+     * @param integer $active
968 969
      * @return void
969 970
      * @assert (-1,0) === false
970 971
      * @assert (1,1) === true
@@ -995,6 +996,7 @@  discard block
 block discarded – undo
995 996
     /**
996 997
      * Disables a user
997 998
      * @param int User id
999
+     * @param integer $user_id
998 1000
      * @return bool
999 1001
      * @uses UserManager::change_active_state() to actually disable the user
1000 1002
      * @assert (0) === false
@@ -1011,6 +1013,7 @@  discard block
 block discarded – undo
1011 1013
     /**
1012 1014
      * Enable a user
1013 1015
      * @param int User id
1016
+     * @param integer $user_id
1014 1017
      * @return bool
1015 1018
      * @uses UserManager::change_active_state() to actually disable the user
1016 1019
      * @assert (0) === false
@@ -1175,6 +1178,7 @@  discard block
 block discarded – undo
1175 1178
      * Checks whether the user id exists in the database
1176 1179
      *
1177 1180
      * @param int User id
1181
+     * @param integer $userId
1178 1182
      * @return bool True if user id was found, false otherwise
1179 1183
      */
1180 1184
     public static function is_user_id_valid($userId)
@@ -1357,7 +1361,7 @@  discard block
 block discarded – undo
1357 1361
      * @param   array $userInfo user information to avoid query the DB
1358 1362
      * returns the /main/img/unknown.jpg image set it at true
1359 1363
      *
1360
-     * @return    array     Array of 2 elements: 'dir' and 'file' which contain
1364
+     * @return    integer     Array of 2 elements: 'dir' and 'file' which contain
1361 1365
      * the dir and file as the name implies if image does not exist it will
1362 1366
      * return the unknow image if anonymous parameter is true if not it returns an empty array
1363 1367
      */
@@ -1729,7 +1733,7 @@  discard block
 block discarded – undo
1729 1733
      * @param    int $user_id    User id
1730 1734
      * @param    $force    Optional parameter to force building after a removal request
1731 1735
      *
1732
-     * @return    A string containing the XHTML code to dipslay the production list, or FALSE
1736
+     * @return    boolean|string string containing the XHTML code to dipslay the production list, or FALSE
1733 1737
      */
1734 1738
     public static function build_production_list($user_id, $force = false, $showdelete = false)
1735 1739
     {
@@ -1765,7 +1769,7 @@  discard block
 block discarded – undo
1765 1769
     /**
1766 1770
      * Returns an array with the user's productions.
1767 1771
      *
1768
-     * @param    $user_id    User id
1772
+     * @param    integer $user_id    User id
1769 1773
      * @return   array  An array containing the user's productions
1770 1774
      */
1771 1775
     public static function get_user_productions($user_id)
@@ -1920,7 +1924,7 @@  discard block
 block discarded – undo
1920 1924
 
1921 1925
     /**
1922 1926
      * Build a list of extra file already uploaded in $user_folder/{$extra_field}/
1923
-     * @param $user_id
1927
+     * @param integer $user_id
1924 1928
      * @param $extra_field
1925 1929
      * @param bool $force
1926 1930
      * @param bool $showdelete
@@ -2023,7 +2027,7 @@  discard block
 block discarded – undo
2023 2027
      * @param    int       $fieldType  Field's type
2024 2028
      * @param    string    $displayText Field's language var name
2025 2029
      * @param    string    $default Field's default value
2026
-     * @return int
2030
+     * @return boolean
2027 2031
      */
2028 2032
     public static function create_extra_field($variable, $fieldType, $displayText, $default)
2029 2033
     {
@@ -2056,6 +2060,7 @@  discard block
 block discarded – undo
2056 2060
      * @param    boolean    Whether to prefix the fields indexes with "extra_" (might be used by formvalidator)
2057 2061
      * @param    boolean    Whether to return invisible fields as well
2058 2062
      * @param    boolean    Whether to split multiple-selection fields or not
2063
+     * @param boolean $field_filter
2059 2064
      * @return    array    Array of fields => value for the given user
2060 2065
      */
2061 2066
     public static function get_extra_user_data(
@@ -2242,7 +2247,6 @@  discard block
 block discarded – undo
2242 2247
     /**
2243 2248
      * Get all the extra field information of a certain field (also the options)
2244 2249
      *
2245
-     * @param int $field_name the name of the field we want to know everything of
2246 2250
      * @return array $return containing all th information about the extra profile field
2247 2251
      * @author Julio Montoya
2248 2252
      * @deprecated
@@ -2285,6 +2289,7 @@  discard block
 block discarded – undo
2285 2289
     /**
2286 2290
      * Get extra user data by field variable
2287 2291
      * @param string    field variable
2292
+     * @param string $field_variable
2288 2293
      * @return array    data
2289 2294
      */
2290 2295
     public static function get_extra_user_data_by_field_variable($field_variable)
@@ -2829,7 +2834,7 @@  discard block
 block discarded – undo
2829 2834
      * @param    string    User ID
2830 2835
      * @param   string  course directory
2831 2836
      * @param   string  resourcetype: images, all
2832
-     * @return    int        User ID (or false if not found)
2837
+     * @return    string        User ID (or false if not found)
2833 2838
      */
2834 2839
     public static function get_user_upload_files_by_course($user_id, $course, $resourcetype = 'all')
2835 2840
     {
@@ -2909,7 +2914,7 @@  discard block
 block discarded – undo
2909 2914
     /**
2910 2915
      * Adds a new API key to the users' account
2911 2916
      * @param   int     Optional user ID (defaults to the results of api_get_user_id())
2912
-     * @return  boolean True on success, false on failure
2917
+     * @return  false|string True on success, false on failure
2913 2918
      */
2914 2919
     public static function add_api_key($user_id = null, $api_service = 'dokeos')
2915 2920
     {
@@ -2964,6 +2969,7 @@  discard block
 block discarded – undo
2964 2969
      * Regenerate an API key from the user's account
2965 2970
      * @param   int     user ID (defaults to the results of api_get_user_id())
2966 2971
      * @param   string  API key's internal ID
2972
+     * @param string $api_service
2967 2973
      * @return  int        num
2968 2974
      */
2969 2975
     public static function update_api_key($user_id, $api_service)
@@ -2993,6 +2999,7 @@  discard block
 block discarded – undo
2993 2999
     /**
2994 3000
      * @param   int     user ID (defaults to the results of api_get_user_id())
2995 3001
      * @param   string    API key's internal ID
3002
+     * @param string $api_service
2996 3003
      * @return  int    row ID, or return false if not found
2997 3004
      */
2998 3005
     public static function get_api_key_id($user_id, $api_service)
@@ -3204,7 +3211,8 @@  discard block
 block discarded – undo
3204 3211
      * @param int user_id
3205 3212
      * @param int field_id
3206 3213
      * @param bool show links or not
3207
-     * @return array
3214
+     * @param integer $user_id
3215
+     * @return string
3208 3216
      */
3209 3217
     public static function get_user_tags_to_string($user_id, $field_id, $show_links = true)
3210 3218
     {
@@ -3249,6 +3257,8 @@  discard block
 block discarded – undo
3249 3257
      * Get the tag id
3250 3258
      * @param int tag
3251 3259
      * @param int field_id
3260
+     * @param string $tag
3261
+     * @param integer $field_id
3252 3262
      * @return int returns 0 if fails otherwise the tag id
3253 3263
      */
3254 3264
     public static function get_tag_id($tag, $field_id)
@@ -3295,7 +3305,7 @@  discard block
 block discarded – undo
3295 3305
      * @param mixed tag
3296 3306
      * @param int The user id
3297 3307
      * @param int field id of the tag
3298
-     * @return bool
3308
+     * @return boolean|null
3299 3309
      */
3300 3310
     public static function add_tag($tag, $user_id, $field_id)
3301 3311
     {
@@ -4101,7 +4111,7 @@  discard block
 block discarded – undo
4101 4111
      * Add subscribed users to a user by relation type
4102 4112
      * @param int $userId The user id
4103 4113
      * @param array $subscribedUsersId The id of suscribed users
4104
-     * @param action $relationType The relation type
4114
+     * @param integer $relationType The relation type
4105 4115
      */
4106 4116
     public static function subscribeUsersToUser($userId, $subscribedUsersId, $relationType)
4107 4117
     {
@@ -4158,6 +4168,8 @@  discard block
 block discarded – undo
4158 4168
      * This function check if an user is followed by human resources manager
4159 4169
      * @param     int     User id
4160 4170
      * @param    int        Human resources manager
4171
+     * @param integer $user_id
4172
+     * @param integer $hr_dept_id
4161 4173
      * @return    bool
4162 4174
      */
4163 4175
     public static function is_user_followed_by_drh($user_id, $hr_dept_id)
@@ -4230,6 +4242,8 @@  discard block
 block discarded – undo
4230 4242
      * Determines if a user is a gradebook certified
4231 4243
      * @param int The category id of gradebook
4232 4244
      * @param int The user id
4245
+     * @param integer $cat_id
4246
+     * @param integer $user_id
4233 4247
      * @return boolean
4234 4248
      */
4235 4249
     public static function is_user_certified($cat_id, $user_id)
@@ -4252,6 +4266,8 @@  discard block
 block discarded – undo
4252 4266
      * Gets the info about a gradebook certificate for a user by course
4253 4267
      * @param string The course code
4254 4268
      * @param int The user id
4269
+     * @param integer $course_code
4270
+     * @param integer $user_id
4255 4271
      * @return array  if there is not information return false
4256 4272
      */
4257 4273
     public static function get_info_gradebook_certificate($course_code, $user_id)
@@ -4715,7 +4731,7 @@  discard block
 block discarded – undo
4715 4731
     }
4716 4732
 
4717 4733
     /**
4718
-     * @return array
4734
+     * @return string[]
4719 4735
      */
4720 4736
     static function get_user_field_types()
4721 4737
     {
@@ -4967,7 +4983,7 @@  discard block
 block discarded – undo
4967 4983
      * Get either a Gravatar URL or complete image tag for a specified email address.
4968 4984
      *
4969 4985
      * @param string $email The email address
4970
-     * @param string $s Size in pixels, defaults to 80px [ 1 - 2048 ]
4986
+     * @param integer $s Size in pixels, defaults to 80px [ 1 - 2048 ]
4971 4987
      * @param string $d Default imageset to use [ 404 | mm | identicon | monsterid | wavatar ]
4972 4988
      * @param string $r Maximum rating (inclusive) [ g | pg | r | x ]
4973 4989
      * @param boole $img True to return a complete IMG tag False for just the URL
Please login to merge, or discard this patch.
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -1229,13 +1229,13 @@  discard block
 block discarded – undo
1229 1229
     }
1230 1230
 
1231 1231
     /**
1232
-    * Get the users by ID
1233
-    * @param array $ids student ids
1234
-    * @param string $active
1235
-    * @param string $order
1236
-    * @param string $limit
1237
-    * @return array $result student information
1238
-    */
1232
+     * Get the users by ID
1233
+     * @param array $ids student ids
1234
+     * @param string $active
1235
+     * @param string $order
1236
+     * @param string $limit
1237
+     * @return array $result student information
1238
+     */
1239 1239
     public static function get_user_list_by_ids($ids = array(), $active = null, $order = null, $limit = null)
1240 1240
     {
1241 1241
         if (empty($ids)) {
@@ -3332,12 +3332,12 @@  discard block
 block discarded – undo
3332 3332
         if ($tag_id == 0) {
3333 3333
             //the tag doesn't exist
3334 3334
             $sql = "INSERT INTO $table_user_tag (tag, field_id,count) VALUES ('$tag','$field_id', count + 1)";
3335
-             Database::query($sql);
3335
+                Database::query($sql);
3336 3336
             $last_insert_id = Database::insert_id();
3337 3337
         } else {
3338 3338
             //the tag exists we update it
3339 3339
             $sql = "UPDATE $table_user_tag SET count = count + 1 WHERE id  = $tag_id";
3340
-             Database::query($sql);
3340
+                Database::query($sql);
3341 3341
             $last_insert_id = $tag_id;
3342 3342
         }
3343 3343
 
@@ -3532,9 +3532,9 @@  discard block
 block discarded – undo
3532 3532
     }
3533 3533
 
3534 3534
     /**
3535
-      * Get extra filtrable user fields (only type select)
3536
-      * @return array
3537
-      */
3535
+     * Get extra filtrable user fields (only type select)
3536
+     * @return array
3537
+     */
3538 3538
     public static function get_extra_filtrable_fields()
3539 3539
     {
3540 3540
         $extraFieldList = UserManager::get_extra_fields();
@@ -3559,9 +3559,9 @@  discard block
 block discarded – undo
3559 3559
     }
3560 3560
 
3561 3561
     /**
3562
-      * Get extra where clauses for finding users based on extra filtrable user fields (type select)
3563
-      * @return string With AND clauses based on user's ID which have the values to search in extra user fields
3564
-      */
3562
+     * Get extra where clauses for finding users based on extra filtrable user fields (type select)
3563
+     * @return string With AND clauses based on user's ID which have the values to search in extra user fields
3564
+     */
3565 3565
     public static function get_search_form_where_extra_fields()
3566 3566
     {
3567 3567
         $useExtraFields = false;
@@ -3869,23 +3869,23 @@  discard block
 block discarded – undo
3869 3869
     }
3870 3870
 
3871 3871
     /**
3872
-    * Get users followed by human resource manager
3873
-    * @param int $userId
3874
-    * @param int  $userStatus Filter users by status (STUDENT, COURSEMANAGER, etc)
3875
-    * @param bool $getOnlyUserId
3876
-    * @param bool $getSql
3877
-    * @param bool $getCount
3878
-    * @param int $from
3879
-    * @param int $numberItems
3880
-    * @param int $column
3881
-    * @param string $direction
3882
-    * @param int $active
3883
-    * @param string $lastConnectionDate
3884
-    * @param int $status the function is called by who? COURSEMANAGER, DRH?
3885
-    * @param string $keyword
3872
+     * Get users followed by human resource manager
3873
+     * @param int $userId
3874
+     * @param int  $userStatus Filter users by status (STUDENT, COURSEMANAGER, etc)
3875
+     * @param bool $getOnlyUserId
3876
+     * @param bool $getSql
3877
+     * @param bool $getCount
3878
+     * @param int $from
3879
+     * @param int $numberItems
3880
+     * @param int $column
3881
+     * @param string $direction
3882
+     * @param int $active
3883
+     * @param string $lastConnectionDate
3884
+     * @param int $status the function is called by who? COURSEMANAGER, DRH?
3885
+     * @param string $keyword
3886 3886
      *
3887
-    * @return array user list
3888
-    */
3887
+     * @return array user list
3888
+     */
3889 3889
     public static function getUsersFollowedByUser(
3890 3890
         $userId,
3891 3891
         $userStatus = null,
Please login to merge, or discard this patch.
Braces   +97 added lines, -62 removed lines patch added patch discarded remove patch
@@ -774,10 +774,12 @@  discard block
 block discarded – undo
774 774
     public static function update_openid($user_id, $openid)
775 775
     {
776 776
         $table_user = Database :: get_main_table(TABLE_MAIN_USER);
777
-        if ($user_id != strval(intval($user_id)))
778
-            return false;
779
-        if ($user_id === false)
780
-            return false;
777
+        if ($user_id != strval(intval($user_id))) {
778
+                    return false;
779
+        }
780
+        if ($user_id === false) {
781
+                    return false;
782
+        }
781 783
         $sql = "UPDATE $table_user SET
782 784
                 openid='".Database::escape_string($openid)."'";
783 785
         $sql .= " WHERE id= $user_id";
@@ -2069,8 +2071,9 @@  discard block
 block discarded – undo
2069 2071
         if (empty($user_id)) {
2070 2072
             $user_id = 0;
2071 2073
         } else {
2072
-            if ($user_id != strval(intval($user_id)))
2073
-                return array();
2074
+            if ($user_id != strval(intval($user_id))) {
2075
+                            return array();
2076
+            }
2074 2077
         }
2075 2078
         $extra_data = array();
2076 2079
         $t_uf = Database::get_main_table(TABLE_EXTRA_FIELD);
@@ -2162,8 +2165,9 @@  discard block
 block discarded – undo
2162 2165
         if (empty($user_id)) {
2163 2166
             $user_id = 0;
2164 2167
         } else {
2165
-            if ($user_id != strval(intval($user_id)))
2166
-                return array();
2168
+            if ($user_id != strval(intval($user_id))) {
2169
+                            return array();
2170
+            }
2167 2171
         }
2168 2172
         $extra_data = array();
2169 2173
         $t_uf = Database::get_main_table(TABLE_EXTRA_FIELD);
@@ -2880,13 +2884,15 @@  discard block
 block discarded – undo
2880 2884
      */
2881 2885
     public static function get_api_keys($user_id = null, $api_service = 'dokeos')
2882 2886
     {
2883
-        if ($user_id != strval(intval($user_id)))
2884
-            return false;
2887
+        if ($user_id != strval(intval($user_id))) {
2888
+                    return false;
2889
+        }
2885 2890
         if (empty($user_id)) {
2886 2891
             $user_id = api_get_user_id();
2887 2892
         }
2888
-        if ($user_id === false)
2889
-            return false;
2893
+        if ($user_id === false) {
2894
+                    return false;
2895
+        }
2890 2896
         $service_name = Database::escape_string($api_service);
2891 2897
         if (is_string($service_name) === false) {
2892 2898
             return false;
@@ -2894,11 +2900,14 @@  discard block
 block discarded – undo
2894 2900
         $t_api = Database::get_main_table(TABLE_MAIN_USER_API_KEY);
2895 2901
         $sql = "SELECT * FROM $t_api WHERE user_id = $user_id AND api_service='$api_service';";
2896 2902
         $res = Database::query($sql);
2897
-        if ($res === false)
2898
-            return false; //error during query
2903
+        if ($res === false) {
2904
+                    return false;
2905
+        }
2906
+        //error during query
2899 2907
         $num = Database::num_rows($res);
2900
-        if ($num == 0)
2901
-            return false;
2908
+        if ($num == 0) {
2909
+                    return false;
2910
+        }
2902 2911
         $list = array();
2903 2912
         while ($row = Database::fetch_array($res)) {
2904 2913
             $list[$row['id']] = $row['api_key'];
@@ -2913,13 +2922,15 @@  discard block
 block discarded – undo
2913 2922
      */
2914 2923
     public static function add_api_key($user_id = null, $api_service = 'dokeos')
2915 2924
     {
2916
-        if ($user_id != strval(intval($user_id)))
2917
-            return false;
2925
+        if ($user_id != strval(intval($user_id))) {
2926
+                    return false;
2927
+        }
2918 2928
         if (empty($user_id)) {
2919 2929
             $user_id = api_get_user_id();
2920 2930
         }
2921
-        if ($user_id === false)
2922
-            return false;
2931
+        if ($user_id === false) {
2932
+                    return false;
2933
+        }
2923 2934
         $service_name = Database::escape_string($api_service);
2924 2935
         if (is_string($service_name) === false) {
2925 2936
             return false;
@@ -2928,8 +2939,10 @@  discard block
 block discarded – undo
2928 2939
         $md5 = md5((time() + ($user_id * 5)) - rand(10000, 10000)); //generate some kind of random key
2929 2940
         $sql = "INSERT INTO $t_api (user_id, api_key,api_service) VALUES ($user_id,'$md5','$service_name')";
2930 2941
         $res = Database::query($sql);
2931
-        if ($res === false)
2932
-            return false; //error during query
2942
+        if ($res === false) {
2943
+                    return false;
2944
+        }
2945
+        //error during query
2933 2946
         $num = Database::insert_id();
2934 2947
         return ($num == 0) ? false : $num;
2935 2948
     }
@@ -2941,22 +2954,29 @@  discard block
 block discarded – undo
2941 2954
      */
2942 2955
     public static function delete_api_key($key_id)
2943 2956
     {
2944
-        if ($key_id != strval(intval($key_id)))
2945
-            return false;
2946
-        if ($key_id === false)
2947
-            return false;
2957
+        if ($key_id != strval(intval($key_id))) {
2958
+                    return false;
2959
+        }
2960
+        if ($key_id === false) {
2961
+                    return false;
2962
+        }
2948 2963
         $t_api = Database::get_main_table(TABLE_MAIN_USER_API_KEY);
2949 2964
         $sql = "SELECT * FROM $t_api WHERE id = ".$key_id;
2950 2965
         $res = Database::query($sql);
2951
-        if ($res === false)
2952
-            return false; //error during query
2966
+        if ($res === false) {
2967
+                    return false;
2968
+        }
2969
+        //error during query
2953 2970
         $num = Database::num_rows($res);
2954
-        if ($num !== 1)
2955
-            return false;
2971
+        if ($num !== 1) {
2972
+                    return false;
2973
+        }
2956 2974
         $sql = "DELETE FROM $t_api WHERE id = ".$key_id;
2957 2975
         $res = Database::query($sql);
2958
-        if ($res === false)
2959
-            return false; //error during query
2976
+        if ($res === false) {
2977
+                    return false;
2978
+        }
2979
+        //error during query
2960 2980
         return true;
2961 2981
     }
2962 2982
 
@@ -2968,10 +2988,12 @@  discard block
 block discarded – undo
2968 2988
      */
2969 2989
     public static function update_api_key($user_id, $api_service)
2970 2990
     {
2971
-        if ($user_id != strval(intval($user_id)))
2972
-            return false;
2973
-        if ($user_id === false)
2974
-            return false;
2991
+        if ($user_id != strval(intval($user_id))) {
2992
+                    return false;
2993
+        }
2994
+        if ($user_id === false) {
2995
+                    return false;
2996
+        }
2975 2997
         $service_name = Database::escape_string($api_service);
2976 2998
         if (is_string($service_name) === false) {
2977 2999
             return false;
@@ -2997,12 +3019,15 @@  discard block
 block discarded – undo
2997 3019
      */
2998 3020
     public static function get_api_key_id($user_id, $api_service)
2999 3021
     {
3000
-        if ($user_id != strval(intval($user_id)))
3001
-            return false;
3002
-        if ($user_id === false)
3003
-            return false;
3004
-        if (empty($api_service))
3005
-            return false;
3022
+        if ($user_id != strval(intval($user_id))) {
3023
+                    return false;
3024
+        }
3025
+        if ($user_id === false) {
3026
+                    return false;
3027
+        }
3028
+        if (empty($api_service)) {
3029
+                    return false;
3030
+        }
3006 3031
         $t_api = Database::get_main_table(TABLE_MAIN_USER_API_KEY);
3007 3032
         $api_service = Database::escape_string($api_service);
3008 3033
         $sql = "SELECT id FROM $t_api WHERE user_id=".$user_id." AND api_service='".$api_service."'";
@@ -4473,8 +4498,9 @@  discard block
 block discarded – undo
4473 4498
                     $form->applyFilter('extra_'.$field_details[1], 'stripslashes');
4474 4499
                     $form->applyFilter('extra_'.$field_details[1], 'trim');
4475 4500
                     if (!$admin_permissions) {
4476
-                        if ($field_details[7] == 0)
4477
-                            $form->freeze('extra_'.$field_details[1]);
4501
+                        if ($field_details[7] == 0) {
4502
+                                                    $form->freeze('extra_'.$field_details[1]);
4503
+                        }
4478 4504
                     }
4479 4505
                     break;
4480 4506
                 case ExtraField::FIELD_TYPE_RADIO:
@@ -4491,8 +4517,9 @@  discard block
 block discarded – undo
4491 4517
                     }
4492 4518
                     $form->addGroup($group, 'extra_'.$field_details[1], $field_details[3], '');
4493 4519
                     if (!$admin_permissions) {
4494
-                        if ($field_details[7] == 0)
4495
-                            $form->freeze('extra_'.$field_details[1]);
4520
+                        if ($field_details[7] == 0) {
4521
+                                                    $form->freeze('extra_'.$field_details[1]);
4522
+                        }
4496 4523
                     }
4497 4524
                     break;
4498 4525
                 case ExtraField::FIELD_TYPE_SELECT:
@@ -4530,8 +4557,9 @@  discard block
 block discarded – undo
4530 4557
                     );
4531 4558
 
4532 4559
                     if (!$admin_permissions) {
4533
-                        if ($field_details[7] == 0)
4534
-                            $form->freeze('extra_'.$field_details[1]);
4560
+                        if ($field_details[7] == 0) {
4561
+                                                    $form->freeze('extra_'.$field_details[1]);
4562
+                        }
4535 4563
                     }
4536 4564
                     break;
4537 4565
                 case ExtraField::FIELD_TYPE_SELECT_MULTIPLE:
@@ -4547,8 +4575,9 @@  discard block
 block discarded – undo
4547 4575
                         array('multiple' => 'multiple')
4548 4576
                     );
4549 4577
                     if (!$admin_permissions) {
4550
-                        if ($field_details[7] == 0)
4551
-                            $form->freeze('extra_'.$field_details[1]);
4578
+                        if ($field_details[7] == 0) {
4579
+                                                    $form->freeze('extra_'.$field_details[1]);
4580
+                        }
4552 4581
                     }
4553 4582
                     break;
4554 4583
                 case ExtraField::FIELD_TYPE_DATE:
@@ -4556,8 +4585,9 @@  discard block
 block discarded – undo
4556 4585
                     $defaults['extra_'.$field_details[1]] = date('Y-m-d 12:00:00');
4557 4586
                     $form->setDefaults($defaults);
4558 4587
                     if (!$admin_permissions) {
4559
-                        if ($field_details[7] == 0)
4560
-                            $form->freeze('extra_'.$field_details[1]);
4588
+                        if ($field_details[7] == 0) {
4589
+                                                    $form->freeze('extra_'.$field_details[1]);
4590
+                        }
4561 4591
                     }
4562 4592
                     $form->applyFilter('theme', 'trim');
4563 4593
                     break;
@@ -4566,8 +4596,9 @@  discard block
 block discarded – undo
4566 4596
                     $defaults['extra_'.$field_details[1]] = date('Y-m-d 12:00:00');
4567 4597
                     $form->setDefaults($defaults);
4568 4598
                     if (!$admin_permissions) {
4569
-                        if ($field_details[7] == 0)
4570
-                            $form->freeze('extra_'.$field_details[1]);
4599
+                        if ($field_details[7] == 0) {
4600
+                                                    $form->freeze('extra_'.$field_details[1]);
4601
+                        }
4571 4602
                     }
4572 4603
                     $form->applyFilter('theme', 'trim');
4573 4604
                     break;
@@ -4586,8 +4617,9 @@  discard block
 block discarded – undo
4586 4617
                     $form->addGroup($group, 'extra_'.$field_details[1], $field_details[3], '&nbsp;');
4587 4618
 
4588 4619
                     if (!$admin_permissions) {
4589
-                        if ($field_details[7] == 0)
4590
-                            $form->freeze('extra_'.$field_details[1]);
4620
+                        if ($field_details[7] == 0) {
4621
+                                                    $form->freeze('extra_'.$field_details[1]);
4622
+                        }
4591 4623
                     }
4592 4624
 
4593 4625
                     /* Recoding the selected values for double : if the user has
@@ -4647,8 +4679,9 @@  discard block
 block discarded – undo
4647 4679
                     break;
4648 4680
                 case ExtraField::FIELD_TYPE_TIMEZONE:
4649 4681
                     $form->addElement('select', 'extra_'.$field_details[1], $field_details[3], api_get_timezones(), '');
4650
-                    if ($field_details[7] == 0)
4651
-                        $form->freeze('extra_'.$field_details[1]);
4682
+                    if ($field_details[7] == 0) {
4683
+                                            $form->freeze('extra_'.$field_details[1]);
4684
+                    }
4652 4685
                     break;
4653 4686
                 case ExtraField::FIELD_TYPE_SOCIAL_PROFILE:
4654 4687
                     // get the social network's favicon
@@ -4673,8 +4706,9 @@  discard block
 block discarded – undo
4673 4706
                     );
4674 4707
                     $form->applyFilter('extra_'.$field_details[1], 'stripslashes');
4675 4708
                     $form->applyFilter('extra_'.$field_details[1], 'trim');
4676
-                    if ($field_details[7] == 0)
4677
-                        $form->freeze('extra_'.$field_details[1]);
4709
+                    if ($field_details[7] == 0) {
4710
+                                            $form->freeze('extra_'.$field_details[1]);
4711
+                    }
4678 4712
                     break;
4679 4713
                 case ExtraField::FIELD_TYPE_FILE:
4680 4714
                     $extra_field = 'extra_'.$field_details[1];
@@ -4991,8 +5025,9 @@  discard block
 block discarded – undo
4991 5025
         $url .= "?s=$s&d=$d&r=$r";
4992 5026
         if ( $img ) {
4993 5027
             $url = '<img src="' . $url . '"';
4994
-            foreach ( $atts as $key => $val )
4995
-                $url .= ' ' . $key . '="' . $val . '"';
5028
+            foreach ( $atts as $key => $val ) {
5029
+                            $url .= ' ' . $key . '="' . $val . '"';
5030
+            }
4996 5031
             $url .= ' />';
4997 5032
         }
4998 5033
         return $url;
Please login to merge, or discard this patch.
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
     const USER_FIELD_TYPE_TIMEZONE = 11;
35 35
     const USER_FIELD_TYPE_SOCIAL_PROFILE = 12;
36 36
     const USER_FIELD_TYPE_FILE = 13;
37
-    const USER_FIELD_TYPE_MOBILE_PHONE_NUMBER  = 14;
37
+    const USER_FIELD_TYPE_MOBILE_PHONE_NUMBER = 14;
38 38
 
39 39
     private static $encryptionMethod;
40 40
 
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
         }
281 281
 
282 282
         if (empty($password)) {
283
-            Display::addFlash(Display::return_message(get_lang('ThisFieldIsRequired').': '.get_lang('Password') , 'warning'));
283
+            Display::addFlash(Display::return_message(get_lang('ThisFieldIsRequired').': '.get_lang('Password'), 'warning'));
284 284
 
285 285
             return false;
286 286
         }
@@ -494,7 +494,7 @@  discard block
 block discarded – undo
494 494
         $res = Database::query($sql);
495 495
         while ($course = Database::fetch_object($res)) {
496 496
             $sql = "SELECT id FROM $table_course_user
497
-                    WHERE status=1 AND c_id = " . intval($course->c_id);
497
+                    WHERE status=1 AND c_id = ".intval($course->c_id);
498 498
             $res2 = Database::query($sql);
499 499
             if (Database::num_rows($res2) == 1) {
500 500
 
@@ -758,7 +758,7 @@  discard block
 block discarded – undo
758 758
         $sql = "UPDATE $table_user SET active = 1 WHERE id IN ($ids)";
759 759
         $r = Database::query($sql);
760 760
         if ($r !== false) {
761
-            Event::addEvent(LOG_USER_ENABLE,LOG_USER_ID,$ids);
761
+            Event::addEvent(LOG_USER_ENABLE, LOG_USER_ID, $ids);
762 762
         }
763 763
         return $r;
764 764
     }
@@ -1164,7 +1164,7 @@  discard block
 block discarded – undo
1164 1164
             // 1. Conversion of unacceptable letters (latinian letters with accents for example) into ASCII letters in order they not to be totally removed.
1165 1165
             // 2. Applying the strict purifier.
1166 1166
             // 3. Length limitation.
1167
-            $return  = api_get_setting('login_is_email') == 'true' ? substr(preg_replace(USERNAME_PURIFIER_MAIL, '', $username), 0, USERNAME_MAX_LENGTH) : substr(preg_replace(USERNAME_PURIFIER, '', $username), 0, USERNAME_MAX_LENGTH);
1167
+            $return = api_get_setting('login_is_email') == 'true' ? substr(preg_replace(USERNAME_PURIFIER_MAIL, '', $username), 0, USERNAME_MAX_LENGTH) : substr(preg_replace(USERNAME_PURIFIER, '', $username), 0, USERNAME_MAX_LENGTH);
1168 1168
             $return = URLify::transliterate($return);
1169 1169
             return $return;
1170 1170
         }
@@ -1256,12 +1256,12 @@  discard block
 block discarded – undo
1256 1256
 
1257 1257
         if (!is_null($order)) {
1258 1258
             $order = Database::escape_string($order);
1259
-            $sql .= ' ORDER BY ' . $order;
1259
+            $sql .= ' ORDER BY '.$order;
1260 1260
         }
1261 1261
 
1262 1262
         if (!is_null($limit)) {
1263 1263
             $limit = Database::escape_string($limit);
1264
-            $sql .= ' LIMIT ' . $limit;
1264
+            $sql .= ' LIMIT '.$limit;
1265 1265
         }
1266 1266
 
1267 1267
         $rs = Database::query($sql);
@@ -1443,7 +1443,7 @@  discard block
 block discarded – undo
1443 1443
             // In exceptional cases, on some portals, the intermediate base user
1444 1444
             // directory might not have been created. Make sure it is before
1445 1445
             // going further.
1446
-            $rootPath = api_get_path(SYS_UPLOAD_PATH) . 'users/' . substr((string) $id, 0, 1);
1446
+            $rootPath = api_get_path(SYS_UPLOAD_PATH).'users/'.substr((string) $id, 0, 1);
1447 1447
             if (!is_dir($rootPath)) {
1448 1448
                 $perm = api_get_permissions_for_new_directories();
1449 1449
                 try {
@@ -1695,7 +1695,7 @@  discard block
 block discarded – undo
1695 1695
         $path_info = self::get_user_picture_path_by_id($user_id, 'system');
1696 1696
         $path = $path_info['dir'];
1697 1697
         if (!empty($extra_field)) {
1698
-            $path .= $extra_field . '/';
1698
+            $path .= $extra_field.'/';
1699 1699
         }
1700 1700
         // If this directory does not exist - we create it.
1701 1701
         if (!file_exists($path)) {
@@ -1703,7 +1703,7 @@  discard block
 block discarded – undo
1703 1703
         }
1704 1704
 
1705 1705
         if (filter_extension($file)) {
1706
-            if (@move_uploaded_file($source_file,$path.$file)) {
1706
+            if (@move_uploaded_file($source_file, $path.$file)) {
1707 1707
                 if ($extra_field) {
1708 1708
                     return $extra_field.'/'.$file;
1709 1709
                 } else {
@@ -1956,10 +1956,10 @@  discard block
 block discarded – undo
1956 1956
         if (count($extra_files) > 0) {
1957 1957
             $extra_file_list = '<div class="files-production"><ul id="productions">';
1958 1958
             foreach ($extra_files as $file) {
1959
-                $filename = substr($file,strlen($extra_field)+1);
1959
+                $filename = substr($file, strlen($extra_field) + 1);
1960 1960
                 $extra_file_list .= '<li>'.Display::return_icon('archive.png').'<a href="'.$path.$extra_field.'/'.urlencode($filename).'" target="_blank">'.htmlentities($filename).'</a> ';
1961 1961
                 if ($showdelete) {
1962
-                    $extra_file_list .= '<input style="width:16px;" type="image" name="remove_extra_' . $extra_field . '['.urlencode($file).']" src="'.$del_image.'" alt="'.$del_text.'" title="'.$del_text.' '.htmlentities($filename).'" onclick="javascript: return confirmation(\''.htmlentities($filename).'\');" /></li>';
1962
+                    $extra_file_list .= '<input style="width:16px;" type="image" name="remove_extra_'.$extra_field.'['.urlencode($file).']" src="'.$del_image.'" alt="'.$del_text.'" title="'.$del_text.' '.htmlentities($filename).'" onclick="javascript: return confirmation(\''.htmlentities($filename).'\');" /></li>';
1963 1963
                 }
1964 1964
             }
1965 1965
             $extra_file_list .= '</ul></div>';
@@ -2546,7 +2546,7 @@  discard block
 block discarded – undo
2546 2546
 
2547 2547
         if (api_is_allowed_to_create_course()) {
2548 2548
             $sessionListFromCourseCoach = array();
2549
-            $sql =" SELECT DISTINCT session_id
2549
+            $sql = " SELECT DISTINCT session_id
2550 2550
                     FROM $tbl_session_course_user
2551 2551
                     WHERE user_id = $user_id AND status = 2 ";
2552 2552
 
@@ -2554,7 +2554,7 @@  discard block
 block discarded – undo
2554 2554
             if (Database::num_rows($result)) {
2555 2555
                 $result = Database::store_result($result);
2556 2556
                 foreach ($result as $session) {
2557
-                    $sessionListFromCourseCoach[]= $session['session_id'];
2557
+                    $sessionListFromCourseCoach[] = $session['session_id'];
2558 2558
                 }
2559 2559
             }
2560 2560
             if (!empty($sessionListFromCourseCoach)) {
@@ -2577,7 +2577,7 @@  discard block
 block discarded – undo
2577 2577
                 ORDER BY access_start_date, access_end_date, name";
2578 2578
 
2579 2579
         $result = Database::query($sql);
2580
-        if (Database::num_rows($result)>0) {
2580
+        if (Database::num_rows($result) > 0) {
2581 2581
             while ($row = Database::fetch_assoc($result)) {
2582 2582
                 $sessions[$row['id']] = $row;
2583 2583
             }
@@ -2593,7 +2593,7 @@  discard block
 block discarded – undo
2593 2593
                 ORDER BY access_start_date, access_end_date, name";
2594 2594
 
2595 2595
         $result = Database::query($sql);
2596
-        if (Database::num_rows($result)>0) {
2596
+        if (Database::num_rows($result) > 0) {
2597 2597
             while ($row = Database::fetch_assoc($result)) {
2598 2598
                 if (empty($sessions[$row['id']])) {
2599 2599
                     $sessions[$row['id']] = $row;
@@ -3585,13 +3585,13 @@  discard block
 block discarded – undo
3585 3585
         $useExtraFields = false;
3586 3586
         $extraFields = UserManager::get_extra_filtrable_fields();
3587 3587
         $extraFieldResult = array();
3588
-        if (is_array($extraFields) && count($extraFields)>0 ) {
3588
+        if (is_array($extraFields) && count($extraFields) > 0) {
3589 3589
             foreach ($extraFields as $extraField) {
3590 3590
                 $varName = 'field_'.$extraField['variable'];
3591 3591
                 if (UserManager::is_extra_field_available($extraField['variable'])) {
3592
-                    if (isset($_GET[$varName]) && $_GET[$varName]!='0') {
3592
+                    if (isset($_GET[$varName]) && $_GET[$varName] != '0') {
3593 3593
                         $useExtraFields = true;
3594
-                        $extraFieldResult[]= UserManager::get_extra_user_data_by_value(
3594
+                        $extraFieldResult[] = UserManager::get_extra_user_data_by_value(
3595 3595
                             $extraField['variable'],
3596 3596
                             $_GET[$varName]
3597 3597
                         );
@@ -3602,17 +3602,17 @@  discard block
 block discarded – undo
3602 3602
 
3603 3603
         if ($useExtraFields) {
3604 3604
             $finalResult = array();
3605
-            if (count($extraFieldResult)>1) {
3606
-                for ($i=0; $i < count($extraFieldResult) -1; $i++) {
3607
-                    if (is_array($extraFieldResult[$i+1])) {
3608
-                        $finalResult  = array_intersect($extraFieldResult[$i], $extraFieldResult[$i+1]);
3605
+            if (count($extraFieldResult) > 1) {
3606
+                for ($i = 0; $i < count($extraFieldResult) - 1; $i++) {
3607
+                    if (is_array($extraFieldResult[$i + 1])) {
3608
+                        $finalResult = array_intersect($extraFieldResult[$i], $extraFieldResult[$i + 1]);
3609 3609
                     }
3610 3610
                 }
3611 3611
             } else {
3612 3612
                 $finalResult = $extraFieldResult[0];
3613 3613
             }
3614 3614
 
3615
-            if (is_array($finalResult) && count($finalResult)>0) {
3615
+            if (is_array($finalResult) && count($finalResult) > 0) {
3616 3616
                 $whereFilter = " AND u.id IN  ('".implode("','", $finalResult)."') ";
3617 3617
             } else {
3618 3618
                 //no results
@@ -3785,7 +3785,7 @@  discard block
 block discarded – undo
3785 3785
             $sql = 'DELETE FROM '.$tbl_my_friend.'
3786 3786
                     WHERE relation_type <> '.USER_RELATION_TYPE_RRHH.' AND friend_user_id='.$friend_id.' '.$extra_condition;
3787 3787
             Database::query($sql);
3788
-            $sql= 'DELETE FROM '.$tbl_my_friend.'
3788
+            $sql = 'DELETE FROM '.$tbl_my_friend.'
3789 3789
                    WHERE relation_type <> '.USER_RELATION_TYPE_RRHH.' AND user_id='.$friend_id.' '.$extra_condition;
3790 3790
             Database::query($sql);
3791 3791
         } else {
@@ -3986,7 +3986,7 @@  discard block
 block discarded – undo
3986 3986
 
3987 3987
         if (!empty($lastConnectionDate)) {
3988 3988
             $lastConnectionDate = Database::escape_string($lastConnectionDate);
3989
-            $userConditions .=  " AND u.last_login <= '$lastConnectionDate' ";
3989
+            $userConditions .= " AND u.last_login <= '$lastConnectionDate' ";
3990 3990
         }
3991 3991
 
3992 3992
         $courseConditions = null;
@@ -4053,7 +4053,7 @@  discard block
 block discarded – undo
4053 4053
                 break;
4054 4054
             case STUDENT_BOSS :
4055 4055
                 $drhConditions = " AND friend_user_id = $userId AND "
4056
-                . "relation_type = " . USER_RELATION_TYPE_BOSS;
4056
+                . "relation_type = ".USER_RELATION_TYPE_BOSS;
4057 4057
                 break;
4058 4058
         }
4059 4059
 
@@ -4144,7 +4144,7 @@  discard block
 block discarded – undo
4144 4144
                     WHERE 
4145 4145
                         friend_user_id = $userId AND 
4146 4146
                         relation_type = $relationType AND 
4147
-                        access_url_id = " . api_get_current_access_url_id();
4147
+                        access_url_id = ".api_get_current_access_url_id();
4148 4148
         } else {
4149 4149
             $sql = "SELECT user_id FROM $userRelUserTable 
4150 4150
                     WHERE friend_user_id = $userId 
@@ -4426,7 +4426,7 @@  discard block
 block discarded – undo
4426 4426
         if (empty($years)) {
4427 4427
             $years = 1;
4428 4428
         }
4429
-        $inactive_time = $years * 31536000;  //1 year
4429
+        $inactive_time = $years * 31536000; //1 year
4430 4430
         $rs = Database::query($sql);
4431 4431
         if (Database::num_rows($rs) > 0) {
4432 4432
             if ($last_login_date = Database::result($rs, 0, 0)) {
@@ -4559,7 +4559,7 @@  discard block
 block discarded – undo
4559 4559
                         'extra_'.$field_details[1],
4560 4560
                         $field_details[3],
4561 4561
                         $options,
4562
-                        array('id' => 'extra_' . $field_details[1])
4562
+                        array('id' => 'extra_'.$field_details[1])
4563 4563
                     );
4564 4564
 
4565 4565
                     if (!$admin_permissions) {
@@ -4713,7 +4713,7 @@  discard block
 block discarded – undo
4713 4713
                     $extra_field = 'extra_'.$field_details[1];
4714 4714
                     $form->addElement('file', $extra_field, $field_details[3], null, '');
4715 4715
                     if ($extra_file_list = UserManager::build_user_extra_file_list($user_id, $field_details[1], '', true)) {
4716
-                        $form->addElement('static', $extra_field . '_list', null, $extra_file_list);
4716
+                        $form->addElement('static', $extra_field.'_list', null, $extra_file_list);
4717 4717
                     }
4718 4718
                     if ($field_details[7] == 0) {
4719 4719
                         $form->freeze($extra_field);
@@ -4881,7 +4881,7 @@  discard block
 block discarded – undo
4881 4881
         $direction = null,
4882 4882
         $active = null,
4883 4883
         $lastConnectionDate = null
4884
-    ){
4884
+    ) {
4885 4885
         return self::getUsersFollowedByUser(
4886 4886
             $userId,
4887 4887
             $userStatus,
@@ -5088,12 +5088,12 @@  discard block
 block discarded – undo
5088 5088
         if (!empty($_SERVER['HTTPS'])) {
5089 5089
             $url = 'https://secure.gravatar.com/avatar/';
5090 5090
         }
5091
-        $url .= md5( strtolower( trim( $email ) ) );
5091
+        $url .= md5(strtolower(trim($email)));
5092 5092
         $url .= "?s=$s&d=$d&r=$r";
5093
-        if ( $img ) {
5094
-            $url = '<img src="' . $url . '"';
5095
-            foreach ( $atts as $key => $val )
5096
-                $url .= ' ' . $key . '="' . $val . '"';
5093
+        if ($img) {
5094
+            $url = '<img src="'.$url.'"';
5095
+            foreach ($atts as $key => $val)
5096
+                $url .= ' '.$key.'="'.$val.'"';
5097 5097
             $url .= ' />';
5098 5098
         }
5099 5099
         return $url;
Please login to merge, or discard this patch.
main/inc/lib/VideoChat.php 1 patch
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@
 block discarded – undo
43 43
      * Create a video chat
44 44
      * @param int $fromUser The sender user
45 45
      * @param int $toUser The receiver user
46
-     * @return int The created video chat id. Otherwise return false
46
+     * @return false|string The created video chat id. Otherwise return false
47 47
      */
48 48
     public static function createRoom($fromUser, $toUser)
49 49
     {
Please login to merge, or discard this patch.
main/inc/lib/xajax/xajax.inc.php 4 patches
Doc Comments   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -500,7 +500,7 @@  discard block
 block discarded – undo
500 500
 	 * Returns the current request mode (XAJAX_GET or XAJAX_POST), or -1 if
501 501
 	 * there is none.
502 502
 	 *
503
-	 * @return mixed
503
+	 * @return integer
504 504
 	 */
505 505
 	function getRequestMode()
506 506
 	{
@@ -1018,6 +1018,7 @@  discard block
 block discarded – undo
1018 1018
 	 *
1019 1019
 	 * @param string the root tag of the XML
1020 1020
 	 * @param string XML to convert
1021
+	 * @param string $rootTag
1021 1022
 	 * @access private
1022 1023
 	 * @return array
1023 1024
 	 */
Please login to merge, or discard this patch.
Braces   +84 added lines, -86 removed lines patch added patch discarded remove patch
@@ -173,8 +173,9 @@  discard block
 block discarded – undo
173 173
 		$this->aObjects = array();
174 174
 		$this->aFunctionIncludeFiles = array();
175 175
 		$this->sRequestURI = $sRequestURI;
176
-		if ($this->sRequestURI == "")
177
-			$this->sRequestURI = $this->_detectURI();
176
+		if ($this->sRequestURI == "") {
177
+					$this->sRequestURI = $this->_detectURI();
178
+		}
178 179
 		$this->sWrapperPrefix = $sWrapperPrefix;
179 180
 		$this->bDebug = $bDebug;
180 181
 		$this->bStatusMessages = false;
@@ -399,8 +400,7 @@  discard block
 block discarded – undo
399 400
 			$this->aFunctions[$mFunction[0]] = 1;
400 401
 			$this->aFunctionRequestTypes[$mFunction[0]] = $sRequestType;
401 402
 			$this->aObjects[$mFunction[0]] = array_slice($mFunction, 1);
402
-		}
403
-		else {
403
+		} else {
404 404
 			$this->aFunctions[$mFunction] = 1;
405 405
 			$this->aFunctionRequestTypes[$mFunction] = $sRequestType;
406 406
 		}
@@ -426,8 +426,7 @@  discard block
 block discarded – undo
426 426
 
427 427
 		if (is_array($mFunction)) {
428 428
 			$this->aFunctionIncludeFiles[$mFunction[0]] = $sIncludeFile;
429
-		}
430
-		else {
429
+		} else {
431 430
 			$this->aFunctionIncludeFiles[$mFunction] = $sIncludeFile;
432 431
 		}
433 432
 	}
@@ -451,8 +450,7 @@  discard block
 block discarded – undo
451 450
 		if (is_array($mFunction)) {
452 451
 			$this->sCatchAllFunction = $mFunction[0];
453 452
 			$this->aObjects[$mFunction[0]] = array_slice($mFunction, 1);
454
-		}
455
-		else {
453
+		} else {
456 454
 			$this->sCatchAllFunction = $mFunction;
457 455
 		}
458 456
 	}
@@ -477,8 +475,7 @@  discard block
 block discarded – undo
477 475
 		if (is_array($mFunction)) {
478 476
 			$this->sPreFunction = $mFunction[0];
479 477
 			$this->aObjects[$mFunction[0]] = array_slice($mFunction, 1);
480
-		}
481
-		else {
478
+		} else {
482 479
 			$this->sPreFunction = $mFunction;
483 480
 		}
484 481
 	}
@@ -492,7 +489,9 @@  discard block
 block discarded – undo
492 489
 	 */
493 490
 	function canProcessRequests()
494 491
 	{
495
-		if ($this->getRequestMode() != -1) return true;
492
+		if ($this->getRequestMode() != -1) {
493
+		    return true;
494
+		}
496 495
 		return false;
497 496
 	}
498 497
 
@@ -504,11 +503,13 @@  discard block
 block discarded – undo
504 503
 	 */
505 504
 	function getRequestMode()
506 505
 	{
507
-		if (!empty($_GET["xajax"]))
508
-			return XAJAX_GET;
506
+		if (!empty($_GET["xajax"])) {
507
+					return XAJAX_GET;
508
+		}
509 509
 
510
-		if (!empty($_POST["xajax"]))
511
-			return XAJAX_POST;
510
+		if (!empty($_POST["xajax"])) {
511
+					return XAJAX_POST;
512
+		}
512 513
 
513 514
 		return -1;
514 515
 	}
@@ -535,16 +536,18 @@  discard block
 block discarded – undo
535 536
 		$sResponse = "";
536 537
 
537 538
 		$requestMode = $this->getRequestMode();
538
-		if ($requestMode == -1) return;
539
+		if ($requestMode == -1) {
540
+		    return;
541
+		}
539 542
 
540 543
 		if ($requestMode == XAJAX_POST)
541 544
 		{
542 545
 			$sFunctionName = $_POST["xajax"];
543 546
 
544
-			if (!empty($_POST["xajaxargs"]))
545
-				$aArgs = $_POST["xajaxargs"];
546
-		}
547
-		else
547
+			if (!empty($_POST["xajaxargs"])) {
548
+							$aArgs = $_POST["xajaxargs"];
549
+			}
550
+		} else
548 551
 		{
549 552
 			header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
550 553
 			header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
@@ -553,8 +556,9 @@  discard block
 block discarded – undo
553 556
 
554 557
 			$sFunctionName = $_GET["xajax"];
555 558
 
556
-			if (!empty($_GET["xajaxargs"]))
557
-				$aArgs = $_GET["xajaxargs"];
559
+			if (!empty($_GET["xajaxargs"])) {
560
+							$aArgs = $_GET["xajaxargs"];
561
+			}
558 562
 		}
559 563
 
560 564
 		// Use xajax error handler if necessary
@@ -586,15 +590,13 @@  discard block
 block discarded – undo
586 590
 				if ($this->sCatchAllFunction) {
587 591
 					$sFunctionName = $this->sCatchAllFunction;
588 592
 					$bFunctionIsCatchAll = true;
589
-				}
590
-				else {
593
+				} else {
591 594
 					$bFoundFunction = false;
592 595
 					$objResponse = new xajaxResponse();
593 596
 					$objResponse->addAlert("Unknown Function $sFunctionName.");
594 597
 					$sResponse = $objResponse->getXML();
595 598
 				}
596
-			}
597
-			else if ($this->aFunctionRequestTypes[$sFunctionName] != $requestMode)
599
+			} else if ($this->aFunctionRequestTypes[$sFunctionName] != $requestMode)
598 600
 			{
599 601
 				$bFoundFunction = false;
600 602
 				$objResponse = new xajaxResponse();
@@ -615,12 +617,10 @@  discard block
 block discarded – undo
615 617
 				if (stristr($aArgs[$i],"<xjxobj>") != false)
616 618
 				{
617 619
 					$aArgs[$i] = $this->_xmlToArray("xjxobj",$aArgs[$i]);
618
-				}
619
-				else if (stristr($aArgs[$i],"<xjxquery>") != false)
620
+				} else if (stristr($aArgs[$i],"<xjxquery>") != false)
620 621
 				{
621 622
 					$aArgs[$i] = $this->_xmlToArray("xjxquery",$aArgs[$i]);
622
-				}
623
-				else if ($this->bDecodeUTF8Input)
623
+				} else if ($this->bDecodeUTF8Input)
624 624
 				{
625 625
 					$aArgs[$i] = $this->_decodeUTF8Data($aArgs[$i]);
626 626
 				}
@@ -631,14 +631,15 @@  discard block
 block discarded – undo
631 631
 				if (is_array($mPreResponse) && $mPreResponse[0] === false) {
632 632
 					$bEndRequest = true;
633 633
 					$sPreResponse = $mPreResponse[1];
634
-				}
635
-				else {
634
+				} else {
636 635
 					$sPreResponse = $mPreResponse;
637 636
 				}
638 637
 				if (is_a($sPreResponse, "xajaxResponse")) {
639 638
 					$sPreResponse = $sPreResponse->getXML();
640 639
 				}
641
-				if ($bEndRequest) $sResponse = $sPreResponse;
640
+				if ($bEndRequest) {
641
+				    $sResponse = $sPreResponse;
642
+				}
642 643
 			}
643 644
 
644 645
 			if (!$bEndRequest) {
@@ -646,8 +647,7 @@  discard block
 block discarded – undo
646 647
 					$objResponse = new xajaxResponse();
647 648
 					$objResponse->addAlert("The Registered Function $sFunctionName Could Not Be Found.");
648 649
 					$sResponse = $objResponse->getXML();
649
-				}
650
-				else {
650
+				} else {
651 651
 					if ($bFunctionIsCatchAll) {
652 652
 						$aArgs = array($sFunctionNameForSpecial, $aArgs);
653 653
 					}
@@ -660,8 +660,7 @@  discard block
 block discarded – undo
660 660
 					$objResponse = new xajaxResponse();
661 661
 					$objResponse->addAlert("No XML Response Was Returned By Function $sFunctionName.");
662 662
 					$sResponse = $objResponse->getXML();
663
-				}
664
-				else if ($sPreResponse != "") {
663
+				} else if ($sPreResponse != "") {
665 664
 					$sNewResponse = new xajaxResponse($this->sEncoding, $this->bOutputEntities);
666 665
 					$sNewResponse->loadXML($sPreResponse);
667 666
 					$sNewResponse->loadXML($sResponse);
@@ -671,8 +670,9 @@  discard block
 block discarded – undo
671 670
 		}
672 671
 
673 672
 		$sContentHeader = "Content-type: text/xml;";
674
-		if ($this->sEncoding && strlen(trim($this->sEncoding)) > 0)
675
-			$sContentHeader .= " charset=".$this->sEncoding;
673
+		if ($this->sEncoding && strlen(trim($this->sEncoding)) > 0) {
674
+					$sContentHeader .= " charset=".$this->sEncoding;
675
+		}
676 676
 		header($sContentHeader);
677 677
 		if ($this->bErrorHandler && !empty( $GLOBALS['xajaxErrorHandlerText'] )) {
678 678
 			$sErrorResponse = new xajaxResponse();
@@ -681,8 +681,7 @@  discard block
 block discarded – undo
681 681
 				$fH = @fopen($this->sLogFile, "a");
682 682
 				if (!$fH) {
683 683
 					$sErrorResponse->addAlert("** Logging Error **\n\nxajax was unable to write to the error log file:\n" . $this->sLogFile);
684
-				}
685
-				else {
684
+				} else {
686 685
 					fwrite($fH, "** xajax Error Log - " . strftime("%b %e %Y %I:%M:%S %p") . " **" . $GLOBALS['xajaxErrorHandlerText'] . "\n\n\n");
687 686
 					fclose($fH);
688 687
 				}
@@ -692,12 +691,17 @@  discard block
 block discarded – undo
692 691
 			$sResponse = $sErrorResponse->getXML();
693 692
 
694 693
 		}
695
-		if ($this->bCleanBuffer) while (@ob_end_clean());
694
+		if ($this->bCleanBuffer) {
695
+		    while (@ob_end_clean());
696
+		}
696 697
 		print $sResponse;
697
-		if ($this->bErrorHandler) restore_error_handler();
698
+		if ($this->bErrorHandler) {
699
+		    restore_error_handler();
700
+		}
698 701
 
699
-		if ($this->bExitAllowed)
700
-			exit();
702
+		if ($this->bExitAllowed) {
703
+					exit();
704
+		}
701 705
 	}
702 706
 
703 707
 	/**
@@ -806,9 +810,13 @@  discard block
 block discarded – undo
806 810
 	 */
807 811
 	function getJavascriptInclude($sJsURI="", $sJsFile=NULL)
808 812
 	{
809
-		if ($sJsFile == NULL) $sJsFile = "xajax_js/xajax.js";
813
+		if ($sJsFile == NULL) {
814
+		    $sJsFile = "xajax_js/xajax.js";
815
+		}
810 816
 
811
-		if ($sJsURI != "" && substr($sJsURI, -1) != "/") $sJsURI .= "/";
817
+		if ($sJsURI != "" && substr($sJsURI, -1) != "/") {
818
+		    $sJsURI .= "/";
819
+		}
812 820
 
813 821
 		$html = "\t<script type=\"text/javascript\" src=\"" . $sJsURI . $sJsFile . "\"></script>\n";
814 822
 		$html .= "\t<script type=\"text/javascript\">\n";
@@ -831,8 +839,7 @@  discard block
 block discarded – undo
831 839
 
832 840
 		if ($sJsFullFilename) {
833 841
 			$realJsFile = $sJsFullFilename;
834
-		}
835
-		else {
842
+		} else {
836 843
 			$realPath = realpath(dirname(__FILE__));
837 844
 			$realJsFile = $realPath . "/". $sJsFile;
838 845
 		}
@@ -849,8 +856,7 @@  discard block
 block discarded – undo
849 856
 			$fH = @fopen($realJsFile, "w");
850 857
 			if (!$fH) {
851 858
 				trigger_error("The xajax compressed javascript file could not be written in the <b>" . dirname($realJsFile) . "</b> folder. Error ", E_USER_ERROR);
852
-			}
853
-			else {
859
+			} else {
854 860
 				fwrite($fH, $compressedScript);
855 861
 				fclose($fH);
856 862
 			}
@@ -950,7 +956,9 @@  discard block
 block discarded – undo
950 956
 	 */
951 957
 	function _isObjectCallback($sFunction)
952 958
 	{
953
-		if (array_key_exists($sFunction, $this->aObjects)) return true;
959
+		if (array_key_exists($sFunction, $this->aObjects)) {
960
+		    return true;
961
+		}
954 962
 		return false;
955 963
 	}
956 964
 
@@ -967,12 +975,10 @@  discard block
 block discarded – undo
967 975
 		if ($this->_isObjectCallback($sFunction)) {
968 976
 			if (is_object($this->aObjects[$sFunction][0])) {
969 977
 				return method_exists($this->aObjects[$sFunction][0], $this->aObjects[$sFunction][1]);
970
-			}
971
-			else {
978
+			} else {
972 979
 				return is_callable($this->aObjects[$sFunction]);
973 980
 			}
974
-		}
975
-		else {
981
+		} else {
976 982
 			return function_exists($sFunction);
977 983
 		}
978 984
 	}
@@ -990,8 +996,7 @@  discard block
 block discarded – undo
990 996
 	{
991 997
 		if ($this->_isObjectCallback($sFunction)) {
992 998
 			$mReturn = call_user_func_array($this->aObjects[$sFunction], $aArgs);
993
-		}
994
-		else {
999
+		} else {
995 1000
 			$mReturn = call_user_func_array($sFunction, $aArgs);
996 1001
 		}
997 1002
 		return $mReturn;
@@ -1086,8 +1091,7 @@  discard block
 block discarded – undo
1086 1091
 								{
1087 1092
 									$value = $this->_parseObjXml("xjxobj");
1088 1093
 									$this->iPos++;
1089
-								}
1090
-								else
1094
+								} else
1091 1095
 								{
1092 1096
 									$value .= $this->aObjArray[$this->iPos];
1093 1097
 									if ($this->bDecodeUTF8Input)
@@ -1134,10 +1138,11 @@  discard block
 block discarded – undo
1134 1138
 			if (get_magic_quotes_gpc() == 1) {
1135 1139
 				$newArray = array();
1136 1140
 				foreach ($aArray as $sKey => $sValue) {
1137
-					if (is_string($sValue))
1138
-						$newArray[$sKey] = stripslashes($sValue);
1139
-					else
1140
-						$newArray[$sKey] = $sValue;
1141
+					if (is_string($sValue)) {
1142
+											$newArray[$sKey] = stripslashes($sValue);
1143
+					} else {
1144
+											$newArray[$sKey] = $sValue;
1145
+					}
1141 1146
 				}
1142 1147
 				$aArray = $newArray;
1143 1148
 			}
@@ -1166,20 +1171,18 @@  discard block
 block discarded – undo
1166 1171
 				$sFuncToUse = "api_convert_encoding";
1167 1172
 			}
1168 1173
 			//if (function_exists('iconv'))
1169
-			elseif (function_exists('iconv'))
1170
-			//
1174
+			elseif (function_exists('iconv')) {
1175
+						//
1171 1176
 			{
1172 1177
 				$sFuncToUse = "iconv";
1173 1178
 			}
1174
-			else if (function_exists('mb_convert_encoding'))
1179
+			} else if (function_exists('mb_convert_encoding'))
1175 1180
 			{
1176 1181
 				$sFuncToUse = "mb_convert_encoding";
1177
-			}
1178
-			else if ($this->sEncoding == "ISO-8859-1")
1182
+			} else if ($this->sEncoding == "ISO-8859-1")
1179 1183
 			{
1180 1184
 				$sFuncToUse = "utf8_decode";
1181
-			}
1182
-			else
1185
+			} else
1183 1186
 			{
1184 1187
 				trigger_error("The incoming xajax data could not be converted from UTF-8", E_USER_NOTICE);
1185 1188
 			}
@@ -1191,8 +1194,7 @@  discard block
 block discarded – undo
1191 1194
 					if ($sFuncToUse == "iconv")
1192 1195
 					{
1193 1196
 						$sValue = iconv("UTF-8", $this->sEncoding.'//TRANSLIT', $sValue);
1194
-					}
1195
-					else if ($sFuncToUse == "mb_convert_encoding")
1197
+					} else if ($sFuncToUse == "mb_convert_encoding")
1196 1198
 					{
1197 1199
 						$sValue = mb_convert_encoding($sValue, $this->sEncoding, "UTF-8");
1198 1200
 					}
@@ -1221,27 +1223,23 @@  discard block
 block discarded – undo
1221 1223
 function xajaxErrorHandler($errno, $errstr, $errfile, $errline)
1222 1224
 {
1223 1225
 	$errorReporting = error_reporting();
1224
-	if (($errno & $errorReporting) == 0) return;
1226
+	if (($errno & $errorReporting) == 0) {
1227
+	    return;
1228
+	}
1225 1229
 
1226 1230
 	if ($errno == E_NOTICE) {
1227 1231
 		$errTypeStr = "NOTICE";
1228
-	}
1229
-	else if ($errno == E_WARNING) {
1232
+	} else if ($errno == E_WARNING) {
1230 1233
 		$errTypeStr = "WARNING";
1231
-	}
1232
-	else if ($errno == E_USER_NOTICE) {
1234
+	} else if ($errno == E_USER_NOTICE) {
1233 1235
 		$errTypeStr = "USER NOTICE";
1234
-	}
1235
-	else if ($errno == E_USER_WARNING) {
1236
+	} else if ($errno == E_USER_WARNING) {
1236 1237
 		$errTypeStr = "USER WARNING";
1237
-	}
1238
-	else if ($errno == E_USER_ERROR) {
1238
+	} else if ($errno == E_USER_ERROR) {
1239 1239
 		$errTypeStr = "USER FATAL ERROR";
1240
-	}
1241
-	else if ($errno == E_STRICT) {
1240
+	} else if ($errno == E_STRICT) {
1242 1241
 		return;
1243
-	}
1244
-	else {
1242
+	} else {
1245 1243
 		$errTypeStr = "UNKNOWN: $errno";
1246 1244
 	}
1247 1245
 	$GLOBALS['xajaxErrorHandlerText'] .= "\n----\n[$errTypeStr] $errstr\nerror in line $errline of file $errfile";
Please login to merge, or discard this patch.
Spacing   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -45,21 +45,21 @@  discard block
 block discarded – undo
45 45
  * Define XAJAX_DEFAULT_CHAR_ENCODING that is used by both
46 46
  * the xajax and xajaxResponse classes
47 47
  */
48
-if (!defined ('XAJAX_DEFAULT_CHAR_ENCODING'))
48
+if (!defined('XAJAX_DEFAULT_CHAR_ENCODING'))
49 49
 {
50
-	define ('XAJAX_DEFAULT_CHAR_ENCODING', 'utf-8' );
50
+	define('XAJAX_DEFAULT_CHAR_ENCODING', 'utf-8');
51 51
 }
52 52
 
53 53
 /**
54 54
  * Communication Method Defines
55 55
  */
56
-if (!defined ('XAJAX_GET'))
56
+if (!defined('XAJAX_GET'))
57 57
 {
58
-	define ('XAJAX_GET', 0);
58
+	define('XAJAX_GET', 0);
59 59
 }
60
-if (!defined ('XAJAX_POST'))
60
+if (!defined('XAJAX_POST'))
61 61
 {
62
-	define ('XAJAX_POST', 1);
62
+	define('XAJAX_POST', 1);
63 63
 }
64 64
 
65 65
 /**
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 	 * @param string  defaults to XAJAX_DEFAULT_CHAR_ENCODING defined above
168 168
 	 * @param boolean defaults to false
169 169
 	 */
170
-	public function __construct($sRequestURI="",$sWrapperPrefix="xajax_",$sEncoding=XAJAX_DEFAULT_CHAR_ENCODING,$bDebug=false)
170
+	public function __construct($sRequestURI = "", $sWrapperPrefix = "xajax_", $sEncoding = XAJAX_DEFAULT_CHAR_ENCODING, $bDebug = false)
171 171
 	{
172 172
 		$this->aFunctions = array();
173 173
 		$this->aObjects = array();
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
 	 * @param mixed  request type (XAJAX_GET/XAJAX_POST) that should be used
394 394
 	 *               for this function.  Defaults to XAJAX_POST.
395 395
 	 */
396
-	function registerFunction($mFunction,$sRequestType=XAJAX_POST)
396
+	function registerFunction($mFunction, $sRequestType = XAJAX_POST)
397 397
 	{
398 398
 		if (is_array($mFunction)) {
399 399
 			$this->aFunctions[$mFunction[0]] = 1;
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
 	 * @param mixed  the RequestType (XAJAX_GET/XAJAX_POST) that should be used
421 421
 	 *		          for this function. Defaults to XAJAX_POST.
422 422
 	 */
423
-	function registerExternalFunction($mFunction,$sIncludeFile,$sRequestType=XAJAX_POST)
423
+	function registerExternalFunction($mFunction, $sIncludeFile, $sRequestType = XAJAX_POST)
424 424
 	{
425 425
 		$this->registerFunction($mFunction, $sRequestType);
426 426
 
@@ -545,10 +545,10 @@  discard block
 block discarded – undo
545 545
 		}
546 546
 		else
547 547
 		{
548
-			header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
549
-			header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
550
-			header ("Cache-Control: no-cache, must-revalidate");
551
-			header ("Pragma: no-cache");
548
+			header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
549
+			header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
550
+			header("Cache-Control: no-cache, must-revalidate");
551
+			header("Pragma: no-cache");
552 552
 
553 553
 			$sFunctionName = $_GET["xajax"];
554 554
 
@@ -566,12 +566,12 @@  discard block
 block discarded – undo
566 566
 			if (!$this->_isFunctionCallable($this->sPreFunction)) {
567 567
 				$bFoundFunction = false;
568 568
 				$objResponse = new xajaxResponse();
569
-				$objResponse->addAlert("Unknown Pre-Function ". $this->sPreFunction);
569
+				$objResponse->addAlert("Unknown Pre-Function ".$this->sPreFunction);
570 570
 				$sResponse = $objResponse->getXML();
571 571
 			}
572 572
 		}
573 573
 		//include any external dependencies associated with this function name
574
-		if (array_key_exists($sFunctionName,$this->aFunctionIncludeFiles))
574
+		if (array_key_exists($sFunctionName, $this->aFunctionIncludeFiles))
575 575
 		{
576 576
 			ob_start();
577 577
 			include_once($this->aFunctionIncludeFiles[$sFunctionName]);
@@ -611,13 +611,13 @@  discard block
 block discarded – undo
611 611
 
612 612
 					$aArgs[$i] = stripslashes($aArgs[$i]);
613 613
 				}
614
-				if (stristr($aArgs[$i],"<xjxobj>") != false)
614
+				if (stristr($aArgs[$i], "<xjxobj>") != false)
615 615
 				{
616
-					$aArgs[$i] = $this->_xmlToArray("xjxobj",$aArgs[$i]);
616
+					$aArgs[$i] = $this->_xmlToArray("xjxobj", $aArgs[$i]);
617 617
 				}
618
-				else if (stristr($aArgs[$i],"<xjxquery>") != false)
618
+				else if (stristr($aArgs[$i], "<xjxquery>") != false)
619 619
 				{
620
-					$aArgs[$i] = $this->_xmlToArray("xjxquery",$aArgs[$i]);
620
+					$aArgs[$i] = $this->_xmlToArray("xjxquery", $aArgs[$i]);
621 621
 				}
622 622
 				else if ($this->bDecodeUTF8Input)
623 623
 				{
@@ -673,16 +673,16 @@  discard block
 block discarded – undo
673 673
 		if ($this->sEncoding && strlen(trim($this->sEncoding)) > 0)
674 674
 			$sContentHeader .= " charset=".$this->sEncoding;
675 675
 		header($sContentHeader);
676
-		if ($this->bErrorHandler && !empty( $GLOBALS['xajaxErrorHandlerText'] )) {
676
+		if ($this->bErrorHandler && !empty($GLOBALS['xajaxErrorHandlerText'])) {
677 677
 			$sErrorResponse = new xajaxResponse();
678
-			$sErrorResponse->addAlert("** PHP Error Messages: **" . $GLOBALS['xajaxErrorHandlerText']);
678
+			$sErrorResponse->addAlert("** PHP Error Messages: **".$GLOBALS['xajaxErrorHandlerText']);
679 679
 			if ($this->sLogFile) {
680 680
 				$fH = @fopen($this->sLogFile, "a");
681 681
 				if (!$fH) {
682
-					$sErrorResponse->addAlert("** Logging Error **\n\nxajax was unable to write to the error log file:\n" . $this->sLogFile);
682
+					$sErrorResponse->addAlert("** Logging Error **\n\nxajax was unable to write to the error log file:\n".$this->sLogFile);
683 683
 				}
684 684
 				else {
685
-					fwrite($fH, "** xajax Error Log - " . strftime("%b %e %Y %I:%M:%S %p") . " **" . $GLOBALS['xajaxErrorHandlerText'] . "\n\n\n");
685
+					fwrite($fH, "** xajax Error Log - ".strftime("%b %e %Y %I:%M:%S %p")." **".$GLOBALS['xajaxErrorHandlerText']."\n\n\n");
686 686
 					fclose($fH);
687 687
 				}
688 688
 			}
@@ -724,7 +724,7 @@  discard block
 block discarded – undo
724 724
 	 *               engine located within the xajax installation folder.
725 725
 	 *               Defaults to xajax_js/xajax.js.
726 726
 	 */
727
-	function printJavascript($sJsURI="", $sJsFile=NULL)
727
+	function printJavascript($sJsURI = "", $sJsFile = NULL)
728 728
 	{
729 729
 		print $this->getJavascript($sJsURI, $sJsFile);
730 730
 	}
@@ -753,7 +753,7 @@  discard block
 block discarded – undo
753 753
 	 *               Defaults to xajax_js/xajax.js.
754 754
 	 * @return string
755 755
 	 */
756
-	function getJavascript($sJsURI="", $sJsFile=NULL)
756
+	function getJavascript($sJsURI = "", $sJsFile = NULL)
757 757
 	{
758 758
 		$html = $this->getJavascriptConfig();
759 759
 		$html .= $this->getJavascriptInclude($sJsURI, $sJsFile);
@@ -771,15 +771,15 @@  discard block
 block discarded – undo
771 771
 	{
772 772
 		$html  = "\t<script type=\"text/javascript\">\n";
773 773
 		$html .= "var xajaxRequestUri=\"".$this->sRequestURI."\";\n";
774
-		$html .= "var xajaxDebug=".($this->bDebug?"true":"false").";\n";
775
-		$html .= "var xajaxStatusMessages=".($this->bStatusMessages?"true":"false").";\n";
776
-		$html .= "var xajaxWaitCursor=".($this->bWaitCursor?"true":"false").";\n";
774
+		$html .= "var xajaxDebug=".($this->bDebug ? "true" : "false").";\n";
775
+		$html .= "var xajaxStatusMessages=".($this->bStatusMessages ? "true" : "false").";\n";
776
+		$html .= "var xajaxWaitCursor=".($this->bWaitCursor ? "true" : "false").";\n";
777 777
 		$html .= "var xajaxDefinedGet=".XAJAX_GET.";\n";
778 778
 		$html .= "var xajaxDefinedPost=".XAJAX_POST.";\n";
779 779
 		$html .= "var xajaxLoaded=false;\n";
780 780
 
781
-		foreach($this->aFunctions as $sFunction => $bExists) {
782
-			$html .= $this->_wrap($sFunction,$this->aFunctionRequestTypes[$sFunction]);
781
+		foreach ($this->aFunctions as $sFunction => $bExists) {
782
+			$html .= $this->_wrap($sFunction, $this->aFunctionRequestTypes[$sFunction]);
783 783
 		}
784 784
 
785 785
 		$html .= "\t</script>\n";
@@ -803,7 +803,7 @@  discard block
 block discarded – undo
803 803
 	 *               Defaults to xajax_js/xajax.js.
804 804
 	 * @return string
805 805
 	 */
806
-	function getJavascriptInclude($sJsURI="", $sJsFile=NULL)
806
+	function getJavascriptInclude($sJsURI = "", $sJsFile = NULL)
807 807
 	{
808 808
         //if ($sJsFile == NULL) $sJsFile = "xajax_js/xajax.js";
809 809
         $sJsFile = "xajax_js/xajax.js";
@@ -811,7 +811,7 @@  discard block
 block discarded – undo
811 811
         //if ($sJsURI != "" && substr($sJsURI, -1) != "/") $sJsURI .= "/";
812 812
         $sJsURI = api_get_path(WEB_LIBRARY_JS_PATH);
813 813
 
814
-		$html = "\t<script type=\"text/javascript\" src=\"" . $sJsURI . $sJsFile . "\"></script>\n";
814
+		$html = "\t<script type=\"text/javascript\" src=\"".$sJsURI.$sJsFile."\"></script>\n";
815 815
 		$html .= "\t<script type=\"text/javascript\">\n";
816 816
 		$html .= "window.setTimeout(function () { if (!xajaxLoaded) { alert('Error: the xajax Javascript file could not be included. Perhaps the URL is incorrect?\\nURL: {$sJsURI}{$sJsFile}'); } }, 6000);\n";
817 817
 		$html .= "\t</script>\n";
@@ -826,7 +826,7 @@  discard block
 block discarded – undo
826 826
 	 * @param string an optional argument containing the full server file path
827 827
 	 *               of xajax.js.
828 828
 	 */
829
-	function autoCompressJavascript($sJsFullFilename=NULL)
829
+	function autoCompressJavascript($sJsFullFilename = NULL)
830 830
 	{
831 831
 		$sJsFile = "xajax_js/xajax.js";
832 832
 
@@ -835,21 +835,21 @@  discard block
 block discarded – undo
835 835
 		}
836 836
 		else {
837 837
 			$realPath = realpath(dirname(__FILE__));
838
-			$realJsFile = $realPath . "/". $sJsFile;
838
+			$realJsFile = $realPath."/".$sJsFile;
839 839
 		}
840 840
 
841 841
 		// Create a compressed file if necessary
842 842
 		if (!file_exists($realJsFile)) {
843 843
 			$srcFile = str_replace(".js", "_uncompressed.js", $realJsFile);
844 844
 			if (!file_exists($srcFile)) {
845
-				trigger_error("The xajax uncompressed Javascript file could not be found in the <b>" . dirname($realJsFile) . "</b> folder. Error ", E_USER_ERROR);
845
+				trigger_error("The xajax uncompressed Javascript file could not be found in the <b>".dirname($realJsFile)."</b> folder. Error ", E_USER_ERROR);
846 846
 			}
847 847
 			require(dirname(__FILE__)."/xajaxCompress.php");
848 848
 			$javaScript = implode('', file($srcFile));
849 849
 			$compressedScript = xajaxCompressJavascript($javaScript);
850 850
 			$fH = @fopen($realJsFile, "w");
851 851
 			if (!$fH) {
852
-				trigger_error("The xajax compressed javascript file could not be written in the <b>" . dirname($realJsFile) . "</b> folder. Error ", E_USER_ERROR);
852
+				trigger_error("The xajax compressed javascript file could not be written in the <b>".dirname($realJsFile)."</b> folder. Error ", E_USER_ERROR);
853 853
 			}
854 854
 			else {
855 855
 				fwrite($fH, $compressedScript);
@@ -918,23 +918,23 @@  discard block
 block discarded – undo
918 918
 		// Build the URL: Start with scheme, user and pass
919 919
 		$sURL = $aURL['scheme'].'://';
920 920
 		if (!empty($aURL['user'])) {
921
-			$sURL.= $aURL['user'];
921
+			$sURL .= $aURL['user'];
922 922
 			if (!empty($aURL['pass'])) {
923
-				$sURL.= ':'.$aURL['pass'];
923
+				$sURL .= ':'.$aURL['pass'];
924 924
 			}
925
-			$sURL.= '@';
925
+			$sURL .= '@';
926 926
 		}
927 927
 
928 928
 		// Add the host
929
-		$sURL.= $aURL['host'];
929
+		$sURL .= $aURL['host'];
930 930
 
931 931
 		// Add the port if needed
932 932
 		if (!empty($aURL['port']) && (($aURL['scheme'] == 'http' && $aURL['port'] != 80) || ($aURL['scheme'] == 'https' && $aURL['port'] != 443))) {
933
-			$sURL.= ':'.$aURL['port'];
933
+			$sURL .= ':'.$aURL['port'];
934 934
 		}
935 935
 
936 936
 		// Add the path and the query string
937
-		$sURL.= $aURL['path'].@$aURL['query'];
937
+		$sURL .= $aURL['path'].@$aURL['query'];
938 938
 
939 939
 		// Clean up
940 940
 		unset($aURL);
@@ -1006,7 +1006,7 @@  discard block
 block discarded – undo
1006 1006
 	 * @access private
1007 1007
 	 * @return string
1008 1008
 	 */
1009
-	function _wrap($sFunction,$sRequestType=XAJAX_POST)
1009
+	function _wrap($sFunction, $sRequestType = XAJAX_POST)
1010 1010
 	{
1011 1011
 		$js = "function ".$this->sWrapperPrefix."$sFunction(){return xajax.call(\"$sFunction\", arguments, ".$sRequestType.");}\n";
1012 1012
 		return $js;
@@ -1025,18 +1025,18 @@  discard block
 block discarded – undo
1025 1025
 	function _xmlToArray($rootTag, $sXml)
1026 1026
 	{
1027 1027
 		$aArray = array();
1028
-		$sXml = str_replace("<$rootTag>","<$rootTag>|~|",$sXml);
1029
-		$sXml = str_replace("</$rootTag>","</$rootTag>|~|",$sXml);
1030
-		$sXml = str_replace("<e>","<e>|~|",$sXml);
1031
-		$sXml = str_replace("</e>","</e>|~|",$sXml);
1032
-		$sXml = str_replace("<k>","<k>|~|",$sXml);
1033
-		$sXml = str_replace("</k>","|~|</k>|~|",$sXml);
1034
-		$sXml = str_replace("<v>","<v>|~|",$sXml);
1035
-		$sXml = str_replace("</v>","|~|</v>|~|",$sXml);
1036
-		$sXml = str_replace("<q>","<q>|~|",$sXml);
1037
-		$sXml = str_replace("</q>","|~|</q>|~|",$sXml);
1038
-
1039
-		$this->aObjArray = explode("|~|",$sXml);
1028
+		$sXml = str_replace("<$rootTag>", "<$rootTag>|~|", $sXml);
1029
+		$sXml = str_replace("</$rootTag>", "</$rootTag>|~|", $sXml);
1030
+		$sXml = str_replace("<e>", "<e>|~|", $sXml);
1031
+		$sXml = str_replace("</e>", "</e>|~|", $sXml);
1032
+		$sXml = str_replace("<k>", "<k>|~|", $sXml);
1033
+		$sXml = str_replace("</k>", "|~|</k>|~|", $sXml);
1034
+		$sXml = str_replace("<v>", "<v>|~|", $sXml);
1035
+		$sXml = str_replace("</v>", "|~|</v>|~|", $sXml);
1036
+		$sXml = str_replace("<q>", "<q>|~|", $sXml);
1037
+		$sXml = str_replace("</q>", "|~|</q>|~|", $sXml);
1038
+
1039
+		$this->aObjArray = explode("|~|", $sXml);
1040 1040
 
1041 1041
 		$this->iPos = 0;
1042 1042
 		$aArray = $this->_parseObjXml($rootTag);
@@ -1058,32 +1058,32 @@  discard block
 block discarded – undo
1058 1058
 
1059 1059
 		if ($rootTag == "xjxobj")
1060 1060
 		{
1061
-			while(!stristr($this->aObjArray[$this->iPos],"</xjxobj>"))
1061
+			while (!stristr($this->aObjArray[$this->iPos], "</xjxobj>"))
1062 1062
 			{
1063 1063
 				$this->iPos++;
1064
-				if(stristr($this->aObjArray[$this->iPos],"<e>"))
1064
+				if (stristr($this->aObjArray[$this->iPos], "<e>"))
1065 1065
 				{
1066 1066
 					$key = "";
1067 1067
 					$value = null;
1068 1068
 
1069 1069
 					$this->iPos++;
1070
-					while(!stristr($this->aObjArray[$this->iPos],"</e>"))
1070
+					while (!stristr($this->aObjArray[$this->iPos], "</e>"))
1071 1071
 					{
1072
-						if(stristr($this->aObjArray[$this->iPos],"<k>"))
1072
+						if (stristr($this->aObjArray[$this->iPos], "<k>"))
1073 1073
 						{
1074 1074
 							$this->iPos++;
1075
-							while(!stristr($this->aObjArray[$this->iPos],"</k>"))
1075
+							while (!stristr($this->aObjArray[$this->iPos], "</k>"))
1076 1076
 							{
1077 1077
 								$key .= $this->aObjArray[$this->iPos];
1078 1078
 								$this->iPos++;
1079 1079
 							}
1080 1080
 						}
1081
-						if(stristr($this->aObjArray[$this->iPos],"<v>"))
1081
+						if (stristr($this->aObjArray[$this->iPos], "<v>"))
1082 1082
 						{
1083 1083
 							$this->iPos++;
1084
-							while(!stristr($this->aObjArray[$this->iPos],"</v>"))
1084
+							while (!stristr($this->aObjArray[$this->iPos], "</v>"))
1085 1085
 							{
1086
-								if(stristr($this->aObjArray[$this->iPos],"<xjxobj>"))
1086
+								if (stristr($this->aObjArray[$this->iPos], "<xjxobj>"))
1087 1087
 								{
1088 1088
 									$value = $this->_parseObjXml("xjxobj");
1089 1089
 									$this->iPos++;
@@ -1102,7 +1102,7 @@  discard block
 block discarded – undo
1102 1102
 						$this->iPos++;
1103 1103
 					}
1104 1104
 
1105
-					$aArray[$key]=$value;
1105
+					$aArray[$key] = $value;
1106 1106
 				}
1107 1107
 			}
1108 1108
 		}
@@ -1111,21 +1111,21 @@  discard block
 block discarded – undo
1111 1111
 		{
1112 1112
 			$sQuery = "";
1113 1113
 			$this->iPos++;
1114
-			while(!stristr($this->aObjArray[$this->iPos],"</xjxquery>"))
1114
+			while (!stristr($this->aObjArray[$this->iPos], "</xjxquery>"))
1115 1115
 			{
1116
-				if (stristr($this->aObjArray[$this->iPos],"<q>") || stristr($this->aObjArray[$this->iPos],"</q>"))
1116
+				if (stristr($this->aObjArray[$this->iPos], "<q>") || stristr($this->aObjArray[$this->iPos], "</q>"))
1117 1117
 				{
1118 1118
 					$this->iPos++;
1119 1119
 					continue;
1120 1120
 				}
1121
-				$sQuery	.= $this->aObjArray[$this->iPos];
1121
+				$sQuery .= $this->aObjArray[$this->iPos];
1122 1122
 				$this->iPos++;
1123 1123
 			}
1124 1124
 
1125 1125
 			parse_str($sQuery, $aArray);
1126 1126
 			if ($this->bDecodeUTF8Input)
1127 1127
 			{
1128
-				foreach($aArray as $key => $value)
1128
+				foreach ($aArray as $key => $value)
1129 1129
 				{
1130 1130
 					$aArray[$key] = $this->_decodeUTF8Data($value);
1131 1131
 				}
Please login to merge, or discard this patch.
Indentation   +1165 added lines, -1165 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
  */
48 48
 if (!defined ('XAJAX_DEFAULT_CHAR_ENCODING'))
49 49
 {
50
-	define ('XAJAX_DEFAULT_CHAR_ENCODING', 'utf-8' );
50
+    define ('XAJAX_DEFAULT_CHAR_ENCODING', 'utf-8' );
51 51
 }
52 52
 
53 53
 /**
@@ -55,11 +55,11 @@  discard block
 block discarded – undo
55 55
  */
56 56
 if (!defined ('XAJAX_GET'))
57 57
 {
58
-	define ('XAJAX_GET', 0);
58
+    define ('XAJAX_GET', 0);
59 59
 }
60 60
 if (!defined ('XAJAX_POST'))
61 61
 {
62
-	define ('XAJAX_POST', 1);
62
+    define ('XAJAX_POST', 1);
63 63
 }
64 64
 
65 65
 /**
@@ -72,1145 +72,1145 @@  discard block
 block discarded – undo
72 72
  */
73 73
 class xajax
74 74
 {
75
-	/**#@+
75
+    /**#@+
76 76
 	 * @access protected
77 77
 	 */
78
-	/**
79
-	 * @var array Array of PHP functions that will be callable through javascript wrappers
80
-	 */
81
-	var $aFunctions;
82
-	/**
83
-	 * @var array Array of object callbacks that will allow Javascript to call PHP methods (key=function name)
84
-	 */
85
-	var $aObjects;
86
-	/**
87
-	 * @var array Array of RequestTypes to be used with each function (key=function name)
88
-	 */
89
-	var $aFunctionRequestTypes;
90
-	/**
91
-	 * @var array Array of Include Files for any external functions (key=function name)
92
-	 */
93
-	var $aFunctionIncludeFiles;
94
-	/**
95
-	 * @var string Name of the PHP function to call if no callable function was found
96
-	 */
97
-	var $sCatchAllFunction;
98
-	/**
99
-	 * @var string Name of the PHP function to call before any other function
100
-	 */
101
-	var $sPreFunction;
102
-	/**
103
-	 * @var string The URI for making requests to the xajax object
104
-	 */
105
-	var $sRequestURI;
106
-	/**
107
-	 * @var string The prefix to prepend to the javascript wraper function name
108
-	 */
109
-	var $sWrapperPrefix;
110
-	/**
111
-	 * @var boolean Show debug messages (default false)
112
-	 */
113
-	var $bDebug;
114
-	/**
115
-	 * @var boolean Show messages in the client browser's status bar (default false)
116
-	 */
117
-	var $bStatusMessages;
118
-	/**
119
-	 * @var boolean Allow xajax to exit after processing a request (default true)
120
-	 */
121
-	var $bExitAllowed;
122
-	/**
123
-	 * @var boolean Use wait cursor in browser (default true)
124
-	 */
125
-	var $bWaitCursor;
126
-	/**
127
-	 * @var boolean Use an special xajax error handler so the errors are sent to the browser properly (default false)
128
-	 */
129
-	var $bErrorHandler;
130
-	/**
131
-	 * @var string Specify what, if any, file xajax should log errors to (and more information in a future release)
132
-	 */
133
-	var $sLogFile;
134
-	/**
135
-	 * @var boolean Clean all output buffers before outputting response (default false)
136
-	 */
137
-	var $bCleanBuffer;
138
-	/**
139
-	 * @var string String containing the character encoding used
140
-	 */
141
-	var $sEncoding;
142
-	/**
143
-	 * @var boolean Decode input request args from UTF-8 (default false)
144
-	 */
145
-	var $bDecodeUTF8Input;
146
-	/**
147
-	 * @var boolean Convert special characters to HTML entities (default false)
148
-	 */
149
-	var $bOutputEntities;
150
-	/**
151
-	 * @var array Array for parsing complex objects
152
-	 */
153
-	var $aObjArray;
154
-	/**
155
-	 * @var integer Position in $aObjArray
156
-	 */
157
-	var $iPos;
158
-
159
-	/**#@-*/
160
-
161
-	/**
162
-	 * Constructor. You can set some extra xajax options right away or use
163
-	 * individual methods later to set options.
164
-	 *
165
-	 * @param string  defaults to the current browser URI
166
-	 * @param string  defaults to "xajax_";
167
-	 * @param string  defaults to XAJAX_DEFAULT_CHAR_ENCODING defined above
168
-	 * @param boolean defaults to false
169
-	 */
170
-	public function __construct($sRequestURI="",$sWrapperPrefix="xajax_",$sEncoding=XAJAX_DEFAULT_CHAR_ENCODING,$bDebug=false)
171
-	{
172
-		$this->aFunctions = array();
173
-		$this->aObjects = array();
174
-		$this->aFunctionIncludeFiles = array();
175
-		$this->sRequestURI = $sRequestURI;
176
-		if ($this->sRequestURI == "")
177
-			$this->sRequestURI = $this->_detectURI();
178
-		$this->sWrapperPrefix = $sWrapperPrefix;
179
-		$this->bDebug = $bDebug;
180
-		$this->bStatusMessages = false;
181
-		$this->bWaitCursor = true;
182
-		$this->bExitAllowed = true;
183
-		$this->bErrorHandler = false;
184
-		$this->sLogFile = "";
185
-		$this->bCleanBuffer = false;
186
-		$this->setCharEncoding($sEncoding);
187
-		$this->bDecodeUTF8Input = false;
188
-		$this->bOutputEntities = false;
189
-	}
190
-
191
-	/**
192
-	 * Sets the URI to which requests will be made.
193
-	 * <i>Usage:</i> <kbd>$xajax->setRequestURI("http://www.xajaxproject.org");</kbd>
194
-	 *
195
-	 * @param string the URI (can be absolute or relative) of the PHP script
196
-	 *               that will be accessed when an xajax request occurs
197
-	 */
198
-	function setRequestURI($sRequestURI)
199
-	{
200
-		$this->sRequestURI = $sRequestURI;
201
-	}
202
-
203
-	/**
204
-	 * Sets the prefix that will be appended to the Javascript wrapper
205
-	 * functions (default is "xajax_").
206
-	 *
207
-	 * @param string
208
-	 */
209
-	//
210
-	function setWrapperPrefix($sPrefix)
211
-	{
212
-		$this->sWrapperPrefix = $sPrefix;
213
-	}
214
-
215
-	/**
216
-	 * Enables debug messages for xajax.
217
-	 * */
218
-	function debugOn()
219
-	{
220
-		$this->bDebug = true;
221
-	}
222
-
223
-	/**
224
-	 * Disables debug messages for xajax (default behavior).
225
-	 */
226
-	function debugOff()
227
-	{
228
-		$this->bDebug = false;
229
-	}
230
-
231
-	/**
232
-	 * Enables messages in the browser's status bar for xajax.
233
-	 */
234
-	function statusMessagesOn()
235
-	{
236
-		$this->bStatusMessages = true;
237
-	}
238
-
239
-	/**
240
-	 * Disables messages in the browser's status bar for xajax (default behavior).
241
-	 */
242
-	function statusMessagesOff()
243
-	{
244
-		$this->bStatusMessages = false;
245
-	}
246
-
247
-	/**
248
-	 * Enables the wait cursor to be displayed in the browser (default behavior).
249
-	 */
250
-	function waitCursorOn()
251
-	{
252
-		$this->bWaitCursor = true;
253
-	}
254
-
255
-	/**
256
-	 * Disables the wait cursor to be displayed in the browser.
257
-	 */
258
-	function waitCursorOff()
259
-	{
260
-		$this->bWaitCursor = false;
261
-	}
262
-
263
-	/**
264
-	 * Enables xajax to exit immediately after processing a request and
265
-	 * sending the response back to the browser (default behavior).
266
-	 */
267
-	function exitAllowedOn()
268
-	{
269
-		$this->bExitAllowed = true;
270
-	}
271
-
272
-	/**
273
-	 * Disables xajax's default behavior of exiting immediately after
274
-	 * processing a request and sending the response back to the browser.
275
-	 */
276
-	function exitAllowedOff()
277
-	{
278
-		$this->bExitAllowed = false;
279
-	}
280
-
281
-	/**
282
-	 * Turns on xajax's error handling system so that PHP errors that occur
283
-	 * during a request are trapped and pushed to the browser in the form of
284
-	 * a Javascript alert.
285
-	 */
286
-	function errorHandlerOn()
287
-	{
288
-		$this->bErrorHandler = true;
289
-	}
290
-
291
-	/**
292
-	 * Turns off xajax's error handling system (default behavior).
293
-	 */
294
-	function errorHandlerOff()
295
-	{
296
-		$this->bErrorHandler = false;
297
-	}
298
-
299
-	/**
300
-	 * Specifies a log file that will be written to by xajax during a request
301
-	 * (used only by the error handling system at present). If you don't invoke
302
-	 * this method, or you pass in "", then no log file will be written to.
303
-	 * <i>Usage:</i> <kbd>$xajax->setLogFile("/xajax_logs/errors.log");</kbd>
304
-	 */
305
-	function setLogFile($sFilename)
306
-	{
307
-		$this->sLogFile = $sFilename;
308
-	}
309
-
310
-	/**
311
-	 * Causes xajax to clean out all output buffers before outputting a
312
-	 * response (default behavior).
313
-	 */
314
-	function cleanBufferOn()
315
-	{
316
-		$this->bCleanBuffer = true;
317
-	}
318
-	/**
319
-	 * Turns off xajax's output buffer cleaning.
320
-	 */
321
-	function cleanBufferOff()
322
-	{
323
-		$this->bCleanBuffer = false;
324
-	}
325
-
326
-	/**
327
-	 * Sets the character encoding for the HTTP output based on
328
-	 * <kbd>$sEncoding</kbd>, which is a string containing the character
329
-	 * encoding to use. You don't need to use this method normally, since the
330
-	 * character encoding for the response gets set automatically based on the
331
-	 * <kbd>XAJAX_DEFAULT_CHAR_ENCODING</kbd> constant.
332
-	 * <i>Usage:</i> <kbd>$xajax->setCharEncoding("utf-8");</kbd>
333
-	 *
334
-	 * @param string the encoding type to use (utf-8, iso-8859-1, etc.)
335
-	 */
336
-	function setCharEncoding($sEncoding)
337
-	{
338
-		$this->sEncoding = $sEncoding;
339
-	}
340
-
341
-	/**
342
-	 * Causes xajax to decode the input request args from UTF-8 to the current
343
-	 * encoding if possible. Either the iconv or mb_string extension must be
344
-	 * present for optimal functionality.
345
-	 */
346
-	function decodeUTF8InputOn()
347
-	{
348
-		$this->bDecodeUTF8Input = true;
349
-	}
350
-
351
-	/**
352
-	 * Turns off decoding the input request args from UTF-8 (default behavior).
353
-	 */
354
-	function decodeUTF8InputOff()
355
-	{
356
-		$this->bDecodeUTF8Input = false;
357
-	}
358
-
359
-	/**
360
-	 * Tells the response object to convert special characters to HTML entities
361
-	 * automatically (only works if the mb_string extension is available).
362
-	 */
363
-	function outputEntitiesOn()
364
-	{
365
-		$this->bOutputEntities = true;
366
-	}
367
-
368
-	/**
369
-	 * Tells the response object to output special characters intact. (default
370
-	 * behavior).
371
-	 */
372
-	function outputEntitiesOff()
373
-	{
374
-		$this->bOutputEntities = false;
375
-	}
376
-
377
-	/**
378
-	 * Registers a PHP function or method to be callable through xajax in your
379
-	 * Javascript. If you want to register a function, pass in the name of that
380
-	 * function. If you want to register a static class method, pass in an
381
-	 * array like so:
382
-	 * <kbd>array("myFunctionName", "myClass", "myMethod")</kbd>
383
-	 * For an object instance method, use an object variable for the second
384
-	 * array element (and in PHP 4 make sure you put an & before the variable
385
-	 * to pass the object by reference). Note: the function name is what you
386
-	 * call via Javascript, so it can be anything as long as it doesn't
387
-	 * conflict with any other registered function name.
388
-	 *
389
-	 * <i>Usage:</i> <kbd>$xajax->registerFunction("myFunction");</kbd>
390
-	 * or: <kbd>$xajax->registerFunction(array("myFunctionName", &$myObject, "myMethod"));</kbd>
391
-	 *
392
-	 * @param mixed  contains the function name or an object callback array
393
-	 * @param mixed  request type (XAJAX_GET/XAJAX_POST) that should be used
394
-	 *               for this function.  Defaults to XAJAX_POST.
395
-	 */
396
-	function registerFunction($mFunction,$sRequestType=XAJAX_POST)
397
-	{
398
-		if (is_array($mFunction)) {
399
-			$this->aFunctions[$mFunction[0]] = 1;
400
-			$this->aFunctionRequestTypes[$mFunction[0]] = $sRequestType;
401
-			$this->aObjects[$mFunction[0]] = array_slice($mFunction, 1);
402
-		}
403
-		else {
404
-			$this->aFunctions[$mFunction] = 1;
405
-			$this->aFunctionRequestTypes[$mFunction] = $sRequestType;
406
-		}
407
-	}
408
-
409
-	/**
410
-	 * Registers a PHP function to be callable through xajax which is located
411
-	 * in some other file.  If the function is requested the external file will
412
-	 * be included to define the function before the function is called.
413
-	 *
414
-	 * <i>Usage:</i> <kbd>$xajax->registerExternalFunction("myFunction","myFunction.inc.php",XAJAX_POST);</kbd>
415
-	 *
416
-	 * @param string contains the function name or an object callback array
417
-	 *               ({@link xajax::registerFunction() see registerFunction} for
418
-	 *               more info on object callback arrays)
419
-	 * @param string contains the path and filename of the include file
420
-	 * @param mixed  the RequestType (XAJAX_GET/XAJAX_POST) that should be used
421
-	 *		          for this function. Defaults to XAJAX_POST.
422
-	 */
423
-	function registerExternalFunction($mFunction,$sIncludeFile,$sRequestType=XAJAX_POST)
424
-	{
425
-		$this->registerFunction($mFunction, $sRequestType);
426
-
427
-		if (is_array($mFunction)) {
428
-			$this->aFunctionIncludeFiles[$mFunction[0]] = $sIncludeFile;
429
-		}
430
-		else {
431
-			$this->aFunctionIncludeFiles[$mFunction] = $sIncludeFile;
432
-		}
433
-	}
434
-
435
-	/**
436
-	 * Registers a PHP function to be called when xajax cannot find the
437
-	 * function being called via Javascript. Because this is technically
438
-	 * impossible when using "wrapped" functions, the catch-all feature is
439
-	 * only useful when you're directly using the xajax.call() Javascript
440
-	 * method. Use the catch-all feature when you want more dynamic ability to
441
-	 * intercept unknown calls and handle them in a custom way.
442
-	 *
443
-	 * <i>Usage:</i> <kbd>$xajax->registerCatchAllFunction("myCatchAllFunction");</kbd>
444
-	 *
445
-	 * @param string contains the function name or an object callback array
446
-	 *               ({@link xajax::registerFunction() see registerFunction} for
447
-	 *               more info on object callback arrays)
448
-	 */
449
-	function registerCatchAllFunction($mFunction)
450
-	{
451
-		if (is_array($mFunction)) {
452
-			$this->sCatchAllFunction = $mFunction[0];
453
-			$this->aObjects[$mFunction[0]] = array_slice($mFunction, 1);
454
-		}
455
-		else {
456
-			$this->sCatchAllFunction = $mFunction;
457
-		}
458
-	}
459
-
460
-	/**
461
-	 * Registers a PHP function to be called before xajax calls the requested
462
-	 * function. xajax will automatically add the request function's response
463
-	 * to the pre-function's response to create a single response. Another
464
-	 * feature is the ability to return not just a response, but an array with
465
-	 * the first element being false (a boolean) and the second being the
466
-	 * response. In this case, the pre-function's response will be returned to
467
-	 * the browser without xajax calling the requested function.
468
-	 *
469
-	 * <i>Usage:</i> <kbd>$xajax->registerPreFunction("myPreFunction");</kbd>
470
-	 *
471
-	 * @param string contains the function name or an object callback array
472
-	 *               ({@link xajax::registerFunction() see registerFunction} for
473
-	 *               more info on object callback arrays)
474
-	 */
475
-	function registerPreFunction($mFunction)
476
-	{
477
-		if (is_array($mFunction)) {
478
-			$this->sPreFunction = $mFunction[0];
479
-			$this->aObjects[$mFunction[0]] = array_slice($mFunction, 1);
480
-		}
481
-		else {
482
-			$this->sPreFunction = $mFunction;
483
-		}
484
-	}
485
-
486
-	/**
487
-	 * Returns true if xajax can process the request, false if otherwise.
488
-	 * You can use this to determine if xajax needs to process the request or
489
-	 * not.
490
-	 *
491
-	 * @return boolean
492
-	 */
493
-	function canProcessRequests()
494
-	{
495
-		if ($this->getRequestMode() != -1) return true;
496
-		return false;
497
-	}
498
-
499
-	/**
500
-	 * Returns the current request mode (XAJAX_GET or XAJAX_POST), or -1 if
501
-	 * there is none.
502
-	 *
503
-	 * @return mixed
504
-	 */
505
-	function getRequestMode()
506
-	{
507
-		if (!empty($_GET["xajax"]))
508
-			return XAJAX_GET;
509
-
510
-		if (!empty($_POST["xajax"]))
511
-			return XAJAX_POST;
512
-
513
-		return -1;
514
-	}
515
-
516
-	/**
517
-	 * This is the main communications engine of xajax. The engine handles all
518
-	 * incoming xajax requests, calls the apporiate PHP functions (or
519
-	 * class/object methods) and passes the XML responses back to the
520
-	 * Javascript response handler. If your RequestURI is the same as your Web
521
-	 * page then this function should be called before any headers or HTML has
522
-	 * been sent.
523
-	 */
524
-	function processRequests()
525
-	{
526
-
527
-		$requestMode = -1;
528
-		$sFunctionName = "";
529
-		$bFoundFunction = true;
530
-		$bFunctionIsCatchAll = false;
531
-		$sFunctionNameForSpecial = "";
532
-		$aArgs = array();
533
-		$sPreResponse = "";
534
-		$bEndRequest = false;
535
-		$sResponse = "";
536
-
537
-		$requestMode = $this->getRequestMode();
538
-		if ($requestMode == -1) return;
539
-
540
-		if ($requestMode == XAJAX_POST)
541
-		{
542
-			$sFunctionName = $_POST["xajax"];
543
-
544
-			if (!empty($_POST["xajaxargs"]))
545
-				$aArgs = $_POST["xajaxargs"];
546
-		}
547
-		else
548
-		{
549
-			header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
550
-			header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
551
-			header ("Cache-Control: no-cache, must-revalidate");
552
-			header ("Pragma: no-cache");
553
-
554
-			$sFunctionName = $_GET["xajax"];
555
-
556
-			if (!empty($_GET["xajaxargs"]))
557
-				$aArgs = $_GET["xajaxargs"];
558
-		}
559
-
560
-		// Use xajax error handler if necessary
561
-		if ($this->bErrorHandler) {
562
-			$GLOBALS['xajaxErrorHandlerText'] = "";
563
-			set_error_handler("xajaxErrorHandler");
564
-		}
565
-
566
-		if ($this->sPreFunction) {
567
-			if (!$this->_isFunctionCallable($this->sPreFunction)) {
568
-				$bFoundFunction = false;
569
-				$objResponse = new xajaxResponse();
570
-				$objResponse->addAlert("Unknown Pre-Function ". $this->sPreFunction);
571
-				$sResponse = $objResponse->getXML();
572
-			}
573
-		}
574
-		//include any external dependencies associated with this function name
575
-		if (array_key_exists($sFunctionName,$this->aFunctionIncludeFiles))
576
-		{
577
-			ob_start();
578
-			include_once($this->aFunctionIncludeFiles[$sFunctionName]);
579
-			ob_end_clean();
580
-		}
581
-
582
-		if ($bFoundFunction) {
583
-			$sFunctionNameForSpecial = $sFunctionName;
584
-			if (!array_key_exists($sFunctionName, $this->aFunctions))
585
-			{
586
-				if ($this->sCatchAllFunction) {
587
-					$sFunctionName = $this->sCatchAllFunction;
588
-					$bFunctionIsCatchAll = true;
589
-				}
590
-				else {
591
-					$bFoundFunction = false;
592
-					$objResponse = new xajaxResponse();
593
-					$objResponse->addAlert("Unknown Function $sFunctionName.");
594
-					$sResponse = $objResponse->getXML();
595
-				}
596
-			}
597
-			else if ($this->aFunctionRequestTypes[$sFunctionName] != $requestMode)
598
-			{
599
-				$bFoundFunction = false;
600
-				$objResponse = new xajaxResponse();
601
-				$objResponse->addAlert("Incorrect Request Type.");
602
-				$sResponse = $objResponse->getXML();
603
-			}
604
-		}
605
-
606
-		if ($bFoundFunction)
607
-		{
608
-			for ($i = 0; $i < sizeof($aArgs); $i++)
609
-			{
610
-				// If magic quotes is on, then we need to strip the slashes from the args
611
-				if (get_magic_quotes_gpc() == 1 && is_string($aArgs[$i])) {
612
-
613
-					$aArgs[$i] = stripslashes($aArgs[$i]);
614
-				}
615
-				if (stristr($aArgs[$i],"<xjxobj>") != false)
616
-				{
617
-					$aArgs[$i] = $this->_xmlToArray("xjxobj",$aArgs[$i]);
618
-				}
619
-				else if (stristr($aArgs[$i],"<xjxquery>") != false)
620
-				{
621
-					$aArgs[$i] = $this->_xmlToArray("xjxquery",$aArgs[$i]);
622
-				}
623
-				else if ($this->bDecodeUTF8Input)
624
-				{
625
-					$aArgs[$i] = $this->_decodeUTF8Data($aArgs[$i]);
626
-				}
627
-			}
628
-
629
-			if ($this->sPreFunction) {
630
-				$mPreResponse = $this->_callFunction($this->sPreFunction, array($sFunctionNameForSpecial, $aArgs));
631
-				if (is_array($mPreResponse) && $mPreResponse[0] === false) {
632
-					$bEndRequest = true;
633
-					$sPreResponse = $mPreResponse[1];
634
-				}
635
-				else {
636
-					$sPreResponse = $mPreResponse;
637
-				}
638
-				if (is_a($sPreResponse, "xajaxResponse")) {
639
-					$sPreResponse = $sPreResponse->getXML();
640
-				}
641
-				if ($bEndRequest) $sResponse = $sPreResponse;
642
-			}
643
-
644
-			if (!$bEndRequest) {
645
-				if (!$this->_isFunctionCallable($sFunctionName)) {
646
-					$objResponse = new xajaxResponse();
647
-					$objResponse->addAlert("The Registered Function $sFunctionName Could Not Be Found.");
648
-					$sResponse = $objResponse->getXML();
649
-				}
650
-				else {
651
-					if ($bFunctionIsCatchAll) {
652
-						$aArgs = array($sFunctionNameForSpecial, $aArgs);
653
-					}
654
-					$sResponse = $this->_callFunction($sFunctionName, $aArgs);
655
-				}
656
-				if (is_a($sResponse, "xajaxResponse")) {
657
-					$sResponse = $sResponse->getXML();
658
-				}
659
-				if (!is_string($sResponse) || strpos($sResponse, "<xjx>") === FALSE) {
660
-					$objResponse = new xajaxResponse();
661
-					$objResponse->addAlert("No XML Response Was Returned By Function $sFunctionName.");
662
-					$sResponse = $objResponse->getXML();
663
-				}
664
-				else if ($sPreResponse != "") {
665
-					$sNewResponse = new xajaxResponse($this->sEncoding, $this->bOutputEntities);
666
-					$sNewResponse->loadXML($sPreResponse);
667
-					$sNewResponse->loadXML($sResponse);
668
-					$sResponse = $sNewResponse->getXML();
669
-				}
670
-			}
671
-		}
672
-
673
-		$sContentHeader = "Content-type: text/xml;";
674
-		if ($this->sEncoding && strlen(trim($this->sEncoding)) > 0)
675
-			$sContentHeader .= " charset=".$this->sEncoding;
676
-		header($sContentHeader);
677
-		if ($this->bErrorHandler && !empty( $GLOBALS['xajaxErrorHandlerText'] )) {
678
-			$sErrorResponse = new xajaxResponse();
679
-			$sErrorResponse->addAlert("** PHP Error Messages: **" . $GLOBALS['xajaxErrorHandlerText']);
680
-			if ($this->sLogFile) {
681
-				$fH = @fopen($this->sLogFile, "a");
682
-				if (!$fH) {
683
-					$sErrorResponse->addAlert("** Logging Error **\n\nxajax was unable to write to the error log file:\n" . $this->sLogFile);
684
-				}
685
-				else {
686
-					fwrite($fH, "** xajax Error Log - " . strftime("%b %e %Y %I:%M:%S %p") . " **" . $GLOBALS['xajaxErrorHandlerText'] . "\n\n\n");
687
-					fclose($fH);
688
-				}
689
-			}
690
-
691
-			$sErrorResponse->loadXML($sResponse);
692
-			$sResponse = $sErrorResponse->getXML();
693
-
694
-		}
695
-		if ($this->bCleanBuffer) while (@ob_end_clean());
696
-		print $sResponse;
697
-		if ($this->bErrorHandler) restore_error_handler();
698
-
699
-		if ($this->bExitAllowed)
700
-			exit();
701
-	}
702
-
703
-	/**
704
-	 * Prints the xajax Javascript header and wrapper code into your page by
705
-	 * printing the output of the getJavascript() method. It should only be
706
-	 * called between the <pre><head> </head></pre> tags in your HTML page.
707
-	 * Remember, if you only want to obtain the result of this function, use
708
-	 * {@link xajax::getJavascript()} instead.
709
-	 *
710
-	 * <i>Usage:</i>
711
-	 * <code>
712
-	 *  <head>
713
-	 *		...
714
-	 *		< ?php $xajax->printJavascript(); ? >
715
-	 * </code>
716
-	 *
717
-	 * @param string the relative address of the folder where xajax has been
718
-	 *               installed. For instance, if your PHP file is
719
-	 *               "http://www.myserver.com/myfolder/mypage.php"
720
-	 *               and xajax was installed in
721
-	 *               "http://www.myserver.com/anotherfolder", then $sJsURI
722
-	 *               should be set to "../anotherfolder". Defaults to assuming
723
-	 *               xajax is in the same folder as your PHP file.
724
-	 * @param string the relative folder/file pair of the xajax Javascript
725
-	 *               engine located within the xajax installation folder.
726
-	 *               Defaults to xajax_js/xajax.js.
727
-	 */
728
-	function printJavascript($sJsURI="", $sJsFile=NULL)
729
-	{
730
-		print $this->getJavascript($sJsURI, $sJsFile);
731
-	}
732
-
733
-	/**
734
-	 * Returns the xajax Javascript code that should be added to your HTML page
735
-	 * between the <kbd><head> </head></kbd> tags.
736
-	 *
737
-	 * <i>Usage:</i>
738
-	 * <code>
739
-	 *  < ?php $xajaxJSHead = $xajax->getJavascript(); ? >
740
-	 *	<head>
741
-	 *		...
742
-	 *		< ?php echo $xajaxJSHead; ? >
743
-	 * </code>
744
-	 *
745
-	 * @param string the relative address of the folder where xajax has been
746
-	 *               installed. For instance, if your PHP file is
747
-	 *               "http://www.myserver.com/myfolder/mypage.php"
748
-	 *               and xajax was installed in
749
-	 *               "http://www.myserver.com/anotherfolder", then $sJsURI
750
-	 *               should be set to "../anotherfolder". Defaults to assuming
751
-	 *               xajax is in the same folder as your PHP file.
752
-	 * @param string the relative folder/file pair of the xajax Javascript
753
-	 *               engine located within the xajax installation folder.
754
-	 *               Defaults to xajax_js/xajax.js.
755
-	 * @return string
756
-	 */
757
-	function getJavascript($sJsURI="", $sJsFile=NULL)
758
-	{
759
-		$html = $this->getJavascriptConfig();
760
-		$html .= $this->getJavascriptInclude($sJsURI, $sJsFile);
761
-
762
-		return $html;
763
-	}
764
-
765
-	/**
766
-	 * Returns a string containing inline Javascript that sets up the xajax
767
-	 * runtime (typically called internally by xajax from get/printJavascript).
768
-	 *
769
-	 * @return string
770
-	 */
771
-	function getJavascriptConfig()
772
-	{
773
-		$html  = "\t<script type=\"text/javascript\">\n";
774
-		$html .= "var xajaxRequestUri=\"".$this->sRequestURI."\";\n";
775
-		$html .= "var xajaxDebug=".($this->bDebug?"true":"false").";\n";
776
-		$html .= "var xajaxStatusMessages=".($this->bStatusMessages?"true":"false").";\n";
777
-		$html .= "var xajaxWaitCursor=".($this->bWaitCursor?"true":"false").";\n";
778
-		$html .= "var xajaxDefinedGet=".XAJAX_GET.";\n";
779
-		$html .= "var xajaxDefinedPost=".XAJAX_POST.";\n";
780
-		$html .= "var xajaxLoaded=false;\n";
781
-
782
-		foreach($this->aFunctions as $sFunction => $bExists) {
783
-			$html .= $this->_wrap($sFunction,$this->aFunctionRequestTypes[$sFunction]);
784
-		}
785
-
786
-		$html .= "\t</script>\n";
787
-		return $html;
788
-	}
789
-
790
-	/**
791
-	 * Returns a string containing a Javascript include of the xajax.js file
792
-	 * along with a check to see if the file loaded after six seconds
793
-	 * (typically called internally by xajax from get/printJavascript).
794
-	 *
795
-	 * @param string the relative address of the folder where xajax has been
796
-	 *               installed. For instance, if your PHP file is
797
-	 *               "http://www.myserver.com/myfolder/mypage.php"
798
-	 *               and xajax was installed in
799
-	 *               "http://www.myserver.com/anotherfolder", then $sJsURI
800
-	 *               should be set to "../anotherfolder". Defaults to assuming
801
-	 *               xajax is in the same folder as your PHP file.
802
-	 * @param string the relative folder/file pair of the xajax Javascript
803
-	 *               engine located within the xajax installation folder.
804
-	 *               Defaults to xajax_js/xajax.js.
805
-	 * @return string
806
-	 */
807
-	function getJavascriptInclude($sJsURI="", $sJsFile=NULL)
808
-	{
809
-		if ($sJsFile == NULL) $sJsFile = "xajax_js/xajax.js";
810
-
811
-		if ($sJsURI != "" && substr($sJsURI, -1) != "/") $sJsURI .= "/";
812
-
813
-		$html = "\t<script type=\"text/javascript\" src=\"" . $sJsURI . $sJsFile . "\"></script>\n";
814
-		$html .= "\t<script type=\"text/javascript\">\n";
815
-		$html .= "window.setTimeout(function () { if (!xajaxLoaded) { alert('Error: the xajax Javascript file could not be included. Perhaps the URL is incorrect?\\nURL: {$sJsURI}{$sJsFile}'); } }, 6000);\n";
816
-		$html .= "\t</script>\n";
817
-		return $html;
818
-	}
819
-
820
-	/**
821
-	 * This method can be used to create a new xajax.js file out of the
822
-	 * xajax_uncompressed.js file (which will only happen if xajax.js doesn't
823
-	 * already exist on the filesystem).
824
-	 *
825
-	 * @param string an optional argument containing the full server file path
826
-	 *               of xajax.js.
827
-	 */
828
-	function autoCompressJavascript($sJsFullFilename=NULL)
829
-	{
830
-		$sJsFile = "xajax_js/xajax.js";
831
-
832
-		if ($sJsFullFilename) {
833
-			$realJsFile = $sJsFullFilename;
834
-		}
835
-		else {
836
-			$realPath = realpath(dirname(__FILE__));
837
-			$realJsFile = $realPath . "/". $sJsFile;
838
-		}
839
-
840
-		// Create a compressed file if necessary
841
-		if (!file_exists($realJsFile)) {
842
-			$srcFile = str_replace(".js", "_uncompressed.js", $realJsFile);
843
-			if (!file_exists($srcFile)) {
844
-				trigger_error("The xajax uncompressed Javascript file could not be found in the <b>" . dirname($realJsFile) . "</b> folder. Error ", E_USER_ERROR);
845
-			}
846
-			require(dirname(__FILE__)."/xajaxCompress.php");
847
-			$javaScript = implode('', file($srcFile));
848
-			$compressedScript = xajaxCompressJavascript($javaScript);
849
-			$fH = @fopen($realJsFile, "w");
850
-			if (!$fH) {
851
-				trigger_error("The xajax compressed javascript file could not be written in the <b>" . dirname($realJsFile) . "</b> folder. Error ", E_USER_ERROR);
852
-			}
853
-			else {
854
-				fwrite($fH, $compressedScript);
855
-				fclose($fH);
856
-			}
857
-		}
858
-	}
859
-
860
-	/**
861
-	 * Returns the current URL based upon the SERVER vars.
862
-	 *
863
-	 * @access private
864
-	 * @return string
865
-	 */
866
-	function _detectURI() {
867
-		$aURL = array();
868
-
869
-		// Try to get the request URL
870
-		if (!empty($_SERVER['REQUEST_URI'])) {
871
-			$aURL = parse_url($_SERVER['REQUEST_URI']);
872
-		}
873
-
874
-		// Fill in the empty values
875
-		if (empty($aURL['scheme'])) {
876
-			if (!empty($_SERVER['HTTP_SCHEME'])) {
877
-				$aURL['scheme'] = $_SERVER['HTTP_SCHEME'];
878
-			} else {
879
-				$aURL['scheme'] = (!empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) != 'off') ? 'https' : 'http';
880
-			}
881
-		}
882
-
883
-		if (empty($aURL['host'])) {
884
-			if (!empty($_SERVER['HTTP_HOST'])) {
885
-				if (strpos($_SERVER['HTTP_HOST'], ':') > 0) {
886
-					list($aURL['host'], $aURL['port']) = explode(':', $_SERVER['HTTP_HOST']);
887
-				} else {
888
-					$aURL['host'] = $_SERVER['HTTP_HOST'];
889
-				}
890
-			} else if (!empty($_SERVER['SERVER_NAME'])) {
891
-				$aURL['host'] = $_SERVER['SERVER_NAME'];
892
-			} else {
893
-				print "xajax Error: xajax failed to automatically identify your Request URI.";
894
-				print "Please set the Request URI explicitly when you instantiate the xajax object.";
895
-				exit();
896
-			}
897
-		}
898
-
899
-		if (empty($aURL['port']) && !empty($_SERVER['SERVER_PORT'])) {
900
-			$aURL['port'] = $_SERVER['SERVER_PORT'];
901
-		}
902
-
903
-		if (empty($aURL['path'])) {
904
-			if (!empty($_SERVER['PATH_INFO'])) {
905
-				$sPath = parse_url($_SERVER['PATH_INFO']);
906
-			} else {
907
-				$sPath = parse_url(api_get_self());
908
-			}
909
-			$aURL['path'] = $sPath['path'];
910
-			unset($sPath);
911
-		}
912
-
913
-		if (!empty($aURL['query'])) {
914
-			$aURL['query'] = '?'.$aURL['query'];
915
-		}
916
-
917
-		// Build the URL: Start with scheme, user and pass
918
-		$sURL = $aURL['scheme'].'://';
919
-		if (!empty($aURL['user'])) {
920
-			$sURL.= $aURL['user'];
921
-			if (!empty($aURL['pass'])) {
922
-				$sURL.= ':'.$aURL['pass'];
923
-			}
924
-			$sURL.= '@';
925
-		}
926
-
927
-		// Add the host
928
-		$sURL.= $aURL['host'];
929
-
930
-		// Add the port if needed
931
-		if (!empty($aURL['port']) && (($aURL['scheme'] == 'http' && $aURL['port'] != 80) || ($aURL['scheme'] == 'https' && $aURL['port'] != 443))) {
932
-			$sURL.= ':'.$aURL['port'];
933
-		}
934
-
935
-		// Add the path and the query string
936
-		$sURL.= $aURL['path'].@$aURL['query'];
937
-
938
-		// Clean up
939
-		unset($aURL);
940
-		return $sURL;
941
-	}
942
-
943
-	/**
944
-	 * Returns true if the function name is associated with an object callback,
945
-	 * false if not.
946
-	 *
947
-	 * @param string the name of the function
948
-	 * @access private
949
-	 * @return boolean
950
-	 */
951
-	function _isObjectCallback($sFunction)
952
-	{
953
-		if (array_key_exists($sFunction, $this->aObjects)) return true;
954
-		return false;
955
-	}
956
-
957
-	/**
958
-	 * Returns true if the function or object callback can be called, false if
959
-	 * not.
960
-	 *
961
-	 * @param string the name of the function
962
-	 * @access private
963
-	 * @return boolean
964
-	 */
965
-	function _isFunctionCallable($sFunction)
966
-	{
967
-		if ($this->_isObjectCallback($sFunction)) {
968
-			if (is_object($this->aObjects[$sFunction][0])) {
969
-				return method_exists($this->aObjects[$sFunction][0], $this->aObjects[$sFunction][1]);
970
-			}
971
-			else {
972
-				return is_callable($this->aObjects[$sFunction]);
973
-			}
974
-		}
975
-		else {
976
-			return function_exists($sFunction);
977
-		}
978
-	}
979
-
980
-	/**
981
-	 * Calls the function, class method, or object method with the supplied
982
-	 * arguments.
983
-	 *
984
-	 * @param string the name of the function
985
-	 * @param array  arguments to pass to the function
986
-	 * @access private
987
-	 * @return mixed the output of the called function or method
988
-	 */
989
-	function _callFunction($sFunction, $aArgs)
990
-	{
991
-		if ($this->_isObjectCallback($sFunction)) {
992
-			$mReturn = call_user_func_array($this->aObjects[$sFunction], $aArgs);
993
-		}
994
-		else {
995
-			$mReturn = call_user_func_array($sFunction, $aArgs);
996
-		}
997
-		return $mReturn;
998
-	}
999
-
1000
-	/**
1001
-	 * Generates the Javascript wrapper for the specified PHP function.
1002
-	 *
1003
-	 * @param string the name of the function
1004
-	 * @param mixed  the request type
1005
-	 * @access private
1006
-	 * @return string
1007
-	 */
1008
-	function _wrap($sFunction,$sRequestType=XAJAX_POST)
1009
-	{
1010
-		$js = "function ".$this->sWrapperPrefix."$sFunction(){return xajax.call(\"$sFunction\", arguments, ".$sRequestType.");}\n";
1011
-		return $js;
1012
-	}
1013
-
1014
-	/**
1015
-	 * Takes a string containing xajax xjxobj XML or xjxquery XML and builds an
1016
-	 * array representation of it to pass as an argument to the PHP function
1017
-	 * being called.
1018
-	 *
1019
-	 * @param string the root tag of the XML
1020
-	 * @param string XML to convert
1021
-	 * @access private
1022
-	 * @return array
1023
-	 */
1024
-	function _xmlToArray($rootTag, $sXml)
1025
-	{
1026
-		$aArray = array();
1027
-		$sXml = str_replace("<$rootTag>","<$rootTag>|~|",$sXml);
1028
-		$sXml = str_replace("</$rootTag>","</$rootTag>|~|",$sXml);
1029
-		$sXml = str_replace("<e>","<e>|~|",$sXml);
1030
-		$sXml = str_replace("</e>","</e>|~|",$sXml);
1031
-		$sXml = str_replace("<k>","<k>|~|",$sXml);
1032
-		$sXml = str_replace("</k>","|~|</k>|~|",$sXml);
1033
-		$sXml = str_replace("<v>","<v>|~|",$sXml);
1034
-		$sXml = str_replace("</v>","|~|</v>|~|",$sXml);
1035
-		$sXml = str_replace("<q>","<q>|~|",$sXml);
1036
-		$sXml = str_replace("</q>","|~|</q>|~|",$sXml);
1037
-
1038
-		$this->aObjArray = explode("|~|",$sXml);
1039
-
1040
-		$this->iPos = 0;
1041
-		$aArray = $this->_parseObjXml($rootTag);
1042
-
1043
-		return $aArray;
1044
-	}
1045
-
1046
-	/**
1047
-	 * A recursive function that generates an array from the contents of
1048
-	 * $this->aObjArray.
1049
-	 *
1050
-	 * @param string the root tag of the XML
1051
-	 * @access private
1052
-	 * @return array
1053
-	 */
1054
-	function _parseObjXml($rootTag)
1055
-	{
1056
-		$aArray = array();
1057
-
1058
-		if ($rootTag == "xjxobj")
1059
-		{
1060
-			while(!stristr($this->aObjArray[$this->iPos],"</xjxobj>"))
1061
-			{
1062
-				$this->iPos++;
1063
-				if(stristr($this->aObjArray[$this->iPos],"<e>"))
1064
-				{
1065
-					$key = "";
1066
-					$value = null;
1067
-
1068
-					$this->iPos++;
1069
-					while(!stristr($this->aObjArray[$this->iPos],"</e>"))
1070
-					{
1071
-						if(stristr($this->aObjArray[$this->iPos],"<k>"))
1072
-						{
1073
-							$this->iPos++;
1074
-							while(!stristr($this->aObjArray[$this->iPos],"</k>"))
1075
-							{
1076
-								$key .= $this->aObjArray[$this->iPos];
1077
-								$this->iPos++;
1078
-							}
1079
-						}
1080
-						if(stristr($this->aObjArray[$this->iPos],"<v>"))
1081
-						{
1082
-							$this->iPos++;
1083
-							while(!stristr($this->aObjArray[$this->iPos],"</v>"))
1084
-							{
1085
-								if(stristr($this->aObjArray[$this->iPos],"<xjxobj>"))
1086
-								{
1087
-									$value = $this->_parseObjXml("xjxobj");
1088
-									$this->iPos++;
1089
-								}
1090
-								else
1091
-								{
1092
-									$value .= $this->aObjArray[$this->iPos];
1093
-									if ($this->bDecodeUTF8Input)
1094
-									{
1095
-										$value = $this->_decodeUTF8Data($value);
1096
-									}
1097
-								}
1098
-								$this->iPos++;
1099
-							}
1100
-						}
1101
-						$this->iPos++;
1102
-					}
1103
-
1104
-					$aArray[$key]=$value;
1105
-				}
1106
-			}
1107
-		}
1108
-
1109
-		if ($rootTag == "xjxquery")
1110
-		{
1111
-			$sQuery = "";
1112
-			$this->iPos++;
1113
-			while(!stristr($this->aObjArray[$this->iPos],"</xjxquery>"))
1114
-			{
1115
-				if (stristr($this->aObjArray[$this->iPos],"<q>") || stristr($this->aObjArray[$this->iPos],"</q>"))
1116
-				{
1117
-					$this->iPos++;
1118
-					continue;
1119
-				}
1120
-				$sQuery	.= $this->aObjArray[$this->iPos];
1121
-				$this->iPos++;
1122
-			}
1123
-
1124
-			parse_str($sQuery, $aArray);
1125
-			if ($this->bDecodeUTF8Input)
1126
-			{
1127
-				foreach($aArray as $key => $value)
1128
-				{
1129
-					$aArray[$key] = $this->_decodeUTF8Data($value);
1130
-				}
1131
-			}
1132
-			// If magic quotes is on, then we need to strip the slashes from the
1133
-			// array values because of the parse_str pass which adds slashes
1134
-			if (get_magic_quotes_gpc() == 1) {
1135
-				$newArray = array();
1136
-				foreach ($aArray as $sKey => $sValue) {
1137
-					if (is_string($sValue))
1138
-						$newArray[$sKey] = stripslashes($sValue);
1139
-					else
1140
-						$newArray[$sKey] = $sValue;
1141
-				}
1142
-				$aArray = $newArray;
1143
-			}
1144
-		}
1145
-
1146
-		return $aArray;
1147
-	}
1148
-
1149
-	/**
1150
-	 * Decodes string data from UTF-8 to the current xajax encoding.
1151
-	 *
1152
-	 * @param string data to convert
1153
-	 * @access private
1154
-	 * @return string converted data
1155
-	 */
1156
-	function _decodeUTF8Data($sData)
1157
-	{
1158
-		$sValue = $sData;
1159
-		if ($this->bDecodeUTF8Input)
1160
-		{
1161
-			$sFuncToUse = NULL;
1162
-
1163
-			// An adaptation for the Dokeos LMS, 22-AUG-2009.
1164
-			if (function_exists('api_convert_encoding'))
1165
-			{
1166
-				$sFuncToUse = "api_convert_encoding";
1167
-			}
1168
-			//if (function_exists('iconv'))
1169
-			elseif (function_exists('iconv'))
1170
-			//
1171
-			{
1172
-				$sFuncToUse = "iconv";
1173
-			}
1174
-			else if (function_exists('mb_convert_encoding'))
1175
-			{
1176
-				$sFuncToUse = "mb_convert_encoding";
1177
-			}
1178
-			else if ($this->sEncoding == "ISO-8859-1")
1179
-			{
1180
-				$sFuncToUse = "utf8_decode";
1181
-			}
1182
-			else
1183
-			{
1184
-				trigger_error("The incoming xajax data could not be converted from UTF-8", E_USER_NOTICE);
1185
-			}
1186
-
1187
-			if ($sFuncToUse)
1188
-			{
1189
-				if (is_string($sValue))
1190
-				{
1191
-					if ($sFuncToUse == "iconv")
1192
-					{
1193
-						$sValue = iconv("UTF-8", $this->sEncoding.'//TRANSLIT', $sValue);
1194
-					}
1195
-					else if ($sFuncToUse == "mb_convert_encoding")
1196
-					{
1197
-						$sValue = mb_convert_encoding($sValue, $this->sEncoding, "UTF-8");
1198
-					}
1199
-					// Added code, an adaptation for the Dokeos LMS, 22-AUG-2009.
1200
-					else if ($sFuncToUse == "api_convert_encoding")
1201
-					{
1202
-						$sValue = api_convert_encoding($sValue, $this->sEncoding, "UTF-8");
1203
-					}
1204
-					//
1205
-					else
1206
-					{
1207
-						$sValue = utf8_decode($sValue);
1208
-					}
1209
-				}
1210
-			}
1211
-		}
1212
-		return $sValue;
1213
-	}
78
+    /**
79
+     * @var array Array of PHP functions that will be callable through javascript wrappers
80
+     */
81
+    var $aFunctions;
82
+    /**
83
+     * @var array Array of object callbacks that will allow Javascript to call PHP methods (key=function name)
84
+     */
85
+    var $aObjects;
86
+    /**
87
+     * @var array Array of RequestTypes to be used with each function (key=function name)
88
+     */
89
+    var $aFunctionRequestTypes;
90
+    /**
91
+     * @var array Array of Include Files for any external functions (key=function name)
92
+     */
93
+    var $aFunctionIncludeFiles;
94
+    /**
95
+     * @var string Name of the PHP function to call if no callable function was found
96
+     */
97
+    var $sCatchAllFunction;
98
+    /**
99
+     * @var string Name of the PHP function to call before any other function
100
+     */
101
+    var $sPreFunction;
102
+    /**
103
+     * @var string The URI for making requests to the xajax object
104
+     */
105
+    var $sRequestURI;
106
+    /**
107
+     * @var string The prefix to prepend to the javascript wraper function name
108
+     */
109
+    var $sWrapperPrefix;
110
+    /**
111
+     * @var boolean Show debug messages (default false)
112
+     */
113
+    var $bDebug;
114
+    /**
115
+     * @var boolean Show messages in the client browser's status bar (default false)
116
+     */
117
+    var $bStatusMessages;
118
+    /**
119
+     * @var boolean Allow xajax to exit after processing a request (default true)
120
+     */
121
+    var $bExitAllowed;
122
+    /**
123
+     * @var boolean Use wait cursor in browser (default true)
124
+     */
125
+    var $bWaitCursor;
126
+    /**
127
+     * @var boolean Use an special xajax error handler so the errors are sent to the browser properly (default false)
128
+     */
129
+    var $bErrorHandler;
130
+    /**
131
+     * @var string Specify what, if any, file xajax should log errors to (and more information in a future release)
132
+     */
133
+    var $sLogFile;
134
+    /**
135
+     * @var boolean Clean all output buffers before outputting response (default false)
136
+     */
137
+    var $bCleanBuffer;
138
+    /**
139
+     * @var string String containing the character encoding used
140
+     */
141
+    var $sEncoding;
142
+    /**
143
+     * @var boolean Decode input request args from UTF-8 (default false)
144
+     */
145
+    var $bDecodeUTF8Input;
146
+    /**
147
+     * @var boolean Convert special characters to HTML entities (default false)
148
+     */
149
+    var $bOutputEntities;
150
+    /**
151
+     * @var array Array for parsing complex objects
152
+     */
153
+    var $aObjArray;
154
+    /**
155
+     * @var integer Position in $aObjArray
156
+     */
157
+    var $iPos;
158
+
159
+    /**#@-*/
160
+
161
+    /**
162
+     * Constructor. You can set some extra xajax options right away or use
163
+     * individual methods later to set options.
164
+     *
165
+     * @param string  defaults to the current browser URI
166
+     * @param string  defaults to "xajax_";
167
+     * @param string  defaults to XAJAX_DEFAULT_CHAR_ENCODING defined above
168
+     * @param boolean defaults to false
169
+     */
170
+    public function __construct($sRequestURI="",$sWrapperPrefix="xajax_",$sEncoding=XAJAX_DEFAULT_CHAR_ENCODING,$bDebug=false)
171
+    {
172
+        $this->aFunctions = array();
173
+        $this->aObjects = array();
174
+        $this->aFunctionIncludeFiles = array();
175
+        $this->sRequestURI = $sRequestURI;
176
+        if ($this->sRequestURI == "")
177
+            $this->sRequestURI = $this->_detectURI();
178
+        $this->sWrapperPrefix = $sWrapperPrefix;
179
+        $this->bDebug = $bDebug;
180
+        $this->bStatusMessages = false;
181
+        $this->bWaitCursor = true;
182
+        $this->bExitAllowed = true;
183
+        $this->bErrorHandler = false;
184
+        $this->sLogFile = "";
185
+        $this->bCleanBuffer = false;
186
+        $this->setCharEncoding($sEncoding);
187
+        $this->bDecodeUTF8Input = false;
188
+        $this->bOutputEntities = false;
189
+    }
190
+
191
+    /**
192
+     * Sets the URI to which requests will be made.
193
+     * <i>Usage:</i> <kbd>$xajax->setRequestURI("http://www.xajaxproject.org");</kbd>
194
+     *
195
+     * @param string the URI (can be absolute or relative) of the PHP script
196
+     *               that will be accessed when an xajax request occurs
197
+     */
198
+    function setRequestURI($sRequestURI)
199
+    {
200
+        $this->sRequestURI = $sRequestURI;
201
+    }
202
+
203
+    /**
204
+     * Sets the prefix that will be appended to the Javascript wrapper
205
+     * functions (default is "xajax_").
206
+     *
207
+     * @param string
208
+     */
209
+    //
210
+    function setWrapperPrefix($sPrefix)
211
+    {
212
+        $this->sWrapperPrefix = $sPrefix;
213
+    }
214
+
215
+    /**
216
+     * Enables debug messages for xajax.
217
+     * */
218
+    function debugOn()
219
+    {
220
+        $this->bDebug = true;
221
+    }
222
+
223
+    /**
224
+     * Disables debug messages for xajax (default behavior).
225
+     */
226
+    function debugOff()
227
+    {
228
+        $this->bDebug = false;
229
+    }
230
+
231
+    /**
232
+     * Enables messages in the browser's status bar for xajax.
233
+     */
234
+    function statusMessagesOn()
235
+    {
236
+        $this->bStatusMessages = true;
237
+    }
238
+
239
+    /**
240
+     * Disables messages in the browser's status bar for xajax (default behavior).
241
+     */
242
+    function statusMessagesOff()
243
+    {
244
+        $this->bStatusMessages = false;
245
+    }
246
+
247
+    /**
248
+     * Enables the wait cursor to be displayed in the browser (default behavior).
249
+     */
250
+    function waitCursorOn()
251
+    {
252
+        $this->bWaitCursor = true;
253
+    }
254
+
255
+    /**
256
+     * Disables the wait cursor to be displayed in the browser.
257
+     */
258
+    function waitCursorOff()
259
+    {
260
+        $this->bWaitCursor = false;
261
+    }
262
+
263
+    /**
264
+     * Enables xajax to exit immediately after processing a request and
265
+     * sending the response back to the browser (default behavior).
266
+     */
267
+    function exitAllowedOn()
268
+    {
269
+        $this->bExitAllowed = true;
270
+    }
271
+
272
+    /**
273
+     * Disables xajax's default behavior of exiting immediately after
274
+     * processing a request and sending the response back to the browser.
275
+     */
276
+    function exitAllowedOff()
277
+    {
278
+        $this->bExitAllowed = false;
279
+    }
280
+
281
+    /**
282
+     * Turns on xajax's error handling system so that PHP errors that occur
283
+     * during a request are trapped and pushed to the browser in the form of
284
+     * a Javascript alert.
285
+     */
286
+    function errorHandlerOn()
287
+    {
288
+        $this->bErrorHandler = true;
289
+    }
290
+
291
+    /**
292
+     * Turns off xajax's error handling system (default behavior).
293
+     */
294
+    function errorHandlerOff()
295
+    {
296
+        $this->bErrorHandler = false;
297
+    }
298
+
299
+    /**
300
+     * Specifies a log file that will be written to by xajax during a request
301
+     * (used only by the error handling system at present). If you don't invoke
302
+     * this method, or you pass in "", then no log file will be written to.
303
+     * <i>Usage:</i> <kbd>$xajax->setLogFile("/xajax_logs/errors.log");</kbd>
304
+     */
305
+    function setLogFile($sFilename)
306
+    {
307
+        $this->sLogFile = $sFilename;
308
+    }
309
+
310
+    /**
311
+     * Causes xajax to clean out all output buffers before outputting a
312
+     * response (default behavior).
313
+     */
314
+    function cleanBufferOn()
315
+    {
316
+        $this->bCleanBuffer = true;
317
+    }
318
+    /**
319
+     * Turns off xajax's output buffer cleaning.
320
+     */
321
+    function cleanBufferOff()
322
+    {
323
+        $this->bCleanBuffer = false;
324
+    }
325
+
326
+    /**
327
+     * Sets the character encoding for the HTTP output based on
328
+     * <kbd>$sEncoding</kbd>, which is a string containing the character
329
+     * encoding to use. You don't need to use this method normally, since the
330
+     * character encoding for the response gets set automatically based on the
331
+     * <kbd>XAJAX_DEFAULT_CHAR_ENCODING</kbd> constant.
332
+     * <i>Usage:</i> <kbd>$xajax->setCharEncoding("utf-8");</kbd>
333
+     *
334
+     * @param string the encoding type to use (utf-8, iso-8859-1, etc.)
335
+     */
336
+    function setCharEncoding($sEncoding)
337
+    {
338
+        $this->sEncoding = $sEncoding;
339
+    }
340
+
341
+    /**
342
+     * Causes xajax to decode the input request args from UTF-8 to the current
343
+     * encoding if possible. Either the iconv or mb_string extension must be
344
+     * present for optimal functionality.
345
+     */
346
+    function decodeUTF8InputOn()
347
+    {
348
+        $this->bDecodeUTF8Input = true;
349
+    }
350
+
351
+    /**
352
+     * Turns off decoding the input request args from UTF-8 (default behavior).
353
+     */
354
+    function decodeUTF8InputOff()
355
+    {
356
+        $this->bDecodeUTF8Input = false;
357
+    }
358
+
359
+    /**
360
+     * Tells the response object to convert special characters to HTML entities
361
+     * automatically (only works if the mb_string extension is available).
362
+     */
363
+    function outputEntitiesOn()
364
+    {
365
+        $this->bOutputEntities = true;
366
+    }
367
+
368
+    /**
369
+     * Tells the response object to output special characters intact. (default
370
+     * behavior).
371
+     */
372
+    function outputEntitiesOff()
373
+    {
374
+        $this->bOutputEntities = false;
375
+    }
376
+
377
+    /**
378
+     * Registers a PHP function or method to be callable through xajax in your
379
+     * Javascript. If you want to register a function, pass in the name of that
380
+     * function. If you want to register a static class method, pass in an
381
+     * array like so:
382
+     * <kbd>array("myFunctionName", "myClass", "myMethod")</kbd>
383
+     * For an object instance method, use an object variable for the second
384
+     * array element (and in PHP 4 make sure you put an & before the variable
385
+     * to pass the object by reference). Note: the function name is what you
386
+     * call via Javascript, so it can be anything as long as it doesn't
387
+     * conflict with any other registered function name.
388
+     *
389
+     * <i>Usage:</i> <kbd>$xajax->registerFunction("myFunction");</kbd>
390
+     * or: <kbd>$xajax->registerFunction(array("myFunctionName", &$myObject, "myMethod"));</kbd>
391
+     *
392
+     * @param mixed  contains the function name or an object callback array
393
+     * @param mixed  request type (XAJAX_GET/XAJAX_POST) that should be used
394
+     *               for this function.  Defaults to XAJAX_POST.
395
+     */
396
+    function registerFunction($mFunction,$sRequestType=XAJAX_POST)
397
+    {
398
+        if (is_array($mFunction)) {
399
+            $this->aFunctions[$mFunction[0]] = 1;
400
+            $this->aFunctionRequestTypes[$mFunction[0]] = $sRequestType;
401
+            $this->aObjects[$mFunction[0]] = array_slice($mFunction, 1);
402
+        }
403
+        else {
404
+            $this->aFunctions[$mFunction] = 1;
405
+            $this->aFunctionRequestTypes[$mFunction] = $sRequestType;
406
+        }
407
+    }
408
+
409
+    /**
410
+     * Registers a PHP function to be callable through xajax which is located
411
+     * in some other file.  If the function is requested the external file will
412
+     * be included to define the function before the function is called.
413
+     *
414
+     * <i>Usage:</i> <kbd>$xajax->registerExternalFunction("myFunction","myFunction.inc.php",XAJAX_POST);</kbd>
415
+     *
416
+     * @param string contains the function name or an object callback array
417
+     *               ({@link xajax::registerFunction() see registerFunction} for
418
+     *               more info on object callback arrays)
419
+     * @param string contains the path and filename of the include file
420
+     * @param mixed  the RequestType (XAJAX_GET/XAJAX_POST) that should be used
421
+     *		          for this function. Defaults to XAJAX_POST.
422
+     */
423
+    function registerExternalFunction($mFunction,$sIncludeFile,$sRequestType=XAJAX_POST)
424
+    {
425
+        $this->registerFunction($mFunction, $sRequestType);
426
+
427
+        if (is_array($mFunction)) {
428
+            $this->aFunctionIncludeFiles[$mFunction[0]] = $sIncludeFile;
429
+        }
430
+        else {
431
+            $this->aFunctionIncludeFiles[$mFunction] = $sIncludeFile;
432
+        }
433
+    }
434
+
435
+    /**
436
+     * Registers a PHP function to be called when xajax cannot find the
437
+     * function being called via Javascript. Because this is technically
438
+     * impossible when using "wrapped" functions, the catch-all feature is
439
+     * only useful when you're directly using the xajax.call() Javascript
440
+     * method. Use the catch-all feature when you want more dynamic ability to
441
+     * intercept unknown calls and handle them in a custom way.
442
+     *
443
+     * <i>Usage:</i> <kbd>$xajax->registerCatchAllFunction("myCatchAllFunction");</kbd>
444
+     *
445
+     * @param string contains the function name or an object callback array
446
+     *               ({@link xajax::registerFunction() see registerFunction} for
447
+     *               more info on object callback arrays)
448
+     */
449
+    function registerCatchAllFunction($mFunction)
450
+    {
451
+        if (is_array($mFunction)) {
452
+            $this->sCatchAllFunction = $mFunction[0];
453
+            $this->aObjects[$mFunction[0]] = array_slice($mFunction, 1);
454
+        }
455
+        else {
456
+            $this->sCatchAllFunction = $mFunction;
457
+        }
458
+    }
459
+
460
+    /**
461
+     * Registers a PHP function to be called before xajax calls the requested
462
+     * function. xajax will automatically add the request function's response
463
+     * to the pre-function's response to create a single response. Another
464
+     * feature is the ability to return not just a response, but an array with
465
+     * the first element being false (a boolean) and the second being the
466
+     * response. In this case, the pre-function's response will be returned to
467
+     * the browser without xajax calling the requested function.
468
+     *
469
+     * <i>Usage:</i> <kbd>$xajax->registerPreFunction("myPreFunction");</kbd>
470
+     *
471
+     * @param string contains the function name or an object callback array
472
+     *               ({@link xajax::registerFunction() see registerFunction} for
473
+     *               more info on object callback arrays)
474
+     */
475
+    function registerPreFunction($mFunction)
476
+    {
477
+        if (is_array($mFunction)) {
478
+            $this->sPreFunction = $mFunction[0];
479
+            $this->aObjects[$mFunction[0]] = array_slice($mFunction, 1);
480
+        }
481
+        else {
482
+            $this->sPreFunction = $mFunction;
483
+        }
484
+    }
485
+
486
+    /**
487
+     * Returns true if xajax can process the request, false if otherwise.
488
+     * You can use this to determine if xajax needs to process the request or
489
+     * not.
490
+     *
491
+     * @return boolean
492
+     */
493
+    function canProcessRequests()
494
+    {
495
+        if ($this->getRequestMode() != -1) return true;
496
+        return false;
497
+    }
498
+
499
+    /**
500
+     * Returns the current request mode (XAJAX_GET or XAJAX_POST), or -1 if
501
+     * there is none.
502
+     *
503
+     * @return mixed
504
+     */
505
+    function getRequestMode()
506
+    {
507
+        if (!empty($_GET["xajax"]))
508
+            return XAJAX_GET;
509
+
510
+        if (!empty($_POST["xajax"]))
511
+            return XAJAX_POST;
512
+
513
+        return -1;
514
+    }
515
+
516
+    /**
517
+     * This is the main communications engine of xajax. The engine handles all
518
+     * incoming xajax requests, calls the apporiate PHP functions (or
519
+     * class/object methods) and passes the XML responses back to the
520
+     * Javascript response handler. If your RequestURI is the same as your Web
521
+     * page then this function should be called before any headers or HTML has
522
+     * been sent.
523
+     */
524
+    function processRequests()
525
+    {
526
+
527
+        $requestMode = -1;
528
+        $sFunctionName = "";
529
+        $bFoundFunction = true;
530
+        $bFunctionIsCatchAll = false;
531
+        $sFunctionNameForSpecial = "";
532
+        $aArgs = array();
533
+        $sPreResponse = "";
534
+        $bEndRequest = false;
535
+        $sResponse = "";
536
+
537
+        $requestMode = $this->getRequestMode();
538
+        if ($requestMode == -1) return;
539
+
540
+        if ($requestMode == XAJAX_POST)
541
+        {
542
+            $sFunctionName = $_POST["xajax"];
543
+
544
+            if (!empty($_POST["xajaxargs"]))
545
+                $aArgs = $_POST["xajaxargs"];
546
+        }
547
+        else
548
+        {
549
+            header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
550
+            header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
551
+            header ("Cache-Control: no-cache, must-revalidate");
552
+            header ("Pragma: no-cache");
553
+
554
+            $sFunctionName = $_GET["xajax"];
555
+
556
+            if (!empty($_GET["xajaxargs"]))
557
+                $aArgs = $_GET["xajaxargs"];
558
+        }
559
+
560
+        // Use xajax error handler if necessary
561
+        if ($this->bErrorHandler) {
562
+            $GLOBALS['xajaxErrorHandlerText'] = "";
563
+            set_error_handler("xajaxErrorHandler");
564
+        }
565
+
566
+        if ($this->sPreFunction) {
567
+            if (!$this->_isFunctionCallable($this->sPreFunction)) {
568
+                $bFoundFunction = false;
569
+                $objResponse = new xajaxResponse();
570
+                $objResponse->addAlert("Unknown Pre-Function ". $this->sPreFunction);
571
+                $sResponse = $objResponse->getXML();
572
+            }
573
+        }
574
+        //include any external dependencies associated with this function name
575
+        if (array_key_exists($sFunctionName,$this->aFunctionIncludeFiles))
576
+        {
577
+            ob_start();
578
+            include_once($this->aFunctionIncludeFiles[$sFunctionName]);
579
+            ob_end_clean();
580
+        }
581
+
582
+        if ($bFoundFunction) {
583
+            $sFunctionNameForSpecial = $sFunctionName;
584
+            if (!array_key_exists($sFunctionName, $this->aFunctions))
585
+            {
586
+                if ($this->sCatchAllFunction) {
587
+                    $sFunctionName = $this->sCatchAllFunction;
588
+                    $bFunctionIsCatchAll = true;
589
+                }
590
+                else {
591
+                    $bFoundFunction = false;
592
+                    $objResponse = new xajaxResponse();
593
+                    $objResponse->addAlert("Unknown Function $sFunctionName.");
594
+                    $sResponse = $objResponse->getXML();
595
+                }
596
+            }
597
+            else if ($this->aFunctionRequestTypes[$sFunctionName] != $requestMode)
598
+            {
599
+                $bFoundFunction = false;
600
+                $objResponse = new xajaxResponse();
601
+                $objResponse->addAlert("Incorrect Request Type.");
602
+                $sResponse = $objResponse->getXML();
603
+            }
604
+        }
605
+
606
+        if ($bFoundFunction)
607
+        {
608
+            for ($i = 0; $i < sizeof($aArgs); $i++)
609
+            {
610
+                // If magic quotes is on, then we need to strip the slashes from the args
611
+                if (get_magic_quotes_gpc() == 1 && is_string($aArgs[$i])) {
612
+
613
+                    $aArgs[$i] = stripslashes($aArgs[$i]);
614
+                }
615
+                if (stristr($aArgs[$i],"<xjxobj>") != false)
616
+                {
617
+                    $aArgs[$i] = $this->_xmlToArray("xjxobj",$aArgs[$i]);
618
+                }
619
+                else if (stristr($aArgs[$i],"<xjxquery>") != false)
620
+                {
621
+                    $aArgs[$i] = $this->_xmlToArray("xjxquery",$aArgs[$i]);
622
+                }
623
+                else if ($this->bDecodeUTF8Input)
624
+                {
625
+                    $aArgs[$i] = $this->_decodeUTF8Data($aArgs[$i]);
626
+                }
627
+            }
628
+
629
+            if ($this->sPreFunction) {
630
+                $mPreResponse = $this->_callFunction($this->sPreFunction, array($sFunctionNameForSpecial, $aArgs));
631
+                if (is_array($mPreResponse) && $mPreResponse[0] === false) {
632
+                    $bEndRequest = true;
633
+                    $sPreResponse = $mPreResponse[1];
634
+                }
635
+                else {
636
+                    $sPreResponse = $mPreResponse;
637
+                }
638
+                if (is_a($sPreResponse, "xajaxResponse")) {
639
+                    $sPreResponse = $sPreResponse->getXML();
640
+                }
641
+                if ($bEndRequest) $sResponse = $sPreResponse;
642
+            }
643
+
644
+            if (!$bEndRequest) {
645
+                if (!$this->_isFunctionCallable($sFunctionName)) {
646
+                    $objResponse = new xajaxResponse();
647
+                    $objResponse->addAlert("The Registered Function $sFunctionName Could Not Be Found.");
648
+                    $sResponse = $objResponse->getXML();
649
+                }
650
+                else {
651
+                    if ($bFunctionIsCatchAll) {
652
+                        $aArgs = array($sFunctionNameForSpecial, $aArgs);
653
+                    }
654
+                    $sResponse = $this->_callFunction($sFunctionName, $aArgs);
655
+                }
656
+                if (is_a($sResponse, "xajaxResponse")) {
657
+                    $sResponse = $sResponse->getXML();
658
+                }
659
+                if (!is_string($sResponse) || strpos($sResponse, "<xjx>") === FALSE) {
660
+                    $objResponse = new xajaxResponse();
661
+                    $objResponse->addAlert("No XML Response Was Returned By Function $sFunctionName.");
662
+                    $sResponse = $objResponse->getXML();
663
+                }
664
+                else if ($sPreResponse != "") {
665
+                    $sNewResponse = new xajaxResponse($this->sEncoding, $this->bOutputEntities);
666
+                    $sNewResponse->loadXML($sPreResponse);
667
+                    $sNewResponse->loadXML($sResponse);
668
+                    $sResponse = $sNewResponse->getXML();
669
+                }
670
+            }
671
+        }
672
+
673
+        $sContentHeader = "Content-type: text/xml;";
674
+        if ($this->sEncoding && strlen(trim($this->sEncoding)) > 0)
675
+            $sContentHeader .= " charset=".$this->sEncoding;
676
+        header($sContentHeader);
677
+        if ($this->bErrorHandler && !empty( $GLOBALS['xajaxErrorHandlerText'] )) {
678
+            $sErrorResponse = new xajaxResponse();
679
+            $sErrorResponse->addAlert("** PHP Error Messages: **" . $GLOBALS['xajaxErrorHandlerText']);
680
+            if ($this->sLogFile) {
681
+                $fH = @fopen($this->sLogFile, "a");
682
+                if (!$fH) {
683
+                    $sErrorResponse->addAlert("** Logging Error **\n\nxajax was unable to write to the error log file:\n" . $this->sLogFile);
684
+                }
685
+                else {
686
+                    fwrite($fH, "** xajax Error Log - " . strftime("%b %e %Y %I:%M:%S %p") . " **" . $GLOBALS['xajaxErrorHandlerText'] . "\n\n\n");
687
+                    fclose($fH);
688
+                }
689
+            }
690
+
691
+            $sErrorResponse->loadXML($sResponse);
692
+            $sResponse = $sErrorResponse->getXML();
693
+
694
+        }
695
+        if ($this->bCleanBuffer) while (@ob_end_clean());
696
+        print $sResponse;
697
+        if ($this->bErrorHandler) restore_error_handler();
698
+
699
+        if ($this->bExitAllowed)
700
+            exit();
701
+    }
702
+
703
+    /**
704
+     * Prints the xajax Javascript header and wrapper code into your page by
705
+     * printing the output of the getJavascript() method. It should only be
706
+     * called between the <pre><head> </head></pre> tags in your HTML page.
707
+     * Remember, if you only want to obtain the result of this function, use
708
+     * {@link xajax::getJavascript()} instead.
709
+     *
710
+     * <i>Usage:</i>
711
+     * <code>
712
+     *  <head>
713
+     *		...
714
+     *		< ?php $xajax->printJavascript(); ? >
715
+     * </code>
716
+     *
717
+     * @param string the relative address of the folder where xajax has been
718
+     *               installed. For instance, if your PHP file is
719
+     *               "http://www.myserver.com/myfolder/mypage.php"
720
+     *               and xajax was installed in
721
+     *               "http://www.myserver.com/anotherfolder", then $sJsURI
722
+     *               should be set to "../anotherfolder". Defaults to assuming
723
+     *               xajax is in the same folder as your PHP file.
724
+     * @param string the relative folder/file pair of the xajax Javascript
725
+     *               engine located within the xajax installation folder.
726
+     *               Defaults to xajax_js/xajax.js.
727
+     */
728
+    function printJavascript($sJsURI="", $sJsFile=NULL)
729
+    {
730
+        print $this->getJavascript($sJsURI, $sJsFile);
731
+    }
732
+
733
+    /**
734
+     * Returns the xajax Javascript code that should be added to your HTML page
735
+     * between the <kbd><head> </head></kbd> tags.
736
+     *
737
+     * <i>Usage:</i>
738
+     * <code>
739
+     *  < ?php $xajaxJSHead = $xajax->getJavascript(); ? >
740
+     *	<head>
741
+     *		...
742
+     *		< ?php echo $xajaxJSHead; ? >
743
+     * </code>
744
+     *
745
+     * @param string the relative address of the folder where xajax has been
746
+     *               installed. For instance, if your PHP file is
747
+     *               "http://www.myserver.com/myfolder/mypage.php"
748
+     *               and xajax was installed in
749
+     *               "http://www.myserver.com/anotherfolder", then $sJsURI
750
+     *               should be set to "../anotherfolder". Defaults to assuming
751
+     *               xajax is in the same folder as your PHP file.
752
+     * @param string the relative folder/file pair of the xajax Javascript
753
+     *               engine located within the xajax installation folder.
754
+     *               Defaults to xajax_js/xajax.js.
755
+     * @return string
756
+     */
757
+    function getJavascript($sJsURI="", $sJsFile=NULL)
758
+    {
759
+        $html = $this->getJavascriptConfig();
760
+        $html .= $this->getJavascriptInclude($sJsURI, $sJsFile);
761
+
762
+        return $html;
763
+    }
764
+
765
+    /**
766
+     * Returns a string containing inline Javascript that sets up the xajax
767
+     * runtime (typically called internally by xajax from get/printJavascript).
768
+     *
769
+     * @return string
770
+     */
771
+    function getJavascriptConfig()
772
+    {
773
+        $html  = "\t<script type=\"text/javascript\">\n";
774
+        $html .= "var xajaxRequestUri=\"".$this->sRequestURI."\";\n";
775
+        $html .= "var xajaxDebug=".($this->bDebug?"true":"false").";\n";
776
+        $html .= "var xajaxStatusMessages=".($this->bStatusMessages?"true":"false").";\n";
777
+        $html .= "var xajaxWaitCursor=".($this->bWaitCursor?"true":"false").";\n";
778
+        $html .= "var xajaxDefinedGet=".XAJAX_GET.";\n";
779
+        $html .= "var xajaxDefinedPost=".XAJAX_POST.";\n";
780
+        $html .= "var xajaxLoaded=false;\n";
781
+
782
+        foreach($this->aFunctions as $sFunction => $bExists) {
783
+            $html .= $this->_wrap($sFunction,$this->aFunctionRequestTypes[$sFunction]);
784
+        }
785
+
786
+        $html .= "\t</script>\n";
787
+        return $html;
788
+    }
789
+
790
+    /**
791
+     * Returns a string containing a Javascript include of the xajax.js file
792
+     * along with a check to see if the file loaded after six seconds
793
+     * (typically called internally by xajax from get/printJavascript).
794
+     *
795
+     * @param string the relative address of the folder where xajax has been
796
+     *               installed. For instance, if your PHP file is
797
+     *               "http://www.myserver.com/myfolder/mypage.php"
798
+     *               and xajax was installed in
799
+     *               "http://www.myserver.com/anotherfolder", then $sJsURI
800
+     *               should be set to "../anotherfolder". Defaults to assuming
801
+     *               xajax is in the same folder as your PHP file.
802
+     * @param string the relative folder/file pair of the xajax Javascript
803
+     *               engine located within the xajax installation folder.
804
+     *               Defaults to xajax_js/xajax.js.
805
+     * @return string
806
+     */
807
+    function getJavascriptInclude($sJsURI="", $sJsFile=NULL)
808
+    {
809
+        if ($sJsFile == NULL) $sJsFile = "xajax_js/xajax.js";
810
+
811
+        if ($sJsURI != "" && substr($sJsURI, -1) != "/") $sJsURI .= "/";
812
+
813
+        $html = "\t<script type=\"text/javascript\" src=\"" . $sJsURI . $sJsFile . "\"></script>\n";
814
+        $html .= "\t<script type=\"text/javascript\">\n";
815
+        $html .= "window.setTimeout(function () { if (!xajaxLoaded) { alert('Error: the xajax Javascript file could not be included. Perhaps the URL is incorrect?\\nURL: {$sJsURI}{$sJsFile}'); } }, 6000);\n";
816
+        $html .= "\t</script>\n";
817
+        return $html;
818
+    }
819
+
820
+    /**
821
+     * This method can be used to create a new xajax.js file out of the
822
+     * xajax_uncompressed.js file (which will only happen if xajax.js doesn't
823
+     * already exist on the filesystem).
824
+     *
825
+     * @param string an optional argument containing the full server file path
826
+     *               of xajax.js.
827
+     */
828
+    function autoCompressJavascript($sJsFullFilename=NULL)
829
+    {
830
+        $sJsFile = "xajax_js/xajax.js";
831
+
832
+        if ($sJsFullFilename) {
833
+            $realJsFile = $sJsFullFilename;
834
+        }
835
+        else {
836
+            $realPath = realpath(dirname(__FILE__));
837
+            $realJsFile = $realPath . "/". $sJsFile;
838
+        }
839
+
840
+        // Create a compressed file if necessary
841
+        if (!file_exists($realJsFile)) {
842
+            $srcFile = str_replace(".js", "_uncompressed.js", $realJsFile);
843
+            if (!file_exists($srcFile)) {
844
+                trigger_error("The xajax uncompressed Javascript file could not be found in the <b>" . dirname($realJsFile) . "</b> folder. Error ", E_USER_ERROR);
845
+            }
846
+            require(dirname(__FILE__)."/xajaxCompress.php");
847
+            $javaScript = implode('', file($srcFile));
848
+            $compressedScript = xajaxCompressJavascript($javaScript);
849
+            $fH = @fopen($realJsFile, "w");
850
+            if (!$fH) {
851
+                trigger_error("The xajax compressed javascript file could not be written in the <b>" . dirname($realJsFile) . "</b> folder. Error ", E_USER_ERROR);
852
+            }
853
+            else {
854
+                fwrite($fH, $compressedScript);
855
+                fclose($fH);
856
+            }
857
+        }
858
+    }
859
+
860
+    /**
861
+     * Returns the current URL based upon the SERVER vars.
862
+     *
863
+     * @access private
864
+     * @return string
865
+     */
866
+    function _detectURI() {
867
+        $aURL = array();
868
+
869
+        // Try to get the request URL
870
+        if (!empty($_SERVER['REQUEST_URI'])) {
871
+            $aURL = parse_url($_SERVER['REQUEST_URI']);
872
+        }
873
+
874
+        // Fill in the empty values
875
+        if (empty($aURL['scheme'])) {
876
+            if (!empty($_SERVER['HTTP_SCHEME'])) {
877
+                $aURL['scheme'] = $_SERVER['HTTP_SCHEME'];
878
+            } else {
879
+                $aURL['scheme'] = (!empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) != 'off') ? 'https' : 'http';
880
+            }
881
+        }
882
+
883
+        if (empty($aURL['host'])) {
884
+            if (!empty($_SERVER['HTTP_HOST'])) {
885
+                if (strpos($_SERVER['HTTP_HOST'], ':') > 0) {
886
+                    list($aURL['host'], $aURL['port']) = explode(':', $_SERVER['HTTP_HOST']);
887
+                } else {
888
+                    $aURL['host'] = $_SERVER['HTTP_HOST'];
889
+                }
890
+            } else if (!empty($_SERVER['SERVER_NAME'])) {
891
+                $aURL['host'] = $_SERVER['SERVER_NAME'];
892
+            } else {
893
+                print "xajax Error: xajax failed to automatically identify your Request URI.";
894
+                print "Please set the Request URI explicitly when you instantiate the xajax object.";
895
+                exit();
896
+            }
897
+        }
898
+
899
+        if (empty($aURL['port']) && !empty($_SERVER['SERVER_PORT'])) {
900
+            $aURL['port'] = $_SERVER['SERVER_PORT'];
901
+        }
902
+
903
+        if (empty($aURL['path'])) {
904
+            if (!empty($_SERVER['PATH_INFO'])) {
905
+                $sPath = parse_url($_SERVER['PATH_INFO']);
906
+            } else {
907
+                $sPath = parse_url(api_get_self());
908
+            }
909
+            $aURL['path'] = $sPath['path'];
910
+            unset($sPath);
911
+        }
912
+
913
+        if (!empty($aURL['query'])) {
914
+            $aURL['query'] = '?'.$aURL['query'];
915
+        }
916
+
917
+        // Build the URL: Start with scheme, user and pass
918
+        $sURL = $aURL['scheme'].'://';
919
+        if (!empty($aURL['user'])) {
920
+            $sURL.= $aURL['user'];
921
+            if (!empty($aURL['pass'])) {
922
+                $sURL.= ':'.$aURL['pass'];
923
+            }
924
+            $sURL.= '@';
925
+        }
926
+
927
+        // Add the host
928
+        $sURL.= $aURL['host'];
929
+
930
+        // Add the port if needed
931
+        if (!empty($aURL['port']) && (($aURL['scheme'] == 'http' && $aURL['port'] != 80) || ($aURL['scheme'] == 'https' && $aURL['port'] != 443))) {
932
+            $sURL.= ':'.$aURL['port'];
933
+        }
934
+
935
+        // Add the path and the query string
936
+        $sURL.= $aURL['path'].@$aURL['query'];
937
+
938
+        // Clean up
939
+        unset($aURL);
940
+        return $sURL;
941
+    }
942
+
943
+    /**
944
+     * Returns true if the function name is associated with an object callback,
945
+     * false if not.
946
+     *
947
+     * @param string the name of the function
948
+     * @access private
949
+     * @return boolean
950
+     */
951
+    function _isObjectCallback($sFunction)
952
+    {
953
+        if (array_key_exists($sFunction, $this->aObjects)) return true;
954
+        return false;
955
+    }
956
+
957
+    /**
958
+     * Returns true if the function or object callback can be called, false if
959
+     * not.
960
+     *
961
+     * @param string the name of the function
962
+     * @access private
963
+     * @return boolean
964
+     */
965
+    function _isFunctionCallable($sFunction)
966
+    {
967
+        if ($this->_isObjectCallback($sFunction)) {
968
+            if (is_object($this->aObjects[$sFunction][0])) {
969
+                return method_exists($this->aObjects[$sFunction][0], $this->aObjects[$sFunction][1]);
970
+            }
971
+            else {
972
+                return is_callable($this->aObjects[$sFunction]);
973
+            }
974
+        }
975
+        else {
976
+            return function_exists($sFunction);
977
+        }
978
+    }
979
+
980
+    /**
981
+     * Calls the function, class method, or object method with the supplied
982
+     * arguments.
983
+     *
984
+     * @param string the name of the function
985
+     * @param array  arguments to pass to the function
986
+     * @access private
987
+     * @return mixed the output of the called function or method
988
+     */
989
+    function _callFunction($sFunction, $aArgs)
990
+    {
991
+        if ($this->_isObjectCallback($sFunction)) {
992
+            $mReturn = call_user_func_array($this->aObjects[$sFunction], $aArgs);
993
+        }
994
+        else {
995
+            $mReturn = call_user_func_array($sFunction, $aArgs);
996
+        }
997
+        return $mReturn;
998
+    }
999
+
1000
+    /**
1001
+     * Generates the Javascript wrapper for the specified PHP function.
1002
+     *
1003
+     * @param string the name of the function
1004
+     * @param mixed  the request type
1005
+     * @access private
1006
+     * @return string
1007
+     */
1008
+    function _wrap($sFunction,$sRequestType=XAJAX_POST)
1009
+    {
1010
+        $js = "function ".$this->sWrapperPrefix."$sFunction(){return xajax.call(\"$sFunction\", arguments, ".$sRequestType.");}\n";
1011
+        return $js;
1012
+    }
1013
+
1014
+    /**
1015
+     * Takes a string containing xajax xjxobj XML or xjxquery XML and builds an
1016
+     * array representation of it to pass as an argument to the PHP function
1017
+     * being called.
1018
+     *
1019
+     * @param string the root tag of the XML
1020
+     * @param string XML to convert
1021
+     * @access private
1022
+     * @return array
1023
+     */
1024
+    function _xmlToArray($rootTag, $sXml)
1025
+    {
1026
+        $aArray = array();
1027
+        $sXml = str_replace("<$rootTag>","<$rootTag>|~|",$sXml);
1028
+        $sXml = str_replace("</$rootTag>","</$rootTag>|~|",$sXml);
1029
+        $sXml = str_replace("<e>","<e>|~|",$sXml);
1030
+        $sXml = str_replace("</e>","</e>|~|",$sXml);
1031
+        $sXml = str_replace("<k>","<k>|~|",$sXml);
1032
+        $sXml = str_replace("</k>","|~|</k>|~|",$sXml);
1033
+        $sXml = str_replace("<v>","<v>|~|",$sXml);
1034
+        $sXml = str_replace("</v>","|~|</v>|~|",$sXml);
1035
+        $sXml = str_replace("<q>","<q>|~|",$sXml);
1036
+        $sXml = str_replace("</q>","|~|</q>|~|",$sXml);
1037
+
1038
+        $this->aObjArray = explode("|~|",$sXml);
1039
+
1040
+        $this->iPos = 0;
1041
+        $aArray = $this->_parseObjXml($rootTag);
1042
+
1043
+        return $aArray;
1044
+    }
1045
+
1046
+    /**
1047
+     * A recursive function that generates an array from the contents of
1048
+     * $this->aObjArray.
1049
+     *
1050
+     * @param string the root tag of the XML
1051
+     * @access private
1052
+     * @return array
1053
+     */
1054
+    function _parseObjXml($rootTag)
1055
+    {
1056
+        $aArray = array();
1057
+
1058
+        if ($rootTag == "xjxobj")
1059
+        {
1060
+            while(!stristr($this->aObjArray[$this->iPos],"</xjxobj>"))
1061
+            {
1062
+                $this->iPos++;
1063
+                if(stristr($this->aObjArray[$this->iPos],"<e>"))
1064
+                {
1065
+                    $key = "";
1066
+                    $value = null;
1067
+
1068
+                    $this->iPos++;
1069
+                    while(!stristr($this->aObjArray[$this->iPos],"</e>"))
1070
+                    {
1071
+                        if(stristr($this->aObjArray[$this->iPos],"<k>"))
1072
+                        {
1073
+                            $this->iPos++;
1074
+                            while(!stristr($this->aObjArray[$this->iPos],"</k>"))
1075
+                            {
1076
+                                $key .= $this->aObjArray[$this->iPos];
1077
+                                $this->iPos++;
1078
+                            }
1079
+                        }
1080
+                        if(stristr($this->aObjArray[$this->iPos],"<v>"))
1081
+                        {
1082
+                            $this->iPos++;
1083
+                            while(!stristr($this->aObjArray[$this->iPos],"</v>"))
1084
+                            {
1085
+                                if(stristr($this->aObjArray[$this->iPos],"<xjxobj>"))
1086
+                                {
1087
+                                    $value = $this->_parseObjXml("xjxobj");
1088
+                                    $this->iPos++;
1089
+                                }
1090
+                                else
1091
+                                {
1092
+                                    $value .= $this->aObjArray[$this->iPos];
1093
+                                    if ($this->bDecodeUTF8Input)
1094
+                                    {
1095
+                                        $value = $this->_decodeUTF8Data($value);
1096
+                                    }
1097
+                                }
1098
+                                $this->iPos++;
1099
+                            }
1100
+                        }
1101
+                        $this->iPos++;
1102
+                    }
1103
+
1104
+                    $aArray[$key]=$value;
1105
+                }
1106
+            }
1107
+        }
1108
+
1109
+        if ($rootTag == "xjxquery")
1110
+        {
1111
+            $sQuery = "";
1112
+            $this->iPos++;
1113
+            while(!stristr($this->aObjArray[$this->iPos],"</xjxquery>"))
1114
+            {
1115
+                if (stristr($this->aObjArray[$this->iPos],"<q>") || stristr($this->aObjArray[$this->iPos],"</q>"))
1116
+                {
1117
+                    $this->iPos++;
1118
+                    continue;
1119
+                }
1120
+                $sQuery	.= $this->aObjArray[$this->iPos];
1121
+                $this->iPos++;
1122
+            }
1123
+
1124
+            parse_str($sQuery, $aArray);
1125
+            if ($this->bDecodeUTF8Input)
1126
+            {
1127
+                foreach($aArray as $key => $value)
1128
+                {
1129
+                    $aArray[$key] = $this->_decodeUTF8Data($value);
1130
+                }
1131
+            }
1132
+            // If magic quotes is on, then we need to strip the slashes from the
1133
+            // array values because of the parse_str pass which adds slashes
1134
+            if (get_magic_quotes_gpc() == 1) {
1135
+                $newArray = array();
1136
+                foreach ($aArray as $sKey => $sValue) {
1137
+                    if (is_string($sValue))
1138
+                        $newArray[$sKey] = stripslashes($sValue);
1139
+                    else
1140
+                        $newArray[$sKey] = $sValue;
1141
+                }
1142
+                $aArray = $newArray;
1143
+            }
1144
+        }
1145
+
1146
+        return $aArray;
1147
+    }
1148
+
1149
+    /**
1150
+     * Decodes string data from UTF-8 to the current xajax encoding.
1151
+     *
1152
+     * @param string data to convert
1153
+     * @access private
1154
+     * @return string converted data
1155
+     */
1156
+    function _decodeUTF8Data($sData)
1157
+    {
1158
+        $sValue = $sData;
1159
+        if ($this->bDecodeUTF8Input)
1160
+        {
1161
+            $sFuncToUse = NULL;
1162
+
1163
+            // An adaptation for the Dokeos LMS, 22-AUG-2009.
1164
+            if (function_exists('api_convert_encoding'))
1165
+            {
1166
+                $sFuncToUse = "api_convert_encoding";
1167
+            }
1168
+            //if (function_exists('iconv'))
1169
+            elseif (function_exists('iconv'))
1170
+            //
1171
+            {
1172
+                $sFuncToUse = "iconv";
1173
+            }
1174
+            else if (function_exists('mb_convert_encoding'))
1175
+            {
1176
+                $sFuncToUse = "mb_convert_encoding";
1177
+            }
1178
+            else if ($this->sEncoding == "ISO-8859-1")
1179
+            {
1180
+                $sFuncToUse = "utf8_decode";
1181
+            }
1182
+            else
1183
+            {
1184
+                trigger_error("The incoming xajax data could not be converted from UTF-8", E_USER_NOTICE);
1185
+            }
1186
+
1187
+            if ($sFuncToUse)
1188
+            {
1189
+                if (is_string($sValue))
1190
+                {
1191
+                    if ($sFuncToUse == "iconv")
1192
+                    {
1193
+                        $sValue = iconv("UTF-8", $this->sEncoding.'//TRANSLIT', $sValue);
1194
+                    }
1195
+                    else if ($sFuncToUse == "mb_convert_encoding")
1196
+                    {
1197
+                        $sValue = mb_convert_encoding($sValue, $this->sEncoding, "UTF-8");
1198
+                    }
1199
+                    // Added code, an adaptation for the Dokeos LMS, 22-AUG-2009.
1200
+                    else if ($sFuncToUse == "api_convert_encoding")
1201
+                    {
1202
+                        $sValue = api_convert_encoding($sValue, $this->sEncoding, "UTF-8");
1203
+                    }
1204
+                    //
1205
+                    else
1206
+                    {
1207
+                        $sValue = utf8_decode($sValue);
1208
+                    }
1209
+                }
1210
+            }
1211
+        }
1212
+        return $sValue;
1213
+    }
1214 1214
 
1215 1215
 }// end class xajax
1216 1216
 
@@ -1220,31 +1220,31 @@  discard block
 block discarded – undo
1220 1220
  */
1221 1221
 function xajaxErrorHandler($errno, $errstr, $errfile, $errline)
1222 1222
 {
1223
-	$errorReporting = error_reporting();
1224
-	if (($errno & $errorReporting) == 0) return;
1225
-
1226
-	if ($errno == E_NOTICE) {
1227
-		$errTypeStr = "NOTICE";
1228
-	}
1229
-	else if ($errno == E_WARNING) {
1230
-		$errTypeStr = "WARNING";
1231
-	}
1232
-	else if ($errno == E_USER_NOTICE) {
1233
-		$errTypeStr = "USER NOTICE";
1234
-	}
1235
-	else if ($errno == E_USER_WARNING) {
1236
-		$errTypeStr = "USER WARNING";
1237
-	}
1238
-	else if ($errno == E_USER_ERROR) {
1239
-		$errTypeStr = "USER FATAL ERROR";
1240
-	}
1241
-	else if ($errno == E_STRICT) {
1242
-		return;
1243
-	}
1244
-	else {
1245
-		$errTypeStr = "UNKNOWN: $errno";
1246
-	}
1247
-	$GLOBALS['xajaxErrorHandlerText'] .= "\n----\n[$errTypeStr] $errstr\nerror in line $errline of file $errfile";
1223
+    $errorReporting = error_reporting();
1224
+    if (($errno & $errorReporting) == 0) return;
1225
+
1226
+    if ($errno == E_NOTICE) {
1227
+        $errTypeStr = "NOTICE";
1228
+    }
1229
+    else if ($errno == E_WARNING) {
1230
+        $errTypeStr = "WARNING";
1231
+    }
1232
+    else if ($errno == E_USER_NOTICE) {
1233
+        $errTypeStr = "USER NOTICE";
1234
+    }
1235
+    else if ($errno == E_USER_WARNING) {
1236
+        $errTypeStr = "USER WARNING";
1237
+    }
1238
+    else if ($errno == E_USER_ERROR) {
1239
+        $errTypeStr = "USER FATAL ERROR";
1240
+    }
1241
+    else if ($errno == E_STRICT) {
1242
+        return;
1243
+    }
1244
+    else {
1245
+        $errTypeStr = "UNKNOWN: $errno";
1246
+    }
1247
+    $GLOBALS['xajaxErrorHandlerText'] .= "\n----\n[$errTypeStr] $errstr\nerror in line $errline of file $errfile";
1248 1248
 }
1249 1249
 
1250 1250
 ?>
Please login to merge, or discard this patch.
main/inc/lib/xajax/xajaxCompress.php 4 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -39,6 +39,7 @@
 block discarded – undo
39 39
  * (used internally)
40 40
  *
41 41
  * @param string contains the Javascript code to compress
42
+ * @param string $sJS
42 43
  */
43 44
 function xajaxCompressJavascript($sJS)
44 45
 {
Please login to merge, or discard this patch.
Indentation   +136 added lines, -136 removed lines patch added patch discarded remove patch
@@ -42,141 +42,141 @@
 block discarded – undo
42 42
  */
43 43
 function xajaxCompressJavascript($sJS)
44 44
 {
45
-	//remove windows cariage returns
46
-	$sJS = str_replace("\r","",$sJS);
47
-
48
-	//array to store replaced literal strings
49
-	$literal_strings = array();
50
-
51
-	//explode the string into lines
52
-	$lines = explode("\n",$sJS);
53
-	//loop through all the lines, building a new string at the same time as removing literal strings
54
-	$clean = "";
55
-	$inComment = false;
56
-	$literal = "";
57
-	$inQuote = false;
58
-	$escaped = false;
59
-	$quoteChar = "";
60
-
61
-	for($i=0;$i<count($lines);$i++)
62
-	{
63
-		$line = $lines[$i];
64
-		$inNormalComment = false;
65
-
66
-		//loop through line's characters and take out any literal strings, replace them with ___i___ where i is the index of this string
67
-		for($j=0;$j<strlen($line);$j++)
68
-		{
69
-			$c = substr($line,$j,1);
70
-			$d = substr($line,$j,2);
71
-
72
-			//look for start of quote
73
-			if(!$inQuote && !$inComment)
74
-			{
75
-				//is this character a quote or a comment
76
-				if(($c=="\"" || $c=="'") && !$inComment && !$inNormalComment)
77
-				{
78
-					$inQuote = true;
79
-					$inComment = false;
80
-					$escaped = false;
81
-					$quoteChar = $c;
82
-					$literal = $c;
83
-				}
84
-				else if($d=="/*" && !$inNormalComment)
85
-				{
86
-					$inQuote = false;
87
-					$inComment = true;
88
-					$escaped = false;
89
-					$quoteChar = $d;
90
-					$literal = $d;
91
-					$j++;
92
-				}
93
-				else if($d=="//") //ignore string markers that are found inside comments
94
-				{
95
-					$inNormalComment = true;
96
-					$clean .= $c;
97
-				}
98
-				else
99
-				{
100
-					$clean .= $c;
101
-				}
102
-			}
103
-			else //allready in a string so find end quote
104
-			{
105
-				if($c == $quoteChar && !$escaped && !$inComment)
106
-				{
107
-					$inQuote = false;
108
-					$literal .= $c;
109
-
110
-					//subsitute in a marker for the string
111
-					$clean .= "___" . count($literal_strings) . "___";
112
-
113
-					//push the string onto our array
114
-					array_push($literal_strings,$literal);
115
-
116
-				}
117
-				else if($inComment && $d=="*/")
118
-				{
119
-					$inComment = false;
120
-					$literal .= $d;
121
-
122
-					//subsitute in a marker for the string
123
-					$clean .= "___" . count($literal_strings) . "___";
124
-
125
-					//push the string onto our array
126
-					array_push($literal_strings,$literal);
127
-
128
-					$j++;
129
-				}
130
-				else if($c == "\\" && !$escaped)
131
-					$escaped = true;
132
-				else
133
-					$escaped = false;
134
-
135
-				$literal .= $c;
136
-			}
137
-		}
138
-		if($inComment) $literal .= "\n";
139
-		$clean .= "\n";
140
-	}
141
-	//explode the clean string into lines again
142
-	$lines = explode("\n",$clean);
143
-
144
-	//now process each line at a time
145
-	for($i=0;$i<count($lines);$i++)
146
-	{
147
-		$line = $lines[$i];
148
-
149
-		//remove comments
150
-		$line = preg_replace("/\/\/(.*)/","",$line);
151
-
152
-		//strip leading and trailing whitespace
153
-		$line = trim($line);
154
-
155
-		//remove all whitespace with a single space
156
-		$line = preg_replace("/\s+/"," ",$line);
157
-
158
-		//remove any whitespace that occurs after/before an operator
159
-		$line = preg_replace("/\s*([!\}\{;,&=\|\-\+\*\/\)\(:])\s*/","\\1",$line);
160
-
161
-		$lines[$i] = $line;
162
-	}
163
-
164
-	//implode the lines
165
-	$sJS = implode("\n",$lines);
166
-
167
-	//make sure there is a max of 1 \n after each line
168
-	$sJS = preg_replace("/[\n]+/","\n",$sJS);
169
-
170
-	//strip out line breaks that immediately follow a semi-colon
171
-	$sJS = preg_replace("/;\n/",";",$sJS);
172
-
173
-	//curly brackets aren't on their own
174
-	$sJS = preg_replace("/[\n]*\{[\n]*/","{",$sJS);
175
-
176
-	//finally loop through and replace all the literal strings:
177
-	for($i=0;$i<count($literal_strings);$i++)
178
-		$sJS = str_replace("___".$i."___",$literal_strings[$i],$sJS);
179
-
180
-	return $sJS;
45
+    //remove windows cariage returns
46
+    $sJS = str_replace("\r","",$sJS);
47
+
48
+    //array to store replaced literal strings
49
+    $literal_strings = array();
50
+
51
+    //explode the string into lines
52
+    $lines = explode("\n",$sJS);
53
+    //loop through all the lines, building a new string at the same time as removing literal strings
54
+    $clean = "";
55
+    $inComment = false;
56
+    $literal = "";
57
+    $inQuote = false;
58
+    $escaped = false;
59
+    $quoteChar = "";
60
+
61
+    for($i=0;$i<count($lines);$i++)
62
+    {
63
+        $line = $lines[$i];
64
+        $inNormalComment = false;
65
+
66
+        //loop through line's characters and take out any literal strings, replace them with ___i___ where i is the index of this string
67
+        for($j=0;$j<strlen($line);$j++)
68
+        {
69
+            $c = substr($line,$j,1);
70
+            $d = substr($line,$j,2);
71
+
72
+            //look for start of quote
73
+            if(!$inQuote && !$inComment)
74
+            {
75
+                //is this character a quote or a comment
76
+                if(($c=="\"" || $c=="'") && !$inComment && !$inNormalComment)
77
+                {
78
+                    $inQuote = true;
79
+                    $inComment = false;
80
+                    $escaped = false;
81
+                    $quoteChar = $c;
82
+                    $literal = $c;
83
+                }
84
+                else if($d=="/*" && !$inNormalComment)
85
+                {
86
+                    $inQuote = false;
87
+                    $inComment = true;
88
+                    $escaped = false;
89
+                    $quoteChar = $d;
90
+                    $literal = $d;
91
+                    $j++;
92
+                }
93
+                else if($d=="//") //ignore string markers that are found inside comments
94
+                {
95
+                    $inNormalComment = true;
96
+                    $clean .= $c;
97
+                }
98
+                else
99
+                {
100
+                    $clean .= $c;
101
+                }
102
+            }
103
+            else //allready in a string so find end quote
104
+            {
105
+                if($c == $quoteChar && !$escaped && !$inComment)
106
+                {
107
+                    $inQuote = false;
108
+                    $literal .= $c;
109
+
110
+                    //subsitute in a marker for the string
111
+                    $clean .= "___" . count($literal_strings) . "___";
112
+
113
+                    //push the string onto our array
114
+                    array_push($literal_strings,$literal);
115
+
116
+                }
117
+                else if($inComment && $d=="*/")
118
+                {
119
+                    $inComment = false;
120
+                    $literal .= $d;
121
+
122
+                    //subsitute in a marker for the string
123
+                    $clean .= "___" . count($literal_strings) . "___";
124
+
125
+                    //push the string onto our array
126
+                    array_push($literal_strings,$literal);
127
+
128
+                    $j++;
129
+                }
130
+                else if($c == "\\" && !$escaped)
131
+                    $escaped = true;
132
+                else
133
+                    $escaped = false;
134
+
135
+                $literal .= $c;
136
+            }
137
+        }
138
+        if($inComment) $literal .= "\n";
139
+        $clean .= "\n";
140
+    }
141
+    //explode the clean string into lines again
142
+    $lines = explode("\n",$clean);
143
+
144
+    //now process each line at a time
145
+    for($i=0;$i<count($lines);$i++)
146
+    {
147
+        $line = $lines[$i];
148
+
149
+        //remove comments
150
+        $line = preg_replace("/\/\/(.*)/","",$line);
151
+
152
+        //strip leading and trailing whitespace
153
+        $line = trim($line);
154
+
155
+        //remove all whitespace with a single space
156
+        $line = preg_replace("/\s+/"," ",$line);
157
+
158
+        //remove any whitespace that occurs after/before an operator
159
+        $line = preg_replace("/\s*([!\}\{;,&=\|\-\+\*\/\)\(:])\s*/","\\1",$line);
160
+
161
+        $lines[$i] = $line;
162
+    }
163
+
164
+    //implode the lines
165
+    $sJS = implode("\n",$lines);
166
+
167
+    //make sure there is a max of 1 \n after each line
168
+    $sJS = preg_replace("/[\n]+/","\n",$sJS);
169
+
170
+    //strip out line breaks that immediately follow a semi-colon
171
+    $sJS = preg_replace("/;\n/",";",$sJS);
172
+
173
+    //curly brackets aren't on their own
174
+    $sJS = preg_replace("/[\n]*\{[\n]*/","{",$sJS);
175
+
176
+    //finally loop through and replace all the literal strings:
177
+    for($i=0;$i<count($literal_strings);$i++)
178
+        $sJS = str_replace("___".$i."___",$literal_strings[$i],$sJS);
179
+
180
+    return $sJS;
181 181
 }
182 182
 ?>
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -43,13 +43,13 @@  discard block
 block discarded – undo
43 43
 function xajaxCompressJavascript($sJS)
44 44
 {
45 45
 	//remove windows cariage returns
46
-	$sJS = str_replace("\r","",$sJS);
46
+	$sJS = str_replace("\r", "", $sJS);
47 47
 
48 48
 	//array to store replaced literal strings
49 49
 	$literal_strings = array();
50 50
 
51 51
 	//explode the string into lines
52
-	$lines = explode("\n",$sJS);
52
+	$lines = explode("\n", $sJS);
53 53
 	//loop through all the lines, building a new string at the same time as removing literal strings
54 54
 	$clean = "";
55 55
 	$inComment = false;
@@ -58,22 +58,22 @@  discard block
 block discarded – undo
58 58
 	$escaped = false;
59 59
 	$quoteChar = "";
60 60
 
61
-	for($i=0;$i<count($lines);$i++)
61
+	for ($i = 0; $i < count($lines); $i++)
62 62
 	{
63 63
 		$line = $lines[$i];
64 64
 		$inNormalComment = false;
65 65
 
66 66
 		//loop through line's characters and take out any literal strings, replace them with ___i___ where i is the index of this string
67
-		for($j=0;$j<strlen($line);$j++)
67
+		for ($j = 0; $j < strlen($line); $j++)
68 68
 		{
69
-			$c = substr($line,$j,1);
70
-			$d = substr($line,$j,2);
69
+			$c = substr($line, $j, 1);
70
+			$d = substr($line, $j, 2);
71 71
 
72 72
 			//look for start of quote
73
-			if(!$inQuote && !$inComment)
73
+			if (!$inQuote && !$inComment)
74 74
 			{
75 75
 				//is this character a quote or a comment
76
-				if(($c=="\"" || $c=="'") && !$inComment && !$inNormalComment)
76
+				if (($c == "\"" || $c == "'") && !$inComment && !$inNormalComment)
77 77
 				{
78 78
 					$inQuote = true;
79 79
 					$inComment = false;
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 					$quoteChar = $c;
82 82
 					$literal = $c;
83 83
 				}
84
-				else if($d=="/*" && !$inNormalComment)
84
+				else if ($d == "/*" && !$inNormalComment)
85 85
 				{
86 86
 					$inQuote = false;
87 87
 					$inComment = true;
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 					$literal = $d;
91 91
 					$j++;
92 92
 				}
93
-				else if($d=="//") //ignore string markers that are found inside comments
93
+				else if ($d == "//") //ignore string markers that are found inside comments
94 94
 				{
95 95
 					$inNormalComment = true;
96 96
 					$clean .= $c;
@@ -102,32 +102,32 @@  discard block
 block discarded – undo
102 102
 			}
103 103
 			else //allready in a string so find end quote
104 104
 			{
105
-				if($c == $quoteChar && !$escaped && !$inComment)
105
+				if ($c == $quoteChar && !$escaped && !$inComment)
106 106
 				{
107 107
 					$inQuote = false;
108 108
 					$literal .= $c;
109 109
 
110 110
 					//subsitute in a marker for the string
111
-					$clean .= "___" . count($literal_strings) . "___";
111
+					$clean .= "___".count($literal_strings)."___";
112 112
 
113 113
 					//push the string onto our array
114
-					array_push($literal_strings,$literal);
114
+					array_push($literal_strings, $literal);
115 115
 
116 116
 				}
117
-				else if($inComment && $d=="*/")
117
+				else if ($inComment && $d == "*/")
118 118
 				{
119 119
 					$inComment = false;
120 120
 					$literal .= $d;
121 121
 
122 122
 					//subsitute in a marker for the string
123
-					$clean .= "___" . count($literal_strings) . "___";
123
+					$clean .= "___".count($literal_strings)."___";
124 124
 
125 125
 					//push the string onto our array
126
-					array_push($literal_strings,$literal);
126
+					array_push($literal_strings, $literal);
127 127
 
128 128
 					$j++;
129 129
 				}
130
-				else if($c == "\\" && !$escaped)
130
+				else if ($c == "\\" && !$escaped)
131 131
 					$escaped = true;
132 132
 				else
133 133
 					$escaped = false;
@@ -135,47 +135,47 @@  discard block
 block discarded – undo
135 135
 				$literal .= $c;
136 136
 			}
137 137
 		}
138
-		if($inComment) $literal .= "\n";
138
+		if ($inComment) $literal .= "\n";
139 139
 		$clean .= "\n";
140 140
 	}
141 141
 	//explode the clean string into lines again
142
-	$lines = explode("\n",$clean);
142
+	$lines = explode("\n", $clean);
143 143
 
144 144
 	//now process each line at a time
145
-	for($i=0;$i<count($lines);$i++)
145
+	for ($i = 0; $i < count($lines); $i++)
146 146
 	{
147 147
 		$line = $lines[$i];
148 148
 
149 149
 		//remove comments
150
-		$line = preg_replace("/\/\/(.*)/","",$line);
150
+		$line = preg_replace("/\/\/(.*)/", "", $line);
151 151
 
152 152
 		//strip leading and trailing whitespace
153 153
 		$line = trim($line);
154 154
 
155 155
 		//remove all whitespace with a single space
156
-		$line = preg_replace("/\s+/"," ",$line);
156
+		$line = preg_replace("/\s+/", " ", $line);
157 157
 
158 158
 		//remove any whitespace that occurs after/before an operator
159
-		$line = preg_replace("/\s*([!\}\{;,&=\|\-\+\*\/\)\(:])\s*/","\\1",$line);
159
+		$line = preg_replace("/\s*([!\}\{;,&=\|\-\+\*\/\)\(:])\s*/", "\\1", $line);
160 160
 
161 161
 		$lines[$i] = $line;
162 162
 	}
163 163
 
164 164
 	//implode the lines
165
-	$sJS = implode("\n",$lines);
165
+	$sJS = implode("\n", $lines);
166 166
 
167 167
 	//make sure there is a max of 1 \n after each line
168
-	$sJS = preg_replace("/[\n]+/","\n",$sJS);
168
+	$sJS = preg_replace("/[\n]+/", "\n", $sJS);
169 169
 
170 170
 	//strip out line breaks that immediately follow a semi-colon
171
-	$sJS = preg_replace("/;\n/",";",$sJS);
171
+	$sJS = preg_replace("/;\n/", ";", $sJS);
172 172
 
173 173
 	//curly brackets aren't on their own
174
-	$sJS = preg_replace("/[\n]*\{[\n]*/","{",$sJS);
174
+	$sJS = preg_replace("/[\n]*\{[\n]*/", "{", $sJS);
175 175
 
176 176
 	//finally loop through and replace all the literal strings:
177
-	for($i=0;$i<count($literal_strings);$i++)
178
-		$sJS = str_replace("___".$i."___",$literal_strings[$i],$sJS);
177
+	for ($i = 0; $i < count($literal_strings); $i++)
178
+		$sJS = str_replace("___".$i."___", $literal_strings[$i], $sJS);
179 179
 
180 180
 	return $sJS;
181 181
 }
Please login to merge, or discard this patch.
Braces   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -80,8 +80,7 @@  discard block
 block discarded – undo
80 80
 					$escaped = false;
81 81
 					$quoteChar = $c;
82 82
 					$literal = $c;
83
-				}
84
-				else if($d=="/*" && !$inNormalComment)
83
+				} else if($d=="/*" && !$inNormalComment)
85 84
 				{
86 85
 					$inQuote = false;
87 86
 					$inComment = true;
@@ -89,18 +88,17 @@  discard block
 block discarded – undo
89 88
 					$quoteChar = $d;
90 89
 					$literal = $d;
91 90
 					$j++;
92
-				}
93
-				else if($d=="//") //ignore string markers that are found inside comments
91
+				} else if($d=="//") {
92
+				    //ignore string markers that are found inside comments
94 93
 				{
95 94
 					$inNormalComment = true;
96
-					$clean .= $c;
97 95
 				}
98
-				else
96
+					$clean .= $c;
97
+				} else
99 98
 				{
100 99
 					$clean .= $c;
101 100
 				}
102
-			}
103
-			else //allready in a string so find end quote
101
+			} else //allready in a string so find end quote
104 102
 			{
105 103
 				if($c == $quoteChar && !$escaped && !$inComment)
106 104
 				{
@@ -113,8 +111,7 @@  discard block
 block discarded – undo
113 111
 					//push the string onto our array
114 112
 					array_push($literal_strings,$literal);
115 113
 
116
-				}
117
-				else if($inComment && $d=="*/")
114
+				} else if($inComment && $d=="*/")
118 115
 				{
119 116
 					$inComment = false;
120 117
 					$literal .= $d;
@@ -126,16 +123,18 @@  discard block
 block discarded – undo
126 123
 					array_push($literal_strings,$literal);
127 124
 
128 125
 					$j++;
126
+				} else if($c == "\\" && !$escaped) {
127
+									$escaped = true;
128
+				} else {
129
+									$escaped = false;
129 130
 				}
130
-				else if($c == "\\" && !$escaped)
131
-					$escaped = true;
132
-				else
133
-					$escaped = false;
134 131
 
135 132
 				$literal .= $c;
136 133
 			}
137 134
 		}
138
-		if($inComment) $literal .= "\n";
135
+		if($inComment) {
136
+		    $literal .= "\n";
137
+		}
139 138
 		$clean .= "\n";
140 139
 	}
141 140
 	//explode the clean string into lines again
@@ -174,8 +173,9 @@  discard block
 block discarded – undo
174 173
 	$sJS = preg_replace("/[\n]*\{[\n]*/","{",$sJS);
175 174
 
176 175
 	//finally loop through and replace all the literal strings:
177
-	for($i=0;$i<count($literal_strings);$i++)
178
-		$sJS = str_replace("___".$i."___",$literal_strings[$i],$sJS);
176
+	for($i=0;$i<count($literal_strings);$i++) {
177
+			$sJS = str_replace("___".$i."___",$literal_strings[$i],$sJS);
178
+	}
179 179
 
180 180
 	return $sJS;
181 181
 }
Please login to merge, or discard this patch.
main/inc/lib/xajax/xajaxResponse.inc.php 4 patches
Doc Comments   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -97,6 +97,7 @@  discard block
 block discarded – undo
97 97
 	 * @param string  contains the character encoding string to use
98 98
 	 * @param boolean lets you set if you want special characters in the output
99 99
 	 *                converted to HTML entities
100
+	 * @param string $sEncoding
100 101
 	 *
101 102
 	 */
102 103
 	function xajaxResponse($sEncoding=XAJAX_DEFAULT_CHAR_ENCODING, $bOutputEntities=false)
@@ -223,6 +224,8 @@  discard block
 block discarded – undo
223 224
 	 * @param string contains the id of an HTML element
224 225
 	 * @param string the part of the element you wish to clear ("innerHTML",
225 226
 	 *               "value", etc.)
227
+	 * @param string $sTarget
228
+	 * @param string $sAttribute
226 229
 	 */
227 230
 	function addClear($sTarget,$sAttribute)
228 231
 	{
@@ -279,6 +282,7 @@  discard block
 block discarded – undo
279 282
 	 * <i>Usage:</i> <kbd>$objResponse->addScript("var x = prompt('get some text');");</kbd>
280 283
 	 *
281 284
 	 * @param string contains Javascript code to be executed
285
+	 * @param string $sJS
282 286
 	 */
283 287
 	function addScript($sJS)
284 288
 	{
@@ -290,8 +294,6 @@  discard block
 block discarded – undo
290 294
 	 *
291 295
 	 * <i>Usage:</i> <kbd>$objResponse->addScriptCall("myJSFunction", "arg 1", "arg 2", 12345);</kbd>
292 296
 	 *
293
-	 * @param string $sFunc the name of a Javascript function
294
-	 * @param mixed $args,... optional arguments to pass to the Javascript function
295 297
 	 */
296 298
 	function addScriptCall() {
297 299
 		$arguments = func_get_args();
Please login to merge, or discard this patch.
Braces   +21 added lines, -17 removed lines patch added patch discarded remove patch
@@ -258,8 +258,9 @@  discard block
 block discarded – undo
258 258
 		{
259 259
 			$queryStart++;
260 260
 			$queryEnd = strpos($sURL, '#', $queryStart);
261
-			if ($queryEnd === FALSE)
262
-				$queryEnd = strlen($sURL);
261
+			if ($queryEnd === FALSE) {
262
+							$queryEnd = strlen($sURL);
263
+			}
263 264
 			$queryPart = substr($sURL, $queryStart, $queryEnd-$queryStart);
264 265
             $queryParts = array();
265 266
 			parse_str($queryPart, $queryParts);
@@ -487,8 +488,9 @@  discard block
 block discarded – undo
487 488
 	function getXML()
488 489
 	{
489 490
 		$sXML = "<?xml version=\"1.0\"";
490
-		if ($this->sEncoding && strlen(trim($this->sEncoding)) > 0)
491
-			$sXML .= " encoding=\"".$this->sEncoding."\"";
491
+		if ($this->sEncoding && strlen(trim($this->sEncoding)) > 0) {
492
+					$sXML .= " encoding=\"".$this->sEncoding."\"";
493
+		}
492 494
 		$sXML .= " ?"."><xjx>" . $this->xml . "</xjx>";
493 495
 
494 496
 		return $sXML;
@@ -538,20 +540,21 @@  discard block
 block discarded – undo
538 540
 			elseif (function_exists('mb_convert_encoding')) {
539 541
 			//
540 542
 				$sData = call_user_func_array('mb_convert_encoding', array(&$sData, 'HTML-ENTITIES', $this->sEncoding));
541
-			}
542
-			else {
543
+			} else {
543 544
 				trigger_error("The xajax XML response output could not be converted to HTML entities because the mb_convert_encoding function is not available", E_USER_NOTICE);
544 545
 			}
545 546
 		}
546 547
 		$xml = "<cmd";
547
-		foreach($aAttributes as $sAttribute => $sValue)
548
-			$xml .= " $sAttribute=\"$sValue\"";
549
-		if ($sData !== null && !stristr($sData,'<![CDATA['))
550
-			$xml .= "><![CDATA[$sData]]></cmd>";
551
-		else if ($sData !== null)
552
-			$xml .= ">$sData</cmd>";
553
-		else
554
-			$xml .= "></cmd>";
548
+		foreach($aAttributes as $sAttribute => $sValue) {
549
+					$xml .= " $sAttribute=\"$sValue\"";
550
+		}
551
+		if ($sData !== null && !stristr($sData,'<![CDATA[')) {
552
+					$xml .= "><![CDATA[$sData]]></cmd>";
553
+		} else if ($sData !== null) {
554
+					$xml .= ">$sData</cmd>";
555
+		} else {
556
+					$xml .= "></cmd>";
557
+		}
555 558
 
556 559
 		return $xml;
557 560
 	}
@@ -566,11 +569,12 @@  discard block
 block discarded – undo
566 569
 	 * @return string serialized XML
567 570
 	 */
568 571
 	function _buildObjXml($var) {
569
-		if (gettype($var) == "object") $var = get_object_vars($var);
572
+		if (gettype($var) == "object") {
573
+		    $var = get_object_vars($var);
574
+		}
570 575
 		if (!is_array($var)) {
571 576
 			return "<![CDATA[$var]]>";
572
-		}
573
-		else {
577
+		} else {
574 578
 			$data = "<xjxobj>";
575 579
 			foreach ($var as $key => $value) {
576 580
 				$data .= "<e>";
Please login to merge, or discard this patch.
Indentation   +512 added lines, -512 removed lines patch added patch discarded remove patch
@@ -67,521 +67,521 @@
 block discarded – undo
67 67
  */
68 68
 class xajaxResponse
69 69
 {
70
-	/**#@+
70
+    /**#@+
71 71
 	 * @access protected
72 72
 	 */
73
-	/**
74
-	 * @var string internal XML storage
75
-	 */
76
-	var $xml;
77
-	/**
78
-	 * @var string the encoding type to use
79
-	 */
80
-	var $sEncoding;
81
-	/**
82
-	 * @var boolean if special characters in the XML should be converted to
83
-	 *              entities
84
-	 */
85
-	var $bOutputEntities;
86
-
87
-	/**#@-*/
88
-
89
-	/**
90
-	 * The constructor's main job is to set the character encoding for the
91
-	 * response.
92
-	 *
93
-	 * <i>Note:</i> to change the character encoding for all of the
94
-	 * responses, set the XAJAX_DEFAULT_ENCODING constant before you
95
-	 * instantiate xajax.
96
-	 *
97
-	 * @param string  contains the character encoding string to use
98
-	 * @param boolean lets you set if you want special characters in the output
99
-	 *                converted to HTML entities
100
-	 *
101
-	 */
102
-	public function __construct($sEncoding=XAJAX_DEFAULT_CHAR_ENCODING, $bOutputEntities=false)
103
-	{
104
-		$this->setCharEncoding($sEncoding);
105
-		$this->bOutputEntities = $bOutputEntities;
106
-	}
107
-
108
-	/**
109
-	 * Sets the character encoding for the response based on $sEncoding, which
110
-	 * is a string containing the character encoding to use. You don't need to
111
-	 * use this method normally, since the character encoding for the response
112
-	 * gets set automatically based on the XAJAX_DEFAULT_CHAR_ENCODING
113
-	 * constant.
114
-	 *
115
-	 * @param string
116
-	 */
117
-	function setCharEncoding($sEncoding)
118
-	{
119
-		$this->sEncoding = $sEncoding;
120
-	}
121
-
122
-	/**
123
-	 * Tells the response object to convert special characters to HTML entities
124
-	 * automatically (only works if the mb_string extension is available).
125
-	 */
126
-	function outputEntitiesOn()
127
-	{
128
-		$this->bOutputEntities = true;
129
-	}
130
-
131
-	/**
132
-	 * Tells the response object to output special characters intact. (default
133
-	 * behavior)
134
-	 */
135
-	function outputEntitiesOff()
136
-	{
137
-		$this->bOutputEntities = false;
138
-	}
139
-
140
-	/**
141
-	 * Adds a confirm commands command message to the XML response.
142
-	 *
143
-	 * <i>Usage:</i> <kbd>$objResponse->addConfirmCommands(1, "Do you want to preview the new data?");</kbd>
144
-	 *
145
-	 * @param integer the number of commands to skip if the user presses
146
-	 *                Cancel in the browsers's confirm dialog
147
-	 * @param string  the message to show in the browser's confirm dialog
148
-	 */
149
-	function addConfirmCommands($iCmdNumber, $sMessage)
150
-	{
151
-		$this->xml .= $this->_cmdXML(array("n"=>"cc","t"=>$iCmdNumber),$sMessage);
152
-	}
153
-
154
-	/**
155
-	 * Adds an assign command message to the XML response.
156
-	 *
157
-	 * <i>Usage:</i> <kbd>$objResponse->addAssign("contentDiv", "innerHTML", "Some Text");</kbd>
158
-	 *
159
-	 * @param string contains the id of an HTML element
160
-	 * @param string the part of the element you wish to modify ("innerHTML",
161
-	 *               "value", etc.)
162
-	 * @param string the data you want to set the attribute to
163
-	 */
164
-	function addAssign($sTarget,$sAttribute,$sData)
165
-	{
166
-		$this->xml .= $this->_cmdXML(array("n"=>"as","t"=>$sTarget,"p"=>$sAttribute),$sData);
167
-	}
168
-
169
-	/**
170
-	 * Adds an append command message to the XML response.
171
-	 *
172
-	 * <i>Usage:</i> <kbd>$objResponse->addAppend("contentDiv", "innerHTML", "Some New Text");</kbd>
173
-	 *
174
-	 * @param string contains the id of an HTML element
175
-	 * @param string the part of the element you wish to modify ("innerHTML",
176
-	 *               "value", etc.)
177
-	 * @param string the data you want to append to the end of the attribute
178
-	 */
179
-	function addAppend($sTarget,$sAttribute,$sData)
180
-	{
181
-		$this->xml .= $this->_cmdXML(array("n"=>"ap","t"=>$sTarget,"p"=>$sAttribute),$sData);
182
-	}
183
-
184
-	/**
185
-	 * Adds an prepend command message to the XML response.
186
-	 *
187
-	 * <i>Usage:</i> <kbd>$objResponse->addPrepend("contentDiv", "innerHTML", "Some Starting Text");</kbd>
188
-	 *
189
-	 * @param string contains the id of an HTML element
190
-	 * @param string the part of the element you wish to modify ("innerHTML",
191
-	 *               "value", etc.)
192
-	 * @param string the data you want to prepend to the beginning of the
193
-	 *               attribute
194
-	 */
195
-	function addPrepend($sTarget,$sAttribute,$sData)
196
-	{
197
-		$this->xml .= $this->_cmdXML(array("n"=>"pp","t"=>$sTarget,"p"=>$sAttribute),$sData);
198
-	}
199
-
200
-	/**
201
-	 * Adds a replace command message to the XML response.
202
-	 *
203
-	 * <i>Usage:</i> <kbd>$objResponse->addReplace("contentDiv", "innerHTML", "text", "<b>text</b>");</kbd>
204
-	 *
205
-	 * @param string contains the id of an HTML element
206
-	 * @param string the part of the element you wish to modify ("innerHTML",
207
-	 *               "value", etc.)
208
-	 * @param string the string to search for
209
-	 * @param string the string to replace the search string when found in the
210
-	 *               attribute
211
-	 */
212
-	function addReplace($sTarget,$sAttribute,$sSearch,$sData)
213
-	{
214
-		$sDta = "<s><![CDATA[$sSearch]]></s><r><![CDATA[$sData]]></r>";
215
-		$this->xml .= $this->_cmdXML(array("n"=>"rp","t"=>$sTarget,"p"=>$sAttribute),$sDta);
216
-	}
217
-
218
-	/**
219
-	 * Adds a clear command message to the XML response.
220
-	 *
221
-	 * <i>Usage:</i> <kbd>$objResponse->addClear("contentDiv", "innerHTML");</kbd>
222
-	 *
223
-	 * @param string contains the id of an HTML element
224
-	 * @param string the part of the element you wish to clear ("innerHTML",
225
-	 *               "value", etc.)
226
-	 */
227
-	function addClear($sTarget,$sAttribute)
228
-	{
229
-		$this->addAssign($sTarget,$sAttribute,'');
230
-	}
231
-
232
-	/**
233
-	 * Adds an alert command message to the XML response.
234
-	 *
235
-	 * <i>Usage:</i> <kbd>$objResponse->addAlert("This is important information");</kbd>
236
-	 *
237
-	 * @param string the text to be displayed in the Javascript alert box
238
-	 */
239
-	function addAlert($sMsg)
240
-	{
241
-		$this->xml .= $this->_cmdXML(array("n"=>"al"),$sMsg);
242
-	}
243
-
244
-	/**
245
-	 * Uses the addScript() method to add a Javascript redirect to another URL.
246
-	 *
247
-	 * <i>Usage:</i> <kbd>$objResponse->addRedirect("http://www.xajaxproject.org");</kbd>
248
-	 *
249
-	 * @param string the URL to redirect the client browser to
250
-	 */
251
-	function addRedirect($sURL)
252
-	{
253
-		//we need to parse the query part so that the values are rawurlencode()'ed
254
-		//can't just use parse_url() cos we could be dealing with a relative URL which
255
-		//  parse_url() can't deal with.
256
-		$queryStart = strpos($sURL, '?', strrpos($sURL, '/'));
257
-		if ($queryStart !== FALSE)
258
-		{
259
-			$queryStart++;
260
-			$queryEnd = strpos($sURL, '#', $queryStart);
261
-			if ($queryEnd === FALSE)
262
-				$queryEnd = strlen($sURL);
263
-			$queryPart = substr($sURL, $queryStart, $queryEnd-$queryStart);
73
+    /**
74
+     * @var string internal XML storage
75
+     */
76
+    var $xml;
77
+    /**
78
+     * @var string the encoding type to use
79
+     */
80
+    var $sEncoding;
81
+    /**
82
+     * @var boolean if special characters in the XML should be converted to
83
+     *              entities
84
+     */
85
+    var $bOutputEntities;
86
+
87
+    /**#@-*/
88
+
89
+    /**
90
+     * The constructor's main job is to set the character encoding for the
91
+     * response.
92
+     *
93
+     * <i>Note:</i> to change the character encoding for all of the
94
+     * responses, set the XAJAX_DEFAULT_ENCODING constant before you
95
+     * instantiate xajax.
96
+     *
97
+     * @param string  contains the character encoding string to use
98
+     * @param boolean lets you set if you want special characters in the output
99
+     *                converted to HTML entities
100
+     *
101
+     */
102
+    public function __construct($sEncoding=XAJAX_DEFAULT_CHAR_ENCODING, $bOutputEntities=false)
103
+    {
104
+        $this->setCharEncoding($sEncoding);
105
+        $this->bOutputEntities = $bOutputEntities;
106
+    }
107
+
108
+    /**
109
+     * Sets the character encoding for the response based on $sEncoding, which
110
+     * is a string containing the character encoding to use. You don't need to
111
+     * use this method normally, since the character encoding for the response
112
+     * gets set automatically based on the XAJAX_DEFAULT_CHAR_ENCODING
113
+     * constant.
114
+     *
115
+     * @param string
116
+     */
117
+    function setCharEncoding($sEncoding)
118
+    {
119
+        $this->sEncoding = $sEncoding;
120
+    }
121
+
122
+    /**
123
+     * Tells the response object to convert special characters to HTML entities
124
+     * automatically (only works if the mb_string extension is available).
125
+     */
126
+    function outputEntitiesOn()
127
+    {
128
+        $this->bOutputEntities = true;
129
+    }
130
+
131
+    /**
132
+     * Tells the response object to output special characters intact. (default
133
+     * behavior)
134
+     */
135
+    function outputEntitiesOff()
136
+    {
137
+        $this->bOutputEntities = false;
138
+    }
139
+
140
+    /**
141
+     * Adds a confirm commands command message to the XML response.
142
+     *
143
+     * <i>Usage:</i> <kbd>$objResponse->addConfirmCommands(1, "Do you want to preview the new data?");</kbd>
144
+     *
145
+     * @param integer the number of commands to skip if the user presses
146
+     *                Cancel in the browsers's confirm dialog
147
+     * @param string  the message to show in the browser's confirm dialog
148
+     */
149
+    function addConfirmCommands($iCmdNumber, $sMessage)
150
+    {
151
+        $this->xml .= $this->_cmdXML(array("n"=>"cc","t"=>$iCmdNumber),$sMessage);
152
+    }
153
+
154
+    /**
155
+     * Adds an assign command message to the XML response.
156
+     *
157
+     * <i>Usage:</i> <kbd>$objResponse->addAssign("contentDiv", "innerHTML", "Some Text");</kbd>
158
+     *
159
+     * @param string contains the id of an HTML element
160
+     * @param string the part of the element you wish to modify ("innerHTML",
161
+     *               "value", etc.)
162
+     * @param string the data you want to set the attribute to
163
+     */
164
+    function addAssign($sTarget,$sAttribute,$sData)
165
+    {
166
+        $this->xml .= $this->_cmdXML(array("n"=>"as","t"=>$sTarget,"p"=>$sAttribute),$sData);
167
+    }
168
+
169
+    /**
170
+     * Adds an append command message to the XML response.
171
+     *
172
+     * <i>Usage:</i> <kbd>$objResponse->addAppend("contentDiv", "innerHTML", "Some New Text");</kbd>
173
+     *
174
+     * @param string contains the id of an HTML element
175
+     * @param string the part of the element you wish to modify ("innerHTML",
176
+     *               "value", etc.)
177
+     * @param string the data you want to append to the end of the attribute
178
+     */
179
+    function addAppend($sTarget,$sAttribute,$sData)
180
+    {
181
+        $this->xml .= $this->_cmdXML(array("n"=>"ap","t"=>$sTarget,"p"=>$sAttribute),$sData);
182
+    }
183
+
184
+    /**
185
+     * Adds an prepend command message to the XML response.
186
+     *
187
+     * <i>Usage:</i> <kbd>$objResponse->addPrepend("contentDiv", "innerHTML", "Some Starting Text");</kbd>
188
+     *
189
+     * @param string contains the id of an HTML element
190
+     * @param string the part of the element you wish to modify ("innerHTML",
191
+     *               "value", etc.)
192
+     * @param string the data you want to prepend to the beginning of the
193
+     *               attribute
194
+     */
195
+    function addPrepend($sTarget,$sAttribute,$sData)
196
+    {
197
+        $this->xml .= $this->_cmdXML(array("n"=>"pp","t"=>$sTarget,"p"=>$sAttribute),$sData);
198
+    }
199
+
200
+    /**
201
+     * Adds a replace command message to the XML response.
202
+     *
203
+     * <i>Usage:</i> <kbd>$objResponse->addReplace("contentDiv", "innerHTML", "text", "<b>text</b>");</kbd>
204
+     *
205
+     * @param string contains the id of an HTML element
206
+     * @param string the part of the element you wish to modify ("innerHTML",
207
+     *               "value", etc.)
208
+     * @param string the string to search for
209
+     * @param string the string to replace the search string when found in the
210
+     *               attribute
211
+     */
212
+    function addReplace($sTarget,$sAttribute,$sSearch,$sData)
213
+    {
214
+        $sDta = "<s><![CDATA[$sSearch]]></s><r><![CDATA[$sData]]></r>";
215
+        $this->xml .= $this->_cmdXML(array("n"=>"rp","t"=>$sTarget,"p"=>$sAttribute),$sDta);
216
+    }
217
+
218
+    /**
219
+     * Adds a clear command message to the XML response.
220
+     *
221
+     * <i>Usage:</i> <kbd>$objResponse->addClear("contentDiv", "innerHTML");</kbd>
222
+     *
223
+     * @param string contains the id of an HTML element
224
+     * @param string the part of the element you wish to clear ("innerHTML",
225
+     *               "value", etc.)
226
+     */
227
+    function addClear($sTarget,$sAttribute)
228
+    {
229
+        $this->addAssign($sTarget,$sAttribute,'');
230
+    }
231
+
232
+    /**
233
+     * Adds an alert command message to the XML response.
234
+     *
235
+     * <i>Usage:</i> <kbd>$objResponse->addAlert("This is important information");</kbd>
236
+     *
237
+     * @param string the text to be displayed in the Javascript alert box
238
+     */
239
+    function addAlert($sMsg)
240
+    {
241
+        $this->xml .= $this->_cmdXML(array("n"=>"al"),$sMsg);
242
+    }
243
+
244
+    /**
245
+     * Uses the addScript() method to add a Javascript redirect to another URL.
246
+     *
247
+     * <i>Usage:</i> <kbd>$objResponse->addRedirect("http://www.xajaxproject.org");</kbd>
248
+     *
249
+     * @param string the URL to redirect the client browser to
250
+     */
251
+    function addRedirect($sURL)
252
+    {
253
+        //we need to parse the query part so that the values are rawurlencode()'ed
254
+        //can't just use parse_url() cos we could be dealing with a relative URL which
255
+        //  parse_url() can't deal with.
256
+        $queryStart = strpos($sURL, '?', strrpos($sURL, '/'));
257
+        if ($queryStart !== FALSE)
258
+        {
259
+            $queryStart++;
260
+            $queryEnd = strpos($sURL, '#', $queryStart);
261
+            if ($queryEnd === FALSE)
262
+                $queryEnd = strlen($sURL);
263
+            $queryPart = substr($sURL, $queryStart, $queryEnd-$queryStart);
264 264
             $queryParts = array();
265
-			parse_str($queryPart, $queryParts);
266
-			$newQueryPart = "";
267
-			foreach($queryParts as $key => $value)
268
-			{
269
-				$newQueryPart .= rawurlencode($key).'='.rawurlencode($value).ini_get('arg_separator.output');
270
-			}
271
-			$sURL = str_replace($queryPart, $newQueryPart, $sURL);
272
-		}
273
-		$this->addScript('window.location = "'.$sURL.'";');
274
-	}
275
-
276
-	/**
277
-	 * Adds a Javascript command message to the XML response.
278
-	 *
279
-	 * <i>Usage:</i> <kbd>$objResponse->addScript("var x = prompt('get some text');");</kbd>
280
-	 *
281
-	 * @param string contains Javascript code to be executed
282
-	 */
283
-	function addScript($sJS)
284
-	{
285
-		$this->xml .= $this->_cmdXML(array("n"=>"js"),$sJS);
286
-	}
287
-
288
-	/**
289
-	 * Adds a Javascript function call command message to the XML response.
290
-	 *
291
-	 * <i>Usage:</i> <kbd>$objResponse->addScriptCall("myJSFunction", "arg 1", "arg 2", 12345);</kbd>
292
-	 *
293
-	 * @param string $sFunc the name of a Javascript function
294
-	 * @param mixed $args,... optional arguments to pass to the Javascript function
295
-	 */
296
-	function addScriptCall() {
297
-		$arguments = func_get_args();
298
-		$sFunc = array_shift($arguments);
299
-		$sData = $this->_buildObjXml($arguments);
300
-		$this->xml .= $this->_cmdXML(array("n"=>"jc","t"=>$sFunc),$sData);
301
-	}
302
-
303
-	/**
304
-	 * Adds a remove element command message to the XML response.
305
-	 *
306
-	 * <i>Usage:</i> <kbd>$objResponse->addRemove("Div2");</kbd>
307
-	 *
308
-	 * @param string contains the id of an HTML element to be removed
309
-	 */
310
-	function addRemove($sTarget)
311
-	{
312
-		$this->xml .= $this->_cmdXML(array("n"=>"rm","t"=>$sTarget),'');
313
-	}
314
-
315
-	/**
316
-	 * Adds a create element command message to the XML response.
317
-	 *
318
-	 * <i>Usage:</i> <kbd>$objResponse->addCreate("parentDiv", "h3", "myid");</kbd>
319
-	 *
320
-	 * @param string contains the id of an HTML element to to which the new
321
-	 *               element will be appended.
322
-	 * @param string the tag to be added
323
-	 * @param string the id to be assigned to the new element
324
-	 * @param string deprecated, use the addCreateInput() method instead
325
-	 */
326
-	function addCreate($sParent, $sTag, $sId, $sType="")
327
-	{
328
-		if ($sType)
329
-		{
330
-			trigger_error("The \$sType parameter of addCreate has been deprecated.  Use the addCreateInput() method instead.", E_USER_WARNING);
331
-			return;
332
-		}
333
-		$this->xml .= $this->_cmdXML(array("n"=>"ce","t"=>$sParent,"p"=>$sId),$sTag);
334
-	}
335
-
336
-	/**
337
-	 * Adds a insert element command message to the XML response.
338
-	 *
339
-	 * <i>Usage:</i> <kbd>$objResponse->addInsert("childDiv", "h3", "myid");</kbd>
340
-	 *
341
-	 * @param string contains the id of the child before which the new element
342
-	 *               will be inserted
343
-	 * @param string the tag to be added
344
-	 * @param string the id to be assigned to the new element
345
-	 */
346
-	function addInsert($sBefore, $sTag, $sId)
347
-	{
348
-		$this->xml .= $this->_cmdXML(array("n"=>"ie","t"=>$sBefore,"p"=>$sId),$sTag);
349
-	}
350
-
351
-	/**
352
-	 * Adds a insert element command message to the XML response.
353
-	 *
354
-	 * <i>Usage:</i> <kbd>$objResponse->addInsertAfter("childDiv", "h3", "myid");</kbd>
355
-	 *
356
-	 * @param string contains the id of the child after which the new element
357
-	 *               will be inserted
358
-	 * @param string the tag to be added
359
-	 * @param string the id to be assigned to the new element
360
-	 */
361
-	function addInsertAfter($sAfter, $sTag, $sId)
362
-	{
363
-		$this->xml .= $this->_cmdXML(array("n"=>"ia","t"=>$sAfter,"p"=>$sId),$sTag);
364
-	}
365
-
366
-	/**
367
-	 * Adds a create input command message to the XML response.
368
-	 *
369
-	 * <i>Usage:</i> <kbd>$objResponse->addCreateInput("form1", "text", "username", "input1");</kbd>
370
-	 *
371
-	 * @param string contains the id of an HTML element to which the new input
372
-	 *               will be appended
373
-	 * @param string the type of input to be created (text, radio, checkbox,
374
-	 *               etc.)
375
-	 * @param string the name to be assigned to the new input and the variable
376
-	 *               name when it is submitted
377
-	 * @param string the id to be assigned to the new input
378
-	 */
379
-	function addCreateInput($sParent, $sType, $sName, $sId)
380
-	{
381
-		$this->xml .= $this->_cmdXML(array("n"=>"ci","t"=>$sParent,"p"=>$sId,"c"=>$sType),$sName);
382
-	}
383
-
384
-	/**
385
-	 * Adds an insert input command message to the XML response.
386
-	 *
387
-	 * <i>Usage:</i> <kbd>$objResponse->addInsertInput("input5", "text", "username", "input1");</kbd>
388
-	 *
389
-	 * @param string contains the id of the child before which the new element
390
-	 *               will be inserted
391
-	 * @param string the type of input to be created (text, radio, checkbox,
392
-	 *               etc.)
393
-	 * @param string the name to be assigned to the new input and the variable
394
-	 *               name when it is submitted
395
-	 * @param string the id to be assigned to the new input
396
-	 */
397
-	function addInsertInput($sBefore, $sType, $sName, $sId)
398
-	{
399
-		$this->xml .= $this->_cmdXML(array("n"=>"ii","t"=>$sBefore,"p"=>$sId,"c"=>$sType),$sName);
400
-	}
401
-
402
-	/**
403
-	 * Adds an insert input command message to the XML response.
404
-	 *
405
-	 * <i>Usage:</i> <kbd>$objResponse->addInsertInputAfter("input7", "text", "email", "input2");</kbd>
406
-	 *
407
-	 * @param string contains the id of the child after which the new element
408
-	 *               will be inserted
409
-	 * @param string the type of input to be created (text, radio, checkbox,
410
-	 *               etc.)
411
-	 * @param string the name to be assigned to the new input and the variable
412
-	 *               name when it is submitted
413
-	 * @param string the id to be assigned to the new input
414
-	 */
415
-	function addInsertInputAfter($sAfter, $sType, $sName, $sId)
416
-	{
417
-		$this->xml .= $this->_cmdXML(array("n"=>"iia","t"=>$sAfter,"p"=>$sId,"c"=>$sType),$sName);
418
-	}
419
-
420
-	/**
421
-	 * Adds an event command message to the XML response.
422
-	 *
423
-	 * <i>Usage:</i> <kbd>$objResponse->addEvent("contentDiv", "onclick", "alert(\'Hello World\');");</kbd>
424
-	 *
425
-	 * @param string contains the id of an HTML element
426
-	 * @param string the event you wish to set ("onclick", "onmouseover", etc.)
427
-	 * @param string the Javascript string you want the event to invoke
428
-	 */
429
-	function addEvent($sTarget,$sEvent,$sScript)
430
-	{
431
-		$this->xml .= $this->_cmdXML(array("n"=>"ev","t"=>$sTarget,"p"=>$sEvent),$sScript);
432
-	}
433
-
434
-	/**
435
-	 * Adds a handler command message to the XML response.
436
-	 *
437
-	 * <i>Usage:</i> <kbd>$objResponse->addHandler("contentDiv", "onclick", "content_click");</kbd>
438
-	 *
439
-	 * @param string contains the id of an HTML element
440
-	 * @param string the event you wish to set ("onclick", "onmouseover", etc.)
441
-	 * @param string the name of a Javascript function that will handle the
442
-	 *               event. Multiple handlers can be added for the same event
443
-	 */
444
-	function addHandler($sTarget,$sEvent,$sHandler)
445
-	{
446
-		$this->xml .= $this->_cmdXML(array("n"=>"ah","t"=>$sTarget,"p"=>$sEvent),$sHandler);
447
-	}
448
-
449
-	/**
450
-	 * Adds a remove handler command message to the XML response.
451
-	 *
452
-	 * <i>Usage:</i> <kbd>$objResponse->addRemoveHandler("contentDiv", "onclick", "content_click");</kbd>
453
-	 *
454
-	 * @param string contains the id of an HTML element
455
-	 * @param string the event you wish to remove ("onclick", "onmouseover",
456
-	 *               etc.)
457
-	 * @param string the name of a Javascript handler function that you want to
458
-	 *               remove
459
-	 */
460
-	function addRemoveHandler($sTarget,$sEvent,$sHandler)
461
-	{
462
-		$this->xml .= $this->_cmdXML(array("n"=>"rh","t"=>$sTarget,"p"=>$sEvent),$sHandler);
463
-	}
464
-
465
-	/**
466
-	 * Adds an include script command message to the XML response.
467
-	 *
468
-	 * <i>Usage:</i> <kbd>$objResponse->addIncludeScript("functions.js");</kbd>
469
-	 *
470
-	 * @param string URL of the Javascript file to include
471
-	 */
472
-	function addIncludeScript($sFileName)
473
-	{
474
-		$this->xml .= $this->_cmdXML(array("n"=>"in"),$sFileName);
475
-	}
476
-
477
-	/**
478
-	 * Returns the XML to be returned from your function to the xajax processor
479
-	 * on your page. Since xajax 0.2, you can also return an xajaxResponse
480
-	 * object from your function directly, and xajax will automatically request
481
-	 * the XML using this method call.
482
-	 *
483
-	 * <i>Usage:</i> <kbd>return $objResponse->getXML();</kbd>
484
-	 *
485
-	 * @return string response XML data
486
-	 */
487
-	function getXML()
488
-	{
489
-		$sXML = "<?xml version=\"1.0\"";
490
-		if ($this->sEncoding && strlen(trim($this->sEncoding)) > 0)
491
-			$sXML .= " encoding=\"".$this->sEncoding."\"";
492
-		$sXML .= " ?"."><xjx>" . $this->xml . "</xjx>";
493
-
494
-		return $sXML;
495
-	}
496
-
497
-	/**
498
-	 * Adds the commands of the provided response XML output to this response
499
-	 * object
500
-	 *
501
-	 * <i>Usage:</i>
502
-	 * <code>$r1 = $objResponse1->getXML();
503
-	 * $objResponse2->loadXML($r1);
504
-	 * return $objResponse2->getXML();</code>
505
-	 *
506
-	 * @param string the response XML (returned from a getXML() method) to add
507
-	 *               to the end of this response object
508
-	 */
509
-	function loadXML($mXML)
510
-	{
511
-		if (is_a($mXML, "xajaxResponse")) {
512
-			$mXML = $mXML->getXML();
513
-		}
514
-		$sNewXML = "";
515
-		$iStartPos = strpos($mXML, "<xjx>") + 5;
516
-		$sNewXML = substr($mXML, $iStartPos);
517
-		$iEndPos = strpos($sNewXML, "</xjx>");
518
-		$sNewXML = substr($sNewXML, 0, $iEndPos);
519
-		$this->xml .= $sNewXML;
520
-	}
521
-
522
-	/**
523
-	 * Generates XML from command data
524
-	 *
525
-	 * @access private
526
-	 * @param array associative array of attributes
527
-	 * @param string data
528
-	 * @return string XML command
529
-	 */
530
-	function _cmdXML($aAttributes, $sData)
531
-	{
532
-		if ($this->bOutputEntities) {
533
-			// An adaptation for the Dokeos LMS, 22-AUG-2009.
534
-			if (function_exists('api_convert_encoding')) {
535
-				$sData = call_user_func_array('api_convert_encoding', array(&$sData, 'HTML-ENTITIES', $this->sEncoding));
536
-			}
537
-			//if (function_exists('mb_convert_encoding')) {
538
-			elseif (function_exists('mb_convert_encoding')) {
539
-			//
540
-				$sData = call_user_func_array('mb_convert_encoding', array(&$sData, 'HTML-ENTITIES', $this->sEncoding));
541
-			}
542
-			else {
543
-				trigger_error("The xajax XML response output could not be converted to HTML entities because the mb_convert_encoding function is not available", E_USER_NOTICE);
544
-			}
545
-		}
546
-		$xml = "<cmd";
547
-		foreach($aAttributes as $sAttribute => $sValue)
548
-			$xml .= " $sAttribute=\"$sValue\"";
549
-		if ($sData !== null && !stristr($sData,'<![CDATA['))
550
-			$xml .= "><![CDATA[$sData]]></cmd>";
551
-		else if ($sData !== null)
552
-			$xml .= ">$sData</cmd>";
553
-		else
554
-			$xml .= "></cmd>";
555
-
556
-		return $xml;
557
-	}
558
-
559
-	/**
560
-	 * Recursively serializes a data structure in XML so it can be sent to
561
-	 * the client. It could be thought of as the opposite of
562
-	 * {@link xajax::_parseObjXml()}.
563
-	 *
564
-	 * @access private
565
-	 * @param mixed data structure to serialize to XML
566
-	 * @return string serialized XML
567
-	 */
568
-	function _buildObjXml($var) {
569
-		if (gettype($var) == "object") $var = get_object_vars($var);
570
-		if (!is_array($var)) {
571
-			return "<![CDATA[$var]]>";
572
-		}
573
-		else {
574
-			$data = "<xjxobj>";
575
-			foreach ($var as $key => $value) {
576
-				$data .= "<e>";
577
-				$data .= "<k>" . htmlspecialchars($key) . "</k>";
578
-				$data .= "<v>" . $this->_buildObjXml($value) . "</v>";
579
-				$data .= "</e>";
580
-			}
581
-			$data .= "</xjxobj>";
582
-			return $data;
583
-		}
584
-	}
265
+            parse_str($queryPart, $queryParts);
266
+            $newQueryPart = "";
267
+            foreach($queryParts as $key => $value)
268
+            {
269
+                $newQueryPart .= rawurlencode($key).'='.rawurlencode($value).ini_get('arg_separator.output');
270
+            }
271
+            $sURL = str_replace($queryPart, $newQueryPart, $sURL);
272
+        }
273
+        $this->addScript('window.location = "'.$sURL.'";');
274
+    }
275
+
276
+    /**
277
+     * Adds a Javascript command message to the XML response.
278
+     *
279
+     * <i>Usage:</i> <kbd>$objResponse->addScript("var x = prompt('get some text');");</kbd>
280
+     *
281
+     * @param string contains Javascript code to be executed
282
+     */
283
+    function addScript($sJS)
284
+    {
285
+        $this->xml .= $this->_cmdXML(array("n"=>"js"),$sJS);
286
+    }
287
+
288
+    /**
289
+     * Adds a Javascript function call command message to the XML response.
290
+     *
291
+     * <i>Usage:</i> <kbd>$objResponse->addScriptCall("myJSFunction", "arg 1", "arg 2", 12345);</kbd>
292
+     *
293
+     * @param string $sFunc the name of a Javascript function
294
+     * @param mixed $args,... optional arguments to pass to the Javascript function
295
+     */
296
+    function addScriptCall() {
297
+        $arguments = func_get_args();
298
+        $sFunc = array_shift($arguments);
299
+        $sData = $this->_buildObjXml($arguments);
300
+        $this->xml .= $this->_cmdXML(array("n"=>"jc","t"=>$sFunc),$sData);
301
+    }
302
+
303
+    /**
304
+     * Adds a remove element command message to the XML response.
305
+     *
306
+     * <i>Usage:</i> <kbd>$objResponse->addRemove("Div2");</kbd>
307
+     *
308
+     * @param string contains the id of an HTML element to be removed
309
+     */
310
+    function addRemove($sTarget)
311
+    {
312
+        $this->xml .= $this->_cmdXML(array("n"=>"rm","t"=>$sTarget),'');
313
+    }
314
+
315
+    /**
316
+     * Adds a create element command message to the XML response.
317
+     *
318
+     * <i>Usage:</i> <kbd>$objResponse->addCreate("parentDiv", "h3", "myid");</kbd>
319
+     *
320
+     * @param string contains the id of an HTML element to to which the new
321
+     *               element will be appended.
322
+     * @param string the tag to be added
323
+     * @param string the id to be assigned to the new element
324
+     * @param string deprecated, use the addCreateInput() method instead
325
+     */
326
+    function addCreate($sParent, $sTag, $sId, $sType="")
327
+    {
328
+        if ($sType)
329
+        {
330
+            trigger_error("The \$sType parameter of addCreate has been deprecated.  Use the addCreateInput() method instead.", E_USER_WARNING);
331
+            return;
332
+        }
333
+        $this->xml .= $this->_cmdXML(array("n"=>"ce","t"=>$sParent,"p"=>$sId),$sTag);
334
+    }
335
+
336
+    /**
337
+     * Adds a insert element command message to the XML response.
338
+     *
339
+     * <i>Usage:</i> <kbd>$objResponse->addInsert("childDiv", "h3", "myid");</kbd>
340
+     *
341
+     * @param string contains the id of the child before which the new element
342
+     *               will be inserted
343
+     * @param string the tag to be added
344
+     * @param string the id to be assigned to the new element
345
+     */
346
+    function addInsert($sBefore, $sTag, $sId)
347
+    {
348
+        $this->xml .= $this->_cmdXML(array("n"=>"ie","t"=>$sBefore,"p"=>$sId),$sTag);
349
+    }
350
+
351
+    /**
352
+     * Adds a insert element command message to the XML response.
353
+     *
354
+     * <i>Usage:</i> <kbd>$objResponse->addInsertAfter("childDiv", "h3", "myid");</kbd>
355
+     *
356
+     * @param string contains the id of the child after which the new element
357
+     *               will be inserted
358
+     * @param string the tag to be added
359
+     * @param string the id to be assigned to the new element
360
+     */
361
+    function addInsertAfter($sAfter, $sTag, $sId)
362
+    {
363
+        $this->xml .= $this->_cmdXML(array("n"=>"ia","t"=>$sAfter,"p"=>$sId),$sTag);
364
+    }
365
+
366
+    /**
367
+     * Adds a create input command message to the XML response.
368
+     *
369
+     * <i>Usage:</i> <kbd>$objResponse->addCreateInput("form1", "text", "username", "input1");</kbd>
370
+     *
371
+     * @param string contains the id of an HTML element to which the new input
372
+     *               will be appended
373
+     * @param string the type of input to be created (text, radio, checkbox,
374
+     *               etc.)
375
+     * @param string the name to be assigned to the new input and the variable
376
+     *               name when it is submitted
377
+     * @param string the id to be assigned to the new input
378
+     */
379
+    function addCreateInput($sParent, $sType, $sName, $sId)
380
+    {
381
+        $this->xml .= $this->_cmdXML(array("n"=>"ci","t"=>$sParent,"p"=>$sId,"c"=>$sType),$sName);
382
+    }
383
+
384
+    /**
385
+     * Adds an insert input command message to the XML response.
386
+     *
387
+     * <i>Usage:</i> <kbd>$objResponse->addInsertInput("input5", "text", "username", "input1");</kbd>
388
+     *
389
+     * @param string contains the id of the child before which the new element
390
+     *               will be inserted
391
+     * @param string the type of input to be created (text, radio, checkbox,
392
+     *               etc.)
393
+     * @param string the name to be assigned to the new input and the variable
394
+     *               name when it is submitted
395
+     * @param string the id to be assigned to the new input
396
+     */
397
+    function addInsertInput($sBefore, $sType, $sName, $sId)
398
+    {
399
+        $this->xml .= $this->_cmdXML(array("n"=>"ii","t"=>$sBefore,"p"=>$sId,"c"=>$sType),$sName);
400
+    }
401
+
402
+    /**
403
+     * Adds an insert input command message to the XML response.
404
+     *
405
+     * <i>Usage:</i> <kbd>$objResponse->addInsertInputAfter("input7", "text", "email", "input2");</kbd>
406
+     *
407
+     * @param string contains the id of the child after which the new element
408
+     *               will be inserted
409
+     * @param string the type of input to be created (text, radio, checkbox,
410
+     *               etc.)
411
+     * @param string the name to be assigned to the new input and the variable
412
+     *               name when it is submitted
413
+     * @param string the id to be assigned to the new input
414
+     */
415
+    function addInsertInputAfter($sAfter, $sType, $sName, $sId)
416
+    {
417
+        $this->xml .= $this->_cmdXML(array("n"=>"iia","t"=>$sAfter,"p"=>$sId,"c"=>$sType),$sName);
418
+    }
419
+
420
+    /**
421
+     * Adds an event command message to the XML response.
422
+     *
423
+     * <i>Usage:</i> <kbd>$objResponse->addEvent("contentDiv", "onclick", "alert(\'Hello World\');");</kbd>
424
+     *
425
+     * @param string contains the id of an HTML element
426
+     * @param string the event you wish to set ("onclick", "onmouseover", etc.)
427
+     * @param string the Javascript string you want the event to invoke
428
+     */
429
+    function addEvent($sTarget,$sEvent,$sScript)
430
+    {
431
+        $this->xml .= $this->_cmdXML(array("n"=>"ev","t"=>$sTarget,"p"=>$sEvent),$sScript);
432
+    }
433
+
434
+    /**
435
+     * Adds a handler command message to the XML response.
436
+     *
437
+     * <i>Usage:</i> <kbd>$objResponse->addHandler("contentDiv", "onclick", "content_click");</kbd>
438
+     *
439
+     * @param string contains the id of an HTML element
440
+     * @param string the event you wish to set ("onclick", "onmouseover", etc.)
441
+     * @param string the name of a Javascript function that will handle the
442
+     *               event. Multiple handlers can be added for the same event
443
+     */
444
+    function addHandler($sTarget,$sEvent,$sHandler)
445
+    {
446
+        $this->xml .= $this->_cmdXML(array("n"=>"ah","t"=>$sTarget,"p"=>$sEvent),$sHandler);
447
+    }
448
+
449
+    /**
450
+     * Adds a remove handler command message to the XML response.
451
+     *
452
+     * <i>Usage:</i> <kbd>$objResponse->addRemoveHandler("contentDiv", "onclick", "content_click");</kbd>
453
+     *
454
+     * @param string contains the id of an HTML element
455
+     * @param string the event you wish to remove ("onclick", "onmouseover",
456
+     *               etc.)
457
+     * @param string the name of a Javascript handler function that you want to
458
+     *               remove
459
+     */
460
+    function addRemoveHandler($sTarget,$sEvent,$sHandler)
461
+    {
462
+        $this->xml .= $this->_cmdXML(array("n"=>"rh","t"=>$sTarget,"p"=>$sEvent),$sHandler);
463
+    }
464
+
465
+    /**
466
+     * Adds an include script command message to the XML response.
467
+     *
468
+     * <i>Usage:</i> <kbd>$objResponse->addIncludeScript("functions.js");</kbd>
469
+     *
470
+     * @param string URL of the Javascript file to include
471
+     */
472
+    function addIncludeScript($sFileName)
473
+    {
474
+        $this->xml .= $this->_cmdXML(array("n"=>"in"),$sFileName);
475
+    }
476
+
477
+    /**
478
+     * Returns the XML to be returned from your function to the xajax processor
479
+     * on your page. Since xajax 0.2, you can also return an xajaxResponse
480
+     * object from your function directly, and xajax will automatically request
481
+     * the XML using this method call.
482
+     *
483
+     * <i>Usage:</i> <kbd>return $objResponse->getXML();</kbd>
484
+     *
485
+     * @return string response XML data
486
+     */
487
+    function getXML()
488
+    {
489
+        $sXML = "<?xml version=\"1.0\"";
490
+        if ($this->sEncoding && strlen(trim($this->sEncoding)) > 0)
491
+            $sXML .= " encoding=\"".$this->sEncoding."\"";
492
+        $sXML .= " ?"."><xjx>" . $this->xml . "</xjx>";
493
+
494
+        return $sXML;
495
+    }
496
+
497
+    /**
498
+     * Adds the commands of the provided response XML output to this response
499
+     * object
500
+     *
501
+     * <i>Usage:</i>
502
+     * <code>$r1 = $objResponse1->getXML();
503
+     * $objResponse2->loadXML($r1);
504
+     * return $objResponse2->getXML();</code>
505
+     *
506
+     * @param string the response XML (returned from a getXML() method) to add
507
+     *               to the end of this response object
508
+     */
509
+    function loadXML($mXML)
510
+    {
511
+        if (is_a($mXML, "xajaxResponse")) {
512
+            $mXML = $mXML->getXML();
513
+        }
514
+        $sNewXML = "";
515
+        $iStartPos = strpos($mXML, "<xjx>") + 5;
516
+        $sNewXML = substr($mXML, $iStartPos);
517
+        $iEndPos = strpos($sNewXML, "</xjx>");
518
+        $sNewXML = substr($sNewXML, 0, $iEndPos);
519
+        $this->xml .= $sNewXML;
520
+    }
521
+
522
+    /**
523
+     * Generates XML from command data
524
+     *
525
+     * @access private
526
+     * @param array associative array of attributes
527
+     * @param string data
528
+     * @return string XML command
529
+     */
530
+    function _cmdXML($aAttributes, $sData)
531
+    {
532
+        if ($this->bOutputEntities) {
533
+            // An adaptation for the Dokeos LMS, 22-AUG-2009.
534
+            if (function_exists('api_convert_encoding')) {
535
+                $sData = call_user_func_array('api_convert_encoding', array(&$sData, 'HTML-ENTITIES', $this->sEncoding));
536
+            }
537
+            //if (function_exists('mb_convert_encoding')) {
538
+            elseif (function_exists('mb_convert_encoding')) {
539
+            //
540
+                $sData = call_user_func_array('mb_convert_encoding', array(&$sData, 'HTML-ENTITIES', $this->sEncoding));
541
+            }
542
+            else {
543
+                trigger_error("The xajax XML response output could not be converted to HTML entities because the mb_convert_encoding function is not available", E_USER_NOTICE);
544
+            }
545
+        }
546
+        $xml = "<cmd";
547
+        foreach($aAttributes as $sAttribute => $sValue)
548
+            $xml .= " $sAttribute=\"$sValue\"";
549
+        if ($sData !== null && !stristr($sData,'<![CDATA['))
550
+            $xml .= "><![CDATA[$sData]]></cmd>";
551
+        else if ($sData !== null)
552
+            $xml .= ">$sData</cmd>";
553
+        else
554
+            $xml .= "></cmd>";
555
+
556
+        return $xml;
557
+    }
558
+
559
+    /**
560
+     * Recursively serializes a data structure in XML so it can be sent to
561
+     * the client. It could be thought of as the opposite of
562
+     * {@link xajax::_parseObjXml()}.
563
+     *
564
+     * @access private
565
+     * @param mixed data structure to serialize to XML
566
+     * @return string serialized XML
567
+     */
568
+    function _buildObjXml($var) {
569
+        if (gettype($var) == "object") $var = get_object_vars($var);
570
+        if (!is_array($var)) {
571
+            return "<![CDATA[$var]]>";
572
+        }
573
+        else {
574
+            $data = "<xjxobj>";
575
+            foreach ($var as $key => $value) {
576
+                $data .= "<e>";
577
+                $data .= "<k>" . htmlspecialchars($key) . "</k>";
578
+                $data .= "<v>" . $this->_buildObjXml($value) . "</v>";
579
+                $data .= "</e>";
580
+            }
581
+            $data .= "</xjxobj>";
582
+            return $data;
583
+        }
584
+    }
585 585
 
586 586
 }// end class xajaxResponse
587 587
 ?>
Please login to merge, or discard this patch.
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 	 *                converted to HTML entities
100 100
 	 *
101 101
 	 */
102
-	public function __construct($sEncoding=XAJAX_DEFAULT_CHAR_ENCODING, $bOutputEntities=false)
102
+	public function __construct($sEncoding = XAJAX_DEFAULT_CHAR_ENCODING, $bOutputEntities = false)
103 103
 	{
104 104
 		$this->setCharEncoding($sEncoding);
105 105
 		$this->bOutputEntities = $bOutputEntities;
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 	 */
149 149
 	function addConfirmCommands($iCmdNumber, $sMessage)
150 150
 	{
151
-		$this->xml .= $this->_cmdXML(array("n"=>"cc","t"=>$iCmdNumber),$sMessage);
151
+		$this->xml .= $this->_cmdXML(array("n"=>"cc", "t"=>$iCmdNumber), $sMessage);
152 152
 	}
153 153
 
154 154
 	/**
@@ -161,9 +161,9 @@  discard block
 block discarded – undo
161 161
 	 *               "value", etc.)
162 162
 	 * @param string the data you want to set the attribute to
163 163
 	 */
164
-	function addAssign($sTarget,$sAttribute,$sData)
164
+	function addAssign($sTarget, $sAttribute, $sData)
165 165
 	{
166
-		$this->xml .= $this->_cmdXML(array("n"=>"as","t"=>$sTarget,"p"=>$sAttribute),$sData);
166
+		$this->xml .= $this->_cmdXML(array("n"=>"as", "t"=>$sTarget, "p"=>$sAttribute), $sData);
167 167
 	}
168 168
 
169 169
 	/**
@@ -176,9 +176,9 @@  discard block
 block discarded – undo
176 176
 	 *               "value", etc.)
177 177
 	 * @param string the data you want to append to the end of the attribute
178 178
 	 */
179
-	function addAppend($sTarget,$sAttribute,$sData)
179
+	function addAppend($sTarget, $sAttribute, $sData)
180 180
 	{
181
-		$this->xml .= $this->_cmdXML(array("n"=>"ap","t"=>$sTarget,"p"=>$sAttribute),$sData);
181
+		$this->xml .= $this->_cmdXML(array("n"=>"ap", "t"=>$sTarget, "p"=>$sAttribute), $sData);
182 182
 	}
183 183
 
184 184
 	/**
@@ -192,9 +192,9 @@  discard block
 block discarded – undo
192 192
 	 * @param string the data you want to prepend to the beginning of the
193 193
 	 *               attribute
194 194
 	 */
195
-	function addPrepend($sTarget,$sAttribute,$sData)
195
+	function addPrepend($sTarget, $sAttribute, $sData)
196 196
 	{
197
-		$this->xml .= $this->_cmdXML(array("n"=>"pp","t"=>$sTarget,"p"=>$sAttribute),$sData);
197
+		$this->xml .= $this->_cmdXML(array("n"=>"pp", "t"=>$sTarget, "p"=>$sAttribute), $sData);
198 198
 	}
199 199
 
200 200
 	/**
@@ -209,10 +209,10 @@  discard block
 block discarded – undo
209 209
 	 * @param string the string to replace the search string when found in the
210 210
 	 *               attribute
211 211
 	 */
212
-	function addReplace($sTarget,$sAttribute,$sSearch,$sData)
212
+	function addReplace($sTarget, $sAttribute, $sSearch, $sData)
213 213
 	{
214 214
 		$sDta = "<s><![CDATA[$sSearch]]></s><r><![CDATA[$sData]]></r>";
215
-		$this->xml .= $this->_cmdXML(array("n"=>"rp","t"=>$sTarget,"p"=>$sAttribute),$sDta);
215
+		$this->xml .= $this->_cmdXML(array("n"=>"rp", "t"=>$sTarget, "p"=>$sAttribute), $sDta);
216 216
 	}
217 217
 
218 218
 	/**
@@ -224,9 +224,9 @@  discard block
 block discarded – undo
224 224
 	 * @param string the part of the element you wish to clear ("innerHTML",
225 225
 	 *               "value", etc.)
226 226
 	 */
227
-	function addClear($sTarget,$sAttribute)
227
+	function addClear($sTarget, $sAttribute)
228 228
 	{
229
-		$this->addAssign($sTarget,$sAttribute,'');
229
+		$this->addAssign($sTarget, $sAttribute, '');
230 230
 	}
231 231
 
232 232
 	/**
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 	 */
239 239
 	function addAlert($sMsg)
240 240
 	{
241
-		$this->xml .= $this->_cmdXML(array("n"=>"al"),$sMsg);
241
+		$this->xml .= $this->_cmdXML(array("n"=>"al"), $sMsg);
242 242
 	}
243 243
 
244 244
 	/**
@@ -260,11 +260,11 @@  discard block
 block discarded – undo
260 260
 			$queryEnd = strpos($sURL, '#', $queryStart);
261 261
 			if ($queryEnd === FALSE)
262 262
 				$queryEnd = strlen($sURL);
263
-			$queryPart = substr($sURL, $queryStart, $queryEnd-$queryStart);
263
+			$queryPart = substr($sURL, $queryStart, $queryEnd - $queryStart);
264 264
             $queryParts = array();
265 265
 			parse_str($queryPart, $queryParts);
266 266
 			$newQueryPart = "";
267
-			foreach($queryParts as $key => $value)
267
+			foreach ($queryParts as $key => $value)
268 268
 			{
269 269
 				$newQueryPart .= rawurlencode($key).'='.rawurlencode($value).ini_get('arg_separator.output');
270 270
 			}
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 	 */
283 283
 	function addScript($sJS)
284 284
 	{
285
-		$this->xml .= $this->_cmdXML(array("n"=>"js"),$sJS);
285
+		$this->xml .= $this->_cmdXML(array("n"=>"js"), $sJS);
286 286
 	}
287 287
 
288 288
 	/**
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
 		$arguments = func_get_args();
298 298
 		$sFunc = array_shift($arguments);
299 299
 		$sData = $this->_buildObjXml($arguments);
300
-		$this->xml .= $this->_cmdXML(array("n"=>"jc","t"=>$sFunc),$sData);
300
+		$this->xml .= $this->_cmdXML(array("n"=>"jc", "t"=>$sFunc), $sData);
301 301
 	}
302 302
 
303 303
 	/**
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
 	 */
310 310
 	function addRemove($sTarget)
311 311
 	{
312
-		$this->xml .= $this->_cmdXML(array("n"=>"rm","t"=>$sTarget),'');
312
+		$this->xml .= $this->_cmdXML(array("n"=>"rm", "t"=>$sTarget), '');
313 313
 	}
314 314
 
315 315
 	/**
@@ -323,14 +323,14 @@  discard block
 block discarded – undo
323 323
 	 * @param string the id to be assigned to the new element
324 324
 	 * @param string deprecated, use the addCreateInput() method instead
325 325
 	 */
326
-	function addCreate($sParent, $sTag, $sId, $sType="")
326
+	function addCreate($sParent, $sTag, $sId, $sType = "")
327 327
 	{
328 328
 		if ($sType)
329 329
 		{
330 330
 			trigger_error("The \$sType parameter of addCreate has been deprecated.  Use the addCreateInput() method instead.", E_USER_WARNING);
331 331
 			return;
332 332
 		}
333
-		$this->xml .= $this->_cmdXML(array("n"=>"ce","t"=>$sParent,"p"=>$sId),$sTag);
333
+		$this->xml .= $this->_cmdXML(array("n"=>"ce", "t"=>$sParent, "p"=>$sId), $sTag);
334 334
 	}
335 335
 
336 336
 	/**
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
 	 */
346 346
 	function addInsert($sBefore, $sTag, $sId)
347 347
 	{
348
-		$this->xml .= $this->_cmdXML(array("n"=>"ie","t"=>$sBefore,"p"=>$sId),$sTag);
348
+		$this->xml .= $this->_cmdXML(array("n"=>"ie", "t"=>$sBefore, "p"=>$sId), $sTag);
349 349
 	}
350 350
 
351 351
 	/**
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
 	 */
361 361
 	function addInsertAfter($sAfter, $sTag, $sId)
362 362
 	{
363
-		$this->xml .= $this->_cmdXML(array("n"=>"ia","t"=>$sAfter,"p"=>$sId),$sTag);
363
+		$this->xml .= $this->_cmdXML(array("n"=>"ia", "t"=>$sAfter, "p"=>$sId), $sTag);
364 364
 	}
365 365
 
366 366
 	/**
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
 	 */
379 379
 	function addCreateInput($sParent, $sType, $sName, $sId)
380 380
 	{
381
-		$this->xml .= $this->_cmdXML(array("n"=>"ci","t"=>$sParent,"p"=>$sId,"c"=>$sType),$sName);
381
+		$this->xml .= $this->_cmdXML(array("n"=>"ci", "t"=>$sParent, "p"=>$sId, "c"=>$sType), $sName);
382 382
 	}
383 383
 
384 384
 	/**
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
 	 */
397 397
 	function addInsertInput($sBefore, $sType, $sName, $sId)
398 398
 	{
399
-		$this->xml .= $this->_cmdXML(array("n"=>"ii","t"=>$sBefore,"p"=>$sId,"c"=>$sType),$sName);
399
+		$this->xml .= $this->_cmdXML(array("n"=>"ii", "t"=>$sBefore, "p"=>$sId, "c"=>$sType), $sName);
400 400
 	}
401 401
 
402 402
 	/**
@@ -414,7 +414,7 @@  discard block
 block discarded – undo
414 414
 	 */
415 415
 	function addInsertInputAfter($sAfter, $sType, $sName, $sId)
416 416
 	{
417
-		$this->xml .= $this->_cmdXML(array("n"=>"iia","t"=>$sAfter,"p"=>$sId,"c"=>$sType),$sName);
417
+		$this->xml .= $this->_cmdXML(array("n"=>"iia", "t"=>$sAfter, "p"=>$sId, "c"=>$sType), $sName);
418 418
 	}
419 419
 
420 420
 	/**
@@ -426,9 +426,9 @@  discard block
 block discarded – undo
426 426
 	 * @param string the event you wish to set ("onclick", "onmouseover", etc.)
427 427
 	 * @param string the Javascript string you want the event to invoke
428 428
 	 */
429
-	function addEvent($sTarget,$sEvent,$sScript)
429
+	function addEvent($sTarget, $sEvent, $sScript)
430 430
 	{
431
-		$this->xml .= $this->_cmdXML(array("n"=>"ev","t"=>$sTarget,"p"=>$sEvent),$sScript);
431
+		$this->xml .= $this->_cmdXML(array("n"=>"ev", "t"=>$sTarget, "p"=>$sEvent), $sScript);
432 432
 	}
433 433
 
434 434
 	/**
@@ -441,9 +441,9 @@  discard block
 block discarded – undo
441 441
 	 * @param string the name of a Javascript function that will handle the
442 442
 	 *               event. Multiple handlers can be added for the same event
443 443
 	 */
444
-	function addHandler($sTarget,$sEvent,$sHandler)
444
+	function addHandler($sTarget, $sEvent, $sHandler)
445 445
 	{
446
-		$this->xml .= $this->_cmdXML(array("n"=>"ah","t"=>$sTarget,"p"=>$sEvent),$sHandler);
446
+		$this->xml .= $this->_cmdXML(array("n"=>"ah", "t"=>$sTarget, "p"=>$sEvent), $sHandler);
447 447
 	}
448 448
 
449 449
 	/**
@@ -457,9 +457,9 @@  discard block
 block discarded – undo
457 457
 	 * @param string the name of a Javascript handler function that you want to
458 458
 	 *               remove
459 459
 	 */
460
-	function addRemoveHandler($sTarget,$sEvent,$sHandler)
460
+	function addRemoveHandler($sTarget, $sEvent, $sHandler)
461 461
 	{
462
-		$this->xml .= $this->_cmdXML(array("n"=>"rh","t"=>$sTarget,"p"=>$sEvent),$sHandler);
462
+		$this->xml .= $this->_cmdXML(array("n"=>"rh", "t"=>$sTarget, "p"=>$sEvent), $sHandler);
463 463
 	}
464 464
 
465 465
 	/**
@@ -471,7 +471,7 @@  discard block
 block discarded – undo
471 471
 	 */
472 472
 	function addIncludeScript($sFileName)
473 473
 	{
474
-		$this->xml .= $this->_cmdXML(array("n"=>"in"),$sFileName);
474
+		$this->xml .= $this->_cmdXML(array("n"=>"in"), $sFileName);
475 475
 	}
476 476
 
477 477
 	/**
@@ -489,7 +489,7 @@  discard block
 block discarded – undo
489 489
 		$sXML = "<?xml version=\"1.0\"";
490 490
 		if ($this->sEncoding && strlen(trim($this->sEncoding)) > 0)
491 491
 			$sXML .= " encoding=\"".$this->sEncoding."\"";
492
-		$sXML .= " ?"."><xjx>" . $this->xml . "</xjx>";
492
+		$sXML .= " ?"."><xjx>".$this->xml."</xjx>";
493 493
 
494 494
 		return $sXML;
495 495
 	}
@@ -544,9 +544,9 @@  discard block
 block discarded – undo
544 544
 			}
545 545
 		}
546 546
 		$xml = "<cmd";
547
-		foreach($aAttributes as $sAttribute => $sValue)
547
+		foreach ($aAttributes as $sAttribute => $sValue)
548 548
 			$xml .= " $sAttribute=\"$sValue\"";
549
-		if ($sData !== null && !stristr($sData,'<![CDATA['))
549
+		if ($sData !== null && !stristr($sData, '<![CDATA['))
550 550
 			$xml .= "><![CDATA[$sData]]></cmd>";
551 551
 		else if ($sData !== null)
552 552
 			$xml .= ">$sData</cmd>";
@@ -574,8 +574,8 @@  discard block
 block discarded – undo
574 574
 			$data = "<xjxobj>";
575 575
 			foreach ($var as $key => $value) {
576 576
 				$data .= "<e>";
577
-				$data .= "<k>" . htmlspecialchars($key) . "</k>";
578
-				$data .= "<v>" . $this->_buildObjXml($value) . "</v>";
577
+				$data .= "<k>".htmlspecialchars($key)."</k>";
578
+				$data .= "<v>".$this->_buildObjXml($value)."</v>";
579 579
 				$data .= "</e>";
580 580
 			}
581 581
 			$data .= "</xjxobj>";
Please login to merge, or discard this patch.
main/inc/lib/zombie/zombie_report.class.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -121,6 +121,9 @@
 block discarded – undo
121 121
         return $form->isSubmitted() == false || $form->validate();
122 122
     }
123 123
 
124
+    /**
125
+     * @param string $format
126
+     */
124 127
     function get_ceiling($format = null)
125 128
     {
126 129
         $result = Request::get('ceiling');
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
         }
168 168
 
169 169
         $action = $this->get_action();
170
-        $f = array($this, 'action_' . $action);
170
+        $f = array($this, 'action_'.$action);
171 171
         if (is_callable($f)) {
172 172
             return call_user_func($f, $ids);
173 173
         }
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
             $text = get_lang('No');
293 293
         }
294 294
 
295
-        $result = Display::return_icon($image . '.png', $text);
295
+        $result = Display::return_icon($image.'.png', $text);
296 296
         return $result;
297 297
     }
298 298
 
Please login to merge, or discard this patch.