Passed
Push — 1.10.x ( 51b3f0...0b3bd8 )
by Yannick
116:33 queued 61:35
created
main/inc/lib/text.lib.php 4 patches
Doc Comments   +10 added lines, -5 removed lines patch added patch discarded remove patch
@@ -52,6 +52,7 @@  discard block
 block discarded – undo
52 52
  * Converts the text of a html-document to a given encoding, the meta-tag is changed accordingly.
53 53
  * @param string $string                The input full-html document.
54 54
  * @param string                        The new encoding value to be set.
55
+ * @param string $encoding
55 56
  */
56 57
 function api_set_encoding_html(&$string, $encoding) {
57 58
     $old_encoding = api_detect_encoding_html($string);
@@ -74,7 +75,7 @@  discard block
 block discarded – undo
74 75
  * Returns the title of a html document.
75 76
  * @param string $string                The contents of the input document.
76 77
  * @param string $input_encoding        The encoding of the input document. If the value is not set, it is detected.
77
- * @param string $$output_encoding      The encoding of the retrieved title. If the value is not set, the system encoding is assumend.
78
+ * @param string $output_encoding      The encoding of the retrieved title. If the value is not set, the system encoding is assumend.
78 79
  * @return string                       The retrieved title, html-entities and extra-whitespace between the words are cleaned.
79 80
  */
80 81
 function api_get_title_html(&$string, $output_encoding = null, $input_encoding = null) {
@@ -433,7 +434,7 @@  discard block
 block discarded – undo
433 434
  * @since wordpress  2.8.1
434 435
  * @access private
435 436
  *
436
- * @param string|array $search The value being searched for, otherwise known as the needle. An array may be used to designate multiple needles.
437
+ * @param string[] $search The value being searched for, otherwise known as the needle. An array may be used to designate multiple needles.
437 438
  * @param string $subject The string being searched and replaced on, otherwise known as the haystack.
438 439
  * @return string The string with the replaced svalues.
439 440
  */
@@ -628,6 +629,7 @@  discard block
 block discarded – undo
628 629
  * @param string    The text to "cut"
629 630
  * @param int       Count of chars
630 631
  * @param bool      Whether to embed in a <span title="...">...</span>
632
+ * @param integer $maxchar
631 633
  * @return string
632 634
  * */
633 635
 function cut($text, $maxchar, $embed = false) {
@@ -645,7 +647,7 @@  discard block
 block discarded – undo
645 647
  *
646 648
  * @param mixed     Number to convert
647 649
  * @param int       Decimal points 0=never, 1=if needed, 2=always
648
- * @return mixed    An integer or a float depends on the parameter
650
+ * @return string|null    An integer or a float depends on the parameter
649 651
  */
650 652
 function float_format($number, $flag = 1) {
651 653
     if (is_numeric($number)) {
@@ -689,7 +691,7 @@  discard block
 block discarded – undo
689 691
 /**
690 692
  * Gets the week from a day
691 693
  * @param   string   Date in UTC (2010-01-01 12:12:12)
692
- * @return  int      Returns an integer with the week number of the year
694
+ * @return  string      Returns an integer with the week number of the year
693 695
  */
694 696
 function get_week_from_day($date) {
695 697
     if (!empty($date)) {
@@ -739,6 +741,9 @@  discard block
 block discarded – undo
739 741
 	return $output.$end;
740 742
 }
741 743
 
744
+/**
745
+ * @param string $glue
746
+ */
742 747
 function implode_with_key($glue, $array) {
743 748
     if (!empty($array)) {
744 749
         $string = '';
@@ -817,7 +822,7 @@  discard block
 block discarded – undo
817 822
 /**
818 823
  * @param string $string
819 824
  * @param bool $capitalizeFirstCharacter
820
- * @return mixed
825
+ * @return string
821 826
  */
822 827
 function underScoreToCamelCase($string, $capitalizeFirstCharacter = true)
823 828
 {
Please login to merge, or discard this patch.
Spacing   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -58,10 +58,10 @@  discard block
 block discarded – undo
58 58
     if (@preg_match('/(.*<head.*)(<meta[^>]*content=[^>]*>)(.*<\/head>.*)/si', $string, $matches)) {
59 59
         $meta = $matches[2];
60 60
         if (@preg_match("/(<meta[^>]*charset=)(.*)([\"';][^>]*>)/si", $meta, $matches1)) {
61
-            $meta = $matches1[1] . $encoding . $matches1[3];
62
-            $string = $matches[1] . $meta . $matches[3];
61
+            $meta = $matches1[1].$encoding.$matches1[3];
62
+            $string = $matches[1].$meta.$matches[3];
63 63
         } else {
64
-            $string = $matches[1] . '<meta http-equiv="Content-Type" content="text/html; charset='.$encoding.'"/>' . $matches[3];
64
+            $string = $matches[1].'<meta http-equiv="Content-Type" content="text/html; charset='.$encoding.'"/>'.$matches[3];
65 65
         }
66 66
     } else {
67 67
         $count = 1;
@@ -168,9 +168,9 @@  discard block
 block discarded – undo
168 168
     if (!preg_match(_PCRE_XML_ENCODING, $string)) {
169 169
         if (strpos($matches[0], 'standalone') !== false) {
170 170
             // The encoding option should precede the standalone option, othewise DOMDocument fails to load the document.
171
-            $replace = str_replace('standalone', ' encoding="'.$to_encoding.'" standalone' , $matches[0]);
171
+            $replace = str_replace('standalone', ' encoding="'.$to_encoding.'" standalone', $matches[0]);
172 172
         } else {
173
-            $replace = str_replace('?>', ' encoding="'.$to_encoding.'"?>' , $matches[0]);
173
+            $replace = str_replace('?>', ' encoding="'.$to_encoding.'"?>', $matches[0]);
174 174
         }
175 175
         return api_convert_encoding(str_replace($matches[0], $replace, $string), $to_encoding, $from_encoding);
176 176
     }
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
 function _make_url_clickable_cb($matches) {
336 336
     $url = $matches[2];
337 337
 
338
-    if ( ')' == $matches[3] && strpos( $url, '(' ) ) {
338
+    if (')' == $matches[3] && strpos($url, '(')) {
339 339
         // If the trailing character is a closing parethesis, and the URL has an opening parenthesis in it, add the closing parenthesis to the URL.
340 340
         // Then we can let the parenthesis balancer do its thing below.
341 341
         $url .= $matches[3];
@@ -345,16 +345,16 @@  discard block
 block discarded – undo
345 345
     }
346 346
 
347 347
     // Include parentheses in the URL only if paired
348
-    while ( substr_count( $url, '(' ) < substr_count( $url, ')' ) ) {
349
-        $suffix = strrchr( $url, ')' ) . $suffix;
350
-        $url = substr( $url, 0, strrpos( $url, ')' ) );
348
+    while (substr_count($url, '(') < substr_count($url, ')')) {
349
+        $suffix = strrchr($url, ')').$suffix;
350
+        $url = substr($url, 0, strrpos($url, ')'));
351 351
     }
352 352
 
353 353
     $url = esc_url($url);
354
-    if ( empty($url) )
354
+    if (empty($url))
355 355
         return $matches[0];
356 356
 
357
-    return $matches[1] . "<a href=\"$url\" rel=\"nofollow\">$url</a>" . $suffix;
357
+    return $matches[1]."<a href=\"$url\" rel=\"nofollow\">$url</a>".$suffix;
358 358
 }
359 359
 
360 360
 /**
@@ -374,10 +374,10 @@  discard block
 block discarded – undo
374 374
  * @param string $_context Private. Use esc_url_raw() for database usage.
375 375
  * @return string The cleaned $url after the 'clean_url' filter is applied.
376 376
  */
377
-function esc_url( $url, $protocols = null, $_context = 'display' ) {
377
+function esc_url($url, $protocols = null, $_context = 'display') {
378 378
     //$original_url = $url;
379 379
 
380
-    if ( '' == $url )
380
+    if ('' == $url)
381 381
         return $url;
382 382
     $url = preg_replace('|[^a-z0-9-~+_.?#=!&;,/:%@$\|*\'()\\x80-\\xff]|i', '', $url);
383 383
     $strip = array('%0d', '%0a', '%0D', '%0A');
@@ -387,9 +387,9 @@  discard block
 block discarded – undo
387 387
      * presume it needs http:// appended (unless a relative
388 388
      * link starting with /, # or ? or a php file).
389 389
      */
390
-    if ( strpos($url, ':') === false && ! in_array( $url[0], array( '/', '#', '?' ) ) &&
391
-        ! preg_match('/^[a-z0-9-]+?\.php/i', $url) )
392
-        $url = 'http://' . $url;
390
+    if (strpos($url, ':') === false && !in_array($url[0], array('/', '#', '?')) &&
391
+        !preg_match('/^[a-z0-9-]+?\.php/i', $url))
392
+        $url = 'http://'.$url;
393 393
 
394 394
     return Security::remove_XSS($url);
395 395
 
@@ -437,12 +437,12 @@  discard block
 block discarded – undo
437 437
  * @param string $subject The string being searched and replaced on, otherwise known as the haystack.
438 438
  * @return string The string with the replaced svalues.
439 439
  */
440
-function _deep_replace( $search, $subject ) {
440
+function _deep_replace($search, $subject) {
441 441
     $subject = (string) $subject;
442 442
 
443 443
     $count = 1;
444
-    while ( $count ) {
445
-        $subject = str_replace( $search, '', $subject, $count );
444
+    while ($count) {
445
+        $subject = str_replace($search, '', $subject, $count);
446 446
     }
447 447
 
448 448
     return $subject;
@@ -464,17 +464,17 @@  discard block
 block discarded – undo
464 464
 function _make_web_ftp_clickable_cb($matches) {
465 465
     $ret = '';
466 466
     $dest = $matches[2];
467
-    $dest = 'http://' . $dest;
467
+    $dest = 'http://'.$dest;
468 468
     $dest = esc_url($dest);
469
-    if ( empty($dest) )
469
+    if (empty($dest))
470 470
         return $matches[0];
471 471
 
472 472
     // removed trailing [.,;:)] from URL
473
-    if ( in_array( substr($dest, -1), array('.', ',', ';', ':', ')') ) === true ) {
473
+    if (in_array(substr($dest, -1), array('.', ',', ';', ':', ')')) === true) {
474 474
         $ret = substr($dest, -1);
475
-        $dest = substr($dest, 0, strlen($dest)-1);
475
+        $dest = substr($dest, 0, strlen($dest) - 1);
476 476
     }
477
-    return $matches[1] . "<a href=\"$dest\" rel=\"nofollow\">$dest</a>$ret";
477
+    return $matches[1]."<a href=\"$dest\" rel=\"nofollow\">$dest</a>$ret";
478 478
 }
479 479
 
480 480
 /**
@@ -490,8 +490,8 @@  discard block
 block discarded – undo
490 490
  * @return string HTML A element with email address.
491 491
  */
492 492
 function _make_email_clickable_cb($matches) {
493
-    $email = $matches[2] . '@' . $matches[3];
494
-    return $matches[1] . "<a href=\"mailto:$email\">$email</a>";
493
+    $email = $matches[2].'@'.$matches[3];
494
+    return $matches[1]."<a href=\"mailto:$email\">$email</a>";
495 495
 }
496 496
 
497 497
 /**
@@ -505,30 +505,30 @@  discard block
 block discarded – undo
505 505
  * @param string $text Content to convert URIs.
506 506
  * @return string Content with converted URIs.
507 507
  */
508
-function make_clickable( $text ) {
508
+function make_clickable($text) {
509 509
     $r = '';
510
-    $textarr = preg_split( '/(<[^<>]+>)/', $text, -1, PREG_SPLIT_DELIM_CAPTURE ); // split out HTML tags
510
+    $textarr = preg_split('/(<[^<>]+>)/', $text, -1, PREG_SPLIT_DELIM_CAPTURE); // split out HTML tags
511 511
     $nested_code_pre = 0; // Keep track of how many levels link is nested inside <pre> or <code>
512
-    foreach ( $textarr as $piece ) {
512
+    foreach ($textarr as $piece) {
513 513
 
514
-        if ( preg_match( '|^<code[\s>]|i', $piece ) || preg_match( '|^<pre[\s>]|i', $piece ) )
514
+        if (preg_match('|^<code[\s>]|i', $piece) || preg_match('|^<pre[\s>]|i', $piece))
515 515
             $nested_code_pre++;
516
-        elseif ( ( '</code>' === strtolower( $piece ) || '</pre>' === strtolower( $piece ) ) && $nested_code_pre )
516
+        elseif (('</code>' === strtolower($piece) || '</pre>' === strtolower($piece)) && $nested_code_pre)
517 517
             $nested_code_pre--;
518 518
 
519
-        if ( $nested_code_pre || empty( $piece ) || ( $piece[0] === '<' && ! preg_match( '|^<\s*[\w]{1,20}+://|', $piece ) ) ) {
519
+        if ($nested_code_pre || empty($piece) || ($piece[0] === '<' && !preg_match('|^<\s*[\w]{1,20}+://|', $piece))) {
520 520
             $r .= $piece;
521 521
             continue;
522 522
         }
523 523
 
524 524
         // Long strings might contain expensive edge cases ...
525
-        if ( 10000 < strlen( $piece ) ) {
525
+        if (10000 < strlen($piece)) {
526 526
             // ... break it up
527
-            foreach ( _split_str_by_whitespace( $piece, 2100 ) as $chunk ) { // 2100: Extra room for scheme and leading and trailing paretheses
528
-                if ( 2101 < strlen( $chunk ) ) {
527
+            foreach (_split_str_by_whitespace($piece, 2100) as $chunk) { // 2100: Extra room for scheme and leading and trailing paretheses
528
+                if (2101 < strlen($chunk)) {
529 529
                     $r .= $chunk; // Too big, no whitespace: bail.
530 530
                 } else {
531
-                    $r .= make_clickable( $chunk );
531
+                    $r .= make_clickable($chunk);
532 532
                 }
533 533
             }
534 534
         } else {
@@ -549,18 +549,18 @@  discard block
 block discarded – undo
549 549
 			~xS'; // The regex is a non-anchored pattern and does not have a single fixed starting character.
550 550
             // Tell PCRE to spend more time optimizing since, when used on a page load, it will probably be used several times.
551 551
 
552
-            $ret = preg_replace_callback( $url_clickable, '_make_url_clickable_cb', $ret );
552
+            $ret = preg_replace_callback($url_clickable, '_make_url_clickable_cb', $ret);
553 553
 
554
-            $ret = preg_replace_callback( '#([\s>])((www|ftp)\.[\w\\x80-\\xff\#$%&~/.\-;:=,?@\[\]+]+)#is', '_make_web_ftp_clickable_cb', $ret );
555
-            $ret = preg_replace_callback( '#([\s>])([.0-9a-z_+-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,})#i', '_make_email_clickable_cb', $ret );
554
+            $ret = preg_replace_callback('#([\s>])((www|ftp)\.[\w\\x80-\\xff\#$%&~/.\-;:=,?@\[\]+]+)#is', '_make_web_ftp_clickable_cb', $ret);
555
+            $ret = preg_replace_callback('#([\s>])([.0-9a-z_+-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,})#i', '_make_email_clickable_cb', $ret);
556 556
 
557
-            $ret = substr( $ret, 1, -1 ); // Remove our whitespace padding.
557
+            $ret = substr($ret, 1, -1); // Remove our whitespace padding.
558 558
             $r .= $ret;
559 559
         }
560 560
     }
561 561
 
562 562
     // Cleanup of accidental links within links
563
-    $r = preg_replace( '#(<a([ \r\n\t]+[^>]+?>|>))<a [^>]+?>([^>]+?)</a></a>#i', "$1$3</a>", $r );
563
+    $r = preg_replace('#(<a([ \r\n\t]+[^>]+?>|>))<a [^>]+?>([^>]+?)</a></a>#i', "$1$3</a>", $r);
564 564
     return $r;
565 565
 }
566 566
 
@@ -595,27 +595,27 @@  discard block
 block discarded – undo
595 595
  * @param int $goal The desired chunk length.
596 596
  * @return array Numeric array of chunks.
597 597
  */
598
-function _split_str_by_whitespace( $string, $goal ) {
598
+function _split_str_by_whitespace($string, $goal) {
599 599
     $chunks = array();
600 600
 
601
-    $string_nullspace = strtr( $string, "\r\n\t\v\f ", "\000\000\000\000\000\000" );
601
+    $string_nullspace = strtr($string, "\r\n\t\v\f ", "\000\000\000\000\000\000");
602 602
 
603
-    while ( $goal < strlen( $string_nullspace ) ) {
604
-        $pos = strrpos( substr( $string_nullspace, 0, $goal + 1 ), "\000" );
603
+    while ($goal < strlen($string_nullspace)) {
604
+        $pos = strrpos(substr($string_nullspace, 0, $goal + 1), "\000");
605 605
 
606
-        if ( false === $pos ) {
607
-            $pos = strpos( $string_nullspace, "\000", $goal + 1 );
608
-            if ( false === $pos ) {
606
+        if (false === $pos) {
607
+            $pos = strpos($string_nullspace, "\000", $goal + 1);
608
+            if (false === $pos) {
609 609
                 break;
610 610
             }
611 611
         }
612 612
 
613
-        $chunks[] = substr( $string, 0, $pos + 1 );
614
-        $string = substr( $string, $pos + 1 );
615
-        $string_nullspace = substr( $string_nullspace, $pos + 1 );
613
+        $chunks[] = substr($string, 0, $pos + 1);
614
+        $string = substr($string, $pos + 1);
615
+        $string_nullspace = substr($string_nullspace, $pos + 1);
616 616
     }
617 617
 
618
-    if ( $string ) {
618
+    if ($string) {
619 619
         $chunks[] = $string;
620 620
     }
621 621
 
@@ -693,7 +693,7 @@  discard block
 block discarded – undo
693 693
  */
694 694
 function get_week_from_day($date) {
695 695
     if (!empty($date)) {
696
-       $time = api_strtotime($date,'UTC');
696
+       $time = api_strtotime($date, 'UTC');
697 697
        return date('W', $time);
698 698
     } else {
699 699
         return date('W');
@@ -710,17 +710,17 @@  discard block
 block discarded – undo
710 710
  * @return a reduce string
711 711
  */
712 712
 
713
-function substrwords($text,$maxchar,$end='...')
713
+function substrwords($text, $maxchar, $end = '...')
714 714
 {
715
-	if(strlen($text)>$maxchar)
715
+	if (strlen($text) > $maxchar)
716 716
 	{
717
-		$words=explode(" ",$text);
717
+		$words = explode(" ", $text);
718 718
 		$output = '';
719
-		$i=0;
720
-		while(1)
719
+		$i = 0;
720
+		while (1)
721 721
 		{
722
-			$length = (strlen($output)+strlen($words[$i]));
723
-			if($length>$maxchar)
722
+			$length = (strlen($output) + strlen($words[$i]));
723
+			if ($length > $maxchar)
724 724
 			{
725 725
 				break;
726 726
 			}
@@ -742,7 +742,7 @@  discard block
 block discarded – undo
742 742
 function implode_with_key($glue, $array) {
743 743
     if (!empty($array)) {
744 744
         $string = '';
745
-        foreach($array as $key => $value) {
745
+        foreach ($array as $key => $value) {
746 746
             if (empty($value)) {
747 747
                 $value = 'null';
748 748
             }
@@ -764,13 +764,13 @@  discard block
 block discarded – undo
764 764
 {
765 765
     $file_size = intval($file_size);
766 766
     if ($file_size >= 1073741824) {
767
-        $file_size = round($file_size / 1073741824 * 100) / 100 . 'G';
768
-    } elseif($file_size >= 1048576) {
769
-        $file_size = round($file_size / 1048576 * 100) / 100 . 'M';
770
-    } elseif($file_size >= 1024) {
771
-        $file_size = round($file_size / 1024 * 100) / 100 . 'k';
767
+        $file_size = round($file_size / 1073741824 * 100) / 100.'G';
768
+    } elseif ($file_size >= 1048576) {
769
+        $file_size = round($file_size / 1048576 * 100) / 100.'M';
770
+    } elseif ($file_size >= 1024) {
771
+        $file_size = round($file_size / 1024 * 100) / 100.'k';
772 772
     } else {
773
-        $file_size = $file_size . 'B';
773
+        $file_size = $file_size.'B';
774 774
     }
775 775
     return $file_size;
776 776
 }
@@ -779,18 +779,18 @@  discard block
 block discarded – undo
779 779
 {
780 780
     $year	 = '0000';
781 781
     $month = $day = $hours = $minutes = $seconds = '00';
782
-    if (isset($array['Y']) && (isset($array['F']) || isset($array['M']))  && isset($array['d']) && isset($array['H']) && isset($array['i'])) {
782
+    if (isset($array['Y']) && (isset($array['F']) || isset($array['M'])) && isset($array['d']) && isset($array['H']) && isset($array['i'])) {
783 783
         $year = $array['Y'];
784
-        $month = isset($array['F'])?$array['F']:$array['M'];
785
-        if (intval($month) < 10 ) $month = '0'.$month;
784
+        $month = isset($array['F']) ? $array['F'] : $array['M'];
785
+        if (intval($month) < 10) $month = '0'.$month;
786 786
         $day = $array['d'];
787
-        if (intval($day) < 10 ) $day = '0'.$day;
787
+        if (intval($day) < 10) $day = '0'.$day;
788 788
         $hours = $array['H'];
789
-        if (intval($hours) < 10 ) $hours = '0'.$hours;
789
+        if (intval($hours) < 10) $hours = '0'.$hours;
790 790
         $minutes = $array['i'];
791
-        if (intval($minutes) < 10 ) $minutes = '0'.$minutes;
791
+        if (intval($minutes) < 10) $minutes = '0'.$minutes;
792 792
     }
793
-    if (checkdate($month,$day,$year)) {
793
+    if (checkdate($month, $day, $year)) {
794 794
         $datetime = $year.'-'.$month.'-'.$day.' '.$hours.':'.$minutes.':'.$seconds;
795 795
     }
796 796
     return $datetime;
Please login to merge, or discard this patch.
Braces   +31 added lines, -20 removed lines patch added patch discarded remove patch
@@ -351,8 +351,9 @@  discard block
 block discarded – undo
351 351
     }
352 352
 
353 353
     $url = esc_url($url);
354
-    if ( empty($url) )
355
-        return $matches[0];
354
+    if ( empty($url) ) {
355
+            return $matches[0];
356
+    }
356 357
 
357 358
     return $matches[1] . "<a href=\"$url\" rel=\"nofollow\">$url</a>" . $suffix;
358 359
 }
@@ -377,8 +378,9 @@  discard block
 block discarded – undo
377 378
 function esc_url( $url, $protocols = null, $_context = 'display' ) {
378 379
     //$original_url = $url;
379 380
 
380
-    if ( '' == $url )
381
-        return $url;
381
+    if ( '' == $url ) {
382
+            return $url;
383
+    }
382 384
     $url = preg_replace('|[^a-z0-9-~+_.?#=!&;,/:%@$\|*\'()\\x80-\\xff]|i', '', $url);
383 385
     $strip = array('%0d', '%0a', '%0D', '%0A');
384 386
     $url = _deep_replace($strip, $url);
@@ -388,8 +390,9 @@  discard block
 block discarded – undo
388 390
      * link starting with /, # or ? or a php file).
389 391
      */
390 392
     if ( strpos($url, ':') === false && ! in_array( $url[0], array( '/', '#', '?' ) ) &&
391
-        ! preg_match('/^[a-z0-9-]+?\.php/i', $url) )
392
-        $url = 'http://' . $url;
393
+        ! preg_match('/^[a-z0-9-]+?\.php/i', $url) ) {
394
+            $url = 'http://' . $url;
395
+    }
393 396
 
394 397
     return Security::remove_XSS($url);
395 398
 
@@ -466,8 +469,9 @@  discard block
 block discarded – undo
466 469
     $dest = $matches[2];
467 470
     $dest = 'http://' . $dest;
468 471
     $dest = esc_url($dest);
469
-    if ( empty($dest) )
470
-        return $matches[0];
472
+    if ( empty($dest) ) {
473
+            return $matches[0];
474
+    }
471 475
 
472 476
     // removed trailing [.,;:)] from URL
473 477
     if ( in_array( substr($dest, -1), array('.', ',', ';', ':', ')') ) === true ) {
@@ -511,10 +515,11 @@  discard block
 block discarded – undo
511 515
     $nested_code_pre = 0; // Keep track of how many levels link is nested inside <pre> or <code>
512 516
     foreach ( $textarr as $piece ) {
513 517
 
514
-        if ( preg_match( '|^<code[\s>]|i', $piece ) || preg_match( '|^<pre[\s>]|i', $piece ) )
515
-            $nested_code_pre++;
516
-        elseif ( ( '</code>' === strtolower( $piece ) || '</pre>' === strtolower( $piece ) ) && $nested_code_pre )
517
-            $nested_code_pre--;
518
+        if ( preg_match( '|^<code[\s>]|i', $piece ) || preg_match( '|^<pre[\s>]|i', $piece ) ) {
519
+                    $nested_code_pre++;
520
+        } elseif ( ( '</code>' === strtolower( $piece ) || '</pre>' === strtolower( $piece ) ) && $nested_code_pre ) {
521
+                    $nested_code_pre--;
522
+        }
518 523
 
519 524
         if ( $nested_code_pre || empty( $piece ) || ( $piece[0] === '<' && ! preg_match( '|^<\s*[\w]{1,20}+://|', $piece ) ) ) {
520 525
             $r .= $piece;
@@ -723,15 +728,13 @@  discard block
 block discarded – undo
723 728
 			if($length>$maxchar)
724 729
 			{
725 730
 				break;
726
-			}
727
-			else
731
+			} else
728 732
 			{
729 733
 				$output = $output." ".$words[$i];
730 734
 				$i++;
731 735
 			};
732 736
 		};
733
-	}
734
-	else
737
+	} else
735 738
 	{
736 739
 		$output = $text;
737 740
 		return $output;
@@ -782,13 +785,21 @@  discard block
 block discarded – undo
782 785
     if (isset($array['Y']) && (isset($array['F']) || isset($array['M']))  && isset($array['d']) && isset($array['H']) && isset($array['i'])) {
783 786
         $year = $array['Y'];
784 787
         $month = isset($array['F'])?$array['F']:$array['M'];
785
-        if (intval($month) < 10 ) $month = '0'.$month;
788
+        if (intval($month) < 10 ) {
789
+            $month = '0'.$month;
790
+        }
786 791
         $day = $array['d'];
787
-        if (intval($day) < 10 ) $day = '0'.$day;
792
+        if (intval($day) < 10 ) {
793
+            $day = '0'.$day;
794
+        }
788 795
         $hours = $array['H'];
789
-        if (intval($hours) < 10 ) $hours = '0'.$hours;
796
+        if (intval($hours) < 10 ) {
797
+            $hours = '0'.$hours;
798
+        }
790 799
         $minutes = $array['i'];
791
-        if (intval($minutes) < 10 ) $minutes = '0'.$minutes;
800
+        if (intval($minutes) < 10 ) {
801
+            $minutes = '0'.$minutes;
802
+        }
792 803
     }
793 804
     if (checkdate($month,$day,$year)) {
794 805
         $datetime = $year.'-'.$month.'-'.$day.' '.$hours.':'.$minutes.':'.$seconds;
Please login to merge, or discard this patch.
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -693,8 +693,8 @@  discard block
 block discarded – undo
693 693
  */
694 694
 function get_week_from_day($date) {
695 695
     if (!empty($date)) {
696
-       $time = api_strtotime($date,'UTC');
697
-       return date('W', $time);
696
+        $time = api_strtotime($date,'UTC');
697
+        return date('W', $time);
698 698
     } else {
699 699
         return date('W');
700 700
     }
@@ -712,31 +712,31 @@  discard block
 block discarded – undo
712 712
 
713 713
 function substrwords($text,$maxchar,$end='...')
714 714
 {
715
-	if(strlen($text)>$maxchar)
716
-	{
717
-		$words=explode(" ",$text);
718
-		$output = '';
719
-		$i=0;
720
-		while(1)
721
-		{
722
-			$length = (strlen($output)+strlen($words[$i]));
723
-			if($length>$maxchar)
724
-			{
725
-				break;
726
-			}
727
-			else
728
-			{
729
-				$output = $output." ".$words[$i];
730
-				$i++;
731
-			};
732
-		};
733
-	}
734
-	else
735
-	{
736
-		$output = $text;
737
-		return $output;
738
-	}
739
-	return $output.$end;
715
+    if(strlen($text)>$maxchar)
716
+    {
717
+        $words=explode(" ",$text);
718
+        $output = '';
719
+        $i=0;
720
+        while(1)
721
+        {
722
+            $length = (strlen($output)+strlen($words[$i]));
723
+            if($length>$maxchar)
724
+            {
725
+                break;
726
+            }
727
+            else
728
+            {
729
+                $output = $output." ".$words[$i];
730
+                $i++;
731
+            };
732
+        };
733
+    }
734
+    else
735
+    {
736
+        $output = $text;
737
+        return $output;
738
+    }
739
+    return $output.$end;
740 740
 }
741 741
 
742 742
 function implode_with_key($glue, $array) {
Please login to merge, or discard this patch.
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.
Indentation   +862 added lines, -862 removed lines patch added patch discarded remove patch
@@ -311,8 +311,8 @@  discard block
 block discarded – undo
311 311
                     $extend_link = '';
312 312
                     if (!empty($inter_num)) {
313 313
                         $extend_link = Display::url(
314
-                              Display::return_icon('visible.gif', get_lang('HideAttemptView')),
315
-                              api_get_self() . '?action=stats&fold_id=' . $my_item_id . $url_suffix
314
+                                Display::return_icon('visible.gif', get_lang('HideAttemptView')),
315
+                                api_get_self() . '?action=stats&fold_id=' . $my_item_id . $url_suffix
316 316
                         );
317 317
                     }
318 318
                     $title = $row['mytitle'];
@@ -1319,7 +1319,7 @@  discard block
 block discarded – undo
1319 1319
             case 'last_30_days':
1320 1320
                 $new_date = date('Y-m-d H:i:s', strtotime('-30 day'));
1321 1321
                 $condition_time = ' AND (login_date >= "'.$new_date.'" AND logout_date <= "'.$today.'") ';
1322
-               break;
1322
+                break;
1323 1323
             case 'custom':
1324 1324
                 if (!empty($start_date) && !empty($end_date)) {
1325 1325
                     $start_date = Database::escape_string($start_date);
@@ -1329,10 +1329,10 @@  discard block
 block discarded – undo
1329 1329
                 break;
1330 1330
         }
1331 1331
 
1332
-    	$sql = 'SELECT SUM(TIMESTAMPDIFF(SECOND, login_date, logout_date)) diff
1332
+        $sql = 'SELECT SUM(TIMESTAMPDIFF(SECOND, login_date, logout_date)) diff
1333 1333
     	        FROM '.$tbl_track_login.'
1334 1334
                 WHERE '.$userCondition.$condition_time;
1335
-    	$rs = Database::query($sql);
1335
+        $rs = Database::query($sql);
1336 1336
         $row = Database::fetch_array($rs, 'ASSOC');
1337 1337
         $diff = $row['diff'];
1338 1338
 
@@ -1354,18 +1354,18 @@  discard block
 block discarded – undo
1354 1354
     public static function get_time_spent_on_the_course($user_id, $courseId, $session_id = 0)
1355 1355
     {
1356 1356
         $courseId = intval($courseId);
1357
-    	$session_id  = intval($session_id);
1358
-
1359
-    	$tbl_track_course = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1360
-    	if (is_array($user_id)) {
1361
-    	    $user_id = array_map('intval', $user_id);
1362
-    		$condition_user = " AND user_id IN (".implode(',',$user_id).") ";
1363
-    	} else {
1364
-    		$user_id = intval($user_id);
1365
-    		$condition_user = " AND user_id = $user_id ";
1366
-    	}
1367
-
1368
-    	$sql = "SELECT
1357
+        $session_id  = intval($session_id);
1358
+
1359
+        $tbl_track_course = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1360
+        if (is_array($user_id)) {
1361
+            $user_id = array_map('intval', $user_id);
1362
+            $condition_user = " AND user_id IN (".implode(',',$user_id).") ";
1363
+        } else {
1364
+            $user_id = intval($user_id);
1365
+            $condition_user = " AND user_id = $user_id ";
1366
+        }
1367
+
1368
+        $sql = "SELECT
1369 1369
     	        SUM(UNIX_TIMESTAMP(logout_course_date) - UNIX_TIMESTAMP(login_course_date)) as nb_seconds
1370 1370
                 FROM $tbl_track_course
1371 1371
                 WHERE UNIX_TIMESTAMP(logout_course_date) > UNIX_TIMESTAMP(login_course_date) ";
@@ -1381,9 +1381,9 @@  discard block
 block discarded – undo
1381 1381
         $sql .= $condition_user;
1382 1382
 
1383 1383
         $rs = Database::query($sql);
1384
-    	$row = Database::fetch_array($rs);
1384
+        $row = Database::fetch_array($rs);
1385 1385
 
1386
-    	return $row['nb_seconds'];
1386
+        return $row['nb_seconds'];
1387 1387
     }
1388 1388
 
1389 1389
     /**
@@ -1394,25 +1394,25 @@  discard block
 block discarded – undo
1394 1394
      */
1395 1395
     public static function get_first_connection_date($student_id)
1396 1396
     {
1397
-    	$tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
1398
-    	$sql = 'SELECT login_date
1397
+        $tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
1398
+        $sql = 'SELECT login_date
1399 1399
     	        FROM ' . $tbl_track_login . '
1400 1400
                 WHERE login_user_id = ' . intval($student_id) . '
1401 1401
                 ORDER BY login_date ASC
1402 1402
                 LIMIT 0,1';
1403 1403
 
1404
-    	$rs = Database::query($sql);
1405
-    	if (Database::num_rows($rs)>0) {
1406
-    		if ($first_login_date = Database::result($rs, 0, 0)) {
1404
+        $rs = Database::query($sql);
1405
+        if (Database::num_rows($rs)>0) {
1406
+            if ($first_login_date = Database::result($rs, 0, 0)) {
1407 1407
                 return api_convert_and_format_date(
1408 1408
                     $first_login_date,
1409 1409
                     DATE_FORMAT_SHORT,
1410 1410
                     date_default_timezone_get()
1411 1411
                 );
1412
-    		}
1413
-    	}
1412
+            }
1413
+        }
1414 1414
 
1415
-    	return false;
1415
+        return false;
1416 1416
     }
1417 1417
 
1418 1418
     /**
@@ -1425,38 +1425,38 @@  discard block
 block discarded – undo
1425 1425
      */
1426 1426
     public static function get_last_connection_date($student_id, $warning_message = false, $return_timestamp = false)
1427 1427
     {
1428
-    	$table = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
1429
-    	$sql = 'SELECT login_date
1428
+        $table = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
1429
+        $sql = 'SELECT login_date
1430 1430
     	        FROM ' . $table . '
1431 1431
                 WHERE login_user_id = ' . intval($student_id) . '
1432 1432
                 ORDER BY login_date
1433 1433
                 DESC LIMIT 0,1';
1434 1434
 
1435
-    	$rs = Database::query($sql);
1436
-    	if (Database::num_rows($rs) > 0) {
1437
-    		if ($last_login_date = Database::result($rs, 0, 0)) {
1438
-    			$last_login_date = api_get_local_time($last_login_date);
1439
-    			if ($return_timestamp) {
1440
-    				return api_strtotime($last_login_date,'UTC');
1441
-    			} else {
1442
-    				if (!$warning_message) {
1443
-    					return api_format_date($last_login_date, DATE_FORMAT_SHORT);
1444
-    				} else {
1445
-    					$timestamp = api_strtotime($last_login_date,'UTC');
1446
-    					$currentTimestamp = time();
1447
-
1448
-    					//If the last connection is > than 7 days, the text is red
1449
-    					//345600 = 7 days in seconds
1450
-    					if ($currentTimestamp - $timestamp > 604800) {
1451
-    						return '<span style="color: #F00;">' . api_format_date($last_login_date, DATE_FORMAT_SHORT) . '</span>';
1452
-    					} else {
1453
-    						return api_format_date($last_login_date, DATE_FORMAT_SHORT);
1454
-    					}
1455
-    				}
1456
-    			}
1457
-    		}
1458
-    	}
1459
-    	return false;
1435
+        $rs = Database::query($sql);
1436
+        if (Database::num_rows($rs) > 0) {
1437
+            if ($last_login_date = Database::result($rs, 0, 0)) {
1438
+                $last_login_date = api_get_local_time($last_login_date);
1439
+                if ($return_timestamp) {
1440
+                    return api_strtotime($last_login_date,'UTC');
1441
+                } else {
1442
+                    if (!$warning_message) {
1443
+                        return api_format_date($last_login_date, DATE_FORMAT_SHORT);
1444
+                    } else {
1445
+                        $timestamp = api_strtotime($last_login_date,'UTC');
1446
+                        $currentTimestamp = time();
1447
+
1448
+                        //If the last connection is > than 7 days, the text is red
1449
+                        //345600 = 7 days in seconds
1450
+                        if ($currentTimestamp - $timestamp > 604800) {
1451
+                            return '<span style="color: #F00;">' . api_format_date($last_login_date, DATE_FORMAT_SHORT) . '</span>';
1452
+                        } else {
1453
+                            return api_format_date($last_login_date, DATE_FORMAT_SHORT);
1454
+                        }
1455
+                    }
1456
+                }
1457
+            }
1458
+        }
1459
+        return false;
1460 1460
     }
1461 1461
 
1462 1462
     /**
@@ -1510,30 +1510,30 @@  discard block
 block discarded – undo
1510 1510
         $session_id = 0,
1511 1511
         $convert_date = true
1512 1512
     ) {
1513
-    	$student_id  = intval($student_id);
1513
+        $student_id  = intval($student_id);
1514 1514
         $courseId = intval($courseId);
1515
-    	$session_id  = intval($session_id);
1515
+        $session_id  = intval($session_id);
1516 1516
 
1517
-    	$tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1518
-    	$sql = 'SELECT login_course_date
1517
+        $tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1518
+        $sql = 'SELECT login_course_date
1519 1519
     	        FROM '.$tbl_track_login.'
1520 1520
                 WHERE
1521 1521
                     user_id = '.$student_id.' AND
1522 1522
                     c_id = '.$courseId.' AND
1523 1523
                     session_id = '.$session_id.'
1524 1524
                 ORDER BY login_course_date ASC LIMIT 0,1';
1525
-    	$rs = Database::query($sql);
1526
-    	if (Database::num_rows($rs) > 0) {
1527
-    		if ($first_login_date = Database::result($rs, 0, 0)) {
1528
-    			if ($convert_date) {
1529
-    				return api_convert_and_format_date($first_login_date, DATE_FORMAT_SHORT);
1530
-    			} else {
1531
-    				return $first_login_date;
1532
-    			}
1533
-    		}
1534
-    	}
1535
-
1536
-    	return false;
1525
+        $rs = Database::query($sql);
1526
+        if (Database::num_rows($rs) > 0) {
1527
+            if ($first_login_date = Database::result($rs, 0, 0)) {
1528
+                if ($convert_date) {
1529
+                    return api_convert_and_format_date($first_login_date, DATE_FORMAT_SHORT);
1530
+                } else {
1531
+                    return $first_login_date;
1532
+                }
1533
+            }
1534
+        }
1535
+
1536
+        return false;
1537 1537
     }
1538 1538
 
1539 1539
     /**
@@ -1549,13 +1549,13 @@  discard block
 block discarded – undo
1549 1549
         $session_id = 0,
1550 1550
         $convert_date = true
1551 1551
     ) {
1552
-    	// protect data
1553
-    	$student_id  = intval($student_id);
1552
+        // protect data
1553
+        $student_id  = intval($student_id);
1554 1554
         $courseId = $courseInfo['real_id'];
1555
-    	$session_id  = intval($session_id);
1555
+        $session_id  = intval($session_id);
1556 1556
 
1557
-    	$tbl_track_e_access = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
1558
-    	$sql = 'SELECT access_date
1557
+        $tbl_track_e_access = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
1558
+        $sql = 'SELECT access_date
1559 1559
                 FROM '.$tbl_track_e_access.'
1560 1560
                 WHERE   access_user_id = '.$student_id.' AND
1561 1561
                         c_id = "'.$courseId.'" AND
@@ -1563,38 +1563,38 @@  discard block
 block discarded – undo
1563 1563
                 ORDER BY access_date DESC
1564 1564
                 LIMIT 0,1';
1565 1565
 
1566
-    	$rs = Database::query($sql);
1567
-    	if (Database::num_rows($rs) > 0) {
1568
-    		if ($last_login_date = Database::result($rs, 0, 0)) {
1566
+        $rs = Database::query($sql);
1567
+        if (Database::num_rows($rs) > 0) {
1568
+            if ($last_login_date = Database::result($rs, 0, 0)) {
1569 1569
                 if (empty($last_login_date) || $last_login_date == '0000-00-00 00:00:00') {
1570 1570
                     return false;
1571 1571
                 }
1572 1572
                 //see #5736
1573 1573
                 $last_login_date_timestamp = api_strtotime($last_login_date);
1574
-    			$now = time();
1575
-    			//If the last connection is > than 7 days, the text is red
1576
-    			//345600 = 7 days in seconds
1577
-    			if ($now - $last_login_date_timestamp > 604800) {
1578
-    				if ($convert_date) {
1574
+                $now = time();
1575
+                //If the last connection is > than 7 days, the text is red
1576
+                //345600 = 7 days in seconds
1577
+                if ($now - $last_login_date_timestamp > 604800) {
1578
+                    if ($convert_date) {
1579 1579
                         $last_login_date = api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT);
1580 1580
                         $icon = api_is_allowed_to_edit() ?
1581 1581
                             '<a href="'.api_get_path(REL_CODE_PATH).'announcements/announcements.php?action=add&remind_inactive='.$student_id.'&cidReq='.$courseInfo['code'].'" title="'.get_lang('RemindInactiveUser').'">
1582 1582
                              <img src="'.api_get_path(WEB_IMG_PATH).'messagebox_warning.gif" /> </a>'
1583 1583
                             : null;
1584
-    					return $icon. Display::label($last_login_date, 'warning');
1585
-    				} else {
1586
-    					return $last_login_date;
1587
-    				}
1588
-    			} else {
1589
-    				if ($convert_date) {
1590
-    					return api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT);
1591
-    				} else {
1592
-    					return $last_login_date;
1593
-    				}
1594
-    			}
1595
-    		}
1596
-    	}
1597
-    	return false;
1584
+                        return $icon. Display::label($last_login_date, 'warning');
1585
+                    } else {
1586
+                        return $last_login_date;
1587
+                    }
1588
+                } else {
1589
+                    if ($convert_date) {
1590
+                        return api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT);
1591
+                    } else {
1592
+                        return $last_login_date;
1593
+                    }
1594
+                }
1595
+            }
1596
+        }
1597
+        return false;
1598 1598
     }
1599 1599
 
1600 1600
     /**
@@ -1607,36 +1607,36 @@  discard block
 block discarded – undo
1607 1607
      */
1608 1608
     public static function get_course_connections_count($courseId, $session_id = 0, $start = 0, $stop = null)
1609 1609
     {
1610
-    	if ($start < 0) {
1611
-    		$start = 0;
1612
-    	}
1613
-    	if (!isset($stop) or ($stop < 0)) {
1614
-    		$stop = api_get_utc_datetime();
1615
-    	}
1610
+        if ($start < 0) {
1611
+            $start = 0;
1612
+        }
1613
+        if (!isset($stop) or ($stop < 0)) {
1614
+            $stop = api_get_utc_datetime();
1615
+        }
1616 1616
 
1617 1617
         $start = Database::escape_string($start);
1618 1618
         $stop = Database::escape_string($stop);
1619 1619
 
1620
-    	$month_filter = " AND login_course_date > '$start' AND login_course_date < '$stop' ";
1620
+        $month_filter = " AND login_course_date > '$start' AND login_course_date < '$stop' ";
1621 1621
 
1622 1622
         $courseId = intval($courseId);
1623
-    	$session_id  = intval($session_id);
1624
-    	$count = 0;
1623
+        $session_id  = intval($session_id);
1624
+        $count = 0;
1625 1625
 
1626
-    	$tbl_track_e_course_access = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1627
-    	$sql = "SELECT count(*) as count_connections
1626
+        $tbl_track_e_course_access = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1627
+        $sql = "SELECT count(*) as count_connections
1628 1628
                 FROM $tbl_track_e_course_access
1629 1629
                 WHERE
1630 1630
                     c_id = $courseId AND
1631 1631
                     session_id = $session_id
1632 1632
                     $month_filter";
1633
-    	$rs = Database::query($sql);
1634
-    	if (Database::num_rows($rs)>0) {
1635
-    		$row = Database::fetch_object($rs);
1636
-    		$count = $row->count_connections;
1637
-    	}
1633
+        $rs = Database::query($sql);
1634
+        if (Database::num_rows($rs)>0) {
1635
+            $row = Database::fetch_object($rs);
1636
+            $count = $row->count_connections;
1637
+        }
1638 1638
 
1639
-    	return $count;
1639
+        return $count;
1640 1640
     }
1641 1641
 
1642 1642
     /**
@@ -1647,25 +1647,25 @@  discard block
 block discarded – undo
1647 1647
      */
1648 1648
     public static function count_course_per_student($user_id, $include_sessions = true)
1649 1649
     {
1650
-    	$user_id = intval($user_id);
1651
-    	$tbl_course_rel_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
1652
-    	$tbl_session_course_rel_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
1650
+        $user_id = intval($user_id);
1651
+        $tbl_course_rel_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
1652
+        $tbl_session_course_rel_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
1653 1653
 
1654
-    	$sql = 'SELECT DISTINCT c_id
1654
+        $sql = 'SELECT DISTINCT c_id
1655 1655
                 FROM ' . $tbl_course_rel_user . '
1656 1656
                 WHERE user_id = ' . $user_id.' AND relation_type<>'.COURSE_RELATION_TYPE_RRHH;
1657
-    	$rs = Database::query($sql);
1658
-    	$nb_courses = Database::num_rows($rs);
1657
+        $rs = Database::query($sql);
1658
+        $nb_courses = Database::num_rows($rs);
1659 1659
 
1660
-    	if ($include_sessions) {
1661
-    		$sql = 'SELECT DISTINCT c_id
1660
+        if ($include_sessions) {
1661
+            $sql = 'SELECT DISTINCT c_id
1662 1662
                     FROM ' . $tbl_session_course_rel_user . '
1663 1663
                     WHERE user_id = ' . $user_id;
1664
-    		$rs = Database::query($sql);
1665
-    		$nb_courses += Database::num_rows($rs);
1666
-    	}
1664
+            $rs = Database::query($sql);
1665
+            $nb_courses += Database::num_rows($rs);
1666
+        }
1667 1667
 
1668
-    	return $nb_courses;
1668
+        return $nb_courses;
1669 1669
     }
1670 1670
 
1671 1671
     /**
@@ -1696,25 +1696,25 @@  discard block
 block discarded – undo
1696 1696
         $into_lp = 0
1697 1697
     ) {
1698 1698
         $course_code = Database::escape_string($course_code);
1699
-    	$course_info = api_get_course_info($course_code);
1700
-    	if (!empty($course_info)) {
1701
-    		// table definition
1702
-    		$tbl_course_quiz     = Database::get_course_table(TABLE_QUIZ_TEST);
1703
-    		$tbl_stats_exercise  = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
1704
-
1705
-    		// Compose a filter based on optional exercise given
1706
-    		$condition_quiz = "";
1707
-    		if (!empty($exercise_id)) {
1708
-    			$exercise_id = intval($exercise_id);
1709
-    			$condition_quiz =" AND id = $exercise_id ";
1710
-    		}
1711
-
1712
-    		// Compose a filter based on optional session id given
1713
-    		$condition_session = "";
1714
-    		if (isset($session_id)) {
1715
-    			$session_id = intval($session_id);
1716
-    			$condition_session = " AND session_id = $session_id ";
1717
-    		}
1699
+        $course_info = api_get_course_info($course_code);
1700
+        if (!empty($course_info)) {
1701
+            // table definition
1702
+            $tbl_course_quiz     = Database::get_course_table(TABLE_QUIZ_TEST);
1703
+            $tbl_stats_exercise  = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
1704
+
1705
+            // Compose a filter based on optional exercise given
1706
+            $condition_quiz = "";
1707
+            if (!empty($exercise_id)) {
1708
+                $exercise_id = intval($exercise_id);
1709
+                $condition_quiz =" AND id = $exercise_id ";
1710
+            }
1711
+
1712
+            // Compose a filter based on optional session id given
1713
+            $condition_session = "";
1714
+            if (isset($session_id)) {
1715
+                $session_id = intval($session_id);
1716
+                $condition_session = " AND session_id = $session_id ";
1717
+            }
1718 1718
             if ($active_filter == 1) {
1719 1719
                 $condition_active = 'AND active <> -1';
1720 1720
             } elseif ($active_filter == 0) {
@@ -1730,25 +1730,25 @@  discard block
 block discarded – undo
1730 1730
                 $select_lp_id = ', orig_lp_id as lp_id ';
1731 1731
             }
1732 1732
 
1733
-    		$sql = "SELECT count(id) FROM $tbl_course_quiz
1733
+            $sql = "SELECT count(id) FROM $tbl_course_quiz
1734 1734
     				WHERE c_id = {$course_info['real_id']} $condition_active $condition_quiz ";
1735
-    		$count_quiz = Database::fetch_row(Database::query($sql));
1735
+            $count_quiz = Database::fetch_row(Database::query($sql));
1736 1736
 
1737
-    		if (!empty($count_quiz[0]) && !empty($student_id)) {
1738
-    			if (is_array($student_id)) {
1737
+            if (!empty($count_quiz[0]) && !empty($student_id)) {
1738
+                if (is_array($student_id)) {
1739 1739
                     $student_id = array_map('intval', $student_id);
1740
-    				$condition_user = " AND exe_user_id IN (".implode(',', $student_id).") ";
1741
-    			} else {
1740
+                    $condition_user = " AND exe_user_id IN (".implode(',', $student_id).") ";
1741
+                } else {
1742 1742
                     $student_id = intval($student_id);
1743
-    				$condition_user = " AND exe_user_id = '$student_id' ";
1744
-    			}
1743
+                    $condition_user = " AND exe_user_id = '$student_id' ";
1744
+                }
1745 1745
 
1746
-    			if (empty($exercise_id)) {
1747
-    				$sql = "SELECT id FROM $tbl_course_quiz
1746
+                if (empty($exercise_id)) {
1747
+                    $sql = "SELECT id FROM $tbl_course_quiz
1748 1748
     						WHERE c_id = {$course_info['real_id']} $condition_active $condition_quiz";
1749 1749
                     $result = Database::query($sql);
1750 1750
                     $exercise_list = array();
1751
-    				$exercise_id = null;
1751
+                    $exercise_id = null;
1752 1752
                     if (Database::num_rows($result)) {
1753 1753
                         while ($row = Database::fetch_array($result)) {
1754 1754
                             $exercise_list[] = $row['id'];
@@ -1757,11 +1757,11 @@  discard block
 block discarded – undo
1757 1757
                     if (!empty($exercise_list)) {
1758 1758
                         $exercise_id = implode("','",$exercise_list);
1759 1759
                     }
1760
-    			}
1760
+                }
1761 1761
 
1762
-    			$count_quiz = Database::fetch_row(Database::query($sql));
1762
+                $count_quiz = Database::fetch_row(Database::query($sql));
1763 1763
 
1764
-    			$sql = "SELECT
1764
+                $sql = "SELECT
1765 1765
     			        SUM(exe_result/exe_weighting*100) as avg_score,
1766 1766
     			        COUNT(*) as num_attempts
1767 1767
     			        $select_lp_id
@@ -1775,20 +1775,20 @@  discard block
 block discarded – undo
1775 1775
                             $condition_into_lp
1776 1776
                         ORDER BY exe_date DESC";
1777 1777
 
1778
-    			$res = Database::query($sql);
1779
-    			$row = Database::fetch_array($res);
1780
-    			$quiz_avg_score = null;
1778
+                $res = Database::query($sql);
1779
+                $row = Database::fetch_array($res);
1780
+                $quiz_avg_score = null;
1781 1781
 
1782
-    			if (!empty($row['avg_score'])) {
1783
-    				$quiz_avg_score = round($row['avg_score'],2);
1784
-    			}
1782
+                if (!empty($row['avg_score'])) {
1783
+                    $quiz_avg_score = round($row['avg_score'],2);
1784
+                }
1785 1785
 
1786
-    			if(!empty($row['num_attempts'])) {
1787
-    				$quiz_avg_score = round($quiz_avg_score / $row['num_attempts'], 2);
1788
-    			}
1789
-    			if (is_array($student_id)) {
1790
-    				$quiz_avg_score = round($quiz_avg_score / count($student_id), 2);
1791
-    			}
1786
+                if(!empty($row['num_attempts'])) {
1787
+                    $quiz_avg_score = round($quiz_avg_score / $row['num_attempts'], 2);
1788
+                }
1789
+                if (is_array($student_id)) {
1790
+                    $quiz_avg_score = round($quiz_avg_score / count($student_id), 2);
1791
+                }
1792 1792
                 if ($into_lp == 0) {
1793 1793
                     return $quiz_avg_score;
1794 1794
                 } else {
@@ -1811,9 +1811,9 @@  discard block
 block discarded – undo
1811 1811
                         return array($quiz_avg_score, null);
1812 1812
                     }
1813 1813
                 }
1814
-    		}
1815
-    	}
1816
-    	return null;
1814
+            }
1815
+        }
1816
+        return null;
1817 1817
     }
1818 1818
 
1819 1819
     /**
@@ -1846,15 +1846,15 @@  discard block
 block discarded – undo
1846 1846
         $find_all_lp = 0
1847 1847
     ) {
1848 1848
         $courseId = intval($courseId);
1849
-    	$student_id  = intval($student_id);
1850
-    	$exercise_id = intval($exercise_id);
1851
-    	$session_id  = intval($session_id);
1849
+        $student_id  = intval($student_id);
1850
+        $exercise_id = intval($exercise_id);
1851
+        $session_id  = intval($session_id);
1852 1852
 
1853
-    	$lp_id = intval($lp_id);
1853
+        $lp_id = intval($lp_id);
1854 1854
         $lp_item_id = intval($lp_item_id);
1855
-    	$tbl_stats_exercises = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
1855
+        $tbl_stats_exercises = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
1856 1856
 
1857
-    	$sql = "SELECT COUNT(ex.exe_id) as essais FROM $tbl_stats_exercises AS ex
1857
+        $sql = "SELECT COUNT(ex.exe_id) as essais FROM $tbl_stats_exercises AS ex
1858 1858
                 WHERE  ex.c_id = $courseId
1859 1859
                 AND ex.exe_exo_id = $exercise_id
1860 1860
                 AND status = ''
@@ -1869,11 +1869,11 @@  discard block
 block discarded – undo
1869 1869
                 AND orig_lp_item_id = $lp_item_id";
1870 1870
         }
1871 1871
 
1872
-    	$rs = Database::query($sql);
1873
-    	$row = Database::fetch_row($rs);
1874
-    	$count_attempts = $row[0];
1872
+        $rs = Database::query($sql);
1873
+        $row = Database::fetch_row($rs);
1874
+        $count_attempts = $row[0];
1875 1875
 
1876
-    	return $count_attempts;
1876
+        return $count_attempts;
1877 1877
     }
1878 1878
 
1879 1879
     /**
@@ -1883,7 +1883,7 @@  discard block
 block discarded – undo
1883 1883
      * @param int    $user_id
1884 1884
      * @param int    $courseId
1885 1885
      * @param int    $session_id
1886
-    */
1886
+     */
1887 1887
     public static function get_exercise_student_progress($exercise_list, $user_id, $courseId, $session_id)
1888 1888
     {
1889 1889
         $courseId = intval($courseId);
@@ -3499,8 +3499,8 @@  discard block
 block discarded – undo
3499 3499
 
3500 3500
         $condition_session = '';
3501 3501
         if (isset($session_id)) {
3502
-             $session_id = intval($session_id);
3503
-             $condition_session = ' AND f.session_id = '. $session_id;
3502
+                $session_id = intval($session_id);
3503
+                $condition_session = ' AND f.session_id = '. $session_id;
3504 3504
         }
3505 3505
 
3506 3506
         $groupId = intval($groupId);
@@ -5399,9 +5399,9 @@  discard block
 block discarded – undo
5399 5399
     }
5400 5400
 
5401 5401
     /**
5402
-    * @param FormValidator $form
5403
-    * @return mixed
5404
-    */
5402
+     * @param FormValidator $form
5403
+     * @return mixed
5404
+     */
5405 5405
     public static function setUserSearchForm($form)
5406 5406
     {
5407 5407
         global $_configuration;
@@ -5680,26 +5680,26 @@  discard block
 block discarded – undo
5680 5680
         $session_id = api_get_session_id();
5681 5681
         $course_id = api_get_course_int_id();
5682 5682
 
5683
-    	$table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
5684
-    	$table_user = Database :: get_main_table(TABLE_MAIN_USER);
5683
+        $table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
5684
+        $table_user = Database :: get_main_table(TABLE_MAIN_USER);
5685 5685
 
5686
-    	$sql = "SELECT count(tool) AS total_number_of_items
5686
+        $sql = "SELECT count(tool) AS total_number_of_items
5687 5687
     	        FROM $table_item_property track_resource, $table_user user
5688 5688
     	        WHERE
5689 5689
                     track_resource.c_id = $course_id AND
5690 5690
                     track_resource.insert_user_id = user.user_id AND
5691 5691
                     session_id " .(empty($session_id) ? ' IS NULL ' : " = $session_id ");
5692 5692
 
5693
-    	if (isset($_GET['keyword'])) {
5694
-    		$keyword = Database::escape_string(trim($_GET['keyword']));
5695
-    		$sql .= " AND (
5693
+        if (isset($_GET['keyword'])) {
5694
+            $keyword = Database::escape_string(trim($_GET['keyword']));
5695
+            $sql .= " AND (
5696 5696
     		            user.username LIKE '%".$keyword."%' OR
5697 5697
     		            lastedit_type LIKE '%".$keyword."%' OR
5698 5698
     		            tool LIKE '%".$keyword."%'
5699 5699
                     )";
5700
-    	}
5700
+        }
5701 5701
 
5702
-    	$sql .= " AND tool IN (
5702
+        $sql .= " AND tool IN (
5703 5703
     	            'document',
5704 5704
     	            'learnpath',
5705 5705
     	            'quiz',
@@ -5711,10 +5711,10 @@  discard block
 block discarded – undo
5711 5711
     	            'thematic_advance',
5712 5712
     	            'thematic_plan'
5713 5713
                 )";
5714
-    	$res = Database::query($sql);
5715
-    	$obj = Database::fetch_object($res);
5714
+        $res = Database::query($sql);
5715
+        $obj = Database::fetch_object($res);
5716 5716
 
5717
-    	return $obj->total_number_of_items;
5717
+        return $obj->total_number_of_items;
5718 5718
     }
5719 5719
 
5720 5720
     /**
@@ -5729,12 +5729,12 @@  discard block
 block discarded – undo
5729 5729
         $session_id = api_get_session_id();
5730 5730
         $course_id = api_get_course_int_id();
5731 5731
 
5732
-    	$table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
5733
-    	$table_user = Database :: get_main_table(TABLE_MAIN_USER);
5734
-    	$table_session = Database :: get_main_table(TABLE_MAIN_SESSION);
5735
-    	$session_id = intval($session_id);
5732
+        $table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
5733
+        $table_user = Database :: get_main_table(TABLE_MAIN_USER);
5734
+        $table_session = Database :: get_main_table(TABLE_MAIN_SESSION);
5735
+        $session_id = intval($session_id);
5736 5736
 
5737
-    	$sql = "SELECT
5737
+        $sql = "SELECT
5738 5738
                     tool as col0,
5739 5739
                     lastedit_type as col1,
5740 5740
                     ref as ref,
@@ -5748,16 +5748,16 @@  discard block
 block discarded – undo
5748 5748
                   track_resource.insert_user_id = user.user_id AND
5749 5749
                   session_id " .(empty($session_id) ? ' IS NULL ' : " = $session_id ");
5750 5750
 
5751
-    	if (isset($_GET['keyword'])) {
5752
-    		$keyword = Database::escape_string(trim($_GET['keyword']));
5753
-    		$sql .= " AND (
5751
+        if (isset($_GET['keyword'])) {
5752
+            $keyword = Database::escape_string(trim($_GET['keyword']));
5753
+            $sql .= " AND (
5754 5754
     		            user.username LIKE '%".$keyword."%' OR
5755 5755
     		            lastedit_type LIKE '%".$keyword."%' OR
5756 5756
     		            tool LIKE '%".$keyword."%'
5757 5757
                      ) ";
5758
-    	}
5758
+        }
5759 5759
 
5760
-    	$sql .= " AND tool IN (
5760
+        $sql .= " AND tool IN (
5761 5761
     	            'document',
5762 5762
     	            'learnpath',
5763 5763
     	            'quiz',
@@ -5770,41 +5770,41 @@  discard block
 block discarded – undo
5770 5770
     	            'thematic_plan'
5771 5771
                 )";
5772 5772
 
5773
-    	if ($column == 0) {
5774
-    		$column = '0';
5775
-    	}
5776
-    	if ($column != '' && $direction != '') {
5777
-    		if ($column != 2 && $column != 4) {
5778
-    			$sql .= " ORDER BY col$column $direction";
5779
-    		}
5780
-    	} else {
5781
-    		$sql .= " ORDER BY col5 DESC ";
5782
-    	}
5773
+        if ($column == 0) {
5774
+            $column = '0';
5775
+        }
5776
+        if ($column != '' && $direction != '') {
5777
+            if ($column != 2 && $column != 4) {
5778
+                $sql .= " ORDER BY col$column $direction";
5779
+            }
5780
+        } else {
5781
+            $sql .= " ORDER BY col5 DESC ";
5782
+        }
5783 5783
 
5784 5784
         $from = intval($from);
5785 5785
         $number_of_items = intval($number_of_items);
5786 5786
 
5787
-    	$sql .= " LIMIT $from, $number_of_items ";
5788
-
5789
-    	$res = Database::query($sql);
5790
-    	$resources = array();
5791
-    	$thematic_tools = array('thematic', 'thematic_advance', 'thematic_plan');
5792
-    	while ($row = Database::fetch_array($res)) {
5793
-    		$ref = $row['ref'];
5794
-    		$table_name = TrackingCourseLog::get_tool_name_table($row['col0']);
5795
-    		$table_tool = Database :: get_course_table($table_name['table_name']);
5796
-
5797
-    		$id = $table_name['id_tool'];
5798
-    		$recorset = false;
5787
+        $sql .= " LIMIT $from, $number_of_items ";
5799 5788
 
5800
-    		if (in_array($row['col0'], array('thematic_plan', 'thematic_advance'))) {
5801
-    			$tbl_thematic = Database :: get_course_table(TABLE_THEMATIC);
5802
-    			$sql = "SELECT thematic_id FROM $table_tool
5789
+        $res = Database::query($sql);
5790
+        $resources = array();
5791
+        $thematic_tools = array('thematic', 'thematic_advance', 'thematic_plan');
5792
+        while ($row = Database::fetch_array($res)) {
5793
+            $ref = $row['ref'];
5794
+            $table_name = TrackingCourseLog::get_tool_name_table($row['col0']);
5795
+            $table_tool = Database :: get_course_table($table_name['table_name']);
5796
+
5797
+            $id = $table_name['id_tool'];
5798
+            $recorset = false;
5799
+
5800
+            if (in_array($row['col0'], array('thematic_plan', 'thematic_advance'))) {
5801
+                $tbl_thematic = Database :: get_course_table(TABLE_THEMATIC);
5802
+                $sql = "SELECT thematic_id FROM $table_tool
5803 5803
     			        WHERE c_id = $course_id AND id = $ref";
5804
-    			$rs_thematic  = Database::query($sql);
5805
-    			if (Database::num_rows($rs_thematic)) {
5806
-    				$row_thematic = Database::fetch_array($rs_thematic);
5807
-    				$thematic_id = $row_thematic['thematic_id'];
5804
+                $rs_thematic  = Database::query($sql);
5805
+                if (Database::num_rows($rs_thematic)) {
5806
+                    $row_thematic = Database::fetch_array($rs_thematic);
5807
+                    $thematic_id = $row_thematic['thematic_id'];
5808 5808
 
5809 5809
                     $sql = "SELECT session.id, session.name, user.username
5810 5810
                             FROM $tbl_thematic t, $table_session session, $table_user user
@@ -5813,9 +5813,9 @@  discard block
 block discarded – undo
5813 5813
                               t.session_id = session.id AND
5814 5814
                               session.id_coach = user.user_id AND
5815 5815
                               t.id = $thematic_id";
5816
-    				$recorset = Database::query($sql);
5817
-    			}
5818
-    		} else {
5816
+                    $recorset = Database::query($sql);
5817
+                }
5818
+            } else {
5819 5819
                 $sql = "SELECT session.id, session.name, user.username
5820 5820
                           FROM $table_tool tool, $table_session session, $table_user user
5821 5821
     			          WHERE
@@ -5823,127 +5823,127 @@  discard block
 block discarded – undo
5823 5823
     			              tool.session_id = session.id AND
5824 5824
     			              session.id_coach = user.user_id AND
5825 5825
     			              tool.$id = $ref";
5826
-    			$recorset = Database::query($sql);
5827
-    		}
5828
-
5829
-    		if (!empty($recorset)) {
5830
-    			$obj = Database::fetch_object($recorset);
5831
-
5832
-    			$name_session = '';
5833
-    			$coach_name = '';
5834
-    			if (!empty($obj)) {
5835
-    				$name_session = $obj->name;
5836
-    				$coach_name   = $obj->username;
5837
-    			}
5838
-
5839
-    			$url_tool = api_get_path(WEB_CODE_PATH).$table_name['link_tool'];
5840
-    			$row[0] = '';
5841
-    			if ($row['col6'] != 2) {
5842
-    				if (in_array($row['col0'], $thematic_tools)) {
5843
-
5844
-    					$exp_thematic_tool = explode('_', $row['col0']);
5845
-    					$thematic_tool_title = '';
5846
-    					if (is_array($exp_thematic_tool)) {
5847
-    						foreach ($exp_thematic_tool as $exp) {
5848
-    							$thematic_tool_title .= api_ucfirst($exp);
5849
-    						}
5850
-    					} else {
5851
-    						$thematic_tool_title = api_ucfirst($row['col0']);
5852
-    					}
5853
-
5854
-    					$row[0] = '<a href="'.$url_tool.'?'.api_get_cidreq().'&action=thematic_details">'.get_lang($thematic_tool_title).'</a>';
5855
-    				} else {
5856
-    					$row[0] = '<a href="'.$url_tool.'?'.api_get_cidreq().'">'.get_lang('Tool'.api_ucfirst($row['col0'])).'</a>';
5857
-    				}
5858
-    			} else {
5859
-    				$row[0] = api_ucfirst($row['col0']);
5860
-    			}
5861
-    			$row[1] = get_lang($row[1]);
5862
-    			$row[6] = api_convert_and_format_date($row['col5'], null, date_default_timezone_get());
5863
-    			$row[5] = '';
5864
-    			//@todo Improve this code please
5865
-    			switch ($table_name['table_name']) {
5866
-    				case 'document' :
5867
-    					$sql = "SELECT tool.title as title FROM $table_tool tool
5826
+                $recorset = Database::query($sql);
5827
+            }
5828
+
5829
+            if (!empty($recorset)) {
5830
+                $obj = Database::fetch_object($recorset);
5831
+
5832
+                $name_session = '';
5833
+                $coach_name = '';
5834
+                if (!empty($obj)) {
5835
+                    $name_session = $obj->name;
5836
+                    $coach_name   = $obj->username;
5837
+                }
5838
+
5839
+                $url_tool = api_get_path(WEB_CODE_PATH).$table_name['link_tool'];
5840
+                $row[0] = '';
5841
+                if ($row['col6'] != 2) {
5842
+                    if (in_array($row['col0'], $thematic_tools)) {
5843
+
5844
+                        $exp_thematic_tool = explode('_', $row['col0']);
5845
+                        $thematic_tool_title = '';
5846
+                        if (is_array($exp_thematic_tool)) {
5847
+                            foreach ($exp_thematic_tool as $exp) {
5848
+                                $thematic_tool_title .= api_ucfirst($exp);
5849
+                            }
5850
+                        } else {
5851
+                            $thematic_tool_title = api_ucfirst($row['col0']);
5852
+                        }
5853
+
5854
+                        $row[0] = '<a href="'.$url_tool.'?'.api_get_cidreq().'&action=thematic_details">'.get_lang($thematic_tool_title).'</a>';
5855
+                    } else {
5856
+                        $row[0] = '<a href="'.$url_tool.'?'.api_get_cidreq().'">'.get_lang('Tool'.api_ucfirst($row['col0'])).'</a>';
5857
+                    }
5858
+                } else {
5859
+                    $row[0] = api_ucfirst($row['col0']);
5860
+                }
5861
+                $row[1] = get_lang($row[1]);
5862
+                $row[6] = api_convert_and_format_date($row['col5'], null, date_default_timezone_get());
5863
+                $row[5] = '';
5864
+                //@todo Improve this code please
5865
+                switch ($table_name['table_name']) {
5866
+                    case 'document' :
5867
+                        $sql = "SELECT tool.title as title FROM $table_tool tool
5868 5868
                                 WHERE c_id = $course_id AND id = $ref";
5869
-    					$rs_document = Database::query($sql);
5870
-    					$obj_document = Database::fetch_object($rs_document);
5871
-    					$row[5] = $obj_document->title;
5869
+                        $rs_document = Database::query($sql);
5870
+                        $obj_document = Database::fetch_object($rs_document);
5871
+                        $row[5] = $obj_document->title;
5872 5872
 
5873
-    					break;
5874
-    				case 'announcement':
5873
+                        break;
5874
+                    case 'announcement':
5875 5875
                         $sql = "SELECT title FROM $table_tool
5876 5876
                                 WHERE c_id = $course_id AND id = $ref";
5877
-    					$rs_document = Database::query($sql);
5878
-    					$obj_document = Database::fetch_object($rs_document);
5877
+                        $rs_document = Database::query($sql);
5878
+                        $obj_document = Database::fetch_object($rs_document);
5879 5879
                         if ($obj_document) {
5880 5880
                             $row[5] = $obj_document->title;
5881 5881
                         }
5882
-    					break;
5883
-    				case 'glossary':
5882
+                        break;
5883
+                    case 'glossary':
5884 5884
                         $sql = "SELECT name FROM $table_tool
5885 5885
     					        WHERE c_id = $course_id AND glossary_id = $ref";
5886
-    					$rs_document = Database::query($sql);
5887
-    					$obj_document = Database::fetch_object($rs_document);
5886
+                        $rs_document = Database::query($sql);
5887
+                        $obj_document = Database::fetch_object($rs_document);
5888 5888
                         if ($obj_document) {
5889 5889
                             $row[5] = $obj_document->name;
5890 5890
                         }
5891
-    					break;
5892
-    				case 'lp':
5891
+                        break;
5892
+                    case 'lp':
5893 5893
                         $sql = "SELECT name
5894 5894
                                 FROM $table_tool WHERE c_id = $course_id AND id = $ref";
5895
-    					$rs_document = Database::query($sql);
5896
-    					$obj_document = Database::fetch_object($rs_document);
5897
-    					$row[5] = $obj_document->name;
5898
-    					break;
5899
-    				case 'quiz':
5895
+                        $rs_document = Database::query($sql);
5896
+                        $obj_document = Database::fetch_object($rs_document);
5897
+                        $row[5] = $obj_document->name;
5898
+                        break;
5899
+                    case 'quiz':
5900 5900
                         $sql = "SELECT title FROM $table_tool
5901 5901
                                 WHERE c_id = $course_id AND id = $ref";
5902
-    					$rs_document = Database::query($sql);
5903
-    					$obj_document = Database::fetch_object($rs_document);
5902
+                        $rs_document = Database::query($sql);
5903
+                        $obj_document = Database::fetch_object($rs_document);
5904 5904
                         if ($obj_document) {
5905 5905
                             $row[5] = $obj_document->title;
5906 5906
                         }
5907
-    					break;
5908
-    				case 'course_description':
5907
+                        break;
5908
+                    case 'course_description':
5909 5909
                         $sql = "SELECT title FROM $table_tool
5910 5910
                                 WHERE c_id = $course_id AND id = $ref";
5911
-    					$rs_document = Database::query($sql);
5912
-    					$obj_document = Database::fetch_object($rs_document);
5911
+                        $rs_document = Database::query($sql);
5912
+                        $obj_document = Database::fetch_object($rs_document);
5913 5913
                         if ($obj_document) {
5914 5914
                             $row[5] = $obj_document->title;
5915 5915
                         }
5916
-    					break;
5917
-    				case 'thematic':
5918
-    					$rs = Database::query("SELECT title FROM $table_tool WHERE c_id = $course_id AND id = $ref");
5919
-    					if (Database::num_rows($rs) > 0) {
5920
-    						$obj = Database::fetch_object($rs);
5921
-    						$row[5] = $obj->title;
5922
-    					}
5923
-    					break;
5924
-    				case 'thematic_advance':
5925
-    					$rs = Database::query("SELECT content FROM $table_tool WHERE c_id = $course_id AND id = $ref");
5926
-    					if (Database::num_rows($rs) > 0) {
5927
-    						$obj = Database::fetch_object($rs);
5928
-    						$row[5] = $obj->content;
5929
-    					}
5930
-    					break;
5931
-    				case 'thematic_plan':
5932
-    					$rs = Database::query("SELECT title FROM $table_tool WHERE c_id = $course_id AND id = $ref");
5933
-    					if (Database::num_rows($rs) > 0) {
5934
-    						$obj = Database::fetch_object($rs);
5935
-    						$row[5] = $obj->title;
5936
-    					}
5937
-    					break;
5938
-    				default:
5939
-    					break;
5940
-    			}
5941
-
5942
-    			$row2 = $name_session;
5943
-    			if (!empty($coach_name)) {
5944
-    				$row2 .= '<br />'.get_lang('Coach').': '.$coach_name;
5945
-    			}
5946
-    			$row[2] = $row2;
5916
+                        break;
5917
+                    case 'thematic':
5918
+                        $rs = Database::query("SELECT title FROM $table_tool WHERE c_id = $course_id AND id = $ref");
5919
+                        if (Database::num_rows($rs) > 0) {
5920
+                            $obj = Database::fetch_object($rs);
5921
+                            $row[5] = $obj->title;
5922
+                        }
5923
+                        break;
5924
+                    case 'thematic_advance':
5925
+                        $rs = Database::query("SELECT content FROM $table_tool WHERE c_id = $course_id AND id = $ref");
5926
+                        if (Database::num_rows($rs) > 0) {
5927
+                            $obj = Database::fetch_object($rs);
5928
+                            $row[5] = $obj->content;
5929
+                        }
5930
+                        break;
5931
+                    case 'thematic_plan':
5932
+                        $rs = Database::query("SELECT title FROM $table_tool WHERE c_id = $course_id AND id = $ref");
5933
+                        if (Database::num_rows($rs) > 0) {
5934
+                            $obj = Database::fetch_object($rs);
5935
+                            $row[5] = $obj->title;
5936
+                        }
5937
+                        break;
5938
+                    default:
5939
+                        break;
5940
+                }
5941
+
5942
+                $row2 = $name_session;
5943
+                if (!empty($coach_name)) {
5944
+                    $row2 .= '<br />'.get_lang('Coach').': '.$coach_name;
5945
+                }
5946
+                $row[2] = $row2;
5947 5947
                 if (!empty($row['col3'])) {
5948 5948
                     $userInfo = api_get_user_info($row['user_id']);
5949 5949
 
@@ -5960,11 +5960,11 @@  discard block
 block discarded – undo
5960 5960
                     $row[4] = $ip;
5961 5961
                 }
5962 5962
 
5963
-    			$resources[] = $row;
5964
-    		}
5965
-    	}
5963
+                $resources[] = $row;
5964
+            }
5965
+        }
5966 5966
 
5967
-    	return $resources;
5967
+        return $resources;
5968 5968
     }
5969 5969
 
5970 5970
     /**
@@ -5974,63 +5974,63 @@  discard block
 block discarded – undo
5974 5974
      */
5975 5975
     public static function get_tool_name_table($tool)
5976 5976
     {
5977
-    	switch ($tool) {
5978
-    		case 'document':
5979
-    			$table_name = TABLE_DOCUMENT;
5980
-    			$link_tool = 'document/document.php';
5981
-    			$id_tool = 'id';
5982
-    			break;
5983
-    		case 'learnpath':
5984
-    			$table_name = TABLE_LP_MAIN;
5985
-    			$link_tool = 'newscorm/lp_controller.php';
5986
-    			$id_tool = 'id';
5987
-    			break;
5988
-    		case 'quiz':
5989
-    			$table_name = TABLE_QUIZ_TEST;
5990
-    			$link_tool = 'exercice/exercice.php';
5991
-    			$id_tool = 'id';
5992
-    			break;
5993
-    		case 'glossary':
5994
-    			$table_name = TABLE_GLOSSARY;
5995
-    			$link_tool = 'glossary/index.php';
5996
-    			$id_tool = 'glossary_id';
5997
-    			break;
5998
-    		case 'link':
5999
-    			$table_name = TABLE_LINK;
6000
-    			$link_tool = 'link/link.php';
6001
-    			$id_tool = 'id';
6002
-    			break;
6003
-    		case 'course_description':
6004
-    			$table_name = TABLE_COURSE_DESCRIPTION;
6005
-    			$link_tool = 'course_description/';
6006
-    			$id_tool = 'id';
6007
-    			break;
6008
-    		case 'announcement':
6009
-    			$table_name = TABLE_ANNOUNCEMENT;
6010
-    			$link_tool = 'announcements/announcements.php';
6011
-    			$id_tool = 'id';
6012
-    			break;
6013
-    		case 'thematic':
6014
-    			$table_name = TABLE_THEMATIC;
6015
-    			$link_tool = 'course_progress/index.php';
6016
-    			$id_tool = 'id';
6017
-    			break;
6018
-    		case 'thematic_advance':
6019
-    			$table_name = TABLE_THEMATIC_ADVANCE;
6020
-    			$link_tool = 'course_progress/index.php';
6021
-    			$id_tool = 'id';
6022
-    			break;
6023
-    		case 'thematic_plan':
6024
-    			$table_name = TABLE_THEMATIC_PLAN;
6025
-    			$link_tool = 'course_progress/index.php';
6026
-    			$id_tool = 'id';
6027
-    			break;
6028
-    		default:
6029
-    			$table_name = $tool;
6030
-    		break;
6031
-    	}
6032
-
6033
-    	return array(
5977
+        switch ($tool) {
5978
+            case 'document':
5979
+                $table_name = TABLE_DOCUMENT;
5980
+                $link_tool = 'document/document.php';
5981
+                $id_tool = 'id';
5982
+                break;
5983
+            case 'learnpath':
5984
+                $table_name = TABLE_LP_MAIN;
5985
+                $link_tool = 'newscorm/lp_controller.php';
5986
+                $id_tool = 'id';
5987
+                break;
5988
+            case 'quiz':
5989
+                $table_name = TABLE_QUIZ_TEST;
5990
+                $link_tool = 'exercice/exercice.php';
5991
+                $id_tool = 'id';
5992
+                break;
5993
+            case 'glossary':
5994
+                $table_name = TABLE_GLOSSARY;
5995
+                $link_tool = 'glossary/index.php';
5996
+                $id_tool = 'glossary_id';
5997
+                break;
5998
+            case 'link':
5999
+                $table_name = TABLE_LINK;
6000
+                $link_tool = 'link/link.php';
6001
+                $id_tool = 'id';
6002
+                break;
6003
+            case 'course_description':
6004
+                $table_name = TABLE_COURSE_DESCRIPTION;
6005
+                $link_tool = 'course_description/';
6006
+                $id_tool = 'id';
6007
+                break;
6008
+            case 'announcement':
6009
+                $table_name = TABLE_ANNOUNCEMENT;
6010
+                $link_tool = 'announcements/announcements.php';
6011
+                $id_tool = 'id';
6012
+                break;
6013
+            case 'thematic':
6014
+                $table_name = TABLE_THEMATIC;
6015
+                $link_tool = 'course_progress/index.php';
6016
+                $id_tool = 'id';
6017
+                break;
6018
+            case 'thematic_advance':
6019
+                $table_name = TABLE_THEMATIC_ADVANCE;
6020
+                $link_tool = 'course_progress/index.php';
6021
+                $id_tool = 'id';
6022
+                break;
6023
+            case 'thematic_plan':
6024
+                $table_name = TABLE_THEMATIC_PLAN;
6025
+                $link_tool = 'course_progress/index.php';
6026
+                $id_tool = 'id';
6027
+                break;
6028
+            default:
6029
+                $table_name = $tool;
6030
+            break;
6031
+        }
6032
+
6033
+        return array(
6034 6034
             'table_name' => $table_name,
6035 6035
             'link_tool' => $link_tool,
6036 6036
             'id_tool' => $id_tool
@@ -6039,45 +6039,45 @@  discard block
 block discarded – undo
6039 6039
 
6040 6040
     public static function display_additional_profile_fields()
6041 6041
     {
6042
-    	// getting all the extra profile fields that are defined by the platform administrator
6043
-    	$extra_fields = UserManager :: get_extra_fields(0,50,5,'ASC');
6044
-
6045
-    	// creating the form
6046
-    	$return = '<form action="courseLog.php" method="get" name="additional_profile_field_form" id="additional_profile_field_form">';
6047
-
6048
-    	// the select field with the additional user profile fields (= this is where we select the field of which we want to see
6049
-    	// the information the users have entered or selected.
6050
-    	$return .= '<select name="additional_profile_field">';
6051
-    	$return .= '<option value="-">'.get_lang('SelectFieldToAdd').'</option>';
6052
-    	$extra_fields_to_show = 0;
6053
-    	foreach ($extra_fields as $key=>$field) {
6054
-    		// show only extra fields that are visible + and can be filtered, added by J.Montoya
6055
-    		if ($field[6]==1 && $field[8] == 1) {
6056
-    			if (isset($_GET['additional_profile_field']) && $field[0] == $_GET['additional_profile_field'] ) {
6057
-    				$selected = 'selected="selected"';
6058
-    			} else {
6059
-    				$selected = '';
6060
-    			}
6061
-    			$extra_fields_to_show++;
6062
-    			$return .= '<option value="'.$field[0].'" '.$selected.'>'.$field[3].'</option>';
6063
-    		}
6064
-    	}
6065
-    	$return .= '</select>';
6066
-
6067
-    	// the form elements for the $_GET parameters (because the form is passed through GET
6068
-    	foreach ($_GET as $key=>$value){
6069
-    		if ($key <> 'additional_profile_field')    {
6070
-    			$return .= '<input type="hidden" name="'.Security::remove_XSS($key).'" value="'.Security::remove_XSS($value).'" />';
6071
-    		}
6072
-    	}
6073
-    	// the submit button
6074
-    	$return .= '<button class="save" type="submit">'.get_lang('AddAdditionalProfileField').'</button>';
6075
-    	$return .= '</form>';
6076
-    	if ($extra_fields_to_show > 0) {
6077
-    		return $return;
6078
-    	} else {
6079
-    		return '';
6080
-    	}
6042
+        // getting all the extra profile fields that are defined by the platform administrator
6043
+        $extra_fields = UserManager :: get_extra_fields(0,50,5,'ASC');
6044
+
6045
+        // creating the form
6046
+        $return = '<form action="courseLog.php" method="get" name="additional_profile_field_form" id="additional_profile_field_form">';
6047
+
6048
+        // the select field with the additional user profile fields (= this is where we select the field of which we want to see
6049
+        // the information the users have entered or selected.
6050
+        $return .= '<select name="additional_profile_field">';
6051
+        $return .= '<option value="-">'.get_lang('SelectFieldToAdd').'</option>';
6052
+        $extra_fields_to_show = 0;
6053
+        foreach ($extra_fields as $key=>$field) {
6054
+            // show only extra fields that are visible + and can be filtered, added by J.Montoya
6055
+            if ($field[6]==1 && $field[8] == 1) {
6056
+                if (isset($_GET['additional_profile_field']) && $field[0] == $_GET['additional_profile_field'] ) {
6057
+                    $selected = 'selected="selected"';
6058
+                } else {
6059
+                    $selected = '';
6060
+                }
6061
+                $extra_fields_to_show++;
6062
+                $return .= '<option value="'.$field[0].'" '.$selected.'>'.$field[3].'</option>';
6063
+            }
6064
+        }
6065
+        $return .= '</select>';
6066
+
6067
+        // the form elements for the $_GET parameters (because the form is passed through GET
6068
+        foreach ($_GET as $key=>$value){
6069
+            if ($key <> 'additional_profile_field')    {
6070
+                $return .= '<input type="hidden" name="'.Security::remove_XSS($key).'" value="'.Security::remove_XSS($value).'" />';
6071
+            }
6072
+        }
6073
+        // the submit button
6074
+        $return .= '<button class="save" type="submit">'.get_lang('AddAdditionalProfileField').'</button>';
6075
+        $return .= '</form>';
6076
+        if ($extra_fields_to_show > 0) {
6077
+            return $return;
6078
+        } else {
6079
+            return '';
6080
+        }
6081 6081
     }
6082 6082
 
6083 6083
     /**
@@ -6096,31 +6096,31 @@  discard block
 block discarded – undo
6096 6096
      */
6097 6097
     public static function get_addtional_profile_information_of_field_by_user($field_id, $users)
6098 6098
     {
6099
-    	// Database table definition
6100
-    	$table_user = Database::get_main_table(TABLE_MAIN_USER);
6101
-    	$table_user_field_values = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES);
6099
+        // Database table definition
6100
+        $table_user = Database::get_main_table(TABLE_MAIN_USER);
6101
+        $table_user_field_values = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES);
6102 6102
         $extraField = Database::get_main_table(TABLE_EXTRA_FIELD);
6103
-    	$result_extra_field = UserManager::get_extra_field_information($field_id);
6104
-
6105
-    	if (!empty($users)) {
6106
-    		if ($result_extra_field['field_type'] == UserManager::USER_FIELD_TYPE_TAG ) {
6107
-    			foreach($users as $user_id) {
6108
-    				$user_result = UserManager::get_user_tags($user_id, $field_id);
6109
-    				$tag_list = array();
6110
-    				foreach($user_result as $item) {
6111
-    					$tag_list[] = $item['tag'];
6112
-    				}
6113
-    				$return[$user_id][] = implode(', ',$tag_list);
6114
-    			}
6115
-    		} else {
6116
-    			$new_user_array = array();
6117
-    			foreach ($users as $user_id) {
6118
-    				$new_user_array[]= "'".$user_id."'";
6119
-    			}
6120
-    			$users = implode(',',$new_user_array);
6103
+        $result_extra_field = UserManager::get_extra_field_information($field_id);
6104
+
6105
+        if (!empty($users)) {
6106
+            if ($result_extra_field['field_type'] == UserManager::USER_FIELD_TYPE_TAG ) {
6107
+                foreach($users as $user_id) {
6108
+                    $user_result = UserManager::get_user_tags($user_id, $field_id);
6109
+                    $tag_list = array();
6110
+                    foreach($user_result as $item) {
6111
+                        $tag_list[] = $item['tag'];
6112
+                    }
6113
+                    $return[$user_id][] = implode(', ',$tag_list);
6114
+                }
6115
+            } else {
6116
+                $new_user_array = array();
6117
+                foreach ($users as $user_id) {
6118
+                    $new_user_array[]= "'".$user_id."'";
6119
+                }
6120
+                $users = implode(',',$new_user_array);
6121 6121
                 $extraFieldType = EntityExtraField::USER_FIELD_TYPE;
6122
-    			// Selecting only the necessary information NOT ALL the user list
6123
-    			$sql = "SELECT user.user_id, v.value
6122
+                // Selecting only the necessary information NOT ALL the user list
6123
+                $sql = "SELECT user.user_id, v.value
6124 6124
     			        FROM $table_user user
6125 6125
     			        INNER JOIN $table_user_field_values v
6126 6126
                         ON (user.user_id = v.item_id)
@@ -6131,27 +6131,27 @@  discard block
 block discarded – undo
6131 6131
                             v.field_id=".intval($field_id)." AND
6132 6132
                             user.user_id IN ($users)";
6133 6133
 
6134
-    			$result = Database::query($sql);
6135
-    			while($row = Database::fetch_array($result)) {
6136
-    				// get option value for field type double select by id
6137
-    				if (!empty($row['value'])) {
6138
-    					if ($result_extra_field['field_type'] ==
6134
+                $result = Database::query($sql);
6135
+                while($row = Database::fetch_array($result)) {
6136
+                    // get option value for field type double select by id
6137
+                    if (!empty($row['value'])) {
6138
+                        if ($result_extra_field['field_type'] ==
6139 6139
                             ExtraField::FIELD_TYPE_DOUBLE_SELECT
6140 6140
                         ) {
6141
-    						$id_double_select = explode(';', $row['value']);
6142
-    						if (is_array($id_double_select)) {
6143
-    							$value1 = $result_extra_field['options'][$id_double_select[0]]['option_value'];
6144
-    							$value2 = $result_extra_field['options'][$id_double_select[1]]['option_value'];
6145
-    							$row['value'] = ($value1.';'.$value2);
6146
-    						}
6147
-    					}
6148
-    				}
6149
-    				// get other value from extra field
6150
-    				$return[$row['user_id']][] = $row['value'];
6151
-    			}
6152
-    		}
6153
-    	}
6154
-    	return $return;
6141
+                            $id_double_select = explode(';', $row['value']);
6142
+                            if (is_array($id_double_select)) {
6143
+                                $value1 = $result_extra_field['options'][$id_double_select[0]]['option_value'];
6144
+                                $value2 = $result_extra_field['options'][$id_double_select[1]]['option_value'];
6145
+                                $row['value'] = ($value1.';'.$value2);
6146
+                            }
6147
+                        }
6148
+                    }
6149
+                    // get other value from extra field
6150
+                    $return[$row['user_id']][] = $row['value'];
6151
+                }
6152
+            }
6153
+        }
6154
+        return $return;
6155 6155
     }
6156 6156
 
6157 6157
     /**
@@ -6160,18 +6160,18 @@  discard block
 block discarded – undo
6160 6160
      */
6161 6161
     public function count_student_in_course()
6162 6162
     {
6163
-    	global $nbStudents;
6164
-    	return $nbStudents;
6163
+        global $nbStudents;
6164
+        return $nbStudents;
6165 6165
     }
6166 6166
 
6167 6167
     public function sort_users($a, $b)
6168 6168
     {
6169
-    	return strcmp(trim(api_strtolower($a[$_SESSION['tracking_column']])), trim(api_strtolower($b[$_SESSION['tracking_column']])));
6169
+        return strcmp(trim(api_strtolower($a[$_SESSION['tracking_column']])), trim(api_strtolower($b[$_SESSION['tracking_column']])));
6170 6170
     }
6171 6171
 
6172 6172
     public function sort_users_desc($a, $b)
6173 6173
     {
6174
-    	return strcmp( trim(api_strtolower($b[$_SESSION['tracking_column']])), trim(api_strtolower($a[$_SESSION['tracking_column']])));
6174
+        return strcmp( trim(api_strtolower($b[$_SESSION['tracking_column']])), trim(api_strtolower($a[$_SESSION['tracking_column']])));
6175 6175
     }
6176 6176
 
6177 6177
     /**
@@ -6180,8 +6180,8 @@  discard block
 block discarded – undo
6180 6180
      */
6181 6181
     public static function get_number_of_users()
6182 6182
     {
6183
-    	global $user_ids;
6184
-    	return count($user_ids);
6183
+        global $user_ids;
6184
+        return count($user_ids);
6185 6185
     }
6186 6186
 
6187 6187
     /**
@@ -6197,37 +6197,37 @@  discard block
 block discarded – undo
6197 6197
     {
6198 6198
         global $user_ids, $course_code, $additional_user_profile_info, $export_csv, $is_western_name_order, $csv_content, $session_id;
6199 6199
 
6200
-    	$course_code = Database::escape_string($course_code);
6201
-    	$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
6202
-    	$tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
6200
+        $course_code = Database::escape_string($course_code);
6201
+        $tbl_user = Database::get_main_table(TABLE_MAIN_USER);
6202
+        $tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
6203 6203
 
6204
-    	$access_url_id = api_get_current_access_url_id();
6204
+        $access_url_id = api_get_current_access_url_id();
6205 6205
 
6206
-    	// get all users data from a course for sortable with limit
6207
-    	if (is_array($user_ids)) {
6208
-    		$user_ids = array_map('intval', $user_ids);
6209
-    		$condition_user = " WHERE user.user_id IN (".implode(',',$user_ids).") ";
6210
-    	} else {
6211
-    		$user_ids = intval($user_ids);
6212
-    		$condition_user = " WHERE user.user_id = $user_ids ";
6213
-    	}
6206
+        // get all users data from a course for sortable with limit
6207
+        if (is_array($user_ids)) {
6208
+            $user_ids = array_map('intval', $user_ids);
6209
+            $condition_user = " WHERE user.user_id IN (".implode(',',$user_ids).") ";
6210
+        } else {
6211
+            $user_ids = intval($user_ids);
6212
+            $condition_user = " WHERE user.user_id = $user_ids ";
6213
+        }
6214 6214
 
6215
-    	if (!empty($_GET['user_keyword'])) {
6216
-    		$keyword = trim(Database::escape_string($_GET['user_keyword']));
6217
-    		$condition_user .=  " AND (
6215
+        if (!empty($_GET['user_keyword'])) {
6216
+            $keyword = trim(Database::escape_string($_GET['user_keyword']));
6217
+            $condition_user .=  " AND (
6218 6218
                 user.firstname LIKE '%".$keyword."%' OR
6219 6219
                 user.lastname LIKE '%".$keyword."%'  OR
6220 6220
                 user.username LIKE '%".$keyword."%'  OR
6221 6221
                 user.email LIKE '%".$keyword."%'
6222 6222
              ) ";
6223
-    	}
6223
+        }
6224 6224
 
6225 6225
         $url_table = null;
6226 6226
         $url_condition = null;
6227
-    	if (api_is_multiple_url_enabled()) {
6228
-    		$url_table = ", ".$tbl_url_rel_user." as url_users";
6229
-    		$url_condition = " AND user.user_id = url_users.user_id AND access_url_id='$access_url_id'";
6230
-    	}
6227
+        if (api_is_multiple_url_enabled()) {
6228
+            $url_table = ", ".$tbl_url_rel_user." as url_users";
6229
+            $url_condition = " AND user.user_id = url_users.user_id AND access_url_id='$access_url_id'";
6230
+        }
6231 6231
 
6232 6232
         $invitedUsersCondition = '';
6233 6233
 
@@ -6235,7 +6235,7 @@  discard block
 block discarded – undo
6235 6235
             $invitedUsersCondition = " AND user.status != " . INVITEE;
6236 6236
         }
6237 6237
 
6238
-    	$sql = "SELECT  user.user_id as user_id,
6238
+        $sql = "SELECT  user.user_id as user_id,
6239 6239
                     user.official_code  as col0,
6240 6240
                     user.lastname       as col1,
6241 6241
                     user.firstname      as col2,
@@ -6243,17 +6243,17 @@  discard block
 block discarded – undo
6243 6243
                 FROM $tbl_user as user $url_table
6244 6244
     	        $condition_user $url_condition $invitedUsersCondition";
6245 6245
 
6246
-    	if (!in_array($direction, array('ASC','DESC'))) {
6247
-    		$direction = 'ASC';
6248
-    	}
6246
+        if (!in_array($direction, array('ASC','DESC'))) {
6247
+            $direction = 'ASC';
6248
+        }
6249 6249
 
6250
-    	$column = intval($column);
6250
+        $column = intval($column);
6251 6251
 
6252
-    	$from = intval($from);
6253
-    	$number_of_items = intval($number_of_items);
6252
+        $from = intval($from);
6253
+        $number_of_items = intval($number_of_items);
6254 6254
 
6255
-    	$sql .= " ORDER BY col$column $direction ";
6256
-    	$sql .= " LIMIT $from,$number_of_items";
6255
+        $sql .= " ORDER BY col$column $direction ";
6256
+        $sql .= " LIMIT $from,$number_of_items";
6257 6257
 
6258 6258
         $res = Database::query($sql);
6259 6259
         $users = array();
@@ -6287,7 +6287,7 @@  discard block
 block discarded – undo
6287 6287
             }
6288 6288
         }
6289 6289
 
6290
-    	while ($user = Database::fetch_array($res, 'ASSOC')) {
6290
+        while ($user = Database::fetch_array($res, 'ASSOC')) {
6291 6291
             $courseInfo = api_get_course_info($course_code);
6292 6292
             $courseId = $courseInfo['real_id'];
6293 6293
 
@@ -6318,10 +6318,10 @@  discard block
 block discarded – undo
6318 6318
                 $session_id
6319 6319
             );
6320 6320
 
6321
-    		if (empty($avg_student_progress)) {
6321
+            if (empty($avg_student_progress)) {
6322 6322
                 $avg_student_progress = 0;
6323
-    		}
6324
-    		$user['average_progress'] = $avg_student_progress.'%';
6323
+            }
6324
+            $user['average_progress'] = $avg_student_progress.'%';
6325 6325
 
6326 6326
             $total_user_exercise = Tracking::get_exercise_student_progress(
6327 6327
                 $total_exercises,
@@ -6341,11 +6341,11 @@  discard block
 block discarded – undo
6341 6341
 
6342 6342
             $user['exercise_average_best_attempt'] = $total_user_exercise;
6343 6343
 
6344
-    		if (is_numeric($avg_student_score)) {
6345
-    			$user['student_score']  = $avg_student_score.'%';
6346
-    		} else {
6347
-    			$user['student_score']  = $avg_student_score;
6348
-    		}
6344
+            if (is_numeric($avg_student_score)) {
6345
+                $user['student_score']  = $avg_student_score.'%';
6346
+            } else {
6347
+                $user['student_score']  = $avg_student_score;
6348
+            }
6349 6349
 
6350 6350
             $user['count_assignments'] = Tracking::count_student_assignments(
6351 6351
                 $user['user_id'],
@@ -6368,26 +6368,26 @@  discard block
 block discarded – undo
6368 6368
                 $session_id
6369 6369
             );
6370 6370
 
6371
-    		// we need to display an additional profile field
6372
-    		$user['additional'] = '';
6371
+            // we need to display an additional profile field
6372
+            $user['additional'] = '';
6373 6373
 
6374
-    		if (isset($_GET['additional_profile_field']) && is_numeric($_GET['additional_profile_field'])) {
6375
-    			if (isset($additional_user_profile_info[$user['user_id']]) &&
6374
+            if (isset($_GET['additional_profile_field']) && is_numeric($_GET['additional_profile_field'])) {
6375
+                if (isset($additional_user_profile_info[$user['user_id']]) &&
6376 6376
                     is_array($additional_user_profile_info[$user['user_id']])
6377 6377
                 ) {
6378
-    				$user['additional'] = implode(', ', $additional_user_profile_info[$user['user_id']]);
6379
-    			}
6380
-    		}
6378
+                    $user['additional'] = implode(', ', $additional_user_profile_info[$user['user_id']]);
6379
+                }
6380
+            }
6381 6381
 
6382 6382
             if (empty($session_id)) {
6383 6383
                 $user['survey'] = (isset($survey_user_list[$user['user_id']]) ? $survey_user_list[$user['user_id']] : 0) .' / '.$total_surveys;
6384 6384
             }
6385 6385
 
6386
-    		$user['link'] = '<center><a href="../mySpace/myStudents.php?student='.$user['user_id'].'&details=true&course='.$course_code.'&origin=tracking_course&id_session='.$session_id.'"><img src="'.api_get_path(WEB_IMG_PATH).'icons/22/2rightarrow.png" border="0" /></a></center>';
6386
+            $user['link'] = '<center><a href="../mySpace/myStudents.php?student='.$user['user_id'].'&details=true&course='.$course_code.'&origin=tracking_course&id_session='.$session_id.'"><img src="'.api_get_path(WEB_IMG_PATH).'icons/22/2rightarrow.png" border="0" /></a></center>';
6387 6387
 
6388
-    		// store columns in array $users
6388
+            // store columns in array $users
6389 6389
 
6390
-    		$is_western_name_order = api_is_western_name_order();
6390
+            $is_western_name_order = api_is_western_name_order();
6391 6391
             $user_row = array();
6392 6392
 
6393 6393
             $user_row[]= $user['official_code']; //0
@@ -6422,21 +6422,21 @@  discard block
 block discarded – undo
6422 6422
 
6423 6423
             $users[] = $user_row;
6424 6424
 
6425
-    		if ($export_csv) {
6426
-    		    if (empty($session_id)) {
6425
+            if ($export_csv) {
6426
+                if (empty($session_id)) {
6427 6427
                     $user_row = array_map('strip_tags', $user_row);
6428
-    			    unset($user_row[14]);
6429
-    			    unset($user_row[15]);
6428
+                    unset($user_row[14]);
6429
+                    unset($user_row[15]);
6430 6430
                 } else {
6431 6431
                     $user_row = array_map('strip_tags', $user_row);
6432 6432
                     unset($user_row[13]);
6433 6433
                     unset($user_row[14]);
6434 6434
                 }
6435 6435
 
6436
-    			$csv_content[] = $user_row;
6437
-    		}
6438
-    	}
6439
-    	return $users;
6436
+                $csv_content[] = $user_row;
6437
+            }
6438
+        }
6439
+        return $users;
6440 6440
     }
6441 6441
 }
6442 6442
 
@@ -6454,18 +6454,18 @@  discard block
 block discarded – undo
6454 6454
      */
6455 6455
     public function display_login_tracking_info($view, $user_id, $course_id, $session_id = 0)
6456 6456
     {
6457
-    	$MonthsLong = $GLOBALS['MonthsLong'];
6458
-
6459
-    	// protected data
6460
-    	$user_id = intval($user_id);
6461
-    	$session_id = intval($session_id);
6462
-    	$course_id = Database::escape_string($course_id);
6463
-
6464
-    	$track_access_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
6465
-    	$tempView = $view;
6466
-    	if(substr($view,0,1) == '1') {
6467
-    		$new_view = substr_replace($view,'0',0,1);
6468
-    		echo "
6457
+        $MonthsLong = $GLOBALS['MonthsLong'];
6458
+
6459
+        // protected data
6460
+        $user_id = intval($user_id);
6461
+        $session_id = intval($session_id);
6462
+        $course_id = Database::escape_string($course_id);
6463
+
6464
+        $track_access_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
6465
+        $tempView = $view;
6466
+        if(substr($view,0,1) == '1') {
6467
+            $new_view = substr_replace($view,'0',0,1);
6468
+            echo "
6469 6469
                 <tr>
6470 6470
                     <td valign='top'>
6471 6471
                     <font color='#0000FF'>-&nbsp;&nbsp;&nbsp;</font>" .
@@ -6473,9 +6473,9 @@  discard block
 block discarded – undo
6473 6473
                     </td>
6474 6474
                 </tr>
6475 6475
                 ";
6476
-    		echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('LoginsDetails')."<br>";
6476
+            echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('LoginsDetails')."<br>";
6477 6477
 
6478
-    		$sql = "SELECT UNIX_TIMESTAMP(access_date), count(access_date)
6478
+            $sql = "SELECT UNIX_TIMESTAMP(access_date), count(access_date)
6479 6479
                         FROM $track_access_table
6480 6480
                         WHERE access_user_id = $user_id
6481 6481
                         AND c_id = $course_id
@@ -6483,11 +6483,11 @@  discard block
 block discarded – undo
6483 6483
                         GROUP BY YEAR(access_date),MONTH(access_date)
6484 6484
                         ORDER BY YEAR(access_date),MONTH(access_date) ASC";
6485 6485
 
6486
-    		echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6487
-    		$results = getManyResults3Col($sql);
6486
+            echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6487
+            $results = getManyResults3Col($sql);
6488 6488
 
6489
-    		echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
6490
-    		echo "<tr>
6489
+            echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
6490
+            echo "<tr>
6491 6491
                     <td class='secLine'>
6492 6492
                     ".get_lang('LoginsTitleMonthColumn')."
6493 6493
                     </td>
@@ -6495,36 +6495,36 @@  discard block
 block discarded – undo
6495 6495
                     ".get_lang('LoginsTitleCountColumn')."
6496 6496
                     </td>
6497 6497
                 </tr>";
6498
-    		$total = 0;
6499
-    		if (is_array($results)) {
6500
-    			for($j = 0 ; $j < count($results) ; $j++) {
6501
-    				echo "<tr>";
6502
-    				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>";
6503
-    				echo "<td valign='top' align='right' class='content'>".$results[$j][1]."</td>";
6504
-    				echo"</tr>";
6505
-    				$total = $total + $results[$j][1];
6506
-    			}
6507
-    			echo "<tr>";
6508
-    			echo "<td>".get_lang('Total')."</td>";
6509
-    			echo "<td align='right' class='content'>".$total."</td>";
6510
-    			echo"</tr>";
6511
-    		} else {
6512
-    			echo "<tr>";
6513
-    			echo "<td colspan='2'><center>".get_lang('NoResult')."</center></td>";
6514
-    			echo"</tr>";
6515
-    		}
6516
-    		echo "</table>";
6517
-    		echo "</td></tr>";
6518
-    	} else {
6519
-    		$new_view = substr_replace($view,'1',0,1);
6520
-    		echo "
6498
+            $total = 0;
6499
+            if (is_array($results)) {
6500
+                for($j = 0 ; $j < count($results) ; $j++) {
6501
+                    echo "<tr>";
6502
+                    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>";
6503
+                    echo "<td valign='top' align='right' class='content'>".$results[$j][1]."</td>";
6504
+                    echo"</tr>";
6505
+                    $total = $total + $results[$j][1];
6506
+                }
6507
+                echo "<tr>";
6508
+                echo "<td>".get_lang('Total')."</td>";
6509
+                echo "<td align='right' class='content'>".$total."</td>";
6510
+                echo"</tr>";
6511
+            } else {
6512
+                echo "<tr>";
6513
+                echo "<td colspan='2'><center>".get_lang('NoResult')."</center></td>";
6514
+                echo"</tr>";
6515
+            }
6516
+            echo "</table>";
6517
+            echo "</td></tr>";
6518
+        } else {
6519
+            $new_view = substr_replace($view,'1',0,1);
6520
+            echo "
6521 6521
                 <tr>
6522 6522
                     <td valign='top'>
6523 6523
                     +<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>
6524 6524
                     </td>
6525 6525
                 </tr>
6526 6526
             ";
6527
-    	}
6527
+        }
6528 6528
     }
6529 6529
 
6530 6530
     /**
@@ -6537,38 +6537,38 @@  discard block
 block discarded – undo
6537 6537
      */
6538 6538
     public function display_exercise_tracking_info($view, $user_id, $courseCode)
6539 6539
     {
6540
-    	global $TBL_TRACK_HOTPOTATOES, $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $dateTimeFormatLong;
6540
+        global $TBL_TRACK_HOTPOTATOES, $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $dateTimeFormatLong;
6541 6541
         $courseId = api_get_course_int_id($courseCode);
6542
-    	if(substr($view,1,1) == '1') {
6543
-    		$new_view = substr_replace($view,'0',1,1);
6544
-    		echo "<tr>
6542
+        if(substr($view,1,1) == '1') {
6543
+            $new_view = substr_replace($view,'0',1,1);
6544
+            echo "<tr>
6545 6545
                     <td valign='top'>
6546 6546
                         <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>]
6547 6547
                     </td>
6548 6548
                 </tr>";
6549
-    		echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('ExercicesDetails')."<br />";
6549
+            echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('ExercicesDetails')."<br />";
6550 6550
 
6551
-    		$sql = "SELECT ce.title, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
6551
+            $sql = "SELECT ce.title, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
6552 6552
                     FROM $TABLECOURSE_EXERCICES AS ce , $TABLETRACK_EXERCICES AS te
6553 6553
                     WHERE te.c_id = $courseId
6554 6554
                         AND te.exe_user_id = ".intval($user_id)."
6555 6555
                         AND te.exe_exo_id = ce.id
6556 6556
                     ORDER BY ce.title ASC, te.exe_date ASC";
6557 6557
 
6558
-    		$hpsql = "SELECT te.exe_name, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
6558
+            $hpsql = "SELECT te.exe_name, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
6559 6559
                         FROM $TBL_TRACK_HOTPOTATOES AS te
6560 6560
                         WHERE te.exe_user_id = '".intval($user_id)."' AND te.c_id = $courseId
6561 6561
                         ORDER BY te.c_id ASC, te.exe_date ASC";
6562 6562
 
6563
-    		$hpresults = StatsUtils::getManyResultsXCol($hpsql, 4);
6563
+            $hpresults = StatsUtils::getManyResultsXCol($hpsql, 4);
6564 6564
 
6565
-    		$NoTestRes = 0;
6566
-    		$NoHPTestRes = 0;
6565
+            $NoTestRes = 0;
6566
+            $NoHPTestRes = 0;
6567 6567
 
6568
-    		echo "<tr>\n<td style='padding-left : 40px;padding-right : 40px;'>\n";
6569
-    		$results = StatsUtils::getManyResultsXCol($sql, 4);
6570
-    		echo "<table cellpadding='2' cellspacing='1' border='0' align='center'>\n";
6571
-    		echo "
6568
+            echo "<tr>\n<td style='padding-left : 40px;padding-right : 40px;'>\n";
6569
+            $results = StatsUtils::getManyResultsXCol($sql, 4);
6570
+            echo "<table cellpadding='2' cellspacing='1' border='0' align='center'>\n";
6571
+            echo "
6572 6572
                 <tr bgcolor='#E6E6E6'>
6573 6573
                     <td>
6574 6574
                     ".get_lang('ExercicesTitleExerciceColumn')."
@@ -6581,28 +6581,28 @@  discard block
 block discarded – undo
6581 6581
                     </td>
6582 6582
                 </tr>";
6583 6583
 
6584
-    		if (is_array($results)) {
6585
-    			for($i = 0; $i < sizeof($results); $i++) {
6586
-    				$display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get());
6587
-    				echo "<tr>\n";
6588
-    				echo "<td class='content'>".$results[$i][0]."</td>\n";
6589
-    				echo "<td class='content'>".$display_date."</td>\n";
6590
-    				echo "<td valign='top' align='right' class='content'>".$results[$i][1]." / ".$results[$i][2]."</td>\n";
6591
-    				echo "</tr>\n";
6592
-    			}
6593
-    		} else {
6594
-    			// istvan begin
6595
-    			$NoTestRes = 1;
6596
-    		}
6597
-
6598
-    		// The Result of Tests
6599
-    		if (is_array($hpresults)) {
6600
-    			for($i = 0; $i < sizeof($hpresults); $i++) {
6601
-    				$title = GetQuizName($hpresults[$i][0],'');
6602
-    				if ($title == '')
6603
-    				$title = basename($hpresults[$i][0]);
6604
-    				$display_date = api_convert_and_format_date($hpresults[$i][3], null, date_default_timezone_get());
6605
-    				?>
6584
+            if (is_array($results)) {
6585
+                for($i = 0; $i < sizeof($results); $i++) {
6586
+                    $display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get());
6587
+                    echo "<tr>\n";
6588
+                    echo "<td class='content'>".$results[$i][0]."</td>\n";
6589
+                    echo "<td class='content'>".$display_date."</td>\n";
6590
+                    echo "<td valign='top' align='right' class='content'>".$results[$i][1]." / ".$results[$i][2]."</td>\n";
6591
+                    echo "</tr>\n";
6592
+                }
6593
+            } else {
6594
+                // istvan begin
6595
+                $NoTestRes = 1;
6596
+            }
6597
+
6598
+            // The Result of Tests
6599
+            if (is_array($hpresults)) {
6600
+                for($i = 0; $i < sizeof($hpresults); $i++) {
6601
+                    $title = GetQuizName($hpresults[$i][0],'');
6602
+                    if ($title == '')
6603
+                    $title = basename($hpresults[$i][0]);
6604
+                    $display_date = api_convert_and_format_date($hpresults[$i][3], null, date_default_timezone_get());
6605
+                    ?>
6606 6606
                     <tr>
6607 6607
                         <td class="content"><?php echo $title; ?></td>
6608 6608
                         <td class="content" align="center"><?php echo $display_date; ?></td>
@@ -6612,26 +6612,26 @@  discard block
 block discarded – undo
6612 6612
 
6613 6613
                     <?php
6614 6614
                 }
6615
-    		} else {
6616
-    			$NoHPTestRes = 1;
6617
-    		}
6618
-
6619
-    		if ($NoTestRes == 1 && $NoHPTestRes == 1) {
6620
-    			echo "<tr>\n";
6621
-    			echo "<td colspan='3'><center>".get_lang('NoResult')."</center></td>\n";
6622
-    			echo "</tr>\n";
6623
-    		}
6624
-    		echo "</table>";
6625
-    		echo "</td>\n</tr>\n";
6626
-    	} else {
6627
-    		$new_view = substr_replace($view,'1',1,1);
6628
-    		echo "
6615
+            } else {
6616
+                $NoHPTestRes = 1;
6617
+            }
6618
+
6619
+            if ($NoTestRes == 1 && $NoHPTestRes == 1) {
6620
+                echo "<tr>\n";
6621
+                echo "<td colspan='3'><center>".get_lang('NoResult')."</center></td>\n";
6622
+                echo "</tr>\n";
6623
+            }
6624
+            echo "</table>";
6625
+            echo "</td>\n</tr>\n";
6626
+        } else {
6627
+            $new_view = substr_replace($view,'1',1,1);
6628
+            echo "
6629 6629
                 <tr>
6630 6630
                     <td valign='top'>
6631 6631
                         +<font color='#0000FF'>&nbsp;&nbsp;</font><a href='".api_get_self()."?uInfo=$user_id&view=".$new_view."' class='specialLink'>".get_lang('ExercicesResults')."</a>
6632 6632
                     </td>
6633 6633
                 </tr>";
6634
-    	}
6634
+        }
6635 6635
     }
6636 6636
 
6637 6637
     /**
@@ -6640,27 +6640,27 @@  discard block
 block discarded – undo
6640 6640
      */
6641 6641
     public function display_student_publications_tracking_info($view, $user_id, $course_id)
6642 6642
     {
6643
-    	global $TABLETRACK_UPLOADS, $TABLECOURSE_WORK;
6643
+        global $TABLETRACK_UPLOADS, $TABLECOURSE_WORK;
6644 6644
         $_course = api_get_course_info_by_id($course_id);
6645 6645
 
6646
-    	if (substr($view,2,1) == '1') {
6647
-    		$new_view = substr_replace($view,'0',2,1);
6648
-    		echo "<tr>
6646
+        if (substr($view,2,1) == '1') {
6647
+            $new_view = substr_replace($view,'0',2,1);
6648
+            echo "<tr>
6649 6649
                     <td valign='top'>
6650 6650
                     <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>]
6651 6651
                     </td>
6652 6652
                 </tr>";
6653
-    		echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('WorksDetails')."<br>";
6654
-    		$sql = "SELECT u.upload_date, w.title, w.author,w.url
6653
+            echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('WorksDetails')."<br>";
6654
+            $sql = "SELECT u.upload_date, w.title, w.author,w.url
6655 6655
                     FROM $TABLETRACK_UPLOADS u , $TABLECOURSE_WORK w
6656 6656
                     WHERE u.upload_work_id = w.id
6657 6657
                         AND u.upload_user_id = '".intval($user_id)."'
6658 6658
                         AND u.c_id = '".intval($course_id)."'
6659 6659
                     ORDER BY u.upload_date DESC";
6660
-    		echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6661
-    		$results = StatsUtils::getManyResultsXCol($sql,4);
6662
-    		echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
6663
-    		echo "<tr>
6660
+            echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6661
+            $results = StatsUtils::getManyResultsXCol($sql,4);
6662
+            echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
6663
+            echo "<tr>
6664 6664
                     <td class='secLine' width='40%'>
6665 6665
                     ".get_lang('WorkTitle')."
6666 6666
                     </td>
@@ -6671,35 +6671,35 @@  discard block
 block discarded – undo
6671 6671
                     ".get_lang('Date')."
6672 6672
                     </td>
6673 6673
                 </tr>";
6674
-    		if (is_array($results)) {
6675
-    			for($j = 0 ; $j < count($results) ; $j++) {
6676
-    				$pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3];
6677
-    				$beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get());
6678
-    				echo "<tr>";
6679
-    				echo "<td class='content'>"
6680
-    				."<a href ='".$pathToFile."'>".$results[$j][1]."</a>"
6681
-    				."</td>";
6682
-    				echo "<td class='content'>".$results[$j][2]."</td>";
6683
-    				echo "<td class='content'>".$beautifulDate."</td>";
6684
-    				echo"</tr>";
6685
-    			}
6686
-    		} else {
6687
-    			echo "<tr>";
6688
-    			echo "<td colspan='3'><center>".get_lang('NoResult')."</center></td>";
6689
-    			echo"</tr>";
6690
-    		}
6691
-    		echo "</table>";
6692
-    		echo "</td></tr>";
6693
-    	} else {
6694
-    		$new_view = substr_replace($view,'1',2,1);
6695
-    		echo "
6674
+            if (is_array($results)) {
6675
+                for($j = 0 ; $j < count($results) ; $j++) {
6676
+                    $pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3];
6677
+                    $beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get());
6678
+                    echo "<tr>";
6679
+                    echo "<td class='content'>"
6680
+                    ."<a href ='".$pathToFile."'>".$results[$j][1]."</a>"
6681
+                    ."</td>";
6682
+                    echo "<td class='content'>".$results[$j][2]."</td>";
6683
+                    echo "<td class='content'>".$beautifulDate."</td>";
6684
+                    echo"</tr>";
6685
+                }
6686
+            } else {
6687
+                echo "<tr>";
6688
+                echo "<td colspan='3'><center>".get_lang('NoResult')."</center></td>";
6689
+                echo"</tr>";
6690
+            }
6691
+            echo "</table>";
6692
+            echo "</td></tr>";
6693
+        } else {
6694
+            $new_view = substr_replace($view,'1',2,1);
6695
+            echo "
6696 6696
                 <tr>
6697 6697
                     <td valign='top'>
6698 6698
                     +<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>
6699 6699
                     </td>
6700 6700
                 </tr>
6701 6701
             ";
6702
-    	}
6702
+        }
6703 6703
     }
6704 6704
 
6705 6705
     /**
@@ -6708,55 +6708,55 @@  discard block
 block discarded – undo
6708 6708
      */
6709 6709
     public function display_links_tracking_info($view, $user_id, $courseCode)
6710 6710
     {
6711
-    	global $TABLETRACK_LINKS, $TABLECOURSE_LINKS;
6711
+        global $TABLETRACK_LINKS, $TABLECOURSE_LINKS;
6712 6712
         $courseId = api_get_course_int_id($courseCode);
6713
-    	if (substr($view,3,1) == '1') {
6714
-    		$new_view = substr_replace($view,'0',3,1);
6715
-    		echo "
6713
+        if (substr($view,3,1) == '1') {
6714
+            $new_view = substr_replace($view,'0',3,1);
6715
+            echo "
6716 6716
                 <tr>
6717 6717
                         <td valign='top'>
6718 6718
                         <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>]
6719 6719
                         </td>
6720 6720
                 </tr>
6721 6721
             ";
6722
-    		echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('LinksDetails')."<br>";
6723
-    		$sql = "SELECT cl.title, cl.url
6722
+            echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('LinksDetails')."<br>";
6723
+            $sql = "SELECT cl.title, cl.url
6724 6724
                     FROM $TABLETRACK_LINKS AS sl, $TABLECOURSE_LINKS AS cl
6725 6725
                     WHERE sl.links_link_id = cl.id
6726 6726
                         AND sl.c_id = $courseId
6727 6727
                         AND sl.links_user_id = ".intval($user_id)."
6728 6728
                     GROUP BY cl.title, cl.url";
6729
-    		echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6730
-    		$results = StatsUtils::getManyResults2Col($sql);
6731
-    		echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
6732
-    		echo "<tr>
6729
+            echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6730
+            $results = StatsUtils::getManyResults2Col($sql);
6731
+            echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
6732
+            echo "<tr>
6733 6733
                     <td class='secLine'>
6734 6734
                     ".get_lang('LinksTitleLinkColumn')."
6735 6735
                     </td>
6736 6736
                 </tr>";
6737
-    		if (is_array($results)) {
6738
-    			for($j = 0 ; $j < count($results) ; $j++) {
6739
-    				echo "<tr>";
6740
-    				echo "<td class='content'><a href='".$results[$j][1]."'>".$results[$j][0]."</a></td>";
6741
-    				echo"</tr>";
6742
-    			}
6743
-    		} else {
6744
-    			echo "<tr>";
6745
-    			echo "<td ><center>".get_lang('NoResult')."</center></td>";
6746
-    			echo"</tr>";
6747
-    		}
6748
-    		echo "</table>";
6749
-    		echo "</td></tr>";
6750
-    	} else {
6751
-    		$new_view = substr_replace($view,'1',3,1);
6752
-    		echo "
6737
+            if (is_array($results)) {
6738
+                for($j = 0 ; $j < count($results) ; $j++) {
6739
+                    echo "<tr>";
6740
+                    echo "<td class='content'><a href='".$results[$j][1]."'>".$results[$j][0]."</a></td>";
6741
+                    echo"</tr>";
6742
+                }
6743
+            } else {
6744
+                echo "<tr>";
6745
+                echo "<td ><center>".get_lang('NoResult')."</center></td>";
6746
+                echo"</tr>";
6747
+            }
6748
+            echo "</table>";
6749
+            echo "</td></tr>";
6750
+        } else {
6751
+            $new_view = substr_replace($view,'1',3,1);
6752
+            echo "
6753 6753
                 <tr>
6754 6754
                     <td valign='top'>
6755 6755
                     +<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>
6756 6756
                     </td>
6757 6757
                 </tr>
6758 6758
             ";
6759
-    	}
6759
+        }
6760 6760
     }
6761 6761
 
6762 6762
     /**
@@ -6769,61 +6769,61 @@  discard block
 block discarded – undo
6769 6769
      */
6770 6770
     public static function display_document_tracking_info($view, $user_id, $course_code, $session_id = 0)
6771 6771
     {
6772
-    	// protect data
6772
+        // protect data
6773 6773
         $user_id = intval($user_id);
6774 6774
         $courseId = api_get_course_int_id($course_code);
6775
-    	$session_id = intval($session_id);
6775
+        $session_id = intval($session_id);
6776 6776
 
6777
-    	$downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
6778
-    	if(substr($view,4,1) == '1') {
6779
-    		$new_view = substr_replace($view,'0',4,1);
6780
-    		echo "
6777
+        $downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
6778
+        if(substr($view,4,1) == '1') {
6779
+            $new_view = substr_replace($view,'0',4,1);
6780
+            echo "
6781 6781
                 <tr>
6782 6782
                     <td valign='top'>
6783 6783
                     <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>]
6784 6784
                     </td>
6785 6785
                 </tr>
6786 6786
             ";
6787
-    		echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('DocumentsDetails')."<br>";
6787
+            echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('DocumentsDetails')."<br>";
6788 6788
 
6789
-    		$sql = "SELECT down_doc_path
6789
+            $sql = "SELECT down_doc_path
6790 6790
                     FROM $downloads_table
6791 6791
                     WHERE c_id = $courseId
6792 6792
                         AND down_user_id = $user_id
6793 6793
                         AND down_session_id = $session_id
6794 6794
                     GROUP BY down_doc_path";
6795 6795
 
6796
-    		echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6797
-    		$results = StatsUtils::getManyResults1Col($sql);
6798
-    		echo "<table cellpadding='2' cellspacing='1' border='0' align='center'>";
6799
-    		echo "<tr>
6796
+            echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6797
+            $results = StatsUtils::getManyResults1Col($sql);
6798
+            echo "<table cellpadding='2' cellspacing='1' border='0' align='center'>";
6799
+            echo "<tr>
6800 6800
                     <td class='secLine'>
6801 6801
                     ".get_lang('DocumentsTitleDocumentColumn')."
6802 6802
                     </td>
6803 6803
                 </tr>";
6804
-    		if (is_array($results)) {
6805
-    			for($j = 0 ; $j < count($results) ; $j++) {
6806
-    				echo "<tr>";
6807
-    				echo "<td class='content'>".$results[$j]."</td>";
6808
-    				echo"</tr>";
6809
-    			}
6810
-    		} else {
6811
-    			echo "<tr>";
6812
-    			echo "<td><center>".get_lang('NoResult')."</center></td>";
6813
-    			echo"</tr>";
6814
-    		}
6815
-    		echo "</table>";
6816
-    		echo "</td></tr>";
6817
-    	} else {
6818
-    		$new_view = substr_replace($view,'1',4,1);
6819
-    		echo "
6804
+            if (is_array($results)) {
6805
+                for($j = 0 ; $j < count($results) ; $j++) {
6806
+                    echo "<tr>";
6807
+                    echo "<td class='content'>".$results[$j]."</td>";
6808
+                    echo"</tr>";
6809
+                }
6810
+            } else {
6811
+                echo "<tr>";
6812
+                echo "<td><center>".get_lang('NoResult')."</center></td>";
6813
+                echo"</tr>";
6814
+            }
6815
+            echo "</table>";
6816
+            echo "</td></tr>";
6817
+        } else {
6818
+            $new_view = substr_replace($view,'1',4,1);
6819
+            echo "
6820 6820
                 <tr>
6821 6821
                     <td valign='top'>
6822 6822
                     +<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>
6823 6823
                     </td>
6824 6824
                 </tr>
6825 6825
             ";
6826
-    	}
6826
+        }
6827 6827
     }
6828 6828
 
6829 6829
     /**
@@ -6880,43 +6880,43 @@  discard block
 block discarded – undo
6880 6880
      */
6881 6881
     public function display_login_tracking_info($view, $user_id, $course_id, $session_id = 0)
6882 6882
     {
6883
-    	$MonthsLong = $GLOBALS['MonthsLong'];
6884
-    	$track_access_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
6885
-
6886
-    	// protected data
6887
-    	$user_id    = intval($user_id);
6888
-    	$session_id = intval($session_id);
6889
-    	$course_id  = intval($course_id);
6890
-
6891
-    	$tempView = $view;
6892
-    	if (substr($view,0,1) == '1') {
6893
-    		$new_view = substr_replace($view,'0',0,1);
6894
-    		$title[1]= get_lang('LoginsAndAccessTools').get_lang('LoginsDetails');
6895
-    		$sql = "SELECT UNIX_TIMESTAMP(access_date), count(access_date)
6883
+        $MonthsLong = $GLOBALS['MonthsLong'];
6884
+        $track_access_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
6885
+
6886
+        // protected data
6887
+        $user_id    = intval($user_id);
6888
+        $session_id = intval($session_id);
6889
+        $course_id  = intval($course_id);
6890
+
6891
+        $tempView = $view;
6892
+        if (substr($view,0,1) == '1') {
6893
+            $new_view = substr_replace($view,'0',0,1);
6894
+            $title[1]= get_lang('LoginsAndAccessTools').get_lang('LoginsDetails');
6895
+            $sql = "SELECT UNIX_TIMESTAMP(access_date), count(access_date)
6896 6896
                     FROM $track_access_table
6897 6897
                     WHERE access_user_id = $user_id
6898 6898
                     AND c_id = $course_id
6899 6899
                     AND access_session_id = $session_id
6900 6900
                     GROUP BY YEAR(access_date),MONTH(access_date)
6901 6901
                     ORDER BY YEAR(access_date),MONTH(access_date) ASC";
6902
-    		//$results = getManyResults2Col($sql);
6903
-    		$results = getManyResults3Col($sql);
6904
-    		$title_line= get_lang('LoginsTitleMonthColumn').';'.get_lang('LoginsTitleCountColumn')."\n";
6905
-    		$line='';
6906
-    		$total = 0;
6907
-    		if (is_array($results)) {
6908
-    			for($j = 0 ; $j < count($results) ; $j++) {
6909
-    				$line .= $results[$j][0].';'.$results[$j][1]."\n";
6910
-    				$total = $total + $results[$j][1];
6911
-    			}
6912
-    			$line .= get_lang('Total').";".$total."\n";
6913
-    		} else {
6914
-    			$line= get_lang('NoResult')."</center></td>";
6915
-    		}
6916
-    	} else {
6917
-    		$new_view = substr_replace($view,'1',0,1);
6918
-    	}
6919
-    	return array($title_line, $line);
6902
+            //$results = getManyResults2Col($sql);
6903
+            $results = getManyResults3Col($sql);
6904
+            $title_line= get_lang('LoginsTitleMonthColumn').';'.get_lang('LoginsTitleCountColumn')."\n";
6905
+            $line='';
6906
+            $total = 0;
6907
+            if (is_array($results)) {
6908
+                for($j = 0 ; $j < count($results) ; $j++) {
6909
+                    $line .= $results[$j][0].';'.$results[$j][1]."\n";
6910
+                    $total = $total + $results[$j][1];
6911
+                }
6912
+                $line .= get_lang('Total').";".$total."\n";
6913
+            } else {
6914
+                $line= get_lang('NoResult')."</center></td>";
6915
+            }
6916
+        } else {
6917
+            $new_view = substr_replace($view,'1',0,1);
6918
+        }
6919
+        return array($title_line, $line);
6920 6920
     }
6921 6921
 
6922 6922
     /**
@@ -6929,67 +6929,67 @@  discard block
 block discarded – undo
6929 6929
      */
6930 6930
     public function display_exercise_tracking_info($view, $userId, $courseCode)
6931 6931
     {
6932
-    	global $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $TABLETRACK_HOTPOTATOES, $dateTimeFormatLong;
6932
+        global $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $TABLETRACK_HOTPOTATOES, $dateTimeFormatLong;
6933 6933
         $courseId = api_get_course_int_id($courseCode);
6934 6934
         $userId = intval($userId);
6935
-    	if (substr($view,1,1) == '1') {
6936
-    		$new_view = substr_replace($view,'0',1,1);
6937
-    		$title[1] = get_lang('ExercicesDetails');
6938
-    		$line = '';
6939
-    		$sql = "SELECT ce.title, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
6935
+        if (substr($view,1,1) == '1') {
6936
+            $new_view = substr_replace($view,'0',1,1);
6937
+            $title[1] = get_lang('ExercicesDetails');
6938
+            $line = '';
6939
+            $sql = "SELECT ce.title, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
6940 6940
                     FROM $TABLECOURSE_EXERCICES AS ce , $TABLETRACK_EXERCICES AS te
6941 6941
                     WHERE te.c_id = $courseId
6942 6942
                         AND te.exe_user_id = $userId
6943 6943
                         AND te.exe_exo_id = ce.id
6944 6944
                     ORDER BY ce.title ASC, te.exe_date ASC";
6945 6945
 
6946
-    		$hpsql = "SELECT te.exe_name, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
6946
+            $hpsql = "SELECT te.exe_name, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
6947 6947
                         FROM $TABLETRACK_HOTPOTATOES AS te
6948 6948
                         WHERE te.exe_user_id = '$userId' AND te.c_id = $courseId
6949 6949
                         ORDER BY te.c_id ASC, te.exe_date ASC";
6950 6950
 
6951
-    		$hpresults = StatsUtils::getManyResultsXCol($hpsql, 4);
6951
+            $hpresults = StatsUtils::getManyResultsXCol($hpsql, 4);
6952 6952
 
6953
-    		$NoTestRes = 0;
6954
-    		$NoHPTestRes = 0;
6953
+            $NoTestRes = 0;
6954
+            $NoHPTestRes = 0;
6955 6955
 
6956
-    		$results = StatsUtils::getManyResultsXCol($sql, 4);
6957
-    		$title_line = get_lang('ExercicesTitleExerciceColumn').";".get_lang('Date').';'.get_lang('ExercicesTitleScoreColumn')."\n";
6956
+            $results = StatsUtils::getManyResultsXCol($sql, 4);
6957
+            $title_line = get_lang('ExercicesTitleExerciceColumn').";".get_lang('Date').';'.get_lang('ExercicesTitleScoreColumn')."\n";
6958 6958
 
6959
-    		if (is_array($results)) {
6960
-    			for($i = 0; $i < sizeof($results); $i++)
6961
-    			{
6962
-    				$display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get());
6963
-    				$line .= $results[$i][0].";".$display_date.";".$results[$i][1]." / ".$results[$i][2]."\n";
6964
-    			}
6965
-    		} else {
6959
+            if (is_array($results)) {
6960
+                for($i = 0; $i < sizeof($results); $i++)
6961
+                {
6962
+                    $display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get());
6963
+                    $line .= $results[$i][0].";".$display_date.";".$results[$i][1]." / ".$results[$i][2]."\n";
6964
+                }
6965
+            } else {
6966 6966
                 // istvan begin
6967
-    			$NoTestRes = 1;
6968
-    		}
6969
-
6970
-    		// The Result of Tests
6971
-    		if (is_array($hpresults)) {
6972
-    			for($i = 0; $i < sizeof($hpresults); $i++) {
6973
-    				$title = GetQuizName($hpresults[$i][0],'');
6974
-
6975
-    				if ($title == '')
6976
-    				$title = basename($hpresults[$i][0]);
6977
-
6978
-    				$display_date = api_convert_and_format_date($hpresults[$i][3], null, date_default_timezone_get());
6979
-
6980
-    				$line .= $title.';'.$display_date.';'.$hpresults[$i][1].'/'.$hpresults[$i][2]."\n";
6981
-    			}
6982
-    		} else {
6983
-    			$NoHPTestRes = 1;
6984
-    		}
6985
-
6986
-    		if ($NoTestRes == 1 && $NoHPTestRes == 1) {
6987
-    			$line=get_lang('NoResult');
6988
-    		}
6989
-    	} else {
6990
-    		$new_view = substr_replace($view,'1',1,1);
6991
-    	}
6992
-    	return array($title_line, $line);
6967
+                $NoTestRes = 1;
6968
+            }
6969
+
6970
+            // The Result of Tests
6971
+            if (is_array($hpresults)) {
6972
+                for($i = 0; $i < sizeof($hpresults); $i++) {
6973
+                    $title = GetQuizName($hpresults[$i][0],'');
6974
+
6975
+                    if ($title == '')
6976
+                    $title = basename($hpresults[$i][0]);
6977
+
6978
+                    $display_date = api_convert_and_format_date($hpresults[$i][3], null, date_default_timezone_get());
6979
+
6980
+                    $line .= $title.';'.$display_date.';'.$hpresults[$i][1].'/'.$hpresults[$i][2]."\n";
6981
+                }
6982
+            } else {
6983
+                $NoHPTestRes = 1;
6984
+            }
6985
+
6986
+            if ($NoTestRes == 1 && $NoHPTestRes == 1) {
6987
+                $line=get_lang('NoResult');
6988
+            }
6989
+        } else {
6990
+            $new_view = substr_replace($view,'1',1,1);
6991
+        }
6992
+        return array($title_line, $line);
6993 6993
     }
6994 6994
 
6995 6995
     /**
@@ -6998,37 +6998,37 @@  discard block
 block discarded – undo
6998 6998
      */
6999 6999
     public function display_student_publications_tracking_info($view, $user_id, $course_id)
7000 7000
     {
7001
-    	global $TABLETRACK_UPLOADS, $TABLECOURSE_WORK;
7001
+        global $TABLETRACK_UPLOADS, $TABLECOURSE_WORK;
7002 7002
         $_course = api_get_course_info();
7003 7003
         $user_id = intval($user_id);
7004 7004
         $course_id = intval($course_id);
7005 7005
 
7006
-    	if (substr($view,2,1) == '1') {
7007
-    		$sql = "SELECT u.upload_date, w.title, w.author, w.url
7006
+        if (substr($view,2,1) == '1') {
7007
+            $sql = "SELECT u.upload_date, w.title, w.author, w.url
7008 7008
                     FROM $TABLETRACK_UPLOADS u , $TABLECOURSE_WORK w
7009 7009
                     WHERE
7010 7010
                         u.upload_work_id = w.id AND
7011 7011
                         u.upload_user_id = '$user_id' AND
7012 7012
                         u.c_id = '$course_id'
7013 7013
                     ORDER BY u.upload_date DESC";
7014
-    		$results = StatsUtils::getManyResultsXCol($sql,4);
7015
-
7016
-    		$title[1]=get_lang('WorksDetails');
7017
-    		$line='';
7018
-    		$title_line=get_lang('WorkTitle').";".get_lang('WorkAuthors').";".get_lang('Date')."\n";
7019
-
7020
-    		if (is_array($results)) {
7021
-    			for($j = 0 ; $j < count($results) ; $j++) {
7022
-    				$pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3];
7023
-    				$beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get());
7024
-    				$line .= $results[$j][1].";".$results[$j][2].";".$beautifulDate."\n";
7025
-    			}
7026
-
7027
-    		} else {
7028
-    			$line= get_lang('NoResult');
7029
-    		}
7030
-    	}
7031
-    	return array($title_line, $line);
7014
+            $results = StatsUtils::getManyResultsXCol($sql,4);
7015
+
7016
+            $title[1]=get_lang('WorksDetails');
7017
+            $line='';
7018
+            $title_line=get_lang('WorkTitle').";".get_lang('WorkAuthors').";".get_lang('Date')."\n";
7019
+
7020
+            if (is_array($results)) {
7021
+                for($j = 0 ; $j < count($results) ; $j++) {
7022
+                    $pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3];
7023
+                    $beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get());
7024
+                    $line .= $results[$j][1].";".$results[$j][2].";".$beautifulDate."\n";
7025
+                }
7026
+
7027
+            } else {
7028
+                $line= get_lang('NoResult');
7029
+            }
7030
+        }
7031
+        return array($title_line, $line);
7032 7032
     }
7033 7033
 
7034 7034
     /**
@@ -7037,32 +7037,32 @@  discard block
 block discarded – undo
7037 7037
      */
7038 7038
     public function display_links_tracking_info($view, $userId, $courseCode)
7039 7039
     {
7040
-    	global $TABLETRACK_LINKS, $TABLECOURSE_LINKS;
7040
+        global $TABLETRACK_LINKS, $TABLECOURSE_LINKS;
7041 7041
         $courseId = api_get_course_int_id($courseCode);
7042 7042
         $userId = intval($userId);
7043 7043
         $line = null;
7044
-    	if (substr($view,3,1) == '1') {
7045
-    		$new_view = substr_replace($view,'0',3,1);
7046
-    		$title[1]=get_lang('LinksDetails');
7047
-    		$sql = "SELECT cl.title, cl.url
7044
+        if (substr($view,3,1) == '1') {
7045
+            $new_view = substr_replace($view,'0',3,1);
7046
+            $title[1]=get_lang('LinksDetails');
7047
+            $sql = "SELECT cl.title, cl.url
7048 7048
                         FROM $TABLETRACK_LINKS AS sl, $TABLECOURSE_LINKS AS cl
7049 7049
                         WHERE sl.links_link_id = cl.id
7050 7050
                             AND sl.c_id = $courseId
7051 7051
                             AND sl.links_user_id = $userId
7052 7052
                         GROUP BY cl.title, cl.url";
7053
-    		$results = StatsUtils::getManyResults2Col($sql);
7054
-    		$title_line= get_lang('LinksTitleLinkColumn')."\n";
7055
-    		if (is_array($results)) {
7056
-    			for ($j = 0 ; $j < count($results) ; $j++) {
7057
-    				$line .= $results[$j][0]."\n";
7058
-    			}
7059
-    		} else {
7060
-    			$line=get_lang('NoResult');
7061
-    		}
7062
-    	} else {
7063
-    		$new_view = substr_replace($view,'1',3,1);
7064
-    	}
7065
-    	return array($title_line, $line);
7053
+            $results = StatsUtils::getManyResults2Col($sql);
7054
+            $title_line= get_lang('LinksTitleLinkColumn')."\n";
7055
+            if (is_array($results)) {
7056
+                for ($j = 0 ; $j < count($results) ; $j++) {
7057
+                    $line .= $results[$j][0]."\n";
7058
+                }
7059
+            } else {
7060
+                $line=get_lang('NoResult');
7061
+            }
7062
+        } else {
7063
+            $new_view = substr_replace($view,'1',3,1);
7064
+        }
7065
+        return array($title_line, $line);
7066 7066
     }
7067 7067
 
7068 7068
     /**
@@ -7075,38 +7075,38 @@  discard block
 block discarded – undo
7075 7075
      */
7076 7076
     public function display_document_tracking_info($view, $user_id, $courseCode, $session_id = 0)
7077 7077
     {
7078
-    	// protect data
7079
-    	$user_id     = intval($user_id);
7078
+        // protect data
7079
+        $user_id     = intval($user_id);
7080 7080
         $courseId = api_get_course_int_id($courseCode);
7081
-    	$session_id = intval($session_id);
7081
+        $session_id = intval($session_id);
7082 7082
 
7083
-    	$downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
7083
+        $downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
7084 7084
 
7085
-    	if (substr($view,4,1) == '1') {
7086
-    		$new_view = substr_replace($view,'0',4,1);
7087
-    		$title[1]= get_lang('DocumentsDetails');
7085
+        if (substr($view,4,1) == '1') {
7086
+            $new_view = substr_replace($view,'0',4,1);
7087
+            $title[1]= get_lang('DocumentsDetails');
7088 7088
 
7089
-    		$sql = "SELECT down_doc_path
7089
+            $sql = "SELECT down_doc_path
7090 7090
                         FROM $downloads_table
7091 7091
                         WHERE c_id = $courseId
7092 7092
                             AND down_user_id = $user_id
7093 7093
                             AND down_session_id = $session_id
7094 7094
                         GROUP BY down_doc_path";
7095 7095
 
7096
-    		$results = StatsUtils::getManyResults1Col($sql);
7097
-    		$title_line = get_lang('DocumentsTitleDocumentColumn')."\n";
7096
+            $results = StatsUtils::getManyResults1Col($sql);
7097
+            $title_line = get_lang('DocumentsTitleDocumentColumn')."\n";
7098 7098
             $line = null;
7099
-    		if (is_array($results)) {
7100
-    			for ($j = 0 ; $j < count($results) ; $j++) {
7101
-    				$line .= $results[$j]."\n";
7102
-    			}
7103
-    		} else {
7104
-    			$line = get_lang('NoResult');
7105
-    		}
7106
-    	} else {
7107
-    		$new_view = substr_replace($view,'1',4,1);
7108
-    	}
7109
-    	return array($title_line, $line);
7099
+            if (is_array($results)) {
7100
+                for ($j = 0 ; $j < count($results) ; $j++) {
7101
+                    $line .= $results[$j]."\n";
7102
+                }
7103
+            } else {
7104
+                $line = get_lang('NoResult');
7105
+            }
7106
+        } else {
7107
+            $new_view = substr_replace($view,'1',4,1);
7108
+        }
7109
+        return array($title_line, $line);
7110 7110
     }
7111 7111
 
7112 7112
     /**
Please login to merge, or discard this patch.
Spacing   +423 added lines, -423 removed lines patch added patch discarded remove patch
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
         $extendedAttempt = null,
112 112
         $extendedAll = null,
113 113
         $type = 'classic',
114
-        $allowExtend =  true
114
+        $allowExtend = true
115 115
     ) {
116 116
         if (empty($courseInfo) || empty($lp_id)) {
117 117
             return null;
@@ -135,22 +135,22 @@  discard block
 block discarded – undo
135 135
         $extend_all = 0;
136 136
 
137 137
         if ($origin == 'tracking') {
138
-            $url_suffix = '&session_id=' . $session_id . '&course=' . $courseCode . '&student_id=' . $user_id . '&lp_id=' . $lp_id . '&origin=' . $origin;
138
+            $url_suffix = '&session_id='.$session_id.'&course='.$courseCode.'&student_id='.$user_id.'&lp_id='.$lp_id.'&origin='.$origin;
139 139
         } else {
140
-            $url_suffix = '&lp_id=' . $lp_id;
140
+            $url_suffix = '&lp_id='.$lp_id;
141 141
         }
142 142
 
143 143
         if (!empty($extendedAll)) {
144 144
             $extend_all_link = Display::url(
145 145
                 Display::return_icon('view_less_stats.gif', get_lang('HideAllAttempts')),
146
-                api_get_self() . '?action=stats' . $url_suffix
146
+                api_get_self().'?action=stats'.$url_suffix
147 147
             );
148 148
 
149 149
             $extend_all = 1;
150 150
         } else {
151 151
             $extend_all_link = Display::url(
152 152
                 Display::return_icon('view_more_stats.gif', get_lang('ShowAllAttempts')),
153
-                api_get_self() . '?action=stats&extend_all=1' . $url_suffix
153
+                api_get_self().'?action=stats&extend_all=1'.$url_suffix
154 154
             );
155 155
         }
156 156
 
@@ -162,24 +162,24 @@  discard block
 block discarded – undo
162 162
 
163 163
         $actionColumn = null;
164 164
         if ($type == 'classic') {
165
-            $actionColumn = ' <th>' . get_lang('Actions') . '</th>';
165
+            $actionColumn = ' <th>'.get_lang('Actions').'</th>';
166 166
         }
167 167
         $output .= '<div class="table-responsive">';
168 168
         $output .= '<table class="table tracking">
169 169
             <thead>
170 170
             <tr class="table-header">
171
-                <th width="16">' . ($allowExtend == true ? $extend_all_link : '&nbsp;') . '</th>
171
+                <th width="16">' . ($allowExtend == true ? $extend_all_link : '&nbsp;').'</th>
172 172
                 <th colspan="4">
173
-                    ' . get_lang('ScormLessonTitle') .'
173
+                    ' . get_lang('ScormLessonTitle').'
174 174
                 </th>
175 175
                 <th colspan="2">
176
-                    ' . get_lang('ScormStatus') . '
176
+                    ' . get_lang('ScormStatus').'
177 177
                 </th>
178 178
                 <th colspan="2">
179
-                    ' . get_lang('ScormScore') . '
179
+                    ' . get_lang('ScormScore').'
180 180
                 </th>
181 181
                 <th colspan="2">
182
-                    ' . get_lang('ScormTime') . '
182
+                    ' . get_lang('ScormTime').'
183 183
                 </th>
184 184
                 '.$actionColumn.'
185 185
                 </tr>
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
                 // Prepare statement to go through each attempt.
243 243
                 $viewCondition = null;
244 244
                 if (!empty($view)) {
245
-                    $viewCondition =  " AND v.view_count = $view  ";
245
+                    $viewCondition = " AND v.view_count = $view  ";
246 246
                 }
247 247
 
248 248
                 $sql = "SELECT
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
                                 FROM $TBL_QUIZ
291 291
                                 WHERE
292 292
                                     c_id = $course_id AND
293
-                                    id ='" . $my_path . "'";
293
+                                    id ='".$my_path."'";
294 294
                         $res_result_disabled = Database::query($sql);
295 295
                         $row_result_disabled = Database::fetch_row($res_result_disabled);
296 296
 
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
                     if (!empty($inter_num)) {
313 313
                         $extend_link = Display::url(
314 314
                               Display::return_icon('visible.gif', get_lang('HideAttemptView')),
315
-                              api_get_self() . '?action=stats&fold_id=' . $my_item_id . $url_suffix
315
+                              api_get_self().'?action=stats&fold_id='.$my_item_id.$url_suffix
316 316
                         );
317 317
                     }
318 318
                     $title = $row['mytitle'];
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
 
331 331
                     $action = null;
332 332
                     if ($type == 'classic') {
333
-                        $action =  '<td></td>';
333
+                        $action = '<td></td>';
334 334
                     }
335 335
 
336 336
                     if (in_array($row['item_type'], $chapterTypes)) {
@@ -374,13 +374,13 @@  discard block
 block discarded – undo
374 374
                                 $extend_this_attempt = 1;
375 375
                                 $extend_attempt_link = Display::url(
376 376
                                     Display::return_icon('visible.gif', get_lang('HideAttemptView')),
377
-                                    api_get_self() . '?action=stats&extend_id=' . $my_item_id . '&fold_attempt_id=' . $row['iv_id'] . $url_suffix
377
+                                    api_get_self().'?action=stats&extend_id='.$my_item_id.'&fold_attempt_id='.$row['iv_id'].$url_suffix
378 378
                                 );
379 379
                             } else { // Same case if fold_attempt_id is set, so not implemented explicitly.
380 380
                                 // The extend button for this attempt has not been clicked.
381 381
                                 $extend_attempt_link = Display::url(
382 382
                                     Display::return_icon('invisible.gif', get_lang('ExtendAttemptView')),
383
-                                    api_get_self() . '?action=stats&extend_id=' . $my_item_id . '&extend_attempt_id=' . $row['iv_id'] . $url_suffix
383
+                                    api_get_self().'?action=stats&extend_id='.$my_item_id.'&extend_attempt_id='.$row['iv_id'].$url_suffix
384 384
                                 );
385 385
                             }
386 386
                         }
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
                         }
414 414
 
415 415
                         // Remove "NaN" if any (@todo: locate the source of these NaN)
416
-                        $time = str_replace('NaN', '00' . $h . '00\'00"', $time);
416
+                        $time = str_replace('NaN', '00'.$h.'00\'00"', $time);
417 417
 
418 418
                         if ($row['item_type'] != 'dokeos_chapter') {
419 419
                             if (!$is_allowed_to_edit && $result_disabled_ext_all) {
@@ -441,13 +441,13 @@  discard block
 block discarded – undo
441 441
                                 $action = '<td></td>';
442 442
                             }
443 443
 
444
-                            $output .= '<tr class="' . $oddclass . '">
444
+                            $output .= '<tr class="'.$oddclass.'">
445 445
                                     <td></td>
446
-                                    <td>' . $extend_attempt_link . '</td>
447
-                                    <td colspan="3">' . get_lang('Attempt') . ' ' . $attemptCount . '</td>
448
-                                    <td colspan="2">' . learnpathItem::humanize_status($lesson_status, true, $type) . '</td>
449
-                                    <td colspan="2">' . $view_score . '</td>
450
-                                    <td colspan="2">' . $time . '</td>
446
+                                    <td>' . $extend_attempt_link.'</td>
447
+                                    <td colspan="3">' . get_lang('Attempt').' '.$attemptCount.'</td>
448
+                                    <td colspan="2">' . learnpathItem::humanize_status($lesson_status, true, $type).'</td>
449
+                                    <td colspan="2">' . $view_score.'</td>
450
+                                    <td colspan="2">' . $time.'</td>
451 451
                                     '.$action.'
452 452
                                 </tr>';
453 453
                             $attemptCount++;
@@ -460,10 +460,10 @@  discard block
 block discarded – undo
460 460
                                     if (!$is_allowed_to_edit && $result_disabled_ext_all) {
461 461
                                         $temp[] = '/';
462 462
                                     } else {
463
-                                        $temp[] = ($score == 0 ? '0/' . $maxscore : ($maxscore == 0 ? $score : $score . '/' . float_format($maxscore, 1)));
463
+                                        $temp[] = ($score == 0 ? '0/'.$maxscore : ($maxscore == 0 ? $score : $score.'/'.float_format($maxscore, 1)));
464 464
                                     }
465 465
                                 } else {
466
-                                    $temp[] = ($score == 0 ? '/' : ($maxscore == 0 ? $score : $score . '/' . float_format($maxscore, 1)));
466
+                                    $temp[] = ($score == 0 ? '/' : ($maxscore == 0 ? $score : $score.'/'.float_format($maxscore, 1)));
467 467
                                 }
468 468
                                 $temp[] = $time;
469 469
                                 $csv_content[] = $temp;
@@ -500,13 +500,13 @@  discard block
 block discarded – undo
500 500
                                         <td></td>
501 501
                                         <td></td>
502 502
                                         <td></td>
503
-                                        <td>'.$interaction['order_id'] . '</td>
504
-                                        <td>'.$interaction['id'] . '</td>
503
+                                        <td>'.$interaction['order_id'].'</td>
504
+                                        <td>'.$interaction['id'].'</td>
505 505
                                         <td colspan="2">' . $interaction['type'].'</td>
506
-                                        <td>'.$student_response . '</td>
507
-                                        <td>'.$interaction['result'] . '</td>
508
-                                        <td>'.$interaction['latency'] . '</td>
509
-                                        <td>'.$interaction['time'] . '</td>
506
+                                        <td>'.$student_response.'</td>
507
+                                        <td>'.$interaction['result'].'</td>
508
+                                        <td>'.$interaction['latency'].'</td>
509
+                                        <td>'.$interaction['time'].'</td>
510 510
                                         '.$action.'
511 511
                                     </tr>';
512 512
                                 $counter++;
@@ -523,12 +523,12 @@  discard block
 block discarded – undo
523 523
                                         <td></td>
524 524
                                         <td></td>
525 525
                                         <td></td>
526
-                                        <td>' . $interaction['order_id'] . '</td>
527
-                                        <td colspan="2">' . $interaction['objective_id'] . '</td>
528
-                                        <td colspan="2">' . $interaction['status'] .'</td>
529
-                                        <td>' . $interaction['score_raw'] . '</td>
530
-                                        <td>' . $interaction['score_max'] . '</td>
531
-                                        <td>' . $interaction['score_min'] . '</td>
526
+                                        <td>' . $interaction['order_id'].'</td>
527
+                                        <td colspan="2">' . $interaction['objective_id'].'</td>
528
+                                        <td colspan="2">' . $interaction['status'].'</td>
529
+                                        <td>' . $interaction['score_raw'].'</td>
530
+                                        <td>' . $interaction['score_max'].'</td>
531
+                                        <td>' . $interaction['score_min'].'</td>
532 532
                                         '.$action.'
533 533
                                      </tr>';
534 534
                                 $counter++;
@@ -551,7 +551,7 @@  discard block
 block discarded – undo
551 551
                         $my_path = Database::escape_string($my_path);
552 552
                         $sql = "SELECT results_disabled
553 553
                                 FROM $TBL_QUIZ
554
-                                WHERE c_id = $course_id AND id ='" . $my_path . "'";
554
+                                WHERE c_id = $course_id AND id ='".$my_path."'";
555 555
                         $res_result_disabled = Database::query($sql);
556 556
                         $row_result_disabled = Database::fetch_row($res_result_disabled);
557 557
 
@@ -575,14 +575,14 @@  discard block
 block discarded – undo
575 575
                             $extend_this_attempt = 1;
576 576
                             $extend_attempt_link = Display::url(
577 577
                                 Display::return_icon('visible.gif', get_lang('HideAttemptView')),
578
-                                api_get_self() . '?action=stats&extend_id=' . $my_item_id . '&fold_attempt_id=' . $row['iv_id'] . $url_suffix
578
+                                api_get_self().'?action=stats&extend_id='.$my_item_id.'&fold_attempt_id='.$row['iv_id'].$url_suffix
579 579
                             );
580 580
                         } else {
581 581
                             // Same case if fold_attempt_id is set, so not implemented explicitly.
582 582
                             // The extend button for this attempt has not been clicked.
583 583
                             $extend_attempt_link = Display::url(
584 584
                                 Display::return_icon('invisible.gif', get_lang('ExtendAttemptView')),
585
-                                api_get_self() . '?action=stats&extend_id=' . $my_item_id . '&extend_attempt_id=' . $row['iv_id'] . $url_suffix
585
+                                api_get_self().'?action=stats&extend_id='.$my_item_id.'&extend_attempt_id='.$row['iv_id'].$url_suffix
586 586
                             );
587 587
                         }
588 588
                     }
@@ -597,7 +597,7 @@  discard block
 block discarded – undo
597 597
                     if ($inter_num > 1) {
598 598
                         $extend_link = Display::url(
599 599
                             Display::return_icon('invisible.gif', get_lang('ExtendAttemptView')),
600
-                            api_get_self() . '?action=stats&extend_id=' . $my_item_id . '&extend_attempt_id=' . $row['iv_id'] . $url_suffix
600
+                            api_get_self().'?action=stats&extend_id='.$my_item_id.'&extend_attempt_id='.$row['iv_id'].$url_suffix
601 601
                         );
602 602
                     }
603 603
 
@@ -613,15 +613,15 @@  discard block
 block discarded – undo
613 613
 
614 614
                     // Selecting the exe_id from stats attempts tables in order to look the max score value.
615 615
 
616
-                    $sql = 'SELECT * FROM ' . $tbl_stats_exercices . '
616
+                    $sql = 'SELECT * FROM '.$tbl_stats_exercices.'
617 617
                              WHERE
618
-                                exe_exo_id="' . $row['path'] . '" AND
619
-                                exe_user_id="' . $user_id . '" AND
620
-                                orig_lp_id = "' . $lp_id . '" AND
621
-                                orig_lp_item_id = "' . $row['myid'] . '" AND
622
-                                c_id = ' . $course_id . ' AND
618
+                                exe_exo_id="' . $row['path'].'" AND
619
+                                exe_user_id="' . $user_id.'" AND
620
+                                orig_lp_id = "' . $lp_id.'" AND
621
+                                orig_lp_item_id = "' . $row['myid'].'" AND
622
+                                c_id = ' . $course_id.' AND
623 623
                                 status <> "incomplete" AND
624
-                                session_id = ' . $session_id . '
624
+                                session_id = ' . $session_id.'
625 625
                              ORDER BY exe_date DESC
626 626
                              LIMIT 1';
627 627
 
@@ -652,8 +652,8 @@  discard block
 block discarded – undo
652 652
                                         FROM $TBL_LP_ITEM_VIEW
653 653
                                         WHERE
654 654
                                             c_id = $course_id AND
655
-                                            lp_item_id = '" . (int) $my_id . "' AND
656
-                                            lp_view_id = '" . (int) $my_lp_view_id . "'
655
+                                            lp_item_id = '".(int) $my_id."' AND
656
+                                            lp_view_id = '" . (int) $my_lp_view_id."'
657 657
                                         ORDER BY view_count DESC limit 1";
658 658
                                 $res_score = Database::query($sql);
659 659
                                 $row_score = Database::fetch_array($res_score);
@@ -662,8 +662,8 @@  discard block
 block discarded – undo
662 662
                                         FROM $TBL_LP_ITEM_VIEW
663 663
                                         WHERE
664 664
                                             c_id = $course_id AND
665
-                                            lp_item_id = '" . (int) $my_id . "' AND
666
-                                            lp_view_id = '" . (int) $my_lp_view_id . "'";
665
+                                            lp_item_id = '".(int) $my_id."' AND
666
+                                            lp_view_id = '" . (int) $my_lp_view_id."'";
667 667
                                 $res_time = Database::query($sql);
668 668
                                 $row_time = Database::fetch_array($res_time);
669 669
 
@@ -722,16 +722,16 @@  discard block
 block discarded – undo
722 722
                     } else {
723 723
                         $correct_test_link = '-';
724 724
                         if ($row['item_type'] == 'quiz') {
725
-                            $my_url_suffix = '&course=' . $courseCode . '&student_id=' . $user_id . '&lp_id=' . intval($row['mylpid']) . '&origin=' . $origin;
726
-                            $sql = 'SELECT * FROM ' . $tbl_stats_exercices . '
725
+                            $my_url_suffix = '&course='.$courseCode.'&student_id='.$user_id.'&lp_id='.intval($row['mylpid']).'&origin='.$origin;
726
+                            $sql = 'SELECT * FROM '.$tbl_stats_exercices.'
727 727
                                      WHERE
728
-                                        exe_exo_id="' . $row['path'] . '" AND
729
-                                        exe_user_id="' . $user_id . '" AND
730
-                                        orig_lp_id = "' . $lp_id . '" AND
731
-                                        orig_lp_item_id = "' . $row['myid'] . '" AND
732
-                                        c_id = ' . $course_id . ' AND
728
+                                        exe_exo_id="' . $row['path'].'" AND
729
+                                        exe_user_id="' . $user_id.'" AND
730
+                                        orig_lp_id = "' . $lp_id.'" AND
731
+                                        orig_lp_item_id = "' . $row['myid'].'" AND
732
+                                        c_id = ' . $course_id.' AND
733 733
                                         status <> "incomplete" AND
734
-                                        session_id = ' . $session_id . '
734
+                                        session_id = ' . $session_id.'
735 735
                                      ORDER BY exe_date DESC ';
736 736
 
737 737
                             $resultLastAttempt = Database::query($sql);
@@ -743,12 +743,12 @@  discard block
 block discarded – undo
743 743
                                 ) {
744 744
                                     $correct_test_link = Display::url(
745 745
                                         Display::return_icon('view_less_stats.gif', get_lang('HideAllAttempts')),
746
-                                        api_get_self() . '?action=stats' . $my_url_suffix . '&session_id=' . $session_id . '&lp_item_id=' . $my_id
746
+                                        api_get_self().'?action=stats'.$my_url_suffix.'&session_id='.$session_id.'&lp_item_id='.$my_id
747 747
                                     );
748 748
                                 } else {
749 749
                                     $correct_test_link = Display::url(
750 750
                                         Display::return_icon('view_more_stats.gif', get_lang('ShowAllAttemptsByExercise')),
751
-                                        api_get_self() . '?action=stats&extend_attempt=1' . $my_url_suffix . '&session_id=' . $session_id . '&lp_item_id=' . $my_id
751
+                                        api_get_self().'?action=stats&extend_attempt=1'.$my_url_suffix.'&session_id='.$session_id.'&lp_item_id='.$my_id
752 752
                                     );
753 753
                                 }
754 754
                             }
@@ -758,14 +758,14 @@  discard block
 block discarded – undo
758 758
 
759 759
                         $action = null;
760 760
                         if ($type == 'classic') {
761
-                            $action =  '<td>' . $correct_test_link . '</td>';
761
+                            $action = '<td>'.$correct_test_link.'</td>';
762 762
                         }
763 763
 
764 764
                         if ($lp_id == $my_lp_id && false) {
765 765
 
766
-                            $output .= '<tr class =' . $oddclass . '>
767
-                                    <td>' . $extend_link . '</td>
768
-                                    <td colspan="4">' . $title . '</td>
766
+                            $output .= '<tr class ='.$oddclass.'>
767
+                                    <td>' . $extend_link.'</td>
768
+                                    <td colspan="4">' . $title.'</td>
769 769
                                     <td colspan="2">&nbsp;</td>
770 770
                                     <td colspan="2">&nbsp;</td>
771 771
                                     <td colspan="2">&nbsp;</td>
@@ -790,13 +790,13 @@  discard block
 block discarded – undo
790 790
                                     $scoreItem .= ExerciseLib::show_score($score, $maxscore, false);
791 791
                                 }
792 792
                             } else {
793
-                                $scoreItem .= $score == 0 ? '/' : ($maxscore == 0 ? $score : $score . '/' . $maxscore);
793
+                                $scoreItem .= $score == 0 ? '/' : ($maxscore == 0 ? $score : $score.'/'.$maxscore);
794 794
                             }
795 795
 
796 796
                             $output .= '
797 797
                                 <td>'.$extend_link.'</td>
798
-                                <td colspan="4">' . $title . '</td>
799
-                                <td colspan="2">' . learnpathitem::humanize_status($lesson_status) .'</td>
798
+                                <td colspan="4">' . $title.'</td>
799
+                                <td colspan="2">' . learnpathitem::humanize_status($lesson_status).'</td>
800 800
                                 <td colspan="2">'.$scoreItem.'</td>
801 801
                                 <td colspan="2">'.$time.'</td>
802 802
                                 '.$action.'
@@ -813,10 +813,10 @@  discard block
 block discarded – undo
813 813
                                 if (!$is_allowed_to_edit && $result_disabled_ext_all) {
814 814
                                     $temp[] = '/';
815 815
                                 } else {
816
-                                    $temp[] = ($score == 0 ? '0/' . $maxscore : ($maxscore == 0 ? $score : $score . '/' . float_format($maxscore, 1)));
816
+                                    $temp[] = ($score == 0 ? '0/'.$maxscore : ($maxscore == 0 ? $score : $score.'/'.float_format($maxscore, 1)));
817 817
                                 }
818 818
                             } else {
819
-                                $temp[] = ($score == 0 ? '/' : ($maxscore == 0 ? $score : $score . '/' . float_format($maxscore, 1)));
819
+                                $temp[] = ($score == 0 ? '/' : ($maxscore == 0 ? $score : $score.'/'.float_format($maxscore, 1)));
820 820
                             }
821 821
                             $temp[] = $time;
822 822
                             $csv_content[] = $temp;
@@ -827,7 +827,7 @@  discard block
 block discarded – undo
827 827
 
828 828
                     $action = null;
829 829
                     if ($type == 'classic') {
830
-                        $action =  '<td></td>';
830
+                        $action = '<td></td>';
831 831
                     }
832 832
 
833 833
                     if ($extend_this_attempt || $extend_all) {
@@ -864,11 +864,11 @@  discard block
 block discarded – undo
864 864
                                     <td></td>
865 865
                                     <td></td>
866 866
                                     <td></td>
867
-                                    <td>' . $interaction['order_id'] . '</td>
868
-                                    <td colspan="2">'.$interaction['objective_id'] . '</td>
869
-                                    <td colspan="2">' . $interaction['status'] . '</td>
867
+                                    <td>' . $interaction['order_id'].'</td>
868
+                                    <td colspan="2">'.$interaction['objective_id'].'</td>
869
+                                    <td colspan="2">' . $interaction['status'].'</td>
870 870
                                     <td>' . $interaction['score_raw'].'</td>
871
-                                    <td>' . $interaction['score_max'] .'</td>
871
+                                    <td>' . $interaction['score_max'].'</td>
872 872
                                     <td>' . $interaction['score_min'].'</td>
873 873
                                     '.$action.'
874 874
                                </tr>';
@@ -877,7 +877,7 @@  discard block
 block discarded – undo
877 877
                     }
878 878
 
879 879
                     // Attempts listing by exercise.
880
-                    if ($lp_id == $my_lp_id && $lp_item_id== $my_id && $extendedAttempt) {
880
+                    if ($lp_id == $my_lp_id && $lp_item_id == $my_id && $extendedAttempt) {
881 881
                         // Get attempts of a exercise.
882 882
                         if (!empty($lp_id) &&
883 883
                             !empty($lp_item_id) &&
@@ -892,15 +892,15 @@  discard block
 block discarded – undo
892 892
                             $row_path = Database::fetch_array($res_path);
893 893
 
894 894
                             if (Database::num_rows($res_path) > 0) {
895
-                                $sql = 'SELECT * FROM ' . $tbl_stats_exercices . '
895
+                                $sql = 'SELECT * FROM '.$tbl_stats_exercices.'
896 896
                                         WHERE
897
-                                            exe_exo_id="' . (int) $row_path['path'] . '" AND
897
+                                            exe_exo_id="' . (int) $row_path['path'].'" AND
898 898
                                             status <> "incomplete" AND
899
-                                            exe_user_id="' . $user_id . '" AND
900
-                                            orig_lp_id = "' . (int) $lp_id . '" AND
901
-                                            orig_lp_item_id = "' . (int) $lp_item_id . '" AND
902
-                                            c_id = ' . $course_id . '  AND
903
-                                            session_id = ' . $session_id . '
899
+                                            exe_user_id="' . $user_id.'" AND
900
+                                            orig_lp_id = "' . (int) $lp_id.'" AND
901
+                                            orig_lp_item_id = "' . (int) $lp_item_id.'" AND
902
+                                            c_id = ' . $course_id.'  AND
903
+                                            session_id = ' . $session_id.'
904 904
                                         ORDER BY exe_date';
905 905
                                 $res_attempts = Database::query($sql);
906 906
                                 $num_attempts = Database::num_rows($res_attempts);
@@ -918,7 +918,7 @@  discard block
 block discarded – undo
918 918
                                         if ($mktime_start_date && $mktime_exe_date) {
919 919
                                             $mytime = ((int) $mktime_exe_date - (int) $mktime_start_date);
920 920
                                             $time_attemp = learnpathItem :: getScormTimeFromParameter('js', $mytime);
921
-                                            $time_attemp = str_replace('NaN', '00' . $h . '00\'00"', $time_attemp);
921
+                                            $time_attemp = str_replace('NaN', '00'.$h.'00\'00"', $time_attemp);
922 922
                                         } else {
923 923
                                             $time_attemp = ' - ';
924 924
                                         }
@@ -944,33 +944,33 @@  discard block
 block discarded – undo
944 944
                                             $my_lesson_status = learnpathitem::humanize_status('incomplete');
945 945
                                         }
946 946
 
947
-                                        $output .= '<tr class="' . $oddclass . '" >
947
+                                        $output .= '<tr class="'.$oddclass.'" >
948 948
                                         <td></td>
949
-                                        <td>' . $extend_attempt_link . '</td>
950
-                                        <td colspan="3">' . get_lang('Attempt').' '. $n.'</td>
951
-                                        <td colspan="2">' . $my_lesson_status . '</td>
952
-                                        <td colspan="2">'.$view_score . '</td>
953
-                                        <td colspan="2">'.$time_attemp . '</td>';
949
+                                        <td>' . $extend_attempt_link.'</td>
950
+                                        <td colspan="3">' . get_lang('Attempt').' '.$n.'</td>
951
+                                        <td colspan="2">' . $my_lesson_status.'</td>
952
+                                        <td colspan="2">'.$view_score.'</td>
953
+                                        <td colspan="2">'.$time_attemp.'</td>';
954 954
                                         if ($action == 'classic') {
955 955
                                             if ($origin != 'tracking') {
956 956
                                                 if (!$is_allowed_to_edit && $result_disabled_ext_all) {
957 957
                                                     $output .= '<td>
958
-                                                            <img src="' . api_get_path(WEB_IMG_PATH) . 'quiz_na.gif" alt="' . get_lang('ShowAttempt') . '" title="' . get_lang('ShowAttempt') . '">
958
+                                                            <img src="' . api_get_path(WEB_IMG_PATH).'quiz_na.gif" alt="'.get_lang('ShowAttempt').'" title="'.get_lang('ShowAttempt').'">
959 959
                                                             </td>';
960 960
                                                 } else {
961 961
                                                     $output .= '<td>
962
-                                                            <a href="../exercice/exercise_show.php?origin=' . $origin . '&id=' . $my_exe_id . '&cidReq=' . $courseCode . '" target="_parent">
963
-                                                            <img src="' . api_get_path(WEB_IMG_PATH) . 'quiz.gif" alt="' . get_lang('ShowAttempt') . '" title="' . get_lang('ShowAttempt') . '">
962
+                                                            <a href="../exercice/exercise_show.php?origin=' . $origin.'&id='.$my_exe_id.'&cidReq='.$courseCode.'" target="_parent">
963
+                                                            <img src="' . api_get_path(WEB_IMG_PATH).'quiz.gif" alt="'.get_lang('ShowAttempt').'" title="'.get_lang('ShowAttempt').'">
964 964
                                                             </a></td>';
965 965
                                                 }
966 966
                                             } else {
967 967
                                                 if (!$is_allowed_to_edit && $result_disabled_ext_all) {
968 968
                                                     $output .= '<td>
969
-                                                                <img src="' . api_get_path(WEB_IMG_PATH) . 'quiz_na.gif" alt="' . get_lang('ShowAndQualifyAttempt') . '" title="' . get_lang('ShowAndQualifyAttempt') . '"></td>';
969
+                                                                <img src="' . api_get_path(WEB_IMG_PATH).'quiz_na.gif" alt="'.get_lang('ShowAndQualifyAttempt').'" title="'.get_lang('ShowAndQualifyAttempt').'"></td>';
970 970
                                                 } else {
971 971
                                                     $output .= '<td>
972
-                                                                    <a href="../exercice/exercise_show.php?cidReq=' . $courseCode . '&origin=correct_exercise_in_lp&id=' . $my_exe_id . '" target="_parent">
973
-                                                                    <img src="' . api_get_path(WEB_IMG_PATH) . 'quiz.gif" alt="' . get_lang('ShowAndQualifyAttempt') . '" title="' . get_lang('ShowAndQualifyAttempt') . '"></a></td>';
972
+                                                                    <a href="../exercice/exercise_show.php?cidReq=' . $courseCode.'&origin=correct_exercise_in_lp&id='.$my_exe_id.'" target="_parent">
973
+                                                                    <img src="' . api_get_path(WEB_IMG_PATH).'quiz.gif" alt="'.get_lang('ShowAndQualifyAttempt').'" title="'.get_lang('ShowAndQualifyAttempt').'"></a></td>';
974 974
                                                 }
975 975
                                             }
976 976
                                         }
@@ -1029,13 +1029,13 @@  discard block
 block discarded – undo
1029 1029
         }
1030 1030
 
1031 1031
         $total_time = learnpathItem::getScormTimeFromParameter('js', $total_time);
1032
-        $total_time = str_replace('NaN', '00' . $h . '00\'00"', $total_time);
1032
+        $total_time = str_replace('NaN', '00'.$h.'00\'00"', $total_time);
1033 1033
 
1034 1034
         if (!$is_allowed_to_edit && $result_disabled_ext_all) {
1035 1035
             $final_score = Display::return_icon('invisible.gif', get_lang('ResultsHiddenByExerciseSetting'));
1036 1036
         } else {
1037 1037
             if (is_numeric($total_score)) {
1038
-                $final_score = $total_score . '%';
1038
+                $final_score = $total_score.'%';
1039 1039
             } else {
1040 1040
                 $final_score = $total_score;
1041 1041
             }
@@ -1051,19 +1051,19 @@  discard block
 block discarded – undo
1051 1051
 
1052 1052
         $action = null;
1053 1053
         if ($type == 'classic') {
1054
-            $action =  '<td></td>';
1054
+            $action = '<td></td>';
1055 1055
         }
1056 1056
 
1057 1057
         $output .= '<tr class="'.$oddclass.'">
1058 1058
                 <td></td>
1059 1059
                 <td colspan="4">
1060
-                    <i>' . get_lang('AccomplishedStepsTotal') .'</i>
1060
+                    <i>' . get_lang('AccomplishedStepsTotal').'</i>
1061 1061
                 </td>
1062 1062
                 <td colspan="2">'.$progress.'%</td>
1063 1063
                 <td colspan="2">
1064 1064
                     ' . $final_score.'
1065 1065
                 </td>
1066
-                <td colspan="2">' . $total_time . '</div>
1066
+                <td colspan="2">' . $total_time.'</div>
1067 1067
                 '.$action.'
1068 1068
            </tr>';
1069 1069
 
@@ -1359,7 +1359,7 @@  discard block
 block discarded – undo
1359 1359
     	$tbl_track_course = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1360 1360
     	if (is_array($user_id)) {
1361 1361
     	    $user_id = array_map('intval', $user_id);
1362
-    		$condition_user = " AND user_id IN (".implode(',',$user_id).") ";
1362
+    		$condition_user = " AND user_id IN (".implode(',', $user_id).") ";
1363 1363
     	} else {
1364 1364
     		$user_id = intval($user_id);
1365 1365
     		$condition_user = " AND user_id = $user_id ";
@@ -1396,13 +1396,13 @@  discard block
 block discarded – undo
1396 1396
     {
1397 1397
     	$tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
1398 1398
     	$sql = 'SELECT login_date
1399
-    	        FROM ' . $tbl_track_login . '
1400
-                WHERE login_user_id = ' . intval($student_id) . '
1399
+    	        FROM ' . $tbl_track_login.'
1400
+                WHERE login_user_id = ' . intval($student_id).'
1401 1401
                 ORDER BY login_date ASC
1402 1402
                 LIMIT 0,1';
1403 1403
 
1404 1404
     	$rs = Database::query($sql);
1405
-    	if (Database::num_rows($rs)>0) {
1405
+    	if (Database::num_rows($rs) > 0) {
1406 1406
     		if ($first_login_date = Database::result($rs, 0, 0)) {
1407 1407
                 return api_convert_and_format_date(
1408 1408
                     $first_login_date,
@@ -1427,8 +1427,8 @@  discard block
 block discarded – undo
1427 1427
     {
1428 1428
     	$table = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
1429 1429
     	$sql = 'SELECT login_date
1430
-    	        FROM ' . $table . '
1431
-                WHERE login_user_id = ' . intval($student_id) . '
1430
+    	        FROM ' . $table.'
1431
+                WHERE login_user_id = ' . intval($student_id).'
1432 1432
                 ORDER BY login_date
1433 1433
                 DESC LIMIT 0,1';
1434 1434
 
@@ -1437,18 +1437,18 @@  discard block
 block discarded – undo
1437 1437
     		if ($last_login_date = Database::result($rs, 0, 0)) {
1438 1438
     			$last_login_date = api_get_local_time($last_login_date);
1439 1439
     			if ($return_timestamp) {
1440
-    				return api_strtotime($last_login_date,'UTC');
1440
+    				return api_strtotime($last_login_date, 'UTC');
1441 1441
     			} else {
1442 1442
     				if (!$warning_message) {
1443 1443
     					return api_format_date($last_login_date, DATE_FORMAT_SHORT);
1444 1444
     				} else {
1445
-    					$timestamp = api_strtotime($last_login_date,'UTC');
1445
+    					$timestamp = api_strtotime($last_login_date, 'UTC');
1446 1446
     					$currentTimestamp = time();
1447 1447
 
1448 1448
     					//If the last connection is > than 7 days, the text is red
1449 1449
     					//345600 = 7 days in seconds
1450 1450
     					if ($currentTimestamp - $timestamp > 604800) {
1451
-    						return '<span style="color: #F00;">' . api_format_date($last_login_date, DATE_FORMAT_SHORT) . '</span>';
1451
+    						return '<span style="color: #F00;">'.api_format_date($last_login_date, DATE_FORMAT_SHORT).'</span>';
1452 1452
     					} else {
1453 1453
     						return api_format_date($last_login_date, DATE_FORMAT_SHORT);
1454 1454
     					}
@@ -1483,7 +1483,7 @@  discard block
 block discarded – undo
1483 1483
         $sql = "$select
1484 1484
                 FROM $tbl_track_login
1485 1485
                 WHERE
1486
-                    login_user_id IN (' ". implode("','", $studentList) . "' ) AND
1486
+                    login_user_id IN (' ".implode("','", $studentList)."' ) AND
1487 1487
                     login_date < '$date'
1488 1488
                 ";
1489 1489
         $rs = Database::query($sql);
@@ -1581,7 +1581,7 @@  discard block
 block discarded – undo
1581 1581
                             '<a href="'.api_get_path(REL_CODE_PATH).'announcements/announcements.php?action=add&remind_inactive='.$student_id.'&cidReq='.$courseInfo['code'].'" title="'.get_lang('RemindInactiveUser').'">
1582 1582
                              <img src="'.api_get_path(WEB_IMG_PATH).'messagebox_warning.gif" /> </a>'
1583 1583
                             : null;
1584
-    					return $icon. Display::label($last_login_date, 'warning');
1584
+    					return $icon.Display::label($last_login_date, 'warning');
1585 1585
     				} else {
1586 1586
     					return $last_login_date;
1587 1587
     				}
@@ -1631,7 +1631,7 @@  discard block
 block discarded – undo
1631 1631
                     session_id = $session_id
1632 1632
                     $month_filter";
1633 1633
     	$rs = Database::query($sql);
1634
-    	if (Database::num_rows($rs)>0) {
1634
+    	if (Database::num_rows($rs) > 0) {
1635 1635
     		$row = Database::fetch_object($rs);
1636 1636
     		$count = $row->count_connections;
1637 1637
     	}
@@ -1652,14 +1652,14 @@  discard block
 block discarded – undo
1652 1652
     	$tbl_session_course_rel_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
1653 1653
 
1654 1654
     	$sql = 'SELECT DISTINCT c_id
1655
-                FROM ' . $tbl_course_rel_user . '
1655
+                FROM ' . $tbl_course_rel_user.'
1656 1656
                 WHERE user_id = ' . $user_id.' AND relation_type<>'.COURSE_RELATION_TYPE_RRHH;
1657 1657
     	$rs = Database::query($sql);
1658 1658
     	$nb_courses = Database::num_rows($rs);
1659 1659
 
1660 1660
     	if ($include_sessions) {
1661 1661
     		$sql = 'SELECT DISTINCT c_id
1662
-                    FROM ' . $tbl_session_course_rel_user . '
1662
+                    FROM ' . $tbl_session_course_rel_user.'
1663 1663
                     WHERE user_id = ' . $user_id;
1664 1664
     		$rs = Database::query($sql);
1665 1665
     		$nb_courses += Database::num_rows($rs);
@@ -1706,7 +1706,7 @@  discard block
 block discarded – undo
1706 1706
     		$condition_quiz = "";
1707 1707
     		if (!empty($exercise_id)) {
1708 1708
     			$exercise_id = intval($exercise_id);
1709
-    			$condition_quiz =" AND id = $exercise_id ";
1709
+    			$condition_quiz = " AND id = $exercise_id ";
1710 1710
     		}
1711 1711
 
1712 1712
     		// Compose a filter based on optional session id given
@@ -1755,7 +1755,7 @@  discard block
 block discarded – undo
1755 1755
                         }
1756 1756
                     }
1757 1757
                     if (!empty($exercise_list)) {
1758
-                        $exercise_id = implode("','",$exercise_list);
1758
+                        $exercise_id = implode("','", $exercise_list);
1759 1759
                     }
1760 1760
     			}
1761 1761
 
@@ -1780,10 +1780,10 @@  discard block
 block discarded – undo
1780 1780
     			$quiz_avg_score = null;
1781 1781
 
1782 1782
     			if (!empty($row['avg_score'])) {
1783
-    				$quiz_avg_score = round($row['avg_score'],2);
1783
+    				$quiz_avg_score = round($row['avg_score'], 2);
1784 1784
     			}
1785 1785
 
1786
-    			if(!empty($row['num_attempts'])) {
1786
+    			if (!empty($row['num_attempts'])) {
1787 1787
     				$quiz_avg_score = round($quiz_avg_score / $row['num_attempts'], 2);
1788 1788
     			}
1789 1789
     			if (is_array($student_id)) {
@@ -1913,7 +1913,7 @@  discard block
 block discarded – undo
1913 1913
             $row = Database::fetch_row($rs);
1914 1914
             $count = $row[0];
1915 1915
         }
1916
-        $count = ($count != 0 ) ? 100*round(intval($count)/count($exercise_list), 2) .'%' : '0%';
1916
+        $count = ($count != 0) ? 100 * round(intval($count) / count($exercise_list), 2).'%' : '0%';
1917 1917
         return $count;
1918 1918
     }
1919 1919
 
@@ -1938,7 +1938,7 @@  discard block
 block discarded – undo
1938 1938
                 );
1939 1939
 
1940 1940
                 if (!empty($best_attempt) && !empty($best_attempt['exe_weighting'])) {
1941
-                    $result += $best_attempt['exe_result']/$best_attempt['exe_weighting'];
1941
+                    $result += $best_attempt['exe_result'] / $best_attempt['exe_weighting'];
1942 1942
                 }
1943 1943
             }
1944 1944
             $result = $result / count($exercise_list);
@@ -1975,7 +1975,7 @@  discard block
 block discarded – undo
1975 1975
         $query = sprintf($sql, intval($courseId), $sessionId);
1976 1976
         $rs = Database::query($query);
1977 1977
         $teachers = array();
1978
-        while ($teacher = Database::fetch_array($rs,'ASSOC')) {
1978
+        while ($teacher = Database::fetch_array($rs, 'ASSOC')) {
1979 1979
             $teachers[] = $teacher;
1980 1980
         }
1981 1981
         $data = array();
@@ -2099,7 +2099,7 @@  discard block
 block discarded – undo
2099 2099
             $data[] = array(
2100 2100
                 'course' => $course['title'],
2101 2101
                 'session' => $teacher['name'],
2102
-                'tutor' => $tutor['username'] . ' - ' . $tutor['lastname'] . ' ' . $tutor['firstname'],
2102
+                'tutor' => $tutor['username'].' - '.$tutor['lastname'].' '.$tutor['firstname'],
2103 2103
                 'documents' => $totalDocuments,
2104 2104
                 'links' => $totalLinks,
2105 2105
                 'forums' => $totalForums,
@@ -2162,7 +2162,7 @@  discard block
 block discarded – undo
2162 2162
             for ($i = 0; $i < count($lPIds); $i++) {
2163 2163
                 $placeHolders[] = '?';
2164 2164
             }
2165
-            $lPConditions['AND id IN(' . implode(', ', $placeHolders) . ') '] = $lPIds;
2165
+            $lPConditions['AND id IN('.implode(', ', $placeHolders).') '] = $lPIds;
2166 2166
         }
2167 2167
 
2168 2168
         if ($onlySeriousGame) {
@@ -2182,12 +2182,12 @@  discard block
 block discarded – undo
2182 2182
 
2183 2183
         $conditions = [
2184 2184
             " c_id = {$courseInfo['real_id']} ",
2185
-            " lp_view.lp_id IN(" . implode(', ', $filteredLP) . ") "
2185
+            " lp_view.lp_id IN(".implode(', ', $filteredLP).") "
2186 2186
         ];
2187 2187
 
2188 2188
         if (is_array($studentId)) {
2189 2189
             $studentId = array_map('intval', $studentId);
2190
-            $conditions[] = " lp_view.user_id IN (" . implode(',', $studentId) . ")  ";
2190
+            $conditions[] = " lp_view.user_id IN (".implode(',', $studentId).")  ";
2191 2191
 
2192 2192
             $groupBy = 'GROUP BY lp_id';
2193 2193
         } else {
@@ -2279,7 +2279,7 @@  discard block
 block discarded – undo
2279 2279
             // Compose a filter based on optional learning paths list given
2280 2280
             $condition_lp = "";
2281 2281
             if (count($lp_ids) > 0) {
2282
-                $condition_lp =" AND id IN(".implode(',',$lp_ids).") ";
2282
+                $condition_lp = " AND id IN(".implode(',', $lp_ids).") ";
2283 2283
             }
2284 2284
 
2285 2285
             // Compose a filter based on optional session id
@@ -2319,9 +2319,9 @@  discard block
 block discarded – undo
2319 2319
             // prepare filter on users
2320 2320
             if (is_array($student_id)) {
2321 2321
                 array_walk($student_id, 'intval');
2322
-                $condition_user1 =" AND user_id IN (".implode(',', $student_id).") ";
2322
+                $condition_user1 = " AND user_id IN (".implode(',', $student_id).") ";
2323 2323
             } else {
2324
-                $condition_user1 =" AND user_id = $student_id ";
2324
+                $condition_user1 = " AND user_id = $student_id ";
2325 2325
             }
2326 2326
 
2327 2327
             if ($count_row_lp > 0 && !empty($student_id)) {
@@ -2364,7 +2364,7 @@  discard block
 block discarded – undo
2364 2364
                                     ORDER BY lp_item_id";
2365 2365
                             $res_lp_item = Database::query($sql);
2366 2366
 
2367
-                            while ($row_lp_item = Database::fetch_array($res_lp_item,'ASSOC')) {
2367
+                            while ($row_lp_item = Database::fetch_array($res_lp_item, 'ASSOC')) {
2368 2368
                                 $my_lp_item_id = $row_lp_item['lp_item_id'];
2369 2369
 
2370 2370
                                 // Getting the most recent attempt
@@ -2387,8 +2387,8 @@  discard block
 block discarded – undo
2387 2387
                                         ORDER BY view_count DESC
2388 2388
                                         LIMIT 1";
2389 2389
                                 $res_lp_item_result = Database::query($sql);
2390
-                                while ($row_max_score = Database::fetch_array($res_lp_item_result,'ASSOC')) {
2391
-                                    $list[]= $row_max_score;
2390
+                                while ($row_max_score = Database::fetch_array($res_lp_item_result, 'ASSOC')) {
2391
+                                    $list[] = $row_max_score;
2392 2392
                                 }
2393 2393
                             }
2394 2394
                         } else {
@@ -2412,8 +2412,8 @@  discard block
 block discarded – undo
2412 2412
                             if ($debug) echo $sql.'<br />';
2413 2413
                             $res_max_score = Database::query($sql);
2414 2414
 
2415
-                            while ($row_max_score = Database::fetch_array($res_max_score,'ASSOC')) {
2416
-                                $list[]= $row_max_score;
2415
+                            while ($row_max_score = Database::fetch_array($res_max_score, 'ASSOC')) {
2416
+                                $list[] = $row_max_score;
2417 2417
                             }
2418 2418
                         }
2419 2419
 
@@ -2428,7 +2428,7 @@  discard block
 block discarded – undo
2428 2428
                             $max_score_item_view = $row_max_score['max_score_item_view'];
2429 2429
                             $score = $row_max_score['score'];
2430 2430
 
2431
-                            if ($debug) echo '<h3>Item Type: ' .$row_max_score['item_type'].'</h3>';
2431
+                            if ($debug) echo '<h3>Item Type: '.$row_max_score['item_type'].'</h3>';
2432 2432
 
2433 2433
                             if ($row_max_score['item_type'] == 'sco') {
2434 2434
                                 /* Check if it is sco (easier to get max_score)
@@ -2446,7 +2446,7 @@  discard block
 block discarded – undo
2446 2446
                                 }
2447 2447
                                 // Avoid division by zero errors
2448 2448
                                 if (!empty($max_score)) {
2449
-                                    $lp_partial_total += $score/$max_score;
2449
+                                    $lp_partial_total += $score / $max_score;
2450 2450
                                 }
2451 2451
                                 if ($debug) echo '<b>$lp_partial_total, $score, $max_score '.$lp_partial_total.' '.$score.' '.$max_score.'</b><br />';
2452 2452
                             } else {
@@ -2470,10 +2470,10 @@  discard block
 block discarded – undo
2470 2470
                                         ORDER BY exe_date DESC
2471 2471
                                         LIMIT 1";
2472 2472
 
2473
-                                if ($debug) echo $sql .'<br />';
2473
+                                if ($debug) echo $sql.'<br />';
2474 2474
                                 $result_last_attempt = Database::query($sql);
2475 2475
                                 $num = Database :: num_rows($result_last_attempt);
2476
-                                if ($num > 0 ) {
2476
+                                if ($num > 0) {
2477 2477
                                     $id_last_attempt = Database :: result($result_last_attempt, 0, 0);
2478 2478
                                     if ($debug) echo $id_last_attempt.'<br />';
2479 2479
 
@@ -2502,13 +2502,13 @@  discard block
 block discarded – undo
2502 2502
                                         $max_score = $row_max_score_bis['maxscore'];
2503 2503
                                     }
2504 2504
                                     if (!empty($max_score) && floatval($max_score) > 0) {
2505
-                                        $lp_partial_total += $score/$max_score;
2505
+                                        $lp_partial_total += $score / $max_score;
2506 2506
                                     }
2507 2507
                                     if ($debug) echo '$lp_partial_total, $score, $max_score <b>'.$lp_partial_total.' '.$score.' '.$max_score.'</b><br />';
2508 2508
                                 }
2509 2509
                             }
2510 2510
 
2511
-                            if (in_array($row_max_score['item_type'], array('quiz','sco'))) {
2511
+                            if (in_array($row_max_score['item_type'], array('quiz', 'sco'))) {
2512 2512
                                 // Normal way
2513 2513
                                 if ($use_max_score[$lp_id]) {
2514 2514
                                     $count_items++;
@@ -2543,8 +2543,8 @@  discard block
 block discarded – undo
2543 2543
                     if ($debug) echo $sql;
2544 2544
                     $result_have_quiz = Database::query($sql);
2545 2545
 
2546
-                    if (Database::num_rows($result_have_quiz) > 0 ) {
2547
-                        $row = Database::fetch_array($result_have_quiz,'ASSOC');
2546
+                    if (Database::num_rows($result_have_quiz) > 0) {
2547
+                        $row = Database::fetch_array($result_have_quiz, 'ASSOC');
2548 2548
                         if (is_numeric($row['count']) && $row['count'] != 0) {
2549 2549
                             $lp_with_quiz++;
2550 2550
                         }
@@ -2556,7 +2556,7 @@  discard block
 block discarded – undo
2556 2556
 
2557 2557
                 if ($lp_with_quiz != 0) {
2558 2558
                     if (!$return_array) {
2559
-                        $score_of_scorm_calculate = round(($global_result/$lp_with_quiz),2);
2559
+                        $score_of_scorm_calculate = round(($global_result / $lp_with_quiz), 2);
2560 2560
                         if ($debug) var_dump($score_of_scorm_calculate);
2561 2561
                         if (empty($lp_ids)) {
2562 2562
                             if ($debug) echo '<h2>All lps fix: '.$score_of_scorm_calculate.'</h2>';
@@ -2630,9 +2630,9 @@  discard block
 block discarded – undo
2630 2630
 
2631 2631
         if (is_array($student_id)) {
2632 2632
             array_walk($student_id, 'intval');
2633
-            $conditions[] =" lp_view.user_id IN (".implode(',', $student_id).") ";
2633
+            $conditions[] = " lp_view.user_id IN (".implode(',', $student_id).") ";
2634 2634
         } else {
2635
-            $conditions[] =" lp_view.user_id = $student_id ";
2635
+            $conditions[] = " lp_view.user_id = $student_id ";
2636 2636
         }
2637 2637
 
2638 2638
         $conditionsToString = implode('AND ', $conditions);
@@ -2656,7 +2656,7 @@  discard block
 block discarded – undo
2656 2656
             return 0;
2657 2657
         }
2658 2658
 
2659
-        return ($row['sum_score'] / $row['sum_max_score'])*100;
2659
+        return ($row['sum_score'] / $row['sum_max_score']) * 100;
2660 2660
 
2661 2661
     }
2662 2662
 
@@ -2686,7 +2686,7 @@  discard block
 block discarded – undo
2686 2686
             // Compose a filter based on optional learning paths list given
2687 2687
             $condition_lp = "";
2688 2688
             if (count($lp_ids) > 0) {
2689
-                $condition_lp =" AND id IN(".implode(',',$lp_ids).") ";
2689
+                $condition_lp = " AND id IN(".implode(',', $lp_ids).") ";
2690 2690
             }
2691 2691
 
2692 2692
             // Compose a filter based on optional session id
@@ -2745,7 +2745,7 @@  discard block
 block discarded – undo
2745 2745
 
2746 2746
         if (!empty($course)) {
2747 2747
 
2748
-            $course_id	 = $course['real_id'];
2748
+            $course_id = $course['real_id'];
2749 2749
 
2750 2750
             $lp_table    = Database :: get_course_table(TABLE_LP_MAIN);
2751 2751
             $t_lpv       = Database :: get_course_table(TABLE_LP_VIEW);
@@ -2759,8 +2759,8 @@  discard block
 block discarded – undo
2759 2759
             // calculates last connection time
2760 2760
             if ($count_row_lp > 0) {
2761 2761
                 $sql = 'SELECT MAX(start_time)
2762
-                        FROM ' . $t_lpiv . ' AS item_view
2763
-                        INNER JOIN ' . $t_lpv . ' AS view
2762
+                        FROM ' . $t_lpiv.' AS item_view
2763
+                        INNER JOIN ' . $t_lpv.' AS view
2764 2764
                             ON item_view.lp_view_id = view.id
2765 2765
                         WHERE
2766 2766
                             item_view.c_id 		= '.$course_id.' AND
@@ -2796,15 +2796,15 @@  discard block
 block discarded – undo
2796 2796
 
2797 2797
         // At first, courses where $coach_id is coach of the course //
2798 2798
         $sql = 'SELECT session_id, c_id
2799
-                FROM ' . $tbl_session_course_user . '
2799
+                FROM ' . $tbl_session_course_user.'
2800 2800
                 WHERE user_id=' . $coach_id.' AND status=2';
2801 2801
 
2802 2802
         if (api_is_multiple_url_enabled()) {
2803
-            $tbl_session_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
2803
+            $tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
2804 2804
             $access_url_id = api_get_current_access_url_id();
2805 2805
             if ($access_url_id != -1) {
2806 2806
                 $sql = 'SELECT scu.session_id, scu.c_id
2807
-                    FROM ' . $tbl_session_course_user . ' scu
2807
+                    FROM ' . $tbl_session_course_user.' scu
2808 2808
                     INNER JOIN '.$tbl_session_rel_access_url.'  sru
2809 2809
                     ON (scu.session_id=sru.session_id)
2810 2810
                     WHERE
@@ -2838,28 +2838,28 @@  discard block
 block discarded – undo
2838 2838
 
2839 2839
         // Then, courses where $coach_id is coach of the session    //
2840 2840
         $sql = 'SELECT session_course_user.user_id
2841
-                FROM ' . $tbl_session_course_user . ' as session_course_user
2841
+                FROM ' . $tbl_session_course_user.' as session_course_user
2842 2842
                 INNER JOIN     '.$tbl_session_user.' sru
2843 2843
                 ON session_course_user.user_id = sru.user_id AND session_course_user.session_id = sru.session_id
2844
-                INNER JOIN ' . $tbl_session_course . ' as session_course
2844
+                INNER JOIN ' . $tbl_session_course.' as session_course
2845 2845
                 ON session_course.c_id = session_course_user.c_id
2846 2846
                 AND session_course_user.session_id = session_course.session_id
2847
-                INNER JOIN ' . $tbl_session . ' as session
2847
+                INNER JOIN ' . $tbl_session.' as session
2848 2848
                 ON session.id = session_course.session_id
2849 2849
                 AND session.id_coach = ' . $coach_id;
2850 2850
         if (api_is_multiple_url_enabled()) {
2851
-            $tbl_session_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
2851
+            $tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
2852 2852
             $access_url_id = api_get_current_access_url_id();
2853
-            if ($access_url_id != -1){
2853
+            if ($access_url_id != -1) {
2854 2854
                 $sql = 'SELECT session_course_user.user_id
2855
-                        FROM ' . $tbl_session_course_user . ' as session_course_user
2855
+                        FROM ' . $tbl_session_course_user.' as session_course_user
2856 2856
                         INNER JOIN     '.$tbl_session_user.' sru
2857 2857
                             ON session_course_user.user_id = sru.user_id AND
2858 2858
                                session_course_user.session_id = sru.session_id
2859
-                        INNER JOIN ' . $tbl_session_course . ' as session_course
2859
+                        INNER JOIN ' . $tbl_session_course.' as session_course
2860 2860
                             ON session_course.c_id = session_course_user.c_id AND
2861 2861
                             session_course_user.session_id = session_course.session_id
2862
-                        INNER JOIN ' . $tbl_session . ' as session
2862
+                        INNER JOIN ' . $tbl_session.' as session
2863 2863
                             ON session.id = session_course.session_id AND
2864 2864
                             session.id_coach = ' . $coach_id.'
2865 2865
                         INNER JOIN '.$tbl_session_rel_access_url.' session_rel_url
@@ -2889,8 +2889,8 @@  discard block
 block discarded – undo
2889 2889
 
2890 2890
         $students = [];
2891 2891
         // At first, courses where $coach_id is coach of the course //
2892
-        $sql = 'SELECT c_id FROM ' . $tbl_session_course_user . '
2893
-                WHERE session_id="' . $id_session . '" AND user_id=' . $coach_id.' AND status=2';
2892
+        $sql = 'SELECT c_id FROM '.$tbl_session_course_user.'
2893
+                WHERE session_id="' . $id_session.'" AND user_id='.$coach_id.' AND status=2';
2894 2894
         $result = Database::query($sql);
2895 2895
 
2896 2896
         while ($a_courses = Database::fetch_array($result)) {
@@ -2900,7 +2900,7 @@  discard block
 block discarded – undo
2900 2900
                     FROM $tbl_session_course_user AS srcru
2901 2901
                     WHERE
2902 2902
                         c_id = '$courseId' AND
2903
-                        session_id = '" . $id_session . "'";
2903
+                        session_id = '".$id_session."'";
2904 2904
             $rs = Database::query($sql);
2905 2905
             while ($row = Database::fetch_array($rs)) {
2906 2906
                 $students[$row['user_id']] = $row['user_id'];
@@ -2908,15 +2908,15 @@  discard block
 block discarded – undo
2908 2908
         }
2909 2909
 
2910 2910
         // Then, courses where $coach_id is coach of the session
2911
-        $sql = 'SELECT id_coach FROM ' . $tbl_session . '
2912
-                WHERE id="' . $id_session.'" AND id_coach="' . $coach_id . '"';
2911
+        $sql = 'SELECT id_coach FROM '.$tbl_session.'
2912
+                WHERE id="' . $id_session.'" AND id_coach="'.$coach_id.'"';
2913 2913
         $result = Database::query($sql);
2914 2914
 
2915 2915
         //He is the session_coach so we select all the users in the session
2916 2916
         if (Database::num_rows($result) > 0) {
2917 2917
             $sql = 'SELECT DISTINCT srcru.user_id
2918
-                    FROM ' . $tbl_session_course_user . ' AS srcru
2919
-                    WHERE session_id="' . $id_session . '"';
2918
+                    FROM ' . $tbl_session_course_user.' AS srcru
2919
+                    WHERE session_id="' . $id_session.'"';
2920 2920
             $result = Database::query($sql);
2921 2921
             while ($row = Database::fetch_array($result)) {
2922 2922
                 $students[$row['user_id']] = $row['user_id'];
@@ -2943,8 +2943,8 @@  discard block
 block discarded – undo
2943 2943
 
2944 2944
         // At first, courses where $coach_id is coach of the course //
2945 2945
 
2946
-        $sql = 'SELECT 1 FROM ' . $tbl_session_course_user . '
2947
-                WHERE user_id=' . $coach_id .' AND status=2';
2946
+        $sql = 'SELECT 1 FROM '.$tbl_session_course_user.'
2947
+                WHERE user_id=' . $coach_id.' AND status=2';
2948 2948
         $result = Database::query($sql);
2949 2949
         if (Database::num_rows($result) > 0) {
2950 2950
             return true;
@@ -2952,12 +2952,12 @@  discard block
 block discarded – undo
2952 2952
 
2953 2953
         // Then, courses where $coach_id is coach of the session
2954 2954
         $sql = 'SELECT session_course_user.user_id
2955
-                FROM ' . $tbl_session_course_user . ' as session_course_user
2956
-                INNER JOIN ' . $tbl_session_course . ' as session_course
2955
+                FROM ' . $tbl_session_course_user.' as session_course_user
2956
+                INNER JOIN ' . $tbl_session_course.' as session_course
2957 2957
                     ON session_course.c_id = session_course_user.c_id
2958
-                INNER JOIN ' . $tbl_session . ' as session
2958
+                INNER JOIN ' . $tbl_session.' as session
2959 2959
                     ON session.id = session_course.session_id
2960
-                    AND session.id_coach = ' . $coach_id . '
2960
+                    AND session.id_coach = ' . $coach_id.'
2961 2961
                 WHERE user_id = ' . $student_id;
2962 2962
         $result = Database::query($sql);
2963 2963
         if (Database::num_rows($result) > 0) {
@@ -2989,16 +2989,16 @@  discard block
 block discarded – undo
2989 2989
         // At first, courses where $coach_id is coach of the course.
2990 2990
 
2991 2991
         $sql = 'SELECT DISTINCT c.code
2992
-                FROM ' . $tbl_session_course_user . ' sc
2992
+                FROM ' . $tbl_session_course_user.' sc
2993 2993
                 INNER JOIN '.$tbl_course.' c
2994 2994
                 ON (c.id = sc.c_id)
2995 2995
                 WHERE user_id = ' . $coach_id.' AND status = 2';
2996 2996
 
2997 2997
         if (api_is_multiple_url_enabled()) {
2998 2998
             $access_url_id = api_get_current_access_url_id();
2999
-            if ($access_url_id != -1){
2999
+            if ($access_url_id != -1) {
3000 3000
                 $sql = 'SELECT DISTINCT c.code
3001
-                        FROM ' . $tbl_session_course_user . ' scu
3001
+                        FROM ' . $tbl_session_course_user.' scu
3002 3002
                         INNER JOIN '.$tbl_course.' c
3003 3003
                         ON (c.code = scu.c_id)
3004 3004
                         INNER JOIN '.$tbl_course_rel_access_url.' cru
@@ -3011,7 +3011,7 @@  discard block
 block discarded – undo
3011 3011
         }
3012 3012
 
3013 3013
         if (!empty($id_session)) {
3014
-            $sql .= ' AND session_id=' . $id_session;
3014
+            $sql .= ' AND session_id='.$id_session;
3015 3015
         }
3016 3016
 
3017 3017
         $courseList = array();
@@ -3023,25 +3023,25 @@  discard block
 block discarded – undo
3023 3023
         // Then, courses where $coach_id is coach of the session
3024 3024
 
3025 3025
         $sql = 'SELECT DISTINCT course.code
3026
-                FROM ' . $tbl_session_course . ' as session_course
3027
-                INNER JOIN ' . $tbl_session . ' as session
3026
+                FROM ' . $tbl_session_course.' as session_course
3027
+                INNER JOIN ' . $tbl_session.' as session
3028 3028
                     ON session.id = session_course.session_id
3029
-                    AND session.id_coach = ' . $coach_id . '
3030
-                INNER JOIN ' . $tbl_course . ' as course
3029
+                    AND session.id_coach = ' . $coach_id.'
3030
+                INNER JOIN ' . $tbl_course.' as course
3031 3031
                     ON course.id = session_course.c_id';
3032 3032
 
3033 3033
         if (api_is_multiple_url_enabled()) {
3034 3034
             $tbl_course_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
3035 3035
             $access_url_id = api_get_current_access_url_id();
3036
-            if ($access_url_id != -1){
3036
+            if ($access_url_id != -1) {
3037 3037
                 $sql = 'SELECT DISTINCT c.code
3038
-                    FROM ' . $tbl_session_course . ' as session_course
3038
+                    FROM ' . $tbl_session_course.' as session_course
3039 3039
                     INNER JOIN '.$tbl_course.' c
3040 3040
                     ON (c.id = session_course.c_id)
3041
-                    INNER JOIN ' . $tbl_session . ' as session
3041
+                    INNER JOIN ' . $tbl_session.' as session
3042 3042
                     ON session.id = session_course.session_id
3043
-                        AND session.id_coach = ' . $coach_id . '
3044
-                    INNER JOIN ' . $tbl_course . ' as course
3043
+                        AND session.id_coach = ' . $coach_id.'
3044
+                    INNER JOIN ' . $tbl_course.' as course
3045 3045
                         ON course.id = session_course.c_id
3046 3046
                      INNER JOIN '.$tbl_course_rel_access_url.' course_rel_url
3047 3047
                     ON (course_rel_url.c_id = c.id)';
@@ -3049,12 +3049,12 @@  discard block
 block discarded – undo
3049 3049
         }
3050 3050
 
3051 3051
         if (!empty ($id_session)) {
3052
-            $sql .= ' WHERE session_course.session_id=' . $id_session;
3052
+            $sql .= ' WHERE session_course.session_id='.$id_session;
3053 3053
             if (api_is_multiple_url_enabled())
3054
-            $sql .=  ' AND access_url_id = '.$access_url_id;
3055
-        }  else {
3054
+            $sql .= ' AND access_url_id = '.$access_url_id;
3055
+        } else {
3056 3056
             if (api_is_multiple_url_enabled())
3057
-            $sql .=  ' WHERE access_url_id = '.$access_url_id;
3057
+            $sql .= ' WHERE access_url_id = '.$access_url_id;
3058 3058
         }
3059 3059
 
3060 3060
         $result = Database::query($sql);
@@ -3110,7 +3110,7 @@  discard block
 block discarded – undo
3110 3110
             }
3111 3111
         }
3112 3112
 
3113
-        $tbl_session_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
3113
+        $tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
3114 3114
         $access_url_id = api_get_current_access_url_id();
3115 3115
 
3116 3116
         $sql = "
@@ -3230,7 +3230,7 @@  discard block
 block discarded – undo
3230 3230
             // table definition
3231 3231
             $tbl_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
3232 3232
             $tbl_document = Database :: get_course_table(TABLE_DOCUMENT);
3233
-            $course_id	 = $a_course['real_id'];
3233
+            $course_id = $a_course['real_id'];
3234 3234
             if (is_array($student_id)) {
3235 3235
                 $studentList = array_map('intval', $student_id);
3236 3236
                 $condition_user = " AND ip.insert_user_id IN ('".implode(',', $studentList)."') ";
@@ -3281,7 +3281,7 @@  discard block
 block discarded – undo
3281 3281
         $a_course = CourseManager::get_course_information($course_code);
3282 3282
         if (!empty($a_course)) {
3283 3283
             $course_id = $a_course['real_id'];
3284
-            $conditions[]= " ip.c_id  = $course_id AND pub.c_id  = $course_id ";
3284
+            $conditions[] = " ip.c_id  = $course_id AND pub.c_id  = $course_id ";
3285 3285
         }
3286 3286
 
3287 3287
         // table definition
@@ -3290,14 +3290,14 @@  discard block
 block discarded – undo
3290 3290
 
3291 3291
         if (is_array($student_id)) {
3292 3292
             $studentList = array_map('intval', $student_id);
3293
-            $conditions[]= " ip.insert_user_id IN ('".implode("','", $studentList)."') ";
3293
+            $conditions[] = " ip.insert_user_id IN ('".implode("','", $studentList)."') ";
3294 3294
         } else {
3295 3295
             $student_id = intval($student_id);
3296
-            $conditions[]= " ip.insert_user_id = '$student_id' ";
3296
+            $conditions[] = " ip.insert_user_id = '$student_id' ";
3297 3297
         }
3298 3298
         if (isset($session_id)) {
3299 3299
             $session_id = intval($session_id);
3300
-            $conditions[]= " pub.session_id = $session_id ";
3300
+            $conditions[] = " pub.session_id = $session_id ";
3301 3301
         }
3302 3302
         $conditionToString = implode('AND', $conditions);
3303 3303
 
@@ -3330,8 +3330,8 @@  discard block
 block discarded – undo
3330 3330
         $courseCondition = null;
3331 3331
         $conditions = array();
3332 3332
         if (!empty($courseInfo)) {
3333
-            $course_id	    = $courseInfo['real_id'];
3334
-            $conditions[]= " post.c_id  = $course_id AND forum.c_id = $course_id ";
3333
+            $course_id = $courseInfo['real_id'];
3334
+            $conditions[] = " post.c_id  = $course_id AND forum.c_id = $course_id ";
3335 3335
         }
3336 3336
 
3337 3337
         // Table definition.
@@ -3340,15 +3340,15 @@  discard block
 block discarded – undo
3340 3340
 
3341 3341
         if (is_array($student_id)) {
3342 3342
             $studentList = array_map('intval', $student_id);
3343
-            $conditions[]= " post.poster_id IN ('".implode("','", $studentList)."') ";
3343
+            $conditions[] = " post.poster_id IN ('".implode("','", $studentList)."') ";
3344 3344
         } else {
3345 3345
             $student_id = intval($student_id);
3346
-            $conditions[]= " post.poster_id = '$student_id' ";
3346
+            $conditions[] = " post.poster_id = '$student_id' ";
3347 3347
         }
3348 3348
 
3349 3349
         if (isset($session_id)) {
3350 3350
             $session_id = intval($session_id);
3351
-            $conditions[]= " forum.session_id = $session_id";
3351
+            $conditions[] = " forum.session_id = $session_id";
3352 3352
         }
3353 3353
 
3354 3354
         $conditionsToString = implode('AND ', $conditions);
@@ -3383,7 +3383,7 @@  discard block
 block discarded – undo
3383 3383
             $condition_session = '';
3384 3384
             if (isset($session_id)) {
3385 3385
                 $session_id = intval($session_id);
3386
-                $condition_session = api_get_session_condition($session_id, true,  false, 'f.session_id');
3386
+                $condition_session = api_get_session_condition($session_id, true, false, 'f.session_id');
3387 3387
             }
3388 3388
 
3389 3389
             $course_id = $courseInfo['real_id'];
@@ -3439,7 +3439,7 @@  discard block
 block discarded – undo
3439 3439
         $condition_session = '';
3440 3440
         if (isset($session_id)) {
3441 3441
             $session_id = intval($session_id);
3442
-            $condition_session = ' AND f.session_id = '. $session_id;
3442
+            $condition_session = ' AND f.session_id = '.$session_id;
3443 3443
         }
3444 3444
 
3445 3445
         $groupId = intval($groupId);
@@ -3500,7 +3500,7 @@  discard block
 block discarded – undo
3500 3500
         $condition_session = '';
3501 3501
         if (isset($session_id)) {
3502 3502
              $session_id = intval($session_id);
3503
-             $condition_session = ' AND f.session_id = '. $session_id;
3503
+             $condition_session = ' AND f.session_id = '.$session_id;
3504 3504
         }
3505 3505
 
3506 3506
         $groupId = intval($groupId);
@@ -3579,7 +3579,7 @@  discard block
 block discarded – undo
3579 3579
     {
3580 3580
         $student_id = intval($student_id);
3581 3581
         $courseId = intval($courseId);
3582
-        $session_id    = intval($session_id);
3582
+        $session_id = intval($session_id);
3583 3583
         $date_time  = '';
3584 3584
 
3585 3585
         // table definition
@@ -3648,7 +3648,7 @@  discard block
 block discarded – undo
3648 3648
         $table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
3649 3649
 
3650 3650
         $sql = 'SELECT 1
3651
-                FROM ' . $table . '
3651
+                FROM ' . $table.'
3652 3652
                 WHERE down_user_id = '.$student_id.'
3653 3653
                 AND c_id  = "'.$courseId.'"
3654 3654
                 AND down_session_id = '.$session_id.' ';
@@ -3726,30 +3726,30 @@  discard block
 block discarded – undo
3726 3726
                 '.$inner.'
3727 3727
                 WHERE c.id = '.$courseId.'
3728 3728
                 GROUP BY stats_login.user_id
3729
-                HAVING DATE_SUB( "' . $now . '", INTERVAL '.$since.' DAY) > max_date ';
3729
+                HAVING DATE_SUB( "' . $now.'", INTERVAL '.$since.' DAY) > max_date ';
3730 3730
 
3731 3731
         if ($since == 'never') {
3732 3732
             if (empty($session_id)) {
3733 3733
                 $sql = 'SELECT course_user.user_id
3734
-                        FROM ' . $table_course_rel_user . ' course_user
3735
-                        LEFT JOIN ' . $tbl_track_login . ' stats_login
3734
+                        FROM ' . $table_course_rel_user.' course_user
3735
+                        LEFT JOIN ' . $tbl_track_login.' stats_login
3736 3736
                         ON course_user.user_id = stats_login.user_id AND
3737
-                        relation_type<>' . COURSE_RELATION_TYPE_RRHH . '
3738
-                        INNER JOIN ' . $tableCourse . ' c
3737
+                        relation_type<>' . COURSE_RELATION_TYPE_RRHH.'
3738
+                        INNER JOIN ' . $tableCourse.' c
3739 3739
                         ON (c.id = course_user.c_id)
3740 3740
                         WHERE
3741
-                            course_user.c_id = ' . $courseId . ' AND
3741
+                            course_user.c_id = ' . $courseId.' AND
3742 3742
                             stats_login.login_course_date IS NULL
3743 3743
                         GROUP BY course_user.user_id';
3744 3744
             } else {
3745 3745
                 $sql = 'SELECT session_course_user.user_id
3746 3746
                         FROM '.$tbl_session_course_user.' session_course_user
3747
-                        LEFT JOIN ' . $tbl_track_login . ' stats_login
3747
+                        LEFT JOIN ' . $tbl_track_login.' stats_login
3748 3748
                         ON session_course_user.user_id = stats_login.user_id
3749
-                        INNER JOIN ' . $tableCourse . ' c
3749
+                        INNER JOIN ' . $tableCourse.' c
3750 3750
                         ON (c.id = session_course_user.c_id)
3751 3751
                         WHERE
3752
-                            session_course_user.c_id = ' . $courseId . ' AND
3752
+                            session_course_user.c_id = ' . $courseId.' AND
3753 3753
                             stats_login.login_course_date IS NULL
3754 3754
                         GROUP BY session_course_user.user_id';
3755 3755
 
@@ -3758,7 +3758,7 @@  discard block
 block discarded – undo
3758 3758
 
3759 3759
         $rs = Database::query($sql);
3760 3760
         $inactive_users = array();
3761
-        while($user = Database::fetch_array($rs)) {
3761
+        while ($user = Database::fetch_array($rs)) {
3762 3762
             $inactive_users[] = $user['user_id'];
3763 3763
         }
3764 3764
 
@@ -3780,10 +3780,10 @@  discard block
 block discarded – undo
3780 3780
         $table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
3781 3781
 
3782 3782
         $sql = 'SELECT '.$student_id.'
3783
-                FROM ' . $table . '
3783
+                FROM ' . $table.'
3784 3784
                 WHERE
3785
-                    access_user_id=' . $student_id . ' AND
3786
-                    c_id="' . $courseId . '" AND
3785
+                    access_user_id=' . $student_id.' AND
3786
+                    c_id="' . $courseId.'" AND
3787 3787
                     access_session_id = "'.$session_id.'" ';
3788 3788
 
3789 3789
         $rs = Database::query($sql);
@@ -3801,13 +3801,13 @@  discard block
 block discarded – undo
3801 3801
     {
3802 3802
         $hr_dept_id = intval($hr_dept_id);
3803 3803
         $a_students = array();
3804
-        $tbl_user     = Database :: get_main_table(TABLE_MAIN_USER);
3804
+        $tbl_user = Database :: get_main_table(TABLE_MAIN_USER);
3805 3805
 
3806 3806
         $sql = 'SELECT DISTINCT user_id FROM '.$tbl_user.' as user
3807 3807
                 WHERE hr_dept_id='.$hr_dept_id;
3808 3808
         $rs = Database::query($sql);
3809 3809
 
3810
-        while($user = Database :: fetch_array($rs)) {
3810
+        while ($user = Database :: fetch_array($rs)) {
3811 3811
             $a_students[$user['user_id']] = $user['user_id'];
3812 3812
         }
3813 3813
 
@@ -3832,7 +3832,7 @@  discard block
 block discarded – undo
3832 3832
         $condition_session     = '';
3833 3833
         if (isset($session_id)) {
3834 3834
             $session_id = intval($session_id);
3835
-            $condition_session = ' AND access_session_id = '. $session_id;
3835
+            $condition_session = ' AND access_session_id = '.$session_id;
3836 3836
         }
3837 3837
         $sql = "SELECT
3838 3838
                     access_tool,
@@ -3944,7 +3944,7 @@  discard block
 block discarded – undo
3944 3944
             if (!empty($date_from) && !empty($date_to)) {
3945 3945
                 $fieldStartDate = $fields['start_date'];
3946 3946
                 if (!isset($fields['end_date'])) {
3947
-                    $where .= sprintf(" AND ($fieldStartDate BETWEEN '%s' AND '%s' )", $date_from, $date_to) ;
3947
+                    $where .= sprintf(" AND ($fieldStartDate BETWEEN '%s' AND '%s' )", $date_from, $date_to);
3948 3948
                 } else {
3949 3949
                     $fieldEndDate = $fields['end_date'];
3950 3950
                     $where .= sprintf(" AND fieldStartDate >= '%s'
@@ -3960,12 +3960,12 @@  discard block
 block discarded – undo
3960 3960
                 $where
3961 3961
                 GROUP BY %s";
3962 3962
             $sql = sprintf($sql,
3963
-                $fields['user'],    //user field
3964
-                $tableName,         //FROM
3965
-                $fields['course'],  //course condition
3966
-                $course['real_id'],    //course condition
3967
-                $fields['user'],    //user condition
3968
-                $userId,            //user condition
3963
+                $fields['user'], //user field
3964
+                $tableName, //FROM
3965
+                $fields['course'], //course condition
3966
+                $course['real_id'], //course condition
3967
+                $fields['user'], //user condition
3968
+                $userId, //user condition
3969 3969
                 $fields['user']     //GROUP BY
3970 3970
                 );
3971 3971
             $rs = Database::query($sql);
@@ -3973,7 +3973,7 @@  discard block
 block discarded – undo
3973 3973
             //iterate query
3974 3974
             if (Database::num_rows($rs) > 0) {
3975 3975
                 while ($row = Database::fetch_array($rs)) {
3976
-                    $data[$row['user']] = (isset($data[$row['user']])) ?  $data[$row['user']] + $row[total]: $row['total'];
3976
+                    $data[$row['user']] = (isset($data[$row['user']])) ? $data[$row['user']] + $row[total] : $row['total'];
3977 3977
                 }
3978 3978
             }
3979 3979
         }
@@ -3996,11 +3996,11 @@  discard block
 block discarded – undo
3996 3996
         $courseId = api_get_course_int_id($course_code);
3997 3997
         $data = array();
3998 3998
 
3999
-        $TABLETRACK_DOWNLOADS   = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
3999
+        $TABLETRACK_DOWNLOADS = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
4000 4000
         $condition_session = '';
4001 4001
         if (isset($session_id)) {
4002 4002
             $session_id = intval($session_id);
4003
-            $condition_session = ' AND down_session_id = '. $session_id;
4003
+            $condition_session = ' AND down_session_id = '.$session_id;
4004 4004
         }
4005 4005
         $sql = "SELECT down_doc_path, COUNT(DISTINCT down_user_id), COUNT(down_doc_path) as count_down
4006 4006
                 FROM $TABLETRACK_DOWNLOADS
@@ -4185,7 +4185,7 @@  discard block
 block discarded – undo
4185 4185
 
4186 4186
             $final_course_data = array();
4187 4187
 
4188
-            foreach($my_course_data as $course_id => $value) {
4188
+            foreach ($my_course_data as $course_id => $value) {
4189 4189
                 $final_course_data[$course_id] = $course_list[$course_id];
4190 4190
             }
4191 4191
             $course_in_session[$my_session_id]['course_list'] = $final_course_data;
@@ -4206,7 +4206,7 @@  discard block
 block discarded – undo
4206 4206
                           '.Display::tag('th', get_lang('Course'), array('width'=>'300px')).'
4207 4207
                           '.Display::tag('th', get_lang('TimeSpentInTheCourse'), array('class'=>'head')).'
4208 4208
                           '.Display::tag('th', get_lang('Progress'), array('class'=>'head')).'
4209
-                          '.Display::tag('th', get_lang('Score').Display::return_icon('info3.gif', get_lang('ScormAndLPTestTotalAverage'), array('align' => 'absmiddle', 'hspace' => '3px')),array('class'=>'head')).'
4209
+                          '.Display::tag('th', get_lang('Score').Display::return_icon('info3.gif', get_lang('ScormAndLPTestTotalAverage'), array('align' => 'absmiddle', 'hspace' => '3px')), array('class'=>'head')).'
4210 4210
                           '.Display::tag('th', get_lang('LastConnexion'), array('class'=>'head')).'
4211 4211
                           '.Display::tag('th', get_lang('Details'), array('class'=>'head')).'
4212 4212
                         </tr>';
@@ -4293,7 +4293,7 @@  discard block
 block discarded – undo
4293 4293
             $all_exercise_start_time = array();
4294 4294
 
4295 4295
             foreach ($course_in_session as $my_session_id => $session_data) {
4296
-                $course_list  = $session_data['course_list'];
4296
+                $course_list = $session_data['course_list'];
4297 4297
                 $user_count = count(SessionManager::get_users_by_session($my_session_id));
4298 4298
                 $exercise_graph_name_list = array();
4299 4299
                 //$user_results = array();
@@ -4338,20 +4338,20 @@  discard block
 block discarded – undo
4338 4338
 
4339 4339
                             $score = 0;
4340 4340
                             if (!empty($user_result_data['exe_weighting']) && intval($user_result_data['exe_weighting']) != 0) {
4341
-                                $score = intval($user_result_data['exe_result']/$user_result_data['exe_weighting'] * 100);
4341
+                                $score = intval($user_result_data['exe_result'] / $user_result_data['exe_weighting'] * 100);
4342 4342
                             }
4343 4343
                             $time = api_strtotime($exercise_data['start_time']) ? api_strtotime($exercise_data['start_time'], 'UTC') : 0;
4344 4344
                             $all_exercise_start_time[] = $time;
4345 4345
                             $my_results[] = $score;
4346
-                            if (count($exercise_list)<=10) {
4346
+                            if (count($exercise_list) <= 10) {
4347 4347
                                 $title = cut($course_data['title'], 30)." \n ".cut($exercise_data['title'], 30);
4348
-                                $exercise_graph_name_list[]= $title;
4348
+                                $exercise_graph_name_list[] = $title;
4349 4349
                                 $all_exercise_graph_name_list[] = $title;
4350 4350
                             } else {
4351 4351
                                 // if there are more than 10 results, space becomes difficult to find, so only show the title of the exercise, not the tool
4352 4352
                                 $title = cut($exercise_data['title'], 30);
4353
-                                $exercise_graph_name_list[]= $title;
4354
-                                $all_exercise_graph_name_list[]= $title;
4353
+                                $exercise_graph_name_list[] = $title;
4354
+                                $all_exercise_graph_name_list[] = $title;
4355 4355
                             }
4356 4356
                         }
4357 4357
                     }
@@ -4384,7 +4384,7 @@  discard block
 block discarded – undo
4384 4384
             }
4385 4385
 
4386 4386
             $html .= Display::page_subheader(
4387
-                Display::return_icon('session.png', get_lang('Sessions'), array(), ICON_SIZE_SMALL) . ' ' . get_lang('Sessions')
4387
+                Display::return_icon('session.png', get_lang('Sessions'), array(), ICON_SIZE_SMALL).' '.get_lang('Sessions')
4388 4388
             );
4389 4389
 
4390 4390
             $html .= '<table class="data_table" width="100%">';
@@ -4434,7 +4434,7 @@  discard block
 block discarded – undo
4434 4434
                                 $courseInfo['real_id'],
4435 4435
                                 $my_session_id
4436 4436
                             );
4437
-                            if ($attempts > 1)  {
4437
+                            if ($attempts > 1) {
4438 4438
                                 $answered_exercises++;
4439 4439
                             }
4440 4440
                         }
@@ -4447,7 +4447,7 @@  discard block
 block discarded – undo
4447 4447
                     $all_average += $average;
4448 4448
                 }
4449 4449
 
4450
-                $all_average = $all_average /  count($course_list);
4450
+                $all_average = $all_average / count($course_list);
4451 4451
 
4452 4452
                 if (isset($_GET['session_id']) && $my_session_id == $_GET['session_id']) {
4453 4453
                     $html .= '<tr style="background-color:#FBF09D">';
@@ -4472,31 +4472,31 @@  discard block
 block discarded – undo
4472 4472
                 $html .= '</tr>';
4473 4473
             }
4474 4474
             $html .= '</table><br />';
4475
-            $html .= Display::div($main_session_graph, array('id'=>'session_graph','class'=>'chart-session', 'style'=>'position:relative; text-align: center;') );
4475
+            $html .= Display::div($main_session_graph, array('id'=>'session_graph', 'class'=>'chart-session', 'style'=>'position:relative; text-align: center;'));
4476 4476
 
4477 4477
             // Checking selected session.
4478 4478
 
4479 4479
             if (isset($_GET['session_id'])) {
4480 4480
                 $session_id_from_get = intval($_GET['session_id']);
4481
-                $session_data 	= $course_in_session[$session_id_from_get];
4482
-                $course_list 	= $session_data['course_list'];
4481
+                $session_data = $course_in_session[$session_id_from_get];
4482
+                $course_list = $session_data['course_list'];
4483 4483
 
4484
-                $html .= Display::tag('h3',$session_data['name'].' - '.get_lang('CourseList'));
4484
+                $html .= Display::tag('h3', $session_data['name'].' - '.get_lang('CourseList'));
4485 4485
 
4486 4486
                 $html .= '<table class="data_table" width="100%">';
4487 4487
                 //'.Display::tag('th', get_lang('DoneExercises'),         array('class'=>'head')).'
4488 4488
                 $html .= '
4489 4489
                     <tr>
4490 4490
                       <th width="300px">'.get_lang('Course').'</th>
4491
-                      '.Display::tag('th', get_lang('PublishedExercises'),    	array('class'=>'head')).'
4492
-                      '.Display::tag('th', get_lang('NewExercises'),    		array('class'=>'head')).'
4493
-                      '.Display::tag('th', get_lang('MyAverage'), 				array('class'=>'head')).'
4494
-                      '.Display::tag('th', get_lang('AverageExerciseResult'), 	array('class'=>'head')).'
4495
-                      '.Display::tag('th', get_lang('TimeSpentInTheCourse'),    array('class'=>'head')).'
4496
-                      '.Display::tag('th', get_lang('LPProgress')     ,      	array('class'=>'head')).'
4497
-                      '.Display::tag('th', get_lang('Score').Display::return_icon('info3.gif', get_lang('ScormAndLPTestTotalAverage'), array ('align' => 'absmiddle', 'hspace' => '3px')), array('class'=>'head')).'
4498
-                      '.Display::tag('th', get_lang('LastConnexion'),         	array('class'=>'head')).'
4499
-                      '.Display::tag('th', get_lang('Details'),               	array('class'=>'head')).'
4491
+                      '.Display::tag('th', get_lang('PublishedExercises'), array('class'=>'head')).'
4492
+                      '.Display::tag('th', get_lang('NewExercises'), array('class'=>'head')).'
4493
+                      '.Display::tag('th', get_lang('MyAverage'), array('class'=>'head')).'
4494
+                      '.Display::tag('th', get_lang('AverageExerciseResult'), array('class'=>'head')).'
4495
+                      '.Display::tag('th', get_lang('TimeSpentInTheCourse'), array('class'=>'head')).'
4496
+                      '.Display::tag('th', get_lang('LPProgress'), array('class'=>'head')).'
4497
+                      '.Display::tag('th', get_lang('Score').Display::return_icon('info3.gif', get_lang('ScormAndLPTestTotalAverage'), array('align' => 'absmiddle', 'hspace' => '3px')), array('class'=>'head')).'
4498
+                      '.Display::tag('th', get_lang('LastConnexion'), array('class'=>'head')).'
4499
+                      '.Display::tag('th', get_lang('Details'), array('class'=>'head')).'
4500 4500
                     </tr>';
4501 4501
 
4502 4502
                 foreach ($course_list as $course_data) {
@@ -4512,14 +4512,14 @@  discard block
 block discarded – undo
4512 4512
                         $count_exercises = count($exercises);
4513 4513
                     }
4514 4514
                     $answered_exercises = 0;
4515
-                    foreach($exercises as $exercise_item) {
4515
+                    foreach ($exercises as $exercise_item) {
4516 4516
                         $attempts = Event::count_exercise_attempts_by_user(
4517 4517
                             api_get_user_id(),
4518 4518
                             $exercise_item['id'],
4519 4519
                             $courseId,
4520 4520
                             $session_id_from_get
4521 4521
                         );
4522
-                        if ($attempts > 1)  {
4522
+                        if ($attempts > 1) {
4523 4523
                             $answered_exercises++;
4524 4524
                         }
4525 4525
                     }
@@ -4528,7 +4528,7 @@  discard block
 block discarded – undo
4528 4528
 
4529 4529
                     // Average
4530 4530
                     $average = ExerciseLib::get_average_score_by_course($courseId, $session_id_from_get);
4531
-                    $my_average	= ExerciseLib::get_average_score_by_course_by_user(api_get_user_id(), $courseId, $session_id_from_get);
4531
+                    $my_average = ExerciseLib::get_average_score_by_course_by_user(api_get_user_id(), $courseId, $session_id_from_get);
4532 4532
 
4533 4533
                     $stats_array[$course_code] = array(
4534 4534
                         'exercises' => $count_exercises,
@@ -4598,11 +4598,11 @@  discard block
 block discarded – undo
4598 4598
                     }
4599 4599
                     //Score
4600 4600
                     $html .= Display::tag('td', $percentage_score, array('align'=>'center'));
4601
-                    $html .= Display::tag('td', $last_connection,  array('align'=>'center'));
4601
+                    $html .= Display::tag('td', $last_connection, array('align'=>'center'));
4602 4602
 
4603 4603
                     if ($course_code == $courseCodeFromGet && $_GET['session_id'] == $session_id_from_get) {
4604 4604
                         $details = '<a href="#">';
4605
-                        $details .=Display::return_icon('2rightarrow_na.png', get_lang('Details'));
4605
+                        $details .= Display::return_icon('2rightarrow_na.png', get_lang('Details'));
4606 4606
                     } else {
4607 4607
                         $details = '<a href="'.api_get_self().'?course='.$course_code.'&session_id='.$session_id_from_get.$extra_params.'">';
4608 4608
                         $details .= Display::return_icon('2rightarrow.png', get_lang('Details'));
@@ -4725,7 +4725,7 @@  discard block
 block discarded – undo
4725 4725
                         );
4726 4726
 
4727 4727
                         $latest_attempt_url = '';
4728
-                        $best_score = $position = $percentage_score_result  = '-';
4728
+                        $best_score = $position = $percentage_score_result = '-';
4729 4729
                         $graph = $normal_graph = null;
4730 4730
 
4731 4731
                         // Getting best results
@@ -4761,7 +4761,7 @@  discard block
 block discarded – undo
4761 4761
                                 $percentage_score_result = Display::url(ExerciseLib::show_score($score, $weighting), $latest_attempt_url);
4762 4762
                                 $my_score = 0;
4763 4763
                                 if (!empty($weighting) && intval($weighting) != 0) {
4764
-                                    $my_score = $score/$weighting;
4764
+                                    $my_score = $score / $weighting;
4765 4765
                                 }
4766 4766
                                 //@todo this function slows the page
4767 4767
                                 $position = ExerciseLib::get_exercise_result_ranking($my_score, $exe_id, $exercices['id'], $course_info['code'], $session_id, $user_list);
@@ -4772,14 +4772,14 @@  discard block
 block discarded – undo
4772 4772
                         }
4773 4773
                         $html .= Display::div(
4774 4774
                             $normal_graph,
4775
-                            array('id'=>'main_graph_'.$exercices['id'],'class'=>'dialog', 'style'=>'display:none')
4775
+                            array('id'=>'main_graph_'.$exercices['id'], 'class'=>'dialog', 'style'=>'display:none')
4776 4776
                         );
4777 4777
 
4778 4778
                         if (empty($graph)) {
4779 4779
                             $graph = '-';
4780 4780
                         } else {
4781 4781
                             $graph = Display::url(
4782
-                                '<img src="' . $graph . '" >',
4782
+                                '<img src="'.$graph.'" >',
4783 4783
                                 $normal_graph,
4784 4784
                                 array(
4785 4785
                                     'id' => $exercices['id'],
@@ -4812,7 +4812,7 @@  discard block
 block discarded – undo
4812 4812
 
4813 4813
 
4814 4814
             // LP table results
4815
-            $html .='<table class="data_table">';
4815
+            $html .= '<table class="data_table">';
4816 4816
             $html .= Display::tag('th', get_lang('Learnpaths'), array('class'=>'head', 'style'=>'color:#000'));
4817 4817
             $html .= Display::tag('th', get_lang('LatencyTimeSpent'), array('class'=>'head', 'style'=>'color:#000'));
4818 4818
             $html .= Display::tag('th', get_lang('Progress'), array('class'=>'head', 'style'=>'color:#000'));
@@ -4866,7 +4866,7 @@  discard block
 block discarded – undo
4866 4866
                     if (!empty($last_connection_in_lp)) {
4867 4867
                         $last_connection = api_convert_and_format_date($last_connection_in_lp, DATE_TIME_FORMAT_LONG);
4868 4868
                     }
4869
-                    $html .= Display::tag('td', $last_connection, array('align'=>'center','width'=>'180px'));
4869
+                    $html .= Display::tag('td', $last_connection, array('align'=>'center', 'width'=>'180px'));
4870 4870
                     $html .= "</tr>";
4871 4871
                 }
4872 4872
             } else {
@@ -4876,7 +4876,7 @@  discard block
 block discarded – undo
4876 4876
                         </td>
4877 4877
                       </tr>';
4878 4878
             }
4879
-            $html .='</table>';
4879
+            $html .= '</table>';
4880 4880
         }
4881 4881
 
4882 4882
         return $html;
@@ -4903,7 +4903,7 @@  discard block
 block discarded – undo
4903 4903
         $myData->setSerieDescription('Serie1', get_lang('MyResults'));
4904 4904
         $myData->setSerieDescription('Serie2', get_lang('AverageScore'));
4905 4905
         $myData->setAxisUnit(0, '%');
4906
-        $myData->loadPalette(api_get_path(SYS_CODE_PATH) . 'palettes/pchart/default.color', true);
4906
+        $myData->loadPalette(api_get_path(SYS_CODE_PATH).'palettes/pchart/default.color', true);
4907 4907
         // Cache definition
4908 4908
         $cachePath = api_get_path(SYS_ARCHIVE_PATH);
4909 4909
         $myCache = new pCache(array('CacheFolder' => substr($cachePath, 0, strlen($cachePath) - 1)));
@@ -4911,9 +4911,9 @@  discard block
 block discarded – undo
4911 4911
 
4912 4912
         if ($myCache->isInCache($chartHash)) {
4913 4913
             //if we already created the img
4914
-            $imgPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash;
4914
+            $imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
4915 4915
             $myCache->saveFromCache($chartHash, $imgPath);
4916
-            $imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash;
4916
+            $imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
4917 4917
         } else {
4918 4918
             /* Define width, height and angle */
4919 4919
             $mainWidth = 860;
@@ -4942,7 +4942,7 @@  discard block
 block discarded – undo
4942 4942
             /* Set the default font */
4943 4943
             $myPicture->setFontProperties(
4944 4944
                 array(
4945
-                    'FontName' => api_get_path(SYS_FONTS_PATH) . 'opensans/OpenSans-Regular.ttf',
4945
+                    'FontName' => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf',
4946 4946
                     'FontSize' => 10)
4947 4947
             );
4948 4948
             /* Write the chart title */
@@ -4959,7 +4959,7 @@  discard block
 block discarded – undo
4959 4959
             /* Set the default font */
4960 4960
             $myPicture->setFontProperties(
4961 4961
                 array(
4962
-                    'FontName' => api_get_path(SYS_FONTS_PATH) . 'opensans/OpenSans-Regular.ttf',
4962
+                    'FontName' => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf',
4963 4963
                     'FontSize' => 6
4964 4964
                 )
4965 4965
             );
@@ -5001,7 +5001,7 @@  discard block
 block discarded – undo
5001 5001
             /* Draw the line chart */
5002 5002
             $myPicture->setFontProperties(
5003 5003
                 array(
5004
-                    'FontName' => api_get_path(SYS_FONTS_PATH) . 'opensans/OpenSans-Regular.ttf',
5004
+                    'FontName' => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf',
5005 5005
                     'FontSize' => 10
5006 5006
                 )
5007 5007
             );
@@ -5034,12 +5034,12 @@  discard block
 block discarded – undo
5034 5034
             );
5035 5035
 
5036 5036
             $myCache->writeToCache($chartHash, $myPicture);
5037
-            $imgPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash;
5037
+            $imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
5038 5038
             $myCache->saveFromCache($chartHash, $imgPath);
5039
-            $imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash;
5039
+            $imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
5040 5040
         }
5041 5041
 
5042
-        $html = '<img src="' . $imgPath . '">';
5042
+        $html = '<img src="'.$imgPath.'">';
5043 5043
 
5044 5044
         return $html;
5045 5045
     }
@@ -5060,12 +5060,12 @@  discard block
 block discarded – undo
5060 5060
 
5061 5061
         foreach ($attempts as $attempt) {
5062 5062
             if (api_get_user_id() == $attempt['exe_user_id']) {
5063
-                if ($attempt['exe_weighting'] != 0 ) {
5064
-                    $my_exercise_result_array[]= $attempt['exe_result']/$attempt['exe_weighting'];
5063
+                if ($attempt['exe_weighting'] != 0) {
5064
+                    $my_exercise_result_array[] = $attempt['exe_result'] / $attempt['exe_weighting'];
5065 5065
                 }
5066 5066
             } else {
5067
-                if ($attempt['exe_weighting'] != 0 ) {
5068
-                    $exercise_result[]=  $attempt['exe_result']/$attempt['exe_weighting'];
5067
+                if ($attempt['exe_weighting'] != 0) {
5068
+                    $exercise_result[] = $attempt['exe_result'] / $attempt['exe_weighting'];
5069 5069
                 }
5070 5070
             }
5071 5071
         }
@@ -5074,27 +5074,27 @@  discard block
 block discarded – undo
5074 5074
         rsort($my_exercise_result_array);
5075 5075
         $my_exercise_result = 0;
5076 5076
         if (isset($my_exercise_result_array[0])) {
5077
-            $my_exercise_result = $my_exercise_result_array[0] *100;
5077
+            $my_exercise_result = $my_exercise_result_array[0] * 100;
5078 5078
         }
5079 5079
 
5080 5080
         $max     = 100;
5081
-        $pieces  = 5 ;
5081
+        $pieces  = 5;
5082 5082
         $part    = round($max / $pieces);
5083 5083
         $x_axis = array();
5084 5084
         $final_array = array();
5085 5085
         $my_final_array = array();
5086 5086
 
5087
-        for ($i=1; $i <=$pieces; $i++) {
5087
+        for ($i = 1; $i <= $pieces; $i++) {
5088 5088
             $sum = 1;
5089 5089
             if ($i == 1) {
5090 5090
                 $sum = 0;
5091 5091
             }
5092
-            $min = ($i-1)*$part + $sum;
5093
-            $max = ($i)*$part;
5094
-            $x_axis[]= $min." - ".$max;
5092
+            $min = ($i - 1) * $part + $sum;
5093
+            $max = ($i) * $part;
5094
+            $x_axis[] = $min." - ".$max;
5095 5095
             $count = 0;
5096
-            foreach($exercise_result as $result) {
5097
-                $percentage = $result*100;
5096
+            foreach ($exercise_result as $result) {
5097
+                $percentage = $result * 100;
5098 5098
                 //echo $percentage.' - '.$min.' - '.$max."<br />";
5099 5099
                 if ($percentage >= $min && $percentage <= $max) {
5100 5100
                     //echo ' is > ';
@@ -5102,7 +5102,7 @@  discard block
 block discarded – undo
5102 5102
                 }
5103 5103
             }
5104 5104
             //echo '<br />';
5105
-            $final_array[]= $count;
5105
+            $final_array[] = $count;
5106 5106
 
5107 5107
             if ($my_exercise_result >= $min && $my_exercise_result <= $max) {
5108 5108
                 $my_final_array[] = 1;
@@ -5112,9 +5112,9 @@  discard block
 block discarded – undo
5112 5112
         }
5113 5113
 
5114 5114
         //Fix to remove the data of the user with my data
5115
-        for($i = 0; $i<=count($my_final_array); $i++) {
5115
+        for ($i = 0; $i <= count($my_final_array); $i++) {
5116 5116
             if (!empty($my_final_array[$i])) {
5117
-                $my_final_array[$i] =  $final_array[$i] + 1; //Add my result
5117
+                $my_final_array[$i] = $final_array[$i] + 1; //Add my result
5118 5118
                 $final_array[$i] = 0;
5119 5119
             }
5120 5120
         }
@@ -5124,16 +5124,16 @@  discard block
 block discarded – undo
5124 5124
         $dataSet->addPoints($final_array, 'Serie1');
5125 5125
         $dataSet->addPoints($my_final_array, 'Serie2');
5126 5126
         $dataSet->normalize(100, "%");
5127
-        $dataSet->loadPalette(api_get_path(SYS_CODE_PATH) . 'palettes/pchart/default.color', true);
5127
+        $dataSet->loadPalette(api_get_path(SYS_CODE_PATH).'palettes/pchart/default.color', true);
5128 5128
 
5129 5129
         // Cache definition
5130 5130
         $cachePath = api_get_path(SYS_ARCHIVE_PATH);
5131 5131
         $myCache = new pCache(array('CacheFolder' => substr($cachePath, 0, strlen($cachePath) - 1)));
5132 5132
         $chartHash = $myCache->getHash($dataSet);
5133 5133
         if ($myCache->isInCache($chartHash)) {
5134
-            $imgPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash;
5134
+            $imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
5135 5135
             $myCache->saveFromCache($chartHash, $imgPath);
5136
-            $imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash;
5136
+            $imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
5137 5137
         } else {
5138 5138
             /* Create the pChart object */
5139 5139
             $widthSize = 80;
@@ -5149,7 +5149,7 @@  discard block
 block discarded – undo
5149 5149
             $myPicture->drawRectangle(0, 0, $widthSize - 1, $heightSize - 1, array('R' => 0, 'G' => 0, 'B' => 0));
5150 5150
 
5151 5151
             /* Set the default font */
5152
-            $myPicture->setFontProperties(array('FontName' => api_get_path(SYS_FONTS_PATH) . 'opensans/OpenSans-Regular.ttf', 'FontSize' => $fontSize));
5152
+            $myPicture->setFontProperties(array('FontName' => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf', 'FontSize' => $fontSize));
5153 5153
 
5154 5154
             /* Do not write the chart title */
5155 5155
 
@@ -5213,9 +5213,9 @@  discard block
 block discarded – undo
5213 5213
 
5214 5214
             /* Save and write in cache */
5215 5215
             $myCache->writeToCache($chartHash, $myPicture);
5216
-            $imgPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash;
5216
+            $imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
5217 5217
             $myCache->saveFromCache($chartHash, $imgPath);
5218
-            $imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash;
5218
+            $imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
5219 5219
         }
5220 5220
 
5221 5221
         return $imgPath;
@@ -5235,12 +5235,12 @@  discard block
 block discarded – undo
5235 5235
         }
5236 5236
         foreach ($attempts as $attempt) {
5237 5237
             if (api_get_user_id() == $attempt['exe_user_id']) {
5238
-                if ($attempt['exe_weighting'] != 0 ) {
5239
-                    $my_exercise_result_array[]= $attempt['exe_result']/$attempt['exe_weighting'];
5238
+                if ($attempt['exe_weighting'] != 0) {
5239
+                    $my_exercise_result_array[] = $attempt['exe_result'] / $attempt['exe_weighting'];
5240 5240
                 }
5241 5241
             } else {
5242
-                if ($attempt['exe_weighting'] != 0 ) {
5243
-                    $exercise_result[]=  $attempt['exe_result']/$attempt['exe_weighting'];
5242
+                if ($attempt['exe_weighting'] != 0) {
5243
+                    $exercise_result[] = $attempt['exe_result'] / $attempt['exe_weighting'];
5244 5244
                 }
5245 5245
             }
5246 5246
         }
@@ -5249,32 +5249,32 @@  discard block
 block discarded – undo
5249 5249
         rsort($my_exercise_result_array);
5250 5250
         $my_exercise_result = 0;
5251 5251
         if (isset($my_exercise_result_array[0])) {
5252
-            $my_exercise_result = $my_exercise_result_array[0] *100;
5252
+            $my_exercise_result = $my_exercise_result_array[0] * 100;
5253 5253
         }
5254 5254
 
5255 5255
         $max = 100;
5256
-        $pieces = 5 ;
5256
+        $pieces = 5;
5257 5257
         $part = round($max / $pieces);
5258 5258
         $x_axis = array();
5259 5259
         $final_array = array();
5260 5260
         $my_final_array = array();
5261 5261
 
5262
-        for ($i=1; $i <=$pieces; $i++) {
5262
+        for ($i = 1; $i <= $pieces; $i++) {
5263 5263
             $sum = 1;
5264 5264
             if ($i == 1) {
5265 5265
                 $sum = 0;
5266 5266
             }
5267
-            $min = ($i-1)*$part + $sum;
5268
-            $max = ($i)*$part;
5269
-            $x_axis[]= $min." - ".$max;
5267
+            $min = ($i - 1) * $part + $sum;
5268
+            $max = ($i) * $part;
5269
+            $x_axis[] = $min." - ".$max;
5270 5270
             $count = 0;
5271
-            foreach($exercise_result as $result) {
5272
-                $percentage = $result*100;
5271
+            foreach ($exercise_result as $result) {
5272
+                $percentage = $result * 100;
5273 5273
                 if ($percentage >= $min && $percentage <= $max) {
5274 5274
                     $count++;
5275 5275
                 }
5276 5276
             }
5277
-            $final_array[]= $count;
5277
+            $final_array[] = $count;
5278 5278
 
5279 5279
             if ($my_exercise_result >= $min && $my_exercise_result <= $max) {
5280 5280
                 $my_final_array[] = 1;
@@ -5285,9 +5285,9 @@  discard block
 block discarded – undo
5285 5285
 
5286 5286
         //Fix to remove the data of the user with my data
5287 5287
 
5288
-        for($i = 0; $i<=count($my_final_array); $i++) {
5288
+        for ($i = 0; $i <= count($my_final_array); $i++) {
5289 5289
             if (!empty($my_final_array[$i])) {
5290
-                $my_final_array[$i] =  $final_array[$i] + 1; //Add my result
5290
+                $my_final_array[$i] = $final_array[$i] + 1; //Add my result
5291 5291
                 $final_array[$i] = 0;
5292 5292
             }
5293 5293
         }
@@ -5305,7 +5305,7 @@  discard block
 block discarded – undo
5305 5305
         $dataSet->setXAxisName(get_lang('Score'));
5306 5306
         $dataSet->normalize(100, "%");
5307 5307
 
5308
-        $dataSet->loadPalette(api_get_path(SYS_CODE_PATH) . 'palettes/pchart/default.color', true);
5308
+        $dataSet->loadPalette(api_get_path(SYS_CODE_PATH).'palettes/pchart/default.color', true);
5309 5309
 
5310 5310
         // Cache definition
5311 5311
         $cachePath = api_get_path(SYS_ARCHIVE_PATH);
@@ -5313,9 +5313,9 @@  discard block
 block discarded – undo
5313 5313
         $chartHash = $myCache->getHash($dataSet);
5314 5314
 
5315 5315
         if ($myCache->isInCache($chartHash)) {
5316
-            $imgPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash;
5316
+            $imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
5317 5317
             $myCache->saveFromCache($chartHash, $imgPath);
5318
-            $imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash;
5318
+            $imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
5319 5319
         } else {
5320 5320
             /* Create the pChart object */
5321 5321
             $widthSize = 480;
@@ -5331,7 +5331,7 @@  discard block
 block discarded – undo
5331 5331
             $myPicture->drawRectangle(0, 0, $widthSize - 1, $heightSize - 1, array('R' => 0, 'G' => 0, 'B' => 0));
5332 5332
 
5333 5333
             /* Set the default font */
5334
-            $myPicture->setFontProperties(array('FontName' => api_get_path(SYS_FONTS_PATH) . 'opensans/OpenSans-Regular.ttf', 'FontSize' => 10));
5334
+            $myPicture->setFontProperties(array('FontName' => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf', 'FontSize' => 10));
5335 5335
 
5336 5336
             /* Write the chart title */
5337 5337
             $myPicture->drawText(
@@ -5390,9 +5390,9 @@  discard block
 block discarded – undo
5390 5390
 
5391 5391
             /* Write and save into cache */
5392 5392
             $myCache->writeToCache($chartHash, $myPicture);
5393
-            $imgPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash;
5393
+            $imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
5394 5394
             $myCache->saveFromCache($chartHash, $imgPath);
5395
-            $imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash;
5395
+            $imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
5396 5396
         }
5397 5397
 
5398 5398
         return $imgPath;
@@ -5518,7 +5518,7 @@  discard block
 block discarded – undo
5518 5518
                         $whereSessionParams .= $sessionIdx.',';
5519 5519
                     }
5520 5520
                 }
5521
-                $whereSessionParams = substr($whereSessionParams,0,-1);
5521
+                $whereSessionParams = substr($whereSessionParams, 0, -1);
5522 5522
             }
5523 5523
 
5524 5524
             if (!empty($exerciseId)) {
@@ -5579,7 +5579,7 @@  discard block
 block discarded – undo
5579 5579
                     qq.position = rq.question_order AND
5580 5580
                     ta.question_id = rq.question_id
5581 5581
                 WHERE
5582
-                    te.c_id = $courseIdx ".(empty($whereSessionParams)?'':"AND te.session_id IN ($whereSessionParams)")."
5582
+                    te.c_id = $courseIdx ".(empty($whereSessionParams) ? '' : "AND te.session_id IN ($whereSessionParams)")."
5583 5583
                     AND q.c_id = $courseIdx
5584 5584
                     $where $order $limit";
5585 5585
             $sql_query = vsprintf($sql, $whereParams);
@@ -5627,7 +5627,7 @@  discard block
 block discarded – undo
5627 5627
             // Now fill users data
5628 5628
             $sqlUsers = "SELECT user_id, username, lastname, firstname
5629 5629
                          FROM $tuser
5630
-                         WHERE user_id IN (".implode(',',$userIds).")";
5630
+                         WHERE user_id IN (".implode(',', $userIds).")";
5631 5631
             $resUsers = Database::query($sqlUsers);
5632 5632
             while ($rowUser = Database::fetch_assoc($resUsers)) {
5633 5633
                 $users[$rowUser['user_id']] = $rowUser;
@@ -5688,7 +5688,7 @@  discard block
 block discarded – undo
5688 5688
     	        WHERE
5689 5689
                     track_resource.c_id = $course_id AND
5690 5690
                     track_resource.insert_user_id = user.user_id AND
5691
-                    session_id " .(empty($session_id) ? ' IS NULL ' : " = $session_id ");
5691
+                    session_id ".(empty($session_id) ? ' IS NULL ' : " = $session_id ");
5692 5692
 
5693 5693
     	if (isset($_GET['keyword'])) {
5694 5694
     		$keyword = Database::escape_string(trim($_GET['keyword']));
@@ -5746,7 +5746,7 @@  discard block
 block discarded – undo
5746 5746
                 WHERE
5747 5747
                   track_resource.c_id = $course_id AND
5748 5748
                   track_resource.insert_user_id = user.user_id AND
5749
-                  session_id " .(empty($session_id) ? ' IS NULL ' : " = $session_id ");
5749
+                  session_id ".(empty($session_id) ? ' IS NULL ' : " = $session_id ");
5750 5750
 
5751 5751
     	if (isset($_GET['keyword'])) {
5752 5752
     		$keyword = Database::escape_string(trim($_GET['keyword']));
@@ -6040,7 +6040,7 @@  discard block
 block discarded – undo
6040 6040
     public static function display_additional_profile_fields()
6041 6041
     {
6042 6042
     	// getting all the extra profile fields that are defined by the platform administrator
6043
-    	$extra_fields = UserManager :: get_extra_fields(0,50,5,'ASC');
6043
+    	$extra_fields = UserManager :: get_extra_fields(0, 50, 5, 'ASC');
6044 6044
 
6045 6045
     	// creating the form
6046 6046
     	$return = '<form action="courseLog.php" method="get" name="additional_profile_field_form" id="additional_profile_field_form">';
@@ -6052,8 +6052,8 @@  discard block
 block discarded – undo
6052 6052
     	$extra_fields_to_show = 0;
6053 6053
     	foreach ($extra_fields as $key=>$field) {
6054 6054
     		// show only extra fields that are visible + and can be filtered, added by J.Montoya
6055
-    		if ($field[6]==1 && $field[8] == 1) {
6056
-    			if (isset($_GET['additional_profile_field']) && $field[0] == $_GET['additional_profile_field'] ) {
6055
+    		if ($field[6] == 1 && $field[8] == 1) {
6056
+    			if (isset($_GET['additional_profile_field']) && $field[0] == $_GET['additional_profile_field']) {
6057 6057
     				$selected = 'selected="selected"';
6058 6058
     			} else {
6059 6059
     				$selected = '';
@@ -6065,8 +6065,8 @@  discard block
 block discarded – undo
6065 6065
     	$return .= '</select>';
6066 6066
 
6067 6067
     	// the form elements for the $_GET parameters (because the form is passed through GET
6068
-    	foreach ($_GET as $key=>$value){
6069
-    		if ($key <> 'additional_profile_field')    {
6068
+    	foreach ($_GET as $key=>$value) {
6069
+    		if ($key <> 'additional_profile_field') {
6070 6070
     			$return .= '<input type="hidden" name="'.Security::remove_XSS($key).'" value="'.Security::remove_XSS($value).'" />';
6071 6071
     		}
6072 6072
     	}
@@ -6103,21 +6103,21 @@  discard block
 block discarded – undo
6103 6103
     	$result_extra_field = UserManager::get_extra_field_information($field_id);
6104 6104
 
6105 6105
     	if (!empty($users)) {
6106
-    		if ($result_extra_field['field_type'] == UserManager::USER_FIELD_TYPE_TAG ) {
6107
-    			foreach($users as $user_id) {
6106
+    		if ($result_extra_field['field_type'] == UserManager::USER_FIELD_TYPE_TAG) {
6107
+    			foreach ($users as $user_id) {
6108 6108
     				$user_result = UserManager::get_user_tags($user_id, $field_id);
6109 6109
     				$tag_list = array();
6110
-    				foreach($user_result as $item) {
6110
+    				foreach ($user_result as $item) {
6111 6111
     					$tag_list[] = $item['tag'];
6112 6112
     				}
6113
-    				$return[$user_id][] = implode(', ',$tag_list);
6113
+    				$return[$user_id][] = implode(', ', $tag_list);
6114 6114
     			}
6115 6115
     		} else {
6116 6116
     			$new_user_array = array();
6117 6117
     			foreach ($users as $user_id) {
6118
-    				$new_user_array[]= "'".$user_id."'";
6118
+    				$new_user_array[] = "'".$user_id."'";
6119 6119
     			}
6120
-    			$users = implode(',',$new_user_array);
6120
+    			$users = implode(',', $new_user_array);
6121 6121
                 $extraFieldType = EntityExtraField::USER_FIELD_TYPE;
6122 6122
     			// Selecting only the necessary information NOT ALL the user list
6123 6123
     			$sql = "SELECT user.user_id, v.value
@@ -6132,7 +6132,7 @@  discard block
 block discarded – undo
6132 6132
                             user.user_id IN ($users)";
6133 6133
 
6134 6134
     			$result = Database::query($sql);
6135
-    			while($row = Database::fetch_array($result)) {
6135
+    			while ($row = Database::fetch_array($result)) {
6136 6136
     				// get option value for field type double select by id
6137 6137
     				if (!empty($row['value'])) {
6138 6138
     					if ($result_extra_field['field_type'] ==
@@ -6171,7 +6171,7 @@  discard block
 block discarded – undo
6171 6171
 
6172 6172
     public function sort_users_desc($a, $b)
6173 6173
     {
6174
-    	return strcmp( trim(api_strtolower($b[$_SESSION['tracking_column']])), trim(api_strtolower($a[$_SESSION['tracking_column']])));
6174
+    	return strcmp(trim(api_strtolower($b[$_SESSION['tracking_column']])), trim(api_strtolower($a[$_SESSION['tracking_column']])));
6175 6175
     }
6176 6176
 
6177 6177
     /**
@@ -6206,7 +6206,7 @@  discard block
 block discarded – undo
6206 6206
     	// get all users data from a course for sortable with limit
6207 6207
     	if (is_array($user_ids)) {
6208 6208
     		$user_ids = array_map('intval', $user_ids);
6209
-    		$condition_user = " WHERE user.user_id IN (".implode(',',$user_ids).") ";
6209
+    		$condition_user = " WHERE user.user_id IN (".implode(',', $user_ids).") ";
6210 6210
     	} else {
6211 6211
     		$user_ids = intval($user_ids);
6212 6212
     		$condition_user = " WHERE user.user_id = $user_ids ";
@@ -6214,7 +6214,7 @@  discard block
 block discarded – undo
6214 6214
 
6215 6215
     	if (!empty($_GET['user_keyword'])) {
6216 6216
     		$keyword = trim(Database::escape_string($_GET['user_keyword']));
6217
-    		$condition_user .=  " AND (
6217
+    		$condition_user .= " AND (
6218 6218
                 user.firstname LIKE '%".$keyword."%' OR
6219 6219
                 user.lastname LIKE '%".$keyword."%'  OR
6220 6220
                 user.username LIKE '%".$keyword."%'  OR
@@ -6232,7 +6232,7 @@  discard block
 block discarded – undo
6232 6232
         $invitedUsersCondition = '';
6233 6233
 
6234 6234
         if (!$includeInvitedUsers) {
6235
-            $invitedUsersCondition = " AND user.status != " . INVITEE;
6235
+            $invitedUsersCondition = " AND user.status != ".INVITEE;
6236 6236
         }
6237 6237
 
6238 6238
     	$sql = "SELECT  user.user_id as user_id,
@@ -6243,7 +6243,7 @@  discard block
 block discarded – undo
6243 6243
                 FROM $tbl_user as user $url_table
6244 6244
     	        $condition_user $url_condition $invitedUsersCondition";
6245 6245
 
6246
-    	if (!in_array($direction, array('ASC','DESC'))) {
6246
+    	if (!in_array($direction, array('ASC', 'DESC'))) {
6247 6247
     		$direction = 'ASC';
6248 6248
     	}
6249 6249
 
@@ -6380,7 +6380,7 @@  discard block
 block discarded – undo
6380 6380
     		}
6381 6381
 
6382 6382
             if (empty($session_id)) {
6383
-                $user['survey'] = (isset($survey_user_list[$user['user_id']]) ? $survey_user_list[$user['user_id']] : 0) .' / '.$total_surveys;
6383
+                $user['survey'] = (isset($survey_user_list[$user['user_id']]) ? $survey_user_list[$user['user_id']] : 0).' / '.$total_surveys;
6384 6384
             }
6385 6385
 
6386 6386
     		$user['link'] = '<center><a href="../mySpace/myStudents.php?student='.$user['user_id'].'&details=true&course='.$course_code.'&origin=tracking_course&id_session='.$session_id.'"><img src="'.api_get_path(WEB_IMG_PATH).'icons/22/2rightarrow.png" border="0" /></a></center>';
@@ -6390,35 +6390,35 @@  discard block
 block discarded – undo
6390 6390
     		$is_western_name_order = api_is_western_name_order();
6391 6391
             $user_row = array();
6392 6392
 
6393
-            $user_row[]= $user['official_code']; //0
6393
+            $user_row[] = $user['official_code']; //0
6394 6394
 
6395 6395
             if ($is_western_name_order) {
6396
-                $user_row[]= $user['firstname'];
6397
-                $user_row[]= $user['lastname'];
6396
+                $user_row[] = $user['firstname'];
6397
+                $user_row[] = $user['lastname'];
6398 6398
             } else {
6399
-                $user_row[]= $user['lastname'];
6400
-                $user_row[]= $user['firstname'];
6399
+                $user_row[] = $user['lastname'];
6400
+                $user_row[] = $user['firstname'];
6401 6401
             }
6402
-            $user_row[]= $user['username'];
6403
-            $user_row[]= $user['time'];
6404
-            $user_row[]= $user['average_progress'];
6405
-            $user_row[]= $user['exercise_progress'];
6406
-            $user_row[]= $user['exercise_average_best_attempt'];
6407
-            $user_row[]= $user['student_score'];
6408
-            $user_row[]= $user['count_assignments'];
6409
-            $user_row[]= $user['count_messages'];
6402
+            $user_row[] = $user['username'];
6403
+            $user_row[] = $user['time'];
6404
+            $user_row[] = $user['average_progress'];
6405
+            $user_row[] = $user['exercise_progress'];
6406
+            $user_row[] = $user['exercise_average_best_attempt'];
6407
+            $user_row[] = $user['student_score'];
6408
+            $user_row[] = $user['count_assignments'];
6409
+            $user_row[] = $user['count_messages'];
6410 6410
 
6411 6411
             if (empty($session_id)) {
6412
-                $user_row[]= $user['survey'];
6412
+                $user_row[] = $user['survey'];
6413 6413
             }
6414 6414
 
6415
-            $user_row[]= $user['first_connection'];
6416
-            $user_row[]= $user['last_connection'];
6415
+            $user_row[] = $user['first_connection'];
6416
+            $user_row[] = $user['last_connection'];
6417 6417
             if (isset($_GET['additional_profile_field']) && is_numeric($_GET['additional_profile_field'])) {
6418
-                $user_row[]= $user['additional'];
6418
+                $user_row[] = $user['additional'];
6419 6419
             }
6420 6420
 
6421
-            $user_row[]= $user['link'];
6421
+            $user_row[] = $user['link'];
6422 6422
 
6423 6423
             $users[] = $user_row;
6424 6424
 
@@ -6463,8 +6463,8 @@  discard block
 block discarded – undo
6463 6463
 
6464 6464
     	$track_access_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
6465 6465
     	$tempView = $view;
6466
-    	if(substr($view,0,1) == '1') {
6467
-    		$new_view = substr_replace($view,'0',0,1);
6466
+    	if (substr($view, 0, 1) == '1') {
6467
+    		$new_view = substr_replace($view, '0', 0, 1);
6468 6468
     		echo "
6469 6469
                 <tr>
6470 6470
                     <td valign='top'>
@@ -6497,9 +6497,9 @@  discard block
 block discarded – undo
6497 6497
                 </tr>";
6498 6498
     		$total = 0;
6499 6499
     		if (is_array($results)) {
6500
-    			for($j = 0 ; $j < count($results) ; $j++) {
6500
+    			for ($j = 0; $j < count($results); $j++) {
6501 6501
     				echo "<tr>";
6502
-    				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>";
6502
+    				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>";
6503 6503
     				echo "<td valign='top' align='right' class='content'>".$results[$j][1]."</td>";
6504 6504
     				echo"</tr>";
6505 6505
     				$total = $total + $results[$j][1];
@@ -6516,7 +6516,7 @@  discard block
 block discarded – undo
6516 6516
     		echo "</table>";
6517 6517
     		echo "</td></tr>";
6518 6518
     	} else {
6519
-    		$new_view = substr_replace($view,'1',0,1);
6519
+    		$new_view = substr_replace($view, '1', 0, 1);
6520 6520
     		echo "
6521 6521
                 <tr>
6522 6522
                     <td valign='top'>
@@ -6539,8 +6539,8 @@  discard block
 block discarded – undo
6539 6539
     {
6540 6540
     	global $TBL_TRACK_HOTPOTATOES, $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $dateTimeFormatLong;
6541 6541
         $courseId = api_get_course_int_id($courseCode);
6542
-    	if(substr($view,1,1) == '1') {
6543
-    		$new_view = substr_replace($view,'0',1,1);
6542
+    	if (substr($view, 1, 1) == '1') {
6543
+    		$new_view = substr_replace($view, '0', 1, 1);
6544 6544
     		echo "<tr>
6545 6545
                     <td valign='top'>
6546 6546
                         <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>]
@@ -6582,7 +6582,7 @@  discard block
 block discarded – undo
6582 6582
                 </tr>";
6583 6583
 
6584 6584
     		if (is_array($results)) {
6585
-    			for($i = 0; $i < sizeof($results); $i++) {
6585
+    			for ($i = 0; $i < sizeof($results); $i++) {
6586 6586
     				$display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get());
6587 6587
     				echo "<tr>\n";
6588 6588
     				echo "<td class='content'>".$results[$i][0]."</td>\n";
@@ -6597,8 +6597,8 @@  discard block
 block discarded – undo
6597 6597
 
6598 6598
     		// The Result of Tests
6599 6599
     		if (is_array($hpresults)) {
6600
-    			for($i = 0; $i < sizeof($hpresults); $i++) {
6601
-    				$title = GetQuizName($hpresults[$i][0],'');
6600
+    			for ($i = 0; $i < sizeof($hpresults); $i++) {
6601
+    				$title = GetQuizName($hpresults[$i][0], '');
6602 6602
     				if ($title == '')
6603 6603
     				$title = basename($hpresults[$i][0]);
6604 6604
     				$display_date = api_convert_and_format_date($hpresults[$i][3], null, date_default_timezone_get());
@@ -6624,7 +6624,7 @@  discard block
 block discarded – undo
6624 6624
     		echo "</table>";
6625 6625
     		echo "</td>\n</tr>\n";
6626 6626
     	} else {
6627
-    		$new_view = substr_replace($view,'1',1,1);
6627
+    		$new_view = substr_replace($view, '1', 1, 1);
6628 6628
     		echo "
6629 6629
                 <tr>
6630 6630
                     <td valign='top'>
@@ -6643,8 +6643,8 @@  discard block
 block discarded – undo
6643 6643
     	global $TABLETRACK_UPLOADS, $TABLECOURSE_WORK;
6644 6644
         $_course = api_get_course_info_by_id($course_id);
6645 6645
 
6646
-    	if (substr($view,2,1) == '1') {
6647
-    		$new_view = substr_replace($view,'0',2,1);
6646
+    	if (substr($view, 2, 1) == '1') {
6647
+    		$new_view = substr_replace($view, '0', 2, 1);
6648 6648
     		echo "<tr>
6649 6649
                     <td valign='top'>
6650 6650
                     <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>]
@@ -6658,7 +6658,7 @@  discard block
 block discarded – undo
6658 6658
                         AND u.c_id = '".intval($course_id)."'
6659 6659
                     ORDER BY u.upload_date DESC";
6660 6660
     		echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6661
-    		$results = StatsUtils::getManyResultsXCol($sql,4);
6661
+    		$results = StatsUtils::getManyResultsXCol($sql, 4);
6662 6662
     		echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
6663 6663
     		echo "<tr>
6664 6664
                     <td class='secLine' width='40%'>
@@ -6672,7 +6672,7 @@  discard block
 block discarded – undo
6672 6672
                     </td>
6673 6673
                 </tr>";
6674 6674
     		if (is_array($results)) {
6675
-    			for($j = 0 ; $j < count($results) ; $j++) {
6675
+    			for ($j = 0; $j < count($results); $j++) {
6676 6676
     				$pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3];
6677 6677
     				$beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get());
6678 6678
     				echo "<tr>";
@@ -6691,7 +6691,7 @@  discard block
 block discarded – undo
6691 6691
     		echo "</table>";
6692 6692
     		echo "</td></tr>";
6693 6693
     	} else {
6694
-    		$new_view = substr_replace($view,'1',2,1);
6694
+    		$new_view = substr_replace($view, '1', 2, 1);
6695 6695
     		echo "
6696 6696
                 <tr>
6697 6697
                     <td valign='top'>
@@ -6710,8 +6710,8 @@  discard block
 block discarded – undo
6710 6710
     {
6711 6711
     	global $TABLETRACK_LINKS, $TABLECOURSE_LINKS;
6712 6712
         $courseId = api_get_course_int_id($courseCode);
6713
-    	if (substr($view,3,1) == '1') {
6714
-    		$new_view = substr_replace($view,'0',3,1);
6713
+    	if (substr($view, 3, 1) == '1') {
6714
+    		$new_view = substr_replace($view, '0', 3, 1);
6715 6715
     		echo "
6716 6716
                 <tr>
6717 6717
                         <td valign='top'>
@@ -6735,7 +6735,7 @@  discard block
 block discarded – undo
6735 6735
                     </td>
6736 6736
                 </tr>";
6737 6737
     		if (is_array($results)) {
6738
-    			for($j = 0 ; $j < count($results) ; $j++) {
6738
+    			for ($j = 0; $j < count($results); $j++) {
6739 6739
     				echo "<tr>";
6740 6740
     				echo "<td class='content'><a href='".$results[$j][1]."'>".$results[$j][0]."</a></td>";
6741 6741
     				echo"</tr>";
@@ -6748,7 +6748,7 @@  discard block
 block discarded – undo
6748 6748
     		echo "</table>";
6749 6749
     		echo "</td></tr>";
6750 6750
     	} else {
6751
-    		$new_view = substr_replace($view,'1',3,1);
6751
+    		$new_view = substr_replace($view, '1', 3, 1);
6752 6752
     		echo "
6753 6753
                 <tr>
6754 6754
                     <td valign='top'>
@@ -6775,8 +6775,8 @@  discard block
 block discarded – undo
6775 6775
     	$session_id = intval($session_id);
6776 6776
 
6777 6777
     	$downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
6778
-    	if(substr($view,4,1) == '1') {
6779
-    		$new_view = substr_replace($view,'0',4,1);
6778
+    	if (substr($view, 4, 1) == '1') {
6779
+    		$new_view = substr_replace($view, '0', 4, 1);
6780 6780
     		echo "
6781 6781
                 <tr>
6782 6782
                     <td valign='top'>
@@ -6802,7 +6802,7 @@  discard block
 block discarded – undo
6802 6802
                     </td>
6803 6803
                 </tr>";
6804 6804
     		if (is_array($results)) {
6805
-    			for($j = 0 ; $j < count($results) ; $j++) {
6805
+    			for ($j = 0; $j < count($results); $j++) {
6806 6806
     				echo "<tr>";
6807 6807
     				echo "<td class='content'>".$results[$j]."</td>";
6808 6808
     				echo"</tr>";
@@ -6815,7 +6815,7 @@  discard block
 block discarded – undo
6815 6815
     		echo "</table>";
6816 6816
     		echo "</td></tr>";
6817 6817
     	} else {
6818
-    		$new_view = substr_replace($view,'1',4,1);
6818
+    		$new_view = substr_replace($view, '1', 4, 1);
6819 6819
     		echo "
6820 6820
                 <tr>
6821 6821
                     <td valign='top'>
@@ -6849,11 +6849,11 @@  discard block
 block discarded – undo
6849 6849
                    ORDER BY login_date DESC LIMIT 1";
6850 6850
         $ip = '';
6851 6851
         $res_ip = Database::query($sql_ip);
6852
-        if ($res_ip !== false && Database::num_rows($res_ip)>0) {
6852
+        if ($res_ip !== false && Database::num_rows($res_ip) > 0) {
6853 6853
             $row_ip = Database::fetch_row($res_ip);
6854 6854
             if ($return_as_link) {
6855 6855
                 $ip = Display::url(
6856
-                    (empty($body_replace)?$row_ip[1]:$body_replace), 'http://www.whatsmyip.org/ip-geo-location/?ip='.$row_ip[1],
6856
+                    (empty($body_replace) ? $row_ip[1] : $body_replace), 'http://www.whatsmyip.org/ip-geo-location/?ip='.$row_ip[1],
6857 6857
                     array('title'=>get_lang('TraceIP'), 'target'=>'_blank')
6858 6858
                 );
6859 6859
             } else {
@@ -6889,9 +6889,9 @@  discard block
 block discarded – undo
6889 6889
     	$course_id  = intval($course_id);
6890 6890
 
6891 6891
     	$tempView = $view;
6892
-    	if (substr($view,0,1) == '1') {
6893
-    		$new_view = substr_replace($view,'0',0,1);
6894
-    		$title[1]= get_lang('LoginsAndAccessTools').get_lang('LoginsDetails');
6892
+    	if (substr($view, 0, 1) == '1') {
6893
+    		$new_view = substr_replace($view, '0', 0, 1);
6894
+    		$title[1] = get_lang('LoginsAndAccessTools').get_lang('LoginsDetails');
6895 6895
     		$sql = "SELECT UNIX_TIMESTAMP(access_date), count(access_date)
6896 6896
                     FROM $track_access_table
6897 6897
                     WHERE access_user_id = $user_id
@@ -6901,20 +6901,20 @@  discard block
 block discarded – undo
6901 6901
                     ORDER BY YEAR(access_date),MONTH(access_date) ASC";
6902 6902
     		//$results = getManyResults2Col($sql);
6903 6903
     		$results = getManyResults3Col($sql);
6904
-    		$title_line= get_lang('LoginsTitleMonthColumn').';'.get_lang('LoginsTitleCountColumn')."\n";
6905
-    		$line='';
6904
+    		$title_line = get_lang('LoginsTitleMonthColumn').';'.get_lang('LoginsTitleCountColumn')."\n";
6905
+    		$line = '';
6906 6906
     		$total = 0;
6907 6907
     		if (is_array($results)) {
6908
-    			for($j = 0 ; $j < count($results) ; $j++) {
6908
+    			for ($j = 0; $j < count($results); $j++) {
6909 6909
     				$line .= $results[$j][0].';'.$results[$j][1]."\n";
6910 6910
     				$total = $total + $results[$j][1];
6911 6911
     			}
6912 6912
     			$line .= get_lang('Total').";".$total."\n";
6913 6913
     		} else {
6914
-    			$line= get_lang('NoResult')."</center></td>";
6914
+    			$line = get_lang('NoResult')."</center></td>";
6915 6915
     		}
6916 6916
     	} else {
6917
-    		$new_view = substr_replace($view,'1',0,1);
6917
+    		$new_view = substr_replace($view, '1', 0, 1);
6918 6918
     	}
6919 6919
     	return array($title_line, $line);
6920 6920
     }
@@ -6932,8 +6932,8 @@  discard block
 block discarded – undo
6932 6932
     	global $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $TABLETRACK_HOTPOTATOES, $dateTimeFormatLong;
6933 6933
         $courseId = api_get_course_int_id($courseCode);
6934 6934
         $userId = intval($userId);
6935
-    	if (substr($view,1,1) == '1') {
6936
-    		$new_view = substr_replace($view,'0',1,1);
6935
+    	if (substr($view, 1, 1) == '1') {
6936
+    		$new_view = substr_replace($view, '0', 1, 1);
6937 6937
     		$title[1] = get_lang('ExercicesDetails');
6938 6938
     		$line = '';
6939 6939
     		$sql = "SELECT ce.title, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
@@ -6957,7 +6957,7 @@  discard block
 block discarded – undo
6957 6957
     		$title_line = get_lang('ExercicesTitleExerciceColumn').";".get_lang('Date').';'.get_lang('ExercicesTitleScoreColumn')."\n";
6958 6958
 
6959 6959
     		if (is_array($results)) {
6960
-    			for($i = 0; $i < sizeof($results); $i++)
6960
+    			for ($i = 0; $i < sizeof($results); $i++)
6961 6961
     			{
6962 6962
     				$display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get());
6963 6963
     				$line .= $results[$i][0].";".$display_date.";".$results[$i][1]." / ".$results[$i][2]."\n";
@@ -6969,8 +6969,8 @@  discard block
 block discarded – undo
6969 6969
 
6970 6970
     		// The Result of Tests
6971 6971
     		if (is_array($hpresults)) {
6972
-    			for($i = 0; $i < sizeof($hpresults); $i++) {
6973
-    				$title = GetQuizName($hpresults[$i][0],'');
6972
+    			for ($i = 0; $i < sizeof($hpresults); $i++) {
6973
+    				$title = GetQuizName($hpresults[$i][0], '');
6974 6974
 
6975 6975
     				if ($title == '')
6976 6976
     				$title = basename($hpresults[$i][0]);
@@ -6984,10 +6984,10 @@  discard block
 block discarded – undo
6984 6984
     		}
6985 6985
 
6986 6986
     		if ($NoTestRes == 1 && $NoHPTestRes == 1) {
6987
-    			$line=get_lang('NoResult');
6987
+    			$line = get_lang('NoResult');
6988 6988
     		}
6989 6989
     	} else {
6990
-    		$new_view = substr_replace($view,'1',1,1);
6990
+    		$new_view = substr_replace($view, '1', 1, 1);
6991 6991
     	}
6992 6992
     	return array($title_line, $line);
6993 6993
     }
@@ -7003,7 +7003,7 @@  discard block
 block discarded – undo
7003 7003
         $user_id = intval($user_id);
7004 7004
         $course_id = intval($course_id);
7005 7005
 
7006
-    	if (substr($view,2,1) == '1') {
7006
+    	if (substr($view, 2, 1) == '1') {
7007 7007
     		$sql = "SELECT u.upload_date, w.title, w.author, w.url
7008 7008
                     FROM $TABLETRACK_UPLOADS u , $TABLECOURSE_WORK w
7009 7009
                     WHERE
@@ -7011,21 +7011,21 @@  discard block
 block discarded – undo
7011 7011
                         u.upload_user_id = '$user_id' AND
7012 7012
                         u.c_id = '$course_id'
7013 7013
                     ORDER BY u.upload_date DESC";
7014
-    		$results = StatsUtils::getManyResultsXCol($sql,4);
7014
+    		$results = StatsUtils::getManyResultsXCol($sql, 4);
7015 7015
 
7016
-    		$title[1]=get_lang('WorksDetails');
7017
-    		$line='';
7018
-    		$title_line=get_lang('WorkTitle').";".get_lang('WorkAuthors').";".get_lang('Date')."\n";
7016
+    		$title[1] = get_lang('WorksDetails');
7017
+    		$line = '';
7018
+    		$title_line = get_lang('WorkTitle').";".get_lang('WorkAuthors').";".get_lang('Date')."\n";
7019 7019
 
7020 7020
     		if (is_array($results)) {
7021
-    			for($j = 0 ; $j < count($results) ; $j++) {
7021
+    			for ($j = 0; $j < count($results); $j++) {
7022 7022
     				$pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3];
7023 7023
     				$beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get());
7024 7024
     				$line .= $results[$j][1].";".$results[$j][2].";".$beautifulDate."\n";
7025 7025
     			}
7026 7026
 
7027 7027
     		} else {
7028
-    			$line= get_lang('NoResult');
7028
+    			$line = get_lang('NoResult');
7029 7029
     		}
7030 7030
     	}
7031 7031
     	return array($title_line, $line);
@@ -7041,9 +7041,9 @@  discard block
 block discarded – undo
7041 7041
         $courseId = api_get_course_int_id($courseCode);
7042 7042
         $userId = intval($userId);
7043 7043
         $line = null;
7044
-    	if (substr($view,3,1) == '1') {
7045
-    		$new_view = substr_replace($view,'0',3,1);
7046
-    		$title[1]=get_lang('LinksDetails');
7044
+    	if (substr($view, 3, 1) == '1') {
7045
+    		$new_view = substr_replace($view, '0', 3, 1);
7046
+    		$title[1] = get_lang('LinksDetails');
7047 7047
     		$sql = "SELECT cl.title, cl.url
7048 7048
                         FROM $TABLETRACK_LINKS AS sl, $TABLECOURSE_LINKS AS cl
7049 7049
                         WHERE sl.links_link_id = cl.id
@@ -7051,16 +7051,16 @@  discard block
 block discarded – undo
7051 7051
                             AND sl.links_user_id = $userId
7052 7052
                         GROUP BY cl.title, cl.url";
7053 7053
     		$results = StatsUtils::getManyResults2Col($sql);
7054
-    		$title_line= get_lang('LinksTitleLinkColumn')."\n";
7054
+    		$title_line = get_lang('LinksTitleLinkColumn')."\n";
7055 7055
     		if (is_array($results)) {
7056
-    			for ($j = 0 ; $j < count($results) ; $j++) {
7056
+    			for ($j = 0; $j < count($results); $j++) {
7057 7057
     				$line .= $results[$j][0]."\n";
7058 7058
     			}
7059 7059
     		} else {
7060
-    			$line=get_lang('NoResult');
7060
+    			$line = get_lang('NoResult');
7061 7061
     		}
7062 7062
     	} else {
7063
-    		$new_view = substr_replace($view,'1',3,1);
7063
+    		$new_view = substr_replace($view, '1', 3, 1);
7064 7064
     	}
7065 7065
     	return array($title_line, $line);
7066 7066
     }
@@ -7082,9 +7082,9 @@  discard block
 block discarded – undo
7082 7082
 
7083 7083
     	$downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
7084 7084
 
7085
-    	if (substr($view,4,1) == '1') {
7086
-    		$new_view = substr_replace($view,'0',4,1);
7087
-    		$title[1]= get_lang('DocumentsDetails');
7085
+    	if (substr($view, 4, 1) == '1') {
7086
+    		$new_view = substr_replace($view, '0', 4, 1);
7087
+    		$title[1] = get_lang('DocumentsDetails');
7088 7088
 
7089 7089
     		$sql = "SELECT down_doc_path
7090 7090
                         FROM $downloads_table
@@ -7097,14 +7097,14 @@  discard block
 block discarded – undo
7097 7097
     		$title_line = get_lang('DocumentsTitleDocumentColumn')."\n";
7098 7098
             $line = null;
7099 7099
     		if (is_array($results)) {
7100
-    			for ($j = 0 ; $j < count($results) ; $j++) {
7100
+    			for ($j = 0; $j < count($results); $j++) {
7101 7101
     				$line .= $results[$j]."\n";
7102 7102
     			}
7103 7103
     		} else {
7104 7104
     			$line = get_lang('NoResult');
7105 7105
     		}
7106 7106
     	} else {
7107
-    		$new_view = substr_replace($view,'1',4,1);
7107
+    		$new_view = substr_replace($view, '1', 4, 1);
7108 7108
     	}
7109 7109
     	return array($title_line, $line);
7110 7110
     }
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.
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.
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
     public static function add($url, $description, $active)
24 24
     {
25 25
         $tms = time();
26
-        $table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
26
+        $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
27 27
         $sql = "INSERT INTO $table
28 28
                 SET url 	= '".Database::escape_string($url)."',
29 29
                 description = '".Database::escape_string($description)."',
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
     {
74 74
         $id = intval($id);
75 75
         $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
76
-        $sql= "DELETE FROM $table WHERE id = ".$id;
76
+        $sql = "DELETE FROM $table WHERE id = ".$id;
77 77
         $result = Database::query($sql);
78 78
 
79 79
         return $result;
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
      */
87 87
     public static function url_exist($url)
88 88
     {
89
-        $table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
89
+        $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
90 90
         $sql = "SELECT id FROM $table
91 91
                 WHERE url = '".Database::escape_string($url)."' ";
92 92
         $res = Database::query($sql);
@@ -120,10 +120,10 @@  discard block
 block discarded – undo
120 120
      * */
121 121
     public static function url_count()
122 122
     {
123
-        $table_access_url= Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
123
+        $table_access_url = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
124 124
         $sql = "SELECT count(id) as count_result FROM $table_access_url";
125 125
         $res = Database::query($sql);
126
-        $url = Database::fetch_array($res,'ASSOC');
126
+        $url = Database::fetch_array($res, 'ASSOC');
127 127
         $result = $url['count_result'];
128 128
 
129 129
         return $result;
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
                 FROM $table
142 142
                 ORDER BY id";
143 143
         $res = Database::query($sql);
144
-        $urls = array ();
144
+        $urls = array();
145 145
         while ($url = Database::fetch_array($res)) {
146 146
             $urls[] = $url;
147 147
         }
@@ -258,12 +258,12 @@  discard block
 block discarded – undo
258 258
      **/
259 259
     public static function get_url_rel_session_data($access_url_id = null)
260 260
     {
261
-        $where ='';
261
+        $where = '';
262 262
         $table_url_rel_session = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
263 263
         $tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION);
264 264
 
265 265
         if (!empty($access_url_id))
266
-            $where ="WHERE $table_url_rel_session.access_url_id = ".intval($access_url_id);
266
+            $where = "WHERE $table_url_rel_session.access_url_id = ".intval($access_url_id);
267 267
 
268 268
         $sql = "SELECT id, name, access_url_id
269 269
                 FROM $tbl_session u
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
         $table_user_group = Database::get_main_table(TABLE_USERGROUP);
294 294
 
295 295
         if (!empty($access_url_id)) {
296
-            $where ="WHERE $table_url_rel_usergroup.access_url_id = ".intval($access_url_id);
296
+            $where = "WHERE $table_url_rel_usergroup.access_url_id = ".intval($access_url_id);
297 297
         }
298 298
 
299 299
         $sql = "SELECT id, name, access_url_id
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
     public static function relation_url_user_exist($user_id, $url_id)
372 372
     {
373 373
         $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
374
-        $sql= "SELECT user_id FROM $table
374
+        $sql = "SELECT user_id FROM $table
375 375
                WHERE access_url_id = ".intval($url_id)." AND user_id = ".intval($user_id)." ";
376 376
         $result = Database::query($sql);
377 377
         $num = Database::num_rows($result);
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
     public static function relation_url_course_exist($courseId, $urlId)
390 390
     {
391 391
         $table_url_rel_course = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
392
-        $sql= "SELECT c_id FROM $table_url_rel_course
392
+        $sql = "SELECT c_id FROM $table_url_rel_course
393 393
                WHERE
394 394
                     access_url_id = ".intval($urlId)." AND
395 395
                     c_id = '".intval($courseId)."'";
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
     public static function relationUrlUsergroupExist($userGroupId, $urlId)
411 411
     {
412 412
         $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USERGROUP);
413
-        $sql= "SELECT usergroup_id FROM $table
413
+        $sql = "SELECT usergroup_id FROM $table
414 414
                WHERE access_url_id = ".intval($urlId)." AND
415 415
                      usergroup_id = ".intval($userGroupId);
416 416
         $result = Database::query($sql);
@@ -428,9 +428,9 @@  discard block
 block discarded – undo
428 428
     * */
429 429
     public static function relation_url_session_exist($session_id, $url_id)
430 430
     {
431
-        $table_url_rel_session= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
431
+        $table_url_rel_session = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
432 432
         $session_id = intval($session_id);
433
-        $url_id		= intval($url_id);
433
+        $url_id = intval($url_id);
434 434
         $sql = "SELECT session_id FROM $table_url_rel_session
435 435
                 WHERE
436 436
                     access_url_id = ".intval($url_id)." AND
@@ -453,11 +453,11 @@  discard block
 block discarded – undo
453 453
         $table_url_rel_user = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
454 454
         $result_array = array();
455 455
 
456
-        if (is_array($user_list) && is_array($url_list)){
456
+        if (is_array($user_list) && is_array($url_list)) {
457 457
             foreach ($url_list as $url_id) {
458 458
                 foreach ($user_list as $user_id) {
459
-                    $count = UrlManager::relation_url_user_exist($user_id,$url_id);
460
-                    if ($count==0) {
459
+                    $count = UrlManager::relation_url_user_exist($user_id, $url_id);
460
+                    if ($count == 0) {
461 461
                         $sql = "INSERT INTO $table_url_rel_user
462 462
                                 SET user_id = ".intval($user_id).", access_url_id = ".intval($url_id);
463 463
                         $result = Database::query($sql);
@@ -482,19 +482,19 @@  discard block
 block discarded – undo
482 482
      * @param  array of url_ids
483 483
      * @return array
484 484
      **/
485
-    public static function add_courses_to_urls($course_list,$url_list)
485
+    public static function add_courses_to_urls($course_list, $url_list)
486 486
     {
487 487
         $table_url_rel_course = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
488 488
         $result_array = array();
489 489
 
490
-        if (is_array($course_list) && is_array($url_list)){
490
+        if (is_array($course_list) && is_array($url_list)) {
491 491
             foreach ($url_list as $url_id) {
492 492
                 foreach ($course_list as $course_code) {
493 493
                     $courseInfo = api_get_course_info($course_code);
494 494
                     $courseId = $courseInfo['real_id'];
495 495
 
496 496
                     $count = self::relation_url_course_exist($courseId, $url_id);
497
-                    if ($count==0) {
497
+                    if ($count == 0) {
498 498
                         $sql = "INSERT INTO $table_url_rel_course
499 499
                                 SET c_id = '".$courseId."', access_url_id = ".intval($url_id);
500 500
                         $result = Database::query($sql);
@@ -580,7 +580,7 @@  discard block
 block discarded – undo
580 580
     public static function relationUrlCourseCategoryExist($categoryCourseId, $urlId)
581 581
     {
582 582
         $table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE_CATEGORY);
583
-        $sql= "SELECT course_category_id FROM $table
583
+        $sql = "SELECT course_category_id FROM $table
584 584
                WHERE access_url_id = ".intval($urlId)." AND
585 585
                      course_category_id = ".intval($categoryCourseId);
586 586
         $result = Database::query($sql);
@@ -749,7 +749,7 @@  discard block
 block discarded – undo
749 749
         $table_url_rel_user = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
750 750
         $result = true;
751 751
         if (!empty($user_id) && !empty($url_id)) {
752
-            $sql= "DELETE FROM $table_url_rel_user
752
+            $sql = "DELETE FROM $table_url_rel_user
753 753
                    WHERE user_id = ".intval($user_id)." AND access_url_id = ".intval($url_id);
754 754
             $result = Database::query($sql);
755 755
         }
@@ -767,8 +767,8 @@  discard block
 block discarded – undo
767 767
     * */
768 768
     public static function delete_url_rel_course($courseId, $urlId)
769 769
     {
770
-        $table_url_rel_course= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
771
-        $sql= "DELETE FROM $table_url_rel_course
770
+        $table_url_rel_course = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
771
+        $sql = "DELETE FROM $table_url_rel_course
772 772
                WHERE c_id = '".intval($courseId)."' AND access_url_id=".intval($urlId)."  ";
773 773
         $result = Database::query($sql);
774 774
 
@@ -786,7 +786,7 @@  discard block
 block discarded – undo
786 786
     public static function delete_url_rel_usergroup($userGroupId, $urlId)
787 787
     {
788 788
         $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USERGROUP);
789
-        $sql= "DELETE FROM $table
789
+        $sql = "DELETE FROM $table
790 790
                WHERE usergroup_id = '".intval($userGroupId)."' AND
791 791
                      access_url_id=".intval($urlId)."  ";
792 792
         $result = Database::query($sql);
@@ -805,7 +805,7 @@  discard block
 block discarded – undo
805 805
     public static function deleteUrlRelCourseCategory($userGroupId, $urlId)
806 806
     {
807 807
         $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE_CATEGORY);
808
-        $sql= "DELETE FROM $table
808
+        $sql = "DELETE FROM $table
809 809
                WHERE course_category_id = '".intval($userGroupId)."' AND
810 810
                      access_url_id=".intval($urlId)."  ";
811 811
         $result = Database::query($sql);
@@ -824,9 +824,9 @@  discard block
 block discarded – undo
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);
827
-        $sql= "DELETE FROM $table_url_rel_session
827
+        $sql = "DELETE FROM $table_url_rel_session
828 828
                WHERE session_id = ".intval($session_id)." AND access_url_id=".intval($url_id)."  ";
829
-        $result = Database::query($sql,'ASSOC');
829
+        $result = Database::query($sql, 'ASSOC');
830 830
 
831 831
         return $result;
832 832
     }
@@ -839,7 +839,7 @@  discard block
 block discarded – undo
839 839
      * */
840 840
     public static function update_urls_rel_user($user_list, $access_url_id)
841 841
     {
842
-        $table_url_rel_user	= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
842
+        $table_url_rel_user = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
843 843
         $sql = "SELECT user_id FROM $table_url_rel_user WHERE access_url_id = ".intval($access_url_id);
844 844
         $result = Database::query($sql);
845 845
         $existing_users = array();
@@ -893,7 +893,7 @@  discard block
 block discarded – undo
893 893
         $result = Database::query($sql);
894 894
 
895 895
         $existing_courses = array();
896
-        while ($row = Database::fetch_array($result)){
896
+        while ($row = Database::fetch_array($result)) {
897 897
             $existing_courses[] = $row['c_id'];
898 898
         }
899 899
 
@@ -926,7 +926,7 @@  discard block
 block discarded – undo
926 926
         $result = Database::query($sql);
927 927
         $existingItems = array();
928 928
 
929
-        while ($row = Database::fetch_array($result)){
929
+        while ($row = Database::fetch_array($result)) {
930 930
             $existingItems[] = $row['usergroup_id'];
931 931
         }
932 932
 
@@ -959,7 +959,7 @@  discard block
 block discarded – undo
959 959
         $result = Database::query($sql);
960 960
         $existingItems = array();
961 961
 
962
-        while ($row = Database::fetch_array($result)){
962
+        while ($row = Database::fetch_array($result)) {
963 963
             $existingItems[] = $row['course_category_id'];
964 964
         }
965 965
 
@@ -1000,15 +1000,15 @@  discard block
 block discarded – undo
1000 1000
      * @param array user list
1001 1001
      * @param int access_url_id
1002 1002
      * */
1003
-    public static function update_urls_rel_session($session_list,$access_url_id)
1003
+    public static function update_urls_rel_session($session_list, $access_url_id)
1004 1004
     {
1005
-        $table_url_rel_session	= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
1005
+        $table_url_rel_session = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
1006 1006
 
1007 1007
         $sql = "SELECT session_id FROM $table_url_rel_session WHERE access_url_id=".intval($access_url_id);
1008 1008
         $result = Database::query($sql);
1009 1009
         $existing_sessions = array();
1010 1010
 
1011
-        while ($row = Database::fetch_array($result)){
1011
+        while ($row = Database::fetch_array($result)) {
1012 1012
             $existing_sessions[] = $row['session_id'];
1013 1013
         }
1014 1014
 
@@ -1037,13 +1037,13 @@  discard block
 block discarded – undo
1037 1037
      */
1038 1038
     public static function get_access_url_from_user($user_id)
1039 1039
     {
1040
-        $table_url_rel_user	= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
1041
-        $table_url	= Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
1040
+        $table_url_rel_user = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
1041
+        $table_url = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
1042 1042
         $sql = "SELECT url, access_url_id FROM $table_url_rel_user url_rel_user INNER JOIN $table_url u
1043 1043
                 ON (url_rel_user.access_url_id = u.id)
1044 1044
                 WHERE user_id = ".intval($user_id);
1045 1045
         $result = Database::query($sql);
1046
-        $url_list = Database::store_result($result,'ASSOC');
1046
+        $url_list = Database::store_result($result, 'ASSOC');
1047 1047
         return $url_list;
1048 1048
     }
1049 1049
 
@@ -1053,14 +1053,14 @@  discard block
 block discarded – undo
1053 1053
      */
1054 1054
     public static function get_access_url_from_course($courseId)
1055 1055
     {
1056
-        $table	= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
1057
-        $table_url	= Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
1056
+        $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
1057
+        $table_url = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
1058 1058
         $sql = "SELECT url, access_url_id FROM $table c INNER JOIN $table_url u
1059 1059
                 ON (c.access_url_id = u.id)
1060 1060
                 WHERE c_id = ".intval($courseId);
1061 1061
 
1062 1062
         $result = Database::query($sql);
1063
-        $url_list = Database::store_result($result,'ASSOC');
1063
+        $url_list = Database::store_result($result, 'ASSOC');
1064 1064
         return $url_list;
1065 1065
     }
1066 1066
 
@@ -1071,7 +1071,7 @@  discard block
 block discarded – undo
1071 1071
     public static function get_access_url_from_session($session_id)
1072 1072
     {
1073 1073
         $table_url_rel_session = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
1074
-        $table_url  = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
1074
+        $table_url = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
1075 1075
         $sql = "SELECT url, access_url_id FROM $table_url_rel_session url_rel_session INNER JOIN $table_url u
1076 1076
                 ON (url_rel_session.access_url_id = u.id)
1077 1077
                 WHERE session_id = ".intval($session_id);
@@ -1087,7 +1087,7 @@  discard block
 block discarded – undo
1087 1087
      */
1088 1088
     public static function get_url_id($url)
1089 1089
     {
1090
-        $table_access_url= Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
1090
+        $table_access_url = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
1091 1091
         $sql = "SELECT id FROM $table_access_url WHERE url = '".Database::escape_string($url)."'";
1092 1092
         $result = Database::query($sql);
1093 1093
         $access_url_id = Database::result($result, 0, 0);
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.
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.
Spacing   +62 added lines, -62 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
 
@@ -527,13 +527,13 @@  discard block
 block discarded – undo
527 527
                 INNER JOIN {$this->table} g
528 528
                 ON (u.usergroup_id = g.id)
529 529
                 ";
530
-            $where =  array('where' => array('user_id = ? AND access_url_id = ? ' => array($userId, $urlId)));
530
+            $where = array('where' => array('user_id = ? AND access_url_id = ? ' => array($userId, $urlId)));
531 531
         } else {
532 532
             $from = $this->usergroup_rel_user_table." u
533 533
                 INNER JOIN {$this->table} g
534 534
                 ON (u.usergroup_id = g.id)
535 535
                 ";
536
-            $where =  array('where' => array('user_id = ?' => $userId));
536
+            $where = array('where' => array('user_id = ?' => $userId));
537 537
         }
538 538
 
539 539
         $results = Database::select(
@@ -562,10 +562,10 @@  discard block
 block discarded – undo
562 562
             $urlId = api_get_current_access_url_id();
563 563
             $from = $this->usergroup_rel_user_table." u
564 564
                     INNER JOIN {$this->access_url_rel_usergroup} a ON (a.usergroup_id AND u.usergroup_id)";
565
-            $where =  array('where' => array('user_id = ? AND access_url_id = ? ' => array($userId, $urlId)));
565
+            $where = array('where' => array('user_id = ? AND access_url_id = ? ' => array($userId, $urlId)));
566 566
         } else {
567 567
             $from = $this->usergroup_rel_user_table." u ";
568
-            $where =  array('where' => array('user_id = ?' => $userId));
568
+            $where = array('where' => array('user_id = ?' => $userId));
569 569
         }
570 570
 
571 571
         $results = Database::select(
@@ -851,7 +851,7 @@  discard block
 block discarded – undo
851 851
             }
852 852
             $result = $new_result;
853 853
         }
854
-        $columns = array('name', 'users', 'courses','sessions', 'group_type');
854
+        $columns = array('name', 'users', 'courses', 'sessions', 'group_type');
855 855
 
856 856
         if (!in_array($sidx, $columns)) {
857 857
             $sidx = 'name';
@@ -1254,7 +1254,7 @@  discard block
 block discarded – undo
1254 1254
                 }
1255 1255
             }
1256 1256
         }
1257
-        $response->addAssign('ajax_list_courses','innerHTML', api_utf8_encode($return));
1257
+        $response->addAssign('ajax_list_courses', 'innerHTML', api_utf8_encode($return));
1258 1258
 
1259 1259
         return $response;
1260 1260
     }
@@ -1361,7 +1361,7 @@  discard block
 block discarded – undo
1361 1361
      * @param string style css
1362 1362
      * @return array with the file and the style of an image i.e $array['file'] $array['style']
1363 1363
      */
1364
-    public function get_picture_group($id, $picture_file, $height, $size_picture = GROUP_IMAGE_SIZE_MEDIUM , $style = '')
1364
+    public function get_picture_group($id, $picture_file, $height, $size_picture = GROUP_IMAGE_SIZE_MEDIUM, $style = '')
1365 1365
     {
1366 1366
         $picture = array();
1367 1367
         $picture['style'] = $style;
@@ -1474,7 +1474,7 @@  discard block
 block discarded – undo
1474 1474
      */
1475 1475
     public function getAllowedPictureExtensions()
1476 1476
     {
1477
-        return $allowed_picture_types = array ('jpg', 'jpeg', 'png', 'gif');
1477
+        return $allowed_picture_types = array('jpg', 'jpeg', 'png', 'gif');
1478 1478
     }
1479 1479
 
1480 1480
     /**
@@ -1508,7 +1508,7 @@  discard block
 block discarded – undo
1508 1508
         if (empty($user_id)) {
1509 1509
             $user_id = api_get_user_id();
1510 1510
         }
1511
-        $user_role	= $this->get_user_group_role($user_id, $group_id);
1511
+        $user_role = $this->get_user_group_role($user_id, $group_id);
1512 1512
         if (in_array($user_role, array(GROUP_USER_PERMISSION_ADMIN))) {
1513 1513
             return true;
1514 1514
         } else {
@@ -1526,7 +1526,7 @@  discard block
 block discarded – undo
1526 1526
         if (empty($user_id)) {
1527 1527
             $user_id = api_get_user_id();
1528 1528
         }
1529
-        $user_role	= $this->get_user_group_role($user_id, $group_id);
1529
+        $user_role = $this->get_user_group_role($user_id, $group_id);
1530 1530
         if (in_array($user_role, array(GROUP_USER_PERMISSION_ADMIN, GROUP_USER_PERMISSION_MODERATOR))) {
1531 1531
             return true;
1532 1532
         } else {
@@ -1553,7 +1553,7 @@  discard block
 block discarded – undo
1553 1553
             GROUP_USER_PERMISSION_READER,
1554 1554
             GROUP_USER_PERMISSION_HRM,
1555 1555
         );
1556
-        $user_role	= self::get_user_group_role($user_id, $group_id);
1556
+        $user_role = self::get_user_group_role($user_id, $group_id);
1557 1557
         if (in_array($user_role, $roles)) {
1558 1558
             return true;
1559 1559
         } else {
@@ -1570,7 +1570,7 @@  discard block
 block discarded – undo
1570 1570
      * */
1571 1571
     public function get_user_group_role($user_id, $group_id)
1572 1572
     {
1573
-        $table_group_rel_user= $this->usergroup_rel_user_table;
1573
+        $table_group_rel_user = $this->usergroup_rel_user_table;
1574 1574
         $return_value = 0;
1575 1575
         if (!empty($user_id) && !empty($group_id)) {
1576 1576
             $sql = "SELECT relation_type FROM $table_group_rel_user
@@ -1578,8 +1578,8 @@  discard block
 block discarded – undo
1578 1578
                         usergroup_id = ".intval($group_id)." AND
1579 1579
                         user_id = ".intval($user_id)." ";
1580 1580
             $result = Database::query($sql);
1581
-            if (Database::num_rows($result)>0) {
1582
-                $row = Database::fetch_array($result,'ASSOC');
1581
+            if (Database::num_rows($result) > 0) {
1582
+                $row = Database::fetch_array($result, 'ASSOC');
1583 1583
                 $return_value = $row['relation_type'];
1584 1584
             }
1585 1585
         }
@@ -1634,7 +1634,7 @@  discard block
 block discarded – undo
1634 1634
         if (is_array($user_list) && is_array($group_list)) {
1635 1635
             foreach ($group_list as $group_id) {
1636 1636
                 foreach ($user_list as $user_id) {
1637
-                    $role = self::get_user_group_role($user_id,$group_id);
1637
+                    $role = self::get_user_group_role($user_id, $group_id);
1638 1638
                     if ($role == 0) {
1639 1639
                         $sql = "INSERT INTO $table_url_rel_group
1640 1640
 		               			SET
@@ -1665,7 +1665,7 @@  discard block
 block discarded – undo
1665 1665
     public function delete_user_rel_group($user_id, $group_id)
1666 1666
     {
1667 1667
         $table = $this->usergroup_rel_user_table;
1668
-        $sql= "DELETE FROM $table
1668
+        $sql = "DELETE FROM $table
1669 1669
                WHERE
1670 1670
                 user_id = ".intval($user_id)." AND
1671 1671
                 usergroup_id = ".intval($group_id)."  ";
@@ -1721,7 +1721,7 @@  discard block
 block discarded – undo
1721 1721
 
1722 1722
         $sql = "UPDATE $table_group_rel_user
1723 1723
    				SET relation_type = ".intval($relation_type)."
1724
-                WHERE user_id = $user_id AND usergroup_id = $group_id" ;
1724
+                WHERE user_id = $user_id AND usergroup_id = $group_id";
1725 1725
         Database::query($sql);
1726 1726
     }
1727 1727
 
@@ -1763,7 +1763,7 @@  discard block
 block discarded – undo
1763 1763
         if (Database::num_rows($result) > 0) {
1764 1764
             while ($row = Database::fetch_array($result, 'ASSOC')) {
1765 1765
                 if ($with_image) {
1766
-                    $picture = self::get_picture_group($row['id'], $row['picture'],80);
1766
+                    $picture = self::get_picture_group($row['id'], $row['picture'], 80);
1767 1767
                     $img = '<img src="'.$picture['file'].'" />';
1768 1768
                     $row['picture'] = $img;
1769 1769
                 }
@@ -1799,11 +1799,11 @@  discard block
 block discarded – undo
1799 1799
 				ORDER BY count DESC
1800 1800
 				LIMIT $num";
1801 1801
 
1802
-        $result=Database::query($sql);
1802
+        $result = Database::query($sql);
1803 1803
         $array = array();
1804 1804
         while ($row = Database::fetch_array($result, 'ASSOC')) {
1805 1805
             if ($with_image) {
1806
-                $picture = self::get_picture_group($row['id'], $row['picture'],80);
1806
+                $picture = self::get_picture_group($row['id'], $row['picture'], 80);
1807 1807
                 $img = '<img src="'.$picture['file'].'" />';
1808 1808
                 $row['picture'] = $img;
1809 1809
             }
@@ -1848,11 +1848,11 @@  discard block
 block discarded – undo
1848 1848
                 ORDER BY created_at DESC
1849 1849
                 LIMIT $num ";
1850 1850
 
1851
-        $result=Database::query($sql);
1851
+        $result = Database::query($sql);
1852 1852
         $array = array();
1853 1853
         while ($row = Database::fetch_array($result, 'ASSOC')) {
1854 1854
             if ($with_image) {
1855
-                $picture = self::get_picture_group($row['id'], $row['picture'],80);
1855
+                $picture = self::get_picture_group($row['id'], $row['picture'], 80);
1856 1856
                 $img = '<img src="'.$picture['file'].'" />';
1857 1857
                 $row['picture'] = $img;
1858 1858
             }
@@ -1886,7 +1886,7 @@  discard block
 block discarded – undo
1886 1886
         $tbl_user = Database::get_main_table(TABLE_MAIN_USER);
1887 1887
         $group_id = intval($group_id);
1888 1888
 
1889
-        if (empty($group_id)){
1889
+        if (empty($group_id)) {
1890 1890
             return array();
1891 1891
         }
1892 1892
 
@@ -1901,9 +1901,9 @@  discard block
 block discarded – undo
1901 1901
             $where_relation_condition = '';
1902 1902
         } else {
1903 1903
             $new_relation_type = array();
1904
-            foreach($relation_type as $rel) {
1904
+            foreach ($relation_type as $rel) {
1905 1905
                 $rel = intval($rel);
1906
-                $new_relation_type[] ="'$rel'";
1906
+                $new_relation_type[] = "'$rel'";
1907 1907
             }
1908 1908
             $relation_type = implode(',', $new_relation_type);
1909 1909
             if (!empty($relation_type))
@@ -1947,7 +1947,7 @@  discard block
 block discarded – undo
1947 1947
         $tbl_user = Database::get_main_table(TABLE_MAIN_USER);
1948 1948
         $group_id = intval($group_id);
1949 1949
 
1950
-        if (empty($group_id)){
1950
+        if (empty($group_id)) {
1951 1951
             return array();
1952 1952
         }
1953 1953
 
@@ -1958,7 +1958,7 @@  discard block
 block discarded – undo
1958 1958
 			    WHERE gu.usergroup_id= $group_id
1959 1959
 			    ORDER BY relation_type, firstname";
1960 1960
 
1961
-        $result=Database::query($sql);
1961
+        $result = Database::query($sql);
1962 1962
         $array = array();
1963 1963
         while ($row = Database::fetch_array($result, 'ASSOC')) {
1964 1964
             $array[$row['id']] = $row;
@@ -1987,27 +1987,27 @@  discard block
 block discarded – undo
1987 1987
             case GROUP_USER_PERMISSION_READER:
1988 1988
                 // I'm just a reader
1989 1989
                 $relation_group_title = get_lang('IAmAReader');
1990
-                $links .=  '<li><a href="group_invitation.php?id='.$group_id.'">'.
1991
-                            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>';
1992
-                $links .=  '<li><a href="group_view.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'.
1990
+                $links .= '<li><a href="group_invitation.php?id='.$group_id.'">'.
1991
+                            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>';
1992
+                $links .= '<li><a href="group_view.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'.
1993 1993
                             Display::return_icon('group_leave.png', get_lang('LeaveGroup'), array('hspace'=>'6')).'<span class="social-menu-text4" >'.get_lang('LeaveGroup').'</span></a></li>';
1994 1994
                 break;
1995 1995
             case GROUP_USER_PERMISSION_ADMIN:
1996 1996
                 $relation_group_title = get_lang('IAmAnAdmin');
1997
-                $links .=  '<li><a href="group_edit.php?id='.$group_id.'">'.
1998
-                            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>';
1999
-                $links .=  '<li><a href="group_waiting_list.php?id='.$group_id.'">'.
2000
-                            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>';
2001
-                $links .=  '<li><a href="group_invitation.php?id='.$group_id.'">'.
2002
-                            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>';
2003
-                $links .=  '<li><a href="group_view.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'.
1997
+                $links .= '<li><a href="group_edit.php?id='.$group_id.'">'.
1998
+                            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>';
1999
+                $links .= '<li><a href="group_waiting_list.php?id='.$group_id.'">'.
2000
+                            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>';
2001
+                $links .= '<li><a href="group_invitation.php?id='.$group_id.'">'.
2002
+                            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>';
2003
+                $links .= '<li><a href="group_view.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'.
2004 2004
                             Display::return_icon('group_leave.png', get_lang('LeaveGroup'), array('hspace'=>'6')).'<span class="social-menu-text4" >'.get_lang('LeaveGroup').'</span></a></li>';
2005 2005
                 break;
2006 2006
             case GROUP_USER_PERMISSION_PENDING_INVITATION:
2007 2007
 //				$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>';
2008 2008
                 break;
2009 2009
             case GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER:
2010
-                $relation_group_title =  get_lang('WaitingForAdminResponse');
2010
+                $relation_group_title = get_lang('WaitingForAdminResponse');
2011 2011
                 break;
2012 2012
             case GROUP_USER_PERMISSION_MODERATOR:
2013 2013
                 $relation_group_title = get_lang('IAmAModerator');
@@ -2015,25 +2015,25 @@  discard block
 block discarded – undo
2015 2015
                 //$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>';
2016 2016
                 //$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>';
2017 2017
                 if ($group_info['visibility'] == GROUP_PERMISSION_CLOSED) {
2018
-                    $links .=  '<li><a href="group_waiting_list.php?id='.$group_id.'">'.
2019
-                                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>';
2018
+                    $links .= '<li><a href="group_waiting_list.php?id='.$group_id.'">'.
2019
+                                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>';
2020 2020
                 }
2021
-                $links .=  '<li><a href="group_invitation.php?id='.$group_id.'">'.
2022
-                            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>';
2023
-                $links .=  '<li><a href="group_view.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'.
2021
+                $links .= '<li><a href="group_invitation.php?id='.$group_id.'">'.
2022
+                            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>';
2023
+                $links .= '<li><a href="group_view.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'.
2024 2024
                             Display::return_icon('group_leave.png', get_lang('LeaveGroup'), array('hspace'=>'6')).'<span class="social-menu-text4" >'.get_lang('LeaveGroup').'</span></a></li>';
2025 2025
                 break;
2026 2026
             case GROUP_USER_PERMISSION_HRM:
2027 2027
                 $relation_group_title = get_lang('IAmAHRM');
2028 2028
                 $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').'">'.
2029 2029
                             Display::return_icon('new-message.png', get_lang('NewTopic'), array('hspace'=>'6')).'<span class="social-menu-text4" >'.get_lang('NewTopic').'</span></a></li>';
2030
-                $links .=  '<li><a href="group_view.php?id='.$group_id.'">'.
2031
-                            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>';
2032
-                $links .=  '<li><a href="group_invitation.php?id='.$group_id.'">'.
2033
-                            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>';
2034
-                $links .=  '<li><a href="group_members.php?id='.$group_id.'">'.
2035
-                            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>';
2036
-                $links .=  '<li><a href="group_view.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'.
2030
+                $links .= '<li><a href="group_view.php?id='.$group_id.'">'.
2031
+                            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>';
2032
+                $links .= '<li><a href="group_invitation.php?id='.$group_id.'">'.
2033
+                            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>';
2034
+                $links .= '<li><a href="group_members.php?id='.$group_id.'">'.
2035
+                            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>';
2036
+                $links .= '<li><a href="group_view.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'.
2037 2037
                             Display::return_icon('delete_data.gif', get_lang('LeaveGroup'), array('hspace'=>'6')).'<span class="social-menu-text4" >'.get_lang('LeaveGroup').'</span></a></li>';
2038 2038
                 break;
2039 2039
             default:
@@ -2076,14 +2076,14 @@  discard block
 block discarded – undo
2076 2076
      */
2077 2077
     public function get_groups_by_user_count($user_id = '', $relation_type = GROUP_USER_PERMISSION_READER, $with_image = false)
2078 2078
     {
2079
-        $table_group_rel_user	= $this->usergroup_rel_user_table;
2080
-        $tbl_group				= $this->table;
2081
-        $user_id 				= intval($user_id);
2079
+        $table_group_rel_user = $this->usergroup_rel_user_table;
2080
+        $tbl_group = $this->table;
2081
+        $user_id = intval($user_id);
2082 2082
 
2083 2083
         if ($relation_type == 0) {
2084 2084
             $where_relation_condition = '';
2085 2085
         } else {
2086
-            $relation_type 			= intval($relation_type);
2086
+            $relation_type = intval($relation_type);
2087 2087
             $where_relation_condition = "AND gu.relation_type = $relation_type ";
2088 2088
         }
2089 2089
 
@@ -2156,7 +2156,7 @@  discard block
 block discarded – undo
2156 2156
         }
2157 2157
 
2158 2158
         $direction = 'ASC';
2159
-        if (!in_array($direction, array('ASC','DESC'))) {
2159
+        if (!in_array($direction, array('ASC', 'DESC'))) {
2160 2160
             $direction = 'ASC';
2161 2161
         }
2162 2162
 
@@ -2167,8 +2167,8 @@  discard block
 block discarded – undo
2167 2167
         $sql .= " LIMIT $from,$number_of_items";
2168 2168
 
2169 2169
         $res = Database::query($sql);
2170
-        if (Database::num_rows($res)> 0) {
2171
-            while ($row = Database::fetch_array($res,'ASSOC')) {
2170
+        if (Database::num_rows($res) > 0) {
2171
+            while ($row = Database::fetch_array($res, 'ASSOC')) {
2172 2172
                 if (!in_array($row['id'], $return)) {
2173 2173
                     $return[$row['id']] = $row;
2174 2174
                 }
@@ -2193,7 +2193,7 @@  discard block
 block discarded – undo
2193 2193
             if ($i == $max_level) {
2194 2194
                 $select_part .= "rg$rg_number.group_id as id_$rg_number ";
2195 2195
             } else {
2196
-                $select_part .="rg$rg_number.group_id as id_$rg_number, ";
2196
+                $select_part .= "rg$rg_number.group_id as id_$rg_number, ";
2197 2197
             }
2198 2198
             if ($i == 1) {
2199 2199
                 $cond_part .= "FROM $t_rel_group rg0 LEFT JOIN $t_rel_group rg$i on rg$rg_number.group_id = rg$i.subgroup_id ";
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.
main/inc/lib/usermanager.lib.php 4 patches
Doc Comments   +31 added lines, -15 removed lines patch added patch discarded remove patch
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
     }
87 87
 
88 88
     /**
89
-     * @return bool|mixed
89
+     * @return string
90 90
      */
91 91
     public static function getPasswordEncryption()
92 92
     {
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
      * @param string $raw
162 162
      * @param User   $user
163 163
      *
164
-     * @return bool
164
+     * @return string
165 165
      */
166 166
     public static function encryptPassword($raw, User $user)
167 167
     {
@@ -965,6 +965,7 @@  discard block
 block discarded – undo
965 965
      * Disables or enables a user
966 966
      * @param int user_id
967 967
      * @param int Enable or disable
968
+     * @param integer $active
968 969
      * @return void
969 970
      * @assert (-1,0) === false
970 971
      * @assert (1,1) === true
@@ -995,6 +996,7 @@  discard block
 block discarded – undo
995 996
     /**
996 997
      * Disables a user
997 998
      * @param int User id
999
+     * @param integer $user_id
998 1000
      * @return bool
999 1001
      * @uses UserManager::change_active_state() to actually disable the user
1000 1002
      * @assert (0) === false
@@ -1011,6 +1013,7 @@  discard block
 block discarded – undo
1011 1013
     /**
1012 1014
      * Enable a user
1013 1015
      * @param int User id
1016
+     * @param integer $user_id
1014 1017
      * @return bool
1015 1018
      * @uses UserManager::change_active_state() to actually disable the user
1016 1019
      * @assert (0) === false
@@ -1175,6 +1178,7 @@  discard block
 block discarded – undo
1175 1178
      * Checks whether the user id exists in the database
1176 1179
      *
1177 1180
      * @param int User id
1181
+     * @param integer $userId
1178 1182
      * @return bool True if user id was found, false otherwise
1179 1183
      */
1180 1184
     public static function is_user_id_valid($userId)
@@ -1357,7 +1361,7 @@  discard block
 block discarded – undo
1357 1361
      * @param   array $userInfo user information to avoid query the DB
1358 1362
      * returns the /main/img/unknown.jpg image set it at true
1359 1363
      *
1360
-     * @return    array     Array of 2 elements: 'dir' and 'file' which contain
1364
+     * @return    integer     Array of 2 elements: 'dir' and 'file' which contain
1361 1365
      * the dir and file as the name implies if image does not exist it will
1362 1366
      * return the unknow image if anonymous parameter is true if not it returns an empty array
1363 1367
      */
@@ -1729,7 +1733,7 @@  discard block
 block discarded – undo
1729 1733
      * @param    int $user_id    User id
1730 1734
      * @param    $force    Optional parameter to force building after a removal request
1731 1735
      *
1732
-     * @return    A string containing the XHTML code to dipslay the production list, or FALSE
1736
+     * @return    boolean|string string containing the XHTML code to dipslay the production list, or FALSE
1733 1737
      */
1734 1738
     public static function build_production_list($user_id, $force = false, $showdelete = false)
1735 1739
     {
@@ -1765,7 +1769,7 @@  discard block
 block discarded – undo
1765 1769
     /**
1766 1770
      * Returns an array with the user's productions.
1767 1771
      *
1768
-     * @param    $user_id    User id
1772
+     * @param    integer $user_id    User id
1769 1773
      * @return   array  An array containing the user's productions
1770 1774
      */
1771 1775
     public static function get_user_productions($user_id)
@@ -1920,7 +1924,7 @@  discard block
 block discarded – undo
1920 1924
 
1921 1925
     /**
1922 1926
      * Build a list of extra file already uploaded in $user_folder/{$extra_field}/
1923
-     * @param $user_id
1927
+     * @param integer $user_id
1924 1928
      * @param $extra_field
1925 1929
      * @param bool $force
1926 1930
      * @param bool $showdelete
@@ -2023,7 +2027,7 @@  discard block
 block discarded – undo
2023 2027
      * @param    int       $fieldType  Field's type
2024 2028
      * @param    string    $displayText Field's language var name
2025 2029
      * @param    string    $default Field's default value
2026
-     * @return int
2030
+     * @return boolean
2027 2031
      */
2028 2032
     public static function create_extra_field($variable, $fieldType, $displayText, $default)
2029 2033
     {
@@ -2056,6 +2060,7 @@  discard block
 block discarded – undo
2056 2060
      * @param    boolean    Whether to prefix the fields indexes with "extra_" (might be used by formvalidator)
2057 2061
      * @param    boolean    Whether to return invisible fields as well
2058 2062
      * @param    boolean    Whether to split multiple-selection fields or not
2063
+     * @param boolean $field_filter
2059 2064
      * @return    array    Array of fields => value for the given user
2060 2065
      */
2061 2066
     public static function get_extra_user_data(
@@ -2242,7 +2247,6 @@  discard block
 block discarded – undo
2242 2247
     /**
2243 2248
      * Get all the extra field information of a certain field (also the options)
2244 2249
      *
2245
-     * @param int $field_name the name of the field we want to know everything of
2246 2250
      * @return array $return containing all th information about the extra profile field
2247 2251
      * @author Julio Montoya
2248 2252
      * @deprecated
@@ -2285,6 +2289,7 @@  discard block
 block discarded – undo
2285 2289
     /**
2286 2290
      * Get extra user data by field variable
2287 2291
      * @param string    field variable
2292
+     * @param string $field_variable
2288 2293
      * @return array    data
2289 2294
      */
2290 2295
     public static function get_extra_user_data_by_field_variable($field_variable)
@@ -2829,7 +2834,7 @@  discard block
 block discarded – undo
2829 2834
      * @param    string    User ID
2830 2835
      * @param   string  course directory
2831 2836
      * @param   string  resourcetype: images, all
2832
-     * @return    int        User ID (or false if not found)
2837
+     * @return    string        User ID (or false if not found)
2833 2838
      */
2834 2839
     public static function get_user_upload_files_by_course($user_id, $course, $resourcetype = 'all')
2835 2840
     {
@@ -2909,7 +2914,7 @@  discard block
 block discarded – undo
2909 2914
     /**
2910 2915
      * Adds a new API key to the users' account
2911 2916
      * @param   int     Optional user ID (defaults to the results of api_get_user_id())
2912
-     * @return  boolean True on success, false on failure
2917
+     * @return  false|string True on success, false on failure
2913 2918
      */
2914 2919
     public static function add_api_key($user_id = null, $api_service = 'dokeos')
2915 2920
     {
@@ -2964,6 +2969,7 @@  discard block
 block discarded – undo
2964 2969
      * Regenerate an API key from the user's account
2965 2970
      * @param   int     user ID (defaults to the results of api_get_user_id())
2966 2971
      * @param   string  API key's internal ID
2972
+     * @param string $api_service
2967 2973
      * @return  int        num
2968 2974
      */
2969 2975
     public static function update_api_key($user_id, $api_service)
@@ -2993,6 +2999,7 @@  discard block
 block discarded – undo
2993 2999
     /**
2994 3000
      * @param   int     user ID (defaults to the results of api_get_user_id())
2995 3001
      * @param   string    API key's internal ID
3002
+     * @param string $api_service
2996 3003
      * @return  int    row ID, or return false if not found
2997 3004
      */
2998 3005
     public static function get_api_key_id($user_id, $api_service)
@@ -3204,7 +3211,8 @@  discard block
 block discarded – undo
3204 3211
      * @param int user_id
3205 3212
      * @param int field_id
3206 3213
      * @param bool show links or not
3207
-     * @return array
3214
+     * @param integer $user_id
3215
+     * @return string
3208 3216
      */
3209 3217
     public static function get_user_tags_to_string($user_id, $field_id, $show_links = true)
3210 3218
     {
@@ -3249,6 +3257,8 @@  discard block
 block discarded – undo
3249 3257
      * Get the tag id
3250 3258
      * @param int tag
3251 3259
      * @param int field_id
3260
+     * @param string $tag
3261
+     * @param integer $field_id
3252 3262
      * @return int returns 0 if fails otherwise the tag id
3253 3263
      */
3254 3264
     public static function get_tag_id($tag, $field_id)
@@ -3295,7 +3305,7 @@  discard block
 block discarded – undo
3295 3305
      * @param mixed tag
3296 3306
      * @param int The user id
3297 3307
      * @param int field id of the tag
3298
-     * @return bool
3308
+     * @return boolean|null
3299 3309
      */
3300 3310
     public static function add_tag($tag, $user_id, $field_id)
3301 3311
     {
@@ -4101,7 +4111,7 @@  discard block
 block discarded – undo
4101 4111
      * Add subscribed users to a user by relation type
4102 4112
      * @param int $userId The user id
4103 4113
      * @param array $subscribedUsersId The id of suscribed users
4104
-     * @param action $relationType The relation type
4114
+     * @param integer $relationType The relation type
4105 4115
      */
4106 4116
     public static function subscribeUsersToUser($userId, $subscribedUsersId, $relationType)
4107 4117
     {
@@ -4158,6 +4168,8 @@  discard block
 block discarded – undo
4158 4168
      * This function check if an user is followed by human resources manager
4159 4169
      * @param     int     User id
4160 4170
      * @param    int        Human resources manager
4171
+     * @param integer $user_id
4172
+     * @param integer $hr_dept_id
4161 4173
      * @return    bool
4162 4174
      */
4163 4175
     public static function is_user_followed_by_drh($user_id, $hr_dept_id)
@@ -4230,6 +4242,8 @@  discard block
 block discarded – undo
4230 4242
      * Determines if a user is a gradebook certified
4231 4243
      * @param int The category id of gradebook
4232 4244
      * @param int The user id
4245
+     * @param integer $cat_id
4246
+     * @param integer $user_id
4233 4247
      * @return boolean
4234 4248
      */
4235 4249
     public static function is_user_certified($cat_id, $user_id)
@@ -4252,6 +4266,8 @@  discard block
 block discarded – undo
4252 4266
      * Gets the info about a gradebook certificate for a user by course
4253 4267
      * @param string The course code
4254 4268
      * @param int The user id
4269
+     * @param integer $course_code
4270
+     * @param integer $user_id
4255 4271
      * @return array  if there is not information return false
4256 4272
      */
4257 4273
     public static function get_info_gradebook_certificate($course_code, $user_id)
@@ -4715,7 +4731,7 @@  discard block
 block discarded – undo
4715 4731
     }
4716 4732
 
4717 4733
     /**
4718
-     * @return array
4734
+     * @return string[]
4719 4735
      */
4720 4736
     static function get_user_field_types()
4721 4737
     {
@@ -4967,7 +4983,7 @@  discard block
 block discarded – undo
4967 4983
      * Get either a Gravatar URL or complete image tag for a specified email address.
4968 4984
      *
4969 4985
      * @param string $email The email address
4970
-     * @param string $s Size in pixels, defaults to 80px [ 1 - 2048 ]
4986
+     * @param integer $s Size in pixels, defaults to 80px [ 1 - 2048 ]
4971 4987
      * @param string $d Default imageset to use [ 404 | mm | identicon | monsterid | wavatar ]
4972 4988
      * @param string $r Maximum rating (inclusive) [ g | pg | r | x ]
4973 4989
      * @param boole $img True to return a complete IMG tag False for just the URL
Please login to merge, or discard this patch.
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -1229,13 +1229,13 @@  discard block
 block discarded – undo
1229 1229
     }
1230 1230
 
1231 1231
     /**
1232
-    * Get the users by ID
1233
-    * @param array $ids student ids
1234
-    * @param string $active
1235
-    * @param string $order
1236
-    * @param string $limit
1237
-    * @return array $result student information
1238
-    */
1232
+     * Get the users by ID
1233
+     * @param array $ids student ids
1234
+     * @param string $active
1235
+     * @param string $order
1236
+     * @param string $limit
1237
+     * @return array $result student information
1238
+     */
1239 1239
     public static function get_user_list_by_ids($ids = array(), $active = null, $order = null, $limit = null)
1240 1240
     {
1241 1241
         if (empty($ids)) {
@@ -3332,12 +3332,12 @@  discard block
 block discarded – undo
3332 3332
         if ($tag_id == 0) {
3333 3333
             //the tag doesn't exist
3334 3334
             $sql = "INSERT INTO $table_user_tag (tag, field_id,count) VALUES ('$tag','$field_id', count + 1)";
3335
-             Database::query($sql);
3335
+                Database::query($sql);
3336 3336
             $last_insert_id = Database::insert_id();
3337 3337
         } else {
3338 3338
             //the tag exists we update it
3339 3339
             $sql = "UPDATE $table_user_tag SET count = count + 1 WHERE id  = $tag_id";
3340
-             Database::query($sql);
3340
+                Database::query($sql);
3341 3341
             $last_insert_id = $tag_id;
3342 3342
         }
3343 3343
 
@@ -3532,9 +3532,9 @@  discard block
 block discarded – undo
3532 3532
     }
3533 3533
 
3534 3534
     /**
3535
-      * Get extra filtrable user fields (only type select)
3536
-      * @return array
3537
-      */
3535
+     * Get extra filtrable user fields (only type select)
3536
+     * @return array
3537
+     */
3538 3538
     public static function get_extra_filtrable_fields()
3539 3539
     {
3540 3540
         $extraFieldList = UserManager::get_extra_fields();
@@ -3559,9 +3559,9 @@  discard block
 block discarded – undo
3559 3559
     }
3560 3560
 
3561 3561
     /**
3562
-      * Get extra where clauses for finding users based on extra filtrable user fields (type select)
3563
-      * @return string With AND clauses based on user's ID which have the values to search in extra user fields
3564
-      */
3562
+     * Get extra where clauses for finding users based on extra filtrable user fields (type select)
3563
+     * @return string With AND clauses based on user's ID which have the values to search in extra user fields
3564
+     */
3565 3565
     public static function get_search_form_where_extra_fields()
3566 3566
     {
3567 3567
         $useExtraFields = false;
@@ -3869,23 +3869,23 @@  discard block
 block discarded – undo
3869 3869
     }
3870 3870
 
3871 3871
     /**
3872
-    * Get users followed by human resource manager
3873
-    * @param int $userId
3874
-    * @param int  $userStatus Filter users by status (STUDENT, COURSEMANAGER, etc)
3875
-    * @param bool $getOnlyUserId
3876
-    * @param bool $getSql
3877
-    * @param bool $getCount
3878
-    * @param int $from
3879
-    * @param int $numberItems
3880
-    * @param int $column
3881
-    * @param string $direction
3882
-    * @param int $active
3883
-    * @param string $lastConnectionDate
3884
-    * @param int $status the function is called by who? COURSEMANAGER, DRH?
3885
-    * @param string $keyword
3872
+     * Get users followed by human resource manager
3873
+     * @param int $userId
3874
+     * @param int  $userStatus Filter users by status (STUDENT, COURSEMANAGER, etc)
3875
+     * @param bool $getOnlyUserId
3876
+     * @param bool $getSql
3877
+     * @param bool $getCount
3878
+     * @param int $from
3879
+     * @param int $numberItems
3880
+     * @param int $column
3881
+     * @param string $direction
3882
+     * @param int $active
3883
+     * @param string $lastConnectionDate
3884
+     * @param int $status the function is called by who? COURSEMANAGER, DRH?
3885
+     * @param string $keyword
3886 3886
      *
3887
-    * @return array user list
3888
-    */
3887
+     * @return array user list
3888
+     */
3889 3889
     public static function getUsersFollowedByUser(
3890 3890
         $userId,
3891 3891
         $userStatus = null,
Please login to merge, or discard this patch.
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
     const USER_FIELD_TYPE_TIMEZONE = 11;
35 35
     const USER_FIELD_TYPE_SOCIAL_PROFILE = 12;
36 36
     const USER_FIELD_TYPE_FILE = 13;
37
-    const USER_FIELD_TYPE_MOBILE_PHONE_NUMBER  = 14;
37
+    const USER_FIELD_TYPE_MOBILE_PHONE_NUMBER = 14;
38 38
 
39 39
     private static $encryptionMethod;
40 40
 
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
         }
281 281
 
282 282
         if (empty($password)) {
283
-            Display::addFlash(Display::return_message(get_lang('ThisFieldIsRequired').': '.get_lang('Password') , 'warning'));
283
+            Display::addFlash(Display::return_message(get_lang('ThisFieldIsRequired').': '.get_lang('Password'), 'warning'));
284 284
 
285 285
             return false;
286 286
         }
@@ -758,7 +758,7 @@  discard block
 block discarded – undo
758 758
         $sql = "UPDATE $table_user SET active = 1 WHERE id IN ($ids)";
759 759
         $r = Database::query($sql);
760 760
         if ($r !== false) {
761
-            Event::addEvent(LOG_USER_ENABLE,LOG_USER_ID,$ids);
761
+            Event::addEvent(LOG_USER_ENABLE, LOG_USER_ID, $ids);
762 762
         }
763 763
         return $r;
764 764
     }
@@ -1162,7 +1162,7 @@  discard block
 block discarded – undo
1162 1162
             // 1. Conversion of unacceptable letters (latinian letters with accents for example) into ASCII letters in order they not to be totally removed.
1163 1163
             // 2. Applying the strict purifier.
1164 1164
             // 3. Length limitation.
1165
-            $return  = api_get_setting('login_is_email') == 'true' ? substr(preg_replace(USERNAME_PURIFIER_MAIL, '', $username), 0, USERNAME_MAX_LENGTH) : substr(preg_replace(USERNAME_PURIFIER, '', $username), 0, USERNAME_MAX_LENGTH);
1165
+            $return = api_get_setting('login_is_email') == 'true' ? substr(preg_replace(USERNAME_PURIFIER_MAIL, '', $username), 0, USERNAME_MAX_LENGTH) : substr(preg_replace(USERNAME_PURIFIER, '', $username), 0, USERNAME_MAX_LENGTH);
1166 1166
             $return = URLify::transliterate($return);
1167 1167
             return $return;
1168 1168
         }
@@ -1254,12 +1254,12 @@  discard block
 block discarded – undo
1254 1254
 
1255 1255
         if (!is_null($order)) {
1256 1256
             $order = Database::escape_string($order);
1257
-            $sql .= ' ORDER BY ' . $order;
1257
+            $sql .= ' ORDER BY '.$order;
1258 1258
         }
1259 1259
 
1260 1260
         if (!is_null($limit)) {
1261 1261
             $limit = Database::escape_string($limit);
1262
-            $sql .= ' LIMIT ' . $limit;
1262
+            $sql .= ' LIMIT '.$limit;
1263 1263
         }
1264 1264
 
1265 1265
         $rs = Database::query($sql);
@@ -1432,7 +1432,7 @@  discard block
 block discarded – undo
1432 1432
             // In exceptional cases, on some portals, the intermediate base user
1433 1433
             // directory might not have been created. Make sure it is before
1434 1434
             // going further.
1435
-            $rootPath = api_get_path(SYS_UPLOAD_PATH) . 'users/' . substr((string) $id, 0, 1);
1435
+            $rootPath = api_get_path(SYS_UPLOAD_PATH).'users/'.substr((string) $id, 0, 1);
1436 1436
             if (!is_dir($rootPath)) {
1437 1437
                 $perm = api_get_permissions_for_new_directories();
1438 1438
                 try {
@@ -1685,7 +1685,7 @@  discard block
 block discarded – undo
1685 1685
         $path_info = self::get_user_picture_path_by_id($user_id, 'system');
1686 1686
         $path = $path_info['dir'];
1687 1687
         if (!empty($extra_field)) {
1688
-            $path .= $extra_field . '/';
1688
+            $path .= $extra_field.'/';
1689 1689
         }
1690 1690
         // If this directory does not exist - we create it.
1691 1691
         if (!file_exists($path)) {
@@ -1693,7 +1693,7 @@  discard block
 block discarded – undo
1693 1693
         }
1694 1694
 
1695 1695
         if (filter_extension($file)) {
1696
-            if (@move_uploaded_file($source_file,$path.$file)) {
1696
+            if (@move_uploaded_file($source_file, $path.$file)) {
1697 1697
                 if ($extra_field) {
1698 1698
                     return $extra_field.'/'.$file;
1699 1699
                 } else {
@@ -1944,10 +1944,10 @@  discard block
 block discarded – undo
1944 1944
         if (count($extra_files) > 0) {
1945 1945
             $extra_file_list = '<div class="files-production"><ul id="productions">';
1946 1946
             foreach ($extra_files as $file) {
1947
-                $filename = substr($file,strlen($extra_field)+1);
1947
+                $filename = substr($file, strlen($extra_field) + 1);
1948 1948
                 $extra_file_list .= '<li>'.Display::return_icon('archive.png').'<a href="'.$path.$extra_field.'/'.urlencode($filename).'" target="_blank">'.htmlentities($filename).'</a> ';
1949 1949
                 if ($showdelete) {
1950
-                    $extra_file_list .= '<input style="width:16px;" type="image" name="remove_extra_' . $extra_field . '['.urlencode($file).']" src="'.$del_image.'" alt="'.$del_text.'" title="'.$del_text.' '.htmlentities($filename).'" onclick="javascript: return confirmation(\''.htmlentities($filename).'\');" /></li>';
1950
+                    $extra_file_list .= '<input style="width:16px;" type="image" name="remove_extra_'.$extra_field.'['.urlencode($file).']" src="'.$del_image.'" alt="'.$del_text.'" title="'.$del_text.' '.htmlentities($filename).'" onclick="javascript: return confirmation(\''.htmlentities($filename).'\');" /></li>';
1951 1951
                 }
1952 1952
             }
1953 1953
             $extra_file_list .= '</ul></div>';
@@ -2531,7 +2531,7 @@  discard block
 block discarded – undo
2531 2531
 
2532 2532
         if (api_is_allowed_to_create_course()) {
2533 2533
             $sessionListFromCourseCoach = array();
2534
-            $sql =" SELECT DISTINCT session_id
2534
+            $sql = " SELECT DISTINCT session_id
2535 2535
                     FROM $tbl_session_course_user
2536 2536
                     WHERE user_id = $user_id AND status = 2 ";
2537 2537
 
@@ -2539,7 +2539,7 @@  discard block
 block discarded – undo
2539 2539
             if (Database::num_rows($result)) {
2540 2540
                 $result = Database::store_result($result);
2541 2541
                 foreach ($result as $session) {
2542
-                    $sessionListFromCourseCoach[]= $session['session_id'];
2542
+                    $sessionListFromCourseCoach[] = $session['session_id'];
2543 2543
                 }
2544 2544
             }
2545 2545
             if (!empty($sessionListFromCourseCoach)) {
@@ -2562,7 +2562,7 @@  discard block
 block discarded – undo
2562 2562
                 ORDER BY access_start_date, access_end_date, name";
2563 2563
 
2564 2564
         $result = Database::query($sql);
2565
-        if (Database::num_rows($result)>0) {
2565
+        if (Database::num_rows($result) > 0) {
2566 2566
             while ($row = Database::fetch_assoc($result)) {
2567 2567
                 $sessions[$row['id']] = $row;
2568 2568
             }
@@ -2578,7 +2578,7 @@  discard block
 block discarded – undo
2578 2578
                 ORDER BY access_start_date, access_end_date, name";
2579 2579
 
2580 2580
         $result = Database::query($sql);
2581
-        if (Database::num_rows($result)>0) {
2581
+        if (Database::num_rows($result) > 0) {
2582 2582
             while ($row = Database::fetch_assoc($result)) {
2583 2583
                 if (empty($sessions[$row['id']])) {
2584 2584
                     $sessions[$row['id']] = $row;
@@ -3567,13 +3567,13 @@  discard block
 block discarded – undo
3567 3567
         $useExtraFields = false;
3568 3568
         $extraFields = UserManager::get_extra_filtrable_fields();
3569 3569
         $extraFieldResult = array();
3570
-        if (is_array($extraFields) && count($extraFields)>0 ) {
3570
+        if (is_array($extraFields) && count($extraFields) > 0) {
3571 3571
             foreach ($extraFields as $extraField) {
3572 3572
                 $varName = 'field_'.$extraField['variable'];
3573 3573
                 if (UserManager::is_extra_field_available($extraField['variable'])) {
3574
-                    if (isset($_GET[$varName]) && $_GET[$varName]!='0') {
3574
+                    if (isset($_GET[$varName]) && $_GET[$varName] != '0') {
3575 3575
                         $useExtraFields = true;
3576
-                        $extraFieldResult[]= UserManager::get_extra_user_data_by_value(
3576
+                        $extraFieldResult[] = UserManager::get_extra_user_data_by_value(
3577 3577
                             $extraField['variable'],
3578 3578
                             $_GET[$varName]
3579 3579
                         );
@@ -3584,17 +3584,17 @@  discard block
 block discarded – undo
3584 3584
 
3585 3585
         if ($useExtraFields) {
3586 3586
             $finalResult = array();
3587
-            if (count($extraFieldResult)>1) {
3588
-                for ($i=0; $i < count($extraFieldResult) -1; $i++) {
3589
-                    if (is_array($extraFieldResult[$i+1])) {
3590
-                        $finalResult  = array_intersect($extraFieldResult[$i], $extraFieldResult[$i+1]);
3587
+            if (count($extraFieldResult) > 1) {
3588
+                for ($i = 0; $i < count($extraFieldResult) - 1; $i++) {
3589
+                    if (is_array($extraFieldResult[$i + 1])) {
3590
+                        $finalResult = array_intersect($extraFieldResult[$i], $extraFieldResult[$i + 1]);
3591 3591
                     }
3592 3592
                 }
3593 3593
             } else {
3594 3594
                 $finalResult = $extraFieldResult[0];
3595 3595
             }
3596 3596
 
3597
-            if (is_array($finalResult) && count($finalResult)>0) {
3597
+            if (is_array($finalResult) && count($finalResult) > 0) {
3598 3598
                 $whereFilter = " AND u.id IN  ('".implode("','", $finalResult)."') ";
3599 3599
             } else {
3600 3600
                 //no results
@@ -3767,7 +3767,7 @@  discard block
 block discarded – undo
3767 3767
             $sql = 'DELETE FROM '.$tbl_my_friend.'
3768 3768
                     WHERE relation_type <> '.USER_RELATION_TYPE_RRHH.' AND friend_user_id='.$friend_id.' '.$extra_condition;
3769 3769
             Database::query($sql);
3770
-            $sql= 'DELETE FROM '.$tbl_my_friend.'
3770
+            $sql = 'DELETE FROM '.$tbl_my_friend.'
3771 3771
                    WHERE relation_type <> '.USER_RELATION_TYPE_RRHH.' AND user_id='.$friend_id.' '.$extra_condition;
3772 3772
             Database::query($sql);
3773 3773
         } else {
@@ -3961,7 +3961,7 @@  discard block
 block discarded – undo
3961 3961
 
3962 3962
         if (!empty($lastConnectionDate)) {
3963 3963
             $lastConnectionDate = Database::escape_string($lastConnectionDate);
3964
-            $userConditions .=  " AND u.last_login <= '$lastConnectionDate' ";
3964
+            $userConditions .= " AND u.last_login <= '$lastConnectionDate' ";
3965 3965
         }
3966 3966
 
3967 3967
         $courseConditions = null;
@@ -4028,7 +4028,7 @@  discard block
 block discarded – undo
4028 4028
                 break;
4029 4029
             case STUDENT_BOSS :
4030 4030
                 $drhConditions = " AND friend_user_id = $userId AND "
4031
-                . "relation_type = " . USER_RELATION_TYPE_BOSS;
4031
+                . "relation_type = ".USER_RELATION_TYPE_BOSS;
4032 4032
                 break;
4033 4033
         }
4034 4034
 
@@ -4118,7 +4118,7 @@  discard block
 block discarded – undo
4118 4118
                 . "INNER JOIN $userRelAccessUrlTable a ON (a.user_id = s.user_id) "
4119 4119
                 . "WHERE friend_user_id = $userId "
4120 4120
                 . "AND relation_type = $relationType "
4121
-                . "AND access_url_id = " . api_get_current_access_url_id() . "";
4121
+                . "AND access_url_id = ".api_get_current_access_url_id()."";
4122 4122
         } else {
4123 4123
             $sql = "SELECT user_id FROM $userRelUserTable "
4124 4124
                 . "WHERE friend_user_id = $userId "
@@ -4393,7 +4393,7 @@  discard block
 block discarded – undo
4393 4393
         if (empty($years)) {
4394 4394
             $years = 1;
4395 4395
         }
4396
-        $inactive_time = $years * 31536000;  //1 year
4396
+        $inactive_time = $years * 31536000; //1 year
4397 4397
         $rs = Database::query($sql);
4398 4398
         if (Database::num_rows($rs) > 0) {
4399 4399
             if ($last_login_date = Database::result($rs, 0, 0)) {
@@ -4526,7 +4526,7 @@  discard block
 block discarded – undo
4526 4526
                         'extra_'.$field_details[1],
4527 4527
                         $field_details[3],
4528 4528
                         $options,
4529
-                        array('id' => 'extra_' . $field_details[1])
4529
+                        array('id' => 'extra_'.$field_details[1])
4530 4530
                     );
4531 4531
 
4532 4532
                     if (!$admin_permissions) {
@@ -4680,7 +4680,7 @@  discard block
 block discarded – undo
4680 4680
                     $extra_field = 'extra_'.$field_details[1];
4681 4681
                     $form->addElement('file', $extra_field, $field_details[3], null, '');
4682 4682
                     if ($extra_file_list = UserManager::build_user_extra_file_list($user_id, $field_details[1], '', true)) {
4683
-                        $form->addElement('static', $extra_field . '_list', null, $extra_file_list);
4683
+                        $form->addElement('static', $extra_field.'_list', null, $extra_file_list);
4684 4684
                     }
4685 4685
                     if ($field_details[7] == 0) {
4686 4686
                         $form->freeze($extra_field);
@@ -4820,7 +4820,7 @@  discard block
 block discarded – undo
4820 4820
         $direction = null,
4821 4821
         $active = null,
4822 4822
         $lastConnectionDate = null
4823
-    ){
4823
+    ) {
4824 4824
         return self::getUsersFollowedByUser(
4825 4825
                 $userId, $userStatus, $getOnlyUserId, $getSql, $getCount, $from, $numberItems, $column, $direction,
4826 4826
                 $active, $lastConnectionDate, STUDENT_BOSS
@@ -4987,12 +4987,12 @@  discard block
 block discarded – undo
4987 4987
         if (!empty($_SERVER['HTTPS'])) {
4988 4988
             $url = 'https://secure.gravatar.com/avatar/';
4989 4989
         }
4990
-        $url .= md5( strtolower( trim( $email ) ) );
4990
+        $url .= md5(strtolower(trim($email)));
4991 4991
         $url .= "?s=$s&d=$d&r=$r";
4992
-        if ( $img ) {
4993
-            $url = '<img src="' . $url . '"';
4994
-            foreach ( $atts as $key => $val )
4995
-                $url .= ' ' . $key . '="' . $val . '"';
4992
+        if ($img) {
4993
+            $url = '<img src="'.$url.'"';
4994
+            foreach ($atts as $key => $val)
4995
+                $url .= ' '.$key.'="'.$val.'"';
4996 4996
             $url .= ' />';
4997 4997
         }
4998 4998
         return $url;
Please login to merge, or discard this patch.
Braces   +97 added lines, -62 removed lines patch added patch discarded remove patch
@@ -774,10 +774,12 @@  discard block
 block discarded – undo
774 774
     public static function update_openid($user_id, $openid)
775 775
     {
776 776
         $table_user = Database :: get_main_table(TABLE_MAIN_USER);
777
-        if ($user_id != strval(intval($user_id)))
778
-            return false;
779
-        if ($user_id === false)
780
-            return false;
777
+        if ($user_id != strval(intval($user_id))) {
778
+                    return false;
779
+        }
780
+        if ($user_id === false) {
781
+                    return false;
782
+        }
781 783
         $sql = "UPDATE $table_user SET
782 784
                 openid='".Database::escape_string($openid)."'";
783 785
         $sql .= " WHERE id= $user_id";
@@ -2069,8 +2071,9 @@  discard block
 block discarded – undo
2069 2071
         if (empty($user_id)) {
2070 2072
             $user_id = 0;
2071 2073
         } else {
2072
-            if ($user_id != strval(intval($user_id)))
2073
-                return array();
2074
+            if ($user_id != strval(intval($user_id))) {
2075
+                            return array();
2076
+            }
2074 2077
         }
2075 2078
         $extra_data = array();
2076 2079
         $t_uf = Database::get_main_table(TABLE_EXTRA_FIELD);
@@ -2162,8 +2165,9 @@  discard block
 block discarded – undo
2162 2165
         if (empty($user_id)) {
2163 2166
             $user_id = 0;
2164 2167
         } else {
2165
-            if ($user_id != strval(intval($user_id)))
2166
-                return array();
2168
+            if ($user_id != strval(intval($user_id))) {
2169
+                            return array();
2170
+            }
2167 2171
         }
2168 2172
         $extra_data = array();
2169 2173
         $t_uf = Database::get_main_table(TABLE_EXTRA_FIELD);
@@ -2880,13 +2884,15 @@  discard block
 block discarded – undo
2880 2884
      */
2881 2885
     public static function get_api_keys($user_id = null, $api_service = 'dokeos')
2882 2886
     {
2883
-        if ($user_id != strval(intval($user_id)))
2884
-            return false;
2887
+        if ($user_id != strval(intval($user_id))) {
2888
+                    return false;
2889
+        }
2885 2890
         if (empty($user_id)) {
2886 2891
             $user_id = api_get_user_id();
2887 2892
         }
2888
-        if ($user_id === false)
2889
-            return false;
2893
+        if ($user_id === false) {
2894
+                    return false;
2895
+        }
2890 2896
         $service_name = Database::escape_string($api_service);
2891 2897
         if (is_string($service_name) === false) {
2892 2898
             return false;
@@ -2894,11 +2900,14 @@  discard block
 block discarded – undo
2894 2900
         $t_api = Database::get_main_table(TABLE_MAIN_USER_API_KEY);
2895 2901
         $sql = "SELECT * FROM $t_api WHERE user_id = $user_id AND api_service='$api_service';";
2896 2902
         $res = Database::query($sql);
2897
-        if ($res === false)
2898
-            return false; //error during query
2903
+        if ($res === false) {
2904
+                    return false;
2905
+        }
2906
+        //error during query
2899 2907
         $num = Database::num_rows($res);
2900
-        if ($num == 0)
2901
-            return false;
2908
+        if ($num == 0) {
2909
+                    return false;
2910
+        }
2902 2911
         $list = array();
2903 2912
         while ($row = Database::fetch_array($res)) {
2904 2913
             $list[$row['id']] = $row['api_key'];
@@ -2913,13 +2922,15 @@  discard block
 block discarded – undo
2913 2922
      */
2914 2923
     public static function add_api_key($user_id = null, $api_service = 'dokeos')
2915 2924
     {
2916
-        if ($user_id != strval(intval($user_id)))
2917
-            return false;
2925
+        if ($user_id != strval(intval($user_id))) {
2926
+                    return false;
2927
+        }
2918 2928
         if (empty($user_id)) {
2919 2929
             $user_id = api_get_user_id();
2920 2930
         }
2921
-        if ($user_id === false)
2922
-            return false;
2931
+        if ($user_id === false) {
2932
+                    return false;
2933
+        }
2923 2934
         $service_name = Database::escape_string($api_service);
2924 2935
         if (is_string($service_name) === false) {
2925 2936
             return false;
@@ -2928,8 +2939,10 @@  discard block
 block discarded – undo
2928 2939
         $md5 = md5((time() + ($user_id * 5)) - rand(10000, 10000)); //generate some kind of random key
2929 2940
         $sql = "INSERT INTO $t_api (user_id, api_key,api_service) VALUES ($user_id,'$md5','$service_name')";
2930 2941
         $res = Database::query($sql);
2931
-        if ($res === false)
2932
-            return false; //error during query
2942
+        if ($res === false) {
2943
+                    return false;
2944
+        }
2945
+        //error during query
2933 2946
         $num = Database::insert_id();
2934 2947
         return ($num == 0) ? false : $num;
2935 2948
     }
@@ -2941,22 +2954,29 @@  discard block
 block discarded – undo
2941 2954
      */
2942 2955
     public static function delete_api_key($key_id)
2943 2956
     {
2944
-        if ($key_id != strval(intval($key_id)))
2945
-            return false;
2946
-        if ($key_id === false)
2947
-            return false;
2957
+        if ($key_id != strval(intval($key_id))) {
2958
+                    return false;
2959
+        }
2960
+        if ($key_id === false) {
2961
+                    return false;
2962
+        }
2948 2963
         $t_api = Database::get_main_table(TABLE_MAIN_USER_API_KEY);
2949 2964
         $sql = "SELECT * FROM $t_api WHERE id = ".$key_id;
2950 2965
         $res = Database::query($sql);
2951
-        if ($res === false)
2952
-            return false; //error during query
2966
+        if ($res === false) {
2967
+                    return false;
2968
+        }
2969
+        //error during query
2953 2970
         $num = Database::num_rows($res);
2954
-        if ($num !== 1)
2955
-            return false;
2971
+        if ($num !== 1) {
2972
+                    return false;
2973
+        }
2956 2974
         $sql = "DELETE FROM $t_api WHERE id = ".$key_id;
2957 2975
         $res = Database::query($sql);
2958
-        if ($res === false)
2959
-            return false; //error during query
2976
+        if ($res === false) {
2977
+                    return false;
2978
+        }
2979
+        //error during query
2960 2980
         return true;
2961 2981
     }
2962 2982
 
@@ -2968,10 +2988,12 @@  discard block
 block discarded – undo
2968 2988
      */
2969 2989
     public static function update_api_key($user_id, $api_service)
2970 2990
     {
2971
-        if ($user_id != strval(intval($user_id)))
2972
-            return false;
2973
-        if ($user_id === false)
2974
-            return false;
2991
+        if ($user_id != strval(intval($user_id))) {
2992
+                    return false;
2993
+        }
2994
+        if ($user_id === false) {
2995
+                    return false;
2996
+        }
2975 2997
         $service_name = Database::escape_string($api_service);
2976 2998
         if (is_string($service_name) === false) {
2977 2999
             return false;
@@ -2997,12 +3019,15 @@  discard block
 block discarded – undo
2997 3019
      */
2998 3020
     public static function get_api_key_id($user_id, $api_service)
2999 3021
     {
3000
-        if ($user_id != strval(intval($user_id)))
3001
-            return false;
3002
-        if ($user_id === false)
3003
-            return false;
3004
-        if (empty($api_service))
3005
-            return false;
3022
+        if ($user_id != strval(intval($user_id))) {
3023
+                    return false;
3024
+        }
3025
+        if ($user_id === false) {
3026
+                    return false;
3027
+        }
3028
+        if (empty($api_service)) {
3029
+                    return false;
3030
+        }
3006 3031
         $t_api = Database::get_main_table(TABLE_MAIN_USER_API_KEY);
3007 3032
         $api_service = Database::escape_string($api_service);
3008 3033
         $sql = "SELECT id FROM $t_api WHERE user_id=".$user_id." AND api_service='".$api_service."'";
@@ -4473,8 +4498,9 @@  discard block
 block discarded – undo
4473 4498
                     $form->applyFilter('extra_'.$field_details[1], 'stripslashes');
4474 4499
                     $form->applyFilter('extra_'.$field_details[1], 'trim');
4475 4500
                     if (!$admin_permissions) {
4476
-                        if ($field_details[7] == 0)
4477
-                            $form->freeze('extra_'.$field_details[1]);
4501
+                        if ($field_details[7] == 0) {
4502
+                                                    $form->freeze('extra_'.$field_details[1]);
4503
+                        }
4478 4504
                     }
4479 4505
                     break;
4480 4506
                 case ExtraField::FIELD_TYPE_RADIO:
@@ -4491,8 +4517,9 @@  discard block
 block discarded – undo
4491 4517
                     }
4492 4518
                     $form->addGroup($group, 'extra_'.$field_details[1], $field_details[3], '');
4493 4519
                     if (!$admin_permissions) {
4494
-                        if ($field_details[7] == 0)
4495
-                            $form->freeze('extra_'.$field_details[1]);
4520
+                        if ($field_details[7] == 0) {
4521
+                                                    $form->freeze('extra_'.$field_details[1]);
4522
+                        }
4496 4523
                     }
4497 4524
                     break;
4498 4525
                 case ExtraField::FIELD_TYPE_SELECT:
@@ -4530,8 +4557,9 @@  discard block
 block discarded – undo
4530 4557
                     );
4531 4558
 
4532 4559
                     if (!$admin_permissions) {
4533
-                        if ($field_details[7] == 0)
4534
-                            $form->freeze('extra_'.$field_details[1]);
4560
+                        if ($field_details[7] == 0) {
4561
+                                                    $form->freeze('extra_'.$field_details[1]);
4562
+                        }
4535 4563
                     }
4536 4564
                     break;
4537 4565
                 case ExtraField::FIELD_TYPE_SELECT_MULTIPLE:
@@ -4547,8 +4575,9 @@  discard block
 block discarded – undo
4547 4575
                         array('multiple' => 'multiple')
4548 4576
                     );
4549 4577
                     if (!$admin_permissions) {
4550
-                        if ($field_details[7] == 0)
4551
-                            $form->freeze('extra_'.$field_details[1]);
4578
+                        if ($field_details[7] == 0) {
4579
+                                                    $form->freeze('extra_'.$field_details[1]);
4580
+                        }
4552 4581
                     }
4553 4582
                     break;
4554 4583
                 case ExtraField::FIELD_TYPE_DATE:
@@ -4556,8 +4585,9 @@  discard block
 block discarded – undo
4556 4585
                     $defaults['extra_'.$field_details[1]] = date('Y-m-d 12:00:00');
4557 4586
                     $form->setDefaults($defaults);
4558 4587
                     if (!$admin_permissions) {
4559
-                        if ($field_details[7] == 0)
4560
-                            $form->freeze('extra_'.$field_details[1]);
4588
+                        if ($field_details[7] == 0) {
4589
+                                                    $form->freeze('extra_'.$field_details[1]);
4590
+                        }
4561 4591
                     }
4562 4592
                     $form->applyFilter('theme', 'trim');
4563 4593
                     break;
@@ -4566,8 +4596,9 @@  discard block
 block discarded – undo
4566 4596
                     $defaults['extra_'.$field_details[1]] = date('Y-m-d 12:00:00');
4567 4597
                     $form->setDefaults($defaults);
4568 4598
                     if (!$admin_permissions) {
4569
-                        if ($field_details[7] == 0)
4570
-                            $form->freeze('extra_'.$field_details[1]);
4599
+                        if ($field_details[7] == 0) {
4600
+                                                    $form->freeze('extra_'.$field_details[1]);
4601
+                        }
4571 4602
                     }
4572 4603
                     $form->applyFilter('theme', 'trim');
4573 4604
                     break;
@@ -4586,8 +4617,9 @@  discard block
 block discarded – undo
4586 4617
                     $form->addGroup($group, 'extra_'.$field_details[1], $field_details[3], '&nbsp;');
4587 4618
 
4588 4619
                     if (!$admin_permissions) {
4589
-                        if ($field_details[7] == 0)
4590
-                            $form->freeze('extra_'.$field_details[1]);
4620
+                        if ($field_details[7] == 0) {
4621
+                                                    $form->freeze('extra_'.$field_details[1]);
4622
+                        }
4591 4623
                     }
4592 4624
 
4593 4625
                     /* Recoding the selected values for double : if the user has
@@ -4647,8 +4679,9 @@  discard block
 block discarded – undo
4647 4679
                     break;
4648 4680
                 case ExtraField::FIELD_TYPE_TIMEZONE:
4649 4681
                     $form->addElement('select', 'extra_'.$field_details[1], $field_details[3], api_get_timezones(), '');
4650
-                    if ($field_details[7] == 0)
4651
-                        $form->freeze('extra_'.$field_details[1]);
4682
+                    if ($field_details[7] == 0) {
4683
+                                            $form->freeze('extra_'.$field_details[1]);
4684
+                    }
4652 4685
                     break;
4653 4686
                 case ExtraField::FIELD_TYPE_SOCIAL_PROFILE:
4654 4687
                     // get the social network's favicon
@@ -4673,8 +4706,9 @@  discard block
 block discarded – undo
4673 4706
                     );
4674 4707
                     $form->applyFilter('extra_'.$field_details[1], 'stripslashes');
4675 4708
                     $form->applyFilter('extra_'.$field_details[1], 'trim');
4676
-                    if ($field_details[7] == 0)
4677
-                        $form->freeze('extra_'.$field_details[1]);
4709
+                    if ($field_details[7] == 0) {
4710
+                                            $form->freeze('extra_'.$field_details[1]);
4711
+                    }
4678 4712
                     break;
4679 4713
                 case ExtraField::FIELD_TYPE_FILE:
4680 4714
                     $extra_field = 'extra_'.$field_details[1];
@@ -4991,8 +5025,9 @@  discard block
 block discarded – undo
4991 5025
         $url .= "?s=$s&d=$d&r=$r";
4992 5026
         if ( $img ) {
4993 5027
             $url = '<img src="' . $url . '"';
4994
-            foreach ( $atts as $key => $val )
4995
-                $url .= ' ' . $key . '="' . $val . '"';
5028
+            foreach ( $atts as $key => $val ) {
5029
+                            $url .= ' ' . $key . '="' . $val . '"';
5030
+            }
4996 5031
             $url .= ' />';
4997 5032
         }
4998 5033
         return $url;
Please login to merge, or discard this patch.
main/inc/lib/userportal.lib.php 4 patches
Doc Comments   +10 added lines, -4 removed lines patch added patch discarded remove patch
@@ -642,6 +642,7 @@  discard block
 block discarded – undo
642 642
     * retrieves all the courses that the user has already subscribed to
643 643
     * @author Patrick Cool <[email protected]>, Ghent University, Belgium
644 644
     * @param int $user_id: the id of the user
645
+    * @param integer $user_id
645 646
     * @return array an array containing all the information of the courses of the given user
646 647
     */
647 648
     public function get_courses_of_user($user_id)
@@ -692,6 +693,11 @@  discard block
 block discarded – undo
692 693
 
693 694
     /**
694 695
      * @todo use the template system
696
+     * @param string|null $title
697
+     * @param string $content
698
+     * @param string $id
699
+     * @param string $idAccordion
700
+     * @param string $idCollpase
695 701
      */
696 702
     function show_right_block($title, $content, $id = null, $params = null, $idAccordion = null, $idCollpase = null)
697 703
     {
@@ -909,7 +915,7 @@  discard block
 block discarded – undo
909 915
     }
910 916
 
911 917
     /**
912
-     * @return null|string
918
+     * @return string
913 919
      */
914 920
     public function return_course_block()
915 921
     {
@@ -1558,8 +1564,8 @@  discard block
 block discarded – undo
1558 1564
 
1559 1565
     /**
1560 1566
      * Return HTML code for personal user course category
1561
-     * @param $id
1562
-     * @param $title
1567
+     * @param integer $id
1568
+     * @param string $title
1563 1569
      * @return string
1564 1570
      */
1565 1571
     private static function getHtmlForUserCategory($id, $title)
@@ -1580,7 +1586,7 @@  discard block
 block discarded – undo
1580 1586
     /**
1581 1587
      * return HTML code for course display in session view
1582 1588
      * @param array $courseInfo
1583
-     * @param $userCategoryId
1589
+     * @param integer $userCategoryId
1584 1590
      * @param bool $displayButton
1585 1591
      * @param $loadDirs
1586 1592
      * @return string
Please login to merge, or discard this patch.
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -248,17 +248,17 @@  discard block
 block discarded – undo
248 248
                 }
249 249
             }
250 250
 
251
-			if (trim($home_top_temp) == '' && api_is_platform_admin()) {
252
-				$home_top_temp = '<div class="welcome-mascot">' . get_lang('PortalHomepageDefaultIntroduction') . '</div>';
253
-			} else {
254
-				$home_top_temp = '<div class="welcome-home-top-temp">' . $home_top_temp . '</div>';
255
-			}
256
-			$open = str_replace('{rel_path}', api_get_path(REL_PATH), $home_top_temp);
257
-			$html = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
258
-		}
259
-
260
-		return $html;
261
-	}
251
+            if (trim($home_top_temp) == '' && api_is_platform_admin()) {
252
+                $home_top_temp = '<div class="welcome-mascot">' . get_lang('PortalHomepageDefaultIntroduction') . '</div>';
253
+            } else {
254
+                $home_top_temp = '<div class="welcome-home-top-temp">' . $home_top_temp . '</div>';
255
+            }
256
+            $open = str_replace('{rel_path}', api_get_path(REL_PATH), $home_top_temp);
257
+            $html = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
258
+        }
259
+
260
+        return $html;
261
+    }
262 262
 
263 263
     function return_notice()
264 264
     {
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
                     $thereIsSubCat = true;
510 510
                 } elseif (api_get_setting('show_empty_course_categories') == 'true') {
511 511
                     /* End changed code to eliminate the (0 courses) after empty categories. */
512
-                      $htmlListCat .= '<li>';
512
+                        $htmlListCat .= '<li>';
513 513
                     $htmlListCat .= $catLine['name'];
514 514
                     $htmlListCat .= "</li>";
515 515
                     $thereIsSubCat = true;
@@ -639,11 +639,11 @@  discard block
 block discarded – undo
639 639
     }
640 640
 
641 641
     /**
642
-    * retrieves all the courses that the user has already subscribed to
643
-    * @author Patrick Cool <[email protected]>, Ghent University, Belgium
644
-    * @param int $user_id: the id of the user
645
-    * @return array an array containing all the information of the courses of the given user
646
-    */
642
+     * retrieves all the courses that the user has already subscribed to
643
+     * @author Patrick Cool <[email protected]>, Ghent University, Belgium
644
+     * @param int $user_id: the id of the user
645
+     * @return array an array containing all the information of the courses of the given user
646
+     */
647 647
     public function get_courses_of_user($user_id)
648 648
     {
649 649
         $table_course = Database::get_main_table(TABLE_MAIN_COURSE);
Please login to merge, or discard this patch.
Spacing   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
     {
45 45
         $exercise_list = array();
46 46
         if (!empty($personal_course_list)) {
47
-            foreach($personal_course_list as  $course_item) {
47
+            foreach ($personal_course_list as  $course_item) {
48 48
                 $course_code = $course_item['c'];
49 49
                 $session_id = $course_item['id_session'];
50 50
 
@@ -53,10 +53,10 @@  discard block
 block discarded – undo
53 53
                     $session_id
54 54
                 );
55 55
 
56
-                foreach($exercises as $exercise_item) {
57
-                    $exercise_item['course_code']     = $course_code;
58
-                    $exercise_item['session_id']     = $session_id;
59
-                    $exercise_item['tms']     = api_strtotime($exercise_item['end_time'], 'UTC');
56
+                foreach ($exercises as $exercise_item) {
57
+                    $exercise_item['course_code'] = $course_code;
58
+                    $exercise_item['session_id'] = $session_id;
59
+                    $exercise_item['tms'] = api_strtotime($exercise_item['end_time'], 'UTC');
60 60
 
61 61
                     $exercise_list[] = $exercise_item;
62 62
                 }
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
                 }
171 171
             }
172 172
 
173
-            if ($show_menu && ($show_create_link || $show_course_link )) {
173
+            if ($show_menu && ($show_create_link || $show_course_link)) {
174 174
                 $show_menu = true;
175 175
             } else {
176 176
                 $show_menu = false;
@@ -182,14 +182,14 @@  discard block
 block discarded – undo
182 182
         if ($show_menu) {
183 183
             $html .= '<ul class="nav nav-pills nav-stacked">';
184 184
             if ($show_create_link) {
185
-                $html .= '<li class="add-course"><a href="' . api_get_path(WEB_CODE_PATH) . 'create_course/add_course.php">'.Display::return_icon('new-course.png',  get_lang('CourseCreate')).(api_get_setting('course_validation') == 'true' ? get_lang('CreateCourseRequest') : get_lang('CourseCreate')).'</a></li>';
185
+                $html .= '<li class="add-course"><a href="'.api_get_path(WEB_CODE_PATH).'create_course/add_course.php">'.Display::return_icon('new-course.png', get_lang('CourseCreate')).(api_get_setting('course_validation') == 'true' ? get_lang('CreateCourseRequest') : get_lang('CourseCreate')).'</a></li>';
186 186
             }
187 187
 
188 188
             if ($show_course_link) {
189 189
                 if (!api_is_drh() && !api_is_session_admin()) {
190
-                    $html .=  '<li class="list-course"><a href="'. api_get_path(WEB_CODE_PATH) . 'auth/courses.php">'. Display::return_icon('catalog-course.png', get_lang('CourseCatalog')) .get_lang('CourseCatalog').'</a></li>';
190
+                    $html .= '<li class="list-course"><a href="'.api_get_path(WEB_CODE_PATH).'auth/courses.php">'.Display::return_icon('catalog-course.png', get_lang('CourseCatalog')).get_lang('CourseCatalog').'</a></li>';
191 191
                 } else {
192
-                    $html .= '<li><a href="' . api_get_path(WEB_CODE_PATH) . 'dashboard/index.php">'.get_lang('Dashboard').'</a></li>';
192
+                    $html .= '<li><a href="'.api_get_path(WEB_CODE_PATH).'dashboard/index.php">'.get_lang('Dashboard').'</a></li>';
193 193
                 }
194 194
             }
195 195
             $html .= '</ul>';
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
         $html = '';
214 214
 
215 215
         if (!empty($_GET['include']) && preg_match('/^[a-zA-Z0-9_-]*\.html$/', $_GET['include'])) {
216
-            $open = @(string)file_get_contents(api_get_path(SYS_PATH).$this->home.$_GET['include']);
216
+            $open = @(string) file_get_contents(api_get_path(SYS_PATH).$this->home.$_GET['include']);
217 217
             $html = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
218 218
         } else {
219 219
             // Hiding home top when user not connected.
@@ -243,15 +243,15 @@  discard block
 block discarded – undo
243 243
                     $home_top_temp = file_get_contents($this->home.'home_top.html');
244 244
                 } else {
245 245
                     if (file_exists($this->default_home.'home_top.html')) {
246
-                        $home_top_temp = file_get_contents($this->default_home . 'home_top.html');
246
+                        $home_top_temp = file_get_contents($this->default_home.'home_top.html');
247 247
                     }
248 248
                 }
249 249
             }
250 250
 
251 251
 			if (trim($home_top_temp) == '' && api_is_platform_admin()) {
252
-				$home_top_temp = '<div class="welcome-mascot">' . get_lang('PortalHomepageDefaultIntroduction') . '</div>';
252
+				$home_top_temp = '<div class="welcome-mascot">'.get_lang('PortalHomepageDefaultIntroduction').'</div>';
253 253
 			} else {
254
-				$home_top_temp = '<div class="welcome-home-top-temp">' . $home_top_temp . '</div>';
254
+				$home_top_temp = '<div class="welcome-home-top-temp">'.$home_top_temp.'</div>';
255 255
 			}
256 256
 			$open = str_replace('{rel_path}', api_get_path(REL_PATH), $home_top_temp);
257 257
 			$html = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
@@ -267,9 +267,9 @@  discard block
 block discarded – undo
267 267
 
268 268
         $html = '';
269 269
         // Notice
270
-        $home_notice = @(string)file_get_contents($sys_path.$this->home.'home_notice_'.$user_selected_language.'.html');
270
+        $home_notice = @(string) file_get_contents($sys_path.$this->home.'home_notice_'.$user_selected_language.'.html');
271 271
         if (empty($home_notice)) {
272
-            $home_notice = @(string)file_get_contents($sys_path.$this->home.'home_notice.html');
272
+            $home_notice = @(string) file_get_contents($sys_path.$this->home.'home_notice.html');
273 273
         }
274 274
 
275 275
         if (!empty($home_notice)) {
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
         }
295 295
 
296 296
         $html = null;
297
-        $home_menu = @(string)file_get_contents($sys_path.$this->home.'home_menu_'.$user_selected_language.'.html');
297
+        $home_menu = @(string) file_get_contents($sys_path.$this->home.'home_menu_'.$user_selected_language.'.html');
298 298
         if (!empty($home_menu)) {
299 299
             $home_menu_content = '<ul class="nav nav-pills nav-stacked">';
300 300
             $home_menu_content .= api_to_system_encoding($home_menu, api_detect_encoding(strip_tags($home_menu)));
@@ -317,9 +317,9 @@  discard block
 block discarded – undo
317 317
         if (!api_is_anonymous()) {
318 318
             $certificatesItem = Display::tag(
319 319
                 'li',
320
-                Display::url(Display::return_icon('graduation.png',get_lang('MyCertificates'),null,ICON_SIZE_SMALL).
320
+                Display::url(Display::return_icon('graduation.png', get_lang('MyCertificates'), null, ICON_SIZE_SMALL).
321 321
                     get_lang('MyCertificates'),
322
-                    api_get_path(WEB_CODE_PATH) . "gradebook/my_certificates.php"
322
+                    api_get_path(WEB_CODE_PATH)."gradebook/my_certificates.php"
323 323
                 )
324 324
             );
325 325
         }
@@ -329,29 +329,29 @@  discard block
 block discarded – undo
329 329
         if (api_get_setting('allow_public_certificates') == 'true') {
330 330
             $searchItem = Display::tag(
331 331
                 'li',
332
-                Display::url(Display::return_icon('search_graduation.png',get_lang('Search'),null,ICON_SIZE_SMALL).
332
+                Display::url(Display::return_icon('search_graduation.png', get_lang('Search'), null, ICON_SIZE_SMALL).
333 333
                     get_lang('Search'),
334
-                    api_get_path(WEB_CODE_PATH) . "gradebook/search.php"
334
+                    api_get_path(WEB_CODE_PATH)."gradebook/search.php"
335 335
                 )
336 336
             );
337 337
         }
338 338
 
339 339
         if (empty($certificatesItem) && empty($searchItem)) {
340 340
             return null;
341
-        }else{
342
-            $content.= $certificatesItem;
343
-            $content.= $searchItem;
341
+        } else {
342
+            $content .= $certificatesItem;
343
+            $content .= $searchItem;
344 344
         }
345 345
 
346 346
         if (api_get_setting('allow_skills_tool') == 'true') {
347 347
 
348
-            $content .= Display::tag('li', Display::url(Display::return_icon('skill-badges.png',get_lang('MySkills'),null,ICON_SIZE_SMALL).get_lang('MySkills'), api_get_path(WEB_CODE_PATH).'social/my_skills_report.php'));
348
+            $content .= Display::tag('li', Display::url(Display::return_icon('skill-badges.png', get_lang('MySkills'), null, ICON_SIZE_SMALL).get_lang('MySkills'), api_get_path(WEB_CODE_PATH).'social/my_skills_report.php'));
349 349
             $allowSkillsManagement = api_get_setting('allow_hr_skills_management') == 'true';
350 350
             if (($allowSkillsManagement && api_is_drh()) || api_is_platform_admin()) {
351 351
                 $content .= Display::tag('li',
352 352
                     Display::url(Display::return_icon('edit-skill.png', get_lang('MySkills'), null,
353
-                            ICON_SIZE_SMALL) . get_lang('ManageSkills'),
354
-                        api_get_path(WEB_CODE_PATH) . 'admin/skills_wheel.php'));
353
+                            ICON_SIZE_SMALL).get_lang('ManageSkills'),
354
+                        api_get_path(WEB_CODE_PATH).'admin/skills_wheel.php'));
355 355
             }
356 356
         }
357 357
         $content .= '</ul>';
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
                     FROM $main_category_table t1
451 451
                     LEFT JOIN $main_category_table t2 ON t1.code=t2.parent_id
452 452
                     LEFT JOIN $main_course_table t3 ON (t3.category_code = t1.code $platform_visible_courses)
453
-                    WHERE t1.parent_id ". (empty ($category) ? "IS NULL" : "='$category'")."
453
+                    WHERE t1.parent_id ".(empty ($category) ? "IS NULL" : "='$category'")."
454 454
                     GROUP BY t1.name,t1.code,t1.parent_id,t1.children_count ORDER BY t1.tree_pos, t1.name";
455 455
 
456 456
         // Showing only the category of courses of the current access_url_id
@@ -527,10 +527,10 @@  discard block
 block discarded – undo
527 527
         }
528 528
         $result .= $htmlTitre;
529 529
         if ($thereIsSubCat) {
530
-            $result .=  $htmlListCat;
530
+            $result .= $htmlListCat;
531 531
         }
532 532
         while ($categoryName = Database::fetch_array($resCats)) {
533
-            $result .= '<h3>' . $categoryName['name'] . "</h3>\n";
533
+            $result .= '<h3>'.$categoryName['name']."</h3>\n";
534 534
         }
535 535
         $numrows = Database::num_rows($sql_result_courses);
536 536
         $courses_list_string = '';
@@ -628,12 +628,12 @@  discard block
 block discarded – undo
628 628
         if ($courses_shown > 0) {
629 629
             // Only display the list of courses and categories if there was more than
630 630
                     // 0 courses visible to the world (we're in the anonymous list here).
631
-            $result .=  $courses_list_string;
631
+            $result .= $courses_list_string;
632 632
         }
633 633
         if ($category != '') {
634
-            $result .=  '<p><a href="'.api_get_self().'"> ' .
634
+            $result .= '<p><a href="'.api_get_self().'"> '.
635 635
                 Display :: return_icon('back.png', get_lang('BackToHomePage')).
636
-                get_lang('BackToHomePage') . '</a></p>';
636
+                get_lang('BackToHomePage').'</a></p>';
637 637
         }
638 638
         return $result;
639 639
     }
@@ -697,14 +697,14 @@  discard block
 block discarded – undo
697 697
     {
698 698
         if (!empty($idAccordion)) {
699 699
             $html = null;
700
-            $html .= '<div class="panel-group" id="'.$idAccordion.'" role="tablist" aria-multiselectable="true">' . PHP_EOL;
701
-            $html .= '<div class="panel panel-default" id="'.$id.'">' . PHP_EOL;
702
-            $html .= '<div class="panel-heading" role="tab"><h4 class="panel-title">' . PHP_EOL;
703
-            $html .= '<a role="button" data-toggle="collapse" data-parent="#'.$idAccordion.'" href="#'.$idCollpase.'" aria-expanded="true" aria-controls="'.$idCollpase.'">'.$title.'</a>' . PHP_EOL;
704
-            $html .= '</h4></div>' . PHP_EOL;
705
-            $html .= '<div id="'.$idCollpase.'" class="panel-collapse collapse in" role="tabpanel">' . PHP_EOL;
706
-            $html .= '<div class="panel-body">'.$content.'</div>' . PHP_EOL;
707
-            $html .= '</div></div></div>' . PHP_EOL;
700
+            $html .= '<div class="panel-group" id="'.$idAccordion.'" role="tablist" aria-multiselectable="true">'.PHP_EOL;
701
+            $html .= '<div class="panel panel-default" id="'.$id.'">'.PHP_EOL;
702
+            $html .= '<div class="panel-heading" role="tab"><h4 class="panel-title">'.PHP_EOL;
703
+            $html .= '<a role="button" data-toggle="collapse" data-parent="#'.$idAccordion.'" href="#'.$idCollpase.'" aria-expanded="true" aria-controls="'.$idCollpase.'">'.$title.'</a>'.PHP_EOL;
704
+            $html .= '</h4></div>'.PHP_EOL;
705
+            $html .= '<div id="'.$idCollpase.'" class="panel-collapse collapse in" role="tabpanel">'.PHP_EOL;
706
+            $html .= '<div class="panel-body">'.$content.'</div>'.PHP_EOL;
707
+            $html .= '</div></div></div>'.PHP_EOL;
708 708
 
709 709
         } else {
710 710
             if (!empty($id)) {
@@ -713,9 +713,9 @@  discard block
 block discarded – undo
713 713
             $params['class'] = 'panel panel-default';
714 714
             $html = null;
715 715
             if (!empty($title)) {
716
-                $html .= '<div class="panel-heading">'.$title.'</div>' . PHP_EOL;
716
+                $html .= '<div class="panel-heading">'.$title.'</div>'.PHP_EOL;
717 717
             }
718
-            $html.= '<div class="panel-body">'.$content.'</div>' . PHP_EOL;
718
+            $html .= '<div class="panel-body">'.$content.'</div>'.PHP_EOL;
719 719
             $html = Display::div($html, $params);
720 720
         }
721 721
         return $html;
@@ -761,7 +761,7 @@  discard block
 block discarded – undo
761 761
             $usergroup_list = $usergroup->get_usergroup_by_user(api_get_user_id());
762 762
             $classes = '';
763 763
             if (!empty($usergroup_list)) {
764
-                foreach($usergroup_list as $group_id) {
764
+                foreach ($usergroup_list as $group_id) {
765 765
                     $data = $usergroup->get($group_id);
766 766
                     $data['name'] = Display::url($data['name'], api_get_path(WEB_CODE_PATH).'user/classes.php?id='.$data['id']);
767 767
                     $classes .= Display::tag('li', $data['name']);
@@ -770,7 +770,7 @@  discard block
 block discarded – undo
770 770
             if (api_is_platform_admin()) {
771 771
                 $classes .= Display::tag(
772 772
                     'li',
773
-                    Display::url(get_lang('AddClasses') ,api_get_path(WEB_CODE_PATH).'admin/usergroups.php?action=add')
773
+                    Display::url(get_lang('AddClasses'), api_get_path(WEB_CODE_PATH).'admin/usergroups.php?action=add')
774 774
                 );
775 775
             }
776 776
             if (!empty($classes)) {
@@ -792,11 +792,11 @@  discard block
 block discarded – undo
792 792
             $content = null;
793 793
 
794 794
             if (api_get_setting('allow_social_tool') == 'true') {
795
-                $content .= '<a style="text-align:center" href="' . api_get_path(WEB_PATH) . 'main/social/home.php">
796
-                <img class="img-circle" src="' . $userPicture . '" ></a>';
795
+                $content .= '<a style="text-align:center" href="'.api_get_path(WEB_PATH).'main/social/home.php">
796
+                <img class="img-circle" src="' . $userPicture.'" ></a>';
797 797
             } else {
798
-                $content .= '<a style="text-align:center" href="' . api_get_path(WEB_PATH) . 'main/auth/profile.php">
799
-                <img class="img-circle" title="' . get_lang('EditProfile') . '" src="' . $userPicture. '" ></a>';
798
+                $content .= '<a style="text-align:center" href="'.api_get_path(WEB_PATH).'main/auth/profile.php">
799
+                <img class="img-circle" title="' . get_lang('EditProfile').'" src="'.$userPicture.'" ></a>';
800 800
             }
801 801
 
802 802
             $html = self::show_right_block(
@@ -848,12 +848,12 @@  discard block
 block discarded – undo
848 848
             if (api_get_setting('allow_social_tool') == 'true') {
849 849
                 $link = '?f=social';
850 850
             }
851
-            $profile_content .= '<li class="inbox-message-social"><a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php'.$link.'">'.Display::return_icon('inbox.png',get_lang('Inbox'),null,ICON_SIZE_SMALL).get_lang('Inbox').$cant_msg.' </a></li>';
852
-            $profile_content .= '<li class="new-message-social"><a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php'.$link.'">'.Display::return_icon('new-message.png',get_lang('Compose'),null,ICON_SIZE_SMALL).get_lang('Compose').' </a></li>';
851
+            $profile_content .= '<li class="inbox-message-social"><a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php'.$link.'">'.Display::return_icon('inbox.png', get_lang('Inbox'), null, ICON_SIZE_SMALL).get_lang('Inbox').$cant_msg.' </a></li>';
852
+            $profile_content .= '<li class="new-message-social"><a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php'.$link.'">'.Display::return_icon('new-message.png', get_lang('Compose'), null, ICON_SIZE_SMALL).get_lang('Compose').' </a></li>';
853 853
 
854 854
             if (api_get_setting('allow_social_tool') == 'true') {
855 855
                 $total_invitations = Display::badge($total_invitations);
856
-                $profile_content .= '<li class="invitations-social"><a href="'.api_get_path(WEB_PATH).'main/social/invitations.php">'.Display::return_icon('invitations.png',get_lang('PendingInvitations'),null,ICON_SIZE_SMALL).get_lang('PendingInvitations').$total_invitations.'</a></li>';
856
+                $profile_content .= '<li class="invitations-social"><a href="'.api_get_path(WEB_PATH).'main/social/invitations.php">'.Display::return_icon('invitations.png', get_lang('PendingInvitations'), null, ICON_SIZE_SMALL).get_lang('PendingInvitations').$total_invitations.'</a></li>';
857 857
             }
858 858
 
859 859
             if (isset($_configuration['allow_my_files_link_in_homepage']) && $_configuration['allow_my_files_link_in_homepage']) {
@@ -869,7 +869,7 @@  discard block
 block discarded – undo
869 869
 
870 870
         $editProfileUrl = Display::getProfileEditionLink($user_id);
871 871
 
872
-        $profile_content .= '<li class="profile-social"><a href="' . $editProfileUrl . '">'.Display::return_icon('edit-profile.png',get_lang('EditProfile'),null,ICON_SIZE_SMALL).get_lang('EditProfile').'</a></li>';
872
+        $profile_content .= '<li class="profile-social"><a href="'.$editProfileUrl.'">'.Display::return_icon('edit-profile.png', get_lang('EditProfile'), null, ICON_SIZE_SMALL).get_lang('EditProfile').'</a></li>';
873 873
         $profile_content .= '</ul>';
874 874
         $html = self::show_right_block(
875 875
             get_lang('Profile'),
@@ -944,17 +944,17 @@  discard block
 block discarded – undo
944 944
         if ($show_create_link) {
945 945
             $my_account_content .= '<li class="add-course"><a href="main/create_course/add_course.php">';
946 946
             if (api_get_setting('course_validation') == 'true' && !api_is_platform_admin()) {
947
-                $my_account_content .= Display::return_icon('new-course.png',get_lang('CreateCourseRequest'),null,ICON_SIZE_SMALL);
947
+                $my_account_content .= Display::return_icon('new-course.png', get_lang('CreateCourseRequest'), null, ICON_SIZE_SMALL);
948 948
                 $my_account_content .= get_lang('CreateCourseRequest');
949 949
             } else {
950
-                $my_account_content .= Display::return_icon('new-course.png',get_lang('CourseCreate'),null,ICON_SIZE_SMALL);
950
+                $my_account_content .= Display::return_icon('new-course.png', get_lang('CourseCreate'), null, ICON_SIZE_SMALL);
951 951
                 $my_account_content .= get_lang('CourseCreate');
952 952
             }
953 953
             $my_account_content .= '</a></li>';
954 954
 
955 955
             if (SessionManager::allowToManageSessions()) {
956 956
                 $my_account_content .= '<li class="add-course"><a href="main/session/session_add.php">';
957
-                $my_account_content .= Display::return_icon('session.png',get_lang('AddSession'),null,ICON_SIZE_SMALL);
957
+                $my_account_content .= Display::return_icon('session.png', get_lang('AddSession'), null, ICON_SIZE_SMALL);
958 958
                 $my_account_content .= get_lang('AddSession');
959 959
                 $my_account_content .= '</a></li>';
960 960
             }
@@ -962,21 +962,21 @@  discard block
 block discarded – undo
962 962
 
963 963
         //Sort courses
964 964
         $url = api_get_path(WEB_CODE_PATH).'auth/courses.php?action=sortmycourses';
965
-        $img_order= Display::return_icon('order-course.png',get_lang('SortMyCourses'),null,ICON_SIZE_SMALL);
965
+        $img_order = Display::return_icon('order-course.png', get_lang('SortMyCourses'), null, ICON_SIZE_SMALL);
966 966
         $my_account_content .= '<li class="order-course">'.Display::url($img_order.get_lang('SortMyCourses'), $url, array('class' => 'sort course')).'</li>';
967 967
 
968 968
         // Session history
969 969
         if (isset($_GET['history']) && intval($_GET['history']) == 1) {
970
-            $my_account_content .= '<li class="history-course"><a href="user_portal.php">'.Display::return_icon('history-course.png',get_lang('DisplayTrainingList'),null,ICON_SIZE_SMALL).get_lang('DisplayTrainingList').'</a></li>';
970
+            $my_account_content .= '<li class="history-course"><a href="user_portal.php">'.Display::return_icon('history-course.png', get_lang('DisplayTrainingList'), null, ICON_SIZE_SMALL).get_lang('DisplayTrainingList').'</a></li>';
971 971
         } else {
972
-            $my_account_content .= '<li class="history-course"><a href="user_portal.php?history=1" >'.Display::return_icon('history-course.png',get_lang('HistoryTrainingSessions'),null,ICON_SIZE_SMALL).get_lang('HistoryTrainingSessions').'</a></li>';
972
+            $my_account_content .= '<li class="history-course"><a href="user_portal.php?history=1" >'.Display::return_icon('history-course.png', get_lang('HistoryTrainingSessions'), null, ICON_SIZE_SMALL).get_lang('HistoryTrainingSessions').'</a></li>';
973 973
         }
974 974
 
975 975
         // Course catalog
976 976
 
977 977
         if ($show_course_link) {
978 978
             if (!api_is_drh()) {
979
-                $my_account_content .= '<li class="list-course"><a href="main/auth/courses.php" >'.Display::return_icon('catalog-course.png',get_lang('CourseCatalog'),null,ICON_SIZE_SMALL).get_lang('CourseCatalog').'</a></li>';
979
+                $my_account_content .= '<li class="list-course"><a href="main/auth/courses.php" >'.Display::return_icon('catalog-course.png', get_lang('CourseCatalog'), null, ICON_SIZE_SMALL).get_lang('CourseCatalog').'</a></li>';
980 980
             } else {
981 981
                 $my_account_content .= '<li><a href="main/dashboard/index.php">'.get_lang('Dashboard').'</a></li>';
982 982
             }
@@ -1153,10 +1153,10 @@  discard block
 block discarded – undo
1153 1153
 
1154 1154
                             $extra_info = !empty($session_box['coach']) ? $session_box['coach'] : null;
1155 1155
                             $extra_info .= !empty($session_box['coach'])
1156
-                                ? ' - ' . $session_box['dates']
1156
+                                ? ' - '.$session_box['dates']
1157 1157
                                 : $session_box['dates'];
1158 1158
                             $extra_info .= isset($session_box['duration'])
1159
-                                ? ' ' . $session_box['duration']
1159
+                                ? ' '.$session_box['duration']
1160 1160
                                 : null;
1161 1161
 
1162 1162
                             $params['extra_fields'] = $session_box['extra_fields'];
@@ -1276,8 +1276,8 @@  discard block
 block discarded – undo
1276 1276
                                 $sessionParams['show_link_to_session'] = !api_is_drh() && $sessionTitleLink;
1277 1277
                                 $sessionParams['title'] = $session_box['title'];
1278 1278
                                 $sessionParams['subtitle'] = (!empty($session_box['coach'])
1279
-                                    ? $session_box['coach'] . ' | '
1280
-                                    : '') . $session_box['dates'];
1279
+                                    ? $session_box['coach'].' | '
1280
+                                    : '').$session_box['dates'];
1281 1281
                                 $sessionParams['show_actions'] = api_is_platform_admin();
1282 1282
                                 $sessionParams['courses'] = $html_courses_session;
1283 1283
                                 $sessionParams['show_simple_session_info'] = false;
@@ -1327,14 +1327,14 @@  discard block
 block discarded – undo
1327 1327
                                 !empty($session_category_start_date) &&
1328 1328
                                 $session_category_start_date != '0000-00-00'
1329 1329
                             ) {
1330
-                                $categoryParams['subtitle'] = get_lang('From') . ' ' . $session_category_start_date;
1330
+                                $categoryParams['subtitle'] = get_lang('From').' '.$session_category_start_date;
1331 1331
                             }
1332 1332
 
1333 1333
                             if (
1334 1334
                                 !empty($session_category_end_date) &&
1335 1335
                                 $session_category_end_date != '0000-00-00'
1336 1336
                             ) {
1337
-                                $categoryParams['subtitle'] = get_lang('Until') . ' ' . $session_category_end_date;
1337
+                                $categoryParams['subtitle'] = get_lang('Until').' '.$session_category_end_date;
1338 1338
                             }
1339 1339
                         }
1340 1340
 
@@ -1408,7 +1408,7 @@  discard block
 block discarded – undo
1408 1408
         if ($load_history) {
1409 1409
             $html .= Display::page_subheader(get_lang('HistoryTrainingSession'));
1410 1410
             if (empty($session_categories)) {
1411
-                $html .=  get_lang('YouDoNotHaveAnySessionInItsHistory');
1411
+                $html .= get_lang('YouDoNotHaveAnySessionInItsHistory');
1412 1412
             }
1413 1413
         }
1414 1414
 
@@ -1481,7 +1481,7 @@  discard block
 block discarded – undo
1481 1481
                     } else {
1482 1482
                         $htmlCategory .= '<div class="session-view-row" >';
1483 1483
                     }
1484
-                    $coursesInfo =  $listCourse['course'];
1484
+                    $coursesInfo = $listCourse['course'];
1485 1485
 
1486 1486
                     $htmlCategory .= self::getHtmlForCourse(
1487 1487
                         $coursesInfo,
@@ -1498,7 +1498,7 @@  discard block
 block discarded – undo
1498 1498
                             $listCategorySession['catSessionName']
1499 1499
                         );
1500 1500
                         // list of session
1501
-                        $htmlSession = '';    // start
1501
+                        $htmlSession = ''; // start
1502 1502
                         foreach ($listCategorySession['sessionList'] as $k => $listSession) {
1503 1503
                             // add session
1504 1504
                             $htmlSession .= '<div class="session-view-row">';
@@ -1515,8 +1515,8 @@  discard block
 block discarded – undo
1515 1515
                         $htmlSessionCategory .= $htmlSession;
1516 1516
                     }
1517 1517
                     $htmlSessionCategory .= '</div>'; // end session cat block
1518
-                    $htmlCategory .=  $htmlSessionCategory .'</div>' ;
1519
-                    $htmlCategory .= '';   // end course block
1518
+                    $htmlCategory .= $htmlSessionCategory.'</div>';
1519
+                    $htmlCategory .= ''; // end course block
1520 1520
                 }
1521 1521
                 $userCategoryHtml .= $htmlCategory;
1522 1522
             }
@@ -1541,11 +1541,11 @@  discard block
 block discarded – undo
1541 1541
                 }
1542 1542
             }
1543 1543
             $htmlCategory .= '';
1544
-            $userCategoryHtml .= $htmlCategory;   // end user cat block
1544
+            $userCategoryHtml .= $htmlCategory; // end user cat block
1545 1545
             if ($userCategoryId != 0) {
1546 1546
                 $userCategoryHtml .= '</div>';
1547 1547
             }
1548
-            $html .= $userCategoryHtml;   //
1548
+            $html .= $userCategoryHtml; //
1549 1549
         }
1550 1550
         $html .= '</div>';
1551 1551
 
@@ -1686,11 +1686,11 @@  discard block
 block discarded – undo
1686 1686
         $html = '';
1687 1687
 
1688 1688
         if ($categorySessionId == 0) {
1689
-            $class1 = 'session-view-lvl-2';    // session
1690
-            $class2 = 'session-view-lvl-4';    // got to course in session link
1689
+            $class1 = 'session-view-lvl-2'; // session
1690
+            $class2 = 'session-view-lvl-4'; // got to course in session link
1691 1691
         } else {
1692
-            $class1 = 'session-view-lvl-3';    // session
1693
-            $class2 = 'session-view-lvl-5';    // got to course in session link
1692
+            $class1 = 'session-view-lvl-3'; // session
1693
+            $class2 = 'session-view-lvl-5'; // got to course in session link
1694 1694
         }
1695 1695
 
1696 1696
         $icon = Display::return_icon(
@@ -1718,7 +1718,7 @@  discard block
 block discarded – undo
1718 1718
         if ($listA['userCatTitle'] == $listB['userCatTitle']) {
1719 1719
             if ($listA['title'] == $listB['title']) {
1720 1720
                 return 0;
1721
-            } else if($listA['title'] > $listB['title']) {
1721
+            } else if ($listA['title'] > $listB['title']) {
1722 1722
                 return 1;
1723 1723
             } else {
1724 1724
                 return -1;
@@ -1739,7 +1739,7 @@  discard block
 block discarded – undo
1739 1739
     {
1740 1740
         if ($listA['title'] == $listB['title']) {
1741 1741
             return 0;
1742
-        } else if($listA['title'] > $listB['title']) {
1742
+        } else if ($listA['title'] > $listB['title']) {
1743 1743
             return 1;
1744 1744
         } else {
1745 1745
             return -1;
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -338,7 +338,7 @@
 block discarded – undo
338 338
 
339 339
         if (empty($certificatesItem) && empty($searchItem)) {
340 340
             return null;
341
-        }else{
341
+        } else{
342 342
             $content.= $certificatesItem;
343 343
             $content.= $searchItem;
344 344
         }
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.
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
-	function xajax($sRequestURI="",$sWrapperPrefix="xajax_",$sEncoding=XAJAX_DEFAULT_CHAR_ENCODING,$bDebug=false)
170
+	function xajax($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.
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   +1198 added lines, -1198 removed lines patch added patch discarded remove patch
@@ -1,38 +1,38 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * xajax.inc.php :: Main xajax class and setup file
4
- *
5
- * xajax version 0.2.4
6
- * copyright (c) 2005 by Jared White & J. Max Wilson
7
- * http://www.xajaxproject.org
8
- *
9
- * xajax is an open source PHP class library for easily creating powerful
10
- * PHP-driven, web-based Ajax Applications. Using xajax, you can asynchronously
11
- * call PHP functions and update the content of your your webpage without
12
- * reloading the page.
13
- *
14
- * xajax is released under the terms of the LGPL license
15
- * http://www.gnu.org/copyleft/lesser.html#SEC3
16
- *
17
- * This library is free software; you can redistribute it and/or
18
- * modify it under the terms of the GNU Lesser General Public
19
- * License as published by the Free Software Foundation; either
20
- * version 2.1 of the License, or (at your option) any later version.
21
- *
22
- * This library is distributed in the hope that it will be useful,
23
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
24
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
25
- * Lesser General Public License for more details.
26
- *
27
- * You should have received a copy of the GNU Lesser General Public
28
- * License along with this library; if not, write to the Free Software
29
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
30
- *
31
- * @package chamilo.include.xajax
32
- * @version $Id: xajax.inc.php,v 1.1 2006/07/21 15:29:46 elixir_inter Exp $
33
- * @copyright Copyright (c) 2005-2006  by Jared White & J. Max Wilson
34
- * @license http://www.gnu.org/copyleft/lesser.html#SEC3 LGPL License
35
- */
3
+     * xajax.inc.php :: Main xajax class and setup file
4
+     *
5
+     * xajax version 0.2.4
6
+     * copyright (c) 2005 by Jared White & J. Max Wilson
7
+     * http://www.xajaxproject.org
8
+     *
9
+     * xajax is an open source PHP class library for easily creating powerful
10
+     * PHP-driven, web-based Ajax Applications. Using xajax, you can asynchronously
11
+     * call PHP functions and update the content of your your webpage without
12
+     * reloading the page.
13
+     *
14
+     * xajax is released under the terms of the LGPL license
15
+     * http://www.gnu.org/copyleft/lesser.html#SEC3
16
+     *
17
+     * This library is free software; you can redistribute it and/or
18
+     * modify it under the terms of the GNU Lesser General Public
19
+     * License as published by the Free Software Foundation; either
20
+     * version 2.1 of the License, or (at your option) any later version.
21
+     *
22
+     * This library is distributed in the hope that it will be useful,
23
+     * but WITHOUT ANY WARRANTY; without even the implied warranty of
24
+     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
25
+     * Lesser General Public License for more details.
26
+     *
27
+     * You should have received a copy of the GNU Lesser General Public
28
+     * License along with this library; if not, write to the Free Software
29
+     * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
30
+     *
31
+     * @package chamilo.include.xajax
32
+     * @version $Id: xajax.inc.php,v 1.1 2006/07/21 15:29:46 elixir_inter Exp $
33
+     * @copyright Copyright (c) 2005-2006  by Jared White & J. Max Wilson
34
+     * @license http://www.gnu.org/copyleft/lesser.html#SEC3 LGPL License
35
+     */
36 36
 
37 37
 /*
38 38
    ----------------------------------------------------------------------------
@@ -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
-	function xajax($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
+    function xajax($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.