Completed
Push — 1.11.x ( 5faee1...f8e4c1 )
by José
88:29 queued 45:39
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/urlmanager.lib.php 4 patches
Doc Comments   +16 added lines, -14 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
     * @param	string	$url The URL of the site
19 19
     * @param	string  $description The description of the site
20 20
     * @param	int		$active is active or not
21
-    * @return boolean if success
21
+    * @return Doctrine\DBAL\Driver\Statement|null if success
22 22
     */
23 23
     public static function add($url, $description, $active)
24 24
     {
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
     * @param	string 	$url
44 44
     * @param	string  $description The description of the site
45 45
     * @param	int		$active is active or not
46
-    * @return 	boolean if success
46
+    * @return 	Doctrine\DBAL\Driver\Statement|null if success
47 47
     */
48 48
     public static function update($url_id, $url, $description, $active)
49 49
     {
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
     * @author Julio Montoya
68 68
     * @param int $id url id
69 69
      *
70
-    * @return boolean true if success
70
+    * @return Doctrine\DBAL\Driver\Statement|null true if success
71 71
     * */
72 72
     public static function delete($id)
73 73
     {
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
     * @author Julio Montoya
367 367
     * @param int user id
368 368
     * @param int url id
369
-    * @return boolean true if success
369
+    * @return integer true if success
370 370
     * */
371 371
     public static function relation_url_user_exist($user_id, $url_id)
372 372
     {
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
     * @author Julio Montoya
385 385
     * @param int $courseId
386 386
     * @param int $urlId
387
-    * @return boolean true if success
387
+    * @return integer true if success
388 388
     * */
389 389
     public static function relation_url_course_exist($courseId, $urlId)
390 390
     {
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
      * @author Julio Montoya
406 406
      * @param int $userGroupId
407 407
      * @param int $urlId
408
-     * @return boolean true if success
408
+     * @return integer true if success
409 409
      * */
410 410
     public static function relationUrlUsergroupExist($userGroupId, $urlId)
411 411
     {
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
     * @author Julio Montoya
425 425
     * @param int user id
426 426
     * @param int url id
427
-    * @return boolean true if success
427
+    * @return integer true if success
428 428
     * */
429 429
     public static function relation_url_session_exist($session_id, $url_id)
430 430
     {
@@ -545,6 +545,8 @@  discard block
 block discarded – undo
545 545
      * @author Julio Montoya
546 546
      * @param  array of course ids
547 547
      * @param  array of url_ids
548
+     * @param integer[] $courseCategoryList
549
+     * @param integer[] $urlList
548 550
      * @return array
549 551
      **/
550 552
     public static function addCourseCategoryListToUrl($courseCategoryList, $urlList)
@@ -575,7 +577,7 @@  discard block
 block discarded – undo
575 577
      * @author Julio Montoya
576 578
      * @param int $categoryCourseId
577 579
      * @param int $urlId
578
-     * @return boolean true if success
580
+     * @return integer true if success
579 581
      * */
580 582
     public static function relationUrlCourseCategoryExist($categoryCourseId, $urlId)
581 583
     {
@@ -592,7 +594,7 @@  discard block
 block discarded – undo
592 594
     /**
593 595
      * @param int $userGroupId
594 596
      * @param int $urlId
595
-     * @return int
597
+     * @return string
596 598
      */
597 599
     public static function addUserGroupToUrl($userGroupId, $urlId)
598 600
     {
@@ -692,7 +694,7 @@  discard block
 block discarded – undo
692 694
      * @param int $courseId
693 695
      * @param int $url_id
694 696
      *
695
-     * @return resource
697
+     * @return boolean
696 698
      */
697 699
     public static function add_course_to_url($courseId, $url_id = 1)
698 700
     {
@@ -763,7 +765,7 @@  discard block
 block discarded – undo
763 765
     * @param  int  $courseId
764 766
     * @param  int  $urlId
765 767
      *
766
-    * @return boolean true if success
768
+    * @return Doctrine\DBAL\Driver\Statement|null true if success
767 769
     * */
768 770
     public static function delete_url_rel_course($courseId, $urlId)
769 771
     {
@@ -781,7 +783,7 @@  discard block
 block discarded – undo
781 783
      * @param  int $userGroupId
782 784
      * @param  int $urlId
783 785
      *
784
-     * @return boolean true if success
786
+     * @return Doctrine\DBAL\Driver\Statement|null true if success
785 787
      * */
786 788
     public static function delete_url_rel_usergroup($userGroupId, $urlId)
787 789
     {
@@ -800,7 +802,7 @@  discard block
 block discarded – undo
800 802
      * @param  int $userGroupId
801 803
      * @param  int $urlId
802 804
      *
803
-     * @return boolean true if success
805
+     * @return Doctrine\DBAL\Driver\Statement|null true if success
804 806
      * */
805 807
     public static function deleteUrlRelCourseCategory($userGroupId, $urlId)
806 808
     {
@@ -819,7 +821,7 @@  discard block
 block discarded – undo
819 821
     * @param  char  course code
820 822
     * @param  int url id
821 823
      *
822
-    * @return boolean true if success
824
+    * @return Doctrine\DBAL\Driver\Statement|null true if success
823 825
     * */
824 826
     public static function delete_url_rel_session($session_id, $url_id)
825 827
     {
Please login to merge, or discard this patch.
Indentation   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -11,15 +11,15 @@  discard block
 block discarded – undo
11 11
 class UrlManager
12 12
 {
13 13
     /**
14
-    * Creates a new url access
15
-    *
16
-    * @author Julio Montoya <[email protected]>,
17
-    *
18
-    * @param	string	$url The URL of the site
19
-    * @param	string  $description The description of the site
20
-    * @param	int		$active is active or not
21
-    * @return boolean if success
22
-    */
14
+     * Creates a new url access
15
+     *
16
+     * @author Julio Montoya <[email protected]>,
17
+     *
18
+     * @param	string	$url The URL of the site
19
+     * @param	string  $description The description of the site
20
+     * @param	int		$active is active or not
21
+     * @return boolean if success
22
+     */
23 23
     public static function add($url, $description, $active)
24 24
     {
25 25
         $tms = time();
@@ -36,15 +36,15 @@  discard block
 block discarded – undo
36 36
     }
37 37
 
38 38
     /**
39
-    * Updates an URL access
40
-    * @author Julio Montoya <[email protected]>,
41
-    *
42
-    * @param	int 	$url_id The url id
43
-    * @param	string 	$url
44
-    * @param	string  $description The description of the site
45
-    * @param	int		$active is active or not
46
-    * @return 	boolean if success
47
-    */
39
+     * Updates an URL access
40
+     * @author Julio Montoya <[email protected]>,
41
+     *
42
+     * @param	int 	$url_id The url id
43
+     * @param	string 	$url
44
+     * @param	string  $description The description of the site
45
+     * @param	int		$active is active or not
46
+     * @return 	boolean if success
47
+     */
48 48
     public static function update($url_id, $url, $description, $active)
49 49
     {
50 50
         $url_id = intval($url_id);
@@ -63,12 +63,12 @@  discard block
 block discarded – undo
63 63
     }
64 64
 
65 65
     /**
66
-    * Deletes an url
67
-    * @author Julio Montoya
68
-    * @param int $id url id
66
+     * Deletes an url
67
+     * @author Julio Montoya
68
+     * @param int $id url id
69 69
      *
70
-    * @return boolean true if success
71
-    * */
70
+     * @return boolean true if success
71
+     * */
72 72
     public static function delete($id)
73 73
     {
74 74
         $id = intval($id);
@@ -200,12 +200,12 @@  discard block
 block discarded – undo
200 200
     }
201 201
 
202 202
     /**
203
-    * Gets the inner join of access_url and the course table
204
-    *
205
-    * @author Julio Montoya
206
-    * @param int  access url id
207
-    * @return array   Database::store_result of the result
208
-    **/
203
+     * Gets the inner join of access_url and the course table
204
+     *
205
+     * @author Julio Montoya
206
+     * @param int  access url id
207
+     * @return array   Database::store_result of the result
208
+     **/
209 209
     public static function get_url_rel_course_data($access_url_id = null)
210 210
     {
211 211
         $where = '';
@@ -362,12 +362,12 @@  discard block
 block discarded – undo
362 362
     }
363 363
 
364 364
     /**
365
-    * Checks the relationship between an URL and a User (return the num_rows)
366
-    * @author Julio Montoya
367
-    * @param int user id
368
-    * @param int url id
369
-    * @return boolean true if success
370
-    * */
365
+     * Checks the relationship between an URL and a User (return the num_rows)
366
+     * @author Julio Montoya
367
+     * @param int user id
368
+     * @param int url id
369
+     * @return boolean true if success
370
+     * */
371 371
     public static function relation_url_user_exist($user_id, $url_id)
372 372
     {
373 373
         $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
@@ -377,15 +377,15 @@  discard block
 block discarded – undo
377 377
         $num = Database::num_rows($result);
378 378
 
379 379
         return $num;
380
-	}
380
+    }
381 381
 
382 382
     /**
383
-    * Checks the relationship between an URL and a Course (return the num_rows)
384
-    * @author Julio Montoya
385
-    * @param int $courseId
386
-    * @param int $urlId
387
-    * @return boolean true if success
388
-    * */
383
+     * Checks the relationship between an URL and a Course (return the num_rows)
384
+     * @author Julio Montoya
385
+     * @param int $courseId
386
+     * @param int $urlId
387
+     * @return boolean true if success
388
+     * */
389 389
     public static function relation_url_course_exist($courseId, $urlId)
390 390
     {
391 391
         $table_url_rel_course = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
@@ -420,12 +420,12 @@  discard block
 block discarded – undo
420 420
     }
421 421
 
422 422
     /**
423
-    * Checks the relationship between an URL and a Session (return the num_rows)
424
-    * @author Julio Montoya
425
-    * @param int user id
426
-    * @param int url id
427
-    * @return boolean true if success
428
-    * */
423
+     * Checks the relationship between an URL and a Session (return the num_rows)
424
+     * @author Julio Montoya
425
+     * @param int user id
426
+     * @param int url id
427
+     * @return boolean true if success
428
+     * */
429 429
     public static function relation_url_session_exist($session_id, $url_id)
430 430
     {
431 431
         $table_url_rel_session= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
@@ -737,13 +737,13 @@  discard block
 block discarded – undo
737 737
     }
738 738
 
739 739
     /**
740
-    * Deletes an url and user relationship
741
-    * @author Julio Montoya
742
-    * @param int user id
743
-    * @param int url id
740
+     * Deletes an url and user relationship
741
+     * @author Julio Montoya
742
+     * @param int user id
743
+     * @param int url id
744 744
      *
745
-    * @return boolean true if success
746
-    * */
745
+     * @return boolean true if success
746
+     * */
747 747
     public static function delete_url_rel_user($user_id, $url_id)
748 748
     {
749 749
         $table_url_rel_user = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
@@ -758,13 +758,13 @@  discard block
 block discarded – undo
758 758
     }
759 759
 
760 760
     /**
761
-    * Deletes an url and course relationship
762
-    * @author Julio Montoya
763
-    * @param  int  $courseId
764
-    * @param  int  $urlId
761
+     * Deletes an url and course relationship
762
+     * @author Julio Montoya
763
+     * @param  int  $courseId
764
+     * @param  int  $urlId
765 765
      *
766
-    * @return boolean true if success
767
-    * */
766
+     * @return boolean true if success
767
+     * */
768 768
     public static function delete_url_rel_course($courseId, $urlId)
769 769
     {
770 770
         $table_url_rel_course= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
@@ -814,13 +814,13 @@  discard block
 block discarded – undo
814 814
     }
815 815
 
816 816
     /**
817
-    * Deletes an url and session relationship
818
-    * @author Julio Montoya
819
-    * @param  char  course code
820
-    * @param  int url id
817
+     * Deletes an url and session relationship
818
+     * @author Julio Montoya
819
+     * @param  char  course code
820
+     * @param  int url id
821 821
      *
822
-    * @return boolean true if success
823
-    * */
822
+     * @return boolean true if success
823
+     * */
824 824
     public static function delete_url_rel_session($session_id, $url_id)
825 825
     {
826 826
         $table_url_rel_session = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -262,8 +262,9 @@
 block discarded – undo
262 262
         $table_url_rel_session = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
263 263
         $tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION);
264 264
 
265
-        if (!empty($access_url_id))
266
-            $where ="WHERE $table_url_rel_session.access_url_id = ".intval($access_url_id);
265
+        if (!empty($access_url_id)) {
266
+                    $where ="WHERE $table_url_rel_session.access_url_id = ".intval($access_url_id);
267
+        }
267 268
 
268 269
         $sql = "SELECT id, name, access_url_id
269 270
                 FROM $tbl_session u
Please login to merge, or discard this patch.
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
     public static function add($url, $description, $active)
24 24
     {
25 25
         $tms = time();
26
-        $table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
26
+        $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
27 27
         $sql = "INSERT INTO $table
28 28
                 SET url 	= '".Database::escape_string($url)."',
29 29
                 description = '".Database::escape_string($description)."',
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
     {
74 74
         $id = intval($id);
75 75
         $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
76
-        $sql= "DELETE FROM $table WHERE id = ".$id;
76
+        $sql = "DELETE FROM $table WHERE id = ".$id;
77 77
         $result = Database::query($sql);
78 78
 
79 79
         return $result;
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
      */
87 87
     public static function url_exist($url)
88 88
     {
89
-        $table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
89
+        $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
90 90
         $sql = "SELECT id FROM $table
91 91
                 WHERE url = '".Database::escape_string($url)."' ";
92 92
         $res = Database::query($sql);
@@ -120,10 +120,10 @@  discard block
 block discarded – undo
120 120
      * */
121 121
     public static function url_count()
122 122
     {
123
-        $table_access_url= Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
123
+        $table_access_url = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
124 124
         $sql = "SELECT count(id) as count_result FROM $table_access_url";
125 125
         $res = Database::query($sql);
126
-        $url = Database::fetch_array($res,'ASSOC');
126
+        $url = Database::fetch_array($res, 'ASSOC');
127 127
         $result = $url['count_result'];
128 128
 
129 129
         return $result;
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
                 FROM $table
142 142
                 ORDER BY id";
143 143
         $res = Database::query($sql);
144
-        $urls = array ();
144
+        $urls = array();
145 145
         while ($url = Database::fetch_array($res)) {
146 146
             $urls[] = $url;
147 147
         }
@@ -258,12 +258,12 @@  discard block
 block discarded – undo
258 258
      **/
259 259
     public static function get_url_rel_session_data($access_url_id = null)
260 260
     {
261
-        $where ='';
261
+        $where = '';
262 262
         $table_url_rel_session = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
263 263
         $tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION);
264 264
 
265 265
         if (!empty($access_url_id))
266
-            $where ="WHERE $table_url_rel_session.access_url_id = ".intval($access_url_id);
266
+            $where = "WHERE $table_url_rel_session.access_url_id = ".intval($access_url_id);
267 267
 
268 268
         $sql = "SELECT id, name, access_url_id
269 269
                 FROM $tbl_session u
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
         $table_user_group = Database::get_main_table(TABLE_USERGROUP);
294 294
 
295 295
         if (!empty($access_url_id)) {
296
-            $where ="WHERE $table_url_rel_usergroup.access_url_id = ".intval($access_url_id);
296
+            $where = "WHERE $table_url_rel_usergroup.access_url_id = ".intval($access_url_id);
297 297
         }
298 298
 
299 299
         $sql = "SELECT id, name, access_url_id
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
     public static function relation_url_user_exist($user_id, $url_id)
372 372
     {
373 373
         $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
374
-        $sql= "SELECT user_id FROM $table
374
+        $sql = "SELECT user_id FROM $table
375 375
                WHERE access_url_id = ".intval($url_id)." AND user_id = ".intval($user_id)." ";
376 376
         $result = Database::query($sql);
377 377
         $num = Database::num_rows($result);
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
     public static function relation_url_course_exist($courseId, $urlId)
390 390
     {
391 391
         $table_url_rel_course = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
392
-        $sql= "SELECT c_id FROM $table_url_rel_course
392
+        $sql = "SELECT c_id FROM $table_url_rel_course
393 393
                WHERE
394 394
                     access_url_id = ".intval($urlId)." AND
395 395
                     c_id = '".intval($courseId)."'";
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
     public static function relationUrlUsergroupExist($userGroupId, $urlId)
411 411
     {
412 412
         $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USERGROUP);
413
-        $sql= "SELECT usergroup_id FROM $table
413
+        $sql = "SELECT usergroup_id FROM $table
414 414
                WHERE access_url_id = ".intval($urlId)." AND
415 415
                      usergroup_id = ".intval($userGroupId);
416 416
         $result = Database::query($sql);
@@ -428,9 +428,9 @@  discard block
 block discarded – undo
428 428
     * */
429 429
     public static function relation_url_session_exist($session_id, $url_id)
430 430
     {
431
-        $table_url_rel_session= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
431
+        $table_url_rel_session = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
432 432
         $session_id = intval($session_id);
433
-        $url_id		= intval($url_id);
433
+        $url_id = intval($url_id);
434 434
         $sql = "SELECT session_id FROM $table_url_rel_session
435 435
                 WHERE
436 436
                     access_url_id = ".intval($url_id)." AND
@@ -453,11 +453,11 @@  discard block
 block discarded – undo
453 453
         $table_url_rel_user = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
454 454
         $result_array = array();
455 455
 
456
-        if (is_array($user_list) && is_array($url_list)){
456
+        if (is_array($user_list) && is_array($url_list)) {
457 457
             foreach ($url_list as $url_id) {
458 458
                 foreach ($user_list as $user_id) {
459
-                    $count = UrlManager::relation_url_user_exist($user_id,$url_id);
460
-                    if ($count==0) {
459
+                    $count = UrlManager::relation_url_user_exist($user_id, $url_id);
460
+                    if ($count == 0) {
461 461
                         $sql = "INSERT INTO $table_url_rel_user
462 462
                                 SET user_id = ".intval($user_id).", access_url_id = ".intval($url_id);
463 463
                         $result = Database::query($sql);
@@ -482,19 +482,19 @@  discard block
 block discarded – undo
482 482
      * @param  array of url_ids
483 483
      * @return array
484 484
      **/
485
-    public static function add_courses_to_urls($course_list,$url_list)
485
+    public static function add_courses_to_urls($course_list, $url_list)
486 486
     {
487 487
         $table_url_rel_course = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
488 488
         $result_array = array();
489 489
 
490
-        if (is_array($course_list) && is_array($url_list)){
490
+        if (is_array($course_list) && is_array($url_list)) {
491 491
             foreach ($url_list as $url_id) {
492 492
                 foreach ($course_list as $course_code) {
493 493
                     $courseInfo = api_get_course_info($course_code);
494 494
                     $courseId = $courseInfo['real_id'];
495 495
 
496 496
                     $count = self::relation_url_course_exist($courseId, $url_id);
497
-                    if ($count==0) {
497
+                    if ($count == 0) {
498 498
                         $sql = "INSERT INTO $table_url_rel_course
499 499
                                 SET c_id = '".$courseId."', access_url_id = ".intval($url_id);
500 500
                         $result = Database::query($sql);
@@ -580,7 +580,7 @@  discard block
 block discarded – undo
580 580
     public static function relationUrlCourseCategoryExist($categoryCourseId, $urlId)
581 581
     {
582 582
         $table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE_CATEGORY);
583
-        $sql= "SELECT course_category_id FROM $table
583
+        $sql = "SELECT course_category_id FROM $table
584 584
                WHERE access_url_id = ".intval($urlId)." AND
585 585
                      course_category_id = ".intval($categoryCourseId);
586 586
         $result = Database::query($sql);
@@ -749,7 +749,7 @@  discard block
 block discarded – undo
749 749
         $table_url_rel_user = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
750 750
         $result = true;
751 751
         if (!empty($user_id) && !empty($url_id)) {
752
-            $sql= "DELETE FROM $table_url_rel_user
752
+            $sql = "DELETE FROM $table_url_rel_user
753 753
                    WHERE user_id = ".intval($user_id)." AND access_url_id = ".intval($url_id);
754 754
             $result = Database::query($sql);
755 755
         }
@@ -769,7 +769,7 @@  discard block
 block discarded – undo
769 769
         $table_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
770 770
         $result = true;
771 771
         if (!empty($userId)) {
772
-            $sql= "DELETE FROM $table_url_rel_user
772
+            $sql = "DELETE FROM $table_url_rel_user
773 773
                    WHERE user_id = ".intval($userId);
774 774
             Database::query($sql);
775 775
         }
@@ -787,8 +787,8 @@  discard block
 block discarded – undo
787 787
     * */
788 788
     public static function delete_url_rel_course($courseId, $urlId)
789 789
     {
790
-        $table_url_rel_course= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
791
-        $sql= "DELETE FROM $table_url_rel_course
790
+        $table_url_rel_course = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
791
+        $sql = "DELETE FROM $table_url_rel_course
792 792
                WHERE c_id = '".intval($courseId)."' AND access_url_id=".intval($urlId)."  ";
793 793
         $result = Database::query($sql);
794 794
 
@@ -806,7 +806,7 @@  discard block
 block discarded – undo
806 806
     public static function delete_url_rel_usergroup($userGroupId, $urlId)
807 807
     {
808 808
         $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USERGROUP);
809
-        $sql= "DELETE FROM $table
809
+        $sql = "DELETE FROM $table
810 810
                WHERE usergroup_id = '".intval($userGroupId)."' AND
811 811
                      access_url_id=".intval($urlId)."  ";
812 812
         $result = Database::query($sql);
@@ -825,7 +825,7 @@  discard block
 block discarded – undo
825 825
     public static function deleteUrlRelCourseCategory($userGroupId, $urlId)
826 826
     {
827 827
         $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE_CATEGORY);
828
-        $sql= "DELETE FROM $table
828
+        $sql = "DELETE FROM $table
829 829
                WHERE course_category_id = '".intval($userGroupId)."' AND
830 830
                      access_url_id=".intval($urlId)."  ";
831 831
         $result = Database::query($sql);
@@ -844,9 +844,9 @@  discard block
 block discarded – undo
844 844
     public static function delete_url_rel_session($session_id, $url_id)
845 845
     {
846 846
         $table_url_rel_session = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
847
-        $sql= "DELETE FROM $table_url_rel_session
847
+        $sql = "DELETE FROM $table_url_rel_session
848 848
                WHERE session_id = ".intval($session_id)." AND access_url_id=".intval($url_id)."  ";
849
-        $result = Database::query($sql,'ASSOC');
849
+        $result = Database::query($sql, 'ASSOC');
850 850
 
851 851
         return $result;
852 852
     }
@@ -859,7 +859,7 @@  discard block
 block discarded – undo
859 859
      * */
860 860
     public static function update_urls_rel_user($user_list, $access_url_id)
861 861
     {
862
-        $table_url_rel_user	= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
862
+        $table_url_rel_user = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
863 863
         $sql = "SELECT user_id FROM $table_url_rel_user WHERE access_url_id = ".intval($access_url_id);
864 864
         $result = Database::query($sql);
865 865
         $existing_users = array();
@@ -913,7 +913,7 @@  discard block
 block discarded – undo
913 913
         $result = Database::query($sql);
914 914
 
915 915
         $existing_courses = array();
916
-        while ($row = Database::fetch_array($result)){
916
+        while ($row = Database::fetch_array($result)) {
917 917
             $existing_courses[] = $row['c_id'];
918 918
         }
919 919
 
@@ -946,7 +946,7 @@  discard block
 block discarded – undo
946 946
         $result = Database::query($sql);
947 947
         $existingItems = array();
948 948
 
949
-        while ($row = Database::fetch_array($result)){
949
+        while ($row = Database::fetch_array($result)) {
950 950
             $existingItems[] = $row['usergroup_id'];
951 951
         }
952 952
 
@@ -979,7 +979,7 @@  discard block
 block discarded – undo
979 979
         $result = Database::query($sql);
980 980
         $existingItems = array();
981 981
 
982
-        while ($row = Database::fetch_array($result)){
982
+        while ($row = Database::fetch_array($result)) {
983 983
             $existingItems[] = $row['course_category_id'];
984 984
         }
985 985
 
@@ -1020,15 +1020,15 @@  discard block
 block discarded – undo
1020 1020
      * @param array user list
1021 1021
      * @param int access_url_id
1022 1022
      * */
1023
-    public static function update_urls_rel_session($session_list,$access_url_id)
1023
+    public static function update_urls_rel_session($session_list, $access_url_id)
1024 1024
     {
1025
-        $table_url_rel_session	= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
1025
+        $table_url_rel_session = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
1026 1026
 
1027 1027
         $sql = "SELECT session_id FROM $table_url_rel_session WHERE access_url_id=".intval($access_url_id);
1028 1028
         $result = Database::query($sql);
1029 1029
         $existing_sessions = array();
1030 1030
 
1031
-        while ($row = Database::fetch_array($result)){
1031
+        while ($row = Database::fetch_array($result)) {
1032 1032
             $existing_sessions[] = $row['session_id'];
1033 1033
         }
1034 1034
 
@@ -1057,13 +1057,13 @@  discard block
 block discarded – undo
1057 1057
      */
1058 1058
     public static function get_access_url_from_user($user_id)
1059 1059
     {
1060
-        $table_url_rel_user	= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
1061
-        $table_url	= Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
1060
+        $table_url_rel_user = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
1061
+        $table_url = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
1062 1062
         $sql = "SELECT url, access_url_id FROM $table_url_rel_user url_rel_user INNER JOIN $table_url u
1063 1063
                 ON (url_rel_user.access_url_id = u.id)
1064 1064
                 WHERE user_id = ".intval($user_id);
1065 1065
         $result = Database::query($sql);
1066
-        $url_list = Database::store_result($result,'ASSOC');
1066
+        $url_list = Database::store_result($result, 'ASSOC');
1067 1067
         return $url_list;
1068 1068
     }
1069 1069
 
@@ -1073,14 +1073,14 @@  discard block
 block discarded – undo
1073 1073
      */
1074 1074
     public static function get_access_url_from_course($courseId)
1075 1075
     {
1076
-        $table	= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
1077
-        $table_url	= Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
1076
+        $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
1077
+        $table_url = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
1078 1078
         $sql = "SELECT url, access_url_id FROM $table c INNER JOIN $table_url u
1079 1079
                 ON (c.access_url_id = u.id)
1080 1080
                 WHERE c_id = ".intval($courseId);
1081 1081
 
1082 1082
         $result = Database::query($sql);
1083
-        $url_list = Database::store_result($result,'ASSOC');
1083
+        $url_list = Database::store_result($result, 'ASSOC');
1084 1084
         return $url_list;
1085 1085
     }
1086 1086
 
@@ -1091,7 +1091,7 @@  discard block
 block discarded – undo
1091 1091
     public static function get_access_url_from_session($session_id)
1092 1092
     {
1093 1093
         $table_url_rel_session = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
1094
-        $table_url  = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
1094
+        $table_url = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
1095 1095
         $sql = "SELECT url, access_url_id FROM $table_url_rel_session url_rel_session INNER JOIN $table_url u
1096 1096
                 ON (url_rel_session.access_url_id = u.id)
1097 1097
                 WHERE session_id = ".intval($session_id);
@@ -1107,7 +1107,7 @@  discard block
 block discarded – undo
1107 1107
      */
1108 1108
     public static function get_url_id($url)
1109 1109
     {
1110
-        $table_access_url= Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
1110
+        $table_access_url = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
1111 1111
         $sql = "SELECT id FROM $table_access_url WHERE url = '".Database::escape_string($url)."'";
1112 1112
         $result = Database::query($sql);
1113 1113
         $access_url_id = Database::result($result, 0, 0);
Please login to merge, or discard this patch.
main/inc/lib/usergroup.lib.php 3 patches
Doc Comments   +12 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1013,7 +1013,7 @@  discard block
 block discarded – undo
1013 1013
      * @param int    $groupId
1014 1014
      * @param string $picture
1015 1015
      *
1016
-     * @return bool|string
1016
+     * @return false|string
1017 1017
      */
1018 1018
     public function manageFileUpload($groupId, $picture)
1019 1019
     {
@@ -1155,7 +1155,7 @@  discard block
 block discarded – undo
1155 1155
     }
1156 1156
 
1157 1157
     /**
1158
-     * @return mixed
1158
+     * @return integer
1159 1159
      */
1160 1160
     public function getGroupType()
1161 1161
     {
@@ -1359,6 +1359,8 @@  discard block
 block discarded – undo
1359 1359
      * @param string height
1360 1360
      * @param string picture size it can be small_,  medium_  or  big_
1361 1361
      * @param string style css
1362
+     * @param integer $height
1363
+     * @param integer $size_picture
1362 1364
      * @return array with the file and the style of an image i.e $array['file'] $array['style']
1363 1365
      */
1364 1366
     public function get_picture_group($id, $picture_file, $height, $size_picture = GROUP_IMAGE_SIZE_MEDIUM , $style = '')
@@ -1420,7 +1422,7 @@  discard block
 block discarded – undo
1420 1422
      * @param	string	Type of path to return (can be 'none', 'system', 'rel', 'web')
1421 1423
      * @param	bool	Whether we want to have the directory name returned 'as if' there was a file or not (in the case we want to know which directory to create - otherwise no file means no split subdir)
1422 1424
      * @param	bool	If we want that the function returns the /main/img/unknown.jpg image set it at true
1423
-     * @return	array 	Array of 2 elements: 'dir' and 'file' which contain the dir and file as the name implies if image does not exist it will return the unknow image if anonymous parameter is true if not it returns an empty er's
1425
+     * @return	integer 	Array of 2 elements: 'dir' and 'file' which contain the dir and file as the name implies if image does not exist it will return the unknow image if anonymous parameter is true if not it returns an empty er's
1424 1426
      */
1425 1427
     public function get_group_picture_path_by_id($id, $type = 'none', $preview = false, $anonymous = false)
1426 1428
     {
@@ -1470,7 +1472,7 @@  discard block
 block discarded – undo
1470 1472
     }
1471 1473
 
1472 1474
     /**
1473
-     * @return array
1475
+     * @return string[]
1474 1476
      */
1475 1477
     public function getAllowedPictureExtensions()
1476 1478
     {
@@ -1660,7 +1662,7 @@  discard block
 block discarded – undo
1660 1662
      * @author Julio Montoya
1661 1663
      * @param  int  $user_id
1662 1664
      * @param  int $group_id
1663
-     * @return boolean true if success
1665
+     * @return Doctrine\DBAL\Driver\Statement|null true if success
1664 1666
      * */
1665 1667
     public function delete_user_rel_group($user_id, $group_id)
1666 1668
     {
@@ -1872,6 +1874,8 @@  discard block
 block discarded – undo
1872 1874
      * @param int from value
1873 1875
      * @param int limit
1874 1876
      * @param array image configuration, i.e array('height'=>'20px', 'size'=> '20px')
1877
+     * @param integer $from
1878
+     * @param integer $limit
1875 1879
      * @return array list of users in a group
1876 1880
      */
1877 1881
     public function get_users_by_group(
@@ -1970,6 +1974,8 @@  discard block
 block discarded – undo
1970 1974
      * Shows the left column of the group page
1971 1975
      * @param int group id
1972 1976
      * @param int user id
1977
+     * @param integer $group_id
1978
+     * @param integer $user_id
1973 1979
      *
1974 1980
      */
1975 1981
     public function show_group_column_information($group_id, $user_id, $show = '')
@@ -2323,7 +2329,7 @@  discard block
 block discarded – undo
2323 2329
      * @param int $group_id
2324 2330
      * @param int $parent_group_id if 0, we delete the parent_group association
2325 2331
      * @param int $relation_type
2326
-     * @return resource
2332
+     * @return Doctrine\DBAL\Driver\Statement|null
2327 2333
      **/
2328 2334
     public static function set_parent_group($group_id, $parent_group_id, $relation_type = 1)
2329 2335
     {
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1906,8 +1906,9 @@
 block discarded – undo
1906 1906
                 $new_relation_type[] ="'$rel'";
1907 1907
             }
1908 1908
             $relation_type = implode(',', $new_relation_type);
1909
-            if (!empty($relation_type))
1910
-                $where_relation_condition = "AND gu.relation_type IN ($relation_type) ";
1909
+            if (!empty($relation_type)) {
1910
+                            $where_relation_condition = "AND gu.relation_type IN ($relation_type) ";
1911
+            }
1911 1912
         }
1912 1913
 
1913 1914
         $sql = "SELECT picture_uri as image, u.id, u.firstname, u.lastname, relation_type
Please login to merge, or discard this patch.
Spacing   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
             ";
83 83
             $result = Database::query($sql);
84 84
             if (Database::num_rows($result)) {
85
-                $row  = Database::fetch_array($result);
85
+                $row = Database::fetch_array($result);
86 86
 
87 87
                 return $row['count'];
88 88
             }
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
             ";
103 103
             $result = Database::query($sql);
104 104
             if (Database::num_rows($result)) {
105
-                $row  = Database::fetch_array($result);
105
+                $row = Database::fetch_array($result);
106 106
                 return $row['count'];
107 107
             }
108 108
         }
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
             ";
128 128
             $result = Database::query($sql);
129 129
             if (Database::num_rows($result)) {
130
-                $row  = Database::fetch_array($result);
130
+                $row = Database::fetch_array($result);
131 131
                 return $row['count'];
132 132
             }
133 133
 
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
             ";
149 149
             $result = Database::query($sql);
150 150
             if (Database::num_rows($result)) {
151
-                $row  = Database::fetch_array($result);
151
+                $row = Database::fetch_array($result);
152 152
                 return $row['count'];
153 153
             }
154 154
 
@@ -529,13 +529,13 @@  discard block
 block discarded – undo
529 529
                 INNER JOIN {$this->table} g
530 530
                 ON (u.usergroup_id = g.id)
531 531
                 ";
532
-            $where =  array('where' => array('user_id = ? AND access_url_id = ? ' => array($userId, $urlId)));
532
+            $where = array('where' => array('user_id = ? AND access_url_id = ? ' => array($userId, $urlId)));
533 533
         } else {
534 534
             $from = $this->usergroup_rel_user_table." u
535 535
                 INNER JOIN {$this->table} g
536 536
                 ON (u.usergroup_id = g.id)
537 537
                 ";
538
-            $where =  array('where' => array('user_id = ?' => $userId));
538
+            $where = array('where' => array('user_id = ?' => $userId));
539 539
         }
540 540
 
541 541
         if ($filterByType !== null) {
@@ -568,10 +568,10 @@  discard block
 block discarded – undo
568 568
             $urlId = api_get_current_access_url_id();
569 569
             $from = $this->usergroup_rel_user_table." u
570 570
                     INNER JOIN {$this->access_url_rel_usergroup} a ON (a.usergroup_id AND u.usergroup_id)";
571
-            $where =  array('where' => array('user_id = ? AND access_url_id = ? ' => array($userId, $urlId)));
571
+            $where = array('where' => array('user_id = ? AND access_url_id = ? ' => array($userId, $urlId)));
572 572
         } else {
573 573
             $from = $this->usergroup_rel_user_table." u ";
574
-            $where =  array('where' => array('user_id = ?' => $userId));
574
+            $where = array('where' => array('user_id = ?' => $userId));
575 575
         }
576 576
 
577 577
         $results = Database::select(
@@ -857,7 +857,7 @@  discard block
 block discarded – undo
857 857
             }
858 858
             $result = $new_result;
859 859
         }
860
-        $columns = array('name', 'users', 'courses','sessions', 'group_type');
860
+        $columns = array('name', 'users', 'courses', 'sessions', 'group_type');
861 861
 
862 862
         if (!in_array($sidx, $columns)) {
863 863
             $sidx = 'name';
@@ -1263,7 +1263,7 @@  discard block
 block discarded – undo
1263 1263
                 }
1264 1264
             }
1265 1265
         }
1266
-        $response->addAssign('ajax_list_courses','innerHTML', api_utf8_encode($return));
1266
+        $response->addAssign('ajax_list_courses', 'innerHTML', api_utf8_encode($return));
1267 1267
 
1268 1268
         return $response;
1269 1269
     }
@@ -1372,7 +1372,7 @@  discard block
 block discarded – undo
1372 1372
      * @param string style css
1373 1373
      * @return array with the file and the style of an image i.e $array['file'] $array['style']
1374 1374
      */
1375
-    public function get_picture_group($id, $picture_file, $height, $size_picture = GROUP_IMAGE_SIZE_MEDIUM , $style = '')
1375
+    public function get_picture_group($id, $picture_file, $height, $size_picture = GROUP_IMAGE_SIZE_MEDIUM, $style = '')
1376 1376
     {
1377 1377
         $picture = array();
1378 1378
         $picture['style'] = $style;
@@ -1415,7 +1415,7 @@  discard block
 block discarded – undo
1415 1415
             if (file_exists($file) && !is_dir($file)) {
1416 1416
                 $picture['file'] = $image_array['dir'].$picture_file;
1417 1417
             } else {
1418
-                $picture['file'] = Display::returnIconPath('group_na.png',64);
1418
+                $picture['file'] = Display::returnIconPath('group_na.png', 64);
1419 1419
             }
1420 1420
         }
1421 1421
         return $picture;
@@ -1485,7 +1485,7 @@  discard block
 block discarded – undo
1485 1485
      */
1486 1486
     public function getAllowedPictureExtensions()
1487 1487
     {
1488
-        return $allowed_picture_types = array ('jpg', 'jpeg', 'png', 'gif');
1488
+        return $allowed_picture_types = array('jpg', 'jpeg', 'png', 'gif');
1489 1489
     }
1490 1490
 
1491 1491
     /**
@@ -1519,7 +1519,7 @@  discard block
 block discarded – undo
1519 1519
         if (empty($user_id)) {
1520 1520
             $user_id = api_get_user_id();
1521 1521
         }
1522
-        $user_role	= $this->get_user_group_role($user_id, $group_id);
1522
+        $user_role = $this->get_user_group_role($user_id, $group_id);
1523 1523
         if (in_array($user_role, array(GROUP_USER_PERMISSION_ADMIN))) {
1524 1524
             return true;
1525 1525
         } else {
@@ -1537,7 +1537,7 @@  discard block
 block discarded – undo
1537 1537
         if (empty($user_id)) {
1538 1538
             $user_id = api_get_user_id();
1539 1539
         }
1540
-        $user_role	= $this->get_user_group_role($user_id, $group_id);
1540
+        $user_role = $this->get_user_group_role($user_id, $group_id);
1541 1541
         if (in_array($user_role, array(GROUP_USER_PERMISSION_ADMIN, GROUP_USER_PERMISSION_MODERATOR))) {
1542 1542
             return true;
1543 1543
         } else {
@@ -1564,7 +1564,7 @@  discard block
 block discarded – undo
1564 1564
             GROUP_USER_PERMISSION_READER,
1565 1565
             GROUP_USER_PERMISSION_HRM,
1566 1566
         );
1567
-        $user_role	= self::get_user_group_role($user_id, $group_id);
1567
+        $user_role = self::get_user_group_role($user_id, $group_id);
1568 1568
         if (in_array($user_role, $roles)) {
1569 1569
             return true;
1570 1570
         } else {
@@ -1581,7 +1581,7 @@  discard block
 block discarded – undo
1581 1581
      * */
1582 1582
     public function get_user_group_role($user_id, $group_id)
1583 1583
     {
1584
-        $table_group_rel_user= $this->usergroup_rel_user_table;
1584
+        $table_group_rel_user = $this->usergroup_rel_user_table;
1585 1585
         $return_value = 0;
1586 1586
         if (!empty($user_id) && !empty($group_id)) {
1587 1587
             $sql = "SELECT relation_type FROM $table_group_rel_user
@@ -1589,8 +1589,8 @@  discard block
 block discarded – undo
1589 1589
                         usergroup_id = ".intval($group_id)." AND
1590 1590
                         user_id = ".intval($user_id)." ";
1591 1591
             $result = Database::query($sql);
1592
-            if (Database::num_rows($result)>0) {
1593
-                $row = Database::fetch_array($result,'ASSOC');
1592
+            if (Database::num_rows($result) > 0) {
1593
+                $row = Database::fetch_array($result, 'ASSOC');
1594 1594
                 $return_value = $row['relation_type'];
1595 1595
             }
1596 1596
         }
@@ -1645,7 +1645,7 @@  discard block
 block discarded – undo
1645 1645
         if (is_array($user_list) && is_array($group_list)) {
1646 1646
             foreach ($group_list as $group_id) {
1647 1647
                 foreach ($user_list as $user_id) {
1648
-                    $role = self::get_user_group_role($user_id,$group_id);
1648
+                    $role = self::get_user_group_role($user_id, $group_id);
1649 1649
                     if ($role == 0) {
1650 1650
                         $sql = "INSERT INTO $table_url_rel_group
1651 1651
 		               			SET
@@ -1676,7 +1676,7 @@  discard block
 block discarded – undo
1676 1676
     public function delete_user_rel_group($user_id, $group_id)
1677 1677
     {
1678 1678
         $table = $this->usergroup_rel_user_table;
1679
-        $sql= "DELETE FROM $table
1679
+        $sql = "DELETE FROM $table
1680 1680
                WHERE
1681 1681
                 user_id = ".intval($user_id)." AND
1682 1682
                 usergroup_id = ".intval($group_id)."  ";
@@ -1732,7 +1732,7 @@  discard block
 block discarded – undo
1732 1732
 
1733 1733
         $sql = "UPDATE $table_group_rel_user
1734 1734
    				SET relation_type = ".intval($relation_type)."
1735
-                WHERE user_id = $user_id AND usergroup_id = $group_id" ;
1735
+                WHERE user_id = $user_id AND usergroup_id = $group_id";
1736 1736
         Database::query($sql);
1737 1737
     }
1738 1738
 
@@ -1774,7 +1774,7 @@  discard block
 block discarded – undo
1774 1774
         if (Database::num_rows($result) > 0) {
1775 1775
             while ($row = Database::fetch_array($result, 'ASSOC')) {
1776 1776
                 if ($with_image) {
1777
-                    $picture = self::get_picture_group($row['id'], $row['picture'],80);
1777
+                    $picture = self::get_picture_group($row['id'], $row['picture'], 80);
1778 1778
                     $img = '<img src="'.$picture['file'].'" />';
1779 1779
                     $row['picture'] = $img;
1780 1780
                 }
@@ -1810,11 +1810,11 @@  discard block
 block discarded – undo
1810 1810
 				ORDER BY count DESC
1811 1811
 				LIMIT $num";
1812 1812
 
1813
-        $result=Database::query($sql);
1813
+        $result = Database::query($sql);
1814 1814
         $array = array();
1815 1815
         while ($row = Database::fetch_array($result, 'ASSOC')) {
1816 1816
             if ($with_image) {
1817
-                $picture = self::get_picture_group($row['id'], $row['picture'],80);
1817
+                $picture = self::get_picture_group($row['id'], $row['picture'], 80);
1818 1818
                 $img = '<img src="'.$picture['file'].'" />';
1819 1819
                 $row['picture'] = $img;
1820 1820
             }
@@ -1859,11 +1859,11 @@  discard block
 block discarded – undo
1859 1859
                 ORDER BY created_at DESC
1860 1860
                 LIMIT $num ";
1861 1861
 
1862
-        $result=Database::query($sql);
1862
+        $result = Database::query($sql);
1863 1863
         $array = array();
1864 1864
         while ($row = Database::fetch_array($result, 'ASSOC')) {
1865 1865
             if ($with_image) {
1866
-                $picture = self::get_picture_group($row['id'], $row['picture'],80);
1866
+                $picture = self::get_picture_group($row['id'], $row['picture'], 80);
1867 1867
                 $img = '<img src="'.$picture['file'].'" />';
1868 1868
                 $row['picture'] = $img;
1869 1869
             }
@@ -1897,7 +1897,7 @@  discard block
 block discarded – undo
1897 1897
         $tbl_user = Database::get_main_table(TABLE_MAIN_USER);
1898 1898
         $group_id = intval($group_id);
1899 1899
 
1900
-        if (empty($group_id)){
1900
+        if (empty($group_id)) {
1901 1901
             return array();
1902 1902
         }
1903 1903
 
@@ -1912,9 +1912,9 @@  discard block
 block discarded – undo
1912 1912
             $where_relation_condition = '';
1913 1913
         } else {
1914 1914
             $new_relation_type = array();
1915
-            foreach($relation_type as $rel) {
1915
+            foreach ($relation_type as $rel) {
1916 1916
                 $rel = intval($rel);
1917
-                $new_relation_type[] ="'$rel'";
1917
+                $new_relation_type[] = "'$rel'";
1918 1918
             }
1919 1919
             $relation_type = implode(',', $new_relation_type);
1920 1920
             if (!empty($relation_type))
@@ -1958,7 +1958,7 @@  discard block
 block discarded – undo
1958 1958
         $tbl_user = Database::get_main_table(TABLE_MAIN_USER);
1959 1959
         $group_id = intval($group_id);
1960 1960
 
1961
-        if (empty($group_id)){
1961
+        if (empty($group_id)) {
1962 1962
             return array();
1963 1963
         }
1964 1964
 
@@ -1969,7 +1969,7 @@  discard block
 block discarded – undo
1969 1969
 			    WHERE gu.usergroup_id= $group_id
1970 1970
 			    ORDER BY relation_type, firstname";
1971 1971
 
1972
-        $result=Database::query($sql);
1972
+        $result = Database::query($sql);
1973 1973
         $array = array();
1974 1974
         while ($row = Database::fetch_array($result, 'ASSOC')) {
1975 1975
             $array[$row['id']] = $row;
@@ -1998,33 +1998,33 @@  discard block
 block discarded – undo
1998 1998
             case GROUP_USER_PERMISSION_READER:
1999 1999
                 // I'm just a reader
2000 2000
                 $relation_group_title = get_lang('IAmAReader');
2001
-                $links .=  '<li class="'. ($show == 'invite_friends' ? 'active' : '') .'"><a href="group_invitation.php?id='.$group_id.'">'.
2002
-                            Display::return_icon('invitation_friend.png', get_lang('InviteFriends')) . get_lang('InviteFriends') . '</a></li>';
2003
-                $links .=  '<li><a href="group_view.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'.
2004
-                            Display::return_icon('group_leave.png', get_lang('LeaveGroup')) . get_lang('LeaveGroup') . '</a></li>';
2001
+                $links .= '<li class="'.($show == 'invite_friends' ? 'active' : '').'"><a href="group_invitation.php?id='.$group_id.'">'.
2002
+                            Display::return_icon('invitation_friend.png', get_lang('InviteFriends')).get_lang('InviteFriends').'</a></li>';
2003
+                $links .= '<li><a href="group_view.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'.
2004
+                            Display::return_icon('group_leave.png', get_lang('LeaveGroup')).get_lang('LeaveGroup').'</a></li>';
2005 2005
                 if (UserGroup::canLeave($group_info)) {
2006
-                    $links .=  '<li><a href="group_view.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'.
2007
-                        Display::return_icon('group_leave.png', get_lang('LeaveGroup')) . get_lang('LeaveGroup') . '</a></li>';
2006
+                    $links .= '<li><a href="group_view.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'.
2007
+                        Display::return_icon('group_leave.png', get_lang('LeaveGroup')).get_lang('LeaveGroup').'</a></li>';
2008 2008
                 }
2009 2009
                 break;
2010 2010
             case GROUP_USER_PERMISSION_ADMIN:
2011 2011
                 $relation_group_title = get_lang('IAmAnAdmin');
2012
-                $links .=  '<li class="'. ($show == 'group_edit' ? 'active' : '') .'"><a href="group_edit.php?id='.$group_id.'">'.
2013
-                            Display::return_icon('group_edit.png', get_lang('EditGroup')) . get_lang('EditGroup') . '</a></li>';
2014
-                $links .=  '<li class="'. ($show == 'member_list' ? 'active' : '') .'"><a href="group_waiting_list.php?id='.$group_id.'">'.
2015
-                            Display::return_icon('waiting_list.png', get_lang('WaitingList')) . get_lang('WaitingList') . '</a></li>';
2016
-                $links .=  '<li class="'. ($show == 'invite_friends' ? 'active' : '') .'"><a href="group_invitation.php?id='.$group_id.'">'.
2017
-                            Display::return_icon('invitation_friend.png', get_lang('InviteFriends')) . get_lang('InviteFriends') . '</a></li>';
2012
+                $links .= '<li class="'.($show == 'group_edit' ? 'active' : '').'"><a href="group_edit.php?id='.$group_id.'">'.
2013
+                            Display::return_icon('group_edit.png', get_lang('EditGroup')).get_lang('EditGroup').'</a></li>';
2014
+                $links .= '<li class="'.($show == 'member_list' ? 'active' : '').'"><a href="group_waiting_list.php?id='.$group_id.'">'.
2015
+                            Display::return_icon('waiting_list.png', get_lang('WaitingList')).get_lang('WaitingList').'</a></li>';
2016
+                $links .= '<li class="'.($show == 'invite_friends' ? 'active' : '').'"><a href="group_invitation.php?id='.$group_id.'">'.
2017
+                            Display::return_icon('invitation_friend.png', get_lang('InviteFriends')).get_lang('InviteFriends').'</a></li>';
2018 2018
                 if (UserGroup::canLeave($group_info)) {
2019 2019
                     $links .= '<li><a href="group_view.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'.
2020
-                        Display::return_icon('group_leave.png', get_lang('LeaveGroup')) . get_lang('LeaveGroup') . '</a></li>';
2020
+                        Display::return_icon('group_leave.png', get_lang('LeaveGroup')).get_lang('LeaveGroup').'</a></li>';
2021 2021
                 }
2022 2022
                 break;
2023 2023
             case GROUP_USER_PERMISSION_PENDING_INVITATION:
2024 2024
 //				$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>';
2025 2025
                 break;
2026 2026
             case GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER:
2027
-                $relation_group_title =  get_lang('WaitingForAdminResponse');
2027
+                $relation_group_title = get_lang('WaitingForAdminResponse');
2028 2028
                 break;
2029 2029
             case GROUP_USER_PERMISSION_MODERATOR:
2030 2030
                 $relation_group_title = get_lang('IAmAModerator');
@@ -2032,28 +2032,28 @@  discard block
 block discarded – undo
2032 2032
                 //$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>';
2033 2033
                 //$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>';
2034 2034
                 if ($group_info['visibility'] == GROUP_PERMISSION_CLOSED) {
2035
-                    $links .=  '<li><a href="group_waiting_list.php?id='.$group_id.'">'.
2036
-                                Display::return_icon('waiting_list.png', get_lang('WaitingList')) . get_lang('WaitingList') . '</a></li>';
2035
+                    $links .= '<li><a href="group_waiting_list.php?id='.$group_id.'">'.
2036
+                                Display::return_icon('waiting_list.png', get_lang('WaitingList')).get_lang('WaitingList').'</a></li>';
2037 2037
                 }
2038
-                $links .=  '<li><a href="group_invitation.php?id='.$group_id.'">'.
2039
-                            Display::return_icon('invitation_friend.png', get_lang('InviteFriends')) . get_lang('InviteFriends') . '</a></li>';
2038
+                $links .= '<li><a href="group_invitation.php?id='.$group_id.'">'.
2039
+                            Display::return_icon('invitation_friend.png', get_lang('InviteFriends')).get_lang('InviteFriends').'</a></li>';
2040 2040
                 if (UserGroup::canLeave($group_info)) {
2041
-                    $links .=  '<li><a href="group_view.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'.
2042
-                        Display::return_icon('group_leave.png', get_lang('LeaveGroup')) . get_lang('LeaveGroup') . '</a></li>';
2041
+                    $links .= '<li><a href="group_view.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'.
2042
+                        Display::return_icon('group_leave.png', get_lang('LeaveGroup')).get_lang('LeaveGroup').'</a></li>';
2043 2043
                 }
2044 2044
                 break;
2045 2045
             case GROUP_USER_PERMISSION_HRM:
2046 2046
                 $relation_group_title = get_lang('IAmAHRM');
2047 2047
                 $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').'">'.
2048
-                            Display::return_icon('new-message.png', get_lang('NewTopic')) . get_lang('NewTopic') . '</a></li>';
2049
-                $links .=  '<li><a href="group_view.php?id='.$group_id.'">'.
2050
-                            Display::return_icon('message_list.png', get_lang('MessageList')) . get_lang('MessageList') . '</a></li>';
2051
-                $links .=  '<li><a href="group_invitation.php?id='.$group_id.'">'.
2052
-                            Display::return_icon('invitation_friend.png', get_lang('InviteFriends')) . get_lang('InviteFriends') . '</a></li>';
2053
-                $links .=  '<li><a href="group_members.php?id='.$group_id.'">'.
2054
-                            Display::return_icon('member_list.png', get_lang('MemberList')) . get_lang('MemberList') . '</a></li>';
2055
-                $links .=  '<li><a href="group_view.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'.
2056
-                            Display::return_icon('delete_data.gif', get_lang('LeaveGroup')) . get_lang('LeaveGroup') . '</a></li>';
2048
+                            Display::return_icon('new-message.png', get_lang('NewTopic')).get_lang('NewTopic').'</a></li>';
2049
+                $links .= '<li><a href="group_view.php?id='.$group_id.'">'.
2050
+                            Display::return_icon('message_list.png', get_lang('MessageList')).get_lang('MessageList').'</a></li>';
2051
+                $links .= '<li><a href="group_invitation.php?id='.$group_id.'">'.
2052
+                            Display::return_icon('invitation_friend.png', get_lang('InviteFriends')).get_lang('InviteFriends').'</a></li>';
2053
+                $links .= '<li><a href="group_members.php?id='.$group_id.'">'.
2054
+                            Display::return_icon('member_list.png', get_lang('MemberList')).get_lang('MemberList').'</a></li>';
2055
+                $links .= '<li><a href="group_view.php?id='.$group_id.'&action=leave&u='.api_get_user_id().'">'.
2056
+                            Display::return_icon('delete_data.gif', get_lang('LeaveGroup')).get_lang('LeaveGroup').'</a></li>';
2057 2057
                 break;
2058 2058
             default:
2059 2059
                 //$links .=  '<li><a href="groups.php?id='.$group_id.'&action=join&u='.api_get_user_id().'">'.Display::return_icon('addd.gif', get_lang('JoinGroup'), array('hspace'=>'6')).'<span class="social-menu-text4" >'.get_lang('JoinGroup').'</a></span></li>';
@@ -2090,14 +2090,14 @@  discard block
 block discarded – undo
2090 2090
      */
2091 2091
     public function get_groups_by_user_count($user_id = '', $relation_type = GROUP_USER_PERMISSION_READER, $with_image = false)
2092 2092
     {
2093
-        $table_group_rel_user	= $this->usergroup_rel_user_table;
2094
-        $tbl_group				= $this->table;
2095
-        $user_id 				= intval($user_id);
2093
+        $table_group_rel_user = $this->usergroup_rel_user_table;
2094
+        $tbl_group = $this->table;
2095
+        $user_id = intval($user_id);
2096 2096
 
2097 2097
         if ($relation_type == 0) {
2098 2098
             $where_relation_condition = '';
2099 2099
         } else {
2100
-            $relation_type 			= intval($relation_type);
2100
+            $relation_type = intval($relation_type);
2101 2101
             $where_relation_condition = "AND gu.relation_type = $relation_type ";
2102 2102
         }
2103 2103
 
@@ -2170,7 +2170,7 @@  discard block
 block discarded – undo
2170 2170
         }
2171 2171
 
2172 2172
         $direction = 'ASC';
2173
-        if (!in_array($direction, array('ASC','DESC'))) {
2173
+        if (!in_array($direction, array('ASC', 'DESC'))) {
2174 2174
             $direction = 'ASC';
2175 2175
         }
2176 2176
 
@@ -2181,8 +2181,8 @@  discard block
 block discarded – undo
2181 2181
         $sql .= " LIMIT $from,$number_of_items";
2182 2182
 
2183 2183
         $res = Database::query($sql);
2184
-        if (Database::num_rows($res)> 0) {
2185
-            while ($row = Database::fetch_array($res,'ASSOC')) {
2184
+        if (Database::num_rows($res) > 0) {
2185
+            while ($row = Database::fetch_array($res, 'ASSOC')) {
2186 2186
                 if (!in_array($row['id'], $return)) {
2187 2187
                     $return[$row['id']] = $row;
2188 2188
                 }
@@ -2207,7 +2207,7 @@  discard block
 block discarded – undo
2207 2207
             if ($i == $max_level) {
2208 2208
                 $select_part .= "rg$rg_number.group_id as id_$rg_number ";
2209 2209
             } else {
2210
-                $select_part .="rg$rg_number.group_id as id_$rg_number, ";
2210
+                $select_part .= "rg$rg_number.group_id as id_$rg_number, ";
2211 2211
             }
2212 2212
             if ($i == 1) {
2213 2213
                 $cond_part .= "FROM $t_rel_group rg0 LEFT JOIN $t_rel_group rg$i on rg$rg_number.group_id = rg$i.subgroup_id ";
@@ -2395,7 +2395,7 @@  discard block
 block discarded – undo
2395 2395
         $nameList = '<ul class="list-unstyled">';
2396 2396
 
2397 2397
         foreach ($groupsNameListParsed as $name) {
2398
-            $nameList .= '<li>' . Display::span($name, ['class' => 'label label-info']) . '</li>';
2398
+            $nameList .= '<li>'.Display::span($name, ['class' => 'label label-info']).'</li>';
2399 2399
         }
2400 2400
 
2401 2401
         $nameList .= '</ul>';
Please login to merge, or discard this patch.
main/inc/lib/VideoChat.php 1 patch
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@
 block discarded – undo
43 43
      * Create a video chat
44 44
      * @param int $fromUser The sender user
45 45
      * @param int $toUser The receiver user
46
-     * @return int The created video chat id. Otherwise return false
46
+     * @return false|string The created video chat id. Otherwise return false
47 47
      */
48 48
     public static function createRoom($fromUser, $toUser)
49 49
     {
Please login to merge, or discard this patch.
main/inc/lib/zombie/zombie_report.class.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -121,6 +121,9 @@
 block discarded – undo
121 121
         return $form->isSubmitted() == false || $form->validate();
122 122
     }
123 123
 
124
+    /**
125
+     * @param string $format
126
+     */
124 127
     function get_ceiling($format = null)
125 128
     {
126 129
         $result = Request::get('ceiling');
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
         }
168 168
 
169 169
         $action = $this->get_action();
170
-        $f = array($this, 'action_' . $action);
170
+        $f = array($this, 'action_'.$action);
171 171
         if (is_callable($f)) {
172 172
             return call_user_func($f, $ids);
173 173
         }
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
             $text = get_lang('No');
293 293
         }
294 294
 
295
-        $result = Display::return_icon($image . '.png', $text);
295
+        $result = Display::return_icon($image.'.png', $text);
296 296
         return $result;
297 297
     }
298 298
 
Please login to merge, or discard this patch.
main/install/install.lib.php 4 patches
Doc Comments   +14 added lines, -5 removed lines patch added patch discarded remove patch
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
  * This function return the value of a php.ini setting if not "" or if exists,
98 98
  * otherwise return false
99 99
  * @param   string  $phpSetting The name of a PHP setting
100
- * @return  mixed   The value of the setting, or false if not found
100
+ * @return  string|false   The value of the setting, or false if not found
101 101
  */
102 102
 function checkPhpSettingExists($phpSetting)
103 103
 {
@@ -1268,6 +1268,10 @@  discard block
 block discarded – undo
1268 1268
  * @param   string  Extra notice (to show on the right side)
1269 1269
  * @param   boolean Whether to display in update mode
1270 1270
  * @param   string  Additional attribute for the <tr> element
1271
+ * @param string $installType
1272
+ * @param string $parameterName
1273
+ * @param string $formFieldName
1274
+ * @param string $extra_notice
1271 1275
  * @return  void    Direct output
1272 1276
  */
1273 1277
 function displayDatabaseParameter(
@@ -1481,6 +1485,11 @@  discard block
 block discarded – undo
1481 1485
 
1482 1486
     <?php
1483 1487
 }
1488
+/**
1489
+ * @param string $content
1490
+ * @param string $title
1491
+ * @param string $id
1492
+ */
1484 1493
 function panel($content = null, $title = null, $id = null, $style = null) {
1485 1494
     $html = '';
1486 1495
     if (empty($style)) {
@@ -1837,8 +1846,8 @@  discard block
 block discarded – undo
1837 1846
 }
1838 1847
 
1839 1848
 /**
1840
- * @param $current_value
1841
- * @param $wanted_value
1849
+ * @param string $current_value
1850
+ * @param string $wanted_value
1842 1851
  * @return string
1843 1852
  */
1844 1853
 function compare_setting_values($current_value, $wanted_value)
@@ -1855,8 +1864,8 @@  discard block
 block discarded – undo
1855 1864
 }
1856 1865
 
1857 1866
 /**
1858
- * @param $course_dir
1859
- * @param $course_attempt_name
1867
+ * @param string $course_dir
1868
+ * @param string $course_attempt_name
1860 1869
  * @param string $file
1861 1870
  * @return bool
1862 1871
  */
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1682,7 +1682,7 @@  discard block
 block discarded – undo
1682 1682
         $html .= '<label class="checkbox-inline">
1683 1683
                         <input type="radio" name="allowSelfReg" value="0" id="allowSelfReg0" '. ($allowSelfReg == 'false' ? '' : 'checked="checked" ') .' /> '. get_lang('No') .'
1684 1684
                     </label>';
1685
-         $html .= '<label class="checkbox-inline">
1685
+            $html .= '<label class="checkbox-inline">
1686 1686
                     <input type="radio" name="allowSelfReg" value="0" id="allowSelfReg0" '. ($allowSelfReg == 'approval' ? '' : 'checked="checked" ') .' /> '. get_lang('AfterApproval') .'
1687 1687
                 </label>';
1688 1688
         $html .= '</div>';
@@ -1716,7 +1716,7 @@  discard block
 block discarded – undo
1716 1716
     </div>';
1717 1717
 
1718 1718
     echo panel($html, get_lang('Platform'), 'platform');
1719
- ?>
1719
+    ?>
1720 1720
     <div class='form-group'>
1721 1721
         <div class="col-sm-6">
1722 1722
             <button type="submit" class="btn btn-default pull-right" name="step3" value="&lt; <?php echo get_lang('Previous'); ?>" ><em class="fa fa-backward"> </em> <?php echo get_lang('Previous'); ?></button>
Please login to merge, or discard this patch.
Braces   +15 added lines, -8 removed lines patch added patch discarded remove patch
@@ -973,8 +973,7 @@  discard block
 block discarded – undo
973 973
                 <?php echo get_lang('Error'); ?>!<br />
974 974
                 Chamilo <?php echo implode('|', $update_from_version_8).' '.get_lang('HasNotBeenFoundInThatDir'); ?>.
975 975
             </div>
976
-        <?php }
977
-        else {
976
+        <?php } else {
978 977
             echo '<br />';
979 978
         }
980 979
         ?>
@@ -1060,14 +1059,19 @@  discard block
 block discarded – undo
1060 1059
         <button type="submit" name="step1" class="btn btn-default" onclick="javascript: window.location='index.php'; return false;" value="<?php echo get_lang('Previous'); ?>" >
1061 1060
             <em class="fa fa-backward"> </em> <?php echo get_lang('Previous'); ?>
1062 1061
         </button>
1063
-        <button type="submit" name="step2_install" class="btn btn-success" value="<?php echo get_lang("NewInstallation"); ?>" <?php if ($error) echo 'disabled="disabled"'; ?> >
1062
+        <button type="submit" name="step2_install" class="btn btn-success" value="<?php echo get_lang("NewInstallation"); ?>" <?php if ($error) {
1063
+    echo 'disabled="disabled"';
1064
+}
1065
+?> >
1064 1066
             <em class="fa fa-forward"> </em> <?php echo get_lang('NewInstallation'); ?>
1065 1067
         </button>
1066 1068
         <input type="hidden" name="is_executable" id="is_executable" value="-" />
1067 1069
         <?php
1068 1070
         // Real code
1069 1071
         echo '<button type="submit" class="btn btn-default" name="step2_update_8" value="Upgrade from Chamilo 1.9.x"';
1070
-        if ($error) echo ' disabled="disabled"';
1072
+        if ($error) {
1073
+            echo ' disabled="disabled"';
1074
+        }
1071 1075
         echo ' ><em class="fa fa-forward"> </em> '.get_lang('UpgradeFromLMS19x').'</button>';
1072 1076
 
1073 1077
         echo '</p>';
@@ -1350,7 +1354,7 @@  discard block
 block discarded – undo
1350 1354
                 <input type="hidden" name="dbHostForm" value="<?php echo htmlentities($dbHostForm); ?>" /><?php echo $dbHostForm; ?>
1351 1355
             </div>
1352 1356
             <div class="col-sm-3"></div>
1353
-            <?php }else{ ?>
1357
+            <?php } else{ ?>
1354 1358
             <div class="col-sm-5">
1355 1359
                 <input type="text" class="form-control" size="25" maxlength="50" name="dbHostForm" value="<?php echo htmlentities($dbHostForm); ?>" />
1356 1360
             </div>
@@ -1364,7 +1368,7 @@  discard block
 block discarded – undo
1364 1368
                 <input type="hidden" name="dbPortForm" value="<?php echo htmlentities($dbPortForm); ?>" /><?php echo $dbPortForm; ?>
1365 1369
             </div>
1366 1370
             <div class="col-sm-3"></div>
1367
-            <?php }else{ ?>
1371
+            <?php } else{ ?>
1368 1372
             <div class="col-sm-5">
1369 1373
                 <input type="text" class="form-control" size="25" maxlength="50" name="dbPortForm" value="<?php echo htmlentities($dbPortForm); ?>" />
1370 1374
             </div>
@@ -1446,9 +1450,12 @@  discard block
 block discarded – undo
1446 1450
             Database port: <strong><?php echo $manager->getConnection()->getPort(); ?></strong><br/>
1447 1451
             Database driver: <strong><?php echo $manager->getConnection()->getDriver()->getName(); ?></strong><br/>
1448 1452
         </div>
1449
-    <?php else: ?>
1453
+    <?php else {
1454
+    : ?>
1450 1455
         <div id="db_status" class="alert alert-danger">
1451
-            <p><?php echo get_lang('FailedConectionDatabase'); ?></strong></p>
1456
+            <p><?php echo get_lang('FailedConectionDatabase');
1457
+}
1458
+?></strong></p>
1452 1459
             <code><?php echo $database_exists_text ?></code>
1453 1460
         </div>
1454 1461
     <?php endif; ?>
Please login to merge, or discard this patch.
Spacing   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
     if (!is_array($result)) {
396 396
         $result = array();
397 397
         $exceptions = array('.', '..', 'CVS', '.svn');
398
-        $search       = array('_latin',   '_unicode',   '_corporate',   '_org'  , '_KM',   '_');
398
+        $search       = array('_latin', '_unicode', '_corporate', '_org', '_KM', '_');
399 399
         $replace_with = array(' (Latin)', ' (unicode)', ' (corporate)', ' (org)', ' (KM)', ' ');
400 400
         $dirname = api_get_path(SYS_LANG_PATH);
401 401
         $handle = opendir($dirname);
@@ -430,9 +430,9 @@  discard block
 block discarded – undo
430 430
     if ($handle = opendir($directory)) {
431 431
         while (false !== ($file = readdir($handle))) {
432 432
             if ($file != "." && $file != "..") {
433
-                if (is_dir($directory. "/" . $file)) {
434
-                    $array_items = array_merge($array_items, my_directory_to_array($directory. '/' . $file));
435
-                    $file = $directory . "/" . $file;
433
+                if (is_dir($directory."/".$file)) {
434
+                    $array_items = array_merge($array_items, my_directory_to_array($directory.'/'.$file));
435
+                    $file = $directory."/".$file;
436 436
                     $array_items[] = preg_replace("/\/\//si", '/', $file);
437 437
                 }
438 438
             }
@@ -636,7 +636,7 @@  discard block
 block discarded – undo
636 636
     <h2><?php get_lang('WelcomeToTheChamiloInstaller'); ?></h2>
637 637
     <div class="RequirementHeading">
638 638
         <h2><?php echo display_step_sequence(); ?>
639
-            <?php echo get_lang('InstallationLanguage');?>
639
+            <?php echo get_lang('InstallationLanguage'); ?>
640 640
         </h2>
641 641
         <p><?php echo get_lang('PleaseSelectInstallationProcessLanguage'); ?>:</p>
642 642
         <form id="lang_form" method="post" action="<?php echo api_get_self(); ?>">
@@ -709,7 +709,7 @@  discard block
 block discarded – undo
709 709
     if (phpversion() < REQUIRED_PHP_VERSION) {
710 710
         echo '<strong><font color="red">'.get_lang('PHPVersionError').'</font></strong>';
711 711
     } else {
712
-        echo '<strong><font color="green">'.get_lang('PHPVersionOK'). ' '.phpversion().'</font></strong>';
712
+        echo '<strong><font color="green">'.get_lang('PHPVersionOK').' '.phpversion().'</font></strong>';
713 713
     }
714 714
     echo '</td>
715 715
             </tr>
@@ -1137,7 +1137,7 @@  discard block
 block discarded – undo
1137 1137
 function get_contact_registration_form()
1138 1138
 {
1139 1139
 
1140
-    $html ='
1140
+    $html = '
1141 1141
    <form class="form-horizontal">
1142 1142
     <div class="panel panel-default">
1143 1143
     <div class="panel-body">
@@ -1234,7 +1234,7 @@  discard block
 block discarded – undo
1234 1234
         <div class="col-sm-9">
1235 1235
             <div class="radio">
1236 1236
                 <label>
1237
-                    <input type="radio" name="financial_decision" id="financial_decision1" value="1" checked /> ' . get_lang('Yes') . '
1237
+                    <input type="radio" name="financial_decision" id="financial_decision1" value="1" checked /> ' . get_lang('Yes').'
1238 1238
                 </label>
1239 1239
             </div>
1240 1240
             <div class="radio">
@@ -1293,8 +1293,8 @@  discard block
 block discarded – undo
1293 1293
             echo '<input type="hidden" name="'.$formFieldName.'" id="'.$formFieldName.'" value="'.api_htmlentities($parameterValue).'" />';
1294 1294
             echo api_htmlentities($parameterValue);
1295 1295
         } else {
1296
-            echo '<div class="col-sm-5"><input type="' . $inputType . '" class="form-control" size="' . DATABASE_FORM_FIELD_DISPLAY_LENGTH . '" maxlength="' . $maxLength . '" name="' . $formFieldName . '" id="' . $formFieldName . '" value="' . api_htmlentities($parameterValue) . '" />' . "</div>";
1297
-            echo '<div class="col-sm-3">' . $extra_notice . '</div>';
1296
+            echo '<div class="col-sm-5"><input type="'.$inputType.'" class="form-control" size="'.DATABASE_FORM_FIELD_DISPLAY_LENGTH.'" maxlength="'.$maxLength.'" name="'.$formFieldName.'" id="'.$formFieldName.'" value="'.api_htmlentities($parameterValue).'" />'."</div>";
1297
+            echo '<div class="col-sm-3">'.$extra_notice.'</div>';
1298 1298
         }
1299 1299
     }
1300 1300
 }
@@ -1328,12 +1328,12 @@  discard block
 block discarded – undo
1328 1328
         $dbNameForm = $_configuration['main_database'];
1329 1329
         $dbPortForm = isset($_configuration['db_port']) ? $_configuration['db_port'] : '';
1330 1330
 
1331
-        echo '<div class="RequirementHeading"><h2>' . display_step_sequence() .get_lang('DBSetting') . '</h2></div>';
1331
+        echo '<div class="RequirementHeading"><h2>'.display_step_sequence().get_lang('DBSetting').'</h2></div>';
1332 1332
         echo '<div class="RequirementContent">';
1333 1333
         echo get_lang('DBSettingUpgradeIntro');
1334 1334
         echo '</div>';
1335 1335
     } else {
1336
-        echo '<div class="RequirementHeading"><h2>' . display_step_sequence() .get_lang('DBSetting') . '</h2></div>';
1336
+        echo '<div class="RequirementHeading"><h2>'.display_step_sequence().get_lang('DBSetting').'</h2></div>';
1337 1337
         echo '<div class="RequirementContent">';
1338 1338
         echo get_lang('DBSettingIntro');
1339 1339
         echo '</div>';
@@ -1343,12 +1343,12 @@  discard block
 block discarded – undo
1343 1343
         <div class="panel-body">
1344 1344
         <div class="form-group">
1345 1345
             <label class="col-sm-4"><?php echo get_lang('DBHost'); ?> </label>
1346
-            <?php if ($installType == 'update'){ ?>
1346
+            <?php if ($installType == 'update') { ?>
1347 1347
             <div class="col-sm-5">
1348 1348
                 <input type="hidden" name="dbHostForm" value="<?php echo htmlentities($dbHostForm); ?>" /><?php echo $dbHostForm; ?>
1349 1349
             </div>
1350 1350
             <div class="col-sm-3"></div>
1351
-            <?php }else{ ?>
1351
+            <?php } else { ?>
1352 1352
             <div class="col-sm-5">
1353 1353
                 <input type="text" class="form-control" size="25" maxlength="50" name="dbHostForm" value="<?php echo htmlentities($dbHostForm); ?>" />
1354 1354
             </div>
@@ -1357,12 +1357,12 @@  discard block
 block discarded – undo
1357 1357
         </div>
1358 1358
         <div class="form-group">
1359 1359
             <label class="col-sm-4"><?php echo get_lang('DBPort'); ?> </label>
1360
-            <?php if ($installType == 'update'){ ?>
1360
+            <?php if ($installType == 'update') { ?>
1361 1361
             <div class="col-sm-5">
1362 1362
                 <input type="hidden" name="dbPortForm" value="<?php echo htmlentities($dbPortForm); ?>" /><?php echo $dbPortForm; ?>
1363 1363
             </div>
1364 1364
             <div class="col-sm-3"></div>
1365
-            <?php }else{ ?>
1365
+            <?php } else { ?>
1366 1366
             <div class="col-sm-5">
1367 1367
                 <input type="text" class="form-control" size="25" maxlength="50" name="dbPortForm" value="<?php echo htmlentities($dbPortForm); ?>" />
1368 1368
             </div>
@@ -1388,7 +1388,7 @@  discard block
 block discarded – undo
1388 1388
             <?php
1389 1389
             //Database Name fix replace weird chars
1390 1390
             if ($installType != INSTALL_TYPE_UPDATE) {
1391
-                $dbNameForm = str_replace(array('-','*', '$', ' ', '.'), '', $dbNameForm);
1391
+                $dbNameForm = str_replace(array('-', '*', '$', ' ', '.'), '', $dbNameForm);
1392 1392
             }
1393 1393
 
1394 1394
             displayDatabaseParameter(
@@ -1481,7 +1481,7 @@  discard block
 block discarded – undo
1481 1481
     if (!empty($title)) {
1482 1482
         $panelTitle = Display::div($title, array('class' => 'panel-heading'));
1483 1483
         $panelBody = Display::div($content, array('class' => 'panel-body'));
1484
-        $panelParent = Display::div($panelTitle . $panelBody, array('id' => $id, 'class' => 'panel panel-'.$style));
1484
+        $panelParent = Display::div($panelTitle.$panelBody, array('id' => $id, 'class' => 'panel panel-'.$style));
1485 1485
     } else {
1486 1486
         $panelBody = Display::div($html, array('class' => 'panel-body'));
1487 1487
         $panelParent = Display::div($panelBody, array('id' => $id, 'class' => 'panel panel-'.$style));
@@ -1507,9 +1507,9 @@  discard block
 block discarded – undo
1507 1507
     $displayWhenUpdate = 'true'
1508 1508
 ) {
1509 1509
     $html = '<div class="form-group">';
1510
-    $html .= '<label class="col-sm-6 control-label">' . $parameterName . '</label>';
1510
+    $html .= '<label class="col-sm-6 control-label">'.$parameterName.'</label>';
1511 1511
     if ($installType == INSTALL_TYPE_UPDATE && $displayWhenUpdate) {
1512
-        $html .= '<input type="hidden" name="' . $formFieldName . '" value="'. api_htmlentities($parameterValue, ENT_QUOTES). '" />' . $parameterValue;
1512
+        $html .= '<input type="hidden" name="'.$formFieldName.'" value="'.api_htmlentities($parameterValue, ENT_QUOTES).'" />'.$parameterValue;
1513 1513
     } else {
1514 1514
         $html .= '<div class="col-sm-6"><input class="form-control" type="text" size="'.FORM_FIELD_DISPLAY_LENGTH.'" maxlength="'.MAX_FORM_FIELD_LENGTH.'" name="'.$formFieldName.'" value="'.api_htmlentities($parameterValue, ENT_QUOTES).'" />'."</div>";
1515 1515
     }
@@ -1557,7 +1557,7 @@  discard block
 block discarded – undo
1557 1557
         $languageForm = $_SESSION['install_language'];
1558 1558
     }
1559 1559
     echo '<div class="RequirementHeading">';
1560
-    echo "<h2>" . display_step_sequence() . get_lang("CfgSetting") . "</h2>";
1560
+    echo "<h2>".display_step_sequence().get_lang("CfgSetting")."</h2>";
1561 1561
     echo '</div>';
1562 1562
 
1563 1563
     echo '<p>'.get_lang('ConfigSettingsInfo').' <strong>app/config/configuration.php</strong></p>';
@@ -1575,14 +1575,14 @@  discard block
 block discarded – undo
1575 1575
 
1576 1576
     // Parameters 3 and 4: administrator's names
1577 1577
 
1578
-    $html .=  display_configuration_parameter($installType, get_lang('AdminFirstName'), 'adminFirstName', $adminFirstName);
1579
-    $html .=  display_configuration_parameter($installType, get_lang('AdminLastName'), 'adminLastName', $adminLastName);
1578
+    $html .= display_configuration_parameter($installType, get_lang('AdminFirstName'), 'adminFirstName', $adminFirstName);
1579
+    $html .= display_configuration_parameter($installType, get_lang('AdminLastName'), 'adminLastName', $adminLastName);
1580 1580
 
1581 1581
     //Parameter 3: administrator's email
1582
-    $html .=  display_configuration_parameter($installType, get_lang('AdminEmail'), 'emailForm', $emailForm);
1582
+    $html .= display_configuration_parameter($installType, get_lang('AdminEmail'), 'emailForm', $emailForm);
1583 1583
 
1584 1584
     //Parameter 6: administrator's telephone
1585
-    $html .=  display_configuration_parameter($installType, get_lang('AdminPhone'), 'adminPhoneForm', $adminPhoneForm);
1585
+    $html .= display_configuration_parameter($installType, get_lang('AdminPhone'), 'adminPhoneForm', $adminPhoneForm);
1586 1586
 
1587 1587
 
1588 1588
     echo panel($html, get_lang('Administrator'), 'administrator');
@@ -1601,12 +1601,12 @@  discard block
 block discarded – undo
1601 1601
         $html .= display_language_selection_box('languageForm', $languageForm);
1602 1602
         $html .= '</div>';
1603 1603
     }
1604
-    $html.= "</div>";
1604
+    $html .= "</div>";
1605 1605
 
1606 1606
 
1607 1607
     //Second parameter: Chamilo URL
1608 1608
     $html .= '<div class="form-group">';
1609
-    $html .= '<label class="col-sm-6 control-label">'.get_lang('ChamiloURL') .get_lang('ThisFieldIsRequired').'</label>';
1609
+    $html .= '<label class="col-sm-6 control-label">'.get_lang('ChamiloURL').get_lang('ThisFieldIsRequired').'</label>';
1610 1610
 
1611 1611
 
1612 1612
 
@@ -1630,34 +1630,34 @@  discard block
 block discarded – undo
1630 1630
 
1631 1631
 
1632 1632
     $html .= '<div class="form-group">
1633
-            <label class="col-sm-6 control-label">' . get_lang("EncryptMethodUserPass") . '</label>
1633
+            <label class="col-sm-6 control-label">' . get_lang("EncryptMethodUserPass").'</label>
1634 1634
         <div class="col-sm-6">';
1635 1635
     if ($installType == 'update') {
1636
-        $html .= '<input type="hidden" name="encryptPassForm" value="'. $encryptPassForm .'" />'. $encryptPassForm;
1636
+        $html .= '<input type="hidden" name="encryptPassForm" value="'.$encryptPassForm.'" />'.$encryptPassForm;
1637 1637
     } else {
1638 1638
 
1639 1639
         $html .= '<div class="checkbox">
1640 1640
                     <label>
1641
-                        <input  type="radio" name="encryptPassForm" value="bcrypt" id="encryptPass1" '. ($encryptPassForm == 'bcrypt' ? 'checked="checked" ':'') .'/> bcrypt
1641
+                        <input  type="radio" name="encryptPassForm" value="bcrypt" id="encryptPass1" '. ($encryptPassForm == 'bcrypt' ? 'checked="checked" ' : '').'/> bcrypt
1642 1642
                     </label>';
1643 1643
 
1644 1644
         $html .= '<label>
1645
-                        <input  type="radio" name="encryptPassForm" value="sha1" id="encryptPass1" '. ($encryptPassForm == 'sha1' ? 'checked="checked" ':'') .'/> sha1
1645
+                        <input  type="radio" name="encryptPassForm" value="sha1" id="encryptPass1" '. ($encryptPassForm == 'sha1' ? 'checked="checked" ' : '').'/> sha1
1646 1646
                     </label>';
1647 1647
 
1648 1648
         $html .= '<label>
1649
-                        <input type="radio" name="encryptPassForm" value="md5" id="encryptPass0" '. ($encryptPassForm == 'md5' ? 'checked="checked" ':'') .'/> md5
1649
+                        <input type="radio" name="encryptPassForm" value="md5" id="encryptPass0" '. ($encryptPassForm == 'md5' ? 'checked="checked" ' : '').'/> md5
1650 1650
                     </label>';
1651 1651
 
1652 1652
         $html .= '<label>
1653
-                        <input type="radio" name="encryptPassForm" value="none" id="encryptPass2" '. ($encryptPassForm == 'none' ? 'checked="checked" ':'') .'/>'. get_lang('None').'
1653
+                        <input type="radio" name="encryptPassForm" value="none" id="encryptPass2" '. ($encryptPassForm == 'none' ? 'checked="checked" ' : '').'/>'.get_lang('None').'
1654 1654
                     </label>';
1655 1655
         $html .= '</div>';
1656 1656
     }
1657 1657
     $html .= '</div></div>';
1658 1658
 
1659 1659
     $html .= '<div class="form-group">
1660
-            <label class="col-sm-6 control-label">' . get_lang('AllowSelfReg') . '</label>
1660
+            <label class="col-sm-6 control-label">' . get_lang('AllowSelfReg').'</label>
1661 1661
             <div class="col-sm-6">';
1662 1662
     if ($installType == 'update') {
1663 1663
         if ($allowSelfReg == 'true') {
@@ -1667,17 +1667,17 @@  discard block
 block discarded – undo
1667 1667
         } else {
1668 1668
             $label = get_lang('AfterApproval');
1669 1669
         }
1670
-        $html .= '<input type="hidden" name="allowSelfReg" value="'. $allowSelfReg .'" />'. $label;
1670
+        $html .= '<input type="hidden" name="allowSelfReg" value="'.$allowSelfReg.'" />'.$label;
1671 1671
     } else {
1672 1672
         $html .= '<div class="control-group">';
1673 1673
         $html .= '<label class="checkbox-inline">
1674
-                        <input type="radio" name="allowSelfReg" value="1" id="allowSelfReg1" '. ($allowSelfReg == 'true' ? 'checked="checked" ' : '') . ' /> '. get_lang('Yes') .'
1674
+                        <input type="radio" name="allowSelfReg" value="1" id="allowSelfReg1" '. ($allowSelfReg == 'true' ? 'checked="checked" ' : '').' /> '.get_lang('Yes').'
1675 1675
                     </label>';
1676 1676
         $html .= '<label class="checkbox-inline">
1677
-                        <input type="radio" name="allowSelfReg" value="0" id="allowSelfReg0" '. ($allowSelfReg == 'false' ? '' : 'checked="checked" ') .' /> '. get_lang('No') .'
1677
+                        <input type="radio" name="allowSelfReg" value="0" id="allowSelfReg0" '. ($allowSelfReg == 'false' ? '' : 'checked="checked" ').' /> '.get_lang('No').'
1678 1678
                     </label>';
1679 1679
          $html .= '<label class="checkbox-inline">
1680
-                    <input type="radio" name="allowSelfReg" value="0" id="allowSelfReg0" '. ($allowSelfReg == 'approval' ? '' : 'checked="checked" ') .' /> '. get_lang('AfterApproval') .'
1680
+                    <input type="radio" name="allowSelfReg" value="0" id="allowSelfReg0" '. ($allowSelfReg == 'approval' ? '' : 'checked="checked" ').' /> '.get_lang('AfterApproval').'
1681 1681
                 </label>';
1682 1682
         $html .= '</div>';
1683 1683
     }
@@ -1685,7 +1685,7 @@  discard block
 block discarded – undo
1685 1685
     $html .= '</div>';
1686 1686
 
1687 1687
     $html .= '<div class="form-group">';
1688
-    $html .= '<label class="col-sm-6 control-label">'. get_lang('AllowSelfRegProf') .'</label>
1688
+    $html .= '<label class="col-sm-6 control-label">'.get_lang('AllowSelfRegProf').'</label>
1689 1689
         <div class="col-sm-6">';
1690 1690
     if ($installType == 'update') {
1691 1691
         if ($allowSelfRegProf == 'true') {
@@ -1693,16 +1693,16 @@  discard block
 block discarded – undo
1693 1693
         } else {
1694 1694
             $label = get_lang('No');
1695 1695
         }
1696
-        $html .= '<input type="hidden" name="allowSelfRegProf" value="'. $allowSelfRegProf.'" />'. $label;
1696
+        $html .= '<input type="hidden" name="allowSelfRegProf" value="'.$allowSelfRegProf.'" />'.$label;
1697 1697
     } else {
1698 1698
         $html .= '<div class="control-group">
1699 1699
                 <label class="checkbox-inline">
1700
-                    <input type="radio" name="allowSelfRegProf" value="1" id="allowSelfRegProf1" '. ($allowSelfRegProf ? 'checked="checked" ' : '') .'/>
1701
-                ' . get_lang('Yes') .'
1700
+                    <input type="radio" name="allowSelfRegProf" value="1" id="allowSelfRegProf1" '. ($allowSelfRegProf ? 'checked="checked" ' : '').'/>
1701
+                ' . get_lang('Yes').'
1702 1702
                 </label>';
1703 1703
         $html .= '<label class="checkbox-inline">
1704
-                    <input type="radio" name="allowSelfRegProf" value="0" id="allowSelfRegProf0" '. ($allowSelfRegProf ? '' : 'checked="checked" ') .' />
1705
-                   '. get_lang('No') .'
1704
+                    <input type="radio" name="allowSelfRegProf" value="0" id="allowSelfRegProf0" '. ($allowSelfRegProf ? '' : 'checked="checked" ').' />
1705
+                   '. get_lang('No').'
1706 1706
                 </label>';
1707 1707
         $html .= '</div>';
1708 1708
     }
@@ -1767,7 +1767,7 @@  discard block
 block discarded – undo
1767 1767
         "Macedonia", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands", "Mauritania", "Mauritius", "Mexico", "Micronesia", "Moldova", "Monaco", "Mongolia", "Morocco", "Mozambique", "Myanmar",
1768 1768
         "Namibia", "Nauru", "Nepa", "Netherlands", "New Zealand", "Nicaragua", "Niger", "Nigeria", "Norway",
1769 1769
         "Oman",
1770
-        "Pakistan", "Palau", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines", "Poland","Portugal",
1770
+        "Pakistan", "Palau", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines", "Poland", "Portugal",
1771 1771
         "Qatar",
1772 1772
         "Romania", "Russia", "Rwanda",
1773 1773
         "Saint Kitts and Nevis", "Saint Lucia", "Saint Vincent", "Samoa", "San Marino", "Sao Tome and Principe", "Saudi Arabia", "Senegal", "Serbia and Montenegro", "Seychelles", "Sierra Leone", "Singapore", "Slovakia", "Slovenia", "Solomon Islands", "Somalia", "South Africa", "Spain", "Sri Lanka", "Sudan", "Suriname", "Swaziland", "Sweden", "Switzerland", "Syria",
@@ -1814,11 +1814,11 @@  discard block
 block discarded – undo
1814 1814
     $permissions_for_new_directories = isset($_SESSION['permissions_for_new_directories']) ? $_SESSION['permissions_for_new_directories'] : 0770;
1815 1815
     $permissions_for_new_files = isset($_SESSION['permissions_for_new_files']) ? $_SESSION['permissions_for_new_files'] : 0660;
1816 1816
     // use decoct() to store as string
1817
-    $sql = "UPDATE $table SET selected_value = '0" . decoct($permissions_for_new_directories) . "'
1817
+    $sql = "UPDATE $table SET selected_value = '0".decoct($permissions_for_new_directories)."'
1818 1818
               WHERE variable  = 'permissions_for_new_directories'";
1819 1819
     Database::query($sql);
1820 1820
 
1821
-    $sql = "UPDATE $table SET selected_value = '0" . decoct($permissions_for_new_files) . "' WHERE variable  = 'permissions_for_new_files'";
1821
+    $sql = "UPDATE $table SET selected_value = '0".decoct($permissions_for_new_files)."' WHERE variable  = 'permissions_for_new_files'";
1822 1822
     Database::query($sql);
1823 1823
 
1824 1824
     if (isset($_SESSION['permissions_for_new_directories'])) {
@@ -1838,8 +1838,8 @@  discard block
 block discarded – undo
1838 1838
 function compare_setting_values($current_value, $wanted_value)
1839 1839
 {
1840 1840
     $current_value_string = $current_value;
1841
-    $current_value = (float)$current_value;
1842
-    $wanted_value = (float)$wanted_value;
1841
+    $current_value = (float) $current_value;
1842
+    $wanted_value = (float) $wanted_value;
1843 1843
 
1844 1844
     if ($current_value >= $wanted_value) {
1845 1845
         return Display::label($current_value_string, 'success');
@@ -1890,7 +1890,7 @@  discard block
 block discarded – undo
1890 1890
 
1891 1891
                     fwrite($fp, $out);
1892 1892
                     while (!feof($fp)) {
1893
-                        $result = str_replace("\r\n", '',fgets($fp, 128));
1893
+                        $result = str_replace("\r\n", '', fgets($fp, 128));
1894 1894
                         if (!empty($result) && $result == '123') {
1895 1895
                             $output = true;
1896 1896
                         }
@@ -1913,7 +1913,7 @@  discard block
 block discarded – undo
1913 1913
                     curl_setopt($ch, CURLOPT_URL, $url);
1914 1914
                     //curl_setopt($ch, CURLOPT_TIMEOUT, 30);
1915 1915
                     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
1916
-                    $result = curl_exec ($ch);
1916
+                    $result = curl_exec($ch);
1917 1917
                     if (!empty($result) && $result == '123') {
1918 1918
                         $output = true;
1919 1919
                     }
@@ -2127,12 +2127,12 @@  discard block
 block discarded – undo
2127 2127
         $adminPhoneForm,
2128 2128
         '', //$picture_uri = '',
2129 2129
         PLATFORM_AUTH_SOURCE,
2130
-        '',//$expirationDate,
2130
+        '', //$expirationDate,
2131 2131
         1,
2132 2132
         0,
2133 2133
         null,
2134 2134
         '',
2135
-        false,  //$send_mail = false,
2135
+        false, //$send_mail = false,
2136 2136
         true //$isAdmin = false
2137 2137
     );
2138 2138
 
@@ -2154,7 +2154,7 @@  discard block
 block discarded – undo
2154 2154
         0,
2155 2155
         null,
2156 2156
         '',
2157
-        false,  //$send_mail = false,
2157
+        false, //$send_mail = false,
2158 2158
         false //$isAdmin = false
2159 2159
     );
2160 2160
 
@@ -2184,7 +2184,7 @@  discard block
 block discarded – undo
2184 2184
     $finder = new \Symfony\Component\Finder\Finder();
2185 2185
     $files = $finder->files()->in($path);
2186 2186
     foreach ($files as $version) {
2187
-        $version = str_replace(['Version',  '.php' ], '', $version->getFilename());
2187
+        $version = str_replace(['Version', '.php'], '', $version->getFilename());
2188 2188
         $sql = "INSERT INTO version VALUES ('$version')";
2189 2189
         Database::query($sql);
2190 2190
     }
@@ -2230,7 +2230,7 @@  discard block
 block discarded – undo
2230 2230
                 SET selected_value = '".$param->selected_value."'
2231 2231
                 WHERE variable = '".$param->variable."'";
2232 2232
         if (!empty($param->subkey)) {
2233
-            $sql .= " AND subkey='" . $param->subkey . "'";
2233
+            $sql .= " AND subkey='".$param->subkey."'";
2234 2234
         }
2235 2235
         Database::query($sql);
2236 2236
     }
Please login to merge, or discard this patch.
main/permissions/permissions_functions.inc.php 4 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 
119 119
 /**
120 120
 * This function retrieves the existing permissions of a user, group or role.
121
-* @param $content are we retrieving the rights of a user, a group or a role (the database depends on it)
121
+* @param string $content are we retrieving the rights of a user, a group or a role (the database depends on it)
122 122
 * @param $id the id of the user, group or role
123 123
 * @author Patrick Cool <[email protected]>, Ghent University
124 124
 * @version 1.0
@@ -526,7 +526,7 @@  discard block
 block discarded – undo
526 526
 
527 527
 /**
528 528
 * This function gets all the roles that are defined
529
-* @param $content are we finding the roles for a user or a group (the database depends on it)
529
+* @param string $content are we finding the roles for a user or a group (the database depends on it)
530 530
 * @param $id the id of the user or group
531 531
 * @param string	Deprecated parameter allowing use of 'platform' scope - the corresponding tables don't exist anymore so the scope is always set to 'course'
532 532
 * @return array that contains the name of the roles the user has
Please login to merge, or discard this patch.
Braces   +10 added lines, -16 removed lines patch added patch discarded remove patch
@@ -132,24 +132,20 @@  discard block
 block discarded – undo
132 132
 	{
133 133
 		$table=Database::get_course_table(TABLE_PERMISSION_USER);
134 134
 		$id_field = 'user_id';
135
-	}
136
-	elseif ($content == 'group')
135
+	} elseif ($content == 'group')
137 136
 	{
138 137
 		$table=Database::get_course_table(TABLE_PERMISSION_GROUP);
139 138
 		$id_field = 'group_id';
140
-	}
141
-	elseif ($content == 'role')
139
+	} elseif ($content == 'role')
142 140
 	{
143 141
 		$table=Database::get_course_table(TABLE_ROLE_PERMISSION);
144 142
 		$id_field = 'role_id';
145
-	}
146
-	elseif ($content == 'platform_role')
143
+	} elseif ($content == 'platform_role')
147 144
 	{
148 145
 		$table=Database::get_main_table(TABLE_ROLE_PERMISSION);
149 146
 		$id_field = 'role_id';
150 147
         $course_id_condition = '';
151
-	}
152
-	elseif ($content == 'task')
148
+	} elseif ($content == 'task')
153 149
 	{
154 150
 		$table=Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS);
155 151
 		$id_field = 'task_id';
@@ -162,8 +158,9 @@  discard block
 block discarded – undo
162 158
 		WHERE $course_id_condition " . $id_field . "='" . Database::escape_string($id) . "'";
163 159
 	$result = Database::query($sql);
164 160
 
165
-	while($row = Database::fetch_array($result))
166
-		$currentpermissions[$row['tool']][] = $row['action'];
161
+	while($row = Database::fetch_array($result)) {
162
+			$currentpermissions[$row['tool']][] = $row['action'];
163
+	}
167 164
 
168 165
 	return $currentpermissions;
169 166
 }
@@ -321,14 +318,12 @@  discard block
 block discarded – undo
321 318
 	if ($course_admin)
322 319
 	{
323 320
 		echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">";
324
-	}
325
-	else
321
+	} else
326 322
 	{
327 323
 		if (!empty($inherited_permissions) and in_array($permission,$inherited_permissions[$tool]))
328 324
 		{
329 325
 			echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">";
330
-		}
331
-		else
326
+		} else
332 327
 		{
333 328
 			if (is_array($permission_array[$tool]) AND in_array($permission,$permission_array[$tool]))
334 329
 			{
@@ -439,8 +434,7 @@  discard block
 block discarded – undo
439 434
 			$checked='checked';
440 435
 			$image='checkbox_on2.gif';
441 436
 			$action='revoke';
442
-		}
443
-		else
437
+		} else
444 438
 		{
445 439
 			$checked='';
446 440
 			$image='wrong.gif';
Please login to merge, or discard this patch.
Indentation   +401 added lines, -401 removed lines patch added patch discarded remove patch
@@ -25,38 +25,38 @@  discard block
 block discarded – undo
25 25
 function store_permissions($content, $id) {
26 26
     $course_id = api_get_course_int_id();
27 27
     
28
-	// Which database are we using (depending on the $content parameter)
29
-	if ($content=='user')
30
-	{
31
-		$table=Database::get_course_table(TABLE_PERMISSION_USER);
32
-		$id_field = user_id;
33
-	}
34
-	if ($content=='group')
35
-	{
36
-		$table=Database::get_course_table(TABLE_PERMISSION_GROUP);
37
-		$id_field = group_id;
38
-	}
39
-	if ($content=='role')
40
-	{
41
-		$table=Database::get_course_table(TABLE_ROLE_PERMISSION);
42
-		$id_field = role_id;
43
-	}
44
-
45
-	// We first delete all the existing permissions for that user/group/role
46
-	$sql="DELETE FROM $table  WHERE c_id = $course_id AND $id_field = '".Database::escape_string($id)."'";
47
-	$result=Database::query($sql);
48
-
49
-	// looping through the post values to find the permission (containing the string permission* )
50
-	foreach ($_POST as $key => $value)
51
-	{
52
-		if (strstr($key,"permission*"))
53
-		{
54
-			list($brol,$tool,$action)=explode("*",$key);
55
-			$sql="INSERT INTO $table (c_id, $id_field,tool,action) VALUES ($course_id, '".Database::escape_string($id)."','".Database::escape_string($tool)."','".Database::escape_string($action)."')";
56
-			$result=Database::query($sql);
57
-		}
58
-	}
59
-	return get_lang('PermissionsStored');
28
+    // Which database are we using (depending on the $content parameter)
29
+    if ($content=='user')
30
+    {
31
+        $table=Database::get_course_table(TABLE_PERMISSION_USER);
32
+        $id_field = user_id;
33
+    }
34
+    if ($content=='group')
35
+    {
36
+        $table=Database::get_course_table(TABLE_PERMISSION_GROUP);
37
+        $id_field = group_id;
38
+    }
39
+    if ($content=='role')
40
+    {
41
+        $table=Database::get_course_table(TABLE_ROLE_PERMISSION);
42
+        $id_field = role_id;
43
+    }
44
+
45
+    // We first delete all the existing permissions for that user/group/role
46
+    $sql="DELETE FROM $table  WHERE c_id = $course_id AND $id_field = '".Database::escape_string($id)."'";
47
+    $result=Database::query($sql);
48
+
49
+    // looping through the post values to find the permission (containing the string permission* )
50
+    foreach ($_POST as $key => $value)
51
+    {
52
+        if (strstr($key,"permission*"))
53
+        {
54
+            list($brol,$tool,$action)=explode("*",$key);
55
+            $sql="INSERT INTO $table (c_id, $id_field,tool,action) VALUES ($course_id, '".Database::escape_string($id)."','".Database::escape_string($tool)."','".Database::escape_string($action)."')";
56
+            $result=Database::query($sql);
57
+        }
58
+    }
59
+    return get_lang('PermissionsStored');
60 60
 }
61 61
 
62 62
 /**
@@ -70,50 +70,50 @@  discard block
 block discarded – undo
70 70
 * @version 1.0
71 71
 */
72 72
 function store_one_permission($content, $action, $id, $tool,$permission) {
73
-	global $rights_full;
73
+    global $rights_full;
74 74
     $course_id = api_get_course_int_id();
75
-	// for some reason I don't know, he can't get to the $rights_full array, so commented the following lines out.
75
+    // for some reason I don't know, he can't get to the $rights_full array, so commented the following lines out.
76 76
 
77
-	// check
78
-	//if(!in_array($permission, $rights_full))
79
-	//{
80
-	//	return get_lang('Error');
81
-	//}
77
+    // check
78
+    //if(!in_array($permission, $rights_full))
79
+    //{
80
+    //	return get_lang('Error');
81
+    //}
82 82
 
83
-	// Which database are we using (depending on the $content parameter)
83
+    // Which database are we using (depending on the $content parameter)
84 84
     
85
-	if ($content=='user') {
86
-		$table=Database::get_course_table(TABLE_PERMISSION_USER);
87
-		$id_field = user_id;
88
-	}
89
-	if ($content=='group')
90
-	{
91
-		$table=Database::get_course_table(TABLE_PERMISSION_GROUP);
92
-		$id_field = group_id;
93
-	}
94
-	if ($content=='role')
95
-	{
96
-		$table=Database::get_course_table(TABLE_ROLE_PERMISSION);
97
-		$id_field = role_id;
98
-	}
99
-
100
-	// grating a right
101
-	if ($action=='grant') {
102
-		$sql="INSERT INTO $table (c_id, $id_field,tool,action) VALUES ($course_id, '".Database::escape_string($id)."','".Database::escape_string($tool)."','".Database::escape_string($permission)."')";
103
-		$result=Database::query($sql);
104
-		if($result) {
105
-			$result_message=get_lang('PermissionGranted');
106
-		}
107
-	}
108
-	if ($action=='revoke')
109
-	{
110
-		$sql="DELETE FROM $table WHERE c_id = $course_id AND $id_field = '".Database::escape_string($id)."' AND tool='".Database::escape_string($tool)."' AND action='".Database::escape_string($permission)."'";
111
-		$result=Database::query($sql);
112
-		if($result) {
113
-			$result_message=get_lang('PermissionRevoked');
114
-		}
115
-	}
116
-	return $result_message;
85
+    if ($content=='user') {
86
+        $table=Database::get_course_table(TABLE_PERMISSION_USER);
87
+        $id_field = user_id;
88
+    }
89
+    if ($content=='group')
90
+    {
91
+        $table=Database::get_course_table(TABLE_PERMISSION_GROUP);
92
+        $id_field = group_id;
93
+    }
94
+    if ($content=='role')
95
+    {
96
+        $table=Database::get_course_table(TABLE_ROLE_PERMISSION);
97
+        $id_field = role_id;
98
+    }
99
+
100
+    // grating a right
101
+    if ($action=='grant') {
102
+        $sql="INSERT INTO $table (c_id, $id_field,tool,action) VALUES ($course_id, '".Database::escape_string($id)."','".Database::escape_string($tool)."','".Database::escape_string($permission)."')";
103
+        $result=Database::query($sql);
104
+        if($result) {
105
+            $result_message=get_lang('PermissionGranted');
106
+        }
107
+    }
108
+    if ($action=='revoke')
109
+    {
110
+        $sql="DELETE FROM $table WHERE c_id = $course_id AND $id_field = '".Database::escape_string($id)."' AND tool='".Database::escape_string($tool)."' AND action='".Database::escape_string($permission)."'";
111
+        $result=Database::query($sql);
112
+        if($result) {
113
+            $result_message=get_lang('PermissionRevoked');
114
+        }
115
+    }
116
+    return $result_message;
117 117
 }
118 118
 
119 119
 /**
@@ -125,47 +125,47 @@  discard block
 block discarded – undo
125 125
 */
126 126
 function get_permissions($content, $id) {
127 127
     $course_id = api_get_course_int_id();
128
-	$currentpermissions=array();
129
-	// Which database are we using (depending on the $content parameter)
128
+    $currentpermissions=array();
129
+    // Which database are we using (depending on the $content parameter)
130 130
     $course_id_condition = " c_id = $course_id AND ";
131
-	if ($content == 'user')
132
-	{
133
-		$table=Database::get_course_table(TABLE_PERMISSION_USER);
134
-		$id_field = 'user_id';
135
-	}
136
-	elseif ($content == 'group')
137
-	{
138
-		$table=Database::get_course_table(TABLE_PERMISSION_GROUP);
139
-		$id_field = 'group_id';
140
-	}
141
-	elseif ($content == 'role')
142
-	{
143
-		$table=Database::get_course_table(TABLE_ROLE_PERMISSION);
144
-		$id_field = 'role_id';
145
-	}
146
-	elseif ($content == 'platform_role')
147
-	{
148
-		$table=Database::get_main_table(TABLE_ROLE_PERMISSION);
149
-		$id_field = 'role_id';
131
+    if ($content == 'user')
132
+    {
133
+        $table=Database::get_course_table(TABLE_PERMISSION_USER);
134
+        $id_field = 'user_id';
135
+    }
136
+    elseif ($content == 'group')
137
+    {
138
+        $table=Database::get_course_table(TABLE_PERMISSION_GROUP);
139
+        $id_field = 'group_id';
140
+    }
141
+    elseif ($content == 'role')
142
+    {
143
+        $table=Database::get_course_table(TABLE_ROLE_PERMISSION);
144
+        $id_field = 'role_id';
145
+    }
146
+    elseif ($content == 'platform_role')
147
+    {
148
+        $table=Database::get_main_table(TABLE_ROLE_PERMISSION);
149
+        $id_field = 'role_id';
150 150
         $course_id_condition = '';
151
-	}
152
-	elseif ($content == 'task')
153
-	{
154
-		$table=Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS);
155
-		$id_field = 'task_id';
156
-	}
157
-
158
-	// finding all the permissions. We store this in a multidimensional array
159
-	// where the first dimension is the tool.
160
-	$sql="
151
+    }
152
+    elseif ($content == 'task')
153
+    {
154
+        $table=Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS);
155
+        $id_field = 'task_id';
156
+    }
157
+
158
+    // finding all the permissions. We store this in a multidimensional array
159
+    // where the first dimension is the tool.
160
+    $sql="
161 161
 		SELECT * FROM " . $table . "
162 162
 		WHERE $course_id_condition " . $id_field . "='" . Database::escape_string($id) . "'";
163
-	$result = Database::query($sql);
163
+    $result = Database::query($sql);
164 164
 
165
-	while($row = Database::fetch_array($result))
166
-		$currentpermissions[$row['tool']][] = $row['action'];
165
+    while($row = Database::fetch_array($result))
166
+        $currentpermissions[$row['tool']][] = $row['action'];
167 167
 
168
-	return $currentpermissions;
168
+    return $currentpermissions;
169 169
 }
170 170
 
171 171
 /**
@@ -179,38 +179,38 @@  discard block
 block discarded – undo
179 179
 */
180 180
 function limited_or_full($current_permissions)
181 181
 {
182
-	if (api_get_setting('permissions')=='limited')
183
-	{
184
-		foreach ($current_permissions as $tool=>$tool_rights)
185
-		{
186
-			// we loop through the possible permissions of a tool and unset the entry if it is view
187
-			// if it is visibility or move we have to grant the edit right
188
-			foreach ($tool_rights as $key=>$value)
189
-			{
190
-				if ($value=='View')
191
-				{
192
-					unset($current_permissions[$tool][$key]);
193
-				}
194
-				if ($value=='Visibility' OR $value=='Move')
195
-				{
196
-					if (!in_array('Edit',$current_permissions[$tool]))
197
-					{
198
-						$current_permissions[$tool][]='Edit';
199
-					}
200
-					unset($current_permissions[$tool][$key]);
201
-				}
202
-				//else
203
-				//{
204
-				//	$current_permissions[$tool][]=$value;
205
-				//}
206
-			}
207
-		}
208
-		return $current_permissions;
209
-	}
210
-	if (api_get_setting('permissions')=='full')
211
-	{
212
-		return $current_permissions;
213
-	}
182
+    if (api_get_setting('permissions')=='limited')
183
+    {
184
+        foreach ($current_permissions as $tool=>$tool_rights)
185
+        {
186
+            // we loop through the possible permissions of a tool and unset the entry if it is view
187
+            // if it is visibility or move we have to grant the edit right
188
+            foreach ($tool_rights as $key=>$value)
189
+            {
190
+                if ($value=='View')
191
+                {
192
+                    unset($current_permissions[$tool][$key]);
193
+                }
194
+                if ($value=='Visibility' OR $value=='Move')
195
+                {
196
+                    if (!in_array('Edit',$current_permissions[$tool]))
197
+                    {
198
+                        $current_permissions[$tool][]='Edit';
199
+                    }
200
+                    unset($current_permissions[$tool][$key]);
201
+                }
202
+                //else
203
+                //{
204
+                //	$current_permissions[$tool][]=$value;
205
+                //}
206
+            }
207
+        }
208
+        return $current_permissions;
209
+    }
210
+    if (api_get_setting('permissions')=='full')
211
+    {
212
+        return $current_permissions;
213
+    }
214 214
 }
215 215
 /**
216 216
 * This function displays a checked or unchecked checkbox. The checkbox will be checked if the
@@ -224,12 +224,12 @@  discard block
 block discarded – undo
224 224
 */
225 225
 function display_checkbox_matrix($permission_array, $tool, $permission, $inherited_permissions=array())
226 226
 {
227
-	$checked="";
228
-	if (is_array($permission_array[$tool]) AND in_array($permission,$permission_array[$tool]))
229
-	{
230
-		$checked="checked";
231
-	}
232
-	echo "\t\t\t<input type=\"checkbox\" name=\"permission*$tool*$permission\" $checked>\n";
227
+    $checked="";
228
+    if (is_array($permission_array[$tool]) AND in_array($permission,$permission_array[$tool]))
229
+    {
230
+        $checked="checked";
231
+    }
232
+    echo "\t\t\t<input type=\"checkbox\" name=\"permission*$tool*$permission\" $checked>\n";
233 233
 
234 234
 }
235 235
 
@@ -245,62 +245,62 @@  discard block
 block discarded – undo
245 245
 */
246 246
 function display_image_matrix($permission_array, $tool, $permission,$inherited_permissions=array(), $course_admin=false, $editable=true)
247 247
 {
248
-	if ($course_admin) {
249
-		echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">";
250
-	} else {
251
-		if (in_array($permission,$inherited_permissions[$tool])) {
252
-			echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">";
253
-		} else {
254
-			if (is_array($permission_array[$tool]) AND in_array($permission,$permission_array[$tool])) {
255
-				if ($editable) {
256
-					$url=api_get_self();
257
-					$urlparameters = '';
258
-					foreach($_GET as $key=>$value) {
259
-						$parameter[$key]=$value;
260
-					}
261
-					$parameter['action']='revoke';
262
-					$parameter['permission']=$permission;
263
-					$parameter['tool']=$tool;
264
-					foreach ($parameter as $key=>$value) {
265
-						$urlparameters.=$key.'='.$value.'&amp;';
266
-					}
267
-					$url=$url.'?'.$urlparameters;
268
-
269
-					echo "\t\t\t <a href=\"".$url."\">";
270
-				}
271
-				echo "<img src=\"../img/checkbox_on2.gif\" border=\"0\"/>";
272
-				if ($editable) {
273
-					echo "</a>";
274
-				}
275
-			} else {
276
-				if ($editable)
277
-				{
278
-					$url=api_get_self();
279
-					$urlparameters = '';
280
-					foreach ($_GET as $key=>$value)
281
-					{
282
-						$parameter[$key]=$value;
283
-					}
284
-					$parameter['action']='grant';
285
-					$parameter['permission']=$permission;
286
-					$parameter['tool']=$tool;
287
-					foreach ($parameter as $key=>$value)
288
-					{
289
-						$urlparameters.=$key.'='.$value.'&amp;';
290
-					}
291
-					$url=$url.'?'.$urlparameters;
292
-
293
-					//echo "\t\t\t <a href=\"".str_replace('&', '&amp;', $_SERVER['REQUEST_URI'])."&amp;action=grant&amp;permission=$permission&amp;tool=$tool\">";
294
-					echo "\t\t\t <a href=\"".$url."\">";
295
-				}
296
-				echo "<img src=\"../img/wrong.gif\" border=\"0\"/>";
297
-				if ($editable)
298
-				{
299
-					echo "</a>";
300
-				}
301
-			}
302
-		}
303
-	}
248
+    if ($course_admin) {
249
+        echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">";
250
+    } else {
251
+        if (in_array($permission,$inherited_permissions[$tool])) {
252
+            echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">";
253
+        } else {
254
+            if (is_array($permission_array[$tool]) AND in_array($permission,$permission_array[$tool])) {
255
+                if ($editable) {
256
+                    $url=api_get_self();
257
+                    $urlparameters = '';
258
+                    foreach($_GET as $key=>$value) {
259
+                        $parameter[$key]=$value;
260
+                    }
261
+                    $parameter['action']='revoke';
262
+                    $parameter['permission']=$permission;
263
+                    $parameter['tool']=$tool;
264
+                    foreach ($parameter as $key=>$value) {
265
+                        $urlparameters.=$key.'='.$value.'&amp;';
266
+                    }
267
+                    $url=$url.'?'.$urlparameters;
268
+
269
+                    echo "\t\t\t <a href=\"".$url."\">";
270
+                }
271
+                echo "<img src=\"../img/checkbox_on2.gif\" border=\"0\"/>";
272
+                if ($editable) {
273
+                    echo "</a>";
274
+                }
275
+            } else {
276
+                if ($editable)
277
+                {
278
+                    $url=api_get_self();
279
+                    $urlparameters = '';
280
+                    foreach ($_GET as $key=>$value)
281
+                    {
282
+                        $parameter[$key]=$value;
283
+                    }
284
+                    $parameter['action']='grant';
285
+                    $parameter['permission']=$permission;
286
+                    $parameter['tool']=$tool;
287
+                    foreach ($parameter as $key=>$value)
288
+                    {
289
+                        $urlparameters.=$key.'='.$value.'&amp;';
290
+                    }
291
+                    $url=$url.'?'.$urlparameters;
292
+
293
+                    //echo "\t\t\t <a href=\"".str_replace('&', '&amp;', $_SERVER['REQUEST_URI'])."&amp;action=grant&amp;permission=$permission&amp;tool=$tool\">";
294
+                    echo "\t\t\t <a href=\"".$url."\">";
295
+                }
296
+                echo "<img src=\"../img/wrong.gif\" border=\"0\"/>";
297
+                if ($editable)
298
+                {
299
+                    echo "</a>";
300
+                }
301
+            }
302
+        }
303
+    }
304 304
 }
305 305
 
306 306
 
@@ -318,72 +318,72 @@  discard block
 block discarded – undo
318 318
 function display_image_matrix_for_blogs($permission_array, $user_id, $tool, $permission,$inherited_permissions=array(), $course_admin=false, $editable=true)
319 319
 {
320 320
 
321
-	if ($course_admin)
322
-	{
323
-		echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">";
324
-	}
325
-	else
326
-	{
327
-		if (!empty($inherited_permissions) and in_array($permission,$inherited_permissions[$tool]))
328
-		{
329
-			echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">";
330
-		}
331
-		else
332
-		{
333
-			if (is_array($permission_array[$tool]) AND in_array($permission,$permission_array[$tool]))
334
-			{
335
-				if ($editable)
336
-				{
337
-					$url = api_get_self();
338
-					$urlparameters = '';
339
-					foreach($_GET as $key => $value)
340
-					{
341
-						$parameter[$key] = $value;
342
-					}
343
-					$parameter['action']='manage_rights';
344
-					$parameter['do']='revoke';
345
-					$parameter['permission']=$permission;
346
-					$parameter['tool']=$tool;
347
-					$parameter['user_id']=$user_id;
348
-					foreach ($parameter as $key=>$value)
349
-					{
350
-						$urlparameters .= $key . '=' . $value . '&amp;';
351
-					}
352
-					$url = $url . '?' . $urlparameters;
353
-
354
-					echo "\t\t\t <a href=\"".$url."\">";
355
-				}
356
-				echo "<img src=\"../img/checkbox_on2.gif\" border=\"0\"/ title=\"".get_lang('UserHasPermission')."\">";
357
-				if ($editable) {
358
-					echo "</a>";
359
-				}
360
-			} else {
361
-				if ($editable) {
362
-					$url = api_get_self();
363
-					$urlparameters = '';
364
-					foreach ($_GET as $key=>$value) {
365
-						$parameter[$key]=$value;
366
-					}
367
-					$parameter['action']='manage_rights';
368
-					$parameter['do']='grant';
369
-					$parameter['permission']=$permission;
370
-					$parameter['tool']=$tool;
371
-					$parameter['user_id']=$user_id;
372
-					foreach ($parameter as $key=>$value) {
373
-						$urlparameters .= $key . '=' . $value . '&amp;';
374
-					}
375
-					$url=$url.'?'.$urlparameters;
376
-
377
-					//echo "\t\t\t <a href=\"".str_replace('&', '&amp;', $_SERVER['REQUEST_URI'])."&amp;action=grant&amp;permission=$permission&amp;tool=$tool\">";
378
-					echo "\t\t\t <a href=\"".$url."\">";
379
-				}
380
-				echo "<img src=\"../img/wrong.gif\" border=\"0\"/ title=\"".get_lang('UserHasPermissionNot')."\">";
381
-				if ($editable) {
382
-					echo "</a>";
383
-				}
384
-			}
385
-		}
386
-	}
321
+    if ($course_admin)
322
+    {
323
+        echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">";
324
+    }
325
+    else
326
+    {
327
+        if (!empty($inherited_permissions) and in_array($permission,$inherited_permissions[$tool]))
328
+        {
329
+            echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">";
330
+        }
331
+        else
332
+        {
333
+            if (is_array($permission_array[$tool]) AND in_array($permission,$permission_array[$tool]))
334
+            {
335
+                if ($editable)
336
+                {
337
+                    $url = api_get_self();
338
+                    $urlparameters = '';
339
+                    foreach($_GET as $key => $value)
340
+                    {
341
+                        $parameter[$key] = $value;
342
+                    }
343
+                    $parameter['action']='manage_rights';
344
+                    $parameter['do']='revoke';
345
+                    $parameter['permission']=$permission;
346
+                    $parameter['tool']=$tool;
347
+                    $parameter['user_id']=$user_id;
348
+                    foreach ($parameter as $key=>$value)
349
+                    {
350
+                        $urlparameters .= $key . '=' . $value . '&amp;';
351
+                    }
352
+                    $url = $url . '?' . $urlparameters;
353
+
354
+                    echo "\t\t\t <a href=\"".$url."\">";
355
+                }
356
+                echo "<img src=\"../img/checkbox_on2.gif\" border=\"0\"/ title=\"".get_lang('UserHasPermission')."\">";
357
+                if ($editable) {
358
+                    echo "</a>";
359
+                }
360
+            } else {
361
+                if ($editable) {
362
+                    $url = api_get_self();
363
+                    $urlparameters = '';
364
+                    foreach ($_GET as $key=>$value) {
365
+                        $parameter[$key]=$value;
366
+                    }
367
+                    $parameter['action']='manage_rights';
368
+                    $parameter['do']='grant';
369
+                    $parameter['permission']=$permission;
370
+                    $parameter['tool']=$tool;
371
+                    $parameter['user_id']=$user_id;
372
+                    foreach ($parameter as $key=>$value) {
373
+                        $urlparameters .= $key . '=' . $value . '&amp;';
374
+                    }
375
+                    $url=$url.'?'.$urlparameters;
376
+
377
+                    //echo "\t\t\t <a href=\"".str_replace('&', '&amp;', $_SERVER['REQUEST_URI'])."&amp;action=grant&amp;permission=$permission&amp;tool=$tool\">";
378
+                    echo "\t\t\t <a href=\"".$url."\">";
379
+                }
380
+                echo "<img src=\"../img/wrong.gif\" border=\"0\"/ title=\"".get_lang('UserHasPermissionNot')."\">";
381
+                if ($editable) {
382
+                    echo "</a>";
383
+                }
384
+            }
385
+        }
386
+    }
387 387
 }
388 388
 
389 389
 
@@ -394,41 +394,41 @@  discard block
 block discarded – undo
394 394
 */
395 395
 function display_role_list($current_course_roles, $current_platform_roles)
396 396
 {
397
-	global $setting_visualisation;
397
+    global $setting_visualisation;
398 398
     $course_id = api_get_course_int_id();
399 399
 
400
-	$coures_roles_table=Database::get_course_table(TABLE_ROLE);
401
-
402
-	// course roles
403
-	$sql="SELECT * FROM $coures_roles_table WHERE c_id = $course_id ";
404
-	$result=Database::query($sql);
405
-	while ($row=Database::fetch_array($result))
406
-	{
407
-		if (in_array($row['role_id'], $current_course_roles))
408
-		{
409
-			$checked='checked';
410
-			$image='checkbox_on2.gif';
411
-			$action='revoke';
412
-		}
413
-		else
414
-		{
415
-			$checked='';
416
-			$image='wrong.gif';
417
-			$action='grant';
418
-		}
419
-		if ($setting_visualisation=='checkbox')
420
-		{
421
-			echo "<input type=\"checkbox\" name=\"role*course*".$row['role_id']."\" $checked>";
422
-		}
423
-		if ($setting_visualisation=='image')
424
-		{
425
-			echo "<a href=\"".str_replace('&', '&amp;', $_SERVER['REQUEST_URI'])."&amp;action=$action&amp;role=".$row['role_id']."&amp;scope=course\"><img src=\"../img/".$image."\" border=\"0\"/></a>";
426
-		}
427
-
428
-
429
-		echo $row['role_name']." <a href=\"../permissions/roles.php?role_id=".$row['role_id']."&amp;scope=course\"><img src=\"../img/edit.gif\" /></a><br />\n";
430
-		echo $row['role_comment']."<br />\n";
431
-	}
400
+    $coures_roles_table=Database::get_course_table(TABLE_ROLE);
401
+
402
+    // course roles
403
+    $sql="SELECT * FROM $coures_roles_table WHERE c_id = $course_id ";
404
+    $result=Database::query($sql);
405
+    while ($row=Database::fetch_array($result))
406
+    {
407
+        if (in_array($row['role_id'], $current_course_roles))
408
+        {
409
+            $checked='checked';
410
+            $image='checkbox_on2.gif';
411
+            $action='revoke';
412
+        }
413
+        else
414
+        {
415
+            $checked='';
416
+            $image='wrong.gif';
417
+            $action='grant';
418
+        }
419
+        if ($setting_visualisation=='checkbox')
420
+        {
421
+            echo "<input type=\"checkbox\" name=\"role*course*".$row['role_id']."\" $checked>";
422
+        }
423
+        if ($setting_visualisation=='image')
424
+        {
425
+            echo "<a href=\"".str_replace('&', '&amp;', $_SERVER['REQUEST_URI'])."&amp;action=$action&amp;role=".$row['role_id']."&amp;scope=course\"><img src=\"../img/".$image."\" border=\"0\"/></a>";
426
+        }
427
+
428
+
429
+        echo $row['role_name']." <a href=\"../permissions/roles.php?role_id=".$row['role_id']."&amp;scope=course\"><img src=\"../img/edit.gif\" /></a><br />\n";
430
+        echo $row['role_comment']."<br />\n";
431
+    }
432 432
 }
433 433
 
434 434
 /**
@@ -442,24 +442,24 @@  discard block
 block discarded – undo
442 442
 */
443 443
 function get_roles($content,$id, $scope='course') {
444 444
     $course_id  = api_get_course_int_id();    
445
-	if ($content=='user') {
446
-		$table=Database::get_course_table(TABLE_ROLE_USER);
447
-		$id_field = user_id;
448
-	}
449
-	if ($content=='group') {
450
-		$table=Database::get_course_table(TABLE_ROLE_GROUP);
451
-		$id_field = 'group_id';
452
-	}
453
-	$table_role=Database::get_course_table(TABLE_ROLE);
454
-
455
-	$current_roles=array();
456
-	//$sql="SELECT role.role_id FROM $table role_group_user, $table_role role WHERE role_group_user.$id_field = '$id' AND role_group_user.role_id=role.role_id AND role_group_user.scope='".$scope."'";$sql="SELECT role.role_id FROM $table role_group_user, $table_role role WHERE role_group_user.$id_field = '$id' AND role_group_user.role_id=role.role_id AND role_group_user.scope='".$scope."'";
457
-	$sql="SELECT role_id FROM $table WHERE c_id = $course_id AND $id_field = '$id' AND scope='".$scope."'";
458
-	$result=Database::query($sql);
459
-	while ($row=Database::fetch_array($result)) {
460
-		$current_roles[]=$row['role_id'];
461
-	}
462
-	return $current_roles;
445
+    if ($content=='user') {
446
+        $table=Database::get_course_table(TABLE_ROLE_USER);
447
+        $id_field = user_id;
448
+    }
449
+    if ($content=='group') {
450
+        $table=Database::get_course_table(TABLE_ROLE_GROUP);
451
+        $id_field = 'group_id';
452
+    }
453
+    $table_role=Database::get_course_table(TABLE_ROLE);
454
+
455
+    $current_roles=array();
456
+    //$sql="SELECT role.role_id FROM $table role_group_user, $table_role role WHERE role_group_user.$id_field = '$id' AND role_group_user.role_id=role.role_id AND role_group_user.scope='".$scope."'";$sql="SELECT role.role_id FROM $table role_group_user, $table_role role WHERE role_group_user.$id_field = '$id' AND role_group_user.role_id=role.role_id AND role_group_user.scope='".$scope."'";
457
+    $sql="SELECT role_id FROM $table WHERE c_id = $course_id AND $id_field = '$id' AND scope='".$scope."'";
458
+    $result=Database::query($sql);
459
+    while ($row=Database::fetch_array($result)) {
460
+        $current_roles[]=$row['role_id'];
461
+    }
462
+    return $current_roles;
463 463
 }
464 464
 
465 465
 /**
@@ -472,25 +472,25 @@  discard block
 block discarded – undo
472 472
     $course_id = api_get_course_int_id();
473 473
     $course_id_condition = " WHERE c_id = $course_id ";
474 474
     
475
-	if ($content=='course')
476
-	{
477
-		$table_role=Database::get_course_table(TABLE_ROLE);
478
-	}
479
-	if ($content=='platform')
480
-	{
481
-		$table_role=Database::get_main_table(TABLE_ROLE);
482
-		$course_id_condition = '';
483
-	}
484
-
485
-	$current_roles=array();
486
-	$sql="SELECT * FROM $table_role $course_id_condition ";
487
-	$result=Database::query($sql);
488
-	while ($row=Database::fetch_array($result))
489
-	{
490
-		$roles[]=$row;
491
-	}
492
-
493
-	return $roles;
475
+    if ($content=='course')
476
+    {
477
+        $table_role=Database::get_course_table(TABLE_ROLE);
478
+    }
479
+    if ($content=='platform')
480
+    {
481
+        $table_role=Database::get_main_table(TABLE_ROLE);
482
+        $course_id_condition = '';
483
+    }
484
+
485
+    $current_roles=array();
486
+    $sql="SELECT * FROM $table_role $course_id_condition ";
487
+    $result=Database::query($sql);
488
+    while ($row=Database::fetch_array($result))
489
+    {
490
+        $roles[]=$row;
491
+    }
492
+
493
+    return $roles;
494 494
 }
495 495
 
496 496
 
@@ -506,34 +506,34 @@  discard block
 block discarded – undo
506 506
 */
507 507
 function get_roles_permissions($content,$id, $scope='course') {
508 508
     $course_id = api_get_course_int_id();
509
-	if ($content == 'user') {
510
-		$table=Database::get_course_table(TABLE_ROLE_USER);
511
-		$id_field = 'user_id';
512
-	}
513
-
514
-	if ($content == 'group') {
515
-		$table = Database::get_course_table(TABLE_ROLE_GROUP);
516
-		$id_field = 'group_id';
517
-	}
518
-
519
-	// course roles or platform roles
520
-	$scope = 'course';
521
-	if ($scope == 'course') {
522
-		$table_role = Database::get_course_table(TABLE_ROLE);
523
-		$table_role_permissions = Database::get_course_table(TABLE_ROLE_PERMISSION);
509
+    if ($content == 'user') {
510
+        $table=Database::get_course_table(TABLE_ROLE_USER);
511
+        $id_field = 'user_id';
512
+    }
513
+
514
+    if ($content == 'group') {
515
+        $table = Database::get_course_table(TABLE_ROLE_GROUP);
516
+        $id_field = 'group_id';
517
+    }
518
+
519
+    // course roles or platform roles
520
+    $scope = 'course';
521
+    if ($scope == 'course') {
522
+        $table_role = Database::get_course_table(TABLE_ROLE);
523
+        $table_role_permissions = Database::get_course_table(TABLE_ROLE_PERMISSION);
524 524
         
525 525
         $role_condition = " role.c_id = $course_id AND role_permissions.c_id = $course_id AND ";
526
-	}
526
+    }
527 527
 
528
-	if ($scope == 'platform') {
529
-		$table_role = Database::get_main_table(TABLE_ROLE);
530
-		$table_role_permissions = Database::get_main_table(TABLE_ROLE_PERMISSION);
528
+    if ($scope == 'platform') {
529
+        $table_role = Database::get_main_table(TABLE_ROLE);
530
+        $table_role_permissions = Database::get_main_table(TABLE_ROLE_PERMISSION);
531 531
         $role_condition = '';
532
-	}
532
+    }
533 533
 
534
-	$current_roles = array();
534
+    $current_roles = array();
535 535
 
536
-	$sql = "
536
+    $sql = "
537 537
 		SELECT *
538 538
 		FROM
539 539
 			" . $table . " role_group_user,
@@ -547,12 +547,12 @@  discard block
 block discarded – undo
547 547
 			role_group_user.role_id = role.role_id AND
548 548
 			role.role_id = role_permissions.role_id";
549 549
 
550
-	$result = Database::query($sql);
550
+    $result = Database::query($sql);
551 551
     $current_role_permissions = array();
552
-	while ($row=Database::fetch_array($result)) {
553
-		$current_role_permissions[$row['tool']][]=$row['action'];
552
+    while ($row=Database::fetch_array($result)) {
553
+        $current_role_permissions[$row['tool']][]=$row['action'];
554 554
     }
555
-	return $current_role_permissions;
555
+    return $current_role_permissions;
556 556
 }
557 557
 
558 558
 /**
@@ -566,34 +566,34 @@  discard block
 block discarded – undo
566 566
 
567 567
 function assign_role($content, $action, $id, $role_id, $scope='course') {
568 568
     $course_id = api_get_course_int_id();
569
-	// Which database are we using (depending on the $content parameter)
570
-	if ($content=='user') {
571
-		$table=Database::get_course_table(TABLE_ROLE_USER);
572
-		$id_field = 'user_id';
573
-	} elseif($content=='group') {
574
-		$table=Database::get_course_table(TABLE_ROLE_GROUP);
575
-		$id_field = 'group_id';
576
-	} else {
577
-		return  get_lang('Error');
578
-	}
579
-
580
-	// grating a right
581
-	if ($action=='grant') {
582
-		$sql="INSERT INTO $table (c_id, role_id, scope, $id_field) VALUES ($course_id, '".Database::escape_string($role_id)."','".Database::escape_string($scope)."','".Database::escape_string($id)."')";
583
-		$result=Database::query($sql);
584
-		if ($result) {
585
-			$result_message=get_lang('RoleGranted');
586
-		}
587
-	}
569
+    // Which database are we using (depending on the $content parameter)
570
+    if ($content=='user') {
571
+        $table=Database::get_course_table(TABLE_ROLE_USER);
572
+        $id_field = 'user_id';
573
+    } elseif($content=='group') {
574
+        $table=Database::get_course_table(TABLE_ROLE_GROUP);
575
+        $id_field = 'group_id';
576
+    } else {
577
+        return  get_lang('Error');
578
+    }
579
+
580
+    // grating a right
581
+    if ($action=='grant') {
582
+        $sql="INSERT INTO $table (c_id, role_id, scope, $id_field) VALUES ($course_id, '".Database::escape_string($role_id)."','".Database::escape_string($scope)."','".Database::escape_string($id)."')";
583
+        $result=Database::query($sql);
584
+        if ($result) {
585
+            $result_message=get_lang('RoleGranted');
586
+        }
587
+    }
588 588
     
589
-	if ($action=='revoke') {
590
-		$sql="DELETE FROM $table WHERE c_id = $course_id AND $id_field = '".Database::escape_string($id)."' AND role_id='".Database::escape_string($role_id)."'";
591
-		$result=Database::query($sql);
592
-		if ($result) {
593
-			$result_message=get_lang('RoleRevoked');
594
-		}
595
-	}
596
-	return $result_message;
589
+    if ($action=='revoke') {
590
+        $sql="DELETE FROM $table WHERE c_id = $course_id AND $id_field = '".Database::escape_string($id)."' AND role_id='".Database::escape_string($role_id)."'";
591
+        $result=Database::query($sql);
592
+        if ($result) {
593
+            $result_message=get_lang('RoleRevoked');
594
+        }
595
+    }
596
+    return $result_message;
597 597
 }
598 598
 
599 599
 
@@ -603,21 +603,21 @@  discard block
 block discarded – undo
603 603
 */
604 604
 function permission_array_merge($array1, $array2)
605 605
 {
606
-	foreach ($array2 as $tool=>$permissions)
607
-	{
608
-		foreach ($permissions as $permissionkey=>$permissionvalue)
609
-		{
610
-			$array1[$tool][]=$permissionvalue;
611
-		}
612
-	}
613
-	return $array1;
606
+    foreach ($array2 as $tool=>$permissions)
607
+    {
608
+        foreach ($permissions as $permissionkey=>$permissionvalue)
609
+        {
610
+            $array1[$tool][]=$permissionvalue;
611
+        }
612
+    }
613
+    return $array1;
614 614
 }
615 615
 
616 616
 
617 617
 function my_print_r($array)
618 618
 {
619
-	echo '<pre>';
620
-	print_r($array);
621
-	echo '</pre>';
619
+    echo '<pre>';
620
+    print_r($array);
621
+    echo '</pre>';
622 622
 }
623 623
 ?>
Please login to merge, or discard this patch.
Spacing   +143 added lines, -143 removed lines patch added patch discarded remove patch
@@ -26,34 +26,34 @@  discard block
 block discarded – undo
26 26
     $course_id = api_get_course_int_id();
27 27
     
28 28
 	// Which database are we using (depending on the $content parameter)
29
-	if ($content=='user')
29
+	if ($content == 'user')
30 30
 	{
31
-		$table=Database::get_course_table(TABLE_PERMISSION_USER);
31
+		$table = Database::get_course_table(TABLE_PERMISSION_USER);
32 32
 		$id_field = user_id;
33 33
 	}
34
-	if ($content=='group')
34
+	if ($content == 'group')
35 35
 	{
36
-		$table=Database::get_course_table(TABLE_PERMISSION_GROUP);
36
+		$table = Database::get_course_table(TABLE_PERMISSION_GROUP);
37 37
 		$id_field = group_id;
38 38
 	}
39
-	if ($content=='role')
39
+	if ($content == 'role')
40 40
 	{
41
-		$table=Database::get_course_table(TABLE_ROLE_PERMISSION);
41
+		$table = Database::get_course_table(TABLE_ROLE_PERMISSION);
42 42
 		$id_field = role_id;
43 43
 	}
44 44
 
45 45
 	// We first delete all the existing permissions for that user/group/role
46
-	$sql="DELETE FROM $table  WHERE c_id = $course_id AND $id_field = '".Database::escape_string($id)."'";
47
-	$result=Database::query($sql);
46
+	$sql = "DELETE FROM $table  WHERE c_id = $course_id AND $id_field = '".Database::escape_string($id)."'";
47
+	$result = Database::query($sql);
48 48
 
49 49
 	// looping through the post values to find the permission (containing the string permission* )
50 50
 	foreach ($_POST as $key => $value)
51 51
 	{
52
-		if (strstr($key,"permission*"))
52
+		if (strstr($key, "permission*"))
53 53
 		{
54
-			list($brol,$tool,$action)=explode("*",$key);
55
-			$sql="INSERT INTO $table (c_id, $id_field,tool,action) VALUES ($course_id, '".Database::escape_string($id)."','".Database::escape_string($tool)."','".Database::escape_string($action)."')";
56
-			$result=Database::query($sql);
54
+			list($brol, $tool, $action) = explode("*", $key);
55
+			$sql = "INSERT INTO $table (c_id, $id_field,tool,action) VALUES ($course_id, '".Database::escape_string($id)."','".Database::escape_string($tool)."','".Database::escape_string($action)."')";
56
+			$result = Database::query($sql);
57 57
 		}
58 58
 	}
59 59
 	return get_lang('PermissionsStored');
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 * @author Patrick Cool <[email protected]>, Ghent University
70 70
 * @version 1.0
71 71
 */
72
-function store_one_permission($content, $action, $id, $tool,$permission) {
72
+function store_one_permission($content, $action, $id, $tool, $permission) {
73 73
 	global $rights_full;
74 74
     $course_id = api_get_course_int_id();
75 75
 	// for some reason I don't know, he can't get to the $rights_full array, so commented the following lines out.
@@ -82,35 +82,35 @@  discard block
 block discarded – undo
82 82
 
83 83
 	// Which database are we using (depending on the $content parameter)
84 84
     
85
-	if ($content=='user') {
86
-		$table=Database::get_course_table(TABLE_PERMISSION_USER);
85
+	if ($content == 'user') {
86
+		$table = Database::get_course_table(TABLE_PERMISSION_USER);
87 87
 		$id_field = user_id;
88 88
 	}
89
-	if ($content=='group')
89
+	if ($content == 'group')
90 90
 	{
91
-		$table=Database::get_course_table(TABLE_PERMISSION_GROUP);
91
+		$table = Database::get_course_table(TABLE_PERMISSION_GROUP);
92 92
 		$id_field = group_id;
93 93
 	}
94
-	if ($content=='role')
94
+	if ($content == 'role')
95 95
 	{
96
-		$table=Database::get_course_table(TABLE_ROLE_PERMISSION);
96
+		$table = Database::get_course_table(TABLE_ROLE_PERMISSION);
97 97
 		$id_field = role_id;
98 98
 	}
99 99
 
100 100
 	// grating a right
101
-	if ($action=='grant') {
102
-		$sql="INSERT INTO $table (c_id, $id_field,tool,action) VALUES ($course_id, '".Database::escape_string($id)."','".Database::escape_string($tool)."','".Database::escape_string($permission)."')";
103
-		$result=Database::query($sql);
104
-		if($result) {
105
-			$result_message=get_lang('PermissionGranted');
101
+	if ($action == 'grant') {
102
+		$sql = "INSERT INTO $table (c_id, $id_field,tool,action) VALUES ($course_id, '".Database::escape_string($id)."','".Database::escape_string($tool)."','".Database::escape_string($permission)."')";
103
+		$result = Database::query($sql);
104
+		if ($result) {
105
+			$result_message = get_lang('PermissionGranted');
106 106
 		}
107 107
 	}
108
-	if ($action=='revoke')
108
+	if ($action == 'revoke')
109 109
 	{
110
-		$sql="DELETE FROM $table WHERE c_id = $course_id AND $id_field = '".Database::escape_string($id)."' AND tool='".Database::escape_string($tool)."' AND action='".Database::escape_string($permission)."'";
111
-		$result=Database::query($sql);
112
-		if($result) {
113
-			$result_message=get_lang('PermissionRevoked');
110
+		$sql = "DELETE FROM $table WHERE c_id = $course_id AND $id_field = '".Database::escape_string($id)."' AND tool='".Database::escape_string($tool)."' AND action='".Database::escape_string($permission)."'";
111
+		$result = Database::query($sql);
112
+		if ($result) {
113
+			$result_message = get_lang('PermissionRevoked');
114 114
 		}
115 115
 	}
116 116
 	return $result_message;
@@ -125,44 +125,44 @@  discard block
 block discarded – undo
125 125
 */
126 126
 function get_permissions($content, $id) {
127 127
     $course_id = api_get_course_int_id();
128
-	$currentpermissions=array();
128
+	$currentpermissions = array();
129 129
 	// Which database are we using (depending on the $content parameter)
130 130
     $course_id_condition = " c_id = $course_id AND ";
131 131
 	if ($content == 'user')
132 132
 	{
133
-		$table=Database::get_course_table(TABLE_PERMISSION_USER);
133
+		$table = Database::get_course_table(TABLE_PERMISSION_USER);
134 134
 		$id_field = 'user_id';
135 135
 	}
136 136
 	elseif ($content == 'group')
137 137
 	{
138
-		$table=Database::get_course_table(TABLE_PERMISSION_GROUP);
138
+		$table = Database::get_course_table(TABLE_PERMISSION_GROUP);
139 139
 		$id_field = 'group_id';
140 140
 	}
141 141
 	elseif ($content == 'role')
142 142
 	{
143
-		$table=Database::get_course_table(TABLE_ROLE_PERMISSION);
143
+		$table = Database::get_course_table(TABLE_ROLE_PERMISSION);
144 144
 		$id_field = 'role_id';
145 145
 	}
146 146
 	elseif ($content == 'platform_role')
147 147
 	{
148
-		$table=Database::get_main_table(TABLE_ROLE_PERMISSION);
148
+		$table = Database::get_main_table(TABLE_ROLE_PERMISSION);
149 149
 		$id_field = 'role_id';
150 150
         $course_id_condition = '';
151 151
 	}
152 152
 	elseif ($content == 'task')
153 153
 	{
154
-		$table=Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS);
154
+		$table = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS);
155 155
 		$id_field = 'task_id';
156 156
 	}
157 157
 
158 158
 	// finding all the permissions. We store this in a multidimensional array
159 159
 	// where the first dimension is the tool.
160
-	$sql="
161
-		SELECT * FROM " . $table . "
162
-		WHERE $course_id_condition " . $id_field . "='" . Database::escape_string($id) . "'";
160
+	$sql = "
161
+		SELECT * FROM " . $table."
162
+		WHERE $course_id_condition ".$id_field."='".Database::escape_string($id)."'";
163 163
 	$result = Database::query($sql);
164 164
 
165
-	while($row = Database::fetch_array($result))
165
+	while ($row = Database::fetch_array($result))
166 166
 		$currentpermissions[$row['tool']][] = $row['action'];
167 167
 
168 168
 	return $currentpermissions;
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 */
180 180
 function limited_or_full($current_permissions)
181 181
 {
182
-	if (api_get_setting('permissions')=='limited')
182
+	if (api_get_setting('permissions') == 'limited')
183 183
 	{
184 184
 		foreach ($current_permissions as $tool=>$tool_rights)
185 185
 		{
@@ -187,15 +187,15 @@  discard block
 block discarded – undo
187 187
 			// if it is visibility or move we have to grant the edit right
188 188
 			foreach ($tool_rights as $key=>$value)
189 189
 			{
190
-				if ($value=='View')
190
+				if ($value == 'View')
191 191
 				{
192 192
 					unset($current_permissions[$tool][$key]);
193 193
 				}
194
-				if ($value=='Visibility' OR $value=='Move')
194
+				if ($value == 'Visibility' OR $value == 'Move')
195 195
 				{
196
-					if (!in_array('Edit',$current_permissions[$tool]))
196
+					if (!in_array('Edit', $current_permissions[$tool]))
197 197
 					{
198
-						$current_permissions[$tool][]='Edit';
198
+						$current_permissions[$tool][] = 'Edit';
199 199
 					}
200 200
 					unset($current_permissions[$tool][$key]);
201 201
 				}
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
 		}
208 208
 		return $current_permissions;
209 209
 	}
210
-	if (api_get_setting('permissions')=='full')
210
+	if (api_get_setting('permissions') == 'full')
211 211
 	{
212 212
 		return $current_permissions;
213 213
 	}
@@ -222,12 +222,12 @@  discard block
 block discarded – undo
222 222
 * @author Patrick Cool <[email protected]>, Ghent University
223 223
 * @version 1.0
224 224
 */
225
-function display_checkbox_matrix($permission_array, $tool, $permission, $inherited_permissions=array())
225
+function display_checkbox_matrix($permission_array, $tool, $permission, $inherited_permissions = array())
226 226
 {
227
-	$checked="";
228
-	if (is_array($permission_array[$tool]) AND in_array($permission,$permission_array[$tool]))
227
+	$checked = "";
228
+	if (is_array($permission_array[$tool]) AND in_array($permission, $permission_array[$tool]))
229 229
 	{
230
-		$checked="checked";
230
+		$checked = "checked";
231 231
 	}
232 232
 	echo "\t\t\t<input type=\"checkbox\" name=\"permission*$tool*$permission\" $checked>\n";
233 233
 
@@ -243,28 +243,28 @@  discard block
 block discarded – undo
243 243
 * @author Patrick Cool <[email protected]>, Ghent University
244 244
 * @version 1.0
245 245
 */
246
-function display_image_matrix($permission_array, $tool, $permission,$inherited_permissions=array(), $course_admin=false, $editable=true)
246
+function display_image_matrix($permission_array, $tool, $permission, $inherited_permissions = array(), $course_admin = false, $editable = true)
247 247
 {
248 248
 	if ($course_admin) {
249 249
 		echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">";
250 250
 	} else {
251
-		if (in_array($permission,$inherited_permissions[$tool])) {
251
+		if (in_array($permission, $inherited_permissions[$tool])) {
252 252
 			echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">";
253 253
 		} else {
254
-			if (is_array($permission_array[$tool]) AND in_array($permission,$permission_array[$tool])) {
254
+			if (is_array($permission_array[$tool]) AND in_array($permission, $permission_array[$tool])) {
255 255
 				if ($editable) {
256
-					$url=api_get_self();
256
+					$url = api_get_self();
257 257
 					$urlparameters = '';
258
-					foreach($_GET as $key=>$value) {
259
-						$parameter[$key]=$value;
258
+					foreach ($_GET as $key=>$value) {
259
+						$parameter[$key] = $value;
260 260
 					}
261
-					$parameter['action']='revoke';
262
-					$parameter['permission']=$permission;
263
-					$parameter['tool']=$tool;
261
+					$parameter['action'] = 'revoke';
262
+					$parameter['permission'] = $permission;
263
+					$parameter['tool'] = $tool;
264 264
 					foreach ($parameter as $key=>$value) {
265
-						$urlparameters.=$key.'='.$value.'&amp;';
265
+						$urlparameters .= $key.'='.$value.'&amp;';
266 266
 					}
267
-					$url=$url.'?'.$urlparameters;
267
+					$url = $url.'?'.$urlparameters;
268 268
 
269 269
 					echo "\t\t\t <a href=\"".$url."\">";
270 270
 				}
@@ -275,20 +275,20 @@  discard block
 block discarded – undo
275 275
 			} else {
276 276
 				if ($editable)
277 277
 				{
278
-					$url=api_get_self();
278
+					$url = api_get_self();
279 279
 					$urlparameters = '';
280 280
 					foreach ($_GET as $key=>$value)
281 281
 					{
282
-						$parameter[$key]=$value;
282
+						$parameter[$key] = $value;
283 283
 					}
284
-					$parameter['action']='grant';
285
-					$parameter['permission']=$permission;
286
-					$parameter['tool']=$tool;
284
+					$parameter['action'] = 'grant';
285
+					$parameter['permission'] = $permission;
286
+					$parameter['tool'] = $tool;
287 287
 					foreach ($parameter as $key=>$value)
288 288
 					{
289
-						$urlparameters.=$key.'='.$value.'&amp;';
289
+						$urlparameters .= $key.'='.$value.'&amp;';
290 290
 					}
291
-					$url=$url.'?'.$urlparameters;
291
+					$url = $url.'?'.$urlparameters;
292 292
 
293 293
 					//echo "\t\t\t <a href=\"".str_replace('&', '&amp;', $_SERVER['REQUEST_URI'])."&amp;action=grant&amp;permission=$permission&amp;tool=$tool\">";
294 294
 					echo "\t\t\t <a href=\"".$url."\">";
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
 * @author Patrick Cool <[email protected]>, Ghent University
316 316
 * @version 1.0
317 317
 */
318
-function display_image_matrix_for_blogs($permission_array, $user_id, $tool, $permission,$inherited_permissions=array(), $course_admin=false, $editable=true)
318
+function display_image_matrix_for_blogs($permission_array, $user_id, $tool, $permission, $inherited_permissions = array(), $course_admin = false, $editable = true)
319 319
 {
320 320
 
321 321
 	if ($course_admin)
@@ -324,32 +324,32 @@  discard block
 block discarded – undo
324 324
 	}
325 325
 	else
326 326
 	{
327
-		if (!empty($inherited_permissions) and in_array($permission,$inherited_permissions[$tool]))
327
+		if (!empty($inherited_permissions) and in_array($permission, $inherited_permissions[$tool]))
328 328
 		{
329 329
 			echo "\t\t\t<img src=\"../img/checkbox_on3.gif\" border=\"0\"/ title=\"".get_lang('PermissionGrantedByGroupOrRole')."\">";
330 330
 		}
331 331
 		else
332 332
 		{
333
-			if (is_array($permission_array[$tool]) AND in_array($permission,$permission_array[$tool]))
333
+			if (is_array($permission_array[$tool]) AND in_array($permission, $permission_array[$tool]))
334 334
 			{
335 335
 				if ($editable)
336 336
 				{
337 337
 					$url = api_get_self();
338 338
 					$urlparameters = '';
339
-					foreach($_GET as $key => $value)
339
+					foreach ($_GET as $key => $value)
340 340
 					{
341 341
 						$parameter[$key] = $value;
342 342
 					}
343
-					$parameter['action']='manage_rights';
344
-					$parameter['do']='revoke';
345
-					$parameter['permission']=$permission;
346
-					$parameter['tool']=$tool;
347
-					$parameter['user_id']=$user_id;
343
+					$parameter['action'] = 'manage_rights';
344
+					$parameter['do'] = 'revoke';
345
+					$parameter['permission'] = $permission;
346
+					$parameter['tool'] = $tool;
347
+					$parameter['user_id'] = $user_id;
348 348
 					foreach ($parameter as $key=>$value)
349 349
 					{
350
-						$urlparameters .= $key . '=' . $value . '&amp;';
350
+						$urlparameters .= $key.'='.$value.'&amp;';
351 351
 					}
352
-					$url = $url . '?' . $urlparameters;
352
+					$url = $url.'?'.$urlparameters;
353 353
 
354 354
 					echo "\t\t\t <a href=\"".$url."\">";
355 355
 				}
@@ -362,17 +362,17 @@  discard block
 block discarded – undo
362 362
 					$url = api_get_self();
363 363
 					$urlparameters = '';
364 364
 					foreach ($_GET as $key=>$value) {
365
-						$parameter[$key]=$value;
365
+						$parameter[$key] = $value;
366 366
 					}
367
-					$parameter['action']='manage_rights';
368
-					$parameter['do']='grant';
369
-					$parameter['permission']=$permission;
370
-					$parameter['tool']=$tool;
371
-					$parameter['user_id']=$user_id;
367
+					$parameter['action'] = 'manage_rights';
368
+					$parameter['do'] = 'grant';
369
+					$parameter['permission'] = $permission;
370
+					$parameter['tool'] = $tool;
371
+					$parameter['user_id'] = $user_id;
372 372
 					foreach ($parameter as $key=>$value) {
373
-						$urlparameters .= $key . '=' . $value . '&amp;';
373
+						$urlparameters .= $key.'='.$value.'&amp;';
374 374
 					}
375
-					$url=$url.'?'.$urlparameters;
375
+					$url = $url.'?'.$urlparameters;
376 376
 
377 377
 					//echo "\t\t\t <a href=\"".str_replace('&', '&amp;', $_SERVER['REQUEST_URI'])."&amp;action=grant&amp;permission=$permission&amp;tool=$tool\">";
378 378
 					echo "\t\t\t <a href=\"".$url."\">";
@@ -397,30 +397,30 @@  discard block
 block discarded – undo
397 397
 	global $setting_visualisation;
398 398
     $course_id = api_get_course_int_id();
399 399
 
400
-	$coures_roles_table=Database::get_course_table(TABLE_ROLE);
400
+	$coures_roles_table = Database::get_course_table(TABLE_ROLE);
401 401
 
402 402
 	// course roles
403
-	$sql="SELECT * FROM $coures_roles_table WHERE c_id = $course_id ";
404
-	$result=Database::query($sql);
405
-	while ($row=Database::fetch_array($result))
403
+	$sql = "SELECT * FROM $coures_roles_table WHERE c_id = $course_id ";
404
+	$result = Database::query($sql);
405
+	while ($row = Database::fetch_array($result))
406 406
 	{
407 407
 		if (in_array($row['role_id'], $current_course_roles))
408 408
 		{
409
-			$checked='checked';
410
-			$image='checkbox_on2.gif';
411
-			$action='revoke';
409
+			$checked = 'checked';
410
+			$image = 'checkbox_on2.gif';
411
+			$action = 'revoke';
412 412
 		}
413 413
 		else
414 414
 		{
415
-			$checked='';
416
-			$image='wrong.gif';
417
-			$action='grant';
415
+			$checked = '';
416
+			$image = 'wrong.gif';
417
+			$action = 'grant';
418 418
 		}
419
-		if ($setting_visualisation=='checkbox')
419
+		if ($setting_visualisation == 'checkbox')
420 420
 		{
421 421
 			echo "<input type=\"checkbox\" name=\"role*course*".$row['role_id']."\" $checked>";
422 422
 		}
423
-		if ($setting_visualisation=='image')
423
+		if ($setting_visualisation == 'image')
424 424
 		{
425 425
 			echo "<a href=\"".str_replace('&', '&amp;', $_SERVER['REQUEST_URI'])."&amp;action=$action&amp;role=".$row['role_id']."&amp;scope=course\"><img src=\"../img/".$image."\" border=\"0\"/></a>";
426 426
 		}
@@ -440,24 +440,24 @@  discard block
 block discarded – undo
440 440
 * @author Patrick Cool <[email protected]>, Ghent University
441 441
 * @version 1.0
442 442
 */
443
-function get_roles($content,$id, $scope='course') {
444
-    $course_id  = api_get_course_int_id();    
445
-	if ($content=='user') {
446
-		$table=Database::get_course_table(TABLE_ROLE_USER);
443
+function get_roles($content, $id, $scope = 'course') {
444
+    $course_id = api_get_course_int_id();    
445
+	if ($content == 'user') {
446
+		$table = Database::get_course_table(TABLE_ROLE_USER);
447 447
 		$id_field = user_id;
448 448
 	}
449
-	if ($content=='group') {
450
-		$table=Database::get_course_table(TABLE_ROLE_GROUP);
449
+	if ($content == 'group') {
450
+		$table = Database::get_course_table(TABLE_ROLE_GROUP);
451 451
 		$id_field = 'group_id';
452 452
 	}
453
-	$table_role=Database::get_course_table(TABLE_ROLE);
453
+	$table_role = Database::get_course_table(TABLE_ROLE);
454 454
 
455
-	$current_roles=array();
455
+	$current_roles = array();
456 456
 	//$sql="SELECT role.role_id FROM $table role_group_user, $table_role role WHERE role_group_user.$id_field = '$id' AND role_group_user.role_id=role.role_id AND role_group_user.scope='".$scope."'";$sql="SELECT role.role_id FROM $table role_group_user, $table_role role WHERE role_group_user.$id_field = '$id' AND role_group_user.role_id=role.role_id AND role_group_user.scope='".$scope."'";
457
-	$sql="SELECT role_id FROM $table WHERE c_id = $course_id AND $id_field = '$id' AND scope='".$scope."'";
458
-	$result=Database::query($sql);
459
-	while ($row=Database::fetch_array($result)) {
460
-		$current_roles[]=$row['role_id'];
457
+	$sql = "SELECT role_id FROM $table WHERE c_id = $course_id AND $id_field = '$id' AND scope='".$scope."'";
458
+	$result = Database::query($sql);
459
+	while ($row = Database::fetch_array($result)) {
460
+		$current_roles[] = $row['role_id'];
461 461
 	}
462 462
 	return $current_roles;
463 463
 }
@@ -468,26 +468,26 @@  discard block
 block discarded – undo
468 468
 * @author Patrick Cool <[email protected]>, Ghent University
469 469
 * @version 1.0
470 470
 */
471
-function get_all_roles($content='course') {
471
+function get_all_roles($content = 'course') {
472 472
     $course_id = api_get_course_int_id();
473 473
     $course_id_condition = " WHERE c_id = $course_id ";
474 474
     
475
-	if ($content=='course')
475
+	if ($content == 'course')
476 476
 	{
477
-		$table_role=Database::get_course_table(TABLE_ROLE);
477
+		$table_role = Database::get_course_table(TABLE_ROLE);
478 478
 	}
479
-	if ($content=='platform')
479
+	if ($content == 'platform')
480 480
 	{
481
-		$table_role=Database::get_main_table(TABLE_ROLE);
481
+		$table_role = Database::get_main_table(TABLE_ROLE);
482 482
 		$course_id_condition = '';
483 483
 	}
484 484
 
485
-	$current_roles=array();
486
-	$sql="SELECT * FROM $table_role $course_id_condition ";
487
-	$result=Database::query($sql);
488
-	while ($row=Database::fetch_array($result))
485
+	$current_roles = array();
486
+	$sql = "SELECT * FROM $table_role $course_id_condition ";
487
+	$result = Database::query($sql);
488
+	while ($row = Database::fetch_array($result))
489 489
 	{
490
-		$roles[]=$row;
490
+		$roles[] = $row;
491 491
 	}
492 492
 
493 493
 	return $roles;
@@ -504,10 +504,10 @@  discard block
 block discarded – undo
504 504
 * @author Patrick Cool <[email protected]>, Ghent University
505 505
 * @version 1.0
506 506
 */
507
-function get_roles_permissions($content,$id, $scope='course') {
507
+function get_roles_permissions($content, $id, $scope = 'course') {
508 508
     $course_id = api_get_course_int_id();
509 509
 	if ($content == 'user') {
510
-		$table=Database::get_course_table(TABLE_ROLE_USER);
510
+		$table = Database::get_course_table(TABLE_ROLE_USER);
511 511
 		$id_field = 'user_id';
512 512
 	}
513 513
 
@@ -536,21 +536,21 @@  discard block
 block discarded – undo
536 536
 	$sql = "
537 537
 		SELECT *
538 538
 		FROM
539
-			" . $table . " role_group_user,
540
-			" . $table_role . " role,
541
-			" . $table_role_permissions . " role_permissions
539
+			" . $table." role_group_user,
540
+			" . $table_role." role,
541
+			" . $table_role_permissions." role_permissions
542 542
 		WHERE
543 543
 		    role_group_user.c_id = $course_id AND
544 544
 		    $role_condition
545
-			role_group_user.scope = '" . $scope . "' AND
546
-			role_group_user." . $id_field . " = '" . $id . "' AND
545
+			role_group_user.scope = '".$scope."' AND
546
+			role_group_user." . $id_field." = '".$id."' AND
547 547
 			role_group_user.role_id = role.role_id AND
548 548
 			role.role_id = role_permissions.role_id";
549 549
 
550 550
 	$result = Database::query($sql);
551 551
     $current_role_permissions = array();
552
-	while ($row=Database::fetch_array($result)) {
553
-		$current_role_permissions[$row['tool']][]=$row['action'];
552
+	while ($row = Database::fetch_array($result)) {
553
+		$current_role_permissions[$row['tool']][] = $row['action'];
554 554
     }
555 555
 	return $current_role_permissions;
556 556
 }
@@ -564,33 +564,33 @@  discard block
 block discarded – undo
564 564
 * @author Patrick Cool <[email protected]>, Ghent University
565 565
 */
566 566
 
567
-function assign_role($content, $action, $id, $role_id, $scope='course') {
567
+function assign_role($content, $action, $id, $role_id, $scope = 'course') {
568 568
     $course_id = api_get_course_int_id();
569 569
 	// Which database are we using (depending on the $content parameter)
570
-	if ($content=='user') {
571
-		$table=Database::get_course_table(TABLE_ROLE_USER);
570
+	if ($content == 'user') {
571
+		$table = Database::get_course_table(TABLE_ROLE_USER);
572 572
 		$id_field = 'user_id';
573
-	} elseif($content=='group') {
574
-		$table=Database::get_course_table(TABLE_ROLE_GROUP);
573
+	} elseif ($content == 'group') {
574
+		$table = Database::get_course_table(TABLE_ROLE_GROUP);
575 575
 		$id_field = 'group_id';
576 576
 	} else {
577 577
 		return  get_lang('Error');
578 578
 	}
579 579
 
580 580
 	// grating a right
581
-	if ($action=='grant') {
582
-		$sql="INSERT INTO $table (c_id, role_id, scope, $id_field) VALUES ($course_id, '".Database::escape_string($role_id)."','".Database::escape_string($scope)."','".Database::escape_string($id)."')";
583
-		$result=Database::query($sql);
581
+	if ($action == 'grant') {
582
+		$sql = "INSERT INTO $table (c_id, role_id, scope, $id_field) VALUES ($course_id, '".Database::escape_string($role_id)."','".Database::escape_string($scope)."','".Database::escape_string($id)."')";
583
+		$result = Database::query($sql);
584 584
 		if ($result) {
585
-			$result_message=get_lang('RoleGranted');
585
+			$result_message = get_lang('RoleGranted');
586 586
 		}
587 587
 	}
588 588
     
589
-	if ($action=='revoke') {
590
-		$sql="DELETE FROM $table WHERE c_id = $course_id AND $id_field = '".Database::escape_string($id)."' AND role_id='".Database::escape_string($role_id)."'";
591
-		$result=Database::query($sql);
589
+	if ($action == 'revoke') {
590
+		$sql = "DELETE FROM $table WHERE c_id = $course_id AND $id_field = '".Database::escape_string($id)."' AND role_id='".Database::escape_string($role_id)."'";
591
+		$result = Database::query($sql);
592 592
 		if ($result) {
593
-			$result_message=get_lang('RoleRevoked');
593
+			$result_message = get_lang('RoleRevoked');
594 594
 		}
595 595
 	}
596 596
 	return $result_message;
@@ -607,7 +607,7 @@  discard block
 block discarded – undo
607 607
 	{
608 608
 		foreach ($permissions as $permissionkey=>$permissionvalue)
609 609
 		{
610
-			$array1[$tool][]=$permissionvalue;
610
+			$array1[$tool][] = $permissionvalue;
611 611
 		}
612 612
 	}
613 613
 	return $array1;
Please login to merge, or discard this patch.
main/user/user.php 2 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -735,7 +735,6 @@
 block discarded – undo
735 735
  * lock = the user can no longer use this account
736 736
  * @author Patrick Cool <[email protected]>, Ghent University
737 737
  * @param int $active the current state of the account
738
- * @param int $user_id The user id
739 738
  * @param string $urlParams
740 739
  *
741 740
  * @return string Some HTML-code with the lock/unlock button
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
  */
14 14
 $use_anonymous = true;
15 15
 require_once '../inc/global.inc.php';
16
-$current_course_tool  = TOOL_USER;
16
+$current_course_tool = TOOL_USER;
17 17
 $this_section = SECTION_COURSES;
18 18
 
19 19
 // notice for unauthorized people.
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 
42 42
 //Can't auto unregister from a session
43 43
 if (!empty($sessionId)) {
44
-    $course_info['unsubscribe']  = 0;
44
+    $course_info['unsubscribe'] = 0;
45 45
 }
46 46
 
47 47
 /* Unregistering a user section	*/
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
                             '#',
185 185
                             get_lang('UserPicture'),
186 186
                             get_lang('OfficialCode'),
187
-                            get_lang('FirstName') . ', ' . get_lang('LastName'),
187
+                            get_lang('FirstName').', '.get_lang('LastName'),
188 188
                             get_lang('Email'),
189 189
                             get_lang('Phone')
190 190
                         );
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
                             '#',
194 194
                             get_lang('UserPicture'),
195 195
                             get_lang('OfficialCode'),
196
-                            get_lang('LastName') . ', ' . get_lang('FirstName'),
196
+                            get_lang('LastName').', '.get_lang('FirstName'),
197 197
                             get_lang('Email'),
198 198
                             get_lang('Phone')
199 199
                         );
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
                     if (api_is_multiple_url_enabled()) {
219 219
                         $sql .= ' , '.Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER).' au ';
220 220
                     }
221
-                    $sql .=" WHERE c_id = '$courseId' AND session_course_user.user_id = user.user_id ";
221
+                    $sql .= " WHERE c_id = '$courseId' AND session_course_user.user_id = user.user_id ";
222 222
                     $sql .= ' AND session_id = '.$sessionId;
223 223
 
224 224
                     if (api_is_multiple_url_enabled()) {
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
                             true
253 253
                         );
254 254
                         if (!empty($extra_fields)) {
255
-                            foreach($extra_fields as $key => $extra_value) {
255
+                            foreach ($extra_fields as $key => $extra_value) {
256 256
                                 $user[$key] = $extra_value;
257 257
                             }
258 258
                         }
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
                                     $counter,
267 267
                                     $user_image,
268 268
                                     $user['official_code'],
269
-                                    $user['firstname'] . ', ' . $user['lastname'],
269
+                                    $user['firstname'].', '.$user['lastname'],
270 270
                                     $user['email'],
271 271
                                     $user['phone']
272 272
                                 );
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
                                     $counter,
276 276
                                     $user_image,
277 277
                                     $user['official_code'],
278
-                                    $user['lastname'] . ', ' . $user['firstname'],
278
+                                    $user['lastname'].', '.$user['firstname'],
279 279
                                     $user['email'],
280 280
                                     $user['phone']
281 281
                                 );
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
                                     $counter,
355 355
                                     $user_image,
356 356
                                     $user['official_code'],
357
-                                    $user['firstname'] . ', ' . $user['lastname'],
357
+                                    $user['firstname'].', '.$user['lastname'],
358 358
                                     $user['email'],
359 359
                                     $user['phone']
360 360
                                 );
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
                                     $counter,
364 364
                                     $user_image,
365 365
                                     $user['official_code'],
366
-                                    $user['lastname'] . ', ' . $user['firstname'],
366
+                                    $user['lastname'].', '.$user['firstname'],
367 367
                                     $user['email'],
368 368
                                     $user['phone']
369 369
                                 );
@@ -700,7 +700,7 @@  discard block
 block discarded – undo
700 700
                 $userInfo = api_get_user_info($user_id);
701 701
                 $userPicture = $userInfo['avatar'];
702 702
 
703
-                $photo= '<img src="'.$userPicture.'" alt="'.$userInfo['complete_name'].'" width="22" height="22" title="'.$userInfo['complete_name'].'" />';
703
+                $photo = '<img src="'.$userPicture.'" alt="'.$userInfo['complete_name'].'" width="22" height="22" title="'.$userInfo['complete_name'].'" />';
704 704
 
705 705
                 $temp[] = $user_id;
706 706
                 $temp[] = $photo;
@@ -821,7 +821,7 @@  discard block
 block discarded – undo
821 821
         if (api_get_setting('allow_user_course_subscription_by_course_admin') == 'true' or api_is_platform_admin()) {
822 822
             // unregister
823 823
             if ($user_id != $current_user_id || api_is_platform_admin()) {
824
-                $result .= '<a class="btn btn-small btn-danger" href="'.api_get_self().'?'.api_get_cidreq().'&type='.$type.'&unregister=yes&user_id='.$user_id.'" title="'.get_lang('Unreg').' " onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset)).'\')) return false;">'.
824
+                $result .= '<a class="btn btn-small btn-danger" href="'.api_get_self().'?'.api_get_cidreq().'&type='.$type.'&unregister=yes&user_id='.$user_id.'" title="'.get_lang('Unreg').' " onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset)).'\')) return false;">'.
825 825
                     get_lang('Unreg').'</a>&nbsp;';
826 826
             } else {
827 827
                 //$result .= Display::return_icon('unsubscribe_course_na.png', get_lang('Unreg'),'',ICON_SIZE_SMALL).'</a>&nbsp;';
@@ -831,7 +831,7 @@  discard block
 block discarded – undo
831 831
         // Show buttons for unsubscribe
832 832
         if ($course_info['unsubscribe'] == 1) {
833 833
             if ($user_id == $current_user_id) {
834
-                $result .= '<a class="btn btn-small btn-danger" href="'.api_get_self().'?'.api_get_cidreq().'&type='.$type.'&unregister=yes&user_id='.$user_id.'" title="'.get_lang('Unreg').' " onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset)).'\')) return false;">'.
834
+                $result .= '<a class="btn btn-small btn-danger" href="'.api_get_self().'?'.api_get_cidreq().'&type='.$type.'&unregister=yes&user_id='.$user_id.'" title="'.get_lang('Unreg').' " onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset)).'\')) return false;">'.
835 835
                     get_lang('Unreg').'</a>&nbsp;';
836 836
             }
837 837
         }
@@ -907,7 +907,7 @@  discard block
 block discarded – undo
907 907
 
908 908
     // Actions column
909 909
     $table->set_header($header_nr++, get_lang('Action'), false);
910
-    $table->set_column_filter($header_nr-1, 'modify_filter');
910
+    $table->set_column_filter($header_nr - 1, 'modify_filter');
911 911
 
912 912
     if (api_get_setting('allow_user_course_subscription_by_course_admin') == 'true') {
913 913
         $table->set_form_actions(array('unsubscribe' => get_lang('Unreg')), 'user');
@@ -915,7 +915,7 @@  discard block
 block discarded – undo
915 915
 } else {
916 916
     if ($course_info['unsubscribe'] == 1) {
917 917
         $table->set_header($header_nr++, get_lang('Action'), false);
918
-        $table->set_column_filter($header_nr-1, 'modify_filter');
918
+        $table->set_column_filter($header_nr - 1, 'modify_filter');
919 919
     }
920 920
 }
921 921
 
@@ -971,19 +971,19 @@  discard block
 block discarded – undo
971 971
     echo '<div class="col-md-6">';
972 972
     echo $icon;
973 973
     $actions .= '<a href="user.php?'.api_get_cidreq().'&action=export&format=csv&type='.$type.'">'.
974
-        Display::return_icon('export_csv.png', get_lang('ExportAsCSV'),'',ICON_SIZE_MEDIUM).'</a> ';
974
+        Display::return_icon('export_csv.png', get_lang('ExportAsCSV'), '', ICON_SIZE_MEDIUM).'</a> ';
975 975
     $actions .= '<a href="user.php?'.api_get_cidreq().'&action=export&format=xls&type='.$type.'">'.
976
-        Display::return_icon('export_excel.png', get_lang('ExportAsXLS'),'',ICON_SIZE_MEDIUM).'</a> ';
976
+        Display::return_icon('export_excel.png', get_lang('ExportAsXLS'), '', ICON_SIZE_MEDIUM).'</a> ';
977 977
 
978 978
     if (api_get_setting('allow_user_course_subscription_by_course_admin') == 'true' ||
979 979
         api_is_platform_admin()
980 980
     ) {
981 981
         $actions .= '<a href="user_import.php?'.api_get_cidreq().'&action=import">'.
982
-            Display::return_icon('import_csv.png', get_lang('ImportUsersToACourse'),'',ICON_SIZE_MEDIUM).'</a> ';
982
+            Display::return_icon('import_csv.png', get_lang('ImportUsersToACourse'), '', ICON_SIZE_MEDIUM).'</a> ';
983 983
     }
984 984
 
985 985
     $actions .= '<a href="user.php?'.api_get_cidreq().'&action=export&format=pdf&type='.$type.'">'.
986
-        Display::return_icon('pdf.png', get_lang('ExportToPDF'),'',ICON_SIZE_MEDIUM).'</a> ';
986
+        Display::return_icon('pdf.png', get_lang('ExportToPDF'), '', ICON_SIZE_MEDIUM).'</a> ';
987 987
     echo $actions;
988 988
 
989 989
     echo '</div>';
Please login to merge, or discard this patch.
main/webservices/additional_webservices.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -84,7 +84,7 @@
 block discarded – undo
84 84
 }
85 85
 
86 86
 /**
87
- * @param $directoryPath
87
+ * @param string $directoryPath
88 88
  * @return bool
89 89
  */
90 90
 function deleteDirectory($directoryPath)
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -19,12 +19,12 @@  discard block
 block discarded – undo
19 19
 {
20 20
     $fileData = $pptData['file_data'];
21 21
     $dataInfo = pathinfo($pptData['file_name']);
22
-    $fileName =  basename($pptData['file_name'], '.' . $dataInfo['extension']);
22
+    $fileName = basename($pptData['file_name'], '.'.$dataInfo['extension']);
23 23
     $fullFileName = $pptData['file_name'];
24 24
 
25 25
     $tempArchivePath = api_get_path(SYS_ARCHIVE_PATH);
26
-    $tempPath = $tempArchivePath . 'wsConvert/' . $fileName . '/';
27
-    $tempPathNewFiles = $tempArchivePath . 'wsConvert/' . $fileName . '-n/';
26
+    $tempPath = $tempArchivePath.'wsConvert/'.$fileName.'/';
27
+    $tempPathNewFiles = $tempArchivePath.'wsConvert/'.$fileName.'-n/';
28 28
 
29 29
     $perms = api_get_permissions_for_new_directories();
30 30
     if (!is_dir($tempPath)) {
@@ -33,28 +33,28 @@  discard block
 block discarded – undo
33 33
     if (!is_dir($tempPathNewFiles)) {
34 34
         mkdir($tempPathNewFiles, $perms, true);
35 35
     }
36
-    if (!is_dir($tempPathNewFiles . $fileName)) {
37
-        mkdir($tempPathNewFiles . $fileName, $perms, true);
36
+    if (!is_dir($tempPathNewFiles.$fileName)) {
37
+        mkdir($tempPathNewFiles.$fileName, $perms, true);
38 38
     }
39 39
 
40 40
     $file = base64_decode($fileData);
41
-    file_put_contents($tempPath . $fullFileName, $file);
41
+    file_put_contents($tempPath.$fullFileName, $file);
42 42
 
43 43
     if (IS_WINDOWS_OS) { // IS_WINDOWS_OS has been defined in main_api.lib.php
44
-        $converterPath = str_replace('/', '\\', api_get_path(SYS_PATH) . 'main/inc/lib/ppt2png');
45
-        $classPath = $converterPath . ';' . $converterPath . '/jodconverter-2.2.2.jar;' . $converterPath . '/jodconverter-cli-2.2.2.jar';
46
-        $cmd = 'java -Dfile.encoding=UTF-8 -cp "' . $classPath . '" DokeosConverter';
44
+        $converterPath = str_replace('/', '\\', api_get_path(SYS_PATH).'main/inc/lib/ppt2png');
45
+        $classPath = $converterPath.';'.$converterPath.'/jodconverter-2.2.2.jar;'.$converterPath.'/jodconverter-cli-2.2.2.jar';
46
+        $cmd = 'java -Dfile.encoding=UTF-8 -cp "'.$classPath.'" DokeosConverter';
47 47
     } else {
48
-        $converterPath = api_get_path(SYS_PATH) . 'main/inc/lib/ppt2png';
48
+        $converterPath = api_get_path(SYS_PATH).'main/inc/lib/ppt2png';
49 49
         $classPath = ' -Dfile.encoding=UTF-8 -cp .:jodconverter-2.2.2.jar:jodconverter-cli-2.2.2.jar';
50
-        $cmd = 'cd ' . $converterPath . ' && java ' . $classPath . ' DokeosConverter';
50
+        $cmd = 'cd '.$converterPath.' && java '.$classPath.' DokeosConverter';
51 51
     }
52 52
 
53
-    $cmd .= ' -p ' . api_get_setting('service_ppt2lp', 'port');
54
-    $cmd .= ' -w 720 -h 540 -d oogie "' . $tempPath . $fullFileName.'"  "' . $tempPathNewFiles . $fileName . '.html"';
53
+    $cmd .= ' -p '.api_get_setting('service_ppt2lp', 'port');
54
+    $cmd .= ' -w 720 -h 540 -d oogie "'.$tempPath.$fullFileName.'"  "'.$tempPathNewFiles.$fileName.'.html"';
55 55
 
56 56
     $perms = api_get_permissions_for_new_files();
57
-    chmod($tempPathNewFiles . $fileName, $perms, true);
57
+    chmod($tempPathNewFiles.$fileName, $perms, true);
58 58
 
59 59
     $files = array();
60 60
     $return = 0;
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
         $images = array();
65 65
         foreach ($files as $file) {
66 66
             $imageData = explode('||', $file);
67
-            $images[$imageData[1]] = base64_encode(file_get_contents($tempPathNewFiles . $fileName . '/' . $imageData[1]));
67
+            $images[$imageData[1]] = base64_encode(file_get_contents($tempPathNewFiles.$fileName.'/'.$imageData[1]));
68 68
         }
69 69
         $data = array(
70 70
             'files' => $files,
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
  */
90 90
 function deleteDirectory($directoryPath)
91 91
 {
92
-    $files = array_diff(scandir($directoryPath), array('.','..'));
92
+    $files = array_diff(scandir($directoryPath), array('.', '..'));
93 93
     foreach ($files as $file) {
94 94
         if (is_dir("$directoryPath/$file")) {
95 95
             deleteDirectory("$directoryPath/$file");
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 $webCodePath = api_get_path(WEB_CODE_PATH);
107 107
 $options = array(
108 108
     'uri' => $webPath,
109
-    'location' => $webCodePath . 'webservices/additional_webservices.php'
109
+    'location' => $webCodePath.'webservices/additional_webservices.php'
110 110
 );
111 111
 
112 112
 $soapServer = new SoapServer(NULL, $options);
Please login to merge, or discard this patch.