Completed
Push — 1.10.x ( 0db498...531f7d )
by Julito
55:48 queued 23:11
created
main/inc/lib/timeline.lib.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -73,7 +73,7 @@
 block discarded – undo
73 73
      * @todo the form should be auto generated
74 74
      * @param   string  url
75 75
      * @param   string  action add, edit
76
-     * @return  obj     form validator obj
76
+     * @return  FormValidator     form validator obj
77 77
      */
78 78
     public function return_form($url, $action)
79 79
     {
Please login to merge, or discard this patch.
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -25,10 +25,10 @@  discard block
 block discarded – undo
25 25
     );
26 26
     public $is_course_model = true;
27 27
 
28
-	public function __construct()
28
+    public function __construct()
29 29
     {
30 30
         $this->table =  Database::get_course_table(TABLE_TIMELINE);
31
-	}
31
+    }
32 32
 
33 33
     /**
34 34
      * Get the count of elements
@@ -52,16 +52,16 @@  discard block
 block discarded – undo
52 52
     /**
53 53
      * Displays the title + grid
54 54
      */
55
-	public function listing()
55
+    public function listing()
56 56
     {
57
-		// action links
58
-		$html = '<div class="actions">';
57
+        // action links
58
+        $html = '<div class="actions">';
59 59
         //$html .= '<a href="career_dashboard.php">'.Display::return_icon('back.png',get_lang('Back'),'','32').'</a>';
60
-		$html .= '<a href="'.api_get_self().'?action=add">'.Display::return_icon('add.png', get_lang('Add'),'','32').'</a>';
61
-		$html .= '</div>';
60
+        $html .= '<a href="'.api_get_self().'?action=add">'.Display::return_icon('add.png', get_lang('Add'),'','32').'</a>';
61
+        $html .= '</div>';
62 62
         $html .= Display::grid_html('timelines');
63 63
         return $html;
64
-	}
64
+    }
65 65
 
66 66
     public function get_status_list()
67 67
     {
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 
90 90
         $form->addElement('text', 'headline', get_lang('Name'), array('size' => '70'));
91 91
         //$form->addHtmlEditor('description', get_lang('Description'), false, false, array('ToolbarSet' => 'Careers','Width' => '100%', 'Height' => '250'));
92
-	    $status_list = $this->get_status_list();
92
+        $status_list = $this->get_status_list();
93 93
         $form->addElement('select', 'status', get_lang('Status'), $status_list);
94 94
         if ($action == 'edit') {
95 95
             //$form->addElement('text', 'created_at', get_lang('CreatedAt'));
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 
174 174
         // Setting the rules
175 175
         $form->addRule('headline', get_lang('ThisFieldIsRequired'), 'required');
176
-		return $form;
176
+        return $form;
177 177
 
178 178
     }
179 179
 
@@ -184,11 +184,11 @@  discard block
 block discarded – undo
184 184
     public function save_item($params)
185 185
     {
186 186
         $params['c_id'] = api_get_course_int_id();
187
-	    $id = parent::save($params);
188
-	    if (!empty($id)) {
189
-	    	//event_system(LOG_CAREER_CREATE, LOG_CAREER_ID, $id, api_get_utc_datetime(), api_get_user_id());
190
-   		}
191
-   		return $id;
187
+        $id = parent::save($params);
188
+        if (!empty($id)) {
189
+            //event_system(LOG_CAREER_CREATE, LOG_CAREER_ID, $id, api_get_utc_datetime(), api_get_user_id());
190
+            }
191
+            return $id;
192 192
     }
193 193
 
194 194
     /**
@@ -199,16 +199,16 @@  discard block
 block discarded – undo
199 199
         $params['c_id'] = api_get_course_int_id();
200 200
         $params['parent_id'] = '0';
201 201
         $params['type'] = 'default';
202
-	    $id = parent::save($params);
203
-	    if (!empty($id)) {
204
-	    	//event_system(LOG_CAREER_CREATE, LOG_CAREER_ID, $id, api_get_utc_datetime(), api_get_user_id());
205
-   		}
206
-   		return $id;
202
+        $id = parent::save($params);
203
+        if (!empty($id)) {
204
+            //event_system(LOG_CAREER_CREATE, LOG_CAREER_ID, $id, api_get_utc_datetime(), api_get_user_id());
205
+            }
206
+            return $id;
207 207
     }
208 208
 
209 209
     public function delete($id) {
210
-	    parent::delete($id);
211
-	    //event_system(LOG_CAREER_DELETE, LOG_CAREER_ID, $id, api_get_utc_datetime(), api_get_user_id());
210
+        parent::delete($id);
211
+        //event_system(LOG_CAREER_DELETE, LOG_CAREER_ID, $id, api_get_utc_datetime(), api_get_user_id());
212 212
     }
213 213
 
214 214
     public function get_url($id) {
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
         $item['asset'] = array( 'media'     => $item['media'],
248 248
                                 'credit'    => $item['media_credit'],
249 249
                                 'caption'   => $item['media_caption'],
250
-         );
250
+            );
251 251
 
252 252
         //Cleaning items
253 253
         unset($item['id']);
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 
28 28
 	public function __construct()
29 29
     {
30
-        $this->table =  Database::get_course_table(TABLE_TIMELINE);
30
+        $this->table = Database::get_course_table(TABLE_TIMELINE);
31 31
 	}
32 32
 
33 33
     /**
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
      */
47 47
     public function get_all($where_conditions = array())
48 48
     {
49
-        return Database::select('*',$this->table, array('where'=>$where_conditions,'order' =>'headline ASC'));
49
+        return Database::select('*', $this->table, array('where'=>$where_conditions, 'order' =>'headline ASC'));
50 50
     }
51 51
 
52 52
     /**
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 		// action links
58 58
 		$html = '<div class="actions">';
59 59
         //$html .= '<a href="career_dashboard.php">'.Display::return_icon('back.png',get_lang('Back'),'','32').'</a>';
60
-		$html .= '<a href="'.api_get_self().'?action=add">'.Display::return_icon('add.png', get_lang('Add'),'','32').'</a>';
60
+		$html .= '<a href="'.api_get_self().'?action=add">'.Display::return_icon('add.png', get_lang('Add'), '', '32').'</a>';
61 61
 		$html .= '</div>';
62 62
         $html .= Display::grid_html('timelines');
63 63
         return $html;
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
         }
245 245
         unset($item['end_date']);
246 246
         // Assets
247
-        $item['asset'] = array( 'media'     => $item['media'],
247
+        $item['asset'] = array('media'     => $item['media'],
248 248
                                 'credit'    => $item['media_credit'],
249 249
                                 'caption'   => $item['media_caption'],
250 250
          );
Please login to merge, or discard this patch.
main/inc/lib/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   +854 added lines, -854 removed lines patch added patch discarded remove patch
@@ -314,8 +314,8 @@  discard block
 block discarded – undo
314 314
                     $extend_link = '';
315 315
                     if (!empty($inter_num)) {
316 316
                         $extend_link = Display::url(
317
-                              Display::return_icon('visible.gif', get_lang('HideAttemptView')),
318
-                              api_get_self() . '?action=stats&fold_id=' . $my_item_id . $url_suffix
317
+                                Display::return_icon('visible.gif', get_lang('HideAttemptView')),
318
+                                api_get_self() . '?action=stats&fold_id=' . $my_item_id . $url_suffix
319 319
                         );
320 320
                     }
321 321
                     $title = $row['mytitle'];
@@ -1366,7 +1366,7 @@  discard block
 block discarded – undo
1366 1366
                 $newDate = new DateTime('-30 days', new DateTimeZone('UTC'));
1367 1367
                 $condition_time = " AND (login_date >= '{$newDate->format('Y-m-d H:i:s')}'";
1368 1368
                 $condition_time .= "AND logout_date <= '{$today->format('Y-m-d H:i:s')}') ";
1369
-               break;
1369
+                break;
1370 1370
             case 'custom':
1371 1371
                 if (!empty($start_date) && !empty($end_date)) {
1372 1372
                     $start_date = Database::escape_string($start_date);
@@ -1376,10 +1376,10 @@  discard block
 block discarded – undo
1376 1376
                 break;
1377 1377
         }
1378 1378
 
1379
-    	$sql = 'SELECT SUM(TIMESTAMPDIFF(SECOND, login_date, logout_date)) diff
1379
+        $sql = 'SELECT SUM(TIMESTAMPDIFF(SECOND, login_date, logout_date)) diff
1380 1380
     	        FROM '.$tbl_track_login.'
1381 1381
                 WHERE '.$userCondition.$condition_time;
1382
-    	$rs = Database::query($sql);
1382
+        $rs = Database::query($sql);
1383 1383
         $row = Database::fetch_array($rs, 'ASSOC');
1384 1384
         $diff = $row['diff'];
1385 1385
 
@@ -1401,18 +1401,18 @@  discard block
 block discarded – undo
1401 1401
     public static function get_time_spent_on_the_course($user_id, $courseId, $session_id = 0)
1402 1402
     {
1403 1403
         $courseId = intval($courseId);
1404
-    	$session_id  = intval($session_id);
1405
-
1406
-    	$tbl_track_course = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1407
-    	if (is_array($user_id)) {
1408
-    	    $user_id = array_map('intval', $user_id);
1409
-    		$condition_user = " AND user_id IN (".implode(',',$user_id).") ";
1410
-    	} else {
1411
-    		$user_id = intval($user_id);
1412
-    		$condition_user = " AND user_id = $user_id ";
1413
-    	}
1414
-
1415
-    	$sql = "SELECT
1404
+        $session_id  = intval($session_id);
1405
+
1406
+        $tbl_track_course = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1407
+        if (is_array($user_id)) {
1408
+            $user_id = array_map('intval', $user_id);
1409
+            $condition_user = " AND user_id IN (".implode(',',$user_id).") ";
1410
+        } else {
1411
+            $user_id = intval($user_id);
1412
+            $condition_user = " AND user_id = $user_id ";
1413
+        }
1414
+
1415
+        $sql = "SELECT
1416 1416
     	        SUM(UNIX_TIMESTAMP(logout_course_date) - UNIX_TIMESTAMP(login_course_date)) as nb_seconds
1417 1417
                 FROM $tbl_track_course
1418 1418
                 WHERE UNIX_TIMESTAMP(logout_course_date) > UNIX_TIMESTAMP(login_course_date) ";
@@ -1427,9 +1427,9 @@  discard block
 block discarded – undo
1427 1427
 
1428 1428
         $sql .= $condition_user;
1429 1429
         $rs = Database::query($sql);
1430
-    	$row = Database::fetch_array($rs);
1430
+        $row = Database::fetch_array($rs);
1431 1431
 
1432
-    	return $row['nb_seconds'];
1432
+        return $row['nb_seconds'];
1433 1433
     }
1434 1434
 
1435 1435
     /**
@@ -1440,25 +1440,25 @@  discard block
 block discarded – undo
1440 1440
      */
1441 1441
     public static function get_first_connection_date($student_id)
1442 1442
     {
1443
-    	$tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
1444
-    	$sql = 'SELECT login_date
1443
+        $tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
1444
+        $sql = 'SELECT login_date
1445 1445
     	        FROM ' . $tbl_track_login . '
1446 1446
                 WHERE login_user_id = ' . intval($student_id) . '
1447 1447
                 ORDER BY login_date ASC
1448 1448
                 LIMIT 0,1';
1449 1449
 
1450
-    	$rs = Database::query($sql);
1451
-    	if (Database::num_rows($rs)>0) {
1452
-    		if ($first_login_date = Database::result($rs, 0, 0)) {
1450
+        $rs = Database::query($sql);
1451
+        if (Database::num_rows($rs)>0) {
1452
+            if ($first_login_date = Database::result($rs, 0, 0)) {
1453 1453
                 return api_convert_and_format_date(
1454 1454
                     $first_login_date,
1455 1455
                     DATE_FORMAT_SHORT,
1456 1456
                     date_default_timezone_get()
1457 1457
                 );
1458
-    		}
1459
-    	}
1458
+            }
1459
+        }
1460 1460
 
1461
-    	return false;
1461
+        return false;
1462 1462
     }
1463 1463
 
1464 1464
     /**
@@ -1471,38 +1471,38 @@  discard block
 block discarded – undo
1471 1471
      */
1472 1472
     public static function get_last_connection_date($student_id, $warning_message = false, $return_timestamp = false)
1473 1473
     {
1474
-    	$table = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
1475
-    	$sql = 'SELECT login_date
1474
+        $table = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
1475
+        $sql = 'SELECT login_date
1476 1476
     	        FROM ' . $table . '
1477 1477
                 WHERE login_user_id = ' . intval($student_id) . '
1478 1478
                 ORDER BY login_date
1479 1479
                 DESC LIMIT 0,1';
1480 1480
 
1481
-    	$rs = Database::query($sql);
1482
-    	if (Database::num_rows($rs) > 0) {
1483
-    		if ($last_login_date = Database::result($rs, 0, 0)) {
1484
-    			$last_login_date = api_get_local_time($last_login_date);
1485
-    			if ($return_timestamp) {
1486
-    				return api_strtotime($last_login_date,'UTC');
1487
-    			} else {
1488
-    				if (!$warning_message) {
1489
-    					return api_format_date($last_login_date, DATE_FORMAT_SHORT);
1490
-    				} else {
1491
-    					$timestamp = api_strtotime($last_login_date,'UTC');
1492
-    					$currentTimestamp = time();
1493
-
1494
-    					//If the last connection is > than 7 days, the text is red
1495
-    					//345600 = 7 days in seconds
1496
-    					if ($currentTimestamp - $timestamp > 604800) {
1497
-    						return '<span style="color: #F00;">' . api_format_date($last_login_date, DATE_FORMAT_SHORT) . '</span>';
1498
-    					} else {
1499
-    						return api_format_date($last_login_date, DATE_FORMAT_SHORT);
1500
-    					}
1501
-    				}
1502
-    			}
1503
-    		}
1504
-    	}
1505
-    	return false;
1481
+        $rs = Database::query($sql);
1482
+        if (Database::num_rows($rs) > 0) {
1483
+            if ($last_login_date = Database::result($rs, 0, 0)) {
1484
+                $last_login_date = api_get_local_time($last_login_date);
1485
+                if ($return_timestamp) {
1486
+                    return api_strtotime($last_login_date,'UTC');
1487
+                } else {
1488
+                    if (!$warning_message) {
1489
+                        return api_format_date($last_login_date, DATE_FORMAT_SHORT);
1490
+                    } else {
1491
+                        $timestamp = api_strtotime($last_login_date,'UTC');
1492
+                        $currentTimestamp = time();
1493
+
1494
+                        //If the last connection is > than 7 days, the text is red
1495
+                        //345600 = 7 days in seconds
1496
+                        if ($currentTimestamp - $timestamp > 604800) {
1497
+                            return '<span style="color: #F00;">' . api_format_date($last_login_date, DATE_FORMAT_SHORT) . '</span>';
1498
+                        } else {
1499
+                            return api_format_date($last_login_date, DATE_FORMAT_SHORT);
1500
+                        }
1501
+                    }
1502
+                }
1503
+            }
1504
+        }
1505
+        return false;
1506 1506
     }
1507 1507
 
1508 1508
     /**
@@ -1556,30 +1556,30 @@  discard block
 block discarded – undo
1556 1556
         $session_id = 0,
1557 1557
         $convert_date = true
1558 1558
     ) {
1559
-    	$student_id  = intval($student_id);
1559
+        $student_id  = intval($student_id);
1560 1560
         $courseId = intval($courseId);
1561
-    	$session_id  = intval($session_id);
1561
+        $session_id  = intval($session_id);
1562 1562
 
1563
-    	$tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1564
-    	$sql = 'SELECT login_course_date
1563
+        $tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1564
+        $sql = 'SELECT login_course_date
1565 1565
     	        FROM '.$tbl_track_login.'
1566 1566
                 WHERE
1567 1567
                     user_id = '.$student_id.' AND
1568 1568
                     c_id = '.$courseId.' AND
1569 1569
                     session_id = '.$session_id.'
1570 1570
                 ORDER BY login_course_date ASC LIMIT 0,1';
1571
-    	$rs = Database::query($sql);
1572
-    	if (Database::num_rows($rs) > 0) {
1573
-    		if ($first_login_date = Database::result($rs, 0, 0)) {
1574
-    			if ($convert_date) {
1575
-    				return api_convert_and_format_date($first_login_date, DATE_FORMAT_SHORT);
1576
-    			} else {
1577
-    				return $first_login_date;
1578
-    			}
1579
-    		}
1580
-    	}
1581
-
1582
-    	return false;
1571
+        $rs = Database::query($sql);
1572
+        if (Database::num_rows($rs) > 0) {
1573
+            if ($first_login_date = Database::result($rs, 0, 0)) {
1574
+                if ($convert_date) {
1575
+                    return api_convert_and_format_date($first_login_date, DATE_FORMAT_SHORT);
1576
+                } else {
1577
+                    return $first_login_date;
1578
+                }
1579
+            }
1580
+        }
1581
+
1582
+        return false;
1583 1583
     }
1584 1584
 
1585 1585
     /**
@@ -1595,13 +1595,13 @@  discard block
 block discarded – undo
1595 1595
         $session_id = 0,
1596 1596
         $convert_date = true
1597 1597
     ) {
1598
-    	// protect data
1599
-    	$student_id  = intval($student_id);
1598
+        // protect data
1599
+        $student_id  = intval($student_id);
1600 1600
         $courseId = $courseInfo['real_id'];
1601
-    	$session_id  = intval($session_id);
1601
+        $session_id  = intval($session_id);
1602 1602
 
1603
-    	$tbl_track_e_access = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
1604
-    	$sql = 'SELECT access_date
1603
+        $tbl_track_e_access = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
1604
+        $sql = 'SELECT access_date
1605 1605
                 FROM '.$tbl_track_e_access.'
1606 1606
                 WHERE   access_user_id = '.$student_id.' AND
1607 1607
                         c_id = "'.$courseId.'" AND
@@ -1609,39 +1609,39 @@  discard block
 block discarded – undo
1609 1609
                 ORDER BY access_date DESC
1610 1610
                 LIMIT 0,1';
1611 1611
 
1612
-    	$rs = Database::query($sql);
1613
-    	if (Database::num_rows($rs) > 0) {
1614
-    		if ($last_login_date = Database::result($rs, 0, 0)) {
1612
+        $rs = Database::query($sql);
1613
+        if (Database::num_rows($rs) > 0) {
1614
+            if ($last_login_date = Database::result($rs, 0, 0)) {
1615 1615
                 if (empty($last_login_date) || $last_login_date == '0000-00-00 00:00:00') {
1616 1616
                     return false;
1617 1617
                 }
1618 1618
                 //see #5736
1619 1619
                 $last_login_date_timestamp = api_strtotime($last_login_date);
1620
-    			$now = time();
1621
-    			//If the last connection is > than 7 days, the text is red
1622
-    			//345600 = 7 days in seconds
1623
-    			if ($now - $last_login_date_timestamp > 604800) {
1624
-    				if ($convert_date) {
1620
+                $now = time();
1621
+                //If the last connection is > than 7 days, the text is red
1622
+                //345600 = 7 days in seconds
1623
+                if ($now - $last_login_date_timestamp > 604800) {
1624
+                    if ($convert_date) {
1625 1625
                         $last_login_date = api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT);
1626 1626
                         $icon = api_is_allowed_to_edit() ?
1627 1627
                             '<a href="'.api_get_path(WEB_CODE_PATH).'announcements/announcements.php?action=add&remind_inactive='.$student_id.'&cidReq='.$courseInfo['code'].'" title="'.get_lang('RemindInactiveUser').'">
1628 1628
                               '.Display::return_icon('messagebox_warning.gif').'
1629 1629
                              </a>'
1630 1630
                             : null;
1631
-    					return $icon. Display::label($last_login_date, 'warning');
1632
-    				} else {
1633
-    					return $last_login_date;
1634
-    				}
1635
-    			} else {
1636
-    				if ($convert_date) {
1637
-    					return api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT);
1638
-    				} else {
1639
-    					return $last_login_date;
1640
-    				}
1641
-    			}
1642
-    		}
1643
-    	}
1644
-    	return false;
1631
+                        return $icon. Display::label($last_login_date, 'warning');
1632
+                    } else {
1633
+                        return $last_login_date;
1634
+                    }
1635
+                } else {
1636
+                    if ($convert_date) {
1637
+                        return api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT);
1638
+                    } else {
1639
+                        return $last_login_date;
1640
+                    }
1641
+                }
1642
+            }
1643
+        }
1644
+        return false;
1645 1645
     }
1646 1646
 
1647 1647
     /**
@@ -1655,11 +1655,11 @@  discard block
 block discarded – undo
1655 1655
     public static function get_course_connections_count($courseId, $session_id = 0, $start = 0, $stop = null)
1656 1656
     {
1657 1657
         if ($start < 0) {
1658
-    		$start = 0;
1659
-    	}
1660
-    	if (!isset($stop) or ($stop < 0)) {
1661
-    		$stop = api_get_utc_datetime();
1662
-    	}
1658
+            $start = 0;
1659
+        }
1660
+        if (!isset($stop) or ($stop < 0)) {
1661
+            $stop = api_get_utc_datetime();
1662
+        }
1663 1663
 
1664 1664
         // Given we're storing in cache, round the start and end times
1665 1665
         // to the lower minute
@@ -1668,11 +1668,11 @@  discard block
 block discarded – undo
1668 1668
         $roundedStart = Database::escape_string($roundedStart);
1669 1669
         $roundedStop = Database::escape_string($roundedStop);
1670 1670
 
1671
-    	$month_filter = " AND login_course_date > '$roundedStart' AND login_course_date < '$roundedStop' ";
1671
+        $month_filter = " AND login_course_date > '$roundedStart' AND login_course_date < '$roundedStop' ";
1672 1672
 
1673 1673
         $courseId = intval($courseId);
1674
-    	$session_id  = intval($session_id);
1675
-    	$count = 0;
1674
+        $session_id  = intval($session_id);
1675
+        $count = 0;
1676 1676
         $tbl_track_e_course_access = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1677 1677
         $sql =  "SELECT count(*) as count_connections
1678 1678
                 FROM $tbl_track_e_course_access
@@ -1711,7 +1711,7 @@  discard block
 block discarded – undo
1711 1711
             }
1712 1712
         }
1713 1713
 
1714
-    	return $count;
1714
+        return $count;
1715 1715
     }
1716 1716
 
1717 1717
     /**
@@ -1722,25 +1722,25 @@  discard block
 block discarded – undo
1722 1722
      */
1723 1723
     public static function count_course_per_student($user_id, $include_sessions = true)
1724 1724
     {
1725
-    	$user_id = intval($user_id);
1726
-    	$tbl_course_rel_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
1727
-    	$tbl_session_course_rel_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
1725
+        $user_id = intval($user_id);
1726
+        $tbl_course_rel_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
1727
+        $tbl_session_course_rel_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
1728 1728
 
1729
-    	$sql = 'SELECT DISTINCT c_id
1729
+        $sql = 'SELECT DISTINCT c_id
1730 1730
                 FROM ' . $tbl_course_rel_user . '
1731 1731
                 WHERE user_id = ' . $user_id.' AND relation_type<>'.COURSE_RELATION_TYPE_RRHH;
1732
-    	$rs = Database::query($sql);
1733
-    	$nb_courses = Database::num_rows($rs);
1732
+        $rs = Database::query($sql);
1733
+        $nb_courses = Database::num_rows($rs);
1734 1734
 
1735
-    	if ($include_sessions) {
1736
-    		$sql = 'SELECT DISTINCT c_id
1735
+        if ($include_sessions) {
1736
+            $sql = 'SELECT DISTINCT c_id
1737 1737
                     FROM ' . $tbl_session_course_rel_user . '
1738 1738
                     WHERE user_id = ' . $user_id;
1739
-    		$rs = Database::query($sql);
1740
-    		$nb_courses += Database::num_rows($rs);
1741
-    	}
1739
+            $rs = Database::query($sql);
1740
+            $nb_courses += Database::num_rows($rs);
1741
+        }
1742 1742
 
1743
-    	return $nb_courses;
1743
+        return $nb_courses;
1744 1744
     }
1745 1745
 
1746 1746
     /**
@@ -1771,25 +1771,25 @@  discard block
 block discarded – undo
1771 1771
         $into_lp = 0
1772 1772
     ) {
1773 1773
         $course_code = Database::escape_string($course_code);
1774
-    	$course_info = api_get_course_info($course_code);
1775
-    	if (!empty($course_info)) {
1776
-    		// table definition
1777
-    		$tbl_course_quiz     = Database::get_course_table(TABLE_QUIZ_TEST);
1778
-    		$tbl_stats_exercise  = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
1779
-
1780
-    		// Compose a filter based on optional exercise given
1781
-    		$condition_quiz = "";
1782
-    		if (!empty($exercise_id)) {
1783
-    			$exercise_id = intval($exercise_id);
1784
-    			$condition_quiz =" AND id = $exercise_id ";
1785
-    		}
1786
-
1787
-    		// Compose a filter based on optional session id given
1788
-    		$condition_session = "";
1789
-    		if (isset($session_id)) {
1790
-    			$session_id = intval($session_id);
1791
-    			$condition_session = " AND session_id = $session_id ";
1792
-    		}
1774
+        $course_info = api_get_course_info($course_code);
1775
+        if (!empty($course_info)) {
1776
+            // table definition
1777
+            $tbl_course_quiz     = Database::get_course_table(TABLE_QUIZ_TEST);
1778
+            $tbl_stats_exercise  = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
1779
+
1780
+            // Compose a filter based on optional exercise given
1781
+            $condition_quiz = "";
1782
+            if (!empty($exercise_id)) {
1783
+                $exercise_id = intval($exercise_id);
1784
+                $condition_quiz =" AND id = $exercise_id ";
1785
+            }
1786
+
1787
+            // Compose a filter based on optional session id given
1788
+            $condition_session = "";
1789
+            if (isset($session_id)) {
1790
+                $session_id = intval($session_id);
1791
+                $condition_session = " AND session_id = $session_id ";
1792
+            }
1793 1793
             if ($active_filter == 1) {
1794 1794
                 $condition_active = 'AND active <> -1';
1795 1795
             } elseif ($active_filter == 0) {
@@ -1805,25 +1805,25 @@  discard block
 block discarded – undo
1805 1805
                 $select_lp_id = ', orig_lp_id as lp_id ';
1806 1806
             }
1807 1807
 
1808
-    		$sql = "SELECT count(id) FROM $tbl_course_quiz
1808
+            $sql = "SELECT count(id) FROM $tbl_course_quiz
1809 1809
     				WHERE c_id = {$course_info['real_id']} $condition_active $condition_quiz ";
1810
-    		$count_quiz = Database::fetch_row(Database::query($sql));
1810
+            $count_quiz = Database::fetch_row(Database::query($sql));
1811 1811
 
1812
-    		if (!empty($count_quiz[0]) && !empty($student_id)) {
1813
-    			if (is_array($student_id)) {
1812
+            if (!empty($count_quiz[0]) && !empty($student_id)) {
1813
+                if (is_array($student_id)) {
1814 1814
                     $student_id = array_map('intval', $student_id);
1815
-    				$condition_user = " AND exe_user_id IN (".implode(',', $student_id).") ";
1816
-    			} else {
1815
+                    $condition_user = " AND exe_user_id IN (".implode(',', $student_id).") ";
1816
+                } else {
1817 1817
                     $student_id = intval($student_id);
1818
-    				$condition_user = " AND exe_user_id = '$student_id' ";
1819
-    			}
1818
+                    $condition_user = " AND exe_user_id = '$student_id' ";
1819
+                }
1820 1820
 
1821
-    			if (empty($exercise_id)) {
1822
-    				$sql = "SELECT id FROM $tbl_course_quiz
1821
+                if (empty($exercise_id)) {
1822
+                    $sql = "SELECT id FROM $tbl_course_quiz
1823 1823
     						WHERE c_id = {$course_info['real_id']} $condition_active $condition_quiz";
1824 1824
                     $result = Database::query($sql);
1825 1825
                     $exercise_list = array();
1826
-    				$exercise_id = null;
1826
+                    $exercise_id = null;
1827 1827
                     if (Database::num_rows($result)) {
1828 1828
                         while ($row = Database::fetch_array($result)) {
1829 1829
                             $exercise_list[] = $row['id'];
@@ -1832,11 +1832,11 @@  discard block
 block discarded – undo
1832 1832
                     if (!empty($exercise_list)) {
1833 1833
                         $exercise_id = implode("','",$exercise_list);
1834 1834
                     }
1835
-    			}
1835
+                }
1836 1836
 
1837
-    			$count_quiz = Database::fetch_row(Database::query($sql));
1837
+                $count_quiz = Database::fetch_row(Database::query($sql));
1838 1838
 
1839
-    			$sql = "SELECT
1839
+                $sql = "SELECT
1840 1840
     			        SUM(exe_result/exe_weighting*100) as avg_score,
1841 1841
     			        COUNT(*) as num_attempts
1842 1842
     			        $select_lp_id
@@ -1850,20 +1850,20 @@  discard block
 block discarded – undo
1850 1850
                             $condition_into_lp
1851 1851
                         ORDER BY exe_date DESC";
1852 1852
 
1853
-    			$res = Database::query($sql);
1854
-    			$row = Database::fetch_array($res);
1855
-    			$quiz_avg_score = null;
1853
+                $res = Database::query($sql);
1854
+                $row = Database::fetch_array($res);
1855
+                $quiz_avg_score = null;
1856 1856
 
1857
-    			if (!empty($row['avg_score'])) {
1858
-    				$quiz_avg_score = round($row['avg_score'],2);
1859
-    			}
1857
+                if (!empty($row['avg_score'])) {
1858
+                    $quiz_avg_score = round($row['avg_score'],2);
1859
+                }
1860 1860
 
1861
-    			if(!empty($row['num_attempts'])) {
1862
-    				$quiz_avg_score = round($quiz_avg_score / $row['num_attempts'], 2);
1863
-    			}
1864
-    			if (is_array($student_id)) {
1865
-    				$quiz_avg_score = round($quiz_avg_score / count($student_id), 2);
1866
-    			}
1861
+                if(!empty($row['num_attempts'])) {
1862
+                    $quiz_avg_score = round($quiz_avg_score / $row['num_attempts'], 2);
1863
+                }
1864
+                if (is_array($student_id)) {
1865
+                    $quiz_avg_score = round($quiz_avg_score / count($student_id), 2);
1866
+                }
1867 1867
                 if ($into_lp == 0) {
1868 1868
                     return $quiz_avg_score;
1869 1869
                 } else {
@@ -1886,9 +1886,9 @@  discard block
 block discarded – undo
1886 1886
                         return array($quiz_avg_score, null);
1887 1887
                     }
1888 1888
                 }
1889
-    		}
1890
-    	}
1891
-    	return null;
1889
+            }
1890
+        }
1891
+        return null;
1892 1892
     }
1893 1893
 
1894 1894
     /**
@@ -1921,15 +1921,15 @@  discard block
 block discarded – undo
1921 1921
         $find_all_lp = 0
1922 1922
     ) {
1923 1923
         $courseId = intval($courseId);
1924
-    	$student_id  = intval($student_id);
1925
-    	$exercise_id = intval($exercise_id);
1926
-    	$session_id  = intval($session_id);
1924
+        $student_id  = intval($student_id);
1925
+        $exercise_id = intval($exercise_id);
1926
+        $session_id  = intval($session_id);
1927 1927
 
1928
-    	$lp_id = intval($lp_id);
1928
+        $lp_id = intval($lp_id);
1929 1929
         $lp_item_id = intval($lp_item_id);
1930
-    	$tbl_stats_exercises = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
1930
+        $tbl_stats_exercises = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
1931 1931
 
1932
-    	$sql = "SELECT COUNT(ex.exe_id) as essais FROM $tbl_stats_exercises AS ex
1932
+        $sql = "SELECT COUNT(ex.exe_id) as essais FROM $tbl_stats_exercises AS ex
1933 1933
                 WHERE  ex.c_id = $courseId
1934 1934
                 AND ex.exe_exo_id = $exercise_id
1935 1935
                 AND status = ''
@@ -1944,11 +1944,11 @@  discard block
 block discarded – undo
1944 1944
                 AND orig_lp_item_id = $lp_item_id";
1945 1945
         }
1946 1946
 
1947
-    	$rs = Database::query($sql);
1948
-    	$row = Database::fetch_row($rs);
1949
-    	$count_attempts = $row[0];
1947
+        $rs = Database::query($sql);
1948
+        $row = Database::fetch_row($rs);
1949
+        $count_attempts = $row[0];
1950 1950
 
1951
-    	return $count_attempts;
1951
+        return $count_attempts;
1952 1952
     }
1953 1953
 
1954 1954
     /**
@@ -1958,7 +1958,7 @@  discard block
 block discarded – undo
1958 1958
      * @param int    $user_id
1959 1959
      * @param int    $courseId
1960 1960
      * @param int    $session_id
1961
-    */
1961
+     */
1962 1962
     public static function get_exercise_student_progress($exercise_list, $user_id, $courseId, $session_id)
1963 1963
     {
1964 1964
         $courseId = intval($courseId);
@@ -3622,8 +3622,8 @@  discard block
 block discarded – undo
3622 3622
 
3623 3623
         $condition_session = '';
3624 3624
         if (isset($session_id)) {
3625
-             $session_id = intval($session_id);
3626
-             $condition_session = ' AND f.session_id = '. $session_id;
3625
+                $session_id = intval($session_id);
3626
+                $condition_session = ' AND f.session_id = '. $session_id;
3627 3627
         }
3628 3628
 
3629 3629
         $groupId = intval($groupId);
@@ -5522,9 +5522,9 @@  discard block
 block discarded – undo
5522 5522
     }
5523 5523
 
5524 5524
     /**
5525
-    * @param FormValidator $form
5526
-    * @return mixed
5527
-    */
5525
+     * @param FormValidator $form
5526
+     * @return mixed
5527
+     */
5528 5528
     public static function setUserSearchForm($form)
5529 5529
     {
5530 5530
         global $_configuration;
@@ -5838,26 +5838,26 @@  discard block
 block discarded – undo
5838 5838
         $session_id = api_get_session_id();
5839 5839
         $course_id = api_get_course_int_id();
5840 5840
 
5841
-    	$table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
5842
-    	$table_user = Database :: get_main_table(TABLE_MAIN_USER);
5841
+        $table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
5842
+        $table_user = Database :: get_main_table(TABLE_MAIN_USER);
5843 5843
 
5844
-    	$sql = "SELECT count(tool) AS total_number_of_items
5844
+        $sql = "SELECT count(tool) AS total_number_of_items
5845 5845
     	        FROM $table_item_property track_resource, $table_user user
5846 5846
     	        WHERE
5847 5847
                     track_resource.c_id = $course_id AND
5848 5848
                     track_resource.insert_user_id = user.user_id AND
5849 5849
                     session_id " .(empty($session_id) ? ' IS NULL ' : " = $session_id ");
5850 5850
 
5851
-    	if (isset($_GET['keyword'])) {
5852
-    		$keyword = Database::escape_string(trim($_GET['keyword']));
5853
-    		$sql .= " AND (
5851
+        if (isset($_GET['keyword'])) {
5852
+            $keyword = Database::escape_string(trim($_GET['keyword']));
5853
+            $sql .= " AND (
5854 5854
     		            user.username LIKE '%".$keyword."%' OR
5855 5855
     		            lastedit_type LIKE '%".$keyword."%' OR
5856 5856
     		            tool LIKE '%".$keyword."%'
5857 5857
                     )";
5858
-    	}
5858
+        }
5859 5859
 
5860
-    	$sql .= " AND tool IN (
5860
+        $sql .= " AND tool IN (
5861 5861
     	            'document',
5862 5862
     	            'learnpath',
5863 5863
     	            'quiz',
@@ -5869,10 +5869,10 @@  discard block
 block discarded – undo
5869 5869
     	            'thematic_advance',
5870 5870
     	            'thematic_plan'
5871 5871
                 )";
5872
-    	$res = Database::query($sql);
5873
-    	$obj = Database::fetch_object($res);
5872
+        $res = Database::query($sql);
5873
+        $obj = Database::fetch_object($res);
5874 5874
 
5875
-    	return $obj->total_number_of_items;
5875
+        return $obj->total_number_of_items;
5876 5876
     }
5877 5877
 
5878 5878
     /**
@@ -5887,12 +5887,12 @@  discard block
 block discarded – undo
5887 5887
         $session_id = api_get_session_id();
5888 5888
         $course_id = api_get_course_int_id();
5889 5889
 
5890
-    	$table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
5891
-    	$table_user = Database :: get_main_table(TABLE_MAIN_USER);
5892
-    	$table_session = Database :: get_main_table(TABLE_MAIN_SESSION);
5893
-    	$session_id = intval($session_id);
5890
+        $table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
5891
+        $table_user = Database :: get_main_table(TABLE_MAIN_USER);
5892
+        $table_session = Database :: get_main_table(TABLE_MAIN_SESSION);
5893
+        $session_id = intval($session_id);
5894 5894
 
5895
-    	$sql = "SELECT
5895
+        $sql = "SELECT
5896 5896
                     tool as col0,
5897 5897
                     lastedit_type as col1,
5898 5898
                     ref as ref,
@@ -5906,16 +5906,16 @@  discard block
 block discarded – undo
5906 5906
                   track_resource.insert_user_id = user.user_id AND
5907 5907
                   session_id " .(empty($session_id) ? ' IS NULL ' : " = $session_id ");
5908 5908
 
5909
-    	if (isset($_GET['keyword'])) {
5910
-    		$keyword = Database::escape_string(trim($_GET['keyword']));
5911
-    		$sql .= " AND (
5909
+        if (isset($_GET['keyword'])) {
5910
+            $keyword = Database::escape_string(trim($_GET['keyword']));
5911
+            $sql .= " AND (
5912 5912
     		            user.username LIKE '%".$keyword."%' OR
5913 5913
     		            lastedit_type LIKE '%".$keyword."%' OR
5914 5914
     		            tool LIKE '%".$keyword."%'
5915 5915
                      ) ";
5916
-    	}
5916
+        }
5917 5917
 
5918
-    	$sql .= " AND tool IN (
5918
+        $sql .= " AND tool IN (
5919 5919
     	            'document',
5920 5920
     	            'learnpath',
5921 5921
     	            'quiz',
@@ -5928,41 +5928,41 @@  discard block
 block discarded – undo
5928 5928
     	            'thematic_plan'
5929 5929
                 )";
5930 5930
 
5931
-    	if ($column == 0) {
5932
-    		$column = '0';
5933
-    	}
5934
-    	if ($column != '' && $direction != '') {
5935
-    		if ($column != 2 && $column != 4) {
5936
-    			$sql .= " ORDER BY col$column $direction";
5937
-    		}
5938
-    	} else {
5939
-    		$sql .= " ORDER BY col5 DESC ";
5940
-    	}
5931
+        if ($column == 0) {
5932
+            $column = '0';
5933
+        }
5934
+        if ($column != '' && $direction != '') {
5935
+            if ($column != 2 && $column != 4) {
5936
+                $sql .= " ORDER BY col$column $direction";
5937
+            }
5938
+        } else {
5939
+            $sql .= " ORDER BY col5 DESC ";
5940
+        }
5941 5941
 
5942 5942
         $from = intval($from);
5943 5943
         $number_of_items = intval($number_of_items);
5944 5944
 
5945
-    	$sql .= " LIMIT $from, $number_of_items ";
5946
-
5947
-    	$res = Database::query($sql);
5948
-    	$resources = array();
5949
-    	$thematic_tools = array('thematic', 'thematic_advance', 'thematic_plan');
5950
-    	while ($row = Database::fetch_array($res)) {
5951
-    		$ref = $row['ref'];
5952
-    		$table_name = TrackingCourseLog::get_tool_name_table($row['col0']);
5953
-    		$table_tool = Database :: get_course_table($table_name['table_name']);
5945
+        $sql .= " LIMIT $from, $number_of_items ";
5954 5946
 
5955
-    		$id = $table_name['id_tool'];
5956
-    		$recorset = false;
5957
-
5958
-    		if (in_array($row['col0'], array('thematic_plan', 'thematic_advance'))) {
5959
-    			$tbl_thematic = Database :: get_course_table(TABLE_THEMATIC);
5960
-    			$sql = "SELECT thematic_id FROM $table_tool
5947
+        $res = Database::query($sql);
5948
+        $resources = array();
5949
+        $thematic_tools = array('thematic', 'thematic_advance', 'thematic_plan');
5950
+        while ($row = Database::fetch_array($res)) {
5951
+            $ref = $row['ref'];
5952
+            $table_name = TrackingCourseLog::get_tool_name_table($row['col0']);
5953
+            $table_tool = Database :: get_course_table($table_name['table_name']);
5954
+
5955
+            $id = $table_name['id_tool'];
5956
+            $recorset = false;
5957
+
5958
+            if (in_array($row['col0'], array('thematic_plan', 'thematic_advance'))) {
5959
+                $tbl_thematic = Database :: get_course_table(TABLE_THEMATIC);
5960
+                $sql = "SELECT thematic_id FROM $table_tool
5961 5961
     			        WHERE c_id = $course_id AND id = $ref";
5962
-    			$rs_thematic  = Database::query($sql);
5963
-    			if (Database::num_rows($rs_thematic)) {
5964
-    				$row_thematic = Database::fetch_array($rs_thematic);
5965
-    				$thematic_id = $row_thematic['thematic_id'];
5962
+                $rs_thematic  = Database::query($sql);
5963
+                if (Database::num_rows($rs_thematic)) {
5964
+                    $row_thematic = Database::fetch_array($rs_thematic);
5965
+                    $thematic_id = $row_thematic['thematic_id'];
5966 5966
 
5967 5967
                     $sql = "SELECT session.id, session.name, user.username
5968 5968
                             FROM $tbl_thematic t, $table_session session, $table_user user
@@ -5971,9 +5971,9 @@  discard block
 block discarded – undo
5971 5971
                               t.session_id = session.id AND
5972 5972
                               session.id_coach = user.user_id AND
5973 5973
                               t.id = $thematic_id";
5974
-    				$recorset = Database::query($sql);
5975
-    			}
5976
-    		} else {
5974
+                    $recorset = Database::query($sql);
5975
+                }
5976
+            } else {
5977 5977
                 $sql = "SELECT session.id, session.name, user.username
5978 5978
                           FROM $table_tool tool, $table_session session, $table_user user
5979 5979
     			          WHERE
@@ -5981,127 +5981,127 @@  discard block
 block discarded – undo
5981 5981
     			              tool.session_id = session.id AND
5982 5982
     			              session.id_coach = user.user_id AND
5983 5983
     			              tool.$id = $ref";
5984
-    			$recorset = Database::query($sql);
5985
-    		}
5986
-
5987
-    		if (!empty($recorset)) {
5988
-    			$obj = Database::fetch_object($recorset);
5989
-
5990
-    			$name_session = '';
5991
-    			$coach_name = '';
5992
-    			if (!empty($obj)) {
5993
-    				$name_session = $obj->name;
5994
-    				$coach_name   = $obj->username;
5995
-    			}
5996
-
5997
-    			$url_tool = api_get_path(WEB_CODE_PATH).$table_name['link_tool'];
5998
-    			$row[0] = '';
5999
-    			if ($row['col6'] != 2) {
6000
-    				if (in_array($row['col0'], $thematic_tools)) {
6001
-
6002
-    					$exp_thematic_tool = explode('_', $row['col0']);
6003
-    					$thematic_tool_title = '';
6004
-    					if (is_array($exp_thematic_tool)) {
6005
-    						foreach ($exp_thematic_tool as $exp) {
6006
-    							$thematic_tool_title .= api_ucfirst($exp);
6007
-    						}
6008
-    					} else {
6009
-    						$thematic_tool_title = api_ucfirst($row['col0']);
6010
-    					}
6011
-
6012
-    					$row[0] = '<a href="'.$url_tool.'?'.api_get_cidreq().'&action=thematic_details">'.get_lang($thematic_tool_title).'</a>';
6013
-    				} else {
6014
-    					$row[0] = '<a href="'.$url_tool.'?'.api_get_cidreq().'">'.get_lang('Tool'.api_ucfirst($row['col0'])).'</a>';
6015
-    				}
6016
-    			} else {
6017
-    				$row[0] = api_ucfirst($row['col0']);
6018
-    			}
6019
-    			$row[1] = get_lang($row[1]);
6020
-    			$row[6] = api_convert_and_format_date($row['col5'], null, date_default_timezone_get());
6021
-    			$row[5] = '';
6022
-    			//@todo Improve this code please
6023
-    			switch ($table_name['table_name']) {
6024
-    				case 'document' :
6025
-    					$sql = "SELECT tool.title as title FROM $table_tool tool
5984
+                $recorset = Database::query($sql);
5985
+            }
5986
+
5987
+            if (!empty($recorset)) {
5988
+                $obj = Database::fetch_object($recorset);
5989
+
5990
+                $name_session = '';
5991
+                $coach_name = '';
5992
+                if (!empty($obj)) {
5993
+                    $name_session = $obj->name;
5994
+                    $coach_name   = $obj->username;
5995
+                }
5996
+
5997
+                $url_tool = api_get_path(WEB_CODE_PATH).$table_name['link_tool'];
5998
+                $row[0] = '';
5999
+                if ($row['col6'] != 2) {
6000
+                    if (in_array($row['col0'], $thematic_tools)) {
6001
+
6002
+                        $exp_thematic_tool = explode('_', $row['col0']);
6003
+                        $thematic_tool_title = '';
6004
+                        if (is_array($exp_thematic_tool)) {
6005
+                            foreach ($exp_thematic_tool as $exp) {
6006
+                                $thematic_tool_title .= api_ucfirst($exp);
6007
+                            }
6008
+                        } else {
6009
+                            $thematic_tool_title = api_ucfirst($row['col0']);
6010
+                        }
6011
+
6012
+                        $row[0] = '<a href="'.$url_tool.'?'.api_get_cidreq().'&action=thematic_details">'.get_lang($thematic_tool_title).'</a>';
6013
+                    } else {
6014
+                        $row[0] = '<a href="'.$url_tool.'?'.api_get_cidreq().'">'.get_lang('Tool'.api_ucfirst($row['col0'])).'</a>';
6015
+                    }
6016
+                } else {
6017
+                    $row[0] = api_ucfirst($row['col0']);
6018
+                }
6019
+                $row[1] = get_lang($row[1]);
6020
+                $row[6] = api_convert_and_format_date($row['col5'], null, date_default_timezone_get());
6021
+                $row[5] = '';
6022
+                //@todo Improve this code please
6023
+                switch ($table_name['table_name']) {
6024
+                    case 'document' :
6025
+                        $sql = "SELECT tool.title as title FROM $table_tool tool
6026 6026
                                 WHERE c_id = $course_id AND id = $ref";
6027
-    					$rs_document = Database::query($sql);
6028
-    					$obj_document = Database::fetch_object($rs_document);
6029
-    					$row[5] = $obj_document->title;
6027
+                        $rs_document = Database::query($sql);
6028
+                        $obj_document = Database::fetch_object($rs_document);
6029
+                        $row[5] = $obj_document->title;
6030 6030
 
6031
-    					break;
6032
-    				case 'announcement':
6031
+                        break;
6032
+                    case 'announcement':
6033 6033
                         $sql = "SELECT title FROM $table_tool
6034 6034
                                 WHERE c_id = $course_id AND id = $ref";
6035
-    					$rs_document = Database::query($sql);
6036
-    					$obj_document = Database::fetch_object($rs_document);
6035
+                        $rs_document = Database::query($sql);
6036
+                        $obj_document = Database::fetch_object($rs_document);
6037 6037
                         if ($obj_document) {
6038 6038
                             $row[5] = $obj_document->title;
6039 6039
                         }
6040
-    					break;
6041
-    				case 'glossary':
6040
+                        break;
6041
+                    case 'glossary':
6042 6042
                         $sql = "SELECT name FROM $table_tool
6043 6043
     					        WHERE c_id = $course_id AND glossary_id = $ref";
6044
-    					$rs_document = Database::query($sql);
6045
-    					$obj_document = Database::fetch_object($rs_document);
6044
+                        $rs_document = Database::query($sql);
6045
+                        $obj_document = Database::fetch_object($rs_document);
6046 6046
                         if ($obj_document) {
6047 6047
                             $row[5] = $obj_document->name;
6048 6048
                         }
6049
-    					break;
6050
-    				case 'lp':
6049
+                        break;
6050
+                    case 'lp':
6051 6051
                         $sql = "SELECT name
6052 6052
                                 FROM $table_tool WHERE c_id = $course_id AND id = $ref";
6053
-    					$rs_document = Database::query($sql);
6054
-    					$obj_document = Database::fetch_object($rs_document);
6055
-    					$row[5] = $obj_document->name;
6056
-    					break;
6057
-    				case 'quiz':
6053
+                        $rs_document = Database::query($sql);
6054
+                        $obj_document = Database::fetch_object($rs_document);
6055
+                        $row[5] = $obj_document->name;
6056
+                        break;
6057
+                    case 'quiz':
6058 6058
                         $sql = "SELECT title FROM $table_tool
6059 6059
                                 WHERE c_id = $course_id AND id = $ref";
6060
-    					$rs_document = Database::query($sql);
6061
-    					$obj_document = Database::fetch_object($rs_document);
6060
+                        $rs_document = Database::query($sql);
6061
+                        $obj_document = Database::fetch_object($rs_document);
6062 6062
                         if ($obj_document) {
6063 6063
                             $row[5] = $obj_document->title;
6064 6064
                         }
6065
-    					break;
6066
-    				case 'course_description':
6065
+                        break;
6066
+                    case 'course_description':
6067 6067
                         $sql = "SELECT title FROM $table_tool
6068 6068
                                 WHERE c_id = $course_id AND id = $ref";
6069
-    					$rs_document = Database::query($sql);
6070
-    					$obj_document = Database::fetch_object($rs_document);
6069
+                        $rs_document = Database::query($sql);
6070
+                        $obj_document = Database::fetch_object($rs_document);
6071 6071
                         if ($obj_document) {
6072 6072
                             $row[5] = $obj_document->title;
6073 6073
                         }
6074
-    					break;
6075
-    				case 'thematic':
6076
-    					$rs = Database::query("SELECT title FROM $table_tool WHERE c_id = $course_id AND id = $ref");
6077
-    					if (Database::num_rows($rs) > 0) {
6078
-    						$obj = Database::fetch_object($rs);
6079
-    						$row[5] = $obj->title;
6080
-    					}
6081
-    					break;
6082
-    				case 'thematic_advance':
6083
-    					$rs = Database::query("SELECT content FROM $table_tool WHERE c_id = $course_id AND id = $ref");
6084
-    					if (Database::num_rows($rs) > 0) {
6085
-    						$obj = Database::fetch_object($rs);
6086
-    						$row[5] = $obj->content;
6087
-    					}
6088
-    					break;
6089
-    				case 'thematic_plan':
6090
-    					$rs = Database::query("SELECT title FROM $table_tool WHERE c_id = $course_id AND id = $ref");
6091
-    					if (Database::num_rows($rs) > 0) {
6092
-    						$obj = Database::fetch_object($rs);
6093
-    						$row[5] = $obj->title;
6094
-    					}
6095
-    					break;
6096
-    				default:
6097
-    					break;
6098
-    			}
6099
-
6100
-    			$row2 = $name_session;
6101
-    			if (!empty($coach_name)) {
6102
-    				$row2 .= '<br />'.get_lang('Coach').': '.$coach_name;
6103
-    			}
6104
-    			$row[2] = $row2;
6074
+                        break;
6075
+                    case 'thematic':
6076
+                        $rs = Database::query("SELECT title FROM $table_tool WHERE c_id = $course_id AND id = $ref");
6077
+                        if (Database::num_rows($rs) > 0) {
6078
+                            $obj = Database::fetch_object($rs);
6079
+                            $row[5] = $obj->title;
6080
+                        }
6081
+                        break;
6082
+                    case 'thematic_advance':
6083
+                        $rs = Database::query("SELECT content FROM $table_tool WHERE c_id = $course_id AND id = $ref");
6084
+                        if (Database::num_rows($rs) > 0) {
6085
+                            $obj = Database::fetch_object($rs);
6086
+                            $row[5] = $obj->content;
6087
+                        }
6088
+                        break;
6089
+                    case 'thematic_plan':
6090
+                        $rs = Database::query("SELECT title FROM $table_tool WHERE c_id = $course_id AND id = $ref");
6091
+                        if (Database::num_rows($rs) > 0) {
6092
+                            $obj = Database::fetch_object($rs);
6093
+                            $row[5] = $obj->title;
6094
+                        }
6095
+                        break;
6096
+                    default:
6097
+                        break;
6098
+                }
6099
+
6100
+                $row2 = $name_session;
6101
+                if (!empty($coach_name)) {
6102
+                    $row2 .= '<br />'.get_lang('Coach').': '.$coach_name;
6103
+                }
6104
+                $row[2] = $row2;
6105 6105
                 if (!empty($row['col3'])) {
6106 6106
                     $userInfo = api_get_user_info($row['user_id']);
6107 6107
 
@@ -6118,11 +6118,11 @@  discard block
 block discarded – undo
6118 6118
                     $row[4] = $ip;
6119 6119
                 }
6120 6120
 
6121
-    			$resources[] = $row;
6122
-    		}
6123
-    	}
6121
+                $resources[] = $row;
6122
+            }
6123
+        }
6124 6124
 
6125
-    	return $resources;
6125
+        return $resources;
6126 6126
     }
6127 6127
 
6128 6128
     /**
@@ -6132,63 +6132,63 @@  discard block
 block discarded – undo
6132 6132
      */
6133 6133
     public static function get_tool_name_table($tool)
6134 6134
     {
6135
-    	switch ($tool) {
6136
-    		case 'document':
6137
-    			$table_name = TABLE_DOCUMENT;
6138
-    			$link_tool = 'document/document.php';
6139
-    			$id_tool = 'id';
6140
-    			break;
6141
-    		case 'learnpath':
6142
-    			$table_name = TABLE_LP_MAIN;
6143
-    			$link_tool = 'newscorm/lp_controller.php';
6144
-    			$id_tool = 'id';
6145
-    			break;
6146
-    		case 'quiz':
6147
-    			$table_name = TABLE_QUIZ_TEST;
6148
-    			$link_tool = 'exercice/exercice.php';
6149
-    			$id_tool = 'id';
6150
-    			break;
6151
-    		case 'glossary':
6152
-    			$table_name = TABLE_GLOSSARY;
6153
-    			$link_tool = 'glossary/index.php';
6154
-    			$id_tool = 'glossary_id';
6155
-    			break;
6156
-    		case 'link':
6157
-    			$table_name = TABLE_LINK;
6158
-    			$link_tool = 'link/link.php';
6159
-    			$id_tool = 'id';
6160
-    			break;
6161
-    		case 'course_description':
6162
-    			$table_name = TABLE_COURSE_DESCRIPTION;
6163
-    			$link_tool = 'course_description/';
6164
-    			$id_tool = 'id';
6165
-    			break;
6166
-    		case 'announcement':
6167
-    			$table_name = TABLE_ANNOUNCEMENT;
6168
-    			$link_tool = 'announcements/announcements.php';
6169
-    			$id_tool = 'id';
6170
-    			break;
6171
-    		case 'thematic':
6172
-    			$table_name = TABLE_THEMATIC;
6173
-    			$link_tool = 'course_progress/index.php';
6174
-    			$id_tool = 'id';
6175
-    			break;
6176
-    		case 'thematic_advance':
6177
-    			$table_name = TABLE_THEMATIC_ADVANCE;
6178
-    			$link_tool = 'course_progress/index.php';
6179
-    			$id_tool = 'id';
6180
-    			break;
6181
-    		case 'thematic_plan':
6182
-    			$table_name = TABLE_THEMATIC_PLAN;
6183
-    			$link_tool = 'course_progress/index.php';
6184
-    			$id_tool = 'id';
6185
-    			break;
6186
-    		default:
6187
-    			$table_name = $tool;
6188
-    		break;
6189
-    	}
6190
-
6191
-    	return array(
6135
+        switch ($tool) {
6136
+            case 'document':
6137
+                $table_name = TABLE_DOCUMENT;
6138
+                $link_tool = 'document/document.php';
6139
+                $id_tool = 'id';
6140
+                break;
6141
+            case 'learnpath':
6142
+                $table_name = TABLE_LP_MAIN;
6143
+                $link_tool = 'newscorm/lp_controller.php';
6144
+                $id_tool = 'id';
6145
+                break;
6146
+            case 'quiz':
6147
+                $table_name = TABLE_QUIZ_TEST;
6148
+                $link_tool = 'exercice/exercice.php';
6149
+                $id_tool = 'id';
6150
+                break;
6151
+            case 'glossary':
6152
+                $table_name = TABLE_GLOSSARY;
6153
+                $link_tool = 'glossary/index.php';
6154
+                $id_tool = 'glossary_id';
6155
+                break;
6156
+            case 'link':
6157
+                $table_name = TABLE_LINK;
6158
+                $link_tool = 'link/link.php';
6159
+                $id_tool = 'id';
6160
+                break;
6161
+            case 'course_description':
6162
+                $table_name = TABLE_COURSE_DESCRIPTION;
6163
+                $link_tool = 'course_description/';
6164
+                $id_tool = 'id';
6165
+                break;
6166
+            case 'announcement':
6167
+                $table_name = TABLE_ANNOUNCEMENT;
6168
+                $link_tool = 'announcements/announcements.php';
6169
+                $id_tool = 'id';
6170
+                break;
6171
+            case 'thematic':
6172
+                $table_name = TABLE_THEMATIC;
6173
+                $link_tool = 'course_progress/index.php';
6174
+                $id_tool = 'id';
6175
+                break;
6176
+            case 'thematic_advance':
6177
+                $table_name = TABLE_THEMATIC_ADVANCE;
6178
+                $link_tool = 'course_progress/index.php';
6179
+                $id_tool = 'id';
6180
+                break;
6181
+            case 'thematic_plan':
6182
+                $table_name = TABLE_THEMATIC_PLAN;
6183
+                $link_tool = 'course_progress/index.php';
6184
+                $id_tool = 'id';
6185
+                break;
6186
+            default:
6187
+                $table_name = $tool;
6188
+            break;
6189
+        }
6190
+
6191
+        return array(
6192 6192
             'table_name' => $table_name,
6193 6193
             'link_tool' => $link_tool,
6194 6194
             'id_tool' => $id_tool
@@ -6197,45 +6197,45 @@  discard block
 block discarded – undo
6197 6197
 
6198 6198
     public static function display_additional_profile_fields()
6199 6199
     {
6200
-    	// getting all the extra profile fields that are defined by the platform administrator
6201
-    	$extra_fields = UserManager :: get_extra_fields(0,50,5,'ASC');
6202
-
6203
-    	// creating the form
6204
-    	$return = '<form action="courseLog.php" method="get" name="additional_profile_field_form" id="additional_profile_field_form">';
6205
-
6206
-    	// the select field with the additional user profile fields (= this is where we select the field of which we want to see
6207
-    	// the information the users have entered or selected.
6208
-    	$return .= '<select name="additional_profile_field">';
6209
-    	$return .= '<option value="-">'.get_lang('SelectFieldToAdd').'</option>';
6210
-    	$extra_fields_to_show = 0;
6211
-    	foreach ($extra_fields as $key=>$field) {
6212
-    		// show only extra fields that are visible + and can be filtered, added by J.Montoya
6213
-    		if ($field[6]==1 && $field[8] == 1) {
6214
-    			if (isset($_GET['additional_profile_field']) && $field[0] == $_GET['additional_profile_field'] ) {
6215
-    				$selected = 'selected="selected"';
6216
-    			} else {
6217
-    				$selected = '';
6218
-    			}
6219
-    			$extra_fields_to_show++;
6220
-    			$return .= '<option value="'.$field[0].'" '.$selected.'>'.$field[3].'</option>';
6221
-    		}
6222
-    	}
6223
-    	$return .= '</select>';
6224
-
6225
-    	// the form elements for the $_GET parameters (because the form is passed through GET
6226
-    	foreach ($_GET as $key=>$value){
6227
-    		if ($key <> 'additional_profile_field')    {
6228
-    			$return .= '<input type="hidden" name="'.Security::remove_XSS($key).'" value="'.Security::remove_XSS($value).'" />';
6229
-    		}
6230
-    	}
6231
-    	// the submit button
6232
-    	$return .= '<button class="save" type="submit">'.get_lang('AddAdditionalProfileField').'</button>';
6233
-    	$return .= '</form>';
6234
-    	if ($extra_fields_to_show > 0) {
6235
-    		return $return;
6236
-    	} else {
6237
-    		return '';
6238
-    	}
6200
+        // getting all the extra profile fields that are defined by the platform administrator
6201
+        $extra_fields = UserManager :: get_extra_fields(0,50,5,'ASC');
6202
+
6203
+        // creating the form
6204
+        $return = '<form action="courseLog.php" method="get" name="additional_profile_field_form" id="additional_profile_field_form">';
6205
+
6206
+        // the select field with the additional user profile fields (= this is where we select the field of which we want to see
6207
+        // the information the users have entered or selected.
6208
+        $return .= '<select name="additional_profile_field">';
6209
+        $return .= '<option value="-">'.get_lang('SelectFieldToAdd').'</option>';
6210
+        $extra_fields_to_show = 0;
6211
+        foreach ($extra_fields as $key=>$field) {
6212
+            // show only extra fields that are visible + and can be filtered, added by J.Montoya
6213
+            if ($field[6]==1 && $field[8] == 1) {
6214
+                if (isset($_GET['additional_profile_field']) && $field[0] == $_GET['additional_profile_field'] ) {
6215
+                    $selected = 'selected="selected"';
6216
+                } else {
6217
+                    $selected = '';
6218
+                }
6219
+                $extra_fields_to_show++;
6220
+                $return .= '<option value="'.$field[0].'" '.$selected.'>'.$field[3].'</option>';
6221
+            }
6222
+        }
6223
+        $return .= '</select>';
6224
+
6225
+        // the form elements for the $_GET parameters (because the form is passed through GET
6226
+        foreach ($_GET as $key=>$value){
6227
+            if ($key <> 'additional_profile_field')    {
6228
+                $return .= '<input type="hidden" name="'.Security::remove_XSS($key).'" value="'.Security::remove_XSS($value).'" />';
6229
+            }
6230
+        }
6231
+        // the submit button
6232
+        $return .= '<button class="save" type="submit">'.get_lang('AddAdditionalProfileField').'</button>';
6233
+        $return .= '</form>';
6234
+        if ($extra_fields_to_show > 0) {
6235
+            return $return;
6236
+        } else {
6237
+            return '';
6238
+        }
6239 6239
     }
6240 6240
 
6241 6241
     /**
@@ -6254,31 +6254,31 @@  discard block
 block discarded – undo
6254 6254
      */
6255 6255
     public static function get_addtional_profile_information_of_field_by_user($field_id, $users)
6256 6256
     {
6257
-    	// Database table definition
6258
-    	$table_user = Database::get_main_table(TABLE_MAIN_USER);
6259
-    	$table_user_field_values = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES);
6257
+        // Database table definition
6258
+        $table_user = Database::get_main_table(TABLE_MAIN_USER);
6259
+        $table_user_field_values = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES);
6260 6260
         $extraField = Database::get_main_table(TABLE_EXTRA_FIELD);
6261
-    	$result_extra_field = UserManager::get_extra_field_information($field_id);
6262
-
6263
-    	if (!empty($users)) {
6264
-    		if ($result_extra_field['field_type'] == UserManager::USER_FIELD_TYPE_TAG ) {
6265
-    			foreach($users as $user_id) {
6266
-    				$user_result = UserManager::get_user_tags($user_id, $field_id);
6267
-    				$tag_list = array();
6268
-    				foreach($user_result as $item) {
6269
-    					$tag_list[] = $item['tag'];
6270
-    				}
6271
-    				$return[$user_id][] = implode(', ',$tag_list);
6272
-    			}
6273
-    		} else {
6274
-    			$new_user_array = array();
6275
-    			foreach ($users as $user_id) {
6276
-    				$new_user_array[]= "'".$user_id."'";
6277
-    			}
6278
-    			$users = implode(',',$new_user_array);
6261
+        $result_extra_field = UserManager::get_extra_field_information($field_id);
6262
+
6263
+        if (!empty($users)) {
6264
+            if ($result_extra_field['field_type'] == UserManager::USER_FIELD_TYPE_TAG ) {
6265
+                foreach($users as $user_id) {
6266
+                    $user_result = UserManager::get_user_tags($user_id, $field_id);
6267
+                    $tag_list = array();
6268
+                    foreach($user_result as $item) {
6269
+                        $tag_list[] = $item['tag'];
6270
+                    }
6271
+                    $return[$user_id][] = implode(', ',$tag_list);
6272
+                }
6273
+            } else {
6274
+                $new_user_array = array();
6275
+                foreach ($users as $user_id) {
6276
+                    $new_user_array[]= "'".$user_id."'";
6277
+                }
6278
+                $users = implode(',',$new_user_array);
6279 6279
                 $extraFieldType = EntityExtraField::USER_FIELD_TYPE;
6280
-    			// Selecting only the necessary information NOT ALL the user list
6281
-    			$sql = "SELECT user.user_id, v.value
6280
+                // Selecting only the necessary information NOT ALL the user list
6281
+                $sql = "SELECT user.user_id, v.value
6282 6282
     			        FROM $table_user user
6283 6283
     			        INNER JOIN $table_user_field_values v
6284 6284
                         ON (user.user_id = v.item_id)
@@ -6289,27 +6289,27 @@  discard block
 block discarded – undo
6289 6289
                             v.field_id=".intval($field_id)." AND
6290 6290
                             user.user_id IN ($users)";
6291 6291
 
6292
-    			$result = Database::query($sql);
6293
-    			while($row = Database::fetch_array($result)) {
6294
-    				// get option value for field type double select by id
6295
-    				if (!empty($row['value'])) {
6296
-    					if ($result_extra_field['field_type'] ==
6292
+                $result = Database::query($sql);
6293
+                while($row = Database::fetch_array($result)) {
6294
+                    // get option value for field type double select by id
6295
+                    if (!empty($row['value'])) {
6296
+                        if ($result_extra_field['field_type'] ==
6297 6297
                             ExtraField::FIELD_TYPE_DOUBLE_SELECT
6298 6298
                         ) {
6299
-    						$id_double_select = explode(';', $row['value']);
6300
-    						if (is_array($id_double_select)) {
6301
-    							$value1 = $result_extra_field['options'][$id_double_select[0]]['option_value'];
6302
-    							$value2 = $result_extra_field['options'][$id_double_select[1]]['option_value'];
6303
-    							$row['value'] = ($value1.';'.$value2);
6304
-    						}
6305
-    					}
6306
-    				}
6307
-    				// get other value from extra field
6308
-    				$return[$row['user_id']][] = $row['value'];
6309
-    			}
6310
-    		}
6311
-    	}
6312
-    	return $return;
6299
+                            $id_double_select = explode(';', $row['value']);
6300
+                            if (is_array($id_double_select)) {
6301
+                                $value1 = $result_extra_field['options'][$id_double_select[0]]['option_value'];
6302
+                                $value2 = $result_extra_field['options'][$id_double_select[1]]['option_value'];
6303
+                                $row['value'] = ($value1.';'.$value2);
6304
+                            }
6305
+                        }
6306
+                    }
6307
+                    // get other value from extra field
6308
+                    $return[$row['user_id']][] = $row['value'];
6309
+                }
6310
+            }
6311
+        }
6312
+        return $return;
6313 6313
     }
6314 6314
 
6315 6315
     /**
@@ -6318,18 +6318,18 @@  discard block
 block discarded – undo
6318 6318
      */
6319 6319
     public function count_student_in_course()
6320 6320
     {
6321
-    	global $nbStudents;
6322
-    	return $nbStudents;
6321
+        global $nbStudents;
6322
+        return $nbStudents;
6323 6323
     }
6324 6324
 
6325 6325
     public function sort_users($a, $b)
6326 6326
     {
6327
-    	return strcmp(trim(api_strtolower($a[$_SESSION['tracking_column']])), trim(api_strtolower($b[$_SESSION['tracking_column']])));
6327
+        return strcmp(trim(api_strtolower($a[$_SESSION['tracking_column']])), trim(api_strtolower($b[$_SESSION['tracking_column']])));
6328 6328
     }
6329 6329
 
6330 6330
     public function sort_users_desc($a, $b)
6331 6331
     {
6332
-    	return strcmp( trim(api_strtolower($b[$_SESSION['tracking_column']])), trim(api_strtolower($a[$_SESSION['tracking_column']])));
6332
+        return strcmp( trim(api_strtolower($b[$_SESSION['tracking_column']])), trim(api_strtolower($a[$_SESSION['tracking_column']])));
6333 6333
     }
6334 6334
 
6335 6335
     /**
@@ -6338,8 +6338,8 @@  discard block
 block discarded – undo
6338 6338
      */
6339 6339
     public static function get_number_of_users()
6340 6340
     {
6341
-    	global $user_ids;
6342
-    	return count($user_ids);
6341
+        global $user_ids;
6342
+        return count($user_ids);
6343 6343
     }
6344 6344
 
6345 6345
     /**
@@ -6355,37 +6355,37 @@  discard block
 block discarded – undo
6355 6355
     {
6356 6356
         global $user_ids, $course_code, $additional_user_profile_info, $export_csv, $is_western_name_order, $csv_content, $session_id;
6357 6357
 
6358
-    	$course_code = Database::escape_string($course_code);
6359
-    	$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
6360
-    	$tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
6358
+        $course_code = Database::escape_string($course_code);
6359
+        $tbl_user = Database::get_main_table(TABLE_MAIN_USER);
6360
+        $tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
6361 6361
 
6362
-    	$access_url_id = api_get_current_access_url_id();
6362
+        $access_url_id = api_get_current_access_url_id();
6363 6363
 
6364
-    	// get all users data from a course for sortable with limit
6365
-    	if (is_array($user_ids)) {
6366
-    		$user_ids = array_map('intval', $user_ids);
6367
-    		$condition_user = " WHERE user.user_id IN (".implode(',',$user_ids).") ";
6368
-    	} else {
6369
-    		$user_ids = intval($user_ids);
6370
-    		$condition_user = " WHERE user.user_id = $user_ids ";
6371
-    	}
6364
+        // get all users data from a course for sortable with limit
6365
+        if (is_array($user_ids)) {
6366
+            $user_ids = array_map('intval', $user_ids);
6367
+            $condition_user = " WHERE user.user_id IN (".implode(',',$user_ids).") ";
6368
+        } else {
6369
+            $user_ids = intval($user_ids);
6370
+            $condition_user = " WHERE user.user_id = $user_ids ";
6371
+        }
6372 6372
 
6373
-    	if (!empty($_GET['user_keyword'])) {
6374
-    		$keyword = trim(Database::escape_string($_GET['user_keyword']));
6375
-    		$condition_user .=  " AND (
6373
+        if (!empty($_GET['user_keyword'])) {
6374
+            $keyword = trim(Database::escape_string($_GET['user_keyword']));
6375
+            $condition_user .=  " AND (
6376 6376
                 user.firstname LIKE '%".$keyword."%' OR
6377 6377
                 user.lastname LIKE '%".$keyword."%'  OR
6378 6378
                 user.username LIKE '%".$keyword."%'  OR
6379 6379
                 user.email LIKE '%".$keyword."%'
6380 6380
              ) ";
6381
-    	}
6381
+        }
6382 6382
 
6383 6383
         $url_table = null;
6384 6384
         $url_condition = null;
6385
-    	if (api_is_multiple_url_enabled()) {
6386
-    		$url_table = ", ".$tbl_url_rel_user." as url_users";
6387
-    		$url_condition = " AND user.user_id = url_users.user_id AND access_url_id='$access_url_id'";
6388
-    	}
6385
+        if (api_is_multiple_url_enabled()) {
6386
+            $url_table = ", ".$tbl_url_rel_user." as url_users";
6387
+            $url_condition = " AND user.user_id = url_users.user_id AND access_url_id='$access_url_id'";
6388
+        }
6389 6389
 
6390 6390
         $invitedUsersCondition = '';
6391 6391
 
@@ -6393,7 +6393,7 @@  discard block
 block discarded – undo
6393 6393
             $invitedUsersCondition = " AND user.status != " . INVITEE;
6394 6394
         }
6395 6395
 
6396
-    	$sql = "SELECT  user.user_id as user_id,
6396
+        $sql = "SELECT  user.user_id as user_id,
6397 6397
                     user.official_code  as col0,
6398 6398
                     user.lastname       as col1,
6399 6399
                     user.firstname      as col2,
@@ -6401,17 +6401,17 @@  discard block
 block discarded – undo
6401 6401
                 FROM $tbl_user as user $url_table
6402 6402
     	        $condition_user $url_condition $invitedUsersCondition";
6403 6403
 
6404
-    	if (!in_array($direction, array('ASC','DESC'))) {
6405
-    		$direction = 'ASC';
6406
-    	}
6404
+        if (!in_array($direction, array('ASC','DESC'))) {
6405
+            $direction = 'ASC';
6406
+        }
6407 6407
 
6408
-    	$column = intval($column);
6408
+        $column = intval($column);
6409 6409
 
6410
-    	$from = intval($from);
6411
-    	$number_of_items = intval($number_of_items);
6410
+        $from = intval($from);
6411
+        $number_of_items = intval($number_of_items);
6412 6412
 
6413
-    	$sql .= " ORDER BY col$column $direction ";
6414
-    	$sql .= " LIMIT $from,$number_of_items";
6413
+        $sql .= " ORDER BY col$column $direction ";
6414
+        $sql .= " LIMIT $from,$number_of_items";
6415 6415
 
6416 6416
         $res = Database::query($sql);
6417 6417
         $users = array();
@@ -6445,7 +6445,7 @@  discard block
 block discarded – undo
6445 6445
             }
6446 6446
         }
6447 6447
 
6448
-    	while ($user = Database::fetch_array($res, 'ASSOC')) {
6448
+        while ($user = Database::fetch_array($res, 'ASSOC')) {
6449 6449
             $courseInfo = api_get_course_info($course_code);
6450 6450
             $courseId = $courseInfo['real_id'];
6451 6451
 
@@ -6476,10 +6476,10 @@  discard block
 block discarded – undo
6476 6476
                 $session_id
6477 6477
             );
6478 6478
 
6479
-    		if (empty($avg_student_progress)) {
6479
+            if (empty($avg_student_progress)) {
6480 6480
                 $avg_student_progress = 0;
6481
-    		}
6482
-    		$user['average_progress'] = $avg_student_progress.'%';
6481
+            }
6482
+            $user['average_progress'] = $avg_student_progress.'%';
6483 6483
 
6484 6484
             $total_user_exercise = Tracking::get_exercise_student_progress(
6485 6485
                 $total_exercises,
@@ -6499,11 +6499,11 @@  discard block
 block discarded – undo
6499 6499
 
6500 6500
             $user['exercise_average_best_attempt'] = $total_user_exercise;
6501 6501
 
6502
-    		if (is_numeric($avg_student_score)) {
6503
-    			$user['student_score']  = $avg_student_score.'%';
6504
-    		} else {
6505
-    			$user['student_score']  = $avg_student_score;
6506
-    		}
6502
+            if (is_numeric($avg_student_score)) {
6503
+                $user['student_score']  = $avg_student_score.'%';
6504
+            } else {
6505
+                $user['student_score']  = $avg_student_score;
6506
+            }
6507 6507
 
6508 6508
             $user['count_assignments'] = Tracking::count_student_assignments(
6509 6509
                 $user['user_id'],
@@ -6526,29 +6526,29 @@  discard block
 block discarded – undo
6526 6526
                 $session_id
6527 6527
             );
6528 6528
 
6529
-    		// we need to display an additional profile field
6530
-    		$user['additional'] = '';
6529
+            // we need to display an additional profile field
6530
+            $user['additional'] = '';
6531 6531
 
6532
-    		if (isset($_GET['additional_profile_field']) && is_numeric($_GET['additional_profile_field'])) {
6533
-    			if (isset($additional_user_profile_info[$user['user_id']]) &&
6532
+            if (isset($_GET['additional_profile_field']) && is_numeric($_GET['additional_profile_field'])) {
6533
+                if (isset($additional_user_profile_info[$user['user_id']]) &&
6534 6534
                     is_array($additional_user_profile_info[$user['user_id']])
6535 6535
                 ) {
6536
-    				$user['additional'] = implode(', ', $additional_user_profile_info[$user['user_id']]);
6537
-    			}
6538
-    		}
6536
+                    $user['additional'] = implode(', ', $additional_user_profile_info[$user['user_id']]);
6537
+                }
6538
+            }
6539 6539
 
6540 6540
             if (empty($session_id)) {
6541 6541
                 $user['survey'] = (isset($survey_user_list[$user['user_id']]) ? $survey_user_list[$user['user_id']] : 0) .' / '.$total_surveys;
6542 6542
             }
6543 6543
 
6544
-    		$user['link'] = '<center>
6544
+            $user['link'] = '<center>
6545 6545
                              <a href="../mySpace/myStudents.php?student='.$user['user_id'].'&details=true&course='.$course_code.'&origin=tracking_course&id_session='.$session_id.'">
6546 6546
     		                 '.Display::return_icon('2rightarrow.png').'
6547 6547
     		                 </a>
6548 6548
                          </center>';
6549 6549
 
6550
-    		// store columns in array $users
6551
-    		$is_western_name_order = api_is_western_name_order();
6550
+            // store columns in array $users
6551
+            $is_western_name_order = api_is_western_name_order();
6552 6552
             $user_row = array();
6553 6553
             $user_row[]= $user['official_code']; //0
6554 6554
             if ($is_western_name_order) {
@@ -6584,21 +6584,21 @@  discard block
 block discarded – undo
6584 6584
 
6585 6585
             $users[] = $user_row;
6586 6586
 
6587
-    		if ($export_csv) {
6588
-    		    if (empty($session_id)) {
6587
+            if ($export_csv) {
6588
+                if (empty($session_id)) {
6589 6589
                     $user_row = array_map('strip_tags', $user_row);
6590
-    			    unset($user_row[14]);
6591
-    			    unset($user_row[15]);
6590
+                    unset($user_row[14]);
6591
+                    unset($user_row[15]);
6592 6592
                 } else {
6593 6593
                     $user_row = array_map('strip_tags', $user_row);
6594 6594
                     unset($user_row[13]);
6595 6595
                     unset($user_row[14]);
6596 6596
                 }
6597 6597
 
6598
-    			$csv_content[] = $user_row;
6599
-    		}
6600
-    	}
6601
-    	return $users;
6598
+                $csv_content[] = $user_row;
6599
+            }
6600
+        }
6601
+        return $users;
6602 6602
     }
6603 6603
 }
6604 6604
 
@@ -6616,18 +6616,18 @@  discard block
 block discarded – undo
6616 6616
      */
6617 6617
     public function display_login_tracking_info($view, $user_id, $course_id, $session_id = 0)
6618 6618
     {
6619
-    	$MonthsLong = $GLOBALS['MonthsLong'];
6620
-
6621
-    	// protected data
6622
-    	$user_id = intval($user_id);
6623
-    	$session_id = intval($session_id);
6624
-    	$course_id = Database::escape_string($course_id);
6625
-
6626
-    	$track_access_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
6627
-    	$tempView = $view;
6628
-    	if(substr($view,0,1) == '1') {
6629
-    		$new_view = substr_replace($view,'0',0,1);
6630
-    		echo "
6619
+        $MonthsLong = $GLOBALS['MonthsLong'];
6620
+
6621
+        // protected data
6622
+        $user_id = intval($user_id);
6623
+        $session_id = intval($session_id);
6624
+        $course_id = Database::escape_string($course_id);
6625
+
6626
+        $track_access_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
6627
+        $tempView = $view;
6628
+        if(substr($view,0,1) == '1') {
6629
+            $new_view = substr_replace($view,'0',0,1);
6630
+            echo "
6631 6631
                 <tr>
6632 6632
                     <td valign='top'>
6633 6633
                     <font color='#0000FF'>-&nbsp;&nbsp;&nbsp;</font>" .
@@ -6635,9 +6635,9 @@  discard block
 block discarded – undo
6635 6635
                     </td>
6636 6636
                 </tr>
6637 6637
                 ";
6638
-    		echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('LoginsDetails')."<br>";
6638
+            echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('LoginsDetails')."<br>";
6639 6639
 
6640
-    		$sql = "SELECT UNIX_TIMESTAMP(access_date), count(access_date)
6640
+            $sql = "SELECT UNIX_TIMESTAMP(access_date), count(access_date)
6641 6641
                         FROM $track_access_table
6642 6642
                         WHERE access_user_id = $user_id
6643 6643
                         AND c_id = $course_id
@@ -6645,11 +6645,11 @@  discard block
 block discarded – undo
6645 6645
                         GROUP BY YEAR(access_date),MONTH(access_date)
6646 6646
                         ORDER BY YEAR(access_date),MONTH(access_date) ASC";
6647 6647
 
6648
-    		echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6649
-    		$results = getManyResults3Col($sql);
6648
+            echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6649
+            $results = getManyResults3Col($sql);
6650 6650
 
6651
-    		echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
6652
-    		echo "<tr>
6651
+            echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
6652
+            echo "<tr>
6653 6653
                     <td class='secLine'>
6654 6654
                     ".get_lang('LoginsTitleMonthColumn')."
6655 6655
                     </td>
@@ -6657,36 +6657,36 @@  discard block
 block discarded – undo
6657 6657
                     ".get_lang('LoginsTitleCountColumn')."
6658 6658
                     </td>
6659 6659
                 </tr>";
6660
-    		$total = 0;
6661
-    		if (is_array($results)) {
6662
-    			for($j = 0 ; $j < count($results) ; $j++) {
6663
-    				echo "<tr>";
6664
-    				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>";
6665
-    				echo "<td valign='top' align='right' class='content'>".$results[$j][1]."</td>";
6666
-    				echo"</tr>";
6667
-    				$total = $total + $results[$j][1];
6668
-    			}
6669
-    			echo "<tr>";
6670
-    			echo "<td>".get_lang('Total')."</td>";
6671
-    			echo "<td align='right' class='content'>".$total."</td>";
6672
-    			echo"</tr>";
6673
-    		} else {
6674
-    			echo "<tr>";
6675
-    			echo "<td colspan='2'><center>".get_lang('NoResult')."</center></td>";
6676
-    			echo"</tr>";
6677
-    		}
6678
-    		echo "</table>";
6679
-    		echo "</td></tr>";
6680
-    	} else {
6681
-    		$new_view = substr_replace($view,'1',0,1);
6682
-    		echo "
6660
+            $total = 0;
6661
+            if (is_array($results)) {
6662
+                for($j = 0 ; $j < count($results) ; $j++) {
6663
+                    echo "<tr>";
6664
+                    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>";
6665
+                    echo "<td valign='top' align='right' class='content'>".$results[$j][1]."</td>";
6666
+                    echo"</tr>";
6667
+                    $total = $total + $results[$j][1];
6668
+                }
6669
+                echo "<tr>";
6670
+                echo "<td>".get_lang('Total')."</td>";
6671
+                echo "<td align='right' class='content'>".$total."</td>";
6672
+                echo"</tr>";
6673
+            } else {
6674
+                echo "<tr>";
6675
+                echo "<td colspan='2'><center>".get_lang('NoResult')."</center></td>";
6676
+                echo"</tr>";
6677
+            }
6678
+            echo "</table>";
6679
+            echo "</td></tr>";
6680
+        } else {
6681
+            $new_view = substr_replace($view,'1',0,1);
6682
+            echo "
6683 6683
                 <tr>
6684 6684
                     <td valign='top'>
6685 6685
                     +<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>
6686 6686
                     </td>
6687 6687
                 </tr>
6688 6688
             ";
6689
-    	}
6689
+        }
6690 6690
     }
6691 6691
 
6692 6692
     /**
@@ -6699,38 +6699,38 @@  discard block
 block discarded – undo
6699 6699
      */
6700 6700
     public function display_exercise_tracking_info($view, $user_id, $courseCode)
6701 6701
     {
6702
-    	global $TBL_TRACK_HOTPOTATOES, $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $dateTimeFormatLong;
6702
+        global $TBL_TRACK_HOTPOTATOES, $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $dateTimeFormatLong;
6703 6703
         $courseId = api_get_course_int_id($courseCode);
6704
-    	if(substr($view,1,1) == '1') {
6705
-    		$new_view = substr_replace($view,'0',1,1);
6706
-    		echo "<tr>
6704
+        if(substr($view,1,1) == '1') {
6705
+            $new_view = substr_replace($view,'0',1,1);
6706
+            echo "<tr>
6707 6707
                     <td valign='top'>
6708 6708
                         <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>]
6709 6709
                     </td>
6710 6710
                 </tr>";
6711
-    		echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('ExercicesDetails')."<br />";
6711
+            echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('ExercicesDetails')."<br />";
6712 6712
 
6713
-    		$sql = "SELECT ce.title, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
6713
+            $sql = "SELECT ce.title, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
6714 6714
                     FROM $TABLECOURSE_EXERCICES AS ce , $TABLETRACK_EXERCICES AS te
6715 6715
                     WHERE te.c_id = $courseId
6716 6716
                         AND te.exe_user_id = ".intval($user_id)."
6717 6717
                         AND te.exe_exo_id = ce.id
6718 6718
                     ORDER BY ce.title ASC, te.exe_date ASC";
6719 6719
 
6720
-    		$hpsql = "SELECT te.exe_name, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
6720
+            $hpsql = "SELECT te.exe_name, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
6721 6721
                         FROM $TBL_TRACK_HOTPOTATOES AS te
6722 6722
                         WHERE te.exe_user_id = '".intval($user_id)."' AND te.c_id = $courseId
6723 6723
                         ORDER BY te.c_id ASC, te.exe_date ASC";
6724 6724
 
6725
-    		$hpresults = StatsUtils::getManyResultsXCol($hpsql, 4);
6725
+            $hpresults = StatsUtils::getManyResultsXCol($hpsql, 4);
6726 6726
 
6727
-    		$NoTestRes = 0;
6728
-    		$NoHPTestRes = 0;
6727
+            $NoTestRes = 0;
6728
+            $NoHPTestRes = 0;
6729 6729
 
6730
-    		echo "<tr>\n<td style='padding-left : 40px;padding-right : 40px;'>\n";
6731
-    		$results = StatsUtils::getManyResultsXCol($sql, 4);
6732
-    		echo "<table cellpadding='2' cellspacing='1' border='0' align='center'>\n";
6733
-    		echo "
6730
+            echo "<tr>\n<td style='padding-left : 40px;padding-right : 40px;'>\n";
6731
+            $results = StatsUtils::getManyResultsXCol($sql, 4);
6732
+            echo "<table cellpadding='2' cellspacing='1' border='0' align='center'>\n";
6733
+            echo "
6734 6734
                 <tr bgcolor='#E6E6E6'>
6735 6735
                     <td>
6736 6736
                     ".get_lang('ExercicesTitleExerciceColumn')."
@@ -6743,28 +6743,28 @@  discard block
 block discarded – undo
6743 6743
                     </td>
6744 6744
                 </tr>";
6745 6745
 
6746
-    		if (is_array($results)) {
6747
-    			for($i = 0; $i < sizeof($results); $i++) {
6748
-    				$display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get());
6749
-    				echo "<tr>\n";
6750
-    				echo "<td class='content'>".$results[$i][0]."</td>\n";
6751
-    				echo "<td class='content'>".$display_date."</td>\n";
6752
-    				echo "<td valign='top' align='right' class='content'>".$results[$i][1]." / ".$results[$i][2]."</td>\n";
6753
-    				echo "</tr>\n";
6754
-    			}
6755
-    		} else {
6756
-    			// istvan begin
6757
-    			$NoTestRes = 1;
6758
-    		}
6759
-
6760
-    		// The Result of Tests
6761
-    		if (is_array($hpresults)) {
6762
-    			for($i = 0; $i < sizeof($hpresults); $i++) {
6763
-    				$title = GetQuizName($hpresults[$i][0],'');
6764
-    				if ($title == '')
6765
-    				$title = basename($hpresults[$i][0]);
6766
-    				$display_date = api_convert_and_format_date($hpresults[$i][3], null, date_default_timezone_get());
6767
-    				?>
6746
+            if (is_array($results)) {
6747
+                for($i = 0; $i < sizeof($results); $i++) {
6748
+                    $display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get());
6749
+                    echo "<tr>\n";
6750
+                    echo "<td class='content'>".$results[$i][0]."</td>\n";
6751
+                    echo "<td class='content'>".$display_date."</td>\n";
6752
+                    echo "<td valign='top' align='right' class='content'>".$results[$i][1]." / ".$results[$i][2]."</td>\n";
6753
+                    echo "</tr>\n";
6754
+                }
6755
+            } else {
6756
+                // istvan begin
6757
+                $NoTestRes = 1;
6758
+            }
6759
+
6760
+            // The Result of Tests
6761
+            if (is_array($hpresults)) {
6762
+                for($i = 0; $i < sizeof($hpresults); $i++) {
6763
+                    $title = GetQuizName($hpresults[$i][0],'');
6764
+                    if ($title == '')
6765
+                    $title = basename($hpresults[$i][0]);
6766
+                    $display_date = api_convert_and_format_date($hpresults[$i][3], null, date_default_timezone_get());
6767
+                    ?>
6768 6768
                     <tr>
6769 6769
                         <td class="content"><?php echo $title; ?></td>
6770 6770
                         <td class="content" align="center"><?php echo $display_date; ?></td>
@@ -6774,26 +6774,26 @@  discard block
 block discarded – undo
6774 6774
 
6775 6775
                     <?php
6776 6776
                 }
6777
-    		} else {
6778
-    			$NoHPTestRes = 1;
6779
-    		}
6780
-
6781
-    		if ($NoTestRes == 1 && $NoHPTestRes == 1) {
6782
-    			echo "<tr>\n";
6783
-    			echo "<td colspan='3'><center>".get_lang('NoResult')."</center></td>\n";
6784
-    			echo "</tr>\n";
6785
-    		}
6786
-    		echo "</table>";
6787
-    		echo "</td>\n</tr>\n";
6788
-    	} else {
6789
-    		$new_view = substr_replace($view,'1',1,1);
6790
-    		echo "
6777
+            } else {
6778
+                $NoHPTestRes = 1;
6779
+            }
6780
+
6781
+            if ($NoTestRes == 1 && $NoHPTestRes == 1) {
6782
+                echo "<tr>\n";
6783
+                echo "<td colspan='3'><center>".get_lang('NoResult')."</center></td>\n";
6784
+                echo "</tr>\n";
6785
+            }
6786
+            echo "</table>";
6787
+            echo "</td>\n</tr>\n";
6788
+        } else {
6789
+            $new_view = substr_replace($view,'1',1,1);
6790
+            echo "
6791 6791
                 <tr>
6792 6792
                     <td valign='top'>
6793 6793
                         +<font color='#0000FF'>&nbsp;&nbsp;</font><a href='".api_get_self()."?uInfo=$user_id&view=".$new_view."' class='specialLink'>".get_lang('ExercicesResults')."</a>
6794 6794
                     </td>
6795 6795
                 </tr>";
6796
-    	}
6796
+        }
6797 6797
     }
6798 6798
 
6799 6799
     /**
@@ -6802,27 +6802,27 @@  discard block
 block discarded – undo
6802 6802
      */
6803 6803
     public function display_student_publications_tracking_info($view, $user_id, $course_id)
6804 6804
     {
6805
-    	global $TABLETRACK_UPLOADS, $TABLECOURSE_WORK;
6805
+        global $TABLETRACK_UPLOADS, $TABLECOURSE_WORK;
6806 6806
         $_course = api_get_course_info_by_id($course_id);
6807 6807
 
6808
-    	if (substr($view,2,1) == '1') {
6809
-    		$new_view = substr_replace($view,'0',2,1);
6810
-    		echo "<tr>
6808
+        if (substr($view,2,1) == '1') {
6809
+            $new_view = substr_replace($view,'0',2,1);
6810
+            echo "<tr>
6811 6811
                     <td valign='top'>
6812 6812
                     <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>]
6813 6813
                     </td>
6814 6814
                 </tr>";
6815
-    		echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('WorksDetails')."<br>";
6816
-    		$sql = "SELECT u.upload_date, w.title, w.author,w.url
6815
+            echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('WorksDetails')."<br>";
6816
+            $sql = "SELECT u.upload_date, w.title, w.author,w.url
6817 6817
                     FROM $TABLETRACK_UPLOADS u , $TABLECOURSE_WORK w
6818 6818
                     WHERE u.upload_work_id = w.id
6819 6819
                         AND u.upload_user_id = '".intval($user_id)."'
6820 6820
                         AND u.c_id = '".intval($course_id)."'
6821 6821
                     ORDER BY u.upload_date DESC";
6822
-    		echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6823
-    		$results = StatsUtils::getManyResultsXCol($sql,4);
6824
-    		echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
6825
-    		echo "<tr>
6822
+            echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6823
+            $results = StatsUtils::getManyResultsXCol($sql,4);
6824
+            echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
6825
+            echo "<tr>
6826 6826
                     <td class='secLine' width='40%'>
6827 6827
                     ".get_lang('WorkTitle')."
6828 6828
                     </td>
@@ -6833,35 +6833,35 @@  discard block
 block discarded – undo
6833 6833
                     ".get_lang('Date')."
6834 6834
                     </td>
6835 6835
                 </tr>";
6836
-    		if (is_array($results)) {
6837
-    			for($j = 0 ; $j < count($results) ; $j++) {
6838
-    				$pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3];
6839
-    				$beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get());
6840
-    				echo "<tr>";
6841
-    				echo "<td class='content'>"
6842
-    				."<a href ='".$pathToFile."'>".$results[$j][1]."</a>"
6843
-    				."</td>";
6844
-    				echo "<td class='content'>".$results[$j][2]."</td>";
6845
-    				echo "<td class='content'>".$beautifulDate."</td>";
6846
-    				echo"</tr>";
6847
-    			}
6848
-    		} else {
6849
-    			echo "<tr>";
6850
-    			echo "<td colspan='3'><center>".get_lang('NoResult')."</center></td>";
6851
-    			echo"</tr>";
6852
-    		}
6853
-    		echo "</table>";
6854
-    		echo "</td></tr>";
6855
-    	} else {
6856
-    		$new_view = substr_replace($view,'1',2,1);
6857
-    		echo "
6836
+            if (is_array($results)) {
6837
+                for($j = 0 ; $j < count($results) ; $j++) {
6838
+                    $pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3];
6839
+                    $beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get());
6840
+                    echo "<tr>";
6841
+                    echo "<td class='content'>"
6842
+                    ."<a href ='".$pathToFile."'>".$results[$j][1]."</a>"
6843
+                    ."</td>";
6844
+                    echo "<td class='content'>".$results[$j][2]."</td>";
6845
+                    echo "<td class='content'>".$beautifulDate."</td>";
6846
+                    echo"</tr>";
6847
+                }
6848
+            } else {
6849
+                echo "<tr>";
6850
+                echo "<td colspan='3'><center>".get_lang('NoResult')."</center></td>";
6851
+                echo"</tr>";
6852
+            }
6853
+            echo "</table>";
6854
+            echo "</td></tr>";
6855
+        } else {
6856
+            $new_view = substr_replace($view,'1',2,1);
6857
+            echo "
6858 6858
                 <tr>
6859 6859
                     <td valign='top'>
6860 6860
                     +<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>
6861 6861
                     </td>
6862 6862
                 </tr>
6863 6863
             ";
6864
-    	}
6864
+        }
6865 6865
     }
6866 6866
 
6867 6867
     /**
@@ -6870,55 +6870,55 @@  discard block
 block discarded – undo
6870 6870
      */
6871 6871
     public function display_links_tracking_info($view, $user_id, $courseCode)
6872 6872
     {
6873
-    	global $TABLETRACK_LINKS, $TABLECOURSE_LINKS;
6873
+        global $TABLETRACK_LINKS, $TABLECOURSE_LINKS;
6874 6874
         $courseId = api_get_course_int_id($courseCode);
6875
-    	if (substr($view,3,1) == '1') {
6876
-    		$new_view = substr_replace($view,'0',3,1);
6877
-    		echo "
6875
+        if (substr($view,3,1) == '1') {
6876
+            $new_view = substr_replace($view,'0',3,1);
6877
+            echo "
6878 6878
                 <tr>
6879 6879
                         <td valign='top'>
6880 6880
                         <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>]
6881 6881
                         </td>
6882 6882
                 </tr>
6883 6883
             ";
6884
-    		echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('LinksDetails')."<br>";
6885
-    		$sql = "SELECT cl.title, cl.url
6884
+            echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('LinksDetails')."<br>";
6885
+            $sql = "SELECT cl.title, cl.url
6886 6886
                     FROM $TABLETRACK_LINKS AS sl, $TABLECOURSE_LINKS AS cl
6887 6887
                     WHERE sl.links_link_id = cl.id
6888 6888
                         AND sl.c_id = $courseId
6889 6889
                         AND sl.links_user_id = ".intval($user_id)."
6890 6890
                     GROUP BY cl.title, cl.url";
6891
-    		echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6892
-    		$results = StatsUtils::getManyResults2Col($sql);
6893
-    		echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
6894
-    		echo "<tr>
6891
+            echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6892
+            $results = StatsUtils::getManyResults2Col($sql);
6893
+            echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
6894
+            echo "<tr>
6895 6895
                     <td class='secLine'>
6896 6896
                     ".get_lang('LinksTitleLinkColumn')."
6897 6897
                     </td>
6898 6898
                 </tr>";
6899
-    		if (is_array($results)) {
6900
-    			for($j = 0 ; $j < count($results) ; $j++) {
6901
-    				echo "<tr>";
6902
-    				echo "<td class='content'><a href='".$results[$j][1]."'>".$results[$j][0]."</a></td>";
6903
-    				echo"</tr>";
6904
-    			}
6905
-    		} else {
6906
-    			echo "<tr>";
6907
-    			echo "<td ><center>".get_lang('NoResult')."</center></td>";
6908
-    			echo"</tr>";
6909
-    		}
6910
-    		echo "</table>";
6911
-    		echo "</td></tr>";
6912
-    	} else {
6913
-    		$new_view = substr_replace($view,'1',3,1);
6914
-    		echo "
6899
+            if (is_array($results)) {
6900
+                for($j = 0 ; $j < count($results) ; $j++) {
6901
+                    echo "<tr>";
6902
+                    echo "<td class='content'><a href='".$results[$j][1]."'>".$results[$j][0]."</a></td>";
6903
+                    echo"</tr>";
6904
+                }
6905
+            } else {
6906
+                echo "<tr>";
6907
+                echo "<td ><center>".get_lang('NoResult')."</center></td>";
6908
+                echo"</tr>";
6909
+            }
6910
+            echo "</table>";
6911
+            echo "</td></tr>";
6912
+        } else {
6913
+            $new_view = substr_replace($view,'1',3,1);
6914
+            echo "
6915 6915
                 <tr>
6916 6916
                     <td valign='top'>
6917 6917
                     +<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>
6918 6918
                     </td>
6919 6919
                 </tr>
6920 6920
             ";
6921
-    	}
6921
+        }
6922 6922
     }
6923 6923
 
6924 6924
     /**
@@ -6931,61 +6931,61 @@  discard block
 block discarded – undo
6931 6931
      */
6932 6932
     public static function display_document_tracking_info($view, $user_id, $course_code, $session_id = 0)
6933 6933
     {
6934
-    	// protect data
6934
+        // protect data
6935 6935
         $user_id = intval($user_id);
6936 6936
         $courseId = api_get_course_int_id($course_code);
6937
-    	$session_id = intval($session_id);
6937
+        $session_id = intval($session_id);
6938 6938
 
6939
-    	$downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
6940
-    	if(substr($view,4,1) == '1') {
6941
-    		$new_view = substr_replace($view,'0',4,1);
6942
-    		echo "
6939
+        $downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
6940
+        if(substr($view,4,1) == '1') {
6941
+            $new_view = substr_replace($view,'0',4,1);
6942
+            echo "
6943 6943
                 <tr>
6944 6944
                     <td valign='top'>
6945 6945
                     <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>]
6946 6946
                     </td>
6947 6947
                 </tr>
6948 6948
             ";
6949
-    		echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('DocumentsDetails')."<br>";
6949
+            echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('DocumentsDetails')."<br>";
6950 6950
 
6951
-    		$sql = "SELECT down_doc_path
6951
+            $sql = "SELECT down_doc_path
6952 6952
                     FROM $downloads_table
6953 6953
                     WHERE c_id = $courseId
6954 6954
                         AND down_user_id = $user_id
6955 6955
                         AND down_session_id = $session_id
6956 6956
                     GROUP BY down_doc_path";
6957 6957
 
6958
-    		echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6959
-    		$results = StatsUtils::getManyResults1Col($sql);
6960
-    		echo "<table cellpadding='2' cellspacing='1' border='0' align='center'>";
6961
-    		echo "<tr>
6958
+            echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6959
+            $results = StatsUtils::getManyResults1Col($sql);
6960
+            echo "<table cellpadding='2' cellspacing='1' border='0' align='center'>";
6961
+            echo "<tr>
6962 6962
                     <td class='secLine'>
6963 6963
                     ".get_lang('DocumentsTitleDocumentColumn')."
6964 6964
                     </td>
6965 6965
                 </tr>";
6966
-    		if (is_array($results)) {
6967
-    			for($j = 0 ; $j < count($results) ; $j++) {
6968
-    				echo "<tr>";
6969
-    				echo "<td class='content'>".$results[$j]."</td>";
6970
-    				echo"</tr>";
6971
-    			}
6972
-    		} else {
6973
-    			echo "<tr>";
6974
-    			echo "<td><center>".get_lang('NoResult')."</center></td>";
6975
-    			echo"</tr>";
6976
-    		}
6977
-    		echo "</table>";
6978
-    		echo "</td></tr>";
6979
-    	} else {
6980
-    		$new_view = substr_replace($view,'1',4,1);
6981
-    		echo "
6966
+            if (is_array($results)) {
6967
+                for($j = 0 ; $j < count($results) ; $j++) {
6968
+                    echo "<tr>";
6969
+                    echo "<td class='content'>".$results[$j]."</td>";
6970
+                    echo"</tr>";
6971
+                }
6972
+            } else {
6973
+                echo "<tr>";
6974
+                echo "<td><center>".get_lang('NoResult')."</center></td>";
6975
+                echo"</tr>";
6976
+            }
6977
+            echo "</table>";
6978
+            echo "</td></tr>";
6979
+        } else {
6980
+            $new_view = substr_replace($view,'1',4,1);
6981
+            echo "
6982 6982
                 <tr>
6983 6983
                     <td valign='top'>
6984 6984
                     +<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>
6985 6985
                     </td>
6986 6986
                 </tr>
6987 6987
             ";
6988
-    	}
6988
+        }
6989 6989
     }
6990 6990
 
6991 6991
     /**
@@ -7042,43 +7042,43 @@  discard block
 block discarded – undo
7042 7042
      */
7043 7043
     public function display_login_tracking_info($view, $user_id, $course_id, $session_id = 0)
7044 7044
     {
7045
-    	$MonthsLong = $GLOBALS['MonthsLong'];
7046
-    	$track_access_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
7047
-
7048
-    	// protected data
7049
-    	$user_id    = intval($user_id);
7050
-    	$session_id = intval($session_id);
7051
-    	$course_id  = intval($course_id);
7052
-
7053
-    	$tempView = $view;
7054
-    	if (substr($view,0,1) == '1') {
7055
-    		$new_view = substr_replace($view,'0',0,1);
7056
-    		$title[1]= get_lang('LoginsAndAccessTools').get_lang('LoginsDetails');
7057
-    		$sql = "SELECT UNIX_TIMESTAMP(access_date), count(access_date)
7045
+        $MonthsLong = $GLOBALS['MonthsLong'];
7046
+        $track_access_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
7047
+
7048
+        // protected data
7049
+        $user_id    = intval($user_id);
7050
+        $session_id = intval($session_id);
7051
+        $course_id  = intval($course_id);
7052
+
7053
+        $tempView = $view;
7054
+        if (substr($view,0,1) == '1') {
7055
+            $new_view = substr_replace($view,'0',0,1);
7056
+            $title[1]= get_lang('LoginsAndAccessTools').get_lang('LoginsDetails');
7057
+            $sql = "SELECT UNIX_TIMESTAMP(access_date), count(access_date)
7058 7058
                     FROM $track_access_table
7059 7059
                     WHERE access_user_id = $user_id
7060 7060
                     AND c_id = $course_id
7061 7061
                     AND access_session_id = $session_id
7062 7062
                     GROUP BY YEAR(access_date),MONTH(access_date)
7063 7063
                     ORDER BY YEAR(access_date),MONTH(access_date) ASC";
7064
-    		//$results = getManyResults2Col($sql);
7065
-    		$results = getManyResults3Col($sql);
7066
-    		$title_line= get_lang('LoginsTitleMonthColumn').';'.get_lang('LoginsTitleCountColumn')."\n";
7067
-    		$line='';
7068
-    		$total = 0;
7069
-    		if (is_array($results)) {
7070
-    			for($j = 0 ; $j < count($results) ; $j++) {
7071
-    				$line .= $results[$j][0].';'.$results[$j][1]."\n";
7072
-    				$total = $total + $results[$j][1];
7073
-    			}
7074
-    			$line .= get_lang('Total').";".$total."\n";
7075
-    		} else {
7076
-    			$line= get_lang('NoResult')."</center></td>";
7077
-    		}
7078
-    	} else {
7079
-    		$new_view = substr_replace($view,'1',0,1);
7080
-    	}
7081
-    	return array($title_line, $line);
7064
+            //$results = getManyResults2Col($sql);
7065
+            $results = getManyResults3Col($sql);
7066
+            $title_line= get_lang('LoginsTitleMonthColumn').';'.get_lang('LoginsTitleCountColumn')."\n";
7067
+            $line='';
7068
+            $total = 0;
7069
+            if (is_array($results)) {
7070
+                for($j = 0 ; $j < count($results) ; $j++) {
7071
+                    $line .= $results[$j][0].';'.$results[$j][1]."\n";
7072
+                    $total = $total + $results[$j][1];
7073
+                }
7074
+                $line .= get_lang('Total').";".$total."\n";
7075
+            } else {
7076
+                $line= get_lang('NoResult')."</center></td>";
7077
+            }
7078
+        } else {
7079
+            $new_view = substr_replace($view,'1',0,1);
7080
+        }
7081
+        return array($title_line, $line);
7082 7082
     }
7083 7083
 
7084 7084
     /**
@@ -7091,67 +7091,67 @@  discard block
 block discarded – undo
7091 7091
      */
7092 7092
     public function display_exercise_tracking_info($view, $userId, $courseCode)
7093 7093
     {
7094
-    	global $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $TABLETRACK_HOTPOTATOES, $dateTimeFormatLong;
7094
+        global $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $TABLETRACK_HOTPOTATOES, $dateTimeFormatLong;
7095 7095
         $courseId = api_get_course_int_id($courseCode);
7096 7096
         $userId = intval($userId);
7097
-    	if (substr($view,1,1) == '1') {
7098
-    		$new_view = substr_replace($view,'0',1,1);
7099
-    		$title[1] = get_lang('ExercicesDetails');
7100
-    		$line = '';
7101
-    		$sql = "SELECT ce.title, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
7097
+        if (substr($view,1,1) == '1') {
7098
+            $new_view = substr_replace($view,'0',1,1);
7099
+            $title[1] = get_lang('ExercicesDetails');
7100
+            $line = '';
7101
+            $sql = "SELECT ce.title, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
7102 7102
                     FROM $TABLECOURSE_EXERCICES AS ce , $TABLETRACK_EXERCICES AS te
7103 7103
                     WHERE te.c_id = $courseId
7104 7104
                         AND te.exe_user_id = $userId
7105 7105
                         AND te.exe_exo_id = ce.id
7106 7106
                     ORDER BY ce.title ASC, te.exe_date ASC";
7107 7107
 
7108
-    		$hpsql = "SELECT te.exe_name, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
7108
+            $hpsql = "SELECT te.exe_name, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
7109 7109
                         FROM $TABLETRACK_HOTPOTATOES AS te
7110 7110
                         WHERE te.exe_user_id = '$userId' AND te.c_id = $courseId
7111 7111
                         ORDER BY te.c_id ASC, te.exe_date ASC";
7112 7112
 
7113
-    		$hpresults = StatsUtils::getManyResultsXCol($hpsql, 4);
7113
+            $hpresults = StatsUtils::getManyResultsXCol($hpsql, 4);
7114 7114
 
7115
-    		$NoTestRes = 0;
7116
-    		$NoHPTestRes = 0;
7115
+            $NoTestRes = 0;
7116
+            $NoHPTestRes = 0;
7117 7117
 
7118
-    		$results = StatsUtils::getManyResultsXCol($sql, 4);
7119
-    		$title_line = get_lang('ExercicesTitleExerciceColumn').";".get_lang('Date').';'.get_lang('ExercicesTitleScoreColumn')."\n";
7118
+            $results = StatsUtils::getManyResultsXCol($sql, 4);
7119
+            $title_line = get_lang('ExercicesTitleExerciceColumn').";".get_lang('Date').';'.get_lang('ExercicesTitleScoreColumn')."\n";
7120 7120
 
7121
-    		if (is_array($results)) {
7122
-    			for($i = 0; $i < sizeof($results); $i++)
7123
-    			{
7124
-    				$display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get());
7125
-    				$line .= $results[$i][0].";".$display_date.";".$results[$i][1]." / ".$results[$i][2]."\n";
7126
-    			}
7127
-    		} else {
7121
+            if (is_array($results)) {
7122
+                for($i = 0; $i < sizeof($results); $i++)
7123
+                {
7124
+                    $display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get());
7125
+                    $line .= $results[$i][0].";".$display_date.";".$results[$i][1]." / ".$results[$i][2]."\n";
7126
+                }
7127
+            } else {
7128 7128
                 // istvan begin
7129
-    			$NoTestRes = 1;
7130
-    		}
7131
-
7132
-    		// The Result of Tests
7133
-    		if (is_array($hpresults)) {
7134
-    			for($i = 0; $i < sizeof($hpresults); $i++) {
7135
-    				$title = GetQuizName($hpresults[$i][0],'');
7136
-
7137
-    				if ($title == '')
7138
-    				$title = basename($hpresults[$i][0]);
7139
-
7140
-    				$display_date = api_convert_and_format_date($hpresults[$i][3], null, date_default_timezone_get());
7141
-
7142
-    				$line .= $title.';'.$display_date.';'.$hpresults[$i][1].'/'.$hpresults[$i][2]."\n";
7143
-    			}
7144
-    		} else {
7145
-    			$NoHPTestRes = 1;
7146
-    		}
7147
-
7148
-    		if ($NoTestRes == 1 && $NoHPTestRes == 1) {
7149
-    			$line=get_lang('NoResult');
7150
-    		}
7151
-    	} else {
7152
-    		$new_view = substr_replace($view,'1',1,1);
7153
-    	}
7154
-    	return array($title_line, $line);
7129
+                $NoTestRes = 1;
7130
+            }
7131
+
7132
+            // The Result of Tests
7133
+            if (is_array($hpresults)) {
7134
+                for($i = 0; $i < sizeof($hpresults); $i++) {
7135
+                    $title = GetQuizName($hpresults[$i][0],'');
7136
+
7137
+                    if ($title == '')
7138
+                    $title = basename($hpresults[$i][0]);
7139
+
7140
+                    $display_date = api_convert_and_format_date($hpresults[$i][3], null, date_default_timezone_get());
7141
+
7142
+                    $line .= $title.';'.$display_date.';'.$hpresults[$i][1].'/'.$hpresults[$i][2]."\n";
7143
+                }
7144
+            } else {
7145
+                $NoHPTestRes = 1;
7146
+            }
7147
+
7148
+            if ($NoTestRes == 1 && $NoHPTestRes == 1) {
7149
+                $line=get_lang('NoResult');
7150
+            }
7151
+        } else {
7152
+            $new_view = substr_replace($view,'1',1,1);
7153
+        }
7154
+        return array($title_line, $line);
7155 7155
     }
7156 7156
 
7157 7157
     /**
@@ -7160,37 +7160,37 @@  discard block
 block discarded – undo
7160 7160
      */
7161 7161
     public function display_student_publications_tracking_info($view, $user_id, $course_id)
7162 7162
     {
7163
-    	global $TABLETRACK_UPLOADS, $TABLECOURSE_WORK;
7163
+        global $TABLETRACK_UPLOADS, $TABLECOURSE_WORK;
7164 7164
         $_course = api_get_course_info();
7165 7165
         $user_id = intval($user_id);
7166 7166
         $course_id = intval($course_id);
7167 7167
 
7168
-    	if (substr($view,2,1) == '1') {
7169
-    		$sql = "SELECT u.upload_date, w.title, w.author, w.url
7168
+        if (substr($view,2,1) == '1') {
7169
+            $sql = "SELECT u.upload_date, w.title, w.author, w.url
7170 7170
                     FROM $TABLETRACK_UPLOADS u , $TABLECOURSE_WORK w
7171 7171
                     WHERE
7172 7172
                         u.upload_work_id = w.id AND
7173 7173
                         u.upload_user_id = '$user_id' AND
7174 7174
                         u.c_id = '$course_id'
7175 7175
                     ORDER BY u.upload_date DESC";
7176
-    		$results = StatsUtils::getManyResultsXCol($sql,4);
7177
-
7178
-    		$title[1]=get_lang('WorksDetails');
7179
-    		$line='';
7180
-    		$title_line=get_lang('WorkTitle').";".get_lang('WorkAuthors').";".get_lang('Date')."\n";
7181
-
7182
-    		if (is_array($results)) {
7183
-    			for($j = 0 ; $j < count($results) ; $j++) {
7184
-    				$pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3];
7185
-    				$beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get());
7186
-    				$line .= $results[$j][1].";".$results[$j][2].";".$beautifulDate."\n";
7187
-    			}
7188
-
7189
-    		} else {
7190
-    			$line= get_lang('NoResult');
7191
-    		}
7192
-    	}
7193
-    	return array($title_line, $line);
7176
+            $results = StatsUtils::getManyResultsXCol($sql,4);
7177
+
7178
+            $title[1]=get_lang('WorksDetails');
7179
+            $line='';
7180
+            $title_line=get_lang('WorkTitle').";".get_lang('WorkAuthors').";".get_lang('Date')."\n";
7181
+
7182
+            if (is_array($results)) {
7183
+                for($j = 0 ; $j < count($results) ; $j++) {
7184
+                    $pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3];
7185
+                    $beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get());
7186
+                    $line .= $results[$j][1].";".$results[$j][2].";".$beautifulDate."\n";
7187
+                }
7188
+
7189
+            } else {
7190
+                $line= get_lang('NoResult');
7191
+            }
7192
+        }
7193
+        return array($title_line, $line);
7194 7194
     }
7195 7195
 
7196 7196
     /**
@@ -7199,32 +7199,32 @@  discard block
 block discarded – undo
7199 7199
      */
7200 7200
     public function display_links_tracking_info($view, $userId, $courseCode)
7201 7201
     {
7202
-    	global $TABLETRACK_LINKS, $TABLECOURSE_LINKS;
7202
+        global $TABLETRACK_LINKS, $TABLECOURSE_LINKS;
7203 7203
         $courseId = api_get_course_int_id($courseCode);
7204 7204
         $userId = intval($userId);
7205 7205
         $line = null;
7206
-    	if (substr($view,3,1) == '1') {
7207
-    		$new_view = substr_replace($view,'0',3,1);
7208
-    		$title[1]=get_lang('LinksDetails');
7209
-    		$sql = "SELECT cl.title, cl.url
7206
+        if (substr($view,3,1) == '1') {
7207
+            $new_view = substr_replace($view,'0',3,1);
7208
+            $title[1]=get_lang('LinksDetails');
7209
+            $sql = "SELECT cl.title, cl.url
7210 7210
                         FROM $TABLETRACK_LINKS AS sl, $TABLECOURSE_LINKS AS cl
7211 7211
                         WHERE sl.links_link_id = cl.id
7212 7212
                             AND sl.c_id = $courseId
7213 7213
                             AND sl.links_user_id = $userId
7214 7214
                         GROUP BY cl.title, cl.url";
7215
-    		$results = StatsUtils::getManyResults2Col($sql);
7216
-    		$title_line= get_lang('LinksTitleLinkColumn')."\n";
7217
-    		if (is_array($results)) {
7218
-    			for ($j = 0 ; $j < count($results) ; $j++) {
7219
-    				$line .= $results[$j][0]."\n";
7220
-    			}
7221
-    		} else {
7222
-    			$line=get_lang('NoResult');
7223
-    		}
7224
-    	} else {
7225
-    		$new_view = substr_replace($view,'1',3,1);
7226
-    	}
7227
-    	return array($title_line, $line);
7215
+            $results = StatsUtils::getManyResults2Col($sql);
7216
+            $title_line= get_lang('LinksTitleLinkColumn')."\n";
7217
+            if (is_array($results)) {
7218
+                for ($j = 0 ; $j < count($results) ; $j++) {
7219
+                    $line .= $results[$j][0]."\n";
7220
+                }
7221
+            } else {
7222
+                $line=get_lang('NoResult');
7223
+            }
7224
+        } else {
7225
+            $new_view = substr_replace($view,'1',3,1);
7226
+        }
7227
+        return array($title_line, $line);
7228 7228
     }
7229 7229
 
7230 7230
     /**
@@ -7237,38 +7237,38 @@  discard block
 block discarded – undo
7237 7237
      */
7238 7238
     public function display_document_tracking_info($view, $user_id, $courseCode, $session_id = 0)
7239 7239
     {
7240
-    	// protect data
7241
-    	$user_id     = intval($user_id);
7240
+        // protect data
7241
+        $user_id     = intval($user_id);
7242 7242
         $courseId = api_get_course_int_id($courseCode);
7243
-    	$session_id = intval($session_id);
7243
+        $session_id = intval($session_id);
7244 7244
 
7245
-    	$downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
7245
+        $downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
7246 7246
 
7247
-    	if (substr($view,4,1) == '1') {
7248
-    		$new_view = substr_replace($view,'0',4,1);
7249
-    		$title[1]= get_lang('DocumentsDetails');
7247
+        if (substr($view,4,1) == '1') {
7248
+            $new_view = substr_replace($view,'0',4,1);
7249
+            $title[1]= get_lang('DocumentsDetails');
7250 7250
 
7251
-    		$sql = "SELECT down_doc_path
7251
+            $sql = "SELECT down_doc_path
7252 7252
                         FROM $downloads_table
7253 7253
                         WHERE c_id = $courseId
7254 7254
                             AND down_user_id = $user_id
7255 7255
                             AND down_session_id = $session_id
7256 7256
                         GROUP BY down_doc_path";
7257 7257
 
7258
-    		$results = StatsUtils::getManyResults1Col($sql);
7259
-    		$title_line = get_lang('DocumentsTitleDocumentColumn')."\n";
7258
+            $results = StatsUtils::getManyResults1Col($sql);
7259
+            $title_line = get_lang('DocumentsTitleDocumentColumn')."\n";
7260 7260
             $line = null;
7261
-    		if (is_array($results)) {
7262
-    			for ($j = 0 ; $j < count($results) ; $j++) {
7263
-    				$line .= $results[$j]."\n";
7264
-    			}
7265
-    		} else {
7266
-    			$line = get_lang('NoResult');
7267
-    		}
7268
-    	} else {
7269
-    		$new_view = substr_replace($view,'1',4,1);
7270
-    	}
7271
-    	return array($title_line, $line);
7261
+            if (is_array($results)) {
7262
+                for ($j = 0 ; $j < count($results) ; $j++) {
7263
+                    $line .= $results[$j]."\n";
7264
+                }
7265
+            } else {
7266
+                $line = get_lang('NoResult');
7267
+            }
7268
+        } else {
7269
+            $new_view = substr_replace($view,'1',4,1);
7270
+        }
7271
+        return array($title_line, $line);
7272 7272
     }
7273 7273
 
7274 7274
     /**
Please login to merge, or discard this patch.
Spacing   +429 added lines, -429 removed lines patch added patch discarded remove patch
@@ -77,8 +77,8 @@  discard block
 block discarded – undo
77 77
                 }
78 78
 
79 79
                 $countUsers = count($users);
80
-                $averageProgress = empty($countUsers) ? 0 : $avg_student_progress/$countUsers;
81
-                $averageScore = empty($countUsers) ? 0 : $avg_student_score/$countUsers;
80
+                $averageProgress = empty($countUsers) ? 0 : $avg_student_progress / $countUsers;
81
+                $averageScore = empty($countUsers) ? 0 : $avg_student_score / $countUsers;
82 82
 
83 83
                 $group_item = array(
84 84
                     'id' => $group['id'],
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
         $extendedAttempt = null,
125 125
         $extendedAll = null,
126 126
         $type = 'classic',
127
-        $allowExtend =  true
127
+        $allowExtend = true
128 128
     ) {
129 129
         if (empty($courseInfo) || empty($lp_id)) {
130 130
             return null;
@@ -148,22 +148,22 @@  discard block
 block discarded – undo
148 148
         $extend_all = 0;
149 149
 
150 150
         if ($origin == 'tracking') {
151
-            $url_suffix = '&session_id=' . $session_id . '&course=' . $courseCode . '&student_id=' . $user_id . '&lp_id=' . $lp_id . '&origin=' . $origin;
151
+            $url_suffix = '&session_id='.$session_id.'&course='.$courseCode.'&student_id='.$user_id.'&lp_id='.$lp_id.'&origin='.$origin;
152 152
         } else {
153
-            $url_suffix = '&lp_id=' . $lp_id;
153
+            $url_suffix = '&lp_id='.$lp_id;
154 154
         }
155 155
 
156 156
         if (!empty($extendedAll)) {
157 157
             $extend_all_link = Display::url(
158 158
                 Display::return_icon('view_less_stats.gif', get_lang('HideAllAttempts')),
159
-                api_get_self() . '?action=stats' . $url_suffix
159
+                api_get_self().'?action=stats'.$url_suffix
160 160
             );
161 161
 
162 162
             $extend_all = 1;
163 163
         } else {
164 164
             $extend_all_link = Display::url(
165 165
                 Display::return_icon('view_more_stats.gif', get_lang('ShowAllAttempts')),
166
-                api_get_self() . '?action=stats&extend_all=1' . $url_suffix
166
+                api_get_self().'?action=stats&extend_all=1'.$url_suffix
167 167
             );
168 168
         }
169 169
 
@@ -175,24 +175,24 @@  discard block
 block discarded – undo
175 175
 
176 176
         $actionColumn = null;
177 177
         if ($type == 'classic') {
178
-            $actionColumn = ' <th>' . get_lang('Actions') . '</th>';
178
+            $actionColumn = ' <th>'.get_lang('Actions').'</th>';
179 179
         }
180 180
         $output .= '<div class="table-responsive">';
181 181
         $output .= '<table class="table tracking">
182 182
             <thead>
183 183
             <tr class="table-header">
184
-                <th width="16">' . ($allowExtend == true ? $extend_all_link : '&nbsp;') . '</th>
184
+                <th width="16">' . ($allowExtend == true ? $extend_all_link : '&nbsp;').'</th>
185 185
                 <th colspan="4">
186
-                    ' . get_lang('ScormLessonTitle') .'
186
+                    ' . get_lang('ScormLessonTitle').'
187 187
                 </th>
188 188
                 <th colspan="2">
189
-                    ' . get_lang('ScormStatus') . '
189
+                    ' . get_lang('ScormStatus').'
190 190
                 </th>
191 191
                 <th colspan="2">
192
-                    ' . get_lang('ScormScore') . '
192
+                    ' . get_lang('ScormScore').'
193 193
                 </th>
194 194
                 <th colspan="2">
195
-                    ' . get_lang('ScormTime') . '
195
+                    ' . get_lang('ScormTime').'
196 196
                 </th>
197 197
                 '.$actionColumn.'
198 198
                 </tr>
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
                 // Prepare statement to go through each attempt.
256 256
                 $viewCondition = null;
257 257
                 if (!empty($view)) {
258
-                    $viewCondition =  " AND v.view_count = $view  ";
258
+                    $viewCondition = " AND v.view_count = $view  ";
259 259
                 }
260 260
 
261 261
                 $sql = "SELECT
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
                                 FROM $TBL_QUIZ
304 304
                                 WHERE
305 305
                                     c_id = $course_id AND
306
-                                    id ='" . $my_path . "'";
306
+                                    id ='".$my_path."'";
307 307
                         $res_result_disabled = Database::query($sql);
308 308
                         $row_result_disabled = Database::fetch_row($res_result_disabled);
309 309
 
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
                     if (!empty($inter_num)) {
326 326
                         $extend_link = Display::url(
327 327
                               Display::return_icon('visible.gif', get_lang('HideAttemptView')),
328
-                              api_get_self() . '?action=stats&fold_id=' . $my_item_id . $url_suffix
328
+                              api_get_self().'?action=stats&fold_id='.$my_item_id.$url_suffix
329 329
                         );
330 330
                     }
331 331
                     $title = $row['mytitle'];
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
 
344 344
                     $action = null;
345 345
                     if ($type == 'classic') {
346
-                        $action =  '<td></td>';
346
+                        $action = '<td></td>';
347 347
                     }
348 348
 
349 349
                     if (in_array($row['item_type'], $chapterTypes)) {
@@ -387,13 +387,13 @@  discard block
 block discarded – undo
387 387
                                 $extend_this_attempt = 1;
388 388
                                 $extend_attempt_link = Display::url(
389 389
                                     Display::return_icon('visible.gif', get_lang('HideAttemptView')),
390
-                                    api_get_self() . '?action=stats&extend_id=' . $my_item_id . '&fold_attempt_id=' . $row['iv_id'] . $url_suffix
390
+                                    api_get_self().'?action=stats&extend_id='.$my_item_id.'&fold_attempt_id='.$row['iv_id'].$url_suffix
391 391
                                 );
392 392
                             } else { // Same case if fold_attempt_id is set, so not implemented explicitly.
393 393
                                 // The extend button for this attempt has not been clicked.
394 394
                                 $extend_attempt_link = Display::url(
395 395
                                     Display::return_icon('invisible.gif', get_lang('ExtendAttemptView')),
396
-                                    api_get_self() . '?action=stats&extend_id=' . $my_item_id . '&extend_attempt_id=' . $row['iv_id'] . $url_suffix
396
+                                    api_get_self().'?action=stats&extend_id='.$my_item_id.'&extend_attempt_id='.$row['iv_id'].$url_suffix
397 397
                                 );
398 398
                             }
399 399
                         }
@@ -426,7 +426,7 @@  discard block
 block discarded – undo
426 426
                         }
427 427
 
428 428
                         // Remove "NaN" if any (@todo: locate the source of these NaN)
429
-                        $time = str_replace('NaN', '00' . $h . '00\'00"', $time);
429
+                        $time = str_replace('NaN', '00'.$h.'00\'00"', $time);
430 430
 
431 431
                         if ($row['item_type'] != 'dokeos_chapter') {
432 432
                             if (!$is_allowed_to_edit && $result_disabled_ext_all) {
@@ -454,13 +454,13 @@  discard block
 block discarded – undo
454 454
                                 $action = '<td></td>';
455 455
                             }
456 456
 
457
-                            $output .= '<tr class="' . $oddclass . '">
457
+                            $output .= '<tr class="'.$oddclass.'">
458 458
                                     <td></td>
459
-                                    <td>' . $extend_attempt_link . '</td>
460
-                                    <td colspan="3">' . get_lang('Attempt') . ' ' . $attemptCount . '</td>
461
-                                    <td colspan="2">' . learnpathItem::humanize_status($lesson_status, true, $type) . '</td>
462
-                                    <td colspan="2">' . $view_score . '</td>
463
-                                    <td colspan="2">' . $time . '</td>
459
+                                    <td>' . $extend_attempt_link.'</td>
460
+                                    <td colspan="3">' . get_lang('Attempt').' '.$attemptCount.'</td>
461
+                                    <td colspan="2">' . learnpathItem::humanize_status($lesson_status, true, $type).'</td>
462
+                                    <td colspan="2">' . $view_score.'</td>
463
+                                    <td colspan="2">' . $time.'</td>
464 464
                                     '.$action.'
465 465
                                 </tr>';
466 466
                             $attemptCount++;
@@ -473,10 +473,10 @@  discard block
 block discarded – undo
473 473
                                     if (!$is_allowed_to_edit && $result_disabled_ext_all) {
474 474
                                         $temp[] = '/';
475 475
                                     } else {
476
-                                        $temp[] = ($score == 0 ? '0/' . $maxscore : ($maxscore == 0 ? $score : $score . '/' . float_format($maxscore, 1)));
476
+                                        $temp[] = ($score == 0 ? '0/'.$maxscore : ($maxscore == 0 ? $score : $score.'/'.float_format($maxscore, 1)));
477 477
                                     }
478 478
                                 } else {
479
-                                    $temp[] = ($score == 0 ? '/' : ($maxscore == 0 ? $score : $score . '/' . float_format($maxscore, 1)));
479
+                                    $temp[] = ($score == 0 ? '/' : ($maxscore == 0 ? $score : $score.'/'.float_format($maxscore, 1)));
480 480
                                 }
481 481
                                 $temp[] = $time;
482 482
                                 $csv_content[] = $temp;
@@ -513,13 +513,13 @@  discard block
 block discarded – undo
513 513
                                         <td></td>
514 514
                                         <td></td>
515 515
                                         <td></td>
516
-                                        <td>'.$interaction['order_id'] . '</td>
517
-                                        <td>'.$interaction['id'] . '</td>
516
+                                        <td>'.$interaction['order_id'].'</td>
517
+                                        <td>'.$interaction['id'].'</td>
518 518
                                         <td colspan="2">' . $interaction['type'].'</td>
519
-                                        <td>'.$student_response . '</td>
520
-                                        <td>'.$interaction['result'] . '</td>
521
-                                        <td>'.$interaction['latency'] . '</td>
522
-                                        <td>'.$interaction['time'] . '</td>
519
+                                        <td>'.$student_response.'</td>
520
+                                        <td>'.$interaction['result'].'</td>
521
+                                        <td>'.$interaction['latency'].'</td>
522
+                                        <td>'.$interaction['time'].'</td>
523 523
                                         '.$action.'
524 524
                                     </tr>';
525 525
                                 $counter++;
@@ -536,12 +536,12 @@  discard block
 block discarded – undo
536 536
                                         <td></td>
537 537
                                         <td></td>
538 538
                                         <td></td>
539
-                                        <td>' . $interaction['order_id'] . '</td>
540
-                                        <td colspan="2">' . $interaction['objective_id'] . '</td>
541
-                                        <td colspan="2">' . $interaction['status'] .'</td>
542
-                                        <td>' . $interaction['score_raw'] . '</td>
543
-                                        <td>' . $interaction['score_max'] . '</td>
544
-                                        <td>' . $interaction['score_min'] . '</td>
539
+                                        <td>' . $interaction['order_id'].'</td>
540
+                                        <td colspan="2">' . $interaction['objective_id'].'</td>
541
+                                        <td colspan="2">' . $interaction['status'].'</td>
542
+                                        <td>' . $interaction['score_raw'].'</td>
543
+                                        <td>' . $interaction['score_max'].'</td>
544
+                                        <td>' . $interaction['score_min'].'</td>
545 545
                                         '.$action.'
546 546
                                      </tr>';
547 547
                                 $counter++;
@@ -564,7 +564,7 @@  discard block
 block discarded – undo
564 564
                         $my_path = Database::escape_string($my_path);
565 565
                         $sql = "SELECT results_disabled
566 566
                                 FROM $TBL_QUIZ
567
-                                WHERE c_id = $course_id AND id ='" . $my_path . "'";
567
+                                WHERE c_id = $course_id AND id ='".$my_path."'";
568 568
                         $res_result_disabled = Database::query($sql);
569 569
                         $row_result_disabled = Database::fetch_row($res_result_disabled);
570 570
 
@@ -588,14 +588,14 @@  discard block
 block discarded – undo
588 588
                             $extend_this_attempt = 1;
589 589
                             $extend_attempt_link = Display::url(
590 590
                                 Display::return_icon('visible.gif', get_lang('HideAttemptView')),
591
-                                api_get_self() . '?action=stats&extend_id=' . $my_item_id . '&fold_attempt_id=' . $row['iv_id'] . $url_suffix
591
+                                api_get_self().'?action=stats&extend_id='.$my_item_id.'&fold_attempt_id='.$row['iv_id'].$url_suffix
592 592
                             );
593 593
                         } else {
594 594
                             // Same case if fold_attempt_id is set, so not implemented explicitly.
595 595
                             // The extend button for this attempt has not been clicked.
596 596
                             $extend_attempt_link = Display::url(
597 597
                                 Display::return_icon('invisible.gif', get_lang('ExtendAttemptView')),
598
-                                api_get_self() . '?action=stats&extend_id=' . $my_item_id . '&extend_attempt_id=' . $row['iv_id'] . $url_suffix
598
+                                api_get_self().'?action=stats&extend_id='.$my_item_id.'&extend_attempt_id='.$row['iv_id'].$url_suffix
599 599
                             );
600 600
                         }
601 601
                     }
@@ -610,7 +610,7 @@  discard block
 block discarded – undo
610 610
                     if ($inter_num > 1) {
611 611
                         $extend_link = Display::url(
612 612
                             Display::return_icon('invisible.gif', get_lang('ExtendAttemptView')),
613
-                            api_get_self() . '?action=stats&extend_id=' . $my_item_id . '&extend_attempt_id=' . $row['iv_id'] . $url_suffix
613
+                            api_get_self().'?action=stats&extend_id='.$my_item_id.'&extend_attempt_id='.$row['iv_id'].$url_suffix
614 614
                         );
615 615
                     }
616 616
 
@@ -626,15 +626,15 @@  discard block
 block discarded – undo
626 626
 
627 627
                     // Selecting the exe_id from stats attempts tables in order to look the max score value.
628 628
 
629
-                    $sql = 'SELECT * FROM ' . $tbl_stats_exercices . '
629
+                    $sql = 'SELECT * FROM '.$tbl_stats_exercices.'
630 630
                              WHERE
631
-                                exe_exo_id="' . $row['path'] . '" AND
632
-                                exe_user_id="' . $user_id . '" AND
633
-                                orig_lp_id = "' . $lp_id . '" AND
634
-                                orig_lp_item_id = "' . $row['myid'] . '" AND
635
-                                c_id = ' . $course_id . ' AND
631
+                                exe_exo_id="' . $row['path'].'" AND
632
+                                exe_user_id="' . $user_id.'" AND
633
+                                orig_lp_id = "' . $lp_id.'" AND
634
+                                orig_lp_item_id = "' . $row['myid'].'" AND
635
+                                c_id = ' . $course_id.' AND
636 636
                                 status <> "incomplete" AND
637
-                                session_id = ' . $session_id . '
637
+                                session_id = ' . $session_id.'
638 638
                              ORDER BY exe_date DESC
639 639
                              LIMIT 1';
640 640
 
@@ -665,8 +665,8 @@  discard block
 block discarded – undo
665 665
                                         FROM $TBL_LP_ITEM_VIEW
666 666
                                         WHERE
667 667
                                             c_id = $course_id AND
668
-                                            lp_item_id = '" . (int) $my_id . "' AND
669
-                                            lp_view_id = '" . (int) $my_lp_view_id . "'
668
+                                            lp_item_id = '".(int) $my_id."' AND
669
+                                            lp_view_id = '" . (int) $my_lp_view_id."'
670 670
                                         ORDER BY view_count DESC limit 1";
671 671
                                 $res_score = Database::query($sql);
672 672
                                 $row_score = Database::fetch_array($res_score);
@@ -675,8 +675,8 @@  discard block
 block discarded – undo
675 675
                                         FROM $TBL_LP_ITEM_VIEW
676 676
                                         WHERE
677 677
                                             c_id = $course_id AND
678
-                                            lp_item_id = '" . (int) $my_id . "' AND
679
-                                            lp_view_id = '" . (int) $my_lp_view_id . "'";
678
+                                            lp_item_id = '".(int) $my_id."' AND
679
+                                            lp_view_id = '" . (int) $my_lp_view_id."'";
680 680
                                 $res_time = Database::query($sql);
681 681
                                 $row_time = Database::fetch_array($res_time);
682 682
 
@@ -735,16 +735,16 @@  discard block
 block discarded – undo
735 735
                     } else {
736 736
                         $correct_test_link = '-';
737 737
                         if ($row['item_type'] == 'quiz') {
738
-                            $my_url_suffix = '&course=' . $courseCode . '&student_id=' . $user_id . '&lp_id=' . intval($row['mylpid']) . '&origin=' . $origin;
739
-                            $sql = 'SELECT * FROM ' . $tbl_stats_exercices . '
738
+                            $my_url_suffix = '&course='.$courseCode.'&student_id='.$user_id.'&lp_id='.intval($row['mylpid']).'&origin='.$origin;
739
+                            $sql = 'SELECT * FROM '.$tbl_stats_exercices.'
740 740
                                      WHERE
741
-                                        exe_exo_id="' . $row['path'] . '" AND
742
-                                        exe_user_id="' . $user_id . '" AND
743
-                                        orig_lp_id = "' . $lp_id . '" AND
744
-                                        orig_lp_item_id = "' . $row['myid'] . '" AND
745
-                                        c_id = ' . $course_id . ' AND
741
+                                        exe_exo_id="' . $row['path'].'" AND
742
+                                        exe_user_id="' . $user_id.'" AND
743
+                                        orig_lp_id = "' . $lp_id.'" AND
744
+                                        orig_lp_item_id = "' . $row['myid'].'" AND
745
+                                        c_id = ' . $course_id.' AND
746 746
                                         status <> "incomplete" AND
747
-                                        session_id = ' . $session_id . '
747
+                                        session_id = ' . $session_id.'
748 748
                                      ORDER BY exe_date DESC ';
749 749
 
750 750
                             $resultLastAttempt = Database::query($sql);
@@ -756,12 +756,12 @@  discard block
 block discarded – undo
756 756
                                 ) {
757 757
                                     $correct_test_link = Display::url(
758 758
                                         Display::return_icon('view_less_stats.gif', get_lang('HideAllAttempts')),
759
-                                        api_get_self() . '?action=stats' . $my_url_suffix . '&session_id=' . $session_id . '&lp_item_id=' . $my_id
759
+                                        api_get_self().'?action=stats'.$my_url_suffix.'&session_id='.$session_id.'&lp_item_id='.$my_id
760 760
                                     );
761 761
                                 } else {
762 762
                                     $correct_test_link = Display::url(
763 763
                                         Display::return_icon('view_more_stats.gif', get_lang('ShowAllAttemptsByExercise')),
764
-                                        api_get_self() . '?action=stats&extend_attempt=1' . $my_url_suffix . '&session_id=' . $session_id . '&lp_item_id=' . $my_id
764
+                                        api_get_self().'?action=stats&extend_attempt=1'.$my_url_suffix.'&session_id='.$session_id.'&lp_item_id='.$my_id
765 765
                                     );
766 766
                                 }
767 767
                             }
@@ -771,14 +771,14 @@  discard block
 block discarded – undo
771 771
 
772 772
                         $action = null;
773 773
                         if ($type == 'classic') {
774
-                            $action =  '<td>' . $correct_test_link . '</td>';
774
+                            $action = '<td>'.$correct_test_link.'</td>';
775 775
                         }
776 776
 
777 777
                         if ($lp_id == $my_lp_id && false) {
778 778
 
779
-                            $output .= '<tr class =' . $oddclass . '>
780
-                                    <td>' . $extend_link . '</td>
781
-                                    <td colspan="4">' . $title . '</td>
779
+                            $output .= '<tr class ='.$oddclass.'>
780
+                                    <td>' . $extend_link.'</td>
781
+                                    <td colspan="4">' . $title.'</td>
782 782
                                     <td colspan="2">&nbsp;</td>
783 783
                                     <td colspan="2">&nbsp;</td>
784 784
                                     <td colspan="2">&nbsp;</td>
@@ -803,13 +803,13 @@  discard block
 block discarded – undo
803 803
                                     $scoreItem .= ExerciseLib::show_score($score, $maxscore, false);
804 804
                                 }
805 805
                             } else {
806
-                                $scoreItem .= $score == 0 ? '/' : ($maxscore == 0 ? $score : $score . '/' . $maxscore);
806
+                                $scoreItem .= $score == 0 ? '/' : ($maxscore == 0 ? $score : $score.'/'.$maxscore);
807 807
                             }
808 808
 
809 809
                             $output .= '
810 810
                                 <td>'.$extend_link.'</td>
811
-                                <td colspan="4">' . $title . '</td>
812
-                                <td colspan="2">' . learnpathitem::humanize_status($lesson_status) .'</td>
811
+                                <td colspan="4">' . $title.'</td>
812
+                                <td colspan="2">' . learnpathitem::humanize_status($lesson_status).'</td>
813 813
                                 <td colspan="2">'.$scoreItem.'</td>
814 814
                                 <td colspan="2">'.$time.'</td>
815 815
                                 '.$action.'
@@ -826,10 +826,10 @@  discard block
 block discarded – undo
826 826
                                 if (!$is_allowed_to_edit && $result_disabled_ext_all) {
827 827
                                     $temp[] = '/';
828 828
                                 } else {
829
-                                    $temp[] = ($score == 0 ? '0/' . $maxscore : ($maxscore == 0 ? $score : $score . '/' . float_format($maxscore, 1)));
829
+                                    $temp[] = ($score == 0 ? '0/'.$maxscore : ($maxscore == 0 ? $score : $score.'/'.float_format($maxscore, 1)));
830 830
                                 }
831 831
                             } else {
832
-                                $temp[] = ($score == 0 ? '/' : ($maxscore == 0 ? $score : $score . '/' . float_format($maxscore, 1)));
832
+                                $temp[] = ($score == 0 ? '/' : ($maxscore == 0 ? $score : $score.'/'.float_format($maxscore, 1)));
833 833
                             }
834 834
                             $temp[] = $time;
835 835
                             $csv_content[] = $temp;
@@ -840,7 +840,7 @@  discard block
 block discarded – undo
840 840
 
841 841
                     $action = null;
842 842
                     if ($type == 'classic') {
843
-                        $action =  '<td></td>';
843
+                        $action = '<td></td>';
844 844
                     }
845 845
 
846 846
                     if ($extend_this_attempt || $extend_all) {
@@ -877,11 +877,11 @@  discard block
 block discarded – undo
877 877
                                     <td></td>
878 878
                                     <td></td>
879 879
                                     <td></td>
880
-                                    <td>' . $interaction['order_id'] . '</td>
881
-                                    <td colspan="2">'.$interaction['objective_id'] . '</td>
882
-                                    <td colspan="2">' . $interaction['status'] . '</td>
880
+                                    <td>' . $interaction['order_id'].'</td>
881
+                                    <td colspan="2">'.$interaction['objective_id'].'</td>
882
+                                    <td colspan="2">' . $interaction['status'].'</td>
883 883
                                     <td>' . $interaction['score_raw'].'</td>
884
-                                    <td>' . $interaction['score_max'] .'</td>
884
+                                    <td>' . $interaction['score_max'].'</td>
885 885
                                     <td>' . $interaction['score_min'].'</td>
886 886
                                     '.$action.'
887 887
                                </tr>';
@@ -890,7 +890,7 @@  discard block
 block discarded – undo
890 890
                     }
891 891
 
892 892
                     // Attempts listing by exercise.
893
-                    if ($lp_id == $my_lp_id && $lp_item_id== $my_id && $extendedAttempt) {
893
+                    if ($lp_id == $my_lp_id && $lp_item_id == $my_id && $extendedAttempt) {
894 894
                         // Get attempts of a exercise.
895 895
                         if (!empty($lp_id) &&
896 896
                             !empty($lp_item_id) &&
@@ -905,15 +905,15 @@  discard block
 block discarded – undo
905 905
                             $row_path = Database::fetch_array($res_path);
906 906
 
907 907
                             if (Database::num_rows($res_path) > 0) {
908
-                                $sql = 'SELECT * FROM ' . $tbl_stats_exercices . '
908
+                                $sql = 'SELECT * FROM '.$tbl_stats_exercices.'
909 909
                                         WHERE
910
-                                            exe_exo_id="' . (int) $row_path['path'] . '" AND
910
+                                            exe_exo_id="' . (int) $row_path['path'].'" AND
911 911
                                             status <> "incomplete" AND
912
-                                            exe_user_id="' . $user_id . '" AND
913
-                                            orig_lp_id = "' . (int) $lp_id . '" AND
914
-                                            orig_lp_item_id = "' . (int) $lp_item_id . '" AND
915
-                                            c_id = ' . $course_id . '  AND
916
-                                            session_id = ' . $session_id . '
912
+                                            exe_user_id="' . $user_id.'" AND
913
+                                            orig_lp_id = "' . (int) $lp_id.'" AND
914
+                                            orig_lp_item_id = "' . (int) $lp_item_id.'" AND
915
+                                            c_id = ' . $course_id.'  AND
916
+                                            session_id = ' . $session_id.'
917 917
                                         ORDER BY exe_date';
918 918
                                 $res_attempts = Database::query($sql);
919 919
                                 $num_attempts = Database::num_rows($res_attempts);
@@ -931,7 +931,7 @@  discard block
 block discarded – undo
931 931
                                         if ($mktime_start_date && $mktime_exe_date) {
932 932
                                             $mytime = ((int) $mktime_exe_date - (int) $mktime_start_date);
933 933
                                             $time_attemp = learnpathItem :: getScormTimeFromParameter('js', $mytime);
934
-                                            $time_attemp = str_replace('NaN', '00' . $h . '00\'00"', $time_attemp);
934
+                                            $time_attemp = str_replace('NaN', '00'.$h.'00\'00"', $time_attemp);
935 935
                                         } else {
936 936
                                             $time_attemp = ' - ';
937 937
                                         }
@@ -957,33 +957,33 @@  discard block
 block discarded – undo
957 957
                                             $my_lesson_status = learnpathitem::humanize_status('incomplete');
958 958
                                         }
959 959
 
960
-                                        $output .= '<tr class="' . $oddclass . '" >
960
+                                        $output .= '<tr class="'.$oddclass.'" >
961 961
                                         <td></td>
962
-                                        <td>' . $extend_attempt_link . '</td>
963
-                                        <td colspan="3">' . get_lang('Attempt').' '. $n.'</td>
964
-                                        <td colspan="2">' . $my_lesson_status . '</td>
965
-                                        <td colspan="2">'.$view_score . '</td>
966
-                                        <td colspan="2">'.$time_attemp . '</td>';
962
+                                        <td>' . $extend_attempt_link.'</td>
963
+                                        <td colspan="3">' . get_lang('Attempt').' '.$n.'</td>
964
+                                        <td colspan="2">' . $my_lesson_status.'</td>
965
+                                        <td colspan="2">'.$view_score.'</td>
966
+                                        <td colspan="2">'.$time_attemp.'</td>';
967 967
                                         if ($action == 'classic') {
968 968
                                             if ($origin != 'tracking') {
969 969
                                                 if (!$is_allowed_to_edit && $result_disabled_ext_all) {
970 970
                                                     $output .= '<td>
971
-                                                            <img src="' . Display::returnIconPath('quiz_na.gif').'" alt="' . get_lang('ShowAttempt') . '" title="' . get_lang('ShowAttempt') . '">
971
+                                                            <img src="' . Display::returnIconPath('quiz_na.gif').'" alt="'.get_lang('ShowAttempt').'" title="'.get_lang('ShowAttempt').'">
972 972
                                                             </td>';
973 973
                                                 } else {
974 974
                                                     $output .= '<td>
975
-                                                            <a href="../exercice/exercise_show.php?origin=' . $origin . '&id=' . $my_exe_id . '&cidReq=' . $courseCode . '" target="_parent">
976
-                                                            <img src="' . Display::returnIconPath('quiz.gif').'" alt="' . get_lang('ShowAttempt') . '" title="' . get_lang('ShowAttempt') . '">
975
+                                                            <a href="../exercice/exercise_show.php?origin=' . $origin.'&id='.$my_exe_id.'&cidReq='.$courseCode.'" target="_parent">
976
+                                                            <img src="' . Display::returnIconPath('quiz.gif').'" alt="'.get_lang('ShowAttempt').'" title="'.get_lang('ShowAttempt').'">
977 977
                                                             </a></td>';
978 978
                                                 }
979 979
                                             } else {
980 980
                                                 if (!$is_allowed_to_edit && $result_disabled_ext_all) {
981 981
                                                     $output .= '<td>
982
-                                                                <img src="' . Display::returnIconPath('quiz_na.gif').'" alt="' . get_lang('ShowAndQualifyAttempt') . '" title="' . get_lang('ShowAndQualifyAttempt') . '"></td>';
982
+                                                                <img src="' . Display::returnIconPath('quiz_na.gif').'" alt="'.get_lang('ShowAndQualifyAttempt').'" title="'.get_lang('ShowAndQualifyAttempt').'"></td>';
983 983
                                                 } else {
984 984
                                                     $output .= '<td>
985
-                                                                    <a href="../exercice/exercise_show.php?cidReq=' . $courseCode . '&origin=correct_exercise_in_lp&id=' . $my_exe_id . '" target="_parent">
986
-                                                                    <img src="' . Display::returnIconPath('quiz.gif').'" alt="' . get_lang('ShowAndQualifyAttempt') . '" title="' . get_lang('ShowAndQualifyAttempt') . '"></a></td>';
985
+                                                                    <a href="../exercice/exercise_show.php?cidReq=' . $courseCode.'&origin=correct_exercise_in_lp&id='.$my_exe_id.'" target="_parent">
986
+                                                                    <img src="' . Display::returnIconPath('quiz.gif').'" alt="'.get_lang('ShowAndQualifyAttempt').'" title="'.get_lang('ShowAndQualifyAttempt').'"></a></td>';
987 987
                                                 }
988 988
                                             }
989 989
                                         }
@@ -1042,13 +1042,13 @@  discard block
 block discarded – undo
1042 1042
         }
1043 1043
 
1044 1044
         $total_time = learnpathItem::getScormTimeFromParameter('js', $total_time);
1045
-        $total_time = str_replace('NaN', '00' . $h . '00\'00"', $total_time);
1045
+        $total_time = str_replace('NaN', '00'.$h.'00\'00"', $total_time);
1046 1046
 
1047 1047
         if (!$is_allowed_to_edit && $result_disabled_ext_all) {
1048 1048
             $final_score = Display::return_icon('invisible.gif', get_lang('ResultsHiddenByExerciseSetting'));
1049 1049
         } else {
1050 1050
             if (is_numeric($total_score)) {
1051
-                $final_score = $total_score . '%';
1051
+                $final_score = $total_score.'%';
1052 1052
             } else {
1053 1053
                 $final_score = $total_score;
1054 1054
             }
@@ -1064,19 +1064,19 @@  discard block
 block discarded – undo
1064 1064
 
1065 1065
         $action = null;
1066 1066
         if ($type == 'classic') {
1067
-            $action =  '<td></td>';
1067
+            $action = '<td></td>';
1068 1068
         }
1069 1069
 
1070 1070
         $output .= '<tr class="'.$oddclass.'">
1071 1071
                 <td></td>
1072 1072
                 <td colspan="4">
1073
-                    <i>' . get_lang('AccomplishedStepsTotal') .'</i>
1073
+                    <i>' . get_lang('AccomplishedStepsTotal').'</i>
1074 1074
                 </td>
1075 1075
                 <td colspan="2">'.$progress.'%</td>
1076 1076
                 <td colspan="2">
1077 1077
                     ' . $final_score.'
1078 1078
                 </td>
1079
-                <td colspan="2">' . $total_time . '</div>
1079
+                <td colspan="2">' . $total_time.'</div>
1080 1080
                 '.$action.'
1081 1081
            </tr>';
1082 1082
 
@@ -1416,7 +1416,7 @@  discard block
 block discarded – undo
1416 1416
     	$tbl_track_course = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1417 1417
     	if (is_array($user_id)) {
1418 1418
     	    $user_id = array_map('intval', $user_id);
1419
-    		$condition_user = " AND user_id IN (".implode(',',$user_id).") ";
1419
+    		$condition_user = " AND user_id IN (".implode(',', $user_id).") ";
1420 1420
     	} else {
1421 1421
     		$user_id = intval($user_id);
1422 1422
     		$condition_user = " AND user_id = $user_id ";
@@ -1452,13 +1452,13 @@  discard block
 block discarded – undo
1452 1452
     {
1453 1453
     	$tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
1454 1454
     	$sql = 'SELECT login_date
1455
-    	        FROM ' . $tbl_track_login . '
1456
-                WHERE login_user_id = ' . intval($student_id) . '
1455
+    	        FROM ' . $tbl_track_login.'
1456
+                WHERE login_user_id = ' . intval($student_id).'
1457 1457
                 ORDER BY login_date ASC
1458 1458
                 LIMIT 0,1';
1459 1459
 
1460 1460
     	$rs = Database::query($sql);
1461
-    	if (Database::num_rows($rs)>0) {
1461
+    	if (Database::num_rows($rs) > 0) {
1462 1462
     		if ($first_login_date = Database::result($rs, 0, 0)) {
1463 1463
                 return api_convert_and_format_date(
1464 1464
                     $first_login_date,
@@ -1483,8 +1483,8 @@  discard block
 block discarded – undo
1483 1483
     {
1484 1484
     	$table = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
1485 1485
     	$sql = 'SELECT login_date
1486
-    	        FROM ' . $table . '
1487
-                WHERE login_user_id = ' . intval($student_id) . '
1486
+    	        FROM ' . $table.'
1487
+                WHERE login_user_id = ' . intval($student_id).'
1488 1488
                 ORDER BY login_date
1489 1489
                 DESC LIMIT 0,1';
1490 1490
 
@@ -1493,18 +1493,18 @@  discard block
 block discarded – undo
1493 1493
     		if ($last_login_date = Database::result($rs, 0, 0)) {
1494 1494
     			$last_login_date = api_get_local_time($last_login_date);
1495 1495
     			if ($return_timestamp) {
1496
-    				return api_strtotime($last_login_date,'UTC');
1496
+    				return api_strtotime($last_login_date, 'UTC');
1497 1497
     			} else {
1498 1498
     				if (!$warning_message) {
1499 1499
     					return api_format_date($last_login_date, DATE_FORMAT_SHORT);
1500 1500
     				} else {
1501
-    					$timestamp = api_strtotime($last_login_date,'UTC');
1501
+    					$timestamp = api_strtotime($last_login_date, 'UTC');
1502 1502
     					$currentTimestamp = time();
1503 1503
 
1504 1504
     					//If the last connection is > than 7 days, the text is red
1505 1505
     					//345600 = 7 days in seconds
1506 1506
     					if ($currentTimestamp - $timestamp > 604800) {
1507
-    						return '<span style="color: #F00;">' . api_format_date($last_login_date, DATE_FORMAT_SHORT) . '</span>';
1507
+    						return '<span style="color: #F00;">'.api_format_date($last_login_date, DATE_FORMAT_SHORT).'</span>';
1508 1508
     					} else {
1509 1509
     						return api_format_date($last_login_date, DATE_FORMAT_SHORT);
1510 1510
     					}
@@ -1539,7 +1539,7 @@  discard block
 block discarded – undo
1539 1539
         $sql = "$select
1540 1540
                 FROM $tbl_track_login
1541 1541
                 WHERE
1542
-                    login_user_id IN (' ". implode("','", $studentList) . "' ) AND
1542
+                    login_user_id IN (' ".implode("','", $studentList)."' ) AND
1543 1543
                     login_date < '$date'
1544 1544
                 ";
1545 1545
         $rs = Database::query($sql);
@@ -1638,7 +1638,7 @@  discard block
 block discarded – undo
1638 1638
                               '.Display::return_icon('messagebox_warning.gif').'
1639 1639
                              </a>'
1640 1640
                             : null;
1641
-    					return $icon. Display::label($last_login_date, 'warning');
1641
+    					return $icon.Display::label($last_login_date, 'warning');
1642 1642
     				} else {
1643 1643
     					return $last_login_date;
1644 1644
     				}
@@ -1673,8 +1673,8 @@  discard block
 block discarded – undo
1673 1673
 
1674 1674
         // Given we're storing in cache, round the start and end times
1675 1675
         // to the lower minute
1676
-        $roundedStart = substr($start, 0, -2) . '00';
1677
-        $roundedStop = substr($stop, 0, -2) . '00';
1676
+        $roundedStart = substr($start, 0, -2).'00';
1677
+        $roundedStop = substr($stop, 0, -2).'00';
1678 1678
         $roundedStart = Database::escape_string($roundedStart);
1679 1679
         $roundedStop = Database::escape_string($roundedStop);
1680 1680
 
@@ -1684,7 +1684,7 @@  discard block
 block discarded – undo
1684 1684
     	$session_id  = intval($session_id);
1685 1685
     	$count = 0;
1686 1686
         $tbl_track_e_course_access = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1687
-        $sql =  "SELECT count(*) as count_connections
1687
+        $sql = "SELECT count(*) as count_connections
1688 1688
                 FROM $tbl_track_e_course_access
1689 1689
                 WHERE
1690 1690
                     c_id = $courseId AND
@@ -1706,7 +1706,7 @@  discard block
 block discarded – undo
1706 1706
                 $count = apcu_fetch($apc_var);
1707 1707
             } else {
1708 1708
                 $rs = Database::query($sql);
1709
-                if (Database::num_rows($rs)>0) {
1709
+                if (Database::num_rows($rs) > 0) {
1710 1710
                     $row = Database::fetch_object($rs);
1711 1711
                     $count = $row->count_connections;
1712 1712
                 }
@@ -1715,7 +1715,7 @@  discard block
 block discarded – undo
1715 1715
             }
1716 1716
         } else {
1717 1717
             $rs = Database::query($sql);
1718
-            if (Database::num_rows($rs)>0) {
1718
+            if (Database::num_rows($rs) > 0) {
1719 1719
                 $row = Database::fetch_object($rs);
1720 1720
                 $count = $row->count_connections;
1721 1721
             }
@@ -1737,14 +1737,14 @@  discard block
 block discarded – undo
1737 1737
     	$tbl_session_course_rel_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
1738 1738
 
1739 1739
     	$sql = 'SELECT DISTINCT c_id
1740
-                FROM ' . $tbl_course_rel_user . '
1740
+                FROM ' . $tbl_course_rel_user.'
1741 1741
                 WHERE user_id = ' . $user_id.' AND relation_type<>'.COURSE_RELATION_TYPE_RRHH;
1742 1742
     	$rs = Database::query($sql);
1743 1743
     	$nb_courses = Database::num_rows($rs);
1744 1744
 
1745 1745
     	if ($include_sessions) {
1746 1746
     		$sql = 'SELECT DISTINCT c_id
1747
-                    FROM ' . $tbl_session_course_rel_user . '
1747
+                    FROM ' . $tbl_session_course_rel_user.'
1748 1748
                     WHERE user_id = ' . $user_id;
1749 1749
     		$rs = Database::query($sql);
1750 1750
     		$nb_courses += Database::num_rows($rs);
@@ -1791,7 +1791,7 @@  discard block
 block discarded – undo
1791 1791
     		$condition_quiz = "";
1792 1792
     		if (!empty($exercise_id)) {
1793 1793
     			$exercise_id = intval($exercise_id);
1794
-    			$condition_quiz =" AND id = $exercise_id ";
1794
+    			$condition_quiz = " AND id = $exercise_id ";
1795 1795
     		}
1796 1796
 
1797 1797
     		// Compose a filter based on optional session id given
@@ -1840,7 +1840,7 @@  discard block
 block discarded – undo
1840 1840
                         }
1841 1841
                     }
1842 1842
                     if (!empty($exercise_list)) {
1843
-                        $exercise_id = implode("','",$exercise_list);
1843
+                        $exercise_id = implode("','", $exercise_list);
1844 1844
                     }
1845 1845
     			}
1846 1846
 
@@ -1865,10 +1865,10 @@  discard block
 block discarded – undo
1865 1865
     			$quiz_avg_score = null;
1866 1866
 
1867 1867
     			if (!empty($row['avg_score'])) {
1868
-    				$quiz_avg_score = round($row['avg_score'],2);
1868
+    				$quiz_avg_score = round($row['avg_score'], 2);
1869 1869
     			}
1870 1870
 
1871
-    			if(!empty($row['num_attempts'])) {
1871
+    			if (!empty($row['num_attempts'])) {
1872 1872
     				$quiz_avg_score = round($quiz_avg_score / $row['num_attempts'], 2);
1873 1873
     			}
1874 1874
     			if (is_array($student_id)) {
@@ -1998,7 +1998,7 @@  discard block
 block discarded – undo
1998 1998
             $row = Database::fetch_row($rs);
1999 1999
             $count = $row[0];
2000 2000
         }
2001
-        $count = ($count != 0 ) ? 100*round(intval($count)/count($exercise_list), 2) .'%' : '0%';
2001
+        $count = ($count != 0) ? 100 * round(intval($count) / count($exercise_list), 2).'%' : '0%';
2002 2002
         return $count;
2003 2003
     }
2004 2004
 
@@ -2023,7 +2023,7 @@  discard block
 block discarded – undo
2023 2023
                 );
2024 2024
 
2025 2025
                 if (!empty($best_attempt) && !empty($best_attempt['exe_weighting'])) {
2026
-                    $result += $best_attempt['exe_result']/$best_attempt['exe_weighting'];
2026
+                    $result += $best_attempt['exe_result'] / $best_attempt['exe_weighting'];
2027 2027
                 }
2028 2028
             }
2029 2029
             $result = $result / count($exercise_list);
@@ -2060,7 +2060,7 @@  discard block
 block discarded – undo
2060 2060
         $query = sprintf($sql, intval($courseId), $sessionId);
2061 2061
         $rs = Database::query($query);
2062 2062
         $teachers = array();
2063
-        while ($teacher = Database::fetch_array($rs,'ASSOC')) {
2063
+        while ($teacher = Database::fetch_array($rs, 'ASSOC')) {
2064 2064
             $teachers[] = $teacher;
2065 2065
         }
2066 2066
         $data = array();
@@ -2184,7 +2184,7 @@  discard block
 block discarded – undo
2184 2184
             $data[] = array(
2185 2185
                 'course' => $course['title'],
2186 2186
                 'session' => $teacher['name'],
2187
-                'tutor' => $tutor['username'] . ' - ' . $tutor['lastname'] . ' ' . $tutor['firstname'],
2187
+                'tutor' => $tutor['username'].' - '.$tutor['lastname'].' '.$tutor['firstname'],
2188 2188
                 'documents' => $totalDocuments,
2189 2189
                 'links' => $totalLinks,
2190 2190
                 'forums' => $totalForums,
@@ -2247,7 +2247,7 @@  discard block
 block discarded – undo
2247 2247
             for ($i = 0; $i < count($lpIdList); $i++) {
2248 2248
                 $placeHolders[] = '?';
2249 2249
             }
2250
-            $lpConditions['AND id IN(' . implode(', ', $placeHolders) . ') '] = $lpIdList;
2250
+            $lpConditions['AND id IN('.implode(', ', $placeHolders).') '] = $lpIdList;
2251 2251
         }
2252 2252
 
2253 2253
         if ($onlySeriousGame) {
@@ -2267,14 +2267,14 @@  discard block
 block discarded – undo
2267 2267
 
2268 2268
         $conditions = [
2269 2269
             " c_id = {$courseInfo['real_id']} ",
2270
-            " lp_view.lp_id IN(" . implode(', ', $filteredLP) . ") "
2270
+            " lp_view.lp_id IN(".implode(', ', $filteredLP).") "
2271 2271
         ];
2272 2272
 
2273 2273
         $groupBy = 'GROUP BY lp_id';
2274 2274
 
2275 2275
         if (is_array($studentId)) {
2276 2276
             $studentId = array_map('intval', $studentId);
2277
-            $conditions[] = " lp_view.user_id IN (" . implode(',', $studentId) . ")  ";
2277
+            $conditions[] = " lp_view.user_id IN (".implode(',', $studentId).")  ";
2278 2278
 
2279 2279
 
2280 2280
         } else {
@@ -2409,7 +2409,7 @@  discard block
 block discarded – undo
2409 2409
             // Compose a filter based on optional learning paths list given
2410 2410
             $condition_lp = "";
2411 2411
             if (count($lp_ids) > 0) {
2412
-                $condition_lp =" AND id IN(".implode(',',$lp_ids).") ";
2412
+                $condition_lp = " AND id IN(".implode(',', $lp_ids).") ";
2413 2413
             }
2414 2414
 
2415 2415
             // Compose a filter based on optional session id
@@ -2449,9 +2449,9 @@  discard block
 block discarded – undo
2449 2449
             // prepare filter on users
2450 2450
             if (is_array($student_id)) {
2451 2451
                 array_walk($student_id, 'intval');
2452
-                $condition_user1 =" AND user_id IN (".implode(',', $student_id).") ";
2452
+                $condition_user1 = " AND user_id IN (".implode(',', $student_id).") ";
2453 2453
             } else {
2454
-                $condition_user1 =" AND user_id = $student_id ";
2454
+                $condition_user1 = " AND user_id = $student_id ";
2455 2455
             }
2456 2456
 
2457 2457
             if ($count_row_lp > 0 && !empty($student_id)) {
@@ -2494,7 +2494,7 @@  discard block
 block discarded – undo
2494 2494
                                     ORDER BY lp_item_id";
2495 2495
                             $res_lp_item = Database::query($sql);
2496 2496
 
2497
-                            while ($row_lp_item = Database::fetch_array($res_lp_item,'ASSOC')) {
2497
+                            while ($row_lp_item = Database::fetch_array($res_lp_item, 'ASSOC')) {
2498 2498
                                 $my_lp_item_id = $row_lp_item['lp_item_id'];
2499 2499
 
2500 2500
                                 // Getting the most recent attempt
@@ -2517,8 +2517,8 @@  discard block
 block discarded – undo
2517 2517
                                         ORDER BY view_count DESC
2518 2518
                                         LIMIT 1";
2519 2519
                                 $res_lp_item_result = Database::query($sql);
2520
-                                while ($row_max_score = Database::fetch_array($res_lp_item_result,'ASSOC')) {
2521
-                                    $list[]= $row_max_score;
2520
+                                while ($row_max_score = Database::fetch_array($res_lp_item_result, 'ASSOC')) {
2521
+                                    $list[] = $row_max_score;
2522 2522
                                 }
2523 2523
                             }
2524 2524
                         } else {
@@ -2542,8 +2542,8 @@  discard block
 block discarded – undo
2542 2542
                             if ($debug) echo $sql.'<br />';
2543 2543
                             $res_max_score = Database::query($sql);
2544 2544
 
2545
-                            while ($row_max_score = Database::fetch_array($res_max_score,'ASSOC')) {
2546
-                                $list[]= $row_max_score;
2545
+                            while ($row_max_score = Database::fetch_array($res_max_score, 'ASSOC')) {
2546
+                                $list[] = $row_max_score;
2547 2547
                             }
2548 2548
                         }
2549 2549
 
@@ -2558,7 +2558,7 @@  discard block
 block discarded – undo
2558 2558
                             $max_score_item_view = $row_max_score['max_score_item_view'];
2559 2559
                             $score = $row_max_score['score'];
2560 2560
 
2561
-                            if ($debug) echo '<h3>Item Type: ' .$row_max_score['item_type'].'</h3>';
2561
+                            if ($debug) echo '<h3>Item Type: '.$row_max_score['item_type'].'</h3>';
2562 2562
 
2563 2563
                             if ($row_max_score['item_type'] == 'sco') {
2564 2564
                                 /* Check if it is sco (easier to get max_score)
@@ -2576,7 +2576,7 @@  discard block
 block discarded – undo
2576 2576
                                 }
2577 2577
                                 // Avoid division by zero errors
2578 2578
                                 if (!empty($max_score)) {
2579
-                                    $lp_partial_total += $score/$max_score;
2579
+                                    $lp_partial_total += $score / $max_score;
2580 2580
                                 }
2581 2581
                                 if ($debug) echo '<b>$lp_partial_total, $score, $max_score '.$lp_partial_total.' '.$score.' '.$max_score.'</b><br />';
2582 2582
                             } else {
@@ -2600,10 +2600,10 @@  discard block
 block discarded – undo
2600 2600
                                         ORDER BY exe_date DESC
2601 2601
                                         LIMIT 1";
2602 2602
 
2603
-                                if ($debug) echo $sql .'<br />';
2603
+                                if ($debug) echo $sql.'<br />';
2604 2604
                                 $result_last_attempt = Database::query($sql);
2605 2605
                                 $num = Database :: num_rows($result_last_attempt);
2606
-                                if ($num > 0 ) {
2606
+                                if ($num > 0) {
2607 2607
                                     $id_last_attempt = Database :: result($result_last_attempt, 0, 0);
2608 2608
                                     if ($debug) echo $id_last_attempt.'<br />';
2609 2609
 
@@ -2632,13 +2632,13 @@  discard block
 block discarded – undo
2632 2632
                                         $max_score = $row_max_score_bis['maxscore'];
2633 2633
                                     }
2634 2634
                                     if (!empty($max_score) && floatval($max_score) > 0) {
2635
-                                        $lp_partial_total += $score/$max_score;
2635
+                                        $lp_partial_total += $score / $max_score;
2636 2636
                                     }
2637 2637
                                     if ($debug) echo '$lp_partial_total, $score, $max_score <b>'.$lp_partial_total.' '.$score.' '.$max_score.'</b><br />';
2638 2638
                                 }
2639 2639
                             }
2640 2640
 
2641
-                            if (in_array($row_max_score['item_type'], array('quiz','sco'))) {
2641
+                            if (in_array($row_max_score['item_type'], array('quiz', 'sco'))) {
2642 2642
                                 // Normal way
2643 2643
                                 if ($use_max_score[$lp_id]) {
2644 2644
                                     $count_items++;
@@ -2673,8 +2673,8 @@  discard block
 block discarded – undo
2673 2673
                     if ($debug) echo $sql;
2674 2674
                     $result_have_quiz = Database::query($sql);
2675 2675
 
2676
-                    if (Database::num_rows($result_have_quiz) > 0 ) {
2677
-                        $row = Database::fetch_array($result_have_quiz,'ASSOC');
2676
+                    if (Database::num_rows($result_have_quiz) > 0) {
2677
+                        $row = Database::fetch_array($result_have_quiz, 'ASSOC');
2678 2678
                         if (is_numeric($row['count']) && $row['count'] != 0) {
2679 2679
                             $lp_with_quiz++;
2680 2680
                         }
@@ -2686,7 +2686,7 @@  discard block
 block discarded – undo
2686 2686
 
2687 2687
                 if ($lp_with_quiz != 0) {
2688 2688
                     if (!$return_array) {
2689
-                        $score_of_scorm_calculate = round(($global_result/$lp_with_quiz),2);
2689
+                        $score_of_scorm_calculate = round(($global_result / $lp_with_quiz), 2);
2690 2690
                         if ($debug) var_dump($score_of_scorm_calculate);
2691 2691
                         if (empty($lp_ids)) {
2692 2692
                             if ($debug) echo '<h2>All lps fix: '.$score_of_scorm_calculate.'</h2>';
@@ -2760,9 +2760,9 @@  discard block
 block discarded – undo
2760 2760
 
2761 2761
         if (is_array($student_id)) {
2762 2762
             array_walk($student_id, 'intval');
2763
-            $conditions[] =" lp_view.user_id IN (".implode(',', $student_id).") ";
2763
+            $conditions[] = " lp_view.user_id IN (".implode(',', $student_id).") ";
2764 2764
         } else {
2765
-            $conditions[] =" lp_view.user_id = $student_id ";
2765
+            $conditions[] = " lp_view.user_id = $student_id ";
2766 2766
         }
2767 2767
 
2768 2768
         $conditionsToString = implode('AND ', $conditions);
@@ -2786,7 +2786,7 @@  discard block
 block discarded – undo
2786 2786
             return 0;
2787 2787
         }
2788 2788
 
2789
-        return ($row['sum_score'] / $row['sum_max_score'])*100;
2789
+        return ($row['sum_score'] / $row['sum_max_score']) * 100;
2790 2790
 
2791 2791
     }
2792 2792
 
@@ -2816,7 +2816,7 @@  discard block
 block discarded – undo
2816 2816
             // Compose a filter based on optional learning paths list given
2817 2817
             $condition_lp = "";
2818 2818
             if (count($lp_ids) > 0) {
2819
-                $condition_lp =" AND id IN(".implode(',',$lp_ids).") ";
2819
+                $condition_lp = " AND id IN(".implode(',', $lp_ids).") ";
2820 2820
             }
2821 2821
 
2822 2822
             // Compose a filter based on optional session id
@@ -2878,7 +2878,7 @@  discard block
 block discarded – undo
2878 2878
 
2879 2879
         if (!empty($course)) {
2880 2880
 
2881
-            $course_id	 = $course['real_id'];
2881
+            $course_id = $course['real_id'];
2882 2882
 
2883 2883
             $lp_table    = Database :: get_course_table(TABLE_LP_MAIN);
2884 2884
             $t_lpv       = Database :: get_course_table(TABLE_LP_VIEW);
@@ -2892,8 +2892,8 @@  discard block
 block discarded – undo
2892 2892
             // calculates last connection time
2893 2893
             if ($count_row_lp > 0) {
2894 2894
                 $sql = 'SELECT MAX(start_time)
2895
-                        FROM ' . $t_lpiv . ' AS item_view
2896
-                        INNER JOIN ' . $t_lpv . ' AS view
2895
+                        FROM ' . $t_lpiv.' AS item_view
2896
+                        INNER JOIN ' . $t_lpv.' AS view
2897 2897
                             ON item_view.lp_view_id = view.id
2898 2898
                         WHERE
2899 2899
                             item_view.c_id 		= '.$course_id.' AND
@@ -2929,15 +2929,15 @@  discard block
 block discarded – undo
2929 2929
 
2930 2930
         // At first, courses where $coach_id is coach of the course //
2931 2931
         $sql = 'SELECT session_id, c_id
2932
-                FROM ' . $tbl_session_course_user . '
2932
+                FROM ' . $tbl_session_course_user.'
2933 2933
                 WHERE user_id=' . $coach_id.' AND status=2';
2934 2934
 
2935 2935
         if (api_is_multiple_url_enabled()) {
2936
-            $tbl_session_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
2936
+            $tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
2937 2937
             $access_url_id = api_get_current_access_url_id();
2938 2938
             if ($access_url_id != -1) {
2939 2939
                 $sql = 'SELECT scu.session_id, scu.c_id
2940
-                    FROM ' . $tbl_session_course_user . ' scu
2940
+                    FROM ' . $tbl_session_course_user.' scu
2941 2941
                     INNER JOIN '.$tbl_session_rel_access_url.'  sru
2942 2942
                     ON (scu.session_id=sru.session_id)
2943 2943
                     WHERE
@@ -2971,28 +2971,28 @@  discard block
 block discarded – undo
2971 2971
 
2972 2972
         // Then, courses where $coach_id is coach of the session    //
2973 2973
         $sql = 'SELECT session_course_user.user_id
2974
-                FROM ' . $tbl_session_course_user . ' as session_course_user
2974
+                FROM ' . $tbl_session_course_user.' as session_course_user
2975 2975
                 INNER JOIN     '.$tbl_session_user.' sru
2976 2976
                 ON session_course_user.user_id = sru.user_id AND session_course_user.session_id = sru.session_id
2977
-                INNER JOIN ' . $tbl_session_course . ' as session_course
2977
+                INNER JOIN ' . $tbl_session_course.' as session_course
2978 2978
                 ON session_course.c_id = session_course_user.c_id
2979 2979
                 AND session_course_user.session_id = session_course.session_id
2980
-                INNER JOIN ' . $tbl_session . ' as session
2980
+                INNER JOIN ' . $tbl_session.' as session
2981 2981
                 ON session.id = session_course.session_id
2982 2982
                 AND session.id_coach = ' . $coach_id;
2983 2983
         if (api_is_multiple_url_enabled()) {
2984
-            $tbl_session_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
2984
+            $tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
2985 2985
             $access_url_id = api_get_current_access_url_id();
2986
-            if ($access_url_id != -1){
2986
+            if ($access_url_id != -1) {
2987 2987
                 $sql = 'SELECT session_course_user.user_id
2988
-                        FROM ' . $tbl_session_course_user . ' as session_course_user
2988
+                        FROM ' . $tbl_session_course_user.' as session_course_user
2989 2989
                         INNER JOIN     '.$tbl_session_user.' sru
2990 2990
                             ON session_course_user.user_id = sru.user_id AND
2991 2991
                                session_course_user.session_id = sru.session_id
2992
-                        INNER JOIN ' . $tbl_session_course . ' as session_course
2992
+                        INNER JOIN ' . $tbl_session_course.' as session_course
2993 2993
                             ON session_course.c_id = session_course_user.c_id AND
2994 2994
                             session_course_user.session_id = session_course.session_id
2995
-                        INNER JOIN ' . $tbl_session . ' as session
2995
+                        INNER JOIN ' . $tbl_session.' as session
2996 2996
                             ON session.id = session_course.session_id AND
2997 2997
                             session.id_coach = ' . $coach_id.'
2998 2998
                         INNER JOIN '.$tbl_session_rel_access_url.' session_rel_url
@@ -3022,8 +3022,8 @@  discard block
 block discarded – undo
3022 3022
 
3023 3023
         $students = [];
3024 3024
         // At first, courses where $coach_id is coach of the course //
3025
-        $sql = 'SELECT c_id FROM ' . $tbl_session_course_user . '
3026
-                WHERE session_id="' . $id_session . '" AND user_id=' . $coach_id.' AND status=2';
3025
+        $sql = 'SELECT c_id FROM '.$tbl_session_course_user.'
3026
+                WHERE session_id="' . $id_session.'" AND user_id='.$coach_id.' AND status=2';
3027 3027
         $result = Database::query($sql);
3028 3028
 
3029 3029
         while ($a_courses = Database::fetch_array($result)) {
@@ -3033,7 +3033,7 @@  discard block
 block discarded – undo
3033 3033
                     FROM $tbl_session_course_user AS srcru
3034 3034
                     WHERE
3035 3035
                         c_id = '$courseId' AND
3036
-                        session_id = '" . $id_session . "'";
3036
+                        session_id = '".$id_session."'";
3037 3037
             $rs = Database::query($sql);
3038 3038
             while ($row = Database::fetch_array($rs)) {
3039 3039
                 $students[$row['user_id']] = $row['user_id'];
@@ -3041,15 +3041,15 @@  discard block
 block discarded – undo
3041 3041
         }
3042 3042
 
3043 3043
         // Then, courses where $coach_id is coach of the session
3044
-        $sql = 'SELECT id_coach FROM ' . $tbl_session . '
3045
-                WHERE id="' . $id_session.'" AND id_coach="' . $coach_id . '"';
3044
+        $sql = 'SELECT id_coach FROM '.$tbl_session.'
3045
+                WHERE id="' . $id_session.'" AND id_coach="'.$coach_id.'"';
3046 3046
         $result = Database::query($sql);
3047 3047
 
3048 3048
         //He is the session_coach so we select all the users in the session
3049 3049
         if (Database::num_rows($result) > 0) {
3050 3050
             $sql = 'SELECT DISTINCT srcru.user_id
3051
-                    FROM ' . $tbl_session_course_user . ' AS srcru
3052
-                    WHERE session_id="' . $id_session . '"';
3051
+                    FROM ' . $tbl_session_course_user.' AS srcru
3052
+                    WHERE session_id="' . $id_session.'"';
3053 3053
             $result = Database::query($sql);
3054 3054
             while ($row = Database::fetch_array($result)) {
3055 3055
                 $students[$row['user_id']] = $row['user_id'];
@@ -3076,8 +3076,8 @@  discard block
 block discarded – undo
3076 3076
 
3077 3077
         // At first, courses where $coach_id is coach of the course //
3078 3078
 
3079
-        $sql = 'SELECT 1 FROM ' . $tbl_session_course_user . '
3080
-                WHERE user_id=' . $coach_id .' AND status=2';
3079
+        $sql = 'SELECT 1 FROM '.$tbl_session_course_user.'
3080
+                WHERE user_id=' . $coach_id.' AND status=2';
3081 3081
         $result = Database::query($sql);
3082 3082
         if (Database::num_rows($result) > 0) {
3083 3083
             return true;
@@ -3085,12 +3085,12 @@  discard block
 block discarded – undo
3085 3085
 
3086 3086
         // Then, courses where $coach_id is coach of the session
3087 3087
         $sql = 'SELECT session_course_user.user_id
3088
-                FROM ' . $tbl_session_course_user . ' as session_course_user
3089
-                INNER JOIN ' . $tbl_session_course . ' as session_course
3088
+                FROM ' . $tbl_session_course_user.' as session_course_user
3089
+                INNER JOIN ' . $tbl_session_course.' as session_course
3090 3090
                     ON session_course.c_id = session_course_user.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 . '
3093
+                    AND session.id_coach = ' . $coach_id.'
3094 3094
                 WHERE user_id = ' . $student_id;
3095 3095
         $result = Database::query($sql);
3096 3096
         if (Database::num_rows($result) > 0) {
@@ -3122,16 +3122,16 @@  discard block
 block discarded – undo
3122 3122
         // At first, courses where $coach_id is coach of the course.
3123 3123
 
3124 3124
         $sql = 'SELECT DISTINCT c.code
3125
-                FROM ' . $tbl_session_course_user . ' sc
3125
+                FROM ' . $tbl_session_course_user.' sc
3126 3126
                 INNER JOIN '.$tbl_course.' c
3127 3127
                 ON (c.id = sc.c_id)
3128 3128
                 WHERE user_id = ' . $coach_id.' AND status = 2';
3129 3129
 
3130 3130
         if (api_is_multiple_url_enabled()) {
3131 3131
             $access_url_id = api_get_current_access_url_id();
3132
-            if ($access_url_id != -1){
3132
+            if ($access_url_id != -1) {
3133 3133
                 $sql = 'SELECT DISTINCT c.code
3134
-                        FROM ' . $tbl_session_course_user . ' scu
3134
+                        FROM ' . $tbl_session_course_user.' scu
3135 3135
                         INNER JOIN '.$tbl_course.' c
3136 3136
                         ON (c.code = scu.c_id)
3137 3137
                         INNER JOIN '.$tbl_course_rel_access_url.' cru
@@ -3144,7 +3144,7 @@  discard block
 block discarded – undo
3144 3144
         }
3145 3145
 
3146 3146
         if (!empty($id_session)) {
3147
-            $sql .= ' AND session_id=' . $id_session;
3147
+            $sql .= ' AND session_id='.$id_session;
3148 3148
         }
3149 3149
 
3150 3150
         $courseList = array();
@@ -3156,25 +3156,25 @@  discard block
 block discarded – undo
3156 3156
         // Then, courses where $coach_id is coach of the session
3157 3157
 
3158 3158
         $sql = 'SELECT DISTINCT course.code
3159
-                FROM ' . $tbl_session_course . ' as session_course
3160
-                INNER JOIN ' . $tbl_session . ' as session
3159
+                FROM ' . $tbl_session_course.' as session_course
3160
+                INNER JOIN ' . $tbl_session.' as session
3161 3161
                     ON session.id = session_course.session_id
3162
-                    AND session.id_coach = ' . $coach_id . '
3163
-                INNER JOIN ' . $tbl_course . ' as course
3162
+                    AND session.id_coach = ' . $coach_id.'
3163
+                INNER JOIN ' . $tbl_course.' as course
3164 3164
                     ON course.id = session_course.c_id';
3165 3165
 
3166 3166
         if (api_is_multiple_url_enabled()) {
3167 3167
             $tbl_course_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
3168 3168
             $access_url_id = api_get_current_access_url_id();
3169
-            if ($access_url_id != -1){
3169
+            if ($access_url_id != -1) {
3170 3170
                 $sql = 'SELECT DISTINCT c.code
3171
-                    FROM ' . $tbl_session_course . ' as session_course
3171
+                    FROM ' . $tbl_session_course.' as session_course
3172 3172
                     INNER JOIN '.$tbl_course.' c
3173 3173
                     ON (c.id = session_course.c_id)
3174
-                    INNER JOIN ' . $tbl_session . ' as session
3174
+                    INNER JOIN ' . $tbl_session.' as session
3175 3175
                     ON session.id = session_course.session_id
3176
-                        AND session.id_coach = ' . $coach_id . '
3177
-                    INNER JOIN ' . $tbl_course . ' as course
3176
+                        AND session.id_coach = ' . $coach_id.'
3177
+                    INNER JOIN ' . $tbl_course.' as course
3178 3178
                         ON course.id = session_course.c_id
3179 3179
                      INNER JOIN '.$tbl_course_rel_access_url.' course_rel_url
3180 3180
                     ON (course_rel_url.c_id = c.id)';
@@ -3182,12 +3182,12 @@  discard block
 block discarded – undo
3182 3182
         }
3183 3183
 
3184 3184
         if (!empty ($id_session)) {
3185
-            $sql .= ' WHERE session_course.session_id=' . $id_session;
3185
+            $sql .= ' WHERE session_course.session_id='.$id_session;
3186 3186
             if (api_is_multiple_url_enabled())
3187
-            $sql .=  ' AND access_url_id = '.$access_url_id;
3188
-        }  else {
3187
+            $sql .= ' AND access_url_id = '.$access_url_id;
3188
+        } else {
3189 3189
             if (api_is_multiple_url_enabled())
3190
-            $sql .=  ' WHERE access_url_id = '.$access_url_id;
3190
+            $sql .= ' WHERE access_url_id = '.$access_url_id;
3191 3191
         }
3192 3192
 
3193 3193
         $result = Database::query($sql);
@@ -3243,7 +3243,7 @@  discard block
 block discarded – undo
3243 3243
             }
3244 3244
         }
3245 3245
 
3246
-        $tbl_session_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
3246
+        $tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
3247 3247
         $access_url_id = api_get_current_access_url_id();
3248 3248
 
3249 3249
         $sql = "
@@ -3363,7 +3363,7 @@  discard block
 block discarded – undo
3363 3363
             // table definition
3364 3364
             $tbl_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
3365 3365
             $tbl_document = Database :: get_course_table(TABLE_DOCUMENT);
3366
-            $course_id	 = $a_course['real_id'];
3366
+            $course_id = $a_course['real_id'];
3367 3367
             if (is_array($student_id)) {
3368 3368
                 $studentList = array_map('intval', $student_id);
3369 3369
                 $condition_user = " AND ip.insert_user_id IN ('".implode(',', $studentList)."') ";
@@ -3414,7 +3414,7 @@  discard block
 block discarded – undo
3414 3414
         $a_course = CourseManager::get_course_information($course_code);
3415 3415
         if (!empty($a_course)) {
3416 3416
             $course_id = $a_course['real_id'];
3417
-            $conditions[]= " ip.c_id  = $course_id AND pub.c_id  = $course_id ";
3417
+            $conditions[] = " ip.c_id  = $course_id AND pub.c_id  = $course_id ";
3418 3418
         }
3419 3419
 
3420 3420
         // table definition
@@ -3423,14 +3423,14 @@  discard block
 block discarded – undo
3423 3423
 
3424 3424
         if (is_array($student_id)) {
3425 3425
             $studentList = array_map('intval', $student_id);
3426
-            $conditions[]= " ip.insert_user_id IN ('".implode("','", $studentList)."') ";
3426
+            $conditions[] = " ip.insert_user_id IN ('".implode("','", $studentList)."') ";
3427 3427
         } else {
3428 3428
             $student_id = intval($student_id);
3429
-            $conditions[]= " ip.insert_user_id = '$student_id' ";
3429
+            $conditions[] = " ip.insert_user_id = '$student_id' ";
3430 3430
         }
3431 3431
         if (isset($session_id)) {
3432 3432
             $session_id = intval($session_id);
3433
-            $conditions[]= " pub.session_id = $session_id ";
3433
+            $conditions[] = " pub.session_id = $session_id ";
3434 3434
         }
3435 3435
         $conditionToString = implode('AND', $conditions);
3436 3436
 
@@ -3463,8 +3463,8 @@  discard block
 block discarded – undo
3463 3463
         $courseCondition = null;
3464 3464
         $conditions = array();
3465 3465
         if (!empty($courseInfo)) {
3466
-            $course_id	    = $courseInfo['real_id'];
3467
-            $conditions[]= " post.c_id  = $course_id AND forum.c_id = $course_id ";
3466
+            $course_id = $courseInfo['real_id'];
3467
+            $conditions[] = " post.c_id  = $course_id AND forum.c_id = $course_id ";
3468 3468
         }
3469 3469
 
3470 3470
         // Table definition.
@@ -3473,15 +3473,15 @@  discard block
 block discarded – undo
3473 3473
 
3474 3474
         if (is_array($student_id)) {
3475 3475
             $studentList = array_map('intval', $student_id);
3476
-            $conditions[]= " post.poster_id IN ('".implode("','", $studentList)."') ";
3476
+            $conditions[] = " post.poster_id IN ('".implode("','", $studentList)."') ";
3477 3477
         } else {
3478 3478
             $student_id = intval($student_id);
3479
-            $conditions[]= " post.poster_id = '$student_id' ";
3479
+            $conditions[] = " post.poster_id = '$student_id' ";
3480 3480
         }
3481 3481
 
3482 3482
         if (isset($session_id)) {
3483 3483
             $session_id = intval($session_id);
3484
-            $conditions[]= " forum.session_id = $session_id";
3484
+            $conditions[] = " forum.session_id = $session_id";
3485 3485
         }
3486 3486
 
3487 3487
         $conditionsToString = implode('AND ', $conditions);
@@ -3516,7 +3516,7 @@  discard block
 block discarded – undo
3516 3516
             $condition_session = '';
3517 3517
             if (isset($session_id)) {
3518 3518
                 $session_id = intval($session_id);
3519
-                $condition_session = api_get_session_condition($session_id, true,  false, 'f.session_id');
3519
+                $condition_session = api_get_session_condition($session_id, true, false, 'f.session_id');
3520 3520
             }
3521 3521
 
3522 3522
             $course_id = $courseInfo['real_id'];
@@ -3572,7 +3572,7 @@  discard block
 block discarded – undo
3572 3572
         $condition_session = '';
3573 3573
         if (isset($session_id)) {
3574 3574
             $session_id = intval($session_id);
3575
-            $condition_session = ' AND f.session_id = '. $session_id;
3575
+            $condition_session = ' AND f.session_id = '.$session_id;
3576 3576
         }
3577 3577
 
3578 3578
         $groupId = intval($groupId);
@@ -3633,7 +3633,7 @@  discard block
 block discarded – undo
3633 3633
         $condition_session = '';
3634 3634
         if (isset($session_id)) {
3635 3635
              $session_id = intval($session_id);
3636
-             $condition_session = ' AND f.session_id = '. $session_id;
3636
+             $condition_session = ' AND f.session_id = '.$session_id;
3637 3637
         }
3638 3638
 
3639 3639
         $groupId = intval($groupId);
@@ -3712,7 +3712,7 @@  discard block
 block discarded – undo
3712 3712
     {
3713 3713
         $student_id = intval($student_id);
3714 3714
         $courseId = intval($courseId);
3715
-        $session_id    = intval($session_id);
3715
+        $session_id = intval($session_id);
3716 3716
         $date_time  = '';
3717 3717
 
3718 3718
         // table definition
@@ -3781,7 +3781,7 @@  discard block
 block discarded – undo
3781 3781
         $table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
3782 3782
 
3783 3783
         $sql = 'SELECT 1
3784
-                FROM ' . $table . '
3784
+                FROM ' . $table.'
3785 3785
                 WHERE down_user_id = '.$student_id.'
3786 3786
                 AND c_id  = "'.$courseId.'"
3787 3787
                 AND down_session_id = '.$session_id.' ';
@@ -3859,30 +3859,30 @@  discard block
 block discarded – undo
3859 3859
                 '.$inner.'
3860 3860
                 WHERE c.id = '.$courseId.'
3861 3861
                 GROUP BY stats_login.user_id
3862
-                HAVING DATE_SUB( "' . $now . '", INTERVAL '.$since.' DAY) > max_date ';
3862
+                HAVING DATE_SUB( "' . $now.'", INTERVAL '.$since.' DAY) > max_date ';
3863 3863
 
3864 3864
         if ($since == 'never') {
3865 3865
             if (empty($session_id)) {
3866 3866
                 $sql = 'SELECT course_user.user_id
3867
-                        FROM ' . $table_course_rel_user . ' course_user
3868
-                        LEFT JOIN ' . $tbl_track_login . ' stats_login
3867
+                        FROM ' . $table_course_rel_user.' course_user
3868
+                        LEFT JOIN ' . $tbl_track_login.' stats_login
3869 3869
                         ON course_user.user_id = stats_login.user_id AND
3870
-                        relation_type<>' . COURSE_RELATION_TYPE_RRHH . '
3871
-                        INNER JOIN ' . $tableCourse . ' c
3870
+                        relation_type<>' . COURSE_RELATION_TYPE_RRHH.'
3871
+                        INNER JOIN ' . $tableCourse.' c
3872 3872
                         ON (c.id = course_user.c_id)
3873 3873
                         WHERE
3874
-                            course_user.c_id = ' . $courseId . ' AND
3874
+                            course_user.c_id = ' . $courseId.' AND
3875 3875
                             stats_login.login_course_date IS NULL
3876 3876
                         GROUP BY course_user.user_id';
3877 3877
             } else {
3878 3878
                 $sql = 'SELECT session_course_user.user_id
3879 3879
                         FROM '.$tbl_session_course_user.' session_course_user
3880
-                        LEFT JOIN ' . $tbl_track_login . ' stats_login
3880
+                        LEFT JOIN ' . $tbl_track_login.' stats_login
3881 3881
                         ON session_course_user.user_id = stats_login.user_id
3882
-                        INNER JOIN ' . $tableCourse . ' c
3882
+                        INNER JOIN ' . $tableCourse.' c
3883 3883
                         ON (c.id = session_course_user.c_id)
3884 3884
                         WHERE
3885
-                            session_course_user.c_id = ' . $courseId . ' AND
3885
+                            session_course_user.c_id = ' . $courseId.' AND
3886 3886
                             stats_login.login_course_date IS NULL
3887 3887
                         GROUP BY session_course_user.user_id';
3888 3888
 
@@ -3891,7 +3891,7 @@  discard block
 block discarded – undo
3891 3891
 
3892 3892
         $rs = Database::query($sql);
3893 3893
         $inactive_users = array();
3894
-        while($user = Database::fetch_array($rs)) {
3894
+        while ($user = Database::fetch_array($rs)) {
3895 3895
             $inactive_users[] = $user['user_id'];
3896 3896
         }
3897 3897
 
@@ -3913,10 +3913,10 @@  discard block
 block discarded – undo
3913 3913
         $table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
3914 3914
 
3915 3915
         $sql = 'SELECT '.$student_id.'
3916
-                FROM ' . $table . '
3916
+                FROM ' . $table.'
3917 3917
                 WHERE
3918
-                    access_user_id=' . $student_id . ' AND
3919
-                    c_id="' . $courseId . '" AND
3918
+                    access_user_id=' . $student_id.' AND
3919
+                    c_id="' . $courseId.'" AND
3920 3920
                     access_session_id = "'.$session_id.'" ';
3921 3921
 
3922 3922
         $rs = Database::query($sql);
@@ -3934,13 +3934,13 @@  discard block
 block discarded – undo
3934 3934
     {
3935 3935
         $hr_dept_id = intval($hr_dept_id);
3936 3936
         $a_students = array();
3937
-        $tbl_user     = Database :: get_main_table(TABLE_MAIN_USER);
3937
+        $tbl_user = Database :: get_main_table(TABLE_MAIN_USER);
3938 3938
 
3939 3939
         $sql = 'SELECT DISTINCT user_id FROM '.$tbl_user.' as user
3940 3940
                 WHERE hr_dept_id='.$hr_dept_id;
3941 3941
         $rs = Database::query($sql);
3942 3942
 
3943
-        while($user = Database :: fetch_array($rs)) {
3943
+        while ($user = Database :: fetch_array($rs)) {
3944 3944
             $a_students[$user['user_id']] = $user['user_id'];
3945 3945
         }
3946 3946
 
@@ -3965,7 +3965,7 @@  discard block
 block discarded – undo
3965 3965
         $condition_session     = '';
3966 3966
         if (isset($session_id)) {
3967 3967
             $session_id = intval($session_id);
3968
-            $condition_session = ' AND access_session_id = '. $session_id;
3968
+            $condition_session = ' AND access_session_id = '.$session_id;
3969 3969
         }
3970 3970
         $sql = "SELECT
3971 3971
                     access_tool,
@@ -4077,7 +4077,7 @@  discard block
 block discarded – undo
4077 4077
             if (!empty($date_from) && !empty($date_to)) {
4078 4078
                 $fieldStartDate = $fields['start_date'];
4079 4079
                 if (!isset($fields['end_date'])) {
4080
-                    $where .= sprintf(" AND ($fieldStartDate BETWEEN '%s' AND '%s' )", $date_from, $date_to) ;
4080
+                    $where .= sprintf(" AND ($fieldStartDate BETWEEN '%s' AND '%s' )", $date_from, $date_to);
4081 4081
                 } else {
4082 4082
                     $fieldEndDate = $fields['end_date'];
4083 4083
                     $where .= sprintf(" AND fieldStartDate >= '%s'
@@ -4093,12 +4093,12 @@  discard block
 block discarded – undo
4093 4093
                 $where
4094 4094
                 GROUP BY %s";
4095 4095
             $sql = sprintf($sql,
4096
-                $fields['user'],    //user field
4097
-                $tableName,         //FROM
4098
-                $fields['course'],  //course condition
4099
-                $course['real_id'],    //course condition
4100
-                $fields['user'],    //user condition
4101
-                $userId,            //user condition
4096
+                $fields['user'], //user field
4097
+                $tableName, //FROM
4098
+                $fields['course'], //course condition
4099
+                $course['real_id'], //course condition
4100
+                $fields['user'], //user condition
4101
+                $userId, //user condition
4102 4102
                 $fields['user']     //GROUP BY
4103 4103
                 );
4104 4104
             $rs = Database::query($sql);
@@ -4106,7 +4106,7 @@  discard block
 block discarded – undo
4106 4106
             //iterate query
4107 4107
             if (Database::num_rows($rs) > 0) {
4108 4108
                 while ($row = Database::fetch_array($rs)) {
4109
-                    $data[$row['user']] = (isset($data[$row['user']])) ?  $data[$row['user']] + $row[total]: $row['total'];
4109
+                    $data[$row['user']] = (isset($data[$row['user']])) ? $data[$row['user']] + $row[total] : $row['total'];
4110 4110
                 }
4111 4111
             }
4112 4112
         }
@@ -4129,11 +4129,11 @@  discard block
 block discarded – undo
4129 4129
         $courseId = api_get_course_int_id($course_code);
4130 4130
         $data = array();
4131 4131
 
4132
-        $TABLETRACK_DOWNLOADS   = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
4132
+        $TABLETRACK_DOWNLOADS = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
4133 4133
         $condition_session = '';
4134 4134
         if (isset($session_id)) {
4135 4135
             $session_id = intval($session_id);
4136
-            $condition_session = ' AND down_session_id = '. $session_id;
4136
+            $condition_session = ' AND down_session_id = '.$session_id;
4137 4137
         }
4138 4138
         $sql = "SELECT down_doc_path, COUNT(DISTINCT down_user_id), COUNT(down_doc_path) as count_down
4139 4139
                 FROM $TABLETRACK_DOWNLOADS
@@ -4318,7 +4318,7 @@  discard block
 block discarded – undo
4318 4318
 
4319 4319
             $final_course_data = array();
4320 4320
 
4321
-            foreach($my_course_data as $course_id => $value) {
4321
+            foreach ($my_course_data as $course_id => $value) {
4322 4322
                 $final_course_data[$course_id] = $course_list[$course_id];
4323 4323
             }
4324 4324
             $course_in_session[$my_session_id]['course_list'] = $final_course_data;
@@ -4339,7 +4339,7 @@  discard block
 block discarded – undo
4339 4339
                           '.Display::tag('th', get_lang('Course'), array('width'=>'300px')).'
4340 4340
                           '.Display::tag('th', get_lang('TimeSpentInTheCourse'), array('class'=>'head')).'
4341 4341
                           '.Display::tag('th', get_lang('Progress'), array('class'=>'head')).'
4342
-                          '.Display::tag('th', get_lang('Score').Display::return_icon('info3.gif', get_lang('ScormAndLPTestTotalAverage'), array('align' => 'absmiddle', 'hspace' => '3px')),array('class'=>'head')).'
4342
+                          '.Display::tag('th', get_lang('Score').Display::return_icon('info3.gif', get_lang('ScormAndLPTestTotalAverage'), array('align' => 'absmiddle', 'hspace' => '3px')), array('class'=>'head')).'
4343 4343
                           '.Display::tag('th', get_lang('LastConnexion'), array('class'=>'head')).'
4344 4344
                           '.Display::tag('th', get_lang('Details'), array('class'=>'head')).'
4345 4345
                         </tr>';
@@ -4426,7 +4426,7 @@  discard block
 block discarded – undo
4426 4426
             $all_exercise_start_time = array();
4427 4427
 
4428 4428
             foreach ($course_in_session as $my_session_id => $session_data) {
4429
-                $course_list  = $session_data['course_list'];
4429
+                $course_list = $session_data['course_list'];
4430 4430
                 $user_count = count(SessionManager::get_users_by_session($my_session_id));
4431 4431
                 $exercise_graph_name_list = array();
4432 4432
                 //$user_results = array();
@@ -4471,20 +4471,20 @@  discard block
 block discarded – undo
4471 4471
 
4472 4472
                             $score = 0;
4473 4473
                             if (!empty($user_result_data['exe_weighting']) && intval($user_result_data['exe_weighting']) != 0) {
4474
-                                $score = intval($user_result_data['exe_result']/$user_result_data['exe_weighting'] * 100);
4474
+                                $score = intval($user_result_data['exe_result'] / $user_result_data['exe_weighting'] * 100);
4475 4475
                             }
4476 4476
                             $time = api_strtotime($exercise_data['start_time']) ? api_strtotime($exercise_data['start_time'], 'UTC') : 0;
4477 4477
                             $all_exercise_start_time[] = $time;
4478 4478
                             $my_results[] = $score;
4479
-                            if (count($exercise_list)<=10) {
4479
+                            if (count($exercise_list) <= 10) {
4480 4480
                                 $title = cut($course_data['title'], 30)." \n ".cut($exercise_data['title'], 30);
4481
-                                $exercise_graph_name_list[]= $title;
4481
+                                $exercise_graph_name_list[] = $title;
4482 4482
                                 $all_exercise_graph_name_list[] = $title;
4483 4483
                             } else {
4484 4484
                                 // if there are more than 10 results, space becomes difficult to find, so only show the title of the exercise, not the tool
4485 4485
                                 $title = cut($exercise_data['title'], 30);
4486
-                                $exercise_graph_name_list[]= $title;
4487
-                                $all_exercise_graph_name_list[]= $title;
4486
+                                $exercise_graph_name_list[] = $title;
4487
+                                $all_exercise_graph_name_list[] = $title;
4488 4488
                             }
4489 4489
                         }
4490 4490
                     }
@@ -4517,7 +4517,7 @@  discard block
 block discarded – undo
4517 4517
             }
4518 4518
 
4519 4519
             $html .= Display::page_subheader(
4520
-                Display::return_icon('session.png', get_lang('Sessions'), array(), ICON_SIZE_SMALL) . ' ' . get_lang('Sessions')
4520
+                Display::return_icon('session.png', get_lang('Sessions'), array(), ICON_SIZE_SMALL).' '.get_lang('Sessions')
4521 4521
             );
4522 4522
 
4523 4523
             $html .= '<table class="data_table" width="100%">';
@@ -4567,7 +4567,7 @@  discard block
 block discarded – undo
4567 4567
                                 $courseInfo['real_id'],
4568 4568
                                 $my_session_id
4569 4569
                             );
4570
-                            if ($attempts > 1)  {
4570
+                            if ($attempts > 1) {
4571 4571
                                 $answered_exercises++;
4572 4572
                             }
4573 4573
                         }
@@ -4580,7 +4580,7 @@  discard block
 block discarded – undo
4580 4580
                     $all_average += $average;
4581 4581
                 }
4582 4582
 
4583
-                $all_average = $all_average /  count($course_list);
4583
+                $all_average = $all_average / count($course_list);
4584 4584
 
4585 4585
                 if (isset($_GET['session_id']) && $my_session_id == $_GET['session_id']) {
4586 4586
                     $html .= '<tr style="background-color:#FBF09D">';
@@ -4605,31 +4605,31 @@  discard block
 block discarded – undo
4605 4605
                 $html .= '</tr>';
4606 4606
             }
4607 4607
             $html .= '</table><br />';
4608
-            $html .= Display::div($main_session_graph, array('id'=>'session_graph','class'=>'chart-session', 'style'=>'position:relative; text-align: center;') );
4608
+            $html .= Display::div($main_session_graph, array('id'=>'session_graph', 'class'=>'chart-session', 'style'=>'position:relative; text-align: center;'));
4609 4609
 
4610 4610
             // Checking selected session.
4611 4611
 
4612 4612
             if (isset($_GET['session_id'])) {
4613 4613
                 $session_id_from_get = intval($_GET['session_id']);
4614
-                $session_data 	= $course_in_session[$session_id_from_get];
4615
-                $course_list 	= $session_data['course_list'];
4614
+                $session_data = $course_in_session[$session_id_from_get];
4615
+                $course_list = $session_data['course_list'];
4616 4616
 
4617
-                $html .= Display::tag('h3',$session_data['name'].' - '.get_lang('CourseList'));
4617
+                $html .= Display::tag('h3', $session_data['name'].' - '.get_lang('CourseList'));
4618 4618
 
4619 4619
                 $html .= '<table class="data_table" width="100%">';
4620 4620
                 //'.Display::tag('th', get_lang('DoneExercises'),         array('class'=>'head')).'
4621 4621
                 $html .= '
4622 4622
                     <tr>
4623 4623
                       <th width="300px">'.get_lang('Course').'</th>
4624
-                      '.Display::tag('th', get_lang('PublishedExercises'),    	array('class'=>'head')).'
4625
-                      '.Display::tag('th', get_lang('NewExercises'),    		array('class'=>'head')).'
4626
-                      '.Display::tag('th', get_lang('MyAverage'), 				array('class'=>'head')).'
4627
-                      '.Display::tag('th', get_lang('AverageExerciseResult'), 	array('class'=>'head')).'
4628
-                      '.Display::tag('th', get_lang('TimeSpentInTheCourse'),    array('class'=>'head')).'
4629
-                      '.Display::tag('th', get_lang('LPProgress')     ,      	array('class'=>'head')).'
4630
-                      '.Display::tag('th', get_lang('Score').Display::return_icon('info3.gif', get_lang('ScormAndLPTestTotalAverage'), array ('align' => 'absmiddle', 'hspace' => '3px')), array('class'=>'head')).'
4631
-                      '.Display::tag('th', get_lang('LastConnexion'),         	array('class'=>'head')).'
4632
-                      '.Display::tag('th', get_lang('Details'),               	array('class'=>'head')).'
4624
+                      '.Display::tag('th', get_lang('PublishedExercises'), array('class'=>'head')).'
4625
+                      '.Display::tag('th', get_lang('NewExercises'), array('class'=>'head')).'
4626
+                      '.Display::tag('th', get_lang('MyAverage'), array('class'=>'head')).'
4627
+                      '.Display::tag('th', get_lang('AverageExerciseResult'), array('class'=>'head')).'
4628
+                      '.Display::tag('th', get_lang('TimeSpentInTheCourse'), array('class'=>'head')).'
4629
+                      '.Display::tag('th', get_lang('LPProgress'), array('class'=>'head')).'
4630
+                      '.Display::tag('th', get_lang('Score').Display::return_icon('info3.gif', get_lang('ScormAndLPTestTotalAverage'), array('align' => 'absmiddle', 'hspace' => '3px')), array('class'=>'head')).'
4631
+                      '.Display::tag('th', get_lang('LastConnexion'), array('class'=>'head')).'
4632
+                      '.Display::tag('th', get_lang('Details'), array('class'=>'head')).'
4633 4633
                     </tr>';
4634 4634
 
4635 4635
                 foreach ($course_list as $course_data) {
@@ -4645,14 +4645,14 @@  discard block
 block discarded – undo
4645 4645
                         $count_exercises = count($exercises);
4646 4646
                     }
4647 4647
                     $answered_exercises = 0;
4648
-                    foreach($exercises as $exercise_item) {
4648
+                    foreach ($exercises as $exercise_item) {
4649 4649
                         $attempts = Event::count_exercise_attempts_by_user(
4650 4650
                             api_get_user_id(),
4651 4651
                             $exercise_item['id'],
4652 4652
                             $courseId,
4653 4653
                             $session_id_from_get
4654 4654
                         );
4655
-                        if ($attempts > 1)  {
4655
+                        if ($attempts > 1) {
4656 4656
                             $answered_exercises++;
4657 4657
                         }
4658 4658
                     }
@@ -4661,7 +4661,7 @@  discard block
 block discarded – undo
4661 4661
 
4662 4662
                     // Average
4663 4663
                     $average = ExerciseLib::get_average_score_by_course($courseId, $session_id_from_get);
4664
-                    $my_average	= ExerciseLib::get_average_score_by_course_by_user(api_get_user_id(), $courseId, $session_id_from_get);
4664
+                    $my_average = ExerciseLib::get_average_score_by_course_by_user(api_get_user_id(), $courseId, $session_id_from_get);
4665 4665
 
4666 4666
                     $stats_array[$course_code] = array(
4667 4667
                         'exercises' => $count_exercises,
@@ -4731,11 +4731,11 @@  discard block
 block discarded – undo
4731 4731
                     }
4732 4732
                     //Score
4733 4733
                     $html .= Display::tag('td', $percentage_score, array('align'=>'center'));
4734
-                    $html .= Display::tag('td', $last_connection,  array('align'=>'center'));
4734
+                    $html .= Display::tag('td', $last_connection, array('align'=>'center'));
4735 4735
 
4736 4736
                     if ($course_code == $courseCodeFromGet && $_GET['session_id'] == $session_id_from_get) {
4737 4737
                         $details = '<a href="#">';
4738
-                        $details .=Display::return_icon('2rightarrow_na.png', get_lang('Details'));
4738
+                        $details .= Display::return_icon('2rightarrow_na.png', get_lang('Details'));
4739 4739
                     } else {
4740 4740
                         $details = '<a href="'.api_get_self().'?course='.$course_code.'&session_id='.$session_id_from_get.$extra_params.'">';
4741 4741
                         $details .= Display::return_icon('2rightarrow.png', get_lang('Details'));
@@ -4858,7 +4858,7 @@  discard block
 block discarded – undo
4858 4858
                         );
4859 4859
 
4860 4860
                         $latest_attempt_url = '';
4861
-                        $best_score = $position = $percentage_score_result  = '-';
4861
+                        $best_score = $position = $percentage_score_result = '-';
4862 4862
                         $graph = $normal_graph = null;
4863 4863
 
4864 4864
                         // Getting best results
@@ -4894,7 +4894,7 @@  discard block
 block discarded – undo
4894 4894
                                 $percentage_score_result = Display::url(ExerciseLib::show_score($score, $weighting), $latest_attempt_url);
4895 4895
                                 $my_score = 0;
4896 4896
                                 if (!empty($weighting) && intval($weighting) != 0) {
4897
-                                    $my_score = $score/$weighting;
4897
+                                    $my_score = $score / $weighting;
4898 4898
                                 }
4899 4899
                                 //@todo this function slows the page
4900 4900
                                 $position = ExerciseLib::get_exercise_result_ranking($my_score, $exe_id, $exercices['id'], $course_info['code'], $session_id, $user_list);
@@ -4905,14 +4905,14 @@  discard block
 block discarded – undo
4905 4905
                         }
4906 4906
                         $html .= Display::div(
4907 4907
                             $normal_graph,
4908
-                            array('id'=>'main_graph_'.$exercices['id'],'class'=>'dialog', 'style'=>'display:none')
4908
+                            array('id'=>'main_graph_'.$exercices['id'], 'class'=>'dialog', 'style'=>'display:none')
4909 4909
                         );
4910 4910
 
4911 4911
                         if (empty($graph)) {
4912 4912
                             $graph = '-';
4913 4913
                         } else {
4914 4914
                             $graph = Display::url(
4915
-                                '<img src="' . $graph . '" >',
4915
+                                '<img src="'.$graph.'" >',
4916 4916
                                 $normal_graph,
4917 4917
                                 array(
4918 4918
                                     'id' => $exercices['id'],
@@ -4945,7 +4945,7 @@  discard block
 block discarded – undo
4945 4945
 
4946 4946
 
4947 4947
             // LP table results
4948
-            $html .='<table class="data_table">';
4948
+            $html .= '<table class="data_table">';
4949 4949
             $html .= Display::tag('th', get_lang('Learnpaths'), array('class'=>'head', 'style'=>'color:#000'));
4950 4950
             $html .= Display::tag('th', get_lang('LatencyTimeSpent'), array('class'=>'head', 'style'=>'color:#000'));
4951 4951
             $html .= Display::tag('th', get_lang('Progress'), array('class'=>'head', 'style'=>'color:#000'));
@@ -4999,7 +4999,7 @@  discard block
 block discarded – undo
4999 4999
                     if (!empty($last_connection_in_lp)) {
5000 5000
                         $last_connection = api_convert_and_format_date($last_connection_in_lp, DATE_TIME_FORMAT_LONG);
5001 5001
                     }
5002
-                    $html .= Display::tag('td', $last_connection, array('align'=>'center','width'=>'180px'));
5002
+                    $html .= Display::tag('td', $last_connection, array('align'=>'center', 'width'=>'180px'));
5003 5003
                     $html .= "</tr>";
5004 5004
                 }
5005 5005
             } else {
@@ -5009,7 +5009,7 @@  discard block
 block discarded – undo
5009 5009
                         </td>
5010 5010
                       </tr>';
5011 5011
             }
5012
-            $html .='</table>';
5012
+            $html .= '</table>';
5013 5013
         }
5014 5014
 
5015 5015
         return $html;
@@ -5036,7 +5036,7 @@  discard block
 block discarded – undo
5036 5036
         $myData->setSerieDescription('Serie1', get_lang('MyResults'));
5037 5037
         $myData->setSerieDescription('Serie2', get_lang('AverageScore'));
5038 5038
         $myData->setAxisUnit(0, '%');
5039
-        $myData->loadPalette(api_get_path(SYS_CODE_PATH) . 'palettes/pchart/default.color', true);
5039
+        $myData->loadPalette(api_get_path(SYS_CODE_PATH).'palettes/pchart/default.color', true);
5040 5040
         // Cache definition
5041 5041
         $cachePath = api_get_path(SYS_ARCHIVE_PATH);
5042 5042
         $myCache = new pCache(array('CacheFolder' => substr($cachePath, 0, strlen($cachePath) - 1)));
@@ -5044,9 +5044,9 @@  discard block
 block discarded – undo
5044 5044
 
5045 5045
         if ($myCache->isInCache($chartHash)) {
5046 5046
             //if we already created the img
5047
-            $imgPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash;
5047
+            $imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
5048 5048
             $myCache->saveFromCache($chartHash, $imgPath);
5049
-            $imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash;
5049
+            $imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
5050 5050
         } else {
5051 5051
             /* Define width, height and angle */
5052 5052
             $mainWidth = 860;
@@ -5075,7 +5075,7 @@  discard block
 block discarded – undo
5075 5075
             /* Set the default font */
5076 5076
             $myPicture->setFontProperties(
5077 5077
                 array(
5078
-                    'FontName' => api_get_path(SYS_FONTS_PATH) . 'opensans/OpenSans-Regular.ttf',
5078
+                    'FontName' => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf',
5079 5079
                     'FontSize' => 10)
5080 5080
             );
5081 5081
             /* Write the chart title */
@@ -5092,7 +5092,7 @@  discard block
 block discarded – undo
5092 5092
             /* Set the default font */
5093 5093
             $myPicture->setFontProperties(
5094 5094
                 array(
5095
-                    'FontName' => api_get_path(SYS_FONTS_PATH) . 'opensans/OpenSans-Regular.ttf',
5095
+                    'FontName' => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf',
5096 5096
                     'FontSize' => 6
5097 5097
                 )
5098 5098
             );
@@ -5134,7 +5134,7 @@  discard block
 block discarded – undo
5134 5134
             /* Draw the line chart */
5135 5135
             $myPicture->setFontProperties(
5136 5136
                 array(
5137
-                    'FontName' => api_get_path(SYS_FONTS_PATH) . 'opensans/OpenSans-Regular.ttf',
5137
+                    'FontName' => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf',
5138 5138
                     'FontSize' => 10
5139 5139
                 )
5140 5140
             );
@@ -5167,12 +5167,12 @@  discard block
 block discarded – undo
5167 5167
             );
5168 5168
 
5169 5169
             $myCache->writeToCache($chartHash, $myPicture);
5170
-            $imgPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash;
5170
+            $imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
5171 5171
             $myCache->saveFromCache($chartHash, $imgPath);
5172
-            $imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash;
5172
+            $imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
5173 5173
         }
5174 5174
 
5175
-        $html = '<img src="' . $imgPath . '">';
5175
+        $html = '<img src="'.$imgPath.'">';
5176 5176
 
5177 5177
         return $html;
5178 5178
     }
@@ -5193,12 +5193,12 @@  discard block
 block discarded – undo
5193 5193
 
5194 5194
         foreach ($attempts as $attempt) {
5195 5195
             if (api_get_user_id() == $attempt['exe_user_id']) {
5196
-                if ($attempt['exe_weighting'] != 0 ) {
5197
-                    $my_exercise_result_array[]= $attempt['exe_result']/$attempt['exe_weighting'];
5196
+                if ($attempt['exe_weighting'] != 0) {
5197
+                    $my_exercise_result_array[] = $attempt['exe_result'] / $attempt['exe_weighting'];
5198 5198
                 }
5199 5199
             } else {
5200
-                if ($attempt['exe_weighting'] != 0 ) {
5201
-                    $exercise_result[]=  $attempt['exe_result']/$attempt['exe_weighting'];
5200
+                if ($attempt['exe_weighting'] != 0) {
5201
+                    $exercise_result[] = $attempt['exe_result'] / $attempt['exe_weighting'];
5202 5202
                 }
5203 5203
             }
5204 5204
         }
@@ -5207,27 +5207,27 @@  discard block
 block discarded – undo
5207 5207
         rsort($my_exercise_result_array);
5208 5208
         $my_exercise_result = 0;
5209 5209
         if (isset($my_exercise_result_array[0])) {
5210
-            $my_exercise_result = $my_exercise_result_array[0] *100;
5210
+            $my_exercise_result = $my_exercise_result_array[0] * 100;
5211 5211
         }
5212 5212
 
5213 5213
         $max     = 100;
5214
-        $pieces  = 5 ;
5214
+        $pieces  = 5;
5215 5215
         $part    = round($max / $pieces);
5216 5216
         $x_axis = array();
5217 5217
         $final_array = array();
5218 5218
         $my_final_array = array();
5219 5219
 
5220
-        for ($i=1; $i <=$pieces; $i++) {
5220
+        for ($i = 1; $i <= $pieces; $i++) {
5221 5221
             $sum = 1;
5222 5222
             if ($i == 1) {
5223 5223
                 $sum = 0;
5224 5224
             }
5225
-            $min = ($i-1)*$part + $sum;
5226
-            $max = ($i)*$part;
5227
-            $x_axis[]= $min." - ".$max;
5225
+            $min = ($i - 1) * $part + $sum;
5226
+            $max = ($i) * $part;
5227
+            $x_axis[] = $min." - ".$max;
5228 5228
             $count = 0;
5229
-            foreach($exercise_result as $result) {
5230
-                $percentage = $result*100;
5229
+            foreach ($exercise_result as $result) {
5230
+                $percentage = $result * 100;
5231 5231
                 //echo $percentage.' - '.$min.' - '.$max."<br />";
5232 5232
                 if ($percentage >= $min && $percentage <= $max) {
5233 5233
                     //echo ' is > ';
@@ -5235,7 +5235,7 @@  discard block
 block discarded – undo
5235 5235
                 }
5236 5236
             }
5237 5237
             //echo '<br />';
5238
-            $final_array[]= $count;
5238
+            $final_array[] = $count;
5239 5239
 
5240 5240
             if ($my_exercise_result >= $min && $my_exercise_result <= $max) {
5241 5241
                 $my_final_array[] = 1;
@@ -5245,9 +5245,9 @@  discard block
 block discarded – undo
5245 5245
         }
5246 5246
 
5247 5247
         //Fix to remove the data of the user with my data
5248
-        for($i = 0; $i<=count($my_final_array); $i++) {
5248
+        for ($i = 0; $i <= count($my_final_array); $i++) {
5249 5249
             if (!empty($my_final_array[$i])) {
5250
-                $my_final_array[$i] =  $final_array[$i] + 1; //Add my result
5250
+                $my_final_array[$i] = $final_array[$i] + 1; //Add my result
5251 5251
                 $final_array[$i] = 0;
5252 5252
             }
5253 5253
         }
@@ -5257,16 +5257,16 @@  discard block
 block discarded – undo
5257 5257
         $dataSet->addPoints($final_array, 'Serie1');
5258 5258
         $dataSet->addPoints($my_final_array, 'Serie2');
5259 5259
         $dataSet->normalize(100, "%");
5260
-        $dataSet->loadPalette(api_get_path(SYS_CODE_PATH) . 'palettes/pchart/default.color', true);
5260
+        $dataSet->loadPalette(api_get_path(SYS_CODE_PATH).'palettes/pchart/default.color', true);
5261 5261
 
5262 5262
         // Cache definition
5263 5263
         $cachePath = api_get_path(SYS_ARCHIVE_PATH);
5264 5264
         $myCache = new pCache(array('CacheFolder' => substr($cachePath, 0, strlen($cachePath) - 1)));
5265 5265
         $chartHash = $myCache->getHash($dataSet);
5266 5266
         if ($myCache->isInCache($chartHash)) {
5267
-            $imgPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash;
5267
+            $imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
5268 5268
             $myCache->saveFromCache($chartHash, $imgPath);
5269
-            $imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash;
5269
+            $imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
5270 5270
         } else {
5271 5271
             /* Create the pChart object */
5272 5272
             $widthSize = 80;
@@ -5282,7 +5282,7 @@  discard block
 block discarded – undo
5282 5282
             $myPicture->drawRectangle(0, 0, $widthSize - 1, $heightSize - 1, array('R' => 0, 'G' => 0, 'B' => 0));
5283 5283
 
5284 5284
             /* Set the default font */
5285
-            $myPicture->setFontProperties(array('FontName' => api_get_path(SYS_FONTS_PATH) . 'opensans/OpenSans-Regular.ttf', 'FontSize' => $fontSize));
5285
+            $myPicture->setFontProperties(array('FontName' => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf', 'FontSize' => $fontSize));
5286 5286
 
5287 5287
             /* Do not write the chart title */
5288 5288
 
@@ -5346,9 +5346,9 @@  discard block
 block discarded – undo
5346 5346
 
5347 5347
             /* Save and write in cache */
5348 5348
             $myCache->writeToCache($chartHash, $myPicture);
5349
-            $imgPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash;
5349
+            $imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
5350 5350
             $myCache->saveFromCache($chartHash, $imgPath);
5351
-            $imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash;
5351
+            $imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
5352 5352
         }
5353 5353
 
5354 5354
         return $imgPath;
@@ -5368,12 +5368,12 @@  discard block
 block discarded – undo
5368 5368
         }
5369 5369
         foreach ($attempts as $attempt) {
5370 5370
             if (api_get_user_id() == $attempt['exe_user_id']) {
5371
-                if ($attempt['exe_weighting'] != 0 ) {
5372
-                    $my_exercise_result_array[]= $attempt['exe_result']/$attempt['exe_weighting'];
5371
+                if ($attempt['exe_weighting'] != 0) {
5372
+                    $my_exercise_result_array[] = $attempt['exe_result'] / $attempt['exe_weighting'];
5373 5373
                 }
5374 5374
             } else {
5375
-                if ($attempt['exe_weighting'] != 0 ) {
5376
-                    $exercise_result[]=  $attempt['exe_result']/$attempt['exe_weighting'];
5375
+                if ($attempt['exe_weighting'] != 0) {
5376
+                    $exercise_result[] = $attempt['exe_result'] / $attempt['exe_weighting'];
5377 5377
                 }
5378 5378
             }
5379 5379
         }
@@ -5382,32 +5382,32 @@  discard block
 block discarded – undo
5382 5382
         rsort($my_exercise_result_array);
5383 5383
         $my_exercise_result = 0;
5384 5384
         if (isset($my_exercise_result_array[0])) {
5385
-            $my_exercise_result = $my_exercise_result_array[0] *100;
5385
+            $my_exercise_result = $my_exercise_result_array[0] * 100;
5386 5386
         }
5387 5387
 
5388 5388
         $max = 100;
5389
-        $pieces = 5 ;
5389
+        $pieces = 5;
5390 5390
         $part = round($max / $pieces);
5391 5391
         $x_axis = array();
5392 5392
         $final_array = array();
5393 5393
         $my_final_array = array();
5394 5394
 
5395
-        for ($i=1; $i <=$pieces; $i++) {
5395
+        for ($i = 1; $i <= $pieces; $i++) {
5396 5396
             $sum = 1;
5397 5397
             if ($i == 1) {
5398 5398
                 $sum = 0;
5399 5399
             }
5400
-            $min = ($i-1)*$part + $sum;
5401
-            $max = ($i)*$part;
5402
-            $x_axis[]= $min." - ".$max;
5400
+            $min = ($i - 1) * $part + $sum;
5401
+            $max = ($i) * $part;
5402
+            $x_axis[] = $min." - ".$max;
5403 5403
             $count = 0;
5404
-            foreach($exercise_result as $result) {
5405
-                $percentage = $result*100;
5404
+            foreach ($exercise_result as $result) {
5405
+                $percentage = $result * 100;
5406 5406
                 if ($percentage >= $min && $percentage <= $max) {
5407 5407
                     $count++;
5408 5408
                 }
5409 5409
             }
5410
-            $final_array[]= $count;
5410
+            $final_array[] = $count;
5411 5411
 
5412 5412
             if ($my_exercise_result >= $min && $my_exercise_result <= $max) {
5413 5413
                 $my_final_array[] = 1;
@@ -5418,9 +5418,9 @@  discard block
 block discarded – undo
5418 5418
 
5419 5419
         //Fix to remove the data of the user with my data
5420 5420
 
5421
-        for($i = 0; $i<=count($my_final_array); $i++) {
5421
+        for ($i = 0; $i <= count($my_final_array); $i++) {
5422 5422
             if (!empty($my_final_array[$i])) {
5423
-                $my_final_array[$i] =  $final_array[$i] + 1; //Add my result
5423
+                $my_final_array[$i] = $final_array[$i] + 1; //Add my result
5424 5424
                 $final_array[$i] = 0;
5425 5425
             }
5426 5426
         }
@@ -5438,7 +5438,7 @@  discard block
 block discarded – undo
5438 5438
         $dataSet->setXAxisName(get_lang('Score'));
5439 5439
         $dataSet->normalize(100, "%");
5440 5440
 
5441
-        $dataSet->loadPalette(api_get_path(SYS_CODE_PATH) . 'palettes/pchart/default.color', true);
5441
+        $dataSet->loadPalette(api_get_path(SYS_CODE_PATH).'palettes/pchart/default.color', true);
5442 5442
 
5443 5443
         // Cache definition
5444 5444
         $cachePath = api_get_path(SYS_ARCHIVE_PATH);
@@ -5446,9 +5446,9 @@  discard block
 block discarded – undo
5446 5446
         $chartHash = $myCache->getHash($dataSet);
5447 5447
 
5448 5448
         if ($myCache->isInCache($chartHash)) {
5449
-            $imgPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash;
5449
+            $imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
5450 5450
             $myCache->saveFromCache($chartHash, $imgPath);
5451
-            $imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash;
5451
+            $imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
5452 5452
         } else {
5453 5453
             /* Create the pChart object */
5454 5454
             $widthSize = 480;
@@ -5464,7 +5464,7 @@  discard block
 block discarded – undo
5464 5464
             $myPicture->drawRectangle(0, 0, $widthSize - 1, $heightSize - 1, array('R' => 0, 'G' => 0, 'B' => 0));
5465 5465
 
5466 5466
             /* Set the default font */
5467
-            $myPicture->setFontProperties(array('FontName' => api_get_path(SYS_FONTS_PATH) . 'opensans/OpenSans-Regular.ttf', 'FontSize' => 10));
5467
+            $myPicture->setFontProperties(array('FontName' => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf', 'FontSize' => 10));
5468 5468
 
5469 5469
             /* Write the chart title */
5470 5470
             $myPicture->drawText(
@@ -5523,9 +5523,9 @@  discard block
 block discarded – undo
5523 5523
 
5524 5524
             /* Write and save into cache */
5525 5525
             $myCache->writeToCache($chartHash, $myPicture);
5526
-            $imgPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash;
5526
+            $imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
5527 5527
             $myCache->saveFromCache($chartHash, $imgPath);
5528
-            $imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash;
5528
+            $imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
5529 5529
         }
5530 5530
 
5531 5531
         return $imgPath;
@@ -5651,7 +5651,7 @@  discard block
 block discarded – undo
5651 5651
                         $whereSessionParams .= $sessionIdx.',';
5652 5652
                     }
5653 5653
                 }
5654
-                $whereSessionParams = substr($whereSessionParams,0,-1);
5654
+                $whereSessionParams = substr($whereSessionParams, 0, -1);
5655 5655
             }
5656 5656
 
5657 5657
             if (!empty($exerciseId)) {
@@ -5712,7 +5712,7 @@  discard block
 block discarded – undo
5712 5712
                     qq.position = rq.question_order AND
5713 5713
                     ta.question_id = rq.question_id
5714 5714
                 WHERE
5715
-                    te.c_id = $courseIdx ".(empty($whereSessionParams)?'':"AND te.session_id IN ($whereSessionParams)")."
5715
+                    te.c_id = $courseIdx ".(empty($whereSessionParams) ? '' : "AND te.session_id IN ($whereSessionParams)")."
5716 5716
                     AND q.c_id = $courseIdx
5717 5717
                     $where $order $limit";
5718 5718
             $sql_query = vsprintf($sql, $whereParams);
@@ -5760,7 +5760,7 @@  discard block
 block discarded – undo
5760 5760
             // Now fill users data
5761 5761
             $sqlUsers = "SELECT user_id, username, lastname, firstname
5762 5762
                          FROM $tuser
5763
-                         WHERE user_id IN (".implode(',',$userIds).")";
5763
+                         WHERE user_id IN (".implode(',', $userIds).")";
5764 5764
             $resUsers = Database::query($sqlUsers);
5765 5765
             while ($rowUser = Database::fetch_assoc($resUsers)) {
5766 5766
                 $users[$rowUser['user_id']] = $rowUser;
@@ -5856,7 +5856,7 @@  discard block
 block discarded – undo
5856 5856
     	        WHERE
5857 5857
                     track_resource.c_id = $course_id AND
5858 5858
                     track_resource.insert_user_id = user.user_id AND
5859
-                    session_id " .(empty($session_id) ? ' IS NULL ' : " = $session_id ");
5859
+                    session_id ".(empty($session_id) ? ' IS NULL ' : " = $session_id ");
5860 5860
 
5861 5861
     	if (isset($_GET['keyword'])) {
5862 5862
     		$keyword = Database::escape_string(trim($_GET['keyword']));
@@ -5914,7 +5914,7 @@  discard block
 block discarded – undo
5914 5914
                 WHERE
5915 5915
                   track_resource.c_id = $course_id AND
5916 5916
                   track_resource.insert_user_id = user.user_id AND
5917
-                  session_id " .(empty($session_id) ? ' IS NULL ' : " = $session_id ");
5917
+                  session_id ".(empty($session_id) ? ' IS NULL ' : " = $session_id ");
5918 5918
 
5919 5919
     	if (isset($_GET['keyword'])) {
5920 5920
     		$keyword = Database::escape_string(trim($_GET['keyword']));
@@ -6208,7 +6208,7 @@  discard block
 block discarded – undo
6208 6208
     public static function display_additional_profile_fields()
6209 6209
     {
6210 6210
     	// getting all the extra profile fields that are defined by the platform administrator
6211
-    	$extra_fields = UserManager :: get_extra_fields(0,50,5,'ASC');
6211
+    	$extra_fields = UserManager :: get_extra_fields(0, 50, 5, 'ASC');
6212 6212
 
6213 6213
     	// creating the form
6214 6214
     	$return = '<form action="courseLog.php" method="get" name="additional_profile_field_form" id="additional_profile_field_form">';
@@ -6220,8 +6220,8 @@  discard block
 block discarded – undo
6220 6220
     	$extra_fields_to_show = 0;
6221 6221
     	foreach ($extra_fields as $key=>$field) {
6222 6222
     		// show only extra fields that are visible + and can be filtered, added by J.Montoya
6223
-    		if ($field[6]==1 && $field[8] == 1) {
6224
-    			if (isset($_GET['additional_profile_field']) && $field[0] == $_GET['additional_profile_field'] ) {
6223
+    		if ($field[6] == 1 && $field[8] == 1) {
6224
+    			if (isset($_GET['additional_profile_field']) && $field[0] == $_GET['additional_profile_field']) {
6225 6225
     				$selected = 'selected="selected"';
6226 6226
     			} else {
6227 6227
     				$selected = '';
@@ -6233,8 +6233,8 @@  discard block
 block discarded – undo
6233 6233
     	$return .= '</select>';
6234 6234
 
6235 6235
     	// the form elements for the $_GET parameters (because the form is passed through GET
6236
-    	foreach ($_GET as $key=>$value){
6237
-    		if ($key <> 'additional_profile_field')    {
6236
+    	foreach ($_GET as $key=>$value) {
6237
+    		if ($key <> 'additional_profile_field') {
6238 6238
     			$return .= '<input type="hidden" name="'.Security::remove_XSS($key).'" value="'.Security::remove_XSS($value).'" />';
6239 6239
     		}
6240 6240
     	}
@@ -6271,21 +6271,21 @@  discard block
 block discarded – undo
6271 6271
     	$result_extra_field = UserManager::get_extra_field_information($field_id);
6272 6272
 
6273 6273
     	if (!empty($users)) {
6274
-    		if ($result_extra_field['field_type'] == UserManager::USER_FIELD_TYPE_TAG ) {
6275
-    			foreach($users as $user_id) {
6274
+    		if ($result_extra_field['field_type'] == UserManager::USER_FIELD_TYPE_TAG) {
6275
+    			foreach ($users as $user_id) {
6276 6276
     				$user_result = UserManager::get_user_tags($user_id, $field_id);
6277 6277
     				$tag_list = array();
6278
-    				foreach($user_result as $item) {
6278
+    				foreach ($user_result as $item) {
6279 6279
     					$tag_list[] = $item['tag'];
6280 6280
     				}
6281
-    				$return[$user_id][] = implode(', ',$tag_list);
6281
+    				$return[$user_id][] = implode(', ', $tag_list);
6282 6282
     			}
6283 6283
     		} else {
6284 6284
     			$new_user_array = array();
6285 6285
     			foreach ($users as $user_id) {
6286
-    				$new_user_array[]= "'".$user_id."'";
6286
+    				$new_user_array[] = "'".$user_id."'";
6287 6287
     			}
6288
-    			$users = implode(',',$new_user_array);
6288
+    			$users = implode(',', $new_user_array);
6289 6289
                 $extraFieldType = EntityExtraField::USER_FIELD_TYPE;
6290 6290
     			// Selecting only the necessary information NOT ALL the user list
6291 6291
     			$sql = "SELECT user.user_id, v.value
@@ -6300,7 +6300,7 @@  discard block
 block discarded – undo
6300 6300
                             user.user_id IN ($users)";
6301 6301
 
6302 6302
     			$result = Database::query($sql);
6303
-    			while($row = Database::fetch_array($result)) {
6303
+    			while ($row = Database::fetch_array($result)) {
6304 6304
     				// get option value for field type double select by id
6305 6305
     				if (!empty($row['value'])) {
6306 6306
     					if ($result_extra_field['field_type'] ==
@@ -6339,7 +6339,7 @@  discard block
 block discarded – undo
6339 6339
 
6340 6340
     public function sort_users_desc($a, $b)
6341 6341
     {
6342
-    	return strcmp( trim(api_strtolower($b[$_SESSION['tracking_column']])), trim(api_strtolower($a[$_SESSION['tracking_column']])));
6342
+    	return strcmp(trim(api_strtolower($b[$_SESSION['tracking_column']])), trim(api_strtolower($a[$_SESSION['tracking_column']])));
6343 6343
     }
6344 6344
 
6345 6345
     /**
@@ -6374,7 +6374,7 @@  discard block
 block discarded – undo
6374 6374
     	// get all users data from a course for sortable with limit
6375 6375
     	if (is_array($user_ids)) {
6376 6376
     		$user_ids = array_map('intval', $user_ids);
6377
-    		$condition_user = " WHERE user.user_id IN (".implode(',',$user_ids).") ";
6377
+    		$condition_user = " WHERE user.user_id IN (".implode(',', $user_ids).") ";
6378 6378
     	} else {
6379 6379
     		$user_ids = intval($user_ids);
6380 6380
     		$condition_user = " WHERE user.user_id = $user_ids ";
@@ -6382,7 +6382,7 @@  discard block
 block discarded – undo
6382 6382
 
6383 6383
     	if (!empty($_GET['user_keyword'])) {
6384 6384
     		$keyword = trim(Database::escape_string($_GET['user_keyword']));
6385
-    		$condition_user .=  " AND (
6385
+    		$condition_user .= " AND (
6386 6386
                 user.firstname LIKE '%".$keyword."%' OR
6387 6387
                 user.lastname LIKE '%".$keyword."%'  OR
6388 6388
                 user.username LIKE '%".$keyword."%'  OR
@@ -6400,7 +6400,7 @@  discard block
 block discarded – undo
6400 6400
         $invitedUsersCondition = '';
6401 6401
 
6402 6402
         if (!$includeInvitedUsers) {
6403
-            $invitedUsersCondition = " AND user.status != " . INVITEE;
6403
+            $invitedUsersCondition = " AND user.status != ".INVITEE;
6404 6404
         }
6405 6405
 
6406 6406
     	$sql = "SELECT  user.user_id as user_id,
@@ -6411,7 +6411,7 @@  discard block
 block discarded – undo
6411 6411
                 FROM $tbl_user as user $url_table
6412 6412
     	        $condition_user $url_condition $invitedUsersCondition";
6413 6413
 
6414
-    	if (!in_array($direction, array('ASC','DESC'))) {
6414
+    	if (!in_array($direction, array('ASC', 'DESC'))) {
6415 6415
     		$direction = 'ASC';
6416 6416
     	}
6417 6417
 
@@ -6548,7 +6548,7 @@  discard block
 block discarded – undo
6548 6548
     		}
6549 6549
 
6550 6550
             if (empty($session_id)) {
6551
-                $user['survey'] = (isset($survey_user_list[$user['user_id']]) ? $survey_user_list[$user['user_id']] : 0) .' / '.$total_surveys;
6551
+                $user['survey'] = (isset($survey_user_list[$user['user_id']]) ? $survey_user_list[$user['user_id']] : 0).' / '.$total_surveys;
6552 6552
             }
6553 6553
 
6554 6554
     		$user['link'] = '<center>
@@ -6560,37 +6560,37 @@  discard block
 block discarded – undo
6560 6560
     		// store columns in array $users
6561 6561
     		$is_western_name_order = api_is_western_name_order();
6562 6562
             $user_row = array();
6563
-            $user_row[]= $user['official_code']; //0
6563
+            $user_row[] = $user['official_code']; //0
6564 6564
             if ($is_western_name_order) {
6565
-                $user_row[]= $user['firstname'];
6566
-                $user_row[]= $user['lastname'];
6565
+                $user_row[] = $user['firstname'];
6566
+                $user_row[] = $user['lastname'];
6567 6567
             } else {
6568
-                $user_row[]= $user['lastname'];
6569
-                $user_row[]= $user['firstname'];
6568
+                $user_row[] = $user['lastname'];
6569
+                $user_row[] = $user['firstname'];
6570 6570
             }
6571
-            $user_row[]= $user['username'];
6572
-            $user_row[]= $user['time'];
6573
-            $user_row[]= $user['average_progress'];
6574
-            $user_row[]= $user['exercise_progress'];
6575
-            $user_row[]= $user['exercise_average_best_attempt'];
6576
-            $user_row[]= $user['student_score'];
6577
-            $user_row[]= $user['count_assignments'];
6578
-            $user_row[]= $user['count_messages'];
6571
+            $user_row[] = $user['username'];
6572
+            $user_row[] = $user['time'];
6573
+            $user_row[] = $user['average_progress'];
6574
+            $user_row[] = $user['exercise_progress'];
6575
+            $user_row[] = $user['exercise_average_best_attempt'];
6576
+            $user_row[] = $user['student_score'];
6577
+            $user_row[] = $user['count_assignments'];
6578
+            $user_row[] = $user['count_messages'];
6579 6579
 
6580 6580
             $userGroupManager = new UserGroup();
6581 6581
             $user_row[] = $userGroupManager->getLabelsFromNameList($user['user_id'], UserGroup::NORMAL_CLASS);
6582 6582
 
6583 6583
             if (empty($session_id)) {
6584
-                $user_row[]= $user['survey'];
6584
+                $user_row[] = $user['survey'];
6585 6585
             }
6586 6586
 
6587
-            $user_row[]= $user['first_connection'];
6588
-            $user_row[]= $user['last_connection'];
6587
+            $user_row[] = $user['first_connection'];
6588
+            $user_row[] = $user['last_connection'];
6589 6589
             if (isset($_GET['additional_profile_field']) && is_numeric($_GET['additional_profile_field'])) {
6590
-                $user_row[]= $user['additional'];
6590
+                $user_row[] = $user['additional'];
6591 6591
             }
6592 6592
 
6593
-            $user_row[]= $user['link'];
6593
+            $user_row[] = $user['link'];
6594 6594
 
6595 6595
             $users[] = $user_row;
6596 6596
 
@@ -6635,8 +6635,8 @@  discard block
 block discarded – undo
6635 6635
 
6636 6636
     	$track_access_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
6637 6637
     	$tempView = $view;
6638
-    	if(substr($view,0,1) == '1') {
6639
-    		$new_view = substr_replace($view,'0',0,1);
6638
+    	if (substr($view, 0, 1) == '1') {
6639
+    		$new_view = substr_replace($view, '0', 0, 1);
6640 6640
     		echo "
6641 6641
                 <tr>
6642 6642
                     <td valign='top'>
@@ -6669,9 +6669,9 @@  discard block
 block discarded – undo
6669 6669
                 </tr>";
6670 6670
     		$total = 0;
6671 6671
     		if (is_array($results)) {
6672
-    			for($j = 0 ; $j < count($results) ; $j++) {
6672
+    			for ($j = 0; $j < count($results); $j++) {
6673 6673
     				echo "<tr>";
6674
-    				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>";
6674
+    				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>";
6675 6675
     				echo "<td valign='top' align='right' class='content'>".$results[$j][1]."</td>";
6676 6676
     				echo"</tr>";
6677 6677
     				$total = $total + $results[$j][1];
@@ -6688,7 +6688,7 @@  discard block
 block discarded – undo
6688 6688
     		echo "</table>";
6689 6689
     		echo "</td></tr>";
6690 6690
     	} else {
6691
-    		$new_view = substr_replace($view,'1',0,1);
6691
+    		$new_view = substr_replace($view, '1', 0, 1);
6692 6692
     		echo "
6693 6693
                 <tr>
6694 6694
                     <td valign='top'>
@@ -6711,8 +6711,8 @@  discard block
 block discarded – undo
6711 6711
     {
6712 6712
     	global $TBL_TRACK_HOTPOTATOES, $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $dateTimeFormatLong;
6713 6713
         $courseId = api_get_course_int_id($courseCode);
6714
-    	if(substr($view,1,1) == '1') {
6715
-    		$new_view = substr_replace($view,'0',1,1);
6714
+    	if (substr($view, 1, 1) == '1') {
6715
+    		$new_view = substr_replace($view, '0', 1, 1);
6716 6716
     		echo "<tr>
6717 6717
                     <td valign='top'>
6718 6718
                         <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>]
@@ -6754,7 +6754,7 @@  discard block
 block discarded – undo
6754 6754
                 </tr>";
6755 6755
 
6756 6756
     		if (is_array($results)) {
6757
-    			for($i = 0; $i < sizeof($results); $i++) {
6757
+    			for ($i = 0; $i < sizeof($results); $i++) {
6758 6758
     				$display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get());
6759 6759
     				echo "<tr>\n";
6760 6760
     				echo "<td class='content'>".$results[$i][0]."</td>\n";
@@ -6769,8 +6769,8 @@  discard block
 block discarded – undo
6769 6769
 
6770 6770
     		// The Result of Tests
6771 6771
     		if (is_array($hpresults)) {
6772
-    			for($i = 0; $i < sizeof($hpresults); $i++) {
6773
-    				$title = GetQuizName($hpresults[$i][0],'');
6772
+    			for ($i = 0; $i < sizeof($hpresults); $i++) {
6773
+    				$title = GetQuizName($hpresults[$i][0], '');
6774 6774
     				if ($title == '')
6775 6775
     				$title = basename($hpresults[$i][0]);
6776 6776
     				$display_date = api_convert_and_format_date($hpresults[$i][3], null, date_default_timezone_get());
@@ -6796,7 +6796,7 @@  discard block
 block discarded – undo
6796 6796
     		echo "</table>";
6797 6797
     		echo "</td>\n</tr>\n";
6798 6798
     	} else {
6799
-    		$new_view = substr_replace($view,'1',1,1);
6799
+    		$new_view = substr_replace($view, '1', 1, 1);
6800 6800
     		echo "
6801 6801
                 <tr>
6802 6802
                     <td valign='top'>
@@ -6815,8 +6815,8 @@  discard block
 block discarded – undo
6815 6815
     	global $TABLETRACK_UPLOADS, $TABLECOURSE_WORK;
6816 6816
         $_course = api_get_course_info_by_id($course_id);
6817 6817
 
6818
-    	if (substr($view,2,1) == '1') {
6819
-    		$new_view = substr_replace($view,'0',2,1);
6818
+    	if (substr($view, 2, 1) == '1') {
6819
+    		$new_view = substr_replace($view, '0', 2, 1);
6820 6820
     		echo "<tr>
6821 6821
                     <td valign='top'>
6822 6822
                     <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>]
@@ -6830,7 +6830,7 @@  discard block
 block discarded – undo
6830 6830
                         AND u.c_id = '".intval($course_id)."'
6831 6831
                     ORDER BY u.upload_date DESC";
6832 6832
     		echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6833
-    		$results = StatsUtils::getManyResultsXCol($sql,4);
6833
+    		$results = StatsUtils::getManyResultsXCol($sql, 4);
6834 6834
     		echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
6835 6835
     		echo "<tr>
6836 6836
                     <td class='secLine' width='40%'>
@@ -6844,7 +6844,7 @@  discard block
 block discarded – undo
6844 6844
                     </td>
6845 6845
                 </tr>";
6846 6846
     		if (is_array($results)) {
6847
-    			for($j = 0 ; $j < count($results) ; $j++) {
6847
+    			for ($j = 0; $j < count($results); $j++) {
6848 6848
     				$pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3];
6849 6849
     				$beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get());
6850 6850
     				echo "<tr>";
@@ -6863,7 +6863,7 @@  discard block
 block discarded – undo
6863 6863
     		echo "</table>";
6864 6864
     		echo "</td></tr>";
6865 6865
     	} else {
6866
-    		$new_view = substr_replace($view,'1',2,1);
6866
+    		$new_view = substr_replace($view, '1', 2, 1);
6867 6867
     		echo "
6868 6868
                 <tr>
6869 6869
                     <td valign='top'>
@@ -6882,8 +6882,8 @@  discard block
 block discarded – undo
6882 6882
     {
6883 6883
     	global $TABLETRACK_LINKS, $TABLECOURSE_LINKS;
6884 6884
         $courseId = api_get_course_int_id($courseCode);
6885
-    	if (substr($view,3,1) == '1') {
6886
-    		$new_view = substr_replace($view,'0',3,1);
6885
+    	if (substr($view, 3, 1) == '1') {
6886
+    		$new_view = substr_replace($view, '0', 3, 1);
6887 6887
     		echo "
6888 6888
                 <tr>
6889 6889
                         <td valign='top'>
@@ -6907,7 +6907,7 @@  discard block
 block discarded – undo
6907 6907
                     </td>
6908 6908
                 </tr>";
6909 6909
     		if (is_array($results)) {
6910
-    			for($j = 0 ; $j < count($results) ; $j++) {
6910
+    			for ($j = 0; $j < count($results); $j++) {
6911 6911
     				echo "<tr>";
6912 6912
     				echo "<td class='content'><a href='".$results[$j][1]."'>".$results[$j][0]."</a></td>";
6913 6913
     				echo"</tr>";
@@ -6920,7 +6920,7 @@  discard block
 block discarded – undo
6920 6920
     		echo "</table>";
6921 6921
     		echo "</td></tr>";
6922 6922
     	} else {
6923
-    		$new_view = substr_replace($view,'1',3,1);
6923
+    		$new_view = substr_replace($view, '1', 3, 1);
6924 6924
     		echo "
6925 6925
                 <tr>
6926 6926
                     <td valign='top'>
@@ -6947,8 +6947,8 @@  discard block
 block discarded – undo
6947 6947
     	$session_id = intval($session_id);
6948 6948
 
6949 6949
     	$downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
6950
-    	if(substr($view,4,1) == '1') {
6951
-    		$new_view = substr_replace($view,'0',4,1);
6950
+    	if (substr($view, 4, 1) == '1') {
6951
+    		$new_view = substr_replace($view, '0', 4, 1);
6952 6952
     		echo "
6953 6953
                 <tr>
6954 6954
                     <td valign='top'>
@@ -6974,7 +6974,7 @@  discard block
 block discarded – undo
6974 6974
                     </td>
6975 6975
                 </tr>";
6976 6976
     		if (is_array($results)) {
6977
-    			for($j = 0 ; $j < count($results) ; $j++) {
6977
+    			for ($j = 0; $j < count($results); $j++) {
6978 6978
     				echo "<tr>";
6979 6979
     				echo "<td class='content'>".$results[$j]."</td>";
6980 6980
     				echo"</tr>";
@@ -6987,7 +6987,7 @@  discard block
 block discarded – undo
6987 6987
     		echo "</table>";
6988 6988
     		echo "</td></tr>";
6989 6989
     	} else {
6990
-    		$new_view = substr_replace($view,'1',4,1);
6990
+    		$new_view = substr_replace($view, '1', 4, 1);
6991 6991
     		echo "
6992 6992
                 <tr>
6993 6993
                     <td valign='top'>
@@ -7021,11 +7021,11 @@  discard block
 block discarded – undo
7021 7021
                    ORDER BY login_date DESC LIMIT 1";
7022 7022
         $ip = '';
7023 7023
         $res_ip = Database::query($sql_ip);
7024
-        if ($res_ip !== false && Database::num_rows($res_ip)>0) {
7024
+        if ($res_ip !== false && Database::num_rows($res_ip) > 0) {
7025 7025
             $row_ip = Database::fetch_row($res_ip);
7026 7026
             if ($return_as_link) {
7027 7027
                 $ip = Display::url(
7028
-                    (empty($body_replace)?$row_ip[1]:$body_replace), 'http://www.whatsmyip.org/ip-geo-location/?ip='.$row_ip[1],
7028
+                    (empty($body_replace) ? $row_ip[1] : $body_replace), 'http://www.whatsmyip.org/ip-geo-location/?ip='.$row_ip[1],
7029 7029
                     array('title'=>get_lang('TraceIP'), 'target'=>'_blank')
7030 7030
                 );
7031 7031
             } else {
@@ -7061,9 +7061,9 @@  discard block
 block discarded – undo
7061 7061
     	$course_id  = intval($course_id);
7062 7062
 
7063 7063
     	$tempView = $view;
7064
-    	if (substr($view,0,1) == '1') {
7065
-    		$new_view = substr_replace($view,'0',0,1);
7066
-    		$title[1]= get_lang('LoginsAndAccessTools').get_lang('LoginsDetails');
7064
+    	if (substr($view, 0, 1) == '1') {
7065
+    		$new_view = substr_replace($view, '0', 0, 1);
7066
+    		$title[1] = get_lang('LoginsAndAccessTools').get_lang('LoginsDetails');
7067 7067
     		$sql = "SELECT UNIX_TIMESTAMP(access_date), count(access_date)
7068 7068
                     FROM $track_access_table
7069 7069
                     WHERE access_user_id = $user_id
@@ -7073,20 +7073,20 @@  discard block
 block discarded – undo
7073 7073
                     ORDER BY YEAR(access_date),MONTH(access_date) ASC";
7074 7074
     		//$results = getManyResults2Col($sql);
7075 7075
     		$results = getManyResults3Col($sql);
7076
-    		$title_line= get_lang('LoginsTitleMonthColumn').';'.get_lang('LoginsTitleCountColumn')."\n";
7077
-    		$line='';
7076
+    		$title_line = get_lang('LoginsTitleMonthColumn').';'.get_lang('LoginsTitleCountColumn')."\n";
7077
+    		$line = '';
7078 7078
     		$total = 0;
7079 7079
     		if (is_array($results)) {
7080
-    			for($j = 0 ; $j < count($results) ; $j++) {
7080
+    			for ($j = 0; $j < count($results); $j++) {
7081 7081
     				$line .= $results[$j][0].';'.$results[$j][1]."\n";
7082 7082
     				$total = $total + $results[$j][1];
7083 7083
     			}
7084 7084
     			$line .= get_lang('Total').";".$total."\n";
7085 7085
     		} else {
7086
-    			$line= get_lang('NoResult')."</center></td>";
7086
+    			$line = get_lang('NoResult')."</center></td>";
7087 7087
     		}
7088 7088
     	} else {
7089
-    		$new_view = substr_replace($view,'1',0,1);
7089
+    		$new_view = substr_replace($view, '1', 0, 1);
7090 7090
     	}
7091 7091
     	return array($title_line, $line);
7092 7092
     }
@@ -7104,8 +7104,8 @@  discard block
 block discarded – undo
7104 7104
     	global $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $TABLETRACK_HOTPOTATOES, $dateTimeFormatLong;
7105 7105
         $courseId = api_get_course_int_id($courseCode);
7106 7106
         $userId = intval($userId);
7107
-    	if (substr($view,1,1) == '1') {
7108
-    		$new_view = substr_replace($view,'0',1,1);
7107
+    	if (substr($view, 1, 1) == '1') {
7108
+    		$new_view = substr_replace($view, '0', 1, 1);
7109 7109
     		$title[1] = get_lang('ExercicesDetails');
7110 7110
     		$line = '';
7111 7111
     		$sql = "SELECT ce.title, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
@@ -7129,7 +7129,7 @@  discard block
 block discarded – undo
7129 7129
     		$title_line = get_lang('ExercicesTitleExerciceColumn').";".get_lang('Date').';'.get_lang('ExercicesTitleScoreColumn')."\n";
7130 7130
 
7131 7131
     		if (is_array($results)) {
7132
-    			for($i = 0; $i < sizeof($results); $i++)
7132
+    			for ($i = 0; $i < sizeof($results); $i++)
7133 7133
     			{
7134 7134
     				$display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get());
7135 7135
     				$line .= $results[$i][0].";".$display_date.";".$results[$i][1]." / ".$results[$i][2]."\n";
@@ -7141,8 +7141,8 @@  discard block
 block discarded – undo
7141 7141
 
7142 7142
     		// The Result of Tests
7143 7143
     		if (is_array($hpresults)) {
7144
-    			for($i = 0; $i < sizeof($hpresults); $i++) {
7145
-    				$title = GetQuizName($hpresults[$i][0],'');
7144
+    			for ($i = 0; $i < sizeof($hpresults); $i++) {
7145
+    				$title = GetQuizName($hpresults[$i][0], '');
7146 7146
 
7147 7147
     				if ($title == '')
7148 7148
     				$title = basename($hpresults[$i][0]);
@@ -7156,10 +7156,10 @@  discard block
 block discarded – undo
7156 7156
     		}
7157 7157
 
7158 7158
     		if ($NoTestRes == 1 && $NoHPTestRes == 1) {
7159
-    			$line=get_lang('NoResult');
7159
+    			$line = get_lang('NoResult');
7160 7160
     		}
7161 7161
     	} else {
7162
-    		$new_view = substr_replace($view,'1',1,1);
7162
+    		$new_view = substr_replace($view, '1', 1, 1);
7163 7163
     	}
7164 7164
     	return array($title_line, $line);
7165 7165
     }
@@ -7175,7 +7175,7 @@  discard block
 block discarded – undo
7175 7175
         $user_id = intval($user_id);
7176 7176
         $course_id = intval($course_id);
7177 7177
 
7178
-    	if (substr($view,2,1) == '1') {
7178
+    	if (substr($view, 2, 1) == '1') {
7179 7179
     		$sql = "SELECT u.upload_date, w.title, w.author, w.url
7180 7180
                     FROM $TABLETRACK_UPLOADS u , $TABLECOURSE_WORK w
7181 7181
                     WHERE
@@ -7183,21 +7183,21 @@  discard block
 block discarded – undo
7183 7183
                         u.upload_user_id = '$user_id' AND
7184 7184
                         u.c_id = '$course_id'
7185 7185
                     ORDER BY u.upload_date DESC";
7186
-    		$results = StatsUtils::getManyResultsXCol($sql,4);
7186
+    		$results = StatsUtils::getManyResultsXCol($sql, 4);
7187 7187
 
7188
-    		$title[1]=get_lang('WorksDetails');
7189
-    		$line='';
7190
-    		$title_line=get_lang('WorkTitle').";".get_lang('WorkAuthors').";".get_lang('Date')."\n";
7188
+    		$title[1] = get_lang('WorksDetails');
7189
+    		$line = '';
7190
+    		$title_line = get_lang('WorkTitle').";".get_lang('WorkAuthors').";".get_lang('Date')."\n";
7191 7191
 
7192 7192
     		if (is_array($results)) {
7193
-    			for($j = 0 ; $j < count($results) ; $j++) {
7193
+    			for ($j = 0; $j < count($results); $j++) {
7194 7194
     				$pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3];
7195 7195
     				$beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get());
7196 7196
     				$line .= $results[$j][1].";".$results[$j][2].";".$beautifulDate."\n";
7197 7197
     			}
7198 7198
 
7199 7199
     		} else {
7200
-    			$line= get_lang('NoResult');
7200
+    			$line = get_lang('NoResult');
7201 7201
     		}
7202 7202
     	}
7203 7203
     	return array($title_line, $line);
@@ -7213,9 +7213,9 @@  discard block
 block discarded – undo
7213 7213
         $courseId = api_get_course_int_id($courseCode);
7214 7214
         $userId = intval($userId);
7215 7215
         $line = null;
7216
-    	if (substr($view,3,1) == '1') {
7217
-    		$new_view = substr_replace($view,'0',3,1);
7218
-    		$title[1]=get_lang('LinksDetails');
7216
+    	if (substr($view, 3, 1) == '1') {
7217
+    		$new_view = substr_replace($view, '0', 3, 1);
7218
+    		$title[1] = get_lang('LinksDetails');
7219 7219
     		$sql = "SELECT cl.title, cl.url
7220 7220
                         FROM $TABLETRACK_LINKS AS sl, $TABLECOURSE_LINKS AS cl
7221 7221
                         WHERE sl.links_link_id = cl.id
@@ -7223,16 +7223,16 @@  discard block
 block discarded – undo
7223 7223
                             AND sl.links_user_id = $userId
7224 7224
                         GROUP BY cl.title, cl.url";
7225 7225
     		$results = StatsUtils::getManyResults2Col($sql);
7226
-    		$title_line= get_lang('LinksTitleLinkColumn')."\n";
7226
+    		$title_line = get_lang('LinksTitleLinkColumn')."\n";
7227 7227
     		if (is_array($results)) {
7228
-    			for ($j = 0 ; $j < count($results) ; $j++) {
7228
+    			for ($j = 0; $j < count($results); $j++) {
7229 7229
     				$line .= $results[$j][0]."\n";
7230 7230
     			}
7231 7231
     		} else {
7232
-    			$line=get_lang('NoResult');
7232
+    			$line = get_lang('NoResult');
7233 7233
     		}
7234 7234
     	} else {
7235
-    		$new_view = substr_replace($view,'1',3,1);
7235
+    		$new_view = substr_replace($view, '1', 3, 1);
7236 7236
     	}
7237 7237
     	return array($title_line, $line);
7238 7238
     }
@@ -7254,9 +7254,9 @@  discard block
 block discarded – undo
7254 7254
 
7255 7255
     	$downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
7256 7256
 
7257
-    	if (substr($view,4,1) == '1') {
7258
-    		$new_view = substr_replace($view,'0',4,1);
7259
-    		$title[1]= get_lang('DocumentsDetails');
7257
+    	if (substr($view, 4, 1) == '1') {
7258
+    		$new_view = substr_replace($view, '0', 4, 1);
7259
+    		$title[1] = get_lang('DocumentsDetails');
7260 7260
 
7261 7261
     		$sql = "SELECT down_doc_path
7262 7262
                         FROM $downloads_table
@@ -7269,14 +7269,14 @@  discard block
 block discarded – undo
7269 7269
     		$title_line = get_lang('DocumentsTitleDocumentColumn')."\n";
7270 7270
             $line = null;
7271 7271
     		if (is_array($results)) {
7272
-    			for ($j = 0 ; $j < count($results) ; $j++) {
7272
+    			for ($j = 0; $j < count($results); $j++) {
7273 7273
     				$line .= $results[$j]."\n";
7274 7274
     			}
7275 7275
     		} else {
7276 7276
     			$line = get_lang('NoResult');
7277 7277
     		}
7278 7278
     	} else {
7279
-    		$new_view = substr_replace($view,'1',4,1);
7279
+    		$new_view = substr_replace($view, '1', 4, 1);
7280 7280
     	}
7281 7281
     	return array($title_line, $line);
7282 7282
     }
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)."',
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
         $sql = "DELETE FROM $tableUser WHERE access_url_id = ".$id;
93 93
         $result = Database::query($sql);
94 94
 
95
-        $sql= "DELETE FROM $table WHERE id = ".$id;
95
+        $sql = "DELETE FROM $table WHERE id = ".$id;
96 96
         $result = Database::query($sql);
97 97
 
98 98
         return $result;
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
      */
106 106
     public static function url_exist($url)
107 107
     {
108
-        $table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
108
+        $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
109 109
         $sql = "SELECT id FROM $table
110 110
                 WHERE url = '".Database::escape_string($url)."' ";
111 111
         $res = Database::query($sql);
@@ -139,10 +139,10 @@  discard block
 block discarded – undo
139 139
      * */
140 140
     public static function url_count()
141 141
     {
142
-        $table_access_url= Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
142
+        $table_access_url = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
143 143
         $sql = "SELECT count(id) as count_result FROM $table_access_url";
144 144
         $res = Database::query($sql);
145
-        $url = Database::fetch_array($res,'ASSOC');
145
+        $url = Database::fetch_array($res, 'ASSOC');
146 146
         $result = $url['count_result'];
147 147
 
148 148
         return $result;
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
                 FROM $table
161 161
                 ORDER BY id";
162 162
         $res = Database::query($sql);
163
-        $urls = array ();
163
+        $urls = array();
164 164
         while ($url = Database::fetch_array($res)) {
165 165
             $urls[] = $url;
166 166
         }
@@ -277,12 +277,12 @@  discard block
 block discarded – undo
277 277
      **/
278 278
     public static function get_url_rel_session_data($access_url_id = null)
279 279
     {
280
-        $where ='';
280
+        $where = '';
281 281
         $table_url_rel_session = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
282 282
         $tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION);
283 283
 
284 284
         if (!empty($access_url_id))
285
-            $where ="WHERE $table_url_rel_session.access_url_id = ".intval($access_url_id);
285
+            $where = "WHERE $table_url_rel_session.access_url_id = ".intval($access_url_id);
286 286
 
287 287
         $sql = "SELECT id, name, access_url_id
288 288
                 FROM $tbl_session u
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
         $table_user_group = Database::get_main_table(TABLE_USERGROUP);
313 313
 
314 314
         if (!empty($access_url_id)) {
315
-            $where ="WHERE $table_url_rel_usergroup.access_url_id = ".intval($access_url_id);
315
+            $where = "WHERE $table_url_rel_usergroup.access_url_id = ".intval($access_url_id);
316 316
         }
317 317
 
318 318
         $sql = "SELECT u.id, u.name, access_url_id
@@ -390,7 +390,7 @@  discard block
 block discarded – undo
390 390
     public static function relation_url_user_exist($user_id, $url_id)
391 391
     {
392 392
         $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
393
-        $sql= "SELECT user_id FROM $table
393
+        $sql = "SELECT user_id FROM $table
394 394
                WHERE access_url_id = ".intval($url_id)." AND user_id = ".intval($user_id)." ";
395 395
         $result = Database::query($sql);
396 396
         $num = Database::num_rows($result);
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
     public static function relation_url_course_exist($courseId, $urlId)
409 409
     {
410 410
         $table_url_rel_course = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
411
-        $sql= "SELECT c_id FROM $table_url_rel_course
411
+        $sql = "SELECT c_id FROM $table_url_rel_course
412 412
                WHERE
413 413
                     access_url_id = ".intval($urlId)." AND
414 414
                     c_id = '".intval($courseId)."'";
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
     public static function relationUrlUsergroupExist($userGroupId, $urlId)
430 430
     {
431 431
         $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USERGROUP);
432
-        $sql= "SELECT usergroup_id FROM $table
432
+        $sql = "SELECT usergroup_id FROM $table
433 433
                WHERE access_url_id = ".intval($urlId)." AND
434 434
                      usergroup_id = ".intval($userGroupId);
435 435
         $result = Database::query($sql);
@@ -447,9 +447,9 @@  discard block
 block discarded – undo
447 447
     * */
448 448
     public static function relation_url_session_exist($session_id, $url_id)
449 449
     {
450
-        $table_url_rel_session= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
450
+        $table_url_rel_session = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
451 451
         $session_id = intval($session_id);
452
-        $url_id		= intval($url_id);
452
+        $url_id = intval($url_id);
453 453
         $sql = "SELECT session_id FROM $table_url_rel_session
454 454
                 WHERE
455 455
                     access_url_id = ".intval($url_id)." AND
@@ -472,11 +472,11 @@  discard block
 block discarded – undo
472 472
         $table_url_rel_user = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
473 473
         $result_array = array();
474 474
 
475
-        if (is_array($user_list) && is_array($url_list)){
475
+        if (is_array($user_list) && is_array($url_list)) {
476 476
             foreach ($url_list as $url_id) {
477 477
                 foreach ($user_list as $user_id) {
478
-                    $count = UrlManager::relation_url_user_exist($user_id,$url_id);
479
-                    if ($count==0) {
478
+                    $count = UrlManager::relation_url_user_exist($user_id, $url_id);
479
+                    if ($count == 0) {
480 480
                         $sql = "INSERT INTO $table_url_rel_user
481 481
                                 SET user_id = ".intval($user_id).", access_url_id = ".intval($url_id);
482 482
                         $result = Database::query($sql);
@@ -501,19 +501,19 @@  discard block
 block discarded – undo
501 501
      * @param  array of url_ids
502 502
      * @return array
503 503
      **/
504
-    public static function add_courses_to_urls($course_list,$url_list)
504
+    public static function add_courses_to_urls($course_list, $url_list)
505 505
     {
506 506
         $table_url_rel_course = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
507 507
         $result_array = array();
508 508
 
509
-        if (is_array($course_list) && is_array($url_list)){
509
+        if (is_array($course_list) && is_array($url_list)) {
510 510
             foreach ($url_list as $url_id) {
511 511
                 foreach ($course_list as $course_code) {
512 512
                     $courseInfo = api_get_course_info($course_code);
513 513
                     $courseId = $courseInfo['real_id'];
514 514
 
515 515
                     $count = self::relation_url_course_exist($courseId, $url_id);
516
-                    if ($count==0) {
516
+                    if ($count == 0) {
517 517
                         $sql = "INSERT INTO $table_url_rel_course
518 518
                                 SET c_id = '".$courseId."', access_url_id = ".intval($url_id);
519 519
                         $result = Database::query($sql);
@@ -599,7 +599,7 @@  discard block
 block discarded – undo
599 599
     public static function relationUrlCourseCategoryExist($categoryCourseId, $urlId)
600 600
     {
601 601
         $table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE_CATEGORY);
602
-        $sql= "SELECT course_category_id FROM $table
602
+        $sql = "SELECT course_category_id FROM $table
603 603
                WHERE access_url_id = ".intval($urlId)." AND
604 604
                      course_category_id = ".intval($categoryCourseId);
605 605
         $result = Database::query($sql);
@@ -768,7 +768,7 @@  discard block
 block discarded – undo
768 768
         $table_url_rel_user = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
769 769
         $result = true;
770 770
         if (!empty($user_id) && !empty($url_id)) {
771
-            $sql= "DELETE FROM $table_url_rel_user
771
+            $sql = "DELETE FROM $table_url_rel_user
772 772
                    WHERE user_id = ".intval($user_id)." AND access_url_id = ".intval($url_id);
773 773
             $result = Database::query($sql);
774 774
         }
@@ -788,7 +788,7 @@  discard block
 block discarded – undo
788 788
         $table_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
789 789
         $result = true;
790 790
         if (!empty($userId)) {
791
-            $sql= "DELETE FROM $table_url_rel_user
791
+            $sql = "DELETE FROM $table_url_rel_user
792 792
                    WHERE user_id = ".intval($userId);
793 793
             Database::query($sql);
794 794
         }
@@ -806,8 +806,8 @@  discard block
 block discarded – undo
806 806
     * */
807 807
     public static function delete_url_rel_course($courseId, $urlId)
808 808
     {
809
-        $table_url_rel_course= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
810
-        $sql= "DELETE FROM $table_url_rel_course
809
+        $table_url_rel_course = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
810
+        $sql = "DELETE FROM $table_url_rel_course
811 811
                WHERE c_id = '".intval($courseId)."' AND access_url_id=".intval($urlId)."  ";
812 812
         $result = Database::query($sql);
813 813
 
@@ -825,7 +825,7 @@  discard block
 block discarded – undo
825 825
     public static function delete_url_rel_usergroup($userGroupId, $urlId)
826 826
     {
827 827
         $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USERGROUP);
828
-        $sql= "DELETE FROM $table
828
+        $sql = "DELETE FROM $table
829 829
                WHERE usergroup_id = '".intval($userGroupId)."' AND
830 830
                      access_url_id=".intval($urlId)."  ";
831 831
         $result = Database::query($sql);
@@ -844,7 +844,7 @@  discard block
 block discarded – undo
844 844
     public static function deleteUrlRelCourseCategory($userGroupId, $urlId)
845 845
     {
846 846
         $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE_CATEGORY);
847
-        $sql= "DELETE FROM $table
847
+        $sql = "DELETE FROM $table
848 848
                WHERE course_category_id = '".intval($userGroupId)."' AND
849 849
                      access_url_id=".intval($urlId)."  ";
850 850
         $result = Database::query($sql);
@@ -863,9 +863,9 @@  discard block
 block discarded – undo
863 863
     public static function delete_url_rel_session($session_id, $url_id)
864 864
     {
865 865
         $table_url_rel_session = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
866
-        $sql= "DELETE FROM $table_url_rel_session
866
+        $sql = "DELETE FROM $table_url_rel_session
867 867
                WHERE session_id = ".intval($session_id)." AND access_url_id=".intval($url_id)."  ";
868
-        $result = Database::query($sql,'ASSOC');
868
+        $result = Database::query($sql, 'ASSOC');
869 869
 
870 870
         return $result;
871 871
     }
@@ -878,7 +878,7 @@  discard block
 block discarded – undo
878 878
      * */
879 879
     public static function update_urls_rel_user($user_list, $access_url_id)
880 880
     {
881
-        $table_url_rel_user	= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
881
+        $table_url_rel_user = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
882 882
         $sql = "SELECT user_id FROM $table_url_rel_user WHERE access_url_id = ".intval($access_url_id);
883 883
         $result = Database::query($sql);
884 884
         $existing_users = array();
@@ -932,7 +932,7 @@  discard block
 block discarded – undo
932 932
         $result = Database::query($sql);
933 933
 
934 934
         $existing_courses = array();
935
-        while ($row = Database::fetch_array($result)){
935
+        while ($row = Database::fetch_array($result)) {
936 936
             $existing_courses[] = $row['c_id'];
937 937
         }
938 938
 
@@ -965,7 +965,7 @@  discard block
 block discarded – undo
965 965
         $result = Database::query($sql);
966 966
         $existingItems = array();
967 967
 
968
-        while ($row = Database::fetch_array($result)){
968
+        while ($row = Database::fetch_array($result)) {
969 969
             $existingItems[] = $row['usergroup_id'];
970 970
         }
971 971
 
@@ -998,7 +998,7 @@  discard block
 block discarded – undo
998 998
         $result = Database::query($sql);
999 999
         $existingItems = array();
1000 1000
 
1001
-        while ($row = Database::fetch_array($result)){
1001
+        while ($row = Database::fetch_array($result)) {
1002 1002
             $existingItems[] = $row['course_category_id'];
1003 1003
         }
1004 1004
 
@@ -1039,15 +1039,15 @@  discard block
 block discarded – undo
1039 1039
      * @param array user list
1040 1040
      * @param int access_url_id
1041 1041
      * */
1042
-    public static function update_urls_rel_session($session_list,$access_url_id)
1042
+    public static function update_urls_rel_session($session_list, $access_url_id)
1043 1043
     {
1044
-        $table_url_rel_session	= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
1044
+        $table_url_rel_session = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
1045 1045
 
1046 1046
         $sql = "SELECT session_id FROM $table_url_rel_session WHERE access_url_id=".intval($access_url_id);
1047 1047
         $result = Database::query($sql);
1048 1048
         $existing_sessions = array();
1049 1049
 
1050
-        while ($row = Database::fetch_array($result)){
1050
+        while ($row = Database::fetch_array($result)) {
1051 1051
             $existing_sessions[] = $row['session_id'];
1052 1052
         }
1053 1053
 
@@ -1076,13 +1076,13 @@  discard block
 block discarded – undo
1076 1076
      */
1077 1077
     public static function get_access_url_from_user($user_id)
1078 1078
     {
1079
-        $table_url_rel_user	= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
1080
-        $table_url	= Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
1079
+        $table_url_rel_user = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
1080
+        $table_url = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
1081 1081
         $sql = "SELECT url, access_url_id FROM $table_url_rel_user url_rel_user INNER JOIN $table_url u
1082 1082
                 ON (url_rel_user.access_url_id = u.id)
1083 1083
                 WHERE user_id = ".intval($user_id);
1084 1084
         $result = Database::query($sql);
1085
-        $url_list = Database::store_result($result,'ASSOC');
1085
+        $url_list = Database::store_result($result, 'ASSOC');
1086 1086
         return $url_list;
1087 1087
     }
1088 1088
 
@@ -1092,14 +1092,14 @@  discard block
 block discarded – undo
1092 1092
      */
1093 1093
     public static function get_access_url_from_course($courseId)
1094 1094
     {
1095
-        $table	= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
1096
-        $table_url	= Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
1095
+        $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
1096
+        $table_url = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
1097 1097
         $sql = "SELECT url, access_url_id FROM $table c INNER JOIN $table_url u
1098 1098
                 ON (c.access_url_id = u.id)
1099 1099
                 WHERE c_id = ".intval($courseId);
1100 1100
 
1101 1101
         $result = Database::query($sql);
1102
-        $url_list = Database::store_result($result,'ASSOC');
1102
+        $url_list = Database::store_result($result, 'ASSOC');
1103 1103
         return $url_list;
1104 1104
     }
1105 1105
 
@@ -1110,7 +1110,7 @@  discard block
 block discarded – undo
1110 1110
     public static function get_access_url_from_session($session_id)
1111 1111
     {
1112 1112
         $table_url_rel_session = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
1113
-        $table_url  = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
1113
+        $table_url = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
1114 1114
         $sql = "SELECT url, access_url_id FROM $table_url_rel_session url_rel_session INNER JOIN $table_url u
1115 1115
                 ON (url_rel_session.access_url_id = u.id)
1116 1116
                 WHERE session_id = ".intval($session_id);
@@ -1126,7 +1126,7 @@  discard block
 block discarded – undo
1126 1126
      */
1127 1127
     public static function get_url_id($url)
1128 1128
     {
1129
-        $table_access_url= Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
1129
+        $table_access_url = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
1130 1130
         $sql = "SELECT id FROM $table_access_url WHERE url = '".Database::escape_string($url)."'";
1131 1131
         $result = Database::query($sql);
1132 1132
         $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/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.
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.
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
 
@@ -546,10 +546,10 @@  discard block
 block discarded – undo
546 546
 		}
547 547
 		else
548 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");
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 553
 
554 554
 			$sFunctionName = $_GET["xajax"];
555 555
 
@@ -567,12 +567,12 @@  discard block
 block discarded – undo
567 567
 			if (!$this->_isFunctionCallable($this->sPreFunction)) {
568 568
 				$bFoundFunction = false;
569 569
 				$objResponse = new xajaxResponse();
570
-				$objResponse->addAlert("Unknown Pre-Function ". $this->sPreFunction);
570
+				$objResponse->addAlert("Unknown Pre-Function ".$this->sPreFunction);
571 571
 				$sResponse = $objResponse->getXML();
572 572
 			}
573 573
 		}
574 574
 		//include any external dependencies associated with this function name
575
-		if (array_key_exists($sFunctionName,$this->aFunctionIncludeFiles))
575
+		if (array_key_exists($sFunctionName, $this->aFunctionIncludeFiles))
576 576
 		{
577 577
 			ob_start();
578 578
 			include_once($this->aFunctionIncludeFiles[$sFunctionName]);
@@ -612,13 +612,13 @@  discard block
 block discarded – undo
612 612
 
613 613
 					$aArgs[$i] = stripslashes($aArgs[$i]);
614 614
 				}
615
-				if (stristr($aArgs[$i],"<xjxobj>") != false)
615
+				if (stristr($aArgs[$i], "<xjxobj>") != false)
616 616
 				{
617
-					$aArgs[$i] = $this->_xmlToArray("xjxobj",$aArgs[$i]);
617
+					$aArgs[$i] = $this->_xmlToArray("xjxobj", $aArgs[$i]);
618 618
 				}
619
-				else if (stristr($aArgs[$i],"<xjxquery>") != false)
619
+				else if (stristr($aArgs[$i], "<xjxquery>") != false)
620 620
 				{
621
-					$aArgs[$i] = $this->_xmlToArray("xjxquery",$aArgs[$i]);
621
+					$aArgs[$i] = $this->_xmlToArray("xjxquery", $aArgs[$i]);
622 622
 				}
623 623
 				else if ($this->bDecodeUTF8Input)
624 624
 				{
@@ -674,16 +674,16 @@  discard block
 block discarded – undo
674 674
 		if ($this->sEncoding && strlen(trim($this->sEncoding)) > 0)
675 675
 			$sContentHeader .= " charset=".$this->sEncoding;
676 676
 		header($sContentHeader);
677
-		if ($this->bErrorHandler && !empty( $GLOBALS['xajaxErrorHandlerText'] )) {
677
+		if ($this->bErrorHandler && !empty($GLOBALS['xajaxErrorHandlerText'])) {
678 678
 			$sErrorResponse = new xajaxResponse();
679
-			$sErrorResponse->addAlert("** PHP Error Messages: **" . $GLOBALS['xajaxErrorHandlerText']);
679
+			$sErrorResponse->addAlert("** PHP Error Messages: **".$GLOBALS['xajaxErrorHandlerText']);
680 680
 			if ($this->sLogFile) {
681 681
 				$fH = @fopen($this->sLogFile, "a");
682 682
 				if (!$fH) {
683
-					$sErrorResponse->addAlert("** Logging Error **\n\nxajax was unable to write to the error log file:\n" . $this->sLogFile);
683
+					$sErrorResponse->addAlert("** Logging Error **\n\nxajax was unable to write to the error log file:\n".$this->sLogFile);
684 684
 				}
685 685
 				else {
686
-					fwrite($fH, "** xajax Error Log - " . strftime("%b %e %Y %I:%M:%S %p") . " **" . $GLOBALS['xajaxErrorHandlerText'] . "\n\n\n");
686
+					fwrite($fH, "** xajax Error Log - ".strftime("%b %e %Y %I:%M:%S %p")." **".$GLOBALS['xajaxErrorHandlerText']."\n\n\n");
687 687
 					fclose($fH);
688 688
 				}
689 689
 			}
@@ -725,7 +725,7 @@  discard block
 block discarded – undo
725 725
 	 *               engine located within the xajax installation folder.
726 726
 	 *               Defaults to xajax_js/xajax.js.
727 727
 	 */
728
-	function printJavascript($sJsURI="", $sJsFile=NULL)
728
+	function printJavascript($sJsURI = "", $sJsFile = NULL)
729 729
 	{
730 730
 		print $this->getJavascript($sJsURI, $sJsFile);
731 731
 	}
@@ -754,7 +754,7 @@  discard block
 block discarded – undo
754 754
 	 *               Defaults to xajax_js/xajax.js.
755 755
 	 * @return string
756 756
 	 */
757
-	function getJavascript($sJsURI="", $sJsFile=NULL)
757
+	function getJavascript($sJsURI = "", $sJsFile = NULL)
758 758
 	{
759 759
 		$html = $this->getJavascriptConfig();
760 760
 		$html .= $this->getJavascriptInclude($sJsURI, $sJsFile);
@@ -772,15 +772,15 @@  discard block
 block discarded – undo
772 772
 	{
773 773
 		$html  = "\t<script type=\"text/javascript\">\n";
774 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";
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 778
 		$html .= "var xajaxDefinedGet=".XAJAX_GET.";\n";
779 779
 		$html .= "var xajaxDefinedPost=".XAJAX_POST.";\n";
780 780
 		$html .= "var xajaxLoaded=false;\n";
781 781
 
782
-		foreach($this->aFunctions as $sFunction => $bExists) {
783
-			$html .= $this->_wrap($sFunction,$this->aFunctionRequestTypes[$sFunction]);
782
+		foreach ($this->aFunctions as $sFunction => $bExists) {
783
+			$html .= $this->_wrap($sFunction, $this->aFunctionRequestTypes[$sFunction]);
784 784
 		}
785 785
 
786 786
 		$html .= "\t</script>\n";
@@ -804,13 +804,13 @@  discard block
 block discarded – undo
804 804
 	 *               Defaults to xajax_js/xajax.js.
805 805
 	 * @return string
806 806
 	 */
807
-	function getJavascriptInclude($sJsURI="", $sJsFile=NULL)
807
+	function getJavascriptInclude($sJsURI = "", $sJsFile = NULL)
808 808
 	{
809 809
 		if ($sJsFile == NULL) $sJsFile = "xajax_js/xajax.js";
810 810
 
811 811
 		if ($sJsURI != "" && substr($sJsURI, -1) != "/") $sJsURI .= "/";
812 812
 
813
-		$html = "\t<script type=\"text/javascript\" src=\"" . $sJsURI . $sJsFile . "\"></script>\n";
813
+		$html = "\t<script type=\"text/javascript\" src=\"".$sJsURI.$sJsFile."\"></script>\n";
814 814
 		$html .= "\t<script type=\"text/javascript\">\n";
815 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 816
 		$html .= "\t</script>\n";
@@ -825,7 +825,7 @@  discard block
 block discarded – undo
825 825
 	 * @param string an optional argument containing the full server file path
826 826
 	 *               of xajax.js.
827 827
 	 */
828
-	function autoCompressJavascript($sJsFullFilename=NULL)
828
+	function autoCompressJavascript($sJsFullFilename = NULL)
829 829
 	{
830 830
 		$sJsFile = "xajax_js/xajax.js";
831 831
 
@@ -834,21 +834,21 @@  discard block
 block discarded – undo
834 834
 		}
835 835
 		else {
836 836
 			$realPath = realpath(dirname(__FILE__));
837
-			$realJsFile = $realPath . "/". $sJsFile;
837
+			$realJsFile = $realPath."/".$sJsFile;
838 838
 		}
839 839
 
840 840
 		// Create a compressed file if necessary
841 841
 		if (!file_exists($realJsFile)) {
842 842
 			$srcFile = str_replace(".js", "_uncompressed.js", $realJsFile);
843 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);
844
+				trigger_error("The xajax uncompressed Javascript file could not be found in the <b>".dirname($realJsFile)."</b> folder. Error ", E_USER_ERROR);
845 845
 			}
846 846
 			require(dirname(__FILE__)."/xajaxCompress.php");
847 847
 			$javaScript = implode('', file($srcFile));
848 848
 			$compressedScript = xajaxCompressJavascript($javaScript);
849 849
 			$fH = @fopen($realJsFile, "w");
850 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);
851
+				trigger_error("The xajax compressed javascript file could not be written in the <b>".dirname($realJsFile)."</b> folder. Error ", E_USER_ERROR);
852 852
 			}
853 853
 			else {
854 854
 				fwrite($fH, $compressedScript);
@@ -917,23 +917,23 @@  discard block
 block discarded – undo
917 917
 		// Build the URL: Start with scheme, user and pass
918 918
 		$sURL = $aURL['scheme'].'://';
919 919
 		if (!empty($aURL['user'])) {
920
-			$sURL.= $aURL['user'];
920
+			$sURL .= $aURL['user'];
921 921
 			if (!empty($aURL['pass'])) {
922
-				$sURL.= ':'.$aURL['pass'];
922
+				$sURL .= ':'.$aURL['pass'];
923 923
 			}
924
-			$sURL.= '@';
924
+			$sURL .= '@';
925 925
 		}
926 926
 
927 927
 		// Add the host
928
-		$sURL.= $aURL['host'];
928
+		$sURL .= $aURL['host'];
929 929
 
930 930
 		// Add the port if needed
931 931
 		if (!empty($aURL['port']) && (($aURL['scheme'] == 'http' && $aURL['port'] != 80) || ($aURL['scheme'] == 'https' && $aURL['port'] != 443))) {
932
-			$sURL.= ':'.$aURL['port'];
932
+			$sURL .= ':'.$aURL['port'];
933 933
 		}
934 934
 
935 935
 		// Add the path and the query string
936
-		$sURL.= $aURL['path'].@$aURL['query'];
936
+		$sURL .= $aURL['path'].@$aURL['query'];
937 937
 
938 938
 		// Clean up
939 939
 		unset($aURL);
@@ -1005,7 +1005,7 @@  discard block
 block discarded – undo
1005 1005
 	 * @access private
1006 1006
 	 * @return string
1007 1007
 	 */
1008
-	function _wrap($sFunction,$sRequestType=XAJAX_POST)
1008
+	function _wrap($sFunction, $sRequestType = XAJAX_POST)
1009 1009
 	{
1010 1010
 		$js = "function ".$this->sWrapperPrefix."$sFunction(){return xajax.call(\"$sFunction\", arguments, ".$sRequestType.");}\n";
1011 1011
 		return $js;
@@ -1024,18 +1024,18 @@  discard block
 block discarded – undo
1024 1024
 	function _xmlToArray($rootTag, $sXml)
1025 1025
 	{
1026 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);
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 1039
 
1040 1040
 		$this->iPos = 0;
1041 1041
 		$aArray = $this->_parseObjXml($rootTag);
@@ -1057,32 +1057,32 @@  discard block
 block discarded – undo
1057 1057
 
1058 1058
 		if ($rootTag == "xjxobj")
1059 1059
 		{
1060
-			while(!stristr($this->aObjArray[$this->iPos],"</xjxobj>"))
1060
+			while (!stristr($this->aObjArray[$this->iPos], "</xjxobj>"))
1061 1061
 			{
1062 1062
 				$this->iPos++;
1063
-				if(stristr($this->aObjArray[$this->iPos],"<e>"))
1063
+				if (stristr($this->aObjArray[$this->iPos], "<e>"))
1064 1064
 				{
1065 1065
 					$key = "";
1066 1066
 					$value = null;
1067 1067
 
1068 1068
 					$this->iPos++;
1069
-					while(!stristr($this->aObjArray[$this->iPos],"</e>"))
1069
+					while (!stristr($this->aObjArray[$this->iPos], "</e>"))
1070 1070
 					{
1071
-						if(stristr($this->aObjArray[$this->iPos],"<k>"))
1071
+						if (stristr($this->aObjArray[$this->iPos], "<k>"))
1072 1072
 						{
1073 1073
 							$this->iPos++;
1074
-							while(!stristr($this->aObjArray[$this->iPos],"</k>"))
1074
+							while (!stristr($this->aObjArray[$this->iPos], "</k>"))
1075 1075
 							{
1076 1076
 								$key .= $this->aObjArray[$this->iPos];
1077 1077
 								$this->iPos++;
1078 1078
 							}
1079 1079
 						}
1080
-						if(stristr($this->aObjArray[$this->iPos],"<v>"))
1080
+						if (stristr($this->aObjArray[$this->iPos], "<v>"))
1081 1081
 						{
1082 1082
 							$this->iPos++;
1083
-							while(!stristr($this->aObjArray[$this->iPos],"</v>"))
1083
+							while (!stristr($this->aObjArray[$this->iPos], "</v>"))
1084 1084
 							{
1085
-								if(stristr($this->aObjArray[$this->iPos],"<xjxobj>"))
1085
+								if (stristr($this->aObjArray[$this->iPos], "<xjxobj>"))
1086 1086
 								{
1087 1087
 									$value = $this->_parseObjXml("xjxobj");
1088 1088
 									$this->iPos++;
@@ -1101,7 +1101,7 @@  discard block
 block discarded – undo
1101 1101
 						$this->iPos++;
1102 1102
 					}
1103 1103
 
1104
-					$aArray[$key]=$value;
1104
+					$aArray[$key] = $value;
1105 1105
 				}
1106 1106
 			}
1107 1107
 		}
@@ -1110,21 +1110,21 @@  discard block
 block discarded – undo
1110 1110
 		{
1111 1111
 			$sQuery = "";
1112 1112
 			$this->iPos++;
1113
-			while(!stristr($this->aObjArray[$this->iPos],"</xjxquery>"))
1113
+			while (!stristr($this->aObjArray[$this->iPos], "</xjxquery>"))
1114 1114
 			{
1115
-				if (stristr($this->aObjArray[$this->iPos],"<q>") || stristr($this->aObjArray[$this->iPos],"</q>"))
1115
+				if (stristr($this->aObjArray[$this->iPos], "<q>") || stristr($this->aObjArray[$this->iPos], "</q>"))
1116 1116
 				{
1117 1117
 					$this->iPos++;
1118 1118
 					continue;
1119 1119
 				}
1120
-				$sQuery	.= $this->aObjArray[$this->iPos];
1120
+				$sQuery .= $this->aObjArray[$this->iPos];
1121 1121
 				$this->iPos++;
1122 1122
 			}
1123 1123
 
1124 1124
 			parse_str($sQuery, $aArray);
1125 1125
 			if ($this->bDecodeUTF8Input)
1126 1126
 			{
1127
-				foreach($aArray as $key => $value)
1127
+				foreach ($aArray as $key => $value)
1128 1128
 				{
1129 1129
 					$aArray[$key] = $this->_decodeUTF8Data($value);
1130 1130
 				}
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/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.
main/install/install.lib.php 4 patches
Doc Comments   +14 added lines, -5 removed lines patch added patch discarded remove patch
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
  * This function return the value of a php.ini setting if not "" or if exists,
98 98
  * otherwise return false
99 99
  * @param   string  $phpSetting The name of a PHP setting
100
- * @return  mixed   The value of the setting, or false if not found
100
+ * @return  string|false   The value of the setting, or false if not found
101 101
  */
102 102
 function checkPhpSettingExists($phpSetting)
103 103
 {
@@ -1268,6 +1268,10 @@  discard block
 block discarded – undo
1268 1268
  * @param   string  Extra notice (to show on the right side)
1269 1269
  * @param   boolean Whether to display in update mode
1270 1270
  * @param   string  Additional attribute for the <tr> element
1271
+ * @param string $installType
1272
+ * @param string $parameterName
1273
+ * @param string $formFieldName
1274
+ * @param string $extra_notice
1271 1275
  * @return  void    Direct output
1272 1276
  */
1273 1277
 function displayDatabaseParameter(
@@ -1481,6 +1485,11 @@  discard block
 block discarded – undo
1481 1485
 
1482 1486
     <?php
1483 1487
 }
1488
+/**
1489
+ * @param string $content
1490
+ * @param string $title
1491
+ * @param string $id
1492
+ */
1484 1493
 function panel($content = null, $title = null, $id = null, $style = null) {
1485 1494
     $html = '';
1486 1495
     if (empty($style)) {
@@ -1837,8 +1846,8 @@  discard block
 block discarded – undo
1837 1846
 }
1838 1847
 
1839 1848
 /**
1840
- * @param $current_value
1841
- * @param $wanted_value
1849
+ * @param string $current_value
1850
+ * @param string $wanted_value
1842 1851
  * @return string
1843 1852
  */
1844 1853
 function compare_setting_values($current_value, $wanted_value)
@@ -1855,8 +1864,8 @@  discard block
 block discarded – undo
1855 1864
 }
1856 1865
 
1857 1866
 /**
1858
- * @param $course_dir
1859
- * @param $course_attempt_name
1867
+ * @param string $course_dir
1868
+ * @param string $course_attempt_name
1860 1869
  * @param string $file
1861 1870
  * @return bool
1862 1871
  */
Please login to merge, or discard this patch.
Spacing   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
     if (!is_array($result)) {
397 397
         $result = array();
398 398
         $exceptions = array('.', '..', 'CVS', '.svn');
399
-        $search       = array('_latin',   '_unicode',   '_corporate',   '_org'  , '_KM',   '_');
399
+        $search       = array('_latin', '_unicode', '_corporate', '_org', '_KM', '_');
400 400
         $replace_with = array(' (Latin)', ' (unicode)', ' (corporate)', ' (org)', ' (KM)', ' ');
401 401
         $dirname = api_get_path(SYS_LANG_PATH);
402 402
         $handle = opendir($dirname);
@@ -430,9 +430,9 @@  discard block
 block discarded – undo
430 430
     if ($handle = opendir($directory)) {
431 431
         while (false !== ($file = readdir($handle))) {
432 432
             if ($file != "." && $file != "..") {
433
-                if (is_dir($directory. "/" . $file)) {
434
-                    $array_items = array_merge($array_items, my_directory_to_array($directory. '/' . $file));
435
-                    $file = $directory . "/" . $file;
433
+                if (is_dir($directory."/".$file)) {
434
+                    $array_items = array_merge($array_items, my_directory_to_array($directory.'/'.$file));
435
+                    $file = $directory."/".$file;
436 436
                     $array_items[] = preg_replace("/\/\//si", '/', $file);
437 437
                 }
438 438
             }
@@ -636,7 +636,7 @@  discard block
 block discarded – undo
636 636
     <h2><?php get_lang('WelcomeToTheChamiloInstaller'); ?></h2>
637 637
     <div class="RequirementHeading">
638 638
         <h2><?php echo display_step_sequence(); ?>
639
-            <?php echo get_lang('InstallationLanguage');?>
639
+            <?php echo get_lang('InstallationLanguage'); ?>
640 640
         </h2>
641 641
         <p><?php echo get_lang('PleaseSelectInstallationProcessLanguage'); ?>:</p>
642 642
         <form id="lang_form" method="post" action="<?php echo api_get_self(); ?>">
@@ -709,7 +709,7 @@  discard block
 block discarded – undo
709 709
     if (phpversion() < REQUIRED_PHP_VERSION) {
710 710
         echo '<strong><font color="red">'.get_lang('PHPVersionError').'</font></strong>';
711 711
     } else {
712
-        echo '<strong><font color="green">'.get_lang('PHPVersionOK'). ' '.phpversion().'</font></strong>';
712
+        echo '<strong><font color="green">'.get_lang('PHPVersionOK').' '.phpversion().'</font></strong>';
713 713
     }
714 714
     echo '</td>
715 715
             </tr>
@@ -881,7 +881,7 @@  discard block
 block discarded – undo
881 881
             if ($file_course_test_was_created == true) {
882 882
                 break;
883 883
             }
884
-            $r = @touch($course_dir.'/test.php',$perm);
884
+            $r = @touch($course_dir.'/test.php', $perm);
885 885
             if ($r === true) {
886 886
                 $fil_perm_verified = $perm;
887 887
                 if (check_course_script_interpretation($course_dir, $course_attempt_name, 'test.php')) {
@@ -1137,7 +1137,7 @@  discard block
 block discarded – undo
1137 1137
 function get_contact_registration_form()
1138 1138
 {
1139 1139
 
1140
-    $html ='
1140
+    $html = '
1141 1141
    <form class="form-horizontal">
1142 1142
     <div class="panel panel-default">
1143 1143
     <div class="panel-body">
@@ -1234,7 +1234,7 @@  discard block
 block discarded – undo
1234 1234
             <div class="col-sm-9">
1235 1235
                 <div class="radio">
1236 1236
                     <label>
1237
-                        <input type="radio" name="financial_decision" id="financial_decision1" value="1" checked /> ' . get_lang('Yes') . '
1237
+                        <input type="radio" name="financial_decision" id="financial_decision1" value="1" checked /> ' . get_lang('Yes').'
1238 1238
                     </label>
1239 1239
                 </div>
1240 1240
                 <div class="radio">
@@ -1293,8 +1293,8 @@  discard block
 block discarded – undo
1293 1293
             echo '<input type="hidden" name="'.$formFieldName.'" id="'.$formFieldName.'" value="'.api_htmlentities($parameterValue).'" />';
1294 1294
             echo api_htmlentities($parameterValue);
1295 1295
         } else {
1296
-            echo '<div class="col-sm-5"><input type="' . $inputType . '" class="form-control" size="' . DATABASE_FORM_FIELD_DISPLAY_LENGTH . '" maxlength="' . $maxLength . '" name="' . $formFieldName . '" id="' . $formFieldName . '" value="' . api_htmlentities($parameterValue) . '" />' . "</div>";
1297
-            echo '<div class="col-sm-3">' . $extra_notice . '</div>';
1296
+            echo '<div class="col-sm-5"><input type="'.$inputType.'" class="form-control" size="'.DATABASE_FORM_FIELD_DISPLAY_LENGTH.'" maxlength="'.$maxLength.'" name="'.$formFieldName.'" id="'.$formFieldName.'" value="'.api_htmlentities($parameterValue).'" />'."</div>";
1297
+            echo '<div class="col-sm-3">'.$extra_notice.'</div>';
1298 1298
         }
1299 1299
 
1300 1300
     }
@@ -1330,12 +1330,12 @@  discard block
 block discarded – undo
1330 1330
         $dbNameForm = $_configuration['main_database'];
1331 1331
         $dbPortForm = isset($_configuration['db_port']) ? $_configuration['db_port'] : '';
1332 1332
 
1333
-        echo '<div class="RequirementHeading"><h2>' . display_step_sequence() .get_lang('DBSetting') . '</h2></div>';
1333
+        echo '<div class="RequirementHeading"><h2>'.display_step_sequence().get_lang('DBSetting').'</h2></div>';
1334 1334
         echo '<div class="RequirementContent">';
1335 1335
         echo get_lang('DBSettingUpgradeIntro');
1336 1336
         echo '</div>';
1337 1337
     } else {
1338
-        echo '<div class="RequirementHeading"><h2>' . display_step_sequence() .get_lang('DBSetting') . '</h2></div>';
1338
+        echo '<div class="RequirementHeading"><h2>'.display_step_sequence().get_lang('DBSetting').'</h2></div>';
1339 1339
         echo '<div class="RequirementContent">';
1340 1340
         echo get_lang('DBSettingIntro');
1341 1341
         echo '</div>';
@@ -1345,12 +1345,12 @@  discard block
 block discarded – undo
1345 1345
         <div class="panel-body">
1346 1346
         <div class="form-group">
1347 1347
             <label class="col-sm-4"><?php echo get_lang('DBHost'); ?> </label>
1348
-            <?php if ($installType == 'update'){ ?>
1348
+            <?php if ($installType == 'update') { ?>
1349 1349
             <div class="col-sm-5">
1350 1350
                 <input type="hidden" name="dbHostForm" value="<?php echo htmlentities($dbHostForm); ?>" /><?php echo $dbHostForm; ?>
1351 1351
             </div>
1352 1352
             <div class="col-sm-3"></div>
1353
-            <?php }else{ ?>
1353
+            <?php } else { ?>
1354 1354
             <div class="col-sm-5">
1355 1355
                 <input type="text" class="form-control" size="25" maxlength="50" name="dbHostForm" value="<?php echo htmlentities($dbHostForm); ?>" />
1356 1356
             </div>
@@ -1359,12 +1359,12 @@  discard block
 block discarded – undo
1359 1359
         </div>
1360 1360
         <div class="form-group">
1361 1361
             <label class="col-sm-4"><?php echo get_lang('DBPort'); ?> </label>
1362
-            <?php if ($installType == 'update'){ ?>
1362
+            <?php if ($installType == 'update') { ?>
1363 1363
             <div class="col-sm-5">
1364 1364
                 <input type="hidden" name="dbPortForm" value="<?php echo htmlentities($dbPortForm); ?>" /><?php echo $dbPortForm; ?>
1365 1365
             </div>
1366 1366
             <div class="col-sm-3"></div>
1367
-            <?php }else{ ?>
1367
+            <?php } else { ?>
1368 1368
             <div class="col-sm-5">
1369 1369
                 <input type="text" class="form-control" size="25" maxlength="50" name="dbPortForm" value="<?php echo htmlentities($dbPortForm); ?>" />
1370 1370
             </div>
@@ -1390,7 +1390,7 @@  discard block
 block discarded – undo
1390 1390
             <?php
1391 1391
             //Database Name fix replace weird chars
1392 1392
             if ($installType != INSTALL_TYPE_UPDATE) {
1393
-                $dbNameForm = str_replace(array('-','*', '$', ' ', '.'), '', $dbNameForm);
1393
+                $dbNameForm = str_replace(array('-', '*', '$', ' ', '.'), '', $dbNameForm);
1394 1394
             }
1395 1395
 
1396 1396
             displayDatabaseParameter(
@@ -1489,7 +1489,7 @@  discard block
 block discarded – undo
1489 1489
     if (!empty($title)) {
1490 1490
         $panelTitle = Display::div($title, array('class' => 'panel-heading'));
1491 1491
         $panelBody = Display::div($content, array('class' => 'panel-body'));
1492
-        $panelParent = Display::div($panelTitle . $panelBody, array('id' => $id, 'class' => 'panel panel-'.$style));
1492
+        $panelParent = Display::div($panelTitle.$panelBody, array('id' => $id, 'class' => 'panel panel-'.$style));
1493 1493
     } else {
1494 1494
         $panelBody = Display::div($html, array('class' => 'panel-body'));
1495 1495
         $panelParent = Display::div($panelBody, array('id' => $id, 'class' => 'panel panel-'.$style));
@@ -1514,9 +1514,9 @@  discard block
 block discarded – undo
1514 1514
     $displayWhenUpdate = 'true'
1515 1515
 ) {
1516 1516
     $html = '<div class="form-group">';
1517
-    $html .= '<label class="col-sm-6 control-label">' . $parameterName . '</label>';
1517
+    $html .= '<label class="col-sm-6 control-label">'.$parameterName.'</label>';
1518 1518
     if ($installType == INSTALL_TYPE_UPDATE && $displayWhenUpdate) {
1519
-        $html .= '<input type="hidden" name="' . $formFieldName . '" value="'. api_htmlentities($parameterValue, ENT_QUOTES). '" />' . $parameterValue;
1519
+        $html .= '<input type="hidden" name="'.$formFieldName.'" value="'.api_htmlentities($parameterValue, ENT_QUOTES).'" />'.$parameterValue;
1520 1520
     } else {
1521 1521
         $html .= '<div class="col-sm-6"><input class="form-control" type="text" size="'.FORM_FIELD_DISPLAY_LENGTH.'" maxlength="'.MAX_FORM_FIELD_LENGTH.'" name="'.$formFieldName.'" value="'.api_htmlentities($parameterValue, ENT_QUOTES).'" />'."</div>";
1522 1522
     }
@@ -1563,7 +1563,7 @@  discard block
 block discarded – undo
1563 1563
         $languageForm = $_SESSION['install_language'];
1564 1564
     }
1565 1565
     echo '<div class="RequirementHeading">';
1566
-    echo "<h2>" . display_step_sequence() . get_lang("CfgSetting") . "</h2>";
1566
+    echo "<h2>".display_step_sequence().get_lang("CfgSetting")."</h2>";
1567 1567
     echo '</div>';
1568 1568
 
1569 1569
     echo '<p>'.get_lang('ConfigSettingsInfo').' <strong>app/config/configuration.php</strong></p>';
@@ -1581,14 +1581,14 @@  discard block
 block discarded – undo
1581 1581
 
1582 1582
     // Parameters 3 and 4: administrator's names
1583 1583
 
1584
-    $html .=  display_configuration_parameter($installType, get_lang('AdminFirstName'), 'adminFirstName', $adminFirstName);
1585
-    $html .=  display_configuration_parameter($installType, get_lang('AdminLastName'), 'adminLastName', $adminLastName);
1584
+    $html .= display_configuration_parameter($installType, get_lang('AdminFirstName'), 'adminFirstName', $adminFirstName);
1585
+    $html .= display_configuration_parameter($installType, get_lang('AdminLastName'), 'adminLastName', $adminLastName);
1586 1586
 
1587 1587
     //Parameter 3: administrator's email
1588
-    $html .=  display_configuration_parameter($installType, get_lang('AdminEmail'), 'emailForm', $emailForm);
1588
+    $html .= display_configuration_parameter($installType, get_lang('AdminEmail'), 'emailForm', $emailForm);
1589 1589
 
1590 1590
     //Parameter 6: administrator's telephone
1591
-    $html .=  display_configuration_parameter($installType, get_lang('AdminPhone'), 'adminPhoneForm', $adminPhoneForm);
1591
+    $html .= display_configuration_parameter($installType, get_lang('AdminPhone'), 'adminPhoneForm', $adminPhoneForm);
1592 1592
 
1593 1593
 
1594 1594
     echo panel($html, get_lang('Administrator'), 'administrator');
@@ -1607,12 +1607,12 @@  discard block
 block discarded – undo
1607 1607
         $html .= display_language_selection_box('languageForm', $languageForm);
1608 1608
         $html .= '</div>';
1609 1609
     }
1610
-    $html.= "</div>";
1610
+    $html .= "</div>";
1611 1611
 
1612 1612
 
1613 1613
     //Second parameter: Chamilo URL
1614 1614
     $html .= '<div class="form-group">';
1615
-    $html .= '<label class="col-sm-6 control-label">'.get_lang('ChamiloURL') .get_lang('ThisFieldIsRequired').'</label>';
1615
+    $html .= '<label class="col-sm-6 control-label">'.get_lang('ChamiloURL').get_lang('ThisFieldIsRequired').'</label>';
1616 1616
 
1617 1617
 
1618 1618
 
@@ -1636,34 +1636,34 @@  discard block
 block discarded – undo
1636 1636
 
1637 1637
 
1638 1638
     $html .= '<div class="form-group">
1639
-            <label class="col-sm-6 control-label">' . get_lang("EncryptMethodUserPass") . '</label>
1639
+            <label class="col-sm-6 control-label">' . get_lang("EncryptMethodUserPass").'</label>
1640 1640
         <div class="col-sm-6">';
1641 1641
     if ($installType == 'update') {
1642
-        $html .= '<input type="hidden" name="encryptPassForm" value="'. $encryptPassForm .'" />'. $encryptPassForm;
1642
+        $html .= '<input type="hidden" name="encryptPassForm" value="'.$encryptPassForm.'" />'.$encryptPassForm;
1643 1643
     } else {
1644 1644
 
1645 1645
         $html .= '<div class="checkbox">
1646 1646
                     <label>
1647
-                        <input  type="radio" name="encryptPassForm" value="bcrypt" id="encryptPass1" '. ($encryptPassForm == 'bcrypt' ? 'checked="checked" ':'') .'/> bcrypt
1647
+                        <input  type="radio" name="encryptPassForm" value="bcrypt" id="encryptPass1" '. ($encryptPassForm == 'bcrypt' ? 'checked="checked" ' : '').'/> bcrypt
1648 1648
                     </label>';
1649 1649
 
1650 1650
         $html .= '<label>
1651
-                        <input  type="radio" name="encryptPassForm" value="sha1" id="encryptPass1" '. ($encryptPassForm == 'sha1' ? 'checked="checked" ':'') .'/> sha1
1651
+                        <input  type="radio" name="encryptPassForm" value="sha1" id="encryptPass1" '. ($encryptPassForm == 'sha1' ? 'checked="checked" ' : '').'/> sha1
1652 1652
                     </label>';
1653 1653
 
1654 1654
         $html .= '<label>
1655
-                        <input type="radio" name="encryptPassForm" value="md5" id="encryptPass0" '. ($encryptPassForm == 'md5' ? 'checked="checked" ':'') .'/> md5
1655
+                        <input type="radio" name="encryptPassForm" value="md5" id="encryptPass0" '. ($encryptPassForm == 'md5' ? 'checked="checked" ' : '').'/> md5
1656 1656
                     </label>';
1657 1657
 
1658 1658
         $html .= '<label>
1659
-                        <input type="radio" name="encryptPassForm" value="none" id="encryptPass2" '. ($encryptPassForm == 'none' ? 'checked="checked" ':'') .'/>'. get_lang('None').'
1659
+                        <input type="radio" name="encryptPassForm" value="none" id="encryptPass2" '. ($encryptPassForm == 'none' ? 'checked="checked" ' : '').'/>'.get_lang('None').'
1660 1660
                     </label>';
1661 1661
         $html .= '</div>';
1662 1662
     }
1663 1663
     $html .= '</div></div>';
1664 1664
 
1665 1665
     $html .= '<div class="form-group">
1666
-            <label class="col-sm-6 control-label">' . get_lang('AllowSelfReg') . '</label>
1666
+            <label class="col-sm-6 control-label">' . get_lang('AllowSelfReg').'</label>
1667 1667
             <div class="col-sm-6">';
1668 1668
     if ($installType == 'update') {
1669 1669
         if ($allowSelfReg == 'true') {
@@ -1673,17 +1673,17 @@  discard block
 block discarded – undo
1673 1673
         } else {
1674 1674
             $label = get_lang('AfterApproval');
1675 1675
         }
1676
-        $html .= '<input type="hidden" name="allowSelfReg" value="'. $allowSelfReg .'" />'. $label;
1676
+        $html .= '<input type="hidden" name="allowSelfReg" value="'.$allowSelfReg.'" />'.$label;
1677 1677
     } else {
1678 1678
         $html .= '<div class="control-group">';
1679 1679
         $html .= '<label class="checkbox-inline">
1680
-                        <input type="radio" name="allowSelfReg" value="1" id="allowSelfReg1" '. ($allowSelfReg == 'true' ? 'checked="checked" ' : '') . ' /> '. get_lang('Yes') .'
1680
+                        <input type="radio" name="allowSelfReg" value="1" id="allowSelfReg1" '. ($allowSelfReg == 'true' ? 'checked="checked" ' : '').' /> '.get_lang('Yes').'
1681 1681
                     </label>';
1682 1682
         $html .= '<label class="checkbox-inline">
1683
-                        <input type="radio" name="allowSelfReg" value="0" id="allowSelfReg0" '. ($allowSelfReg == 'false' ? '' : 'checked="checked" ') .' /> '. get_lang('No') .'
1683
+                        <input type="radio" name="allowSelfReg" value="0" id="allowSelfReg0" '. ($allowSelfReg == 'false' ? '' : 'checked="checked" ').' /> '.get_lang('No').'
1684 1684
                     </label>';
1685 1685
          $html .= '<label class="checkbox-inline">
1686
-                    <input type="radio" name="allowSelfReg" value="0" id="allowSelfReg0" '. ($allowSelfReg == 'approval' ? '' : 'checked="checked" ') .' /> '. get_lang('AfterApproval') .'
1686
+                    <input type="radio" name="allowSelfReg" value="0" id="allowSelfReg0" '. ($allowSelfReg == 'approval' ? '' : 'checked="checked" ').' /> '.get_lang('AfterApproval').'
1687 1687
                 </label>';
1688 1688
         $html .= '</div>';
1689 1689
     }
@@ -1691,7 +1691,7 @@  discard block
 block discarded – undo
1691 1691
     $html .= '</div>';
1692 1692
 
1693 1693
     $html .= '<div class="form-group">';
1694
-    $html .= '<label class="col-sm-6 control-label">'. get_lang('AllowSelfRegProf') .'</label>
1694
+    $html .= '<label class="col-sm-6 control-label">'.get_lang('AllowSelfRegProf').'</label>
1695 1695
         <div class="col-sm-6">';
1696 1696
     if ($installType == 'update') {
1697 1697
         if ($allowSelfRegProf == 'true') {
@@ -1699,16 +1699,16 @@  discard block
 block discarded – undo
1699 1699
         } else {
1700 1700
             $label = get_lang('No');
1701 1701
         }
1702
-        $html .= '<input type="hidden" name="allowSelfRegProf" value="'. $allowSelfRegProf.'" />'. $label;
1702
+        $html .= '<input type="hidden" name="allowSelfRegProf" value="'.$allowSelfRegProf.'" />'.$label;
1703 1703
     } else {
1704 1704
         $html .= '<div class="control-group">
1705 1705
                 <label class="checkbox-inline">
1706
-                    <input type="radio" name="allowSelfRegProf" value="1" id="allowSelfRegProf1" '. ($allowSelfRegProf ? 'checked="checked" ' : '') .'/>
1707
-                ' . get_lang('Yes') .'
1706
+                    <input type="radio" name="allowSelfRegProf" value="1" id="allowSelfRegProf1" '. ($allowSelfRegProf ? 'checked="checked" ' : '').'/>
1707
+                ' . get_lang('Yes').'
1708 1708
                 </label>';
1709 1709
         $html .= '<label class="checkbox-inline">
1710
-                    <input type="radio" name="allowSelfRegProf" value="0" id="allowSelfRegProf0" '. ($allowSelfRegProf ? '' : 'checked="checked" ') .' />
1711
-                   '. get_lang('No') .'
1710
+                    <input type="radio" name="allowSelfRegProf" value="0" id="allowSelfRegProf0" '. ($allowSelfRegProf ? '' : 'checked="checked" ').' />
1711
+                   '. get_lang('No').'
1712 1712
                 </label>';
1713 1713
         $html .= '</div>';
1714 1714
     }
@@ -1773,7 +1773,7 @@  discard block
 block discarded – undo
1773 1773
         "Macedonia", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands", "Mauritania", "Mauritius", "Mexico", "Micronesia", "Moldova", "Monaco", "Mongolia", "Morocco", "Mozambique", "Myanmar",
1774 1774
         "Namibia", "Nauru", "Nepa", "Netherlands", "New Zealand", "Nicaragua", "Niger", "Nigeria", "Norway",
1775 1775
         "Oman",
1776
-        "Pakistan", "Palau", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines", "Poland","Portugal",
1776
+        "Pakistan", "Palau", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines", "Poland", "Portugal",
1777 1777
         "Qatar",
1778 1778
         "Romania", "Russia", "Rwanda",
1779 1779
         "Saint Kitts and Nevis", "Saint Lucia", "Saint Vincent", "Samoa", "San Marino", "Sao Tome and Principe", "Saudi Arabia", "Senegal", "Serbia and Montenegro", "Seychelles", "Sierra Leone", "Singapore", "Slovakia", "Slovenia", "Solomon Islands", "Somalia", "South Africa", "Spain", "Sri Lanka", "Sudan", "Suriname", "Swaziland", "Sweden", "Switzerland", "Syria",
@@ -1820,11 +1820,11 @@  discard block
 block discarded – undo
1820 1820
     $permissions_for_new_directories = isset($_SESSION['permissions_for_new_directories']) ? $_SESSION['permissions_for_new_directories'] : 0770;
1821 1821
     $permissions_for_new_files = isset($_SESSION['permissions_for_new_files']) ? $_SESSION['permissions_for_new_files'] : 0660;
1822 1822
     // use decoct() to store as string
1823
-    $sql = "UPDATE $table SET selected_value = '0" . decoct($permissions_for_new_directories) . "'
1823
+    $sql = "UPDATE $table SET selected_value = '0".decoct($permissions_for_new_directories)."'
1824 1824
               WHERE variable  = 'permissions_for_new_directories'";
1825 1825
     Database::query($sql);
1826 1826
 
1827
-    $sql = "UPDATE $table SET selected_value = '0" . decoct($permissions_for_new_files) . "' WHERE variable  = 'permissions_for_new_files'";
1827
+    $sql = "UPDATE $table SET selected_value = '0".decoct($permissions_for_new_files)."' WHERE variable  = 'permissions_for_new_files'";
1828 1828
     Database::query($sql);
1829 1829
 
1830 1830
     if (isset($_SESSION['permissions_for_new_directories'])) {
@@ -1844,8 +1844,8 @@  discard block
 block discarded – undo
1844 1844
 function compare_setting_values($current_value, $wanted_value)
1845 1845
 {
1846 1846
     $current_value_string = $current_value;
1847
-    $current_value = (float)$current_value;
1848
-    $wanted_value = (float)$wanted_value;
1847
+    $current_value = (float) $current_value;
1848
+    $wanted_value = (float) $wanted_value;
1849 1849
 
1850 1850
     if ($current_value >= $wanted_value) {
1851 1851
         return Display::label($current_value_string, 'success');
@@ -1896,7 +1896,7 @@  discard block
 block discarded – undo
1896 1896
 
1897 1897
                     fwrite($fp, $out);
1898 1898
                     while (!feof($fp)) {
1899
-                        $result = str_replace("\r\n", '',fgets($fp, 128));
1899
+                        $result = str_replace("\r\n", '', fgets($fp, 128));
1900 1900
                         if (!empty($result) && $result == '123') {
1901 1901
                             $output = true;
1902 1902
                         }
@@ -1919,7 +1919,7 @@  discard block
 block discarded – undo
1919 1919
                     curl_setopt($ch, CURLOPT_URL, $url);
1920 1920
                     //curl_setopt($ch, CURLOPT_TIMEOUT, 30);
1921 1921
                     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
1922
-                    $result = curl_exec ($ch);
1922
+                    $result = curl_exec($ch);
1923 1923
                     if (!empty($result) && $result == '123') {
1924 1924
                         $output = true;
1925 1925
                     }
@@ -2679,12 +2679,12 @@  discard block
 block discarded – undo
2679 2679
         $adminPhoneForm,
2680 2680
         '', //$picture_uri = '',
2681 2681
         PLATFORM_AUTH_SOURCE,
2682
-        '',//$expirationDate,
2682
+        '', //$expirationDate,
2683 2683
         1,
2684 2684
         0,
2685 2685
         null,
2686 2686
         '',
2687
-        false,  //$send_mail = false,
2687
+        false, //$send_mail = false,
2688 2688
         true //$isAdmin = false
2689 2689
     );
2690 2690
 
@@ -2706,7 +2706,7 @@  discard block
 block discarded – undo
2706 2706
         0,
2707 2707
         null,
2708 2708
         '',
2709
-        false,  //$send_mail = false,
2709
+        false, //$send_mail = false,
2710 2710
         false //$isAdmin = false
2711 2711
     );
2712 2712
 
@@ -2772,7 +2772,7 @@  discard block
 block discarded – undo
2772 2772
                 SET selected_value = '".$param->selected_value."'
2773 2773
                 WHERE variable = '".$param->variable."'";
2774 2774
         if (!empty($param->subkey)) {
2775
-            $sql .= " AND subkey='" . $param->subkey . "'";
2775
+            $sql .= " AND subkey='".$param->subkey."'";
2776 2776
         }
2777 2777
         Database::query($sql);
2778 2778
     }
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1682,7 +1682,7 @@  discard block
 block discarded – undo
1682 1682
         $html .= '<label class="checkbox-inline">
1683 1683
                         <input type="radio" name="allowSelfReg" value="0" id="allowSelfReg0" '. ($allowSelfReg == 'false' ? '' : 'checked="checked" ') .' /> '. get_lang('No') .'
1684 1684
                     </label>';
1685
-         $html .= '<label class="checkbox-inline">
1685
+            $html .= '<label class="checkbox-inline">
1686 1686
                     <input type="radio" name="allowSelfReg" value="0" id="allowSelfReg0" '. ($allowSelfReg == 'approval' ? '' : 'checked="checked" ') .' /> '. get_lang('AfterApproval') .'
1687 1687
                 </label>';
1688 1688
         $html .= '</div>';
@@ -1716,7 +1716,7 @@  discard block
 block discarded – undo
1716 1716
     </div>';
1717 1717
 
1718 1718
     echo panel($html, get_lang('Platform'), 'platform');
1719
- ?>
1719
+    ?>
1720 1720
     <div class='form-group'>
1721 1721
         <div class="col-sm-6">
1722 1722
             <button type="submit" class="btn btn-default pull-right" name="step3" value="&lt; <?php echo get_lang('Previous'); ?>" ><em class="fa fa-backward"> </em> <?php echo get_lang('Previous'); ?></button>
Please login to merge, or discard this patch.
Braces   +15 added lines, -8 removed lines patch added patch discarded remove patch
@@ -973,8 +973,7 @@  discard block
 block discarded – undo
973 973
                 <?php echo get_lang('Error'); ?>!<br />
974 974
                 Chamilo <?php echo implode('|', $update_from_version_8).' '.get_lang('HasNotBeenFoundInThatDir'); ?>.
975 975
             </div>
976
-        <?php }
977
-        else {
976
+        <?php } else {
978 977
             echo '<br />';
979 978
         }
980 979
         ?>
@@ -1060,14 +1059,19 @@  discard block
 block discarded – undo
1060 1059
         <button type="submit" name="step1" class="btn btn-default" onclick="javascript: window.location='index.php'; return false;" value="<?php echo get_lang('Previous'); ?>" >
1061 1060
             <em class="fa fa-backward"> </em> <?php echo get_lang('Previous'); ?>
1062 1061
         </button>
1063
-        <button type="submit" name="step2_install" class="btn btn-success" value="<?php echo get_lang("NewInstallation"); ?>" <?php if ($error) echo 'disabled="disabled"'; ?> >
1062
+        <button type="submit" name="step2_install" class="btn btn-success" value="<?php echo get_lang("NewInstallation"); ?>" <?php if ($error) {
1063
+    echo 'disabled="disabled"';
1064
+}
1065
+?> >
1064 1066
             <em class="fa fa-forward"> </em> <?php echo get_lang('NewInstallation'); ?>
1065 1067
         </button>
1066 1068
         <input type="hidden" name="is_executable" id="is_executable" value="-" />
1067 1069
         <?php
1068 1070
         // Real code
1069 1071
         echo '<button type="submit" class="btn btn-default" name="step2_update_8" value="Upgrade from Chamilo 1.9.x"';
1070
-        if ($error) echo ' disabled="disabled"';
1072
+        if ($error) {
1073
+            echo ' disabled="disabled"';
1074
+        }
1071 1075
         echo ' ><em class="fa fa-forward"> </em> '.get_lang('UpgradeFromLMS19x').'</button>';
1072 1076
 
1073 1077
         echo '</p>';
@@ -1350,7 +1354,7 @@  discard block
 block discarded – undo
1350 1354
                 <input type="hidden" name="dbHostForm" value="<?php echo htmlentities($dbHostForm); ?>" /><?php echo $dbHostForm; ?>
1351 1355
             </div>
1352 1356
             <div class="col-sm-3"></div>
1353
-            <?php }else{ ?>
1357
+            <?php } else{ ?>
1354 1358
             <div class="col-sm-5">
1355 1359
                 <input type="text" class="form-control" size="25" maxlength="50" name="dbHostForm" value="<?php echo htmlentities($dbHostForm); ?>" />
1356 1360
             </div>
@@ -1364,7 +1368,7 @@  discard block
 block discarded – undo
1364 1368
                 <input type="hidden" name="dbPortForm" value="<?php echo htmlentities($dbPortForm); ?>" /><?php echo $dbPortForm; ?>
1365 1369
             </div>
1366 1370
             <div class="col-sm-3"></div>
1367
-            <?php }else{ ?>
1371
+            <?php } else{ ?>
1368 1372
             <div class="col-sm-5">
1369 1373
                 <input type="text" class="form-control" size="25" maxlength="50" name="dbPortForm" value="<?php echo htmlentities($dbPortForm); ?>" />
1370 1374
             </div>
@@ -1446,9 +1450,12 @@  discard block
 block discarded – undo
1446 1450
             Database port: <strong><?php echo $manager->getConnection()->getPort(); ?></strong><br/>
1447 1451
             Database driver: <strong><?php echo $manager->getConnection()->getDriver()->getName(); ?></strong><br/>
1448 1452
         </div>
1449
-    <?php else: ?>
1453
+    <?php else {
1454
+    : ?>
1450 1455
         <div id="db_status" class="alert alert-danger">
1451
-            <p><?php echo get_lang('FailedConectionDatabase'); ?></strong></p>
1456
+            <p><?php echo get_lang('FailedConectionDatabase');
1457
+}
1458
+?></strong></p>
1452 1459
             <code><?php echo $database_exists_text ?></code>
1453 1460
         </div>
1454 1461
     <?php endif; ?>
Please login to merge, or discard this patch.