@@ -330,6 +330,7 @@ discard block |
||
330 | 330 | /** |
331 | 331 | * Sets the footer visibility |
332 | 332 | * @param bool true if we show the footer |
333 | + * @param boolean $status |
|
333 | 334 | */ |
334 | 335 | public function set_footer($status) |
335 | 336 | { |
@@ -370,6 +371,7 @@ discard block |
||
370 | 371 | /** |
371 | 372 | * Sets the header visibility |
372 | 373 | * @param bool true if we show the header |
374 | + * @param boolean $status |
|
373 | 375 | */ |
374 | 376 | public function set_header($status) |
375 | 377 | { |
@@ -615,7 +615,7 @@ |
||
615 | 615 | return [ |
616 | 616 | '_p' => $_p, |
617 | 617 | '_s' => $_s, |
618 | - // '_u' => $user_info, |
|
618 | + // '_u' => $user_info, |
|
619 | 619 | 'template' => 'default' // @todo setup template folder in config.yml; |
620 | 620 | ]; |
621 | 621 | } |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | $content = '<div class="help">'; |
313 | 313 | $content .= Display::url( |
314 | 314 | Display::return_icon('help.large.png', get_lang('Help')), |
315 | - api_get_path(WEB_CODE_PATH) . 'help/help.php?open=' . $help, |
|
315 | + api_get_path(WEB_CODE_PATH).'help/help.php?open='.$help, |
|
316 | 316 | [ |
317 | 317 | 'class' => 'ajax', |
318 | 318 | 'data-title' => get_lang('Help') |
@@ -634,12 +634,12 @@ discard block |
||
634 | 634 | foreach ($bowerCSSFiles as $file) { |
635 | 635 | $css[] = api_get_path(WEB_PATH).'web/assets/'.$file; |
636 | 636 | } |
637 | - $css[] = api_get_path(WEB_LIBRARY_PATH) . 'javascript/bootstrap-select/css/bootstrap-select.min.css'; |
|
638 | - $css[] = api_get_path(WEB_LIBRARY_PATH) . 'javascript/chosen/chosen.css'; |
|
639 | - $css[] = api_get_path(WEB_LIBRARY_PATH) . 'javascript/tag/style.css'; |
|
637 | + $css[] = api_get_path(WEB_LIBRARY_PATH).'javascript/bootstrap-select/css/bootstrap-select.min.css'; |
|
638 | + $css[] = api_get_path(WEB_LIBRARY_PATH).'javascript/chosen/chosen.css'; |
|
639 | + $css[] = api_get_path(WEB_LIBRARY_PATH).'javascript/tag/style.css'; |
|
640 | 640 | |
641 | 641 | if (api_is_global_chat_enabled()) { |
642 | - $css[] = api_get_path(WEB_LIBRARY_PATH) . 'javascript/chat/css/chat.css'; |
|
642 | + $css[] = api_get_path(WEB_LIBRARY_PATH).'javascript/chat/css/chat.css'; |
|
643 | 643 | } |
644 | 644 | |
645 | 645 | //THEME CSS STYLE |
@@ -691,7 +691,7 @@ discard block |
||
691 | 691 | |
692 | 692 | if (is_file(api_get_path(SYS_CSS_PATH).'themes/'.$this->theme.'/editor.css')) { |
693 | 693 | $css[] = api_get_path(WEB_CSS_PATH).'themes/'.$this->theme.'/editor.css'; |
694 | - }else{ |
|
694 | + } else { |
|
695 | 695 | $css[] = api_get_cdn_path(api_get_path(WEB_CSS_PATH).'editor.css'); |
696 | 696 | } |
697 | 697 | |
@@ -726,7 +726,7 @@ discard block |
||
726 | 726 | |
727 | 727 | $style_print = ''; |
728 | 728 | if (is_readable(api_get_path(SYS_CSS_PATH).$this->theme.'/print.css')) { |
729 | - $style_print = api_get_css(api_get_cdn_path(api_get_path(WEB_CSS_PATH) . $this->theme . '/print.css'), |
|
729 | + $style_print = api_get_css(api_get_cdn_path(api_get_path(WEB_CSS_PATH).$this->theme.'/print.css'), |
|
730 | 730 | 'print'); |
731 | 731 | } |
732 | 732 | $this->assign('css_style_print', $style_print); |
@@ -749,10 +749,10 @@ discard block |
||
749 | 749 | |
750 | 750 | $isoCode = api_get_language_isocode(); |
751 | 751 | |
752 | - $selectLink = 'bootstrap-select/js/i18n/defaults-' . $isoCode . '_' . strtoupper($isoCode) . '.min.js'; |
|
752 | + $selectLink = 'bootstrap-select/js/i18n/defaults-'.$isoCode.'_'.strtoupper($isoCode).'.min.js'; |
|
753 | 753 | |
754 | 754 | if ($isoCode == 'en') { |
755 | - $selectLink = 'bootstrap-select/js/i18n/defaults-' . $isoCode . '_US.min.js'; |
|
755 | + $selectLink = 'bootstrap-select/js/i18n/defaults-'.$isoCode.'_US.min.js'; |
|
756 | 756 | } |
757 | 757 | // JS files |
758 | 758 | $js_files = array( |
@@ -805,8 +805,8 @@ discard block |
||
805 | 805 | } |
806 | 806 | |
807 | 807 | if ($isoCode != 'en') { |
808 | - $bowerJsFiles[] = 'jqueryui-timepicker-addon/dist/i18n/jquery-ui-timepicker-' . $isoCode . '.js'; |
|
809 | - $bowerJsFiles[] = 'jquery-ui/ui/minified/i18n/datepicker-' . $isoCode . '.min.js'; |
|
808 | + $bowerJsFiles[] = 'jqueryui-timepicker-addon/dist/i18n/jquery-ui-timepicker-'.$isoCode.'.js'; |
|
809 | + $bowerJsFiles[] = 'jquery-ui/ui/minified/i18n/datepicker-'.$isoCode.'.min.js'; |
|
810 | 810 | } |
811 | 811 | |
812 | 812 | foreach ($bowerJsFiles as $file) { |
@@ -889,7 +889,7 @@ discard block |
||
889 | 889 | } |
890 | 890 | |
891 | 891 | $this->assign('online_button', Display::return_icon('statusonline.png', null, null, ICON_SIZE_ATOM)); |
892 | - $this->assign('offline_button',Display::return_icon('statusoffline.png', null, null, ICON_SIZE_ATOM)); |
|
892 | + $this->assign('offline_button', Display::return_icon('statusoffline.png', null, null, ICON_SIZE_ATOM)); |
|
893 | 893 | |
894 | 894 | // Get language iso-code for this page - ignore errors |
895 | 895 | $this->assign('document_language', api_get_language_isocode()); |
@@ -948,14 +948,14 @@ discard block |
||
948 | 948 | $this->assign('section_name', 'section-'.$this_section); |
949 | 949 | |
950 | 950 | //Defaul root chamilo favicon |
951 | - $favico = '<link rel="shortcut icon" href="' . api_get_path(WEB_PATH) . 'favicon.ico" type="image/x-icon" />'; |
|
951 | + $favico = '<link rel="shortcut icon" href="'.api_get_path(WEB_PATH).'favicon.ico" type="image/x-icon" />'; |
|
952 | 952 | |
953 | 953 | //Added to verify if in the current Chamilo Theme exist a favicon |
954 | - $favicoThemeUrl = api_get_path(SYS_CSS_PATH) . 'themes/' . $this->theme . '/images/'; |
|
954 | + $favicoThemeUrl = api_get_path(SYS_CSS_PATH).'themes/'.$this->theme.'/images/'; |
|
955 | 955 | |
956 | 956 | //If exist pick the current chamilo theme favicon |
957 | - if (is_file($favicoThemeUrl . 'favicon.ico')) { |
|
958 | - $favico = '<link rel="shortcut icon" href="' . api_get_path(WEB_CSS_PATH). 'themes/' . $this->theme . '/images/favicon.ico" type="image/x-icon" />'; |
|
957 | + if (is_file($favicoThemeUrl.'favicon.ico')) { |
|
958 | + $favico = '<link rel="shortcut icon" href="'.api_get_path(WEB_CSS_PATH).'themes/'.$this->theme.'/images/favicon.ico" type="image/x-icon" />'; |
|
959 | 959 | } |
960 | 960 | |
961 | 961 | if (api_is_multiple_url_enabled()) { |
@@ -985,7 +985,7 @@ discard block |
||
985 | 985 | if (api_get_setting('show_link_bug_notification') == 'true' && $this->user_is_logged_in) { |
986 | 986 | $rightFloatMenu = '<div class="report"> |
987 | 987 | <a href="https://github.com/chamilo/chamilo-lms/wiki/How-to-report-issues" target="_blank"> |
988 | - '. $iconBug . ' |
|
988 | + '. $iconBug.' |
|
989 | 989 | </a> |
990 | 990 | </div>'; |
991 | 991 | } |
@@ -1001,7 +1001,7 @@ discard block |
||
1001 | 1001 | $url = api_get_path(WEB_CODE_PATH).'ticket/tickets.php?project_id=1&'.$courseParams; |
1002 | 1002 | $rightFloatMenu .= '<div class="report"> |
1003 | 1003 | <a href="'.$url.'" target="_blank"> |
1004 | - '. $iconTicket . ' |
|
1004 | + '. $iconTicket.' |
|
1005 | 1005 | </a> |
1006 | 1006 | </div>'; |
1007 | 1007 | } |
@@ -1108,7 +1108,7 @@ discard block |
||
1108 | 1108 | |
1109 | 1109 | // Block Breadcrumb |
1110 | 1110 | //$breadcrumb = return_breadcrumb($interbreadcrumb, $language_file, $nameTools); |
1111 | - $breadcrumb = ''; |
|
1111 | + $breadcrumb = ''; |
|
1112 | 1112 | $this->assign('breadcrumb', $breadcrumb); |
1113 | 1113 | |
1114 | 1114 | //Extra content |
@@ -1128,13 +1128,13 @@ discard block |
||
1128 | 1128 | $socialMeta = ''; |
1129 | 1129 | $metaTitle = api_get_setting('meta_title'); |
1130 | 1130 | if (!empty($metaTitle)) { |
1131 | - $socialMeta .= '<meta name="twitter:card" content="summary" />' . "\n"; |
|
1131 | + $socialMeta .= '<meta name="twitter:card" content="summary" />'."\n"; |
|
1132 | 1132 | $metaSite = api_get_setting('meta_twitter_site'); |
1133 | 1133 | if (!empty($metaSite)) { |
1134 | - $socialMeta .= '<meta name="twitter:site" content="' . $metaSite . '" />' . "\n"; |
|
1134 | + $socialMeta .= '<meta name="twitter:site" content="'.$metaSite.'" />'."\n"; |
|
1135 | 1135 | $metaCreator = api_get_setting('meta_twitter_creator'); |
1136 | 1136 | if (!empty($metaCreator)) { |
1137 | - $socialMeta .= '<meta name="twitter:creator" content="' . $metaCreator . '" />' . "\n"; |
|
1137 | + $socialMeta .= '<meta name="twitter:creator" content="'.$metaCreator.'" />'."\n"; |
|
1138 | 1138 | } |
1139 | 1139 | } |
1140 | 1140 | |
@@ -1146,19 +1146,19 @@ discard block |
||
1146 | 1146 | if (!$userId && !$skillId) { |
1147 | 1147 | // no combination of user and skill ID has been defined, |
1148 | 1148 | // so print the normal OpenGraph meta tags |
1149 | - $socialMeta .= '<meta property="og:title" content="' . $metaTitle . '" />' . "\n"; |
|
1150 | - $socialMeta .= '<meta property="og:url" content="' . api_get_path(WEB_PATH) . '" />' . "\n"; |
|
1149 | + $socialMeta .= '<meta property="og:title" content="'.$metaTitle.'" />'."\n"; |
|
1150 | + $socialMeta .= '<meta property="og:url" content="'.api_get_path(WEB_PATH).'" />'."\n"; |
|
1151 | 1151 | |
1152 | 1152 | $metaDescription = api_get_setting('meta_description'); |
1153 | 1153 | if (!empty($metaDescription)) { |
1154 | - $socialMeta .= '<meta property="og:description" content="' . $metaDescription . '" />' . "\n"; |
|
1154 | + $socialMeta .= '<meta property="og:description" content="'.$metaDescription.'" />'."\n"; |
|
1155 | 1155 | } |
1156 | 1156 | |
1157 | 1157 | $metaImage = api_get_setting('meta_image_path'); |
1158 | 1158 | if (!empty($metaImage)) { |
1159 | - if (is_file(api_get_path(SYS_PATH) . $metaImage)) { |
|
1160 | - $path = api_get_path(WEB_PATH) . $metaImage; |
|
1161 | - $socialMeta .= '<meta property="og:image" content="' . $path . '" />' . "\n"; |
|
1159 | + if (is_file(api_get_path(SYS_PATH).$metaImage)) { |
|
1160 | + $path = api_get_path(WEB_PATH).$metaImage; |
|
1161 | + $socialMeta .= '<meta property="og:image" content="'.$path.'" />'."\n"; |
|
1162 | 1162 | } |
1163 | 1163 | } |
1164 | 1164 | } |
@@ -1192,7 +1192,7 @@ discard block |
||
1192 | 1192 | // Tutor name |
1193 | 1193 | if (api_get_setting('show_tutor_data') == 'true') { |
1194 | 1194 | // Course manager |
1195 | - $courseId = api_get_course_int_id(); |
|
1195 | + $courseId = api_get_course_int_id(); |
|
1196 | 1196 | $id_session = api_get_session_id(); |
1197 | 1197 | if (!empty($courseId)) { |
1198 | 1198 | $tutor_data = ''; |
@@ -1224,7 +1224,7 @@ discard block |
||
1224 | 1224 | $courseId = api_get_course_int_id(); |
1225 | 1225 | if (!empty($courseId)) { |
1226 | 1226 | $teacher_data = ''; |
1227 | - $mail= CourseManager::get_emails_of_tutors_to_course($courseId); |
|
1227 | + $mail = CourseManager::get_emails_of_tutors_to_course($courseId); |
|
1228 | 1228 | if (!empty($mail)) { |
1229 | 1229 | $teachers_parsed = array(); |
1230 | 1230 | foreach ($mail as $value) { |
@@ -1458,7 +1458,7 @@ discard block |
||
1458 | 1458 | 'sessionVar' => basename(__FILE__, '.php'), |
1459 | 1459 | 'imageOptions' => array( |
1460 | 1460 | 'font_size' => 20, |
1461 | - 'font_path' => api_get_path(SYS_FONTS_PATH) . 'opensans/', |
|
1461 | + 'font_path' => api_get_path(SYS_FONTS_PATH).'opensans/', |
|
1462 | 1462 | 'font_file' => 'OpenSans-Regular.ttf', |
1463 | 1463 | //'output' => 'gif' |
1464 | 1464 | ) |
@@ -603,7 +603,7 @@ |
||
603 | 603 | |
604 | 604 | if (is_file(api_get_path(SYS_CSS_PATH).'themes/'.$this->theme.'/editor.css')) { |
605 | 605 | $css[] = api_get_path(WEB_CSS_PATH).'themes/'.$this->theme.'/editor.css'; |
606 | - }else{ |
|
606 | + } else{ |
|
607 | 607 | $css[] = api_get_cdn_path(api_get_path(WEB_CSS_PATH).'editor.css'); |
608 | 608 | } |
609 | 609 |
@@ -52,6 +52,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | { |
@@ -58,10 +58,10 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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; |
@@ -351,8 +351,9 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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; |
@@ -693,8 +693,8 @@ discard block |
||
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 |
||
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) { |
@@ -43,7 +43,7 @@ |
||
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 | { |
@@ -121,6 +121,9 @@ |
||
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'); |
@@ -167,7 +167,7 @@ discard block |
||
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 |
||
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 |
@@ -97,7 +97,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | */ |
@@ -972,8 +972,7 @@ discard block |
||
972 | 972 | <?php echo get_lang('Error'); ?>!<br /> |
973 | 973 | Chamilo <?php echo implode('|', $update_from_version_8).' '.get_lang('HasNotBeenFoundInThatDir'); ?>. |
974 | 974 | </div> |
975 | - <?php } |
|
976 | - else { |
|
975 | + <?php } else { |
|
977 | 976 | echo '<br />'; |
978 | 977 | } |
979 | 978 | ?> |
@@ -1088,7 +1087,10 @@ discard block |
||
1088 | 1087 | <button type="submit" name="step1" class="btn btn-default" onclick="javascript: window.location='index.php'; return false;" value="<?php echo get_lang('Previous'); ?>" > |
1089 | 1088 | <em class="fa fa-backward"> </em> <?php echo get_lang('Previous'); ?> |
1090 | 1089 | </button> |
1091 | - <button type="submit" name="step2_install" class="btn btn-success" value="<?php echo get_lang("NewInstallation"); ?>" <?php if ($error) echo 'disabled="disabled"'; ?> > |
|
1090 | + <button type="submit" name="step2_install" class="btn btn-success" value="<?php echo get_lang("NewInstallation"); ?>" <?php if ($error) { |
|
1091 | + echo 'disabled="disabled"'; |
|
1092 | +} |
|
1093 | +?> > |
|
1092 | 1094 | <em class="fa fa-forward"> </em> <?php echo get_lang('NewInstallation'); ?> |
1093 | 1095 | </button> |
1094 | 1096 | <input type="hidden" name="is_executable" id="is_executable" value="-" /> |
@@ -1374,7 +1376,7 @@ discard block |
||
1374 | 1376 | <input type="hidden" name="dbHostForm" value="<?php echo htmlentities($dbHostForm); ?>" /><?php echo $dbHostForm; ?> |
1375 | 1377 | </div> |
1376 | 1378 | <div class="col-sm-3"></div> |
1377 | - <?php }else{ ?> |
|
1379 | + <?php } else{ ?> |
|
1378 | 1380 | <div class="col-sm-5"> |
1379 | 1381 | <input type="text" class="form-control" size="25" maxlength="50" name="dbHostForm" value="<?php echo htmlentities($dbHostForm); ?>" /> |
1380 | 1382 | </div> |
@@ -1388,7 +1390,7 @@ discard block |
||
1388 | 1390 | <input type="hidden" name="dbPortForm" value="<?php echo htmlentities($dbPortForm); ?>" /><?php echo $dbPortForm; ?> |
1389 | 1391 | </div> |
1390 | 1392 | <div class="col-sm-3"></div> |
1391 | - <?php }else{ ?> |
|
1393 | + <?php } else{ ?> |
|
1392 | 1394 | <div class="col-sm-5"> |
1393 | 1395 | <input type="text" class="form-control" size="25" maxlength="50" name="dbPortForm" value="<?php echo htmlentities($dbPortForm); ?>" /> |
1394 | 1396 | </div> |
@@ -1470,9 +1472,12 @@ discard block |
||
1470 | 1472 | Database port: <strong><?php echo $manager->getConnection()->getPort(); ?></strong><br/> |
1471 | 1473 | Database driver: <strong><?php echo $manager->getConnection()->getDriver()->getName(); ?></strong><br/> |
1472 | 1474 | </div> |
1473 | - <?php else: ?> |
|
1475 | + <?php else { |
|
1476 | + : ?> |
|
1474 | 1477 | <div id="db_status" class="alert alert-danger"> |
1475 | - <p><?php echo get_lang('FailedConectionDatabase'); ?></strong></p> |
|
1478 | + <p><?php echo get_lang('FailedConectionDatabase'); |
|
1479 | +} |
|
1480 | +?></strong></p> |
|
1476 | 1481 | <code><?php echo $database_exists_text ?></code> |
1477 | 1482 | </div> |
1478 | 1483 | <?php endif; ?> |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | if (!is_array($result)) { |
409 | 409 | $result = array(); |
410 | 410 | $exceptions = array('.', '..', 'CVS', '.svn'); |
411 | - $search = array('_latin', '_unicode', '_corporate', '_org' , '_KM', '_'); |
|
411 | + $search = array('_latin', '_unicode', '_corporate', '_org', '_KM', '_'); |
|
412 | 412 | $replace_with = array(' (Latin)', ' (unicode)', ' (corporate)', ' (org)', ' (KM)', ' '); |
413 | 413 | $dirname = api_get_path(SYS_LANG_PATH); |
414 | 414 | $handle = opendir($dirname); |
@@ -443,9 +443,9 @@ discard block |
||
443 | 443 | if ($handle = opendir($directory)) { |
444 | 444 | while (false !== ($file = readdir($handle))) { |
445 | 445 | if ($file != "." && $file != "..") { |
446 | - if (is_dir($directory. "/" . $file)) { |
|
447 | - $array_items = array_merge($array_items, my_directory_to_array($directory. '/' . $file)); |
|
448 | - $file = $directory . "/" . $file; |
|
446 | + if (is_dir($directory."/".$file)) { |
|
447 | + $array_items = array_merge($array_items, my_directory_to_array($directory.'/'.$file)); |
|
448 | + $file = $directory."/".$file; |
|
449 | 449 | $array_items[] = preg_replace("/\/\//si", '/', $file); |
450 | 450 | } |
451 | 451 | } |
@@ -490,7 +490,7 @@ discard block |
||
490 | 490 | // try to recover config file from Chamilo 1.9.x |
491 | 491 | if (file_exists($updatePath.'main/inc/conf/configuration.php')) { |
492 | 492 | $updateFromConfigFile = 'main/inc/conf/configuration.php'; |
493 | - } elseif (file_exists($updatePath . 'app/config/configuration.php')) { |
|
493 | + } elseif (file_exists($updatePath.'app/config/configuration.php')) { |
|
494 | 494 | $updateFromConfigFile = 'app/config/configuration.php'; |
495 | 495 | } else { |
496 | 496 | // Give up recovering. |
@@ -651,7 +651,7 @@ discard block |
||
651 | 651 | <h2><?php get_lang('WelcomeToTheChamiloInstaller'); ?></h2> |
652 | 652 | <div class="RequirementHeading"> |
653 | 653 | <h2><?php echo display_step_sequence(); ?> |
654 | - <?php echo get_lang('InstallationLanguage');?> |
|
654 | + <?php echo get_lang('InstallationLanguage'); ?> |
|
655 | 655 | </h2> |
656 | 656 | <p><?php echo get_lang('PleaseSelectInstallationProcessLanguage'); ?>:</p> |
657 | 657 | <form id="lang_form" method="post" action="<?php echo api_get_self(); ?>"> |
@@ -705,14 +705,14 @@ discard block |
||
705 | 705 | } |
706 | 706 | echo '</div>'; |
707 | 707 | |
708 | - $properlyAccessUrl = checkAccessUrl(); |
|
708 | + $properlyAccessUrl = checkAccessUrl(); |
|
709 | 709 | |
710 | 710 | if (!$properlyAccessUrl) { |
711 | 711 | echo ' |
712 | 712 | <div class="alert alert-danger"> |
713 | - ' . Display::return_icon('error.png', get_lang('Error'), [], ICON_SIZE_MEDIUM) . |
|
714 | - ' ' . |
|
715 | - sprintf(get_lang('InstallMultiURLDetectedNotMainURL'), api_get_configuration_value('root_web')) . ' |
|
713 | + ' . Display::return_icon('error.png', get_lang('Error'), [], ICON_SIZE_MEDIUM). |
|
714 | + ' '. |
|
715 | + sprintf(get_lang('InstallMultiURLDetectedNotMainURL'), api_get_configuration_value('root_web')).' |
|
716 | 716 | </div> |
717 | 717 | '; |
718 | 718 | } |
@@ -736,7 +736,7 @@ discard block |
||
736 | 736 | if (phpversion() < REQUIRED_PHP_VERSION) { |
737 | 737 | echo '<strong><font color="red">'.get_lang('PHPVersionError').'</font></strong>'; |
738 | 738 | } else { |
739 | - echo '<strong><font color="green">'.get_lang('PHPVersionOK'). ' '.phpversion().'</font></strong>'; |
|
739 | + echo '<strong><font color="green">'.get_lang('PHPVersionOK').' '.phpversion().'</font></strong>'; |
|
740 | 740 | } |
741 | 741 | echo '</td> |
742 | 742 | </tr> |
@@ -1094,9 +1094,9 @@ discard block |
||
1094 | 1094 | } |
1095 | 1095 | |
1096 | 1096 | $deprecated = [ |
1097 | - api_get_path(SYS_CODE_PATH) . 'exercice/', |
|
1098 | - api_get_path(SYS_CODE_PATH) . 'newscorm/', |
|
1099 | - api_get_path(SYS_PLUGIN_PATH) . 'ticket/' |
|
1097 | + api_get_path(SYS_CODE_PATH).'exercice/', |
|
1098 | + api_get_path(SYS_CODE_PATH).'newscorm/', |
|
1099 | + api_get_path(SYS_PLUGIN_PATH).'ticket/' |
|
1100 | 1100 | ]; |
1101 | 1101 | $deprecatedToRemove = []; |
1102 | 1102 | |
@@ -1206,7 +1206,7 @@ discard block |
||
1206 | 1206 | function get_contact_registration_form() |
1207 | 1207 | { |
1208 | 1208 | |
1209 | - $html =' |
|
1209 | + $html = ' |
|
1210 | 1210 | <div class="form-horizontal"> |
1211 | 1211 | <div class="panel panel-default"> |
1212 | 1212 | <div class="panel-body"> |
@@ -1303,7 +1303,7 @@ discard block |
||
1303 | 1303 | <div class="col-sm-9"> |
1304 | 1304 | <div class="radio"> |
1305 | 1305 | <label> |
1306 | - <input type="radio" name="financial_decision" id="financial_decision1" value="1" checked /> ' . get_lang('Yes') . ' |
|
1306 | + <input type="radio" name="financial_decision" id="financial_decision1" value="1" checked /> ' . get_lang('Yes').' |
|
1307 | 1307 | </label> |
1308 | 1308 | </div> |
1309 | 1309 | <div class="radio"> |
@@ -1362,8 +1362,8 @@ discard block |
||
1362 | 1362 | echo '<input type="hidden" name="'.$formFieldName.'" id="'.$formFieldName.'" value="'.api_htmlentities($parameterValue).'" />'; |
1363 | 1363 | echo api_htmlentities($parameterValue); |
1364 | 1364 | } else { |
1365 | - 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>"; |
|
1366 | - echo '<div class="col-sm-3">' . $extra_notice . '</div>'; |
|
1365 | + 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>"; |
|
1366 | + echo '<div class="col-sm-3">'.$extra_notice.'</div>'; |
|
1367 | 1367 | } |
1368 | 1368 | } |
1369 | 1369 | } |
@@ -1397,12 +1397,12 @@ discard block |
||
1397 | 1397 | $dbNameForm = $_configuration['main_database']; |
1398 | 1398 | $dbPortForm = isset($_configuration['db_port']) ? $_configuration['db_port'] : ''; |
1399 | 1399 | |
1400 | - echo '<div class="RequirementHeading"><h2>' . display_step_sequence() .get_lang('DBSetting') . '</h2></div>'; |
|
1400 | + echo '<div class="RequirementHeading"><h2>'.display_step_sequence().get_lang('DBSetting').'</h2></div>'; |
|
1401 | 1401 | echo '<div class="RequirementContent">'; |
1402 | 1402 | echo get_lang('DBSettingUpgradeIntro'); |
1403 | 1403 | echo '</div>'; |
1404 | 1404 | } else { |
1405 | - echo '<div class="RequirementHeading"><h2>' . display_step_sequence() .get_lang('DBSetting') . '</h2></div>'; |
|
1405 | + echo '<div class="RequirementHeading"><h2>'.display_step_sequence().get_lang('DBSetting').'</h2></div>'; |
|
1406 | 1406 | echo '<div class="RequirementContent">'; |
1407 | 1407 | echo get_lang('DBSettingIntro'); |
1408 | 1408 | echo '</div>'; |
@@ -1412,12 +1412,12 @@ discard block |
||
1412 | 1412 | <div class="panel-body"> |
1413 | 1413 | <div class="form-group"> |
1414 | 1414 | <label class="col-sm-4"><?php echo get_lang('DBHost'); ?> </label> |
1415 | - <?php if ($installType == 'update'){ ?> |
|
1415 | + <?php if ($installType == 'update') { ?> |
|
1416 | 1416 | <div class="col-sm-5"> |
1417 | 1417 | <input type="hidden" name="dbHostForm" value="<?php echo htmlentities($dbHostForm); ?>" /><?php echo $dbHostForm; ?> |
1418 | 1418 | </div> |
1419 | 1419 | <div class="col-sm-3"></div> |
1420 | - <?php }else{ ?> |
|
1420 | + <?php } else { ?> |
|
1421 | 1421 | <div class="col-sm-5"> |
1422 | 1422 | <input type="text" class="form-control" size="25" maxlength="50" name="dbHostForm" value="<?php echo htmlentities($dbHostForm); ?>" /> |
1423 | 1423 | </div> |
@@ -1426,12 +1426,12 @@ discard block |
||
1426 | 1426 | </div> |
1427 | 1427 | <div class="form-group"> |
1428 | 1428 | <label class="col-sm-4"><?php echo get_lang('DBPort'); ?> </label> |
1429 | - <?php if ($installType == 'update'){ ?> |
|
1429 | + <?php if ($installType == 'update') { ?> |
|
1430 | 1430 | <div class="col-sm-5"> |
1431 | 1431 | <input type="hidden" name="dbPortForm" value="<?php echo htmlentities($dbPortForm); ?>" /><?php echo $dbPortForm; ?> |
1432 | 1432 | </div> |
1433 | 1433 | <div class="col-sm-3"></div> |
1434 | - <?php }else{ ?> |
|
1434 | + <?php } else { ?> |
|
1435 | 1435 | <div class="col-sm-5"> |
1436 | 1436 | <input type="text" class="form-control" size="25" maxlength="50" name="dbPortForm" value="<?php echo htmlentities($dbPortForm); ?>" /> |
1437 | 1437 | </div> |
@@ -1457,7 +1457,7 @@ discard block |
||
1457 | 1457 | <?php |
1458 | 1458 | //Database Name fix replace weird chars |
1459 | 1459 | if ($installType != INSTALL_TYPE_UPDATE) { |
1460 | - $dbNameForm = str_replace(array('-','*', '$', ' ', '.'), '', $dbNameForm); |
|
1460 | + $dbNameForm = str_replace(array('-', '*', '$', ' ', '.'), '', $dbNameForm); |
|
1461 | 1461 | } |
1462 | 1462 | |
1463 | 1463 | displayDatabaseParameter( |
@@ -1550,7 +1550,7 @@ discard block |
||
1550 | 1550 | if (!empty($title)) { |
1551 | 1551 | $panelTitle = Display::div($title, array('class' => 'panel-heading')); |
1552 | 1552 | $panelBody = Display::div($content, array('class' => 'panel-body')); |
1553 | - $panelParent = Display::div($panelTitle . $panelBody, array('id' => $id, 'class' => 'panel panel-'.$style)); |
|
1553 | + $panelParent = Display::div($panelTitle.$panelBody, array('id' => $id, 'class' => 'panel panel-'.$style)); |
|
1554 | 1554 | } else { |
1555 | 1555 | $panelBody = Display::div($html, array('class' => 'panel-body')); |
1556 | 1556 | $panelParent = Display::div($panelBody, array('id' => $id, 'class' => 'panel panel-'.$style)); |
@@ -1576,9 +1576,9 @@ discard block |
||
1576 | 1576 | $displayWhenUpdate = 'true' |
1577 | 1577 | ) { |
1578 | 1578 | $html = '<div class="form-group">'; |
1579 | - $html .= '<label class="col-sm-6 control-label">' . $parameterName . '</label>'; |
|
1579 | + $html .= '<label class="col-sm-6 control-label">'.$parameterName.'</label>'; |
|
1580 | 1580 | if ($installType == INSTALL_TYPE_UPDATE && $displayWhenUpdate) { |
1581 | - $html .= '<input type="hidden" name="' . $formFieldName . '" value="'. api_htmlentities($parameterValue, ENT_QUOTES). '" />' . $parameterValue; |
|
1581 | + $html .= '<input type="hidden" name="'.$formFieldName.'" value="'.api_htmlentities($parameterValue, ENT_QUOTES).'" />'.$parameterValue; |
|
1582 | 1582 | } else { |
1583 | 1583 | $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>"; |
1584 | 1584 | } |
@@ -1626,7 +1626,7 @@ discard block |
||
1626 | 1626 | $languageForm = $_SESSION['install_language']; |
1627 | 1627 | } |
1628 | 1628 | echo '<div class="RequirementHeading">'; |
1629 | - echo "<h2>" . display_step_sequence() . get_lang("CfgSetting") . "</h2>"; |
|
1629 | + echo "<h2>".display_step_sequence().get_lang("CfgSetting")."</h2>"; |
|
1630 | 1630 | echo '</div>'; |
1631 | 1631 | |
1632 | 1632 | echo '<p>'.get_lang('ConfigSettingsInfo').' <strong>app/config/configuration.php</strong></p>'; |
@@ -1644,14 +1644,14 @@ discard block |
||
1644 | 1644 | |
1645 | 1645 | // Parameters 3 and 4: administrator's names |
1646 | 1646 | |
1647 | - $html .= display_configuration_parameter($installType, get_lang('AdminFirstName'), 'adminFirstName', $adminFirstName); |
|
1648 | - $html .= display_configuration_parameter($installType, get_lang('AdminLastName'), 'adminLastName', $adminLastName); |
|
1647 | + $html .= display_configuration_parameter($installType, get_lang('AdminFirstName'), 'adminFirstName', $adminFirstName); |
|
1648 | + $html .= display_configuration_parameter($installType, get_lang('AdminLastName'), 'adminLastName', $adminLastName); |
|
1649 | 1649 | |
1650 | 1650 | //Parameter 3: administrator's email |
1651 | - $html .= display_configuration_parameter($installType, get_lang('AdminEmail'), 'emailForm', $emailForm); |
|
1651 | + $html .= display_configuration_parameter($installType, get_lang('AdminEmail'), 'emailForm', $emailForm); |
|
1652 | 1652 | |
1653 | 1653 | //Parameter 6: administrator's telephone |
1654 | - $html .= display_configuration_parameter($installType, get_lang('AdminPhone'), 'adminPhoneForm', $adminPhoneForm); |
|
1654 | + $html .= display_configuration_parameter($installType, get_lang('AdminPhone'), 'adminPhoneForm', $adminPhoneForm); |
|
1655 | 1655 | |
1656 | 1656 | |
1657 | 1657 | echo panel($html, get_lang('Administrator'), 'administrator'); |
@@ -1670,12 +1670,12 @@ discard block |
||
1670 | 1670 | $html .= display_language_selection_box('languageForm', $languageForm); |
1671 | 1671 | $html .= '</div>'; |
1672 | 1672 | } |
1673 | - $html.= "</div>"; |
|
1673 | + $html .= "</div>"; |
|
1674 | 1674 | |
1675 | 1675 | |
1676 | 1676 | //Second parameter: Chamilo URL |
1677 | 1677 | $html .= '<div class="form-group">'; |
1678 | - $html .= '<label class="col-sm-6 control-label">'.get_lang('ChamiloURL') .get_lang('ThisFieldIsRequired').'</label>'; |
|
1678 | + $html .= '<label class="col-sm-6 control-label">'.get_lang('ChamiloURL').get_lang('ThisFieldIsRequired').'</label>'; |
|
1679 | 1679 | |
1680 | 1680 | |
1681 | 1681 | |
@@ -1699,34 +1699,34 @@ discard block |
||
1699 | 1699 | |
1700 | 1700 | |
1701 | 1701 | $html .= '<div class="form-group"> |
1702 | - <label class="col-sm-6 control-label">' . get_lang("EncryptMethodUserPass") . '</label> |
|
1702 | + <label class="col-sm-6 control-label">' . get_lang("EncryptMethodUserPass").'</label> |
|
1703 | 1703 | <div class="col-sm-6">'; |
1704 | 1704 | if ($installType == 'update') { |
1705 | - $html .= '<input type="hidden" name="encryptPassForm" value="'. $encryptPassForm .'" />'. $encryptPassForm; |
|
1705 | + $html .= '<input type="hidden" name="encryptPassForm" value="'.$encryptPassForm.'" />'.$encryptPassForm; |
|
1706 | 1706 | } else { |
1707 | 1707 | |
1708 | 1708 | $html .= '<div class="checkbox"> |
1709 | 1709 | <label> |
1710 | - <input type="radio" name="encryptPassForm" value="bcrypt" id="encryptPass1" '. ($encryptPassForm == 'bcrypt' ? 'checked="checked" ':'') .'/> bcrypt |
|
1710 | + <input type="radio" name="encryptPassForm" value="bcrypt" id="encryptPass1" '. ($encryptPassForm == 'bcrypt' ? 'checked="checked" ' : '').'/> bcrypt |
|
1711 | 1711 | </label>'; |
1712 | 1712 | |
1713 | 1713 | $html .= '<label> |
1714 | - <input type="radio" name="encryptPassForm" value="sha1" id="encryptPass1" '. ($encryptPassForm == 'sha1' ? 'checked="checked" ':'') .'/> sha1 |
|
1714 | + <input type="radio" name="encryptPassForm" value="sha1" id="encryptPass1" '. ($encryptPassForm == 'sha1' ? 'checked="checked" ' : '').'/> sha1 |
|
1715 | 1715 | </label>'; |
1716 | 1716 | |
1717 | 1717 | $html .= '<label> |
1718 | - <input type="radio" name="encryptPassForm" value="md5" id="encryptPass0" '. ($encryptPassForm == 'md5' ? 'checked="checked" ':'') .'/> md5 |
|
1718 | + <input type="radio" name="encryptPassForm" value="md5" id="encryptPass0" '. ($encryptPassForm == 'md5' ? 'checked="checked" ' : '').'/> md5 |
|
1719 | 1719 | </label>'; |
1720 | 1720 | |
1721 | 1721 | $html .= '<label> |
1722 | - <input type="radio" name="encryptPassForm" value="none" id="encryptPass2" '. ($encryptPassForm == 'none' ? 'checked="checked" ':'') .'/>'. get_lang('None').' |
|
1722 | + <input type="radio" name="encryptPassForm" value="none" id="encryptPass2" '. ($encryptPassForm == 'none' ? 'checked="checked" ' : '').'/>'.get_lang('None').' |
|
1723 | 1723 | </label>'; |
1724 | 1724 | $html .= '</div>'; |
1725 | 1725 | } |
1726 | 1726 | $html .= '</div></div>'; |
1727 | 1727 | |
1728 | 1728 | $html .= '<div class="form-group"> |
1729 | - <label class="col-sm-6 control-label">' . get_lang('AllowSelfReg') . '</label> |
|
1729 | + <label class="col-sm-6 control-label">' . get_lang('AllowSelfReg').'</label> |
|
1730 | 1730 | <div class="col-sm-6">'; |
1731 | 1731 | if ($installType == 'update') { |
1732 | 1732 | if ($allowSelfReg == 'true') { |
@@ -1736,17 +1736,17 @@ discard block |
||
1736 | 1736 | } else { |
1737 | 1737 | $label = get_lang('AfterApproval'); |
1738 | 1738 | } |
1739 | - $html .= '<input type="hidden" name="allowSelfReg" value="'. $allowSelfReg .'" />'. $label; |
|
1739 | + $html .= '<input type="hidden" name="allowSelfReg" value="'.$allowSelfReg.'" />'.$label; |
|
1740 | 1740 | } else { |
1741 | 1741 | $html .= '<div class="control-group">'; |
1742 | 1742 | $html .= '<label class="checkbox-inline"> |
1743 | - <input type="radio" name="allowSelfReg" value="true" id="allowSelfReg1" '. ($allowSelfReg == 'true' ? 'checked="checked" ' : '') . ' /> '. get_lang('Yes') .' |
|
1743 | + <input type="radio" name="allowSelfReg" value="true" id="allowSelfReg1" '. ($allowSelfReg == 'true' ? 'checked="checked" ' : '').' /> '.get_lang('Yes').' |
|
1744 | 1744 | </label>'; |
1745 | 1745 | $html .= '<label class="checkbox-inline"> |
1746 | - <input type="radio" name="allowSelfReg" value="false" id="allowSelfReg0" '. ($allowSelfReg == 'false' ? '' : 'checked="checked" ') .' /> '. get_lang('No') .' |
|
1746 | + <input type="radio" name="allowSelfReg" value="false" id="allowSelfReg0" '. ($allowSelfReg == 'false' ? '' : 'checked="checked" ').' /> '.get_lang('No').' |
|
1747 | 1747 | </label>'; |
1748 | 1748 | $html .= '<label class="checkbox-inline"> |
1749 | - <input type="radio" name="allowSelfReg" value="approval" id="allowSelfReg2" '. ($allowSelfReg == 'approval' ? '' : 'checked="checked" ') .' /> '. get_lang('AfterApproval') .' |
|
1749 | + <input type="radio" name="allowSelfReg" value="approval" id="allowSelfReg2" '. ($allowSelfReg == 'approval' ? '' : 'checked="checked" ').' /> '.get_lang('AfterApproval').' |
|
1750 | 1750 | </label>'; |
1751 | 1751 | $html .= '</div>'; |
1752 | 1752 | } |
@@ -1754,7 +1754,7 @@ discard block |
||
1754 | 1754 | $html .= '</div>'; |
1755 | 1755 | |
1756 | 1756 | $html .= '<div class="form-group">'; |
1757 | - $html .= '<label class="col-sm-6 control-label">'. get_lang('AllowSelfRegProf') .'</label> |
|
1757 | + $html .= '<label class="col-sm-6 control-label">'.get_lang('AllowSelfRegProf').'</label> |
|
1758 | 1758 | <div class="col-sm-6">'; |
1759 | 1759 | if ($installType == 'update') { |
1760 | 1760 | if ($allowSelfRegProf == 'true') { |
@@ -1762,16 +1762,16 @@ discard block |
||
1762 | 1762 | } else { |
1763 | 1763 | $label = get_lang('No'); |
1764 | 1764 | } |
1765 | - $html .= '<input type="hidden" name="allowSelfRegProf" value="'. $allowSelfRegProf.'" />'. $label; |
|
1765 | + $html .= '<input type="hidden" name="allowSelfRegProf" value="'.$allowSelfRegProf.'" />'.$label; |
|
1766 | 1766 | } else { |
1767 | 1767 | $html .= '<div class="control-group"> |
1768 | 1768 | <label class="checkbox-inline"> |
1769 | - <input type="radio" name="allowSelfRegProf" value="1" id="allowSelfRegProf1" '. ($allowSelfRegProf ? 'checked="checked" ' : '') .'/> |
|
1770 | - ' . get_lang('Yes') .' |
|
1769 | + <input type="radio" name="allowSelfRegProf" value="1" id="allowSelfRegProf1" '. ($allowSelfRegProf ? 'checked="checked" ' : '').'/> |
|
1770 | + ' . get_lang('Yes').' |
|
1771 | 1771 | </label>'; |
1772 | 1772 | $html .= '<label class="checkbox-inline"> |
1773 | - <input type="radio" name="allowSelfRegProf" value="0" id="allowSelfRegProf0" '. ($allowSelfRegProf ? '' : 'checked="checked" ') .' /> |
|
1774 | - '. get_lang('No') .' |
|
1773 | + <input type="radio" name="allowSelfRegProf" value="0" id="allowSelfRegProf0" '. ($allowSelfRegProf ? '' : 'checked="checked" ').' /> |
|
1774 | + '. get_lang('No').' |
|
1775 | 1775 | </label>'; |
1776 | 1776 | $html .= '</div>'; |
1777 | 1777 | } |
@@ -1836,7 +1836,7 @@ discard block |
||
1836 | 1836 | "Macedonia", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands", "Mauritania", "Mauritius", "Mexico", "Micronesia", "Moldova", "Monaco", "Mongolia", "Morocco", "Mozambique", "Myanmar", |
1837 | 1837 | "Namibia", "Nauru", "Nepa", "Netherlands", "New Zealand", "Nicaragua", "Niger", "Nigeria", "Norway", |
1838 | 1838 | "Oman", |
1839 | - "Pakistan", "Palau", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines", "Poland","Portugal", |
|
1839 | + "Pakistan", "Palau", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines", "Poland", "Portugal", |
|
1840 | 1840 | "Qatar", |
1841 | 1841 | "Romania", "Russia", "Rwanda", |
1842 | 1842 | "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", |
@@ -1883,11 +1883,11 @@ discard block |
||
1883 | 1883 | $permissions_for_new_directories = isset($_SESSION['permissions_for_new_directories']) ? $_SESSION['permissions_for_new_directories'] : 0770; |
1884 | 1884 | $permissions_for_new_files = isset($_SESSION['permissions_for_new_files']) ? $_SESSION['permissions_for_new_files'] : 0660; |
1885 | 1885 | // use decoct() to store as string |
1886 | - $sql = "UPDATE $table SET selected_value = '0" . decoct($permissions_for_new_directories) . "' |
|
1886 | + $sql = "UPDATE $table SET selected_value = '0".decoct($permissions_for_new_directories)."' |
|
1887 | 1887 | WHERE variable = 'permissions_for_new_directories'"; |
1888 | 1888 | Database::query($sql); |
1889 | 1889 | |
1890 | - $sql = "UPDATE $table SET selected_value = '0" . decoct($permissions_for_new_files) . "' WHERE variable = 'permissions_for_new_files'"; |
|
1890 | + $sql = "UPDATE $table SET selected_value = '0".decoct($permissions_for_new_files)."' WHERE variable = 'permissions_for_new_files'"; |
|
1891 | 1891 | Database::query($sql); |
1892 | 1892 | |
1893 | 1893 | if (isset($_SESSION['permissions_for_new_directories'])) { |
@@ -1907,8 +1907,8 @@ discard block |
||
1907 | 1907 | function compare_setting_values($current_value, $wanted_value) |
1908 | 1908 | { |
1909 | 1909 | $current_value_string = $current_value; |
1910 | - $current_value = (float)$current_value; |
|
1911 | - $wanted_value = (float)$wanted_value; |
|
1910 | + $current_value = (float) $current_value; |
|
1911 | + $wanted_value = (float) $wanted_value; |
|
1912 | 1912 | |
1913 | 1913 | if ($current_value >= $wanted_value) { |
1914 | 1914 | return Display::label($current_value_string, 'success'); |
@@ -1971,7 +1971,7 @@ discard block |
||
1971 | 1971 | |
1972 | 1972 | fwrite($fp, $out); |
1973 | 1973 | while (!feof($fp)) { |
1974 | - $result = str_replace("\r\n", '',fgets($fp, 128)); |
|
1974 | + $result = str_replace("\r\n", '', fgets($fp, 128)); |
|
1975 | 1975 | if (!empty($result) && $result == '123') { |
1976 | 1976 | $output = true; |
1977 | 1977 | } |
@@ -1994,7 +1994,7 @@ discard block |
||
1994 | 1994 | curl_setopt($ch, CURLOPT_URL, $url); |
1995 | 1995 | //curl_setopt($ch, CURLOPT_TIMEOUT, 30); |
1996 | 1996 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
1997 | - $result = curl_exec ($ch); |
|
1997 | + $result = curl_exec($ch); |
|
1998 | 1998 | if (!empty($result) && $result == '123') { |
1999 | 1999 | $output = true; |
2000 | 2000 | } |
@@ -2755,12 +2755,12 @@ discard block |
||
2755 | 2755 | $adminPhoneForm, |
2756 | 2756 | '', //$picture_uri = '', |
2757 | 2757 | PLATFORM_AUTH_SOURCE, |
2758 | - '',//$expirationDate, |
|
2758 | + '', //$expirationDate, |
|
2759 | 2759 | 1, |
2760 | 2760 | 0, |
2761 | 2761 | null, |
2762 | 2762 | '', |
2763 | - false, //$send_mail = false, |
|
2763 | + false, //$send_mail = false, |
|
2764 | 2764 | true //$isAdmin = false |
2765 | 2765 | ); |
2766 | 2766 | |
@@ -2782,7 +2782,7 @@ discard block |
||
2782 | 2782 | 0, |
2783 | 2783 | null, |
2784 | 2784 | '', |
2785 | - false, //$send_mail = false, |
|
2785 | + false, //$send_mail = false, |
|
2786 | 2786 | false //$isAdmin = false |
2787 | 2787 | ); |
2788 | 2788 | |
@@ -2817,7 +2817,7 @@ discard block |
||
2817 | 2817 | Database::query($sql); |
2818 | 2818 | |
2819 | 2819 | foreach ($files as $version) { |
2820 | - $version = str_replace(['Version', '.php' ], '', $version->getFilename()); |
|
2820 | + $version = str_replace(['Version', '.php'], '', $version->getFilename()); |
|
2821 | 2821 | $sql = "INSERT INTO version (version) VALUES ('$version')"; |
2822 | 2822 | Database::query($sql); |
2823 | 2823 | } |
@@ -2863,7 +2863,7 @@ discard block |
||
2863 | 2863 | SET selected_value = '".$param->selected_value."' |
2864 | 2864 | WHERE variable = '".$param->variable."'"; |
2865 | 2865 | if (!empty($param->subkey)) { |
2866 | - $sql .= " AND subkey='" . $param->subkey . "'"; |
|
2866 | + $sql .= " AND subkey='".$param->subkey."'"; |
|
2867 | 2867 | } |
2868 | 2868 | Database::query($sql); |
2869 | 2869 | } |
@@ -1745,7 +1745,7 @@ discard block |
||
1745 | 1745 | $html .= '<label class="checkbox-inline"> |
1746 | 1746 | <input type="radio" name="allowSelfReg" value="false" id="allowSelfReg0" '. ($allowSelfReg == 'false' ? '' : 'checked="checked" ') .' /> '. get_lang('No') .' |
1747 | 1747 | </label>'; |
1748 | - $html .= '<label class="checkbox-inline"> |
|
1748 | + $html .= '<label class="checkbox-inline"> |
|
1749 | 1749 | <input type="radio" name="allowSelfReg" value="approval" id="allowSelfReg2" '. ($allowSelfReg == 'approval' ? '' : 'checked="checked" ') .' /> '. get_lang('AfterApproval') .' |
1750 | 1750 | </label>'; |
1751 | 1751 | $html .= '</div>'; |
@@ -1779,7 +1779,7 @@ discard block |
||
1779 | 1779 | </div>'; |
1780 | 1780 | |
1781 | 1781 | echo panel($html, get_lang('Platform'), 'platform'); |
1782 | - ?> |
|
1782 | + ?> |
|
1783 | 1783 | <div class='form-group'> |
1784 | 1784 | <div class="col-sm-6"> |
1785 | 1785 | <button type="submit" class="btn btn-default pull-right" name="step3" value="< <?php echo get_lang('Previous'); ?>" ><em class="fa fa-backward"> </em> <?php echo get_lang('Previous'); ?></button> |
@@ -118,7 +118,7 @@ discard block |
||
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 |
||
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 |
@@ -132,24 +132,20 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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'; |
@@ -25,38 +25,38 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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.'&'; |
|
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.'&'; |
|
290 | - } |
|
291 | - $url=$url.'?'.$urlparameters; |
|
292 | - |
|
293 | - //echo "\t\t\t <a href=\"".str_replace('&', '&', $_SERVER['REQUEST_URI'])."&action=grant&permission=$permission&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.'&'; |
|
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.'&'; |
|
290 | + } |
|
291 | + $url=$url.'?'.$urlparameters; |
|
292 | + |
|
293 | + //echo "\t\t\t <a href=\"".str_replace('&', '&', $_SERVER['REQUEST_URI'])."&action=grant&permission=$permission&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 |
||
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 . '&'; |
|
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 . '&'; |
|
374 | - } |
|
375 | - $url=$url.'?'.$urlparameters; |
|
376 | - |
|
377 | - //echo "\t\t\t <a href=\"".str_replace('&', '&', $_SERVER['REQUEST_URI'])."&action=grant&permission=$permission&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 . '&'; |
|
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 . '&'; |
|
374 | + } |
|
375 | + $url=$url.'?'.$urlparameters; |
|
376 | + |
|
377 | + //echo "\t\t\t <a href=\"".str_replace('&', '&', $_SERVER['REQUEST_URI'])."&action=grant&permission=$permission&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 |
||
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('&', '&', $_SERVER['REQUEST_URI'])."&action=$action&role=".$row['role_id']."&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']."&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('&', '&', $_SERVER['REQUEST_URI'])."&action=$action&role=".$row['role_id']."&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']."&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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | ?> |
@@ -26,34 +26,34 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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.'&'; |
|
265 | + $urlparameters .= $key.'='.$value.'&'; |
|
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 |
||
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.'&'; |
|
289 | + $urlparameters .= $key.'='.$value.'&'; |
|
290 | 290 | } |
291 | - $url=$url.'?'.$urlparameters; |
|
291 | + $url = $url.'?'.$urlparameters; |
|
292 | 292 | |
293 | 293 | //echo "\t\t\t <a href=\"".str_replace('&', '&', $_SERVER['REQUEST_URI'])."&action=grant&permission=$permission&tool=$tool\">"; |
294 | 294 | echo "\t\t\t <a href=\"".$url."\">"; |
@@ -315,7 +315,7 @@ discard block |
||
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 |
||
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 . '&'; |
|
350 | + $urlparameters .= $key.'='.$value.'&'; |
|
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 |
||
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 . '&'; |
|
373 | + $urlparameters .= $key.'='.$value.'&'; |
|
374 | 374 | } |
375 | - $url=$url.'?'.$urlparameters; |
|
375 | + $url = $url.'?'.$urlparameters; |
|
376 | 376 | |
377 | 377 | //echo "\t\t\t <a href=\"".str_replace('&', '&', $_SERVER['REQUEST_URI'])."&action=grant&permission=$permission&tool=$tool\">"; |
378 | 378 | echo "\t\t\t <a href=\"".$url."\">"; |
@@ -397,30 +397,30 @@ discard block |
||
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('&', '&', $_SERVER['REQUEST_URI'])."&action=$action&role=".$row['role_id']."&scope=course\"><img src=\"../img/".$image."\" border=\"0\"/></a>"; |
426 | 426 | } |
@@ -440,24 +440,24 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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; |
@@ -785,7 +785,6 @@ |
||
785 | 785 | * lock = the user can no longer use this account |
786 | 786 | * @author Patrick Cool <[email protected]>, Ghent University |
787 | 787 | * @param int $active the current state of the account |
788 | - * @param int $user_id The user id |
|
789 | 788 | * @param string $url_params |
790 | 789 | * @return string Some HTML-code with the lock/unlock button |
791 | 790 | */ |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | |
28 | 28 | // Access restriction |
29 | 29 | if (!api_is_allowed_to_edit()) { |
30 | - api_not_allowed(true); |
|
30 | + api_not_allowed(true); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | $tool_name = get_lang("SubscribeUserToCourse"); |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | $courseInfo = api_get_course_info(); |
38 | 38 | |
39 | 39 | if ($type == COURSEMANAGER) { |
40 | - $tool_name = get_lang("SubscribeUserToCourseAsTeacher"); |
|
40 | + $tool_name = get_lang("SubscribeUserToCourseAsTeacher"); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | //extra entries in breadcrumb |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | "url" => "subscribe_user.php?type=".$type.'&'.api_get_cidreq(), |
51 | 51 | "name" => $tool_name |
52 | 52 | ); |
53 | - $tool_name = get_lang('SearchResults'); |
|
53 | + $tool_name = get_lang('SearchResults'); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | $sessionId = api_get_session_id(); |
@@ -130,10 +130,10 @@ discard block |
||
130 | 130 | |
131 | 131 | // Build table |
132 | 132 | $table = new SortableTable( |
133 | - 'subscribe_users', |
|
134 | - 'get_number_of_users', |
|
135 | - 'get_user_data', |
|
136 | - ($is_western_name_order xor $sort_by_first_name) ? 3 : 2 |
|
133 | + 'subscribe_users', |
|
134 | + 'get_number_of_users', |
|
135 | + 'get_user_data', |
|
136 | + ($is_western_name_order xor $sort_by_first_name) ? 3 : 2 |
|
137 | 137 | ); |
138 | 138 | $parameters['keyword'] = $keyword; |
139 | 139 | $parameters['type'] = $type; |
@@ -220,18 +220,18 @@ discard block |
||
220 | 220 | */ |
221 | 221 | function get_number_of_users() |
222 | 222 | { |
223 | - // Database table definition |
|
224 | - $user_table = Database::get_main_table(TABLE_MAIN_USER); |
|
225 | - $course_user_table = Database::get_main_table(TABLE_MAIN_COURSE_USER); |
|
226 | - $tbl_session_rel_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); |
|
227 | - $table_user_field_values = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES); |
|
223 | + // Database table definition |
|
224 | + $user_table = Database::get_main_table(TABLE_MAIN_USER); |
|
225 | + $course_user_table = Database::get_main_table(TABLE_MAIN_COURSE_USER); |
|
226 | + $tbl_session_rel_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); |
|
227 | + $table_user_field_values = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES); |
|
228 | 228 | |
229 | 229 | $courseCode = api_get_course_id(); |
230 | 230 | $sessionId = api_get_session_id(); |
231 | 231 | |
232 | - if (isset($_REQUEST['type']) && $_REQUEST['type'] === 'teacher') { |
|
233 | - if (api_get_session_id() != 0) { |
|
234 | - $sql = "SELECT COUNT(u.id) |
|
232 | + if (isset($_REQUEST['type']) && $_REQUEST['type'] === 'teacher') { |
|
233 | + if (api_get_session_id() != 0) { |
|
234 | + $sql = "SELECT COUNT(u.id) |
|
235 | 235 | FROM $user_table u |
236 | 236 | LEFT JOIN $tbl_session_rel_course_user cu |
237 | 237 | ON |
@@ -399,11 +399,11 @@ discard block |
||
399 | 399 | $count_user = 0; |
400 | 400 | |
401 | 401 | if ($res) { |
402 | - $row = Database::fetch_row($res); |
|
403 | - $count_user = $row[0]; |
|
402 | + $row = Database::fetch_row($res); |
|
403 | + $count_user = $row[0]; |
|
404 | 404 | } |
405 | 405 | |
406 | - return $count_user; |
|
406 | + return $count_user; |
|
407 | 407 | } |
408 | 408 | /** |
409 | 409 | * Get the users to display on the current page. |
@@ -413,17 +413,17 @@ discard block |
||
413 | 413 | $url_access_id = api_get_current_access_url_id(); |
414 | 414 | $course_code = api_get_course_id(); |
415 | 415 | $sessionId = api_get_session_id(); |
416 | - $courseId = api_get_course_int_id(); |
|
416 | + $courseId = api_get_course_int_id(); |
|
417 | 417 | |
418 | - // Database table definitions |
|
419 | - $user_table = Database::get_main_table(TABLE_MAIN_USER); |
|
420 | - $course_user_table = Database::get_main_table(TABLE_MAIN_COURSE_USER); |
|
421 | - $tbl_session_rel_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); |
|
422 | - $table_user_field_values = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES); |
|
418 | + // Database table definitions |
|
419 | + $user_table = Database::get_main_table(TABLE_MAIN_USER); |
|
420 | + $course_user_table = Database::get_main_table(TABLE_MAIN_COURSE_USER); |
|
421 | + $tbl_session_rel_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); |
|
422 | + $table_user_field_values = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES); |
|
423 | 423 | $tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
424 | 424 | |
425 | 425 | // adding teachers |
426 | - $is_western_name_order = api_is_western_name_order(); |
|
426 | + $is_western_name_order = api_is_western_name_order(); |
|
427 | 427 | |
428 | 428 | if (api_get_setting('show_email_addresses') === 'true') { |
429 | 429 | $select_fields = "u.id AS col0, |
@@ -447,10 +447,10 @@ discard block |
||
447 | 447 | u.active AS col4, |
448 | 448 | u.user_id AS col5"; |
449 | 449 | } |
450 | - if (isset($_REQUEST['type']) && $_REQUEST['type'] == COURSEMANAGER) { |
|
451 | - // adding a teacher through a session |
|
452 | - if (!empty($sessionId)) { |
|
453 | - $sql = "SELECT $select_fields |
|
450 | + if (isset($_REQUEST['type']) && $_REQUEST['type'] == COURSEMANAGER) { |
|
451 | + // adding a teacher through a session |
|
452 | + if (!empty($sessionId)) { |
|
453 | + $sql = "SELECT $select_fields |
|
454 | 454 | FROM $user_table u |
455 | 455 | LEFT JOIN $tbl_session_rel_course_user cu |
456 | 456 | ON |
@@ -460,13 +460,13 @@ discard block |
||
460 | 460 | INNER JOIN $tbl_url_rel_user as url_rel_user |
461 | 461 | ON (url_rel_user.user_id = u.user_id) "; |
462 | 462 | |
463 | - // applying the filter of the additional user profile fields |
|
464 | - if (isset($_GET['subscribe_user_filter_value']) && |
|
465 | - !empty($_GET['subscribe_user_filter_value']) && |
|
466 | - api_get_setting('ProfilingFilterAddingUsers') == 'true' |
|
467 | - ) { |
|
468 | - $field_identification = explode('*',$_GET['subscribe_user_filter_value']); |
|
469 | - $sql .= " |
|
463 | + // applying the filter of the additional user profile fields |
|
464 | + if (isset($_GET['subscribe_user_filter_value']) && |
|
465 | + !empty($_GET['subscribe_user_filter_value']) && |
|
466 | + api_get_setting('ProfilingFilterAddingUsers') == 'true' |
|
467 | + ) { |
|
468 | + $field_identification = explode('*',$_GET['subscribe_user_filter_value']); |
|
469 | + $sql .= " |
|
470 | 470 | LEFT JOIN $table_user_field_values field_values |
471 | 471 | ON field_values.item_id = u.user_id |
472 | 472 | WHERE |
@@ -480,47 +480,47 @@ discard block |
||
480 | 480 | } |
481 | 481 | |
482 | 482 | $sql .= " AND access_url_id = $url_access_id"; |
483 | - } else { |
|
484 | - // adding a teacher NOT through a session |
|
485 | - $sql = "SELECT $select_fields |
|
483 | + } else { |
|
484 | + // adding a teacher NOT through a session |
|
485 | + $sql = "SELECT $select_fields |
|
486 | 486 | FROM $user_table u |
487 | 487 | LEFT JOIN $course_user_table cu |
488 | 488 | ON u.user_id = cu.user_id AND c_id = '".$courseId."'"; |
489 | 489 | |
490 | - // applying the filter of the additional user profile fields |
|
491 | - if (isset($_GET['subscribe_user_filter_value']) && |
|
492 | - !empty($_GET['subscribe_user_filter_value']) && |
|
493 | - api_get_setting('ProfilingFilterAddingUsers') == 'true' |
|
494 | - ) { |
|
495 | - $field_identification = explode('*',$_GET['subscribe_user_filter_value']); |
|
496 | - $sql .= " |
|
490 | + // applying the filter of the additional user profile fields |
|
491 | + if (isset($_GET['subscribe_user_filter_value']) && |
|
492 | + !empty($_GET['subscribe_user_filter_value']) && |
|
493 | + api_get_setting('ProfilingFilterAddingUsers') == 'true' |
|
494 | + ) { |
|
495 | + $field_identification = explode('*',$_GET['subscribe_user_filter_value']); |
|
496 | + $sql .= " |
|
497 | 497 | LEFT JOIN $table_user_field_values field_values |
498 | 498 | ON field_values.item_id = u.user_id |
499 | 499 | WHERE |
500 | 500 | cu.user_id IS NULL AND u.status<>".DRH." AND |
501 | 501 | field_values.field_id = '".intval($field_identification[0])."' AND |
502 | 502 | field_values.value = '".Database::escape_string($field_identification[1])."'"; |
503 | - } else { |
|
504 | - $sql .= "WHERE cu.user_id IS NULL AND u.status<>".DRH." "; |
|
505 | - } |
|
506 | - |
|
507 | - // adding a teacher NOT trough a session on a portal with multiple URLs |
|
508 | - if (api_is_multiple_url_enabled()) { |
|
509 | - if ($url_access_id !=-1) { |
|
510 | - $sql = "SELECT $select_fields |
|
503 | + } else { |
|
504 | + $sql .= "WHERE cu.user_id IS NULL AND u.status<>".DRH." "; |
|
505 | + } |
|
506 | + |
|
507 | + // adding a teacher NOT trough a session on a portal with multiple URLs |
|
508 | + if (api_is_multiple_url_enabled()) { |
|
509 | + if ($url_access_id !=-1) { |
|
510 | + $sql = "SELECT $select_fields |
|
511 | 511 | FROM $user_table u |
512 | 512 | LEFT JOIN $course_user_table cu |
513 | 513 | ON u.user_id = cu.user_id and c_id='".$courseId."' |
514 | 514 | INNER JOIN $tbl_url_rel_user as url_rel_user |
515 | 515 | ON (url_rel_user.user_id = u.user_id) "; |
516 | 516 | |
517 | - // applying the filter of the additional user profile fields |
|
518 | - if (isset($_GET['subscribe_user_filter_value']) && |
|
519 | - !empty($_GET['subscribe_user_filter_value']) && |
|
520 | - api_get_setting('ProfilingFilterAddingUsers') == 'true' |
|
521 | - ){ |
|
522 | - $field_identification = explode('*', $_GET['subscribe_user_filter_value']); |
|
523 | - $sql .= " |
|
517 | + // applying the filter of the additional user profile fields |
|
518 | + if (isset($_GET['subscribe_user_filter_value']) && |
|
519 | + !empty($_GET['subscribe_user_filter_value']) && |
|
520 | + api_get_setting('ProfilingFilterAddingUsers') == 'true' |
|
521 | + ){ |
|
522 | + $field_identification = explode('*', $_GET['subscribe_user_filter_value']); |
|
523 | + $sql .= " |
|
524 | 524 | LEFT JOIN $table_user_field_values field_values |
525 | 525 | ON field_values.item_id = u.user_id |
526 | 526 | WHERE |
@@ -528,16 +528,16 @@ discard block |
||
528 | 528 | u.status<>".DRH." AND |
529 | 529 | field_values.field_id = '".intval($field_identification[0])."' AND |
530 | 530 | field_values.value = '".Database::escape_string($field_identification[1])."'"; |
531 | - } else { |
|
532 | - $sql .= "WHERE cu.user_id IS NULL AND u.status<>".DRH." AND access_url_id= $url_access_id "; |
|
533 | - } |
|
534 | - } |
|
535 | - } |
|
536 | - } |
|
537 | - } else { |
|
538 | - // adding a student |
|
539 | - if (!empty($sessionId)) { |
|
540 | - $sql = "SELECT $select_fields |
|
531 | + } else { |
|
532 | + $sql .= "WHERE cu.user_id IS NULL AND u.status<>".DRH." AND access_url_id= $url_access_id "; |
|
533 | + } |
|
534 | + } |
|
535 | + } |
|
536 | + } |
|
537 | + } else { |
|
538 | + // adding a student |
|
539 | + if (!empty($sessionId)) { |
|
540 | + $sql = "SELECT $select_fields |
|
541 | 541 | FROM $user_table u |
542 | 542 | LEFT JOIN $tbl_session_rel_course_user cu |
543 | 543 | ON |
@@ -572,7 +572,7 @@ discard block |
||
572 | 572 | $sql .= "AND access_url_id = $url_access_id"; |
573 | 573 | } |
574 | 574 | |
575 | - } else { |
|
575 | + } else { |
|
576 | 576 | $sql = "SELECT $select_fields |
577 | 577 | FROM $user_table u |
578 | 578 | LEFT JOIN $course_user_table cu |
@@ -580,10 +580,10 @@ discard block |
||
580 | 580 | u.user_id = cu.user_id AND |
581 | 581 | c_id ='".$courseId."'"; |
582 | 582 | |
583 | - // applying the filter of the additional user profile fields |
|
584 | - if (isset($_GET['subscribe_user_filter_value']) && !empty($_GET['subscribe_user_filter_value'])) { |
|
585 | - $field_identification = explode('*',$_GET['subscribe_user_filter_value']); |
|
586 | - $sql .= " |
|
583 | + // applying the filter of the additional user profile fields |
|
584 | + if (isset($_GET['subscribe_user_filter_value']) && !empty($_GET['subscribe_user_filter_value'])) { |
|
585 | + $field_identification = explode('*',$_GET['subscribe_user_filter_value']); |
|
586 | + $sql .= " |
|
587 | 587 | LEFT JOIN $table_user_field_values field_values |
588 | 588 | ON field_values.item_id = u.user_id |
589 | 589 | WHERE |
@@ -591,28 +591,28 @@ discard block |
||
591 | 591 | u.status<>".DRH." AND |
592 | 592 | field_values.field_id = '".intval($field_identification[0])."' AND |
593 | 593 | field_values.value = '".Database::escape_string($field_identification[1])."'"; |
594 | - } else { |
|
595 | - $sql .= "WHERE cu.user_id IS NULL AND u.status<>".DRH." "; |
|
596 | - } |
|
594 | + } else { |
|
595 | + $sql .= "WHERE cu.user_id IS NULL AND u.status<>".DRH." "; |
|
596 | + } |
|
597 | 597 | |
598 | - //showing only the courses of the current Chamilo access_url_id |
|
598 | + //showing only the courses of the current Chamilo access_url_id |
|
599 | 599 | |
600 | - if (api_is_multiple_url_enabled()) { |
|
601 | - if ($url_access_id !=-1) { |
|
602 | - $sql = "SELECT $select_fields |
|
600 | + if (api_is_multiple_url_enabled()) { |
|
601 | + if ($url_access_id !=-1) { |
|
602 | + $sql = "SELECT $select_fields |
|
603 | 603 | FROM $user_table u |
604 | 604 | LEFT JOIN $course_user_table cu |
605 | 605 | ON u.user_id = cu.user_id AND c_id='".$courseId."' |
606 | 606 | INNER JOIN $tbl_url_rel_user as url_rel_user |
607 | 607 | ON (url_rel_user.user_id = u.user_id) "; |
608 | 608 | |
609 | - // applying the filter of the additional user profile fields |
|
610 | - if (isset($_GET['subscribe_user_filter_value']) && |
|
611 | - !empty($_GET['subscribe_user_filter_value']) && |
|
612 | - api_get_setting('ProfilingFilterAddingUsers') == 'true' |
|
613 | - ){ |
|
614 | - $field_identification = explode('*', $_GET['subscribe_user_filter_value']); |
|
615 | - $sql .= " |
|
609 | + // applying the filter of the additional user profile fields |
|
610 | + if (isset($_GET['subscribe_user_filter_value']) && |
|
611 | + !empty($_GET['subscribe_user_filter_value']) && |
|
612 | + api_get_setting('ProfilingFilterAddingUsers') == 'true' |
|
613 | + ){ |
|
614 | + $field_identification = explode('*', $_GET['subscribe_user_filter_value']); |
|
615 | + $sql .= " |
|
616 | 616 | LEFT JOIN $table_user_field_values field_values |
617 | 617 | ON field_values.item_id = u.user_id |
618 | 618 | WHERE |
@@ -622,18 +622,18 @@ discard block |
||
622 | 622 | field_values.value = '".Database::escape_string($field_identification[1])."' AND |
623 | 623 | access_url_id = $url_access_id |
624 | 624 | "; |
625 | - } else { |
|
626 | - $sql .= "WHERE cu.user_id IS NULL AND u.status<>".DRH." AND access_url_id= $url_access_id "; |
|
627 | - } |
|
628 | - } |
|
629 | - } |
|
630 | - } |
|
631 | - } |
|
632 | - |
|
633 | - // adding additional WHERE statements to the SQL for the search functionality |
|
634 | - if (isset($_REQUEST['keyword'])) { |
|
635 | - $keyword = Database::escape_string(trim($_REQUEST['keyword'])); |
|
636 | - $sql .= " AND ( |
|
625 | + } else { |
|
626 | + $sql .= "WHERE cu.user_id IS NULL AND u.status<>".DRH." AND access_url_id= $url_access_id "; |
|
627 | + } |
|
628 | + } |
|
629 | + } |
|
630 | + } |
|
631 | + } |
|
632 | + |
|
633 | + // adding additional WHERE statements to the SQL for the search functionality |
|
634 | + if (isset($_REQUEST['keyword'])) { |
|
635 | + $keyword = Database::escape_string(trim($_REQUEST['keyword'])); |
|
636 | + $sql .= " AND ( |
|
637 | 637 | firstname LIKE '%".$keyword."%' OR |
638 | 638 | lastname LIKE '%".$keyword."%' OR |
639 | 639 | email LIKE '%".$keyword."%' OR |
@@ -642,39 +642,39 @@ discard block |
||
642 | 642 | ) |
643 | 643 | "; |
644 | 644 | |
645 | - if (api_get_setting('ProfilingFilterAddingUsers') === 'true') { |
|
646 | - // we also want to search for users who have something in |
|
647 | - // their profile fields that matches the keyword |
|
648 | - $additional_users = search_additional_profile_fields($keyword); |
|
649 | - } |
|
650 | - |
|
651 | - // getting all the users of the course (to make sure that we do not |
|
652 | - // display users that are already in the course) |
|
653 | - if (!empty($sessionId)) { |
|
654 | - $a_course_users = CourseManager :: get_user_list_from_course_code($course_code, $sessionId); |
|
655 | - } else { |
|
656 | - $a_course_users = CourseManager :: get_user_list_from_course_code($course_code, 0); |
|
657 | - } |
|
658 | - foreach ($a_course_users as $user_id=>$course_user) { |
|
659 | - $users_of_course[] = $course_user['user_id']; |
|
660 | - } |
|
661 | - } |
|
662 | - |
|
663 | - $sql .=" AND u.status != ".ANONYMOUS." "; |
|
664 | - |
|
665 | - // Sorting and pagination (used by the sortable table) |
|
666 | - $sql .= " ORDER BY col$column $direction "; |
|
645 | + if (api_get_setting('ProfilingFilterAddingUsers') === 'true') { |
|
646 | + // we also want to search for users who have something in |
|
647 | + // their profile fields that matches the keyword |
|
648 | + $additional_users = search_additional_profile_fields($keyword); |
|
649 | + } |
|
650 | + |
|
651 | + // getting all the users of the course (to make sure that we do not |
|
652 | + // display users that are already in the course) |
|
653 | + if (!empty($sessionId)) { |
|
654 | + $a_course_users = CourseManager :: get_user_list_from_course_code($course_code, $sessionId); |
|
655 | + } else { |
|
656 | + $a_course_users = CourseManager :: get_user_list_from_course_code($course_code, 0); |
|
657 | + } |
|
658 | + foreach ($a_course_users as $user_id=>$course_user) { |
|
659 | + $users_of_course[] = $course_user['user_id']; |
|
660 | + } |
|
661 | + } |
|
662 | + |
|
663 | + $sql .=" AND u.status != ".ANONYMOUS." "; |
|
664 | + |
|
665 | + // Sorting and pagination (used by the sortable table) |
|
666 | + $sql .= " ORDER BY col$column $direction "; |
|
667 | 667 | $from = (int) $from; |
668 | 668 | $number_of_items = (int) $number_of_items; |
669 | - $sql .= " LIMIT $from, $number_of_items"; |
|
669 | + $sql .= " LIMIT $from, $number_of_items"; |
|
670 | 670 | |
671 | - $res = Database::query($sql); |
|
672 | - $users = array (); |
|
673 | - while ($user = Database::fetch_row($res)) { |
|
674 | - $users[] = $user; |
|
675 | - } |
|
671 | + $res = Database::query($sql); |
|
672 | + $users = array (); |
|
673 | + while ($user = Database::fetch_row($res)) { |
|
674 | + $users[] = $user; |
|
675 | + } |
|
676 | 676 | |
677 | - return $users; |
|
677 | + return $users; |
|
678 | 678 | } |
679 | 679 | /** |
680 | 680 | * Returns a mailto-link |
@@ -683,7 +683,7 @@ discard block |
||
683 | 683 | */ |
684 | 684 | function email_filter($email) |
685 | 685 | { |
686 | - return Display :: encrypted_mailto_link($email, $email); |
|
686 | + return Display :: encrypted_mailto_link($email, $email); |
|
687 | 687 | } |
688 | 688 | /** |
689 | 689 | * Build the reg-column of the table |
@@ -699,10 +699,10 @@ discard block |
||
699 | 699 | } |
700 | 700 | $user_id = (int) $user_id; |
701 | 701 | |
702 | - $result = '<a class="btn btn-small btn-primary" href="'.api_get_self().'?'.api_get_cidreq().'®ister=yes&type='.$type.'&user_id='.$user_id.'">'. |
|
702 | + $result = '<a class="btn btn-small btn-primary" href="'.api_get_self().'?'.api_get_cidreq().'®ister=yes&type='.$type.'&user_id='.$user_id.'">'. |
|
703 | 703 | get_lang("reg").'</a>'; |
704 | 704 | |
705 | - return $result; |
|
705 | + return $result; |
|
706 | 706 | } |
707 | 707 | |
708 | 708 | /** |
@@ -716,7 +716,7 @@ discard block |
||
716 | 716 | */ |
717 | 717 | function active_filter($active, $url_params, $row) |
718 | 718 | { |
719 | - $_user = api_get_user_info(); |
|
719 | + $_user = api_get_user_info(); |
|
720 | 720 | if ($active == '1') { |
721 | 721 | $action = 'AccountActive'; |
722 | 722 | $image = 'accept'; |
@@ -725,15 +725,15 @@ discard block |
||
725 | 725 | if ($active == '0') { |
726 | 726 | $action = 'AccountInactive'; |
727 | 727 | $image = 'error'; |
728 | - } |
|
728 | + } |
|
729 | 729 | $result = ''; |
730 | 730 | if ($row['0'] <> $_user['user_id']) { |
731 | - // you cannot lock yourself out otherwise you could disable all the accounts |
|
732 | - // including your own => everybody is locked out and nobody can change it anymore. |
|
733 | - $result = Display::return_icon($image.'.png', get_lang(ucfirst($action)), array() , ICON_SIZE_TINY); |
|
734 | - } |
|
731 | + // you cannot lock yourself out otherwise you could disable all the accounts |
|
732 | + // including your own => everybody is locked out and nobody can change it anymore. |
|
733 | + $result = Display::return_icon($image.'.png', get_lang(ucfirst($action)), array() , ICON_SIZE_TINY); |
|
734 | + } |
|
735 | 735 | |
736 | - return $result; |
|
736 | + return $result; |
|
737 | 737 | } |
738 | 738 | |
739 | 739 | /** |
@@ -751,30 +751,30 @@ discard block |
||
751 | 751 | */ |
752 | 752 | function search_additional_profile_fields($keyword) |
753 | 753 | { |
754 | - // database table definitions |
|
755 | - $table_user_field_options = Database :: get_main_table(TABLE_EXTRA_FIELD_OPTIONS); |
|
756 | - $table_user_field_values = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES); |
|
754 | + // database table definitions |
|
755 | + $table_user_field_options = Database :: get_main_table(TABLE_EXTRA_FIELD_OPTIONS); |
|
756 | + $table_user_field_values = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES); |
|
757 | 757 | $tableExtraField = Database::get_main_table(TABLE_EXTRA_FIELD); |
758 | - $table_user = Database::get_main_table(TABLE_MAIN_USER); |
|
758 | + $table_user = Database::get_main_table(TABLE_MAIN_USER); |
|
759 | 759 | |
760 | 760 | $keyword = Database::escape_string($keyword); |
761 | - // getting the field option text that match this keyword (for radio buttons and checkboxes) |
|
762 | - $sql = "SELECT * FROM $table_user_field_options |
|
761 | + // getting the field option text that match this keyword (for radio buttons and checkboxes) |
|
762 | + $sql = "SELECT * FROM $table_user_field_options |
|
763 | 763 | WHERE display_text LIKE '%".$keyword."%'"; |
764 | - $result_profiling = Database::query($sql); |
|
765 | - while ($profiling_field_options = Database::fetch_array($result_profiling)) { |
|
766 | - $profiling_field_options_exact_values[] = $profiling_field_options; |
|
767 | - } |
|
764 | + $result_profiling = Database::query($sql); |
|
765 | + while ($profiling_field_options = Database::fetch_array($result_profiling)) { |
|
766 | + $profiling_field_options_exact_values[] = $profiling_field_options; |
|
767 | + } |
|
768 | 768 | $profiling_field_options_exact_values_sql = ''; |
769 | - foreach ($profiling_field_options_exact_values as $profilingkey => $profilingvalue) { |
|
770 | - $profiling_field_options_exact_values_sql .= " OR (field_id = '".$profilingvalue['field_id']."' AND value='".$profilingvalue['option_value']."') "; |
|
771 | - } |
|
769 | + foreach ($profiling_field_options_exact_values as $profilingkey => $profilingvalue) { |
|
770 | + $profiling_field_options_exact_values_sql .= " OR (field_id = '".$profilingvalue['field_id']."' AND value='".$profilingvalue['option_value']."') "; |
|
771 | + } |
|
772 | 772 | |
773 | 773 | $extraFieldType = ExtraField::USER_FIELD_TYPE; |
774 | 774 | |
775 | - // getting all the user ids of the users who have chosen on of the predefined fields that contain the keyword |
|
776 | - // or all the users who have entered the keyword in a free-form field |
|
777 | - $sql = "SELECT |
|
775 | + // getting all the user ids of the users who have chosen on of the predefined fields that contain the keyword |
|
776 | + // or all the users who have entered the keyword in a free-form field |
|
777 | + $sql = "SELECT |
|
778 | 778 | user.user_id as col0, |
779 | 779 | user.official_code as col1, |
780 | 780 | user.lastname as col2, |
@@ -788,13 +788,13 @@ discard block |
||
788 | 788 | user_values.field_id = e.id AND |
789 | 789 | e.extra_field_type = $extraFieldType AND |
790 | 790 | (value LIKE '%".$keyword."%'".$profiling_field_options_exact_values_sql.")"; |
791 | - $result = Database::query($sql); |
|
791 | + $result = Database::query($sql); |
|
792 | 792 | $additional_users = array(); |
793 | - while ($profiled_users = Database::fetch_array($result)) { |
|
794 | - $additional_users[$profiled_users['col0']] = $profiled_users; |
|
795 | - } |
|
793 | + while ($profiled_users = Database::fetch_array($result)) { |
|
794 | + $additional_users[$profiled_users['col0']] = $profiled_users; |
|
795 | + } |
|
796 | 796 | |
797 | - return $additional_users; |
|
797 | + return $additional_users; |
|
798 | 798 | } |
799 | 799 | |
800 | 800 | /** |
@@ -806,44 +806,44 @@ discard block |
||
806 | 806 | */ |
807 | 807 | function display_extra_profile_fields_filter() |
808 | 808 | { |
809 | - // getting all the additional user profile fields |
|
809 | + // getting all the additional user profile fields |
|
810 | 810 | $extra = UserManager::get_extra_fields(0, 50, 5, 'ASC'); |
811 | - $return = '<option value="">'.get_lang('SelectFilter').'</option>'; |
|
812 | - |
|
813 | - // looping through the additional user profile fields |
|
814 | - foreach ($extra as $id => $field_details) { |
|
815 | - // $field_details[2] contains the type of the additional user profile field |
|
816 | - switch ($field_details[2]) { |
|
817 | - // text fields cannot be used as a filter |
|
818 | - case ExtraFieldModel::FIELD_TYPE_TEXT: |
|
819 | - break; |
|
820 | - // text area fields cannot be used as a filter |
|
821 | - case ExtraFieldModel::FIELD_TYPE_TEXTAREA: |
|
822 | - break; |
|
823 | - case ExtraFieldModel::FIELD_TYPE_RADIO: |
|
824 | - case ExtraFieldModel::FIELD_TYPE_SELECT: |
|
825 | - case ExtraFieldModel::FIELD_TYPE_SELECT_MULTIPLE: |
|
826 | - $return .= '<optgroup label="'.$field_details[3].'">'; |
|
827 | - foreach ($field_details[9] as $option_id => $option_details) { |
|
828 | - if (isset($_GET['subscribe_user_filter_value']) && |
|
811 | + $return = '<option value="">'.get_lang('SelectFilter').'</option>'; |
|
812 | + |
|
813 | + // looping through the additional user profile fields |
|
814 | + foreach ($extra as $id => $field_details) { |
|
815 | + // $field_details[2] contains the type of the additional user profile field |
|
816 | + switch ($field_details[2]) { |
|
817 | + // text fields cannot be used as a filter |
|
818 | + case ExtraFieldModel::FIELD_TYPE_TEXT: |
|
819 | + break; |
|
820 | + // text area fields cannot be used as a filter |
|
821 | + case ExtraFieldModel::FIELD_TYPE_TEXTAREA: |
|
822 | + break; |
|
823 | + case ExtraFieldModel::FIELD_TYPE_RADIO: |
|
824 | + case ExtraFieldModel::FIELD_TYPE_SELECT: |
|
825 | + case ExtraFieldModel::FIELD_TYPE_SELECT_MULTIPLE: |
|
826 | + $return .= '<optgroup label="'.$field_details[3].'">'; |
|
827 | + foreach ($field_details[9] as $option_id => $option_details) { |
|
828 | + if (isset($_GET['subscribe_user_filter_value']) && |
|
829 | 829 | $_GET['subscribe_user_filter_value'] == $field_details[0].'*'.$option_details[1] |
830 | 830 | ) { |
831 | - $selected = 'selected="selected"'; |
|
832 | - } else { |
|
833 | - $selected = false; |
|
834 | - } |
|
835 | - $return .= '<option value="'.$field_details[0].'*'.$option_details[1].'" '.$selected.'>'.$option_details[2].'</option>'; |
|
836 | - } |
|
837 | - $return .= '</optgroup>'; |
|
838 | - break; |
|
839 | - } |
|
840 | - } |
|
841 | - |
|
842 | - $html = '<form class="form-inline" id="subscribe_user_filter" name="subscribe_user_filter" method="get" action="'.api_get_self().'?'.api_get_cidreq().'">'; |
|
843 | - $html .= '<input type="hidden" name="type" id="type" value="'.Security::remove_XSS($_REQUEST['type']).'" />'; |
|
844 | - $html .= '<select name="subscribe_user_filter_value" id="subscribe_user_filter_value">'.$return.'</select>'; |
|
845 | - $html .= '<button type="submit" name="submit_filter" id="submit_filter" value="" class="search">'.get_lang('Filter').'</button>'; |
|
846 | - $html .= '</form>'; |
|
831 | + $selected = 'selected="selected"'; |
|
832 | + } else { |
|
833 | + $selected = false; |
|
834 | + } |
|
835 | + $return .= '<option value="'.$field_details[0].'*'.$option_details[1].'" '.$selected.'>'.$option_details[2].'</option>'; |
|
836 | + } |
|
837 | + $return .= '</optgroup>'; |
|
838 | + break; |
|
839 | + } |
|
840 | + } |
|
841 | + |
|
842 | + $html = '<form class="form-inline" id="subscribe_user_filter" name="subscribe_user_filter" method="get" action="'.api_get_self().'?'.api_get_cidreq().'">'; |
|
843 | + $html .= '<input type="hidden" name="type" id="type" value="'.Security::remove_XSS($_REQUEST['type']).'" />'; |
|
844 | + $html .= '<select name="subscribe_user_filter_value" id="subscribe_user_filter_value">'.$return.'</select>'; |
|
845 | + $html .= '<button type="submit" name="submit_filter" id="submit_filter" value="" class="search">'.get_lang('Filter').'</button>'; |
|
846 | + $html .= '</form>'; |
|
847 | 847 | |
848 | 848 | return $html; |
849 | 849 | } |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | */ |
12 | 12 | |
13 | 13 | require_once __DIR__.'/../inc/global.inc.php'; |
14 | -$current_course_tool = TOOL_USER; |
|
14 | +$current_course_tool = TOOL_USER; |
|
15 | 15 | |
16 | 16 | // the section (for the tabs) |
17 | 17 | $this_section = SECTION_COURSES; |
@@ -54,8 +54,8 @@ discard block |
||
54 | 54 | } |
55 | 55 | |
56 | 56 | $sessionId = api_get_session_id(); |
57 | -$list_register_user=''; |
|
58 | -$list_not_register_user=''; |
|
57 | +$list_register_user = ''; |
|
58 | +$list_not_register_user = ''; |
|
59 | 59 | |
60 | 60 | if (isset($_REQUEST['register'])) { |
61 | 61 | $userInfo = api_get_user_info($_REQUEST['user_id']); |
@@ -154,10 +154,10 @@ discard block |
||
154 | 154 | $table->set_column_filter($col - 1, 'email_filter'); |
155 | 155 | } |
156 | 156 | $table->set_header($col++, get_lang('Active'), false); |
157 | -$table->set_column_filter($col -1, 'active_filter'); |
|
157 | +$table->set_column_filter($col - 1, 'active_filter'); |
|
158 | 158 | $table->set_header($col++, get_lang('Actions'), false); |
159 | -$table->set_column_filter($col -1, 'reg_filter'); |
|
160 | -$table->set_form_actions(array ('subscribe' => get_lang('reg')), 'user'); |
|
159 | +$table->set_column_filter($col - 1, 'reg_filter'); |
|
160 | +$table->set_form_actions(array('subscribe' => get_lang('reg')), 'user'); |
|
161 | 161 | |
162 | 162 | if (!empty($_POST['keyword'])) { |
163 | 163 | $keyword_name = Security::remove_XSS($_POST['keyword']); |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | |
246 | 246 | if (api_is_multiple_url_enabled()) { |
247 | 247 | $url_access_id = api_get_current_access_url_id(); |
248 | - if ($url_access_id !=-1) { |
|
248 | + if ($url_access_id != -1) { |
|
249 | 249 | $tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
250 | 250 | $sql = "SELECT COUNT(u.id) |
251 | 251 | FROM $user_table u |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | |
273 | 273 | if (api_is_multiple_url_enabled()) { |
274 | 274 | $url_access_id = api_get_current_access_url_id(); |
275 | - if ($url_access_id !=-1) { |
|
275 | + if ($url_access_id != -1) { |
|
276 | 276 | $tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
277 | 277 | |
278 | 278 | $sql = "SELECT COUNT(u.id) |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | |
303 | 303 | if (api_is_multiple_url_enabled()) { |
304 | 304 | $url_access_id = api_get_current_access_url_id(); |
305 | - if ($url_access_id !=-1) { |
|
305 | + if ($url_access_id != -1) { |
|
306 | 306 | $tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
307 | 307 | $sql = "SELECT COUNT(u.id) |
308 | 308 | FROM $user_table u |
@@ -330,9 +330,9 @@ discard block |
||
330 | 330 | if (isset($_GET['subscribe_user_filter_value']) && |
331 | 331 | !empty($_GET['subscribe_user_filter_value']) && |
332 | 332 | api_get_setting('ProfilingFilterAddingUsers') === 'true' |
333 | - ){ |
|
334 | - $field_identification = explode('*',$_GET['subscribe_user_filter_value']); |
|
335 | - $sql .= " |
|
333 | + ) { |
|
334 | + $field_identification = explode('*', $_GET['subscribe_user_filter_value']); |
|
335 | + $sql .= " |
|
336 | 336 | LEFT JOIN $table_user_field_values field_values |
337 | 337 | ON field_values.item_id = u.user_id |
338 | 338 | WHERE |
@@ -341,14 +341,14 @@ discard block |
||
341 | 341 | field_values.field_id = '".intval($field_identification[0])."' AND |
342 | 342 | field_values.value = '".Database::escape_string($field_identification[1])."' |
343 | 343 | "; |
344 | - } else { |
|
345 | - $sql .= "WHERE cu.user_id IS NULL AND u.status <> ".DRH." "; |
|
344 | + } else { |
|
345 | + $sql .= "WHERE cu.user_id IS NULL AND u.status <> ".DRH." "; |
|
346 | 346 | } |
347 | 347 | |
348 | 348 | if (api_is_multiple_url_enabled()) { |
349 | 349 | $url_access_id = api_get_current_access_url_id(); |
350 | 350 | |
351 | - if ($url_access_id !=-1) { |
|
351 | + if ($url_access_id != -1) { |
|
352 | 352 | $tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
353 | 353 | $sql = "SELECT COUNT(u.id) |
354 | 354 | FROM $user_table u |
@@ -394,7 +394,7 @@ discard block |
||
394 | 394 | $users_of_course[] = $course_user['user_id']; |
395 | 395 | } |
396 | 396 | } |
397 | - $sql .=" AND u.status <> ".ANONYMOUS." "; |
|
397 | + $sql .= " AND u.status <> ".ANONYMOUS." "; |
|
398 | 398 | $res = Database::query($sql); |
399 | 399 | $count_user = 0; |
400 | 400 | |
@@ -465,8 +465,8 @@ discard block |
||
465 | 465 | !empty($_GET['subscribe_user_filter_value']) && |
466 | 466 | api_get_setting('ProfilingFilterAddingUsers') == 'true' |
467 | 467 | ) { |
468 | - $field_identification = explode('*',$_GET['subscribe_user_filter_value']); |
|
469 | - $sql .= " |
|
468 | + $field_identification = explode('*', $_GET['subscribe_user_filter_value']); |
|
469 | + $sql .= " |
|
470 | 470 | LEFT JOIN $table_user_field_values field_values |
471 | 471 | ON field_values.item_id = u.user_id |
472 | 472 | WHERE |
@@ -476,10 +476,10 @@ discard block |
||
476 | 476 | field_values.field_id = '".intval($field_identification[0])."' AND |
477 | 477 | field_values.value = '".Database::escape_string($field_identification[1])."'"; |
478 | 478 | } else { |
479 | - $sql .= "WHERE cu.user_id IS NULL AND u.status=1 AND (u.official_code <> 'ADMIN' OR u.official_code IS NULL) "; |
|
479 | + $sql .= "WHERE cu.user_id IS NULL AND u.status=1 AND (u.official_code <> 'ADMIN' OR u.official_code IS NULL) "; |
|
480 | 480 | } |
481 | 481 | |
482 | - $sql .= " AND access_url_id = $url_access_id"; |
|
482 | + $sql .= " AND access_url_id = $url_access_id"; |
|
483 | 483 | } else { |
484 | 484 | // adding a teacher NOT through a session |
485 | 485 | $sql = "SELECT $select_fields |
@@ -492,21 +492,21 @@ discard block |
||
492 | 492 | !empty($_GET['subscribe_user_filter_value']) && |
493 | 493 | api_get_setting('ProfilingFilterAddingUsers') == 'true' |
494 | 494 | ) { |
495 | - $field_identification = explode('*',$_GET['subscribe_user_filter_value']); |
|
496 | - $sql .= " |
|
495 | + $field_identification = explode('*', $_GET['subscribe_user_filter_value']); |
|
496 | + $sql .= " |
|
497 | 497 | LEFT JOIN $table_user_field_values field_values |
498 | 498 | ON field_values.item_id = u.user_id |
499 | 499 | WHERE |
500 | 500 | cu.user_id IS NULL AND u.status<>".DRH." AND |
501 | 501 | field_values.field_id = '".intval($field_identification[0])."' AND |
502 | 502 | field_values.value = '".Database::escape_string($field_identification[1])."'"; |
503 | - } else { |
|
504 | - $sql .= "WHERE cu.user_id IS NULL AND u.status<>".DRH." "; |
|
503 | + } else { |
|
504 | + $sql .= "WHERE cu.user_id IS NULL AND u.status<>".DRH." "; |
|
505 | 505 | } |
506 | 506 | |
507 | 507 | // adding a teacher NOT trough a session on a portal with multiple URLs |
508 | 508 | if (api_is_multiple_url_enabled()) { |
509 | - if ($url_access_id !=-1) { |
|
509 | + if ($url_access_id != -1) { |
|
510 | 510 | $sql = "SELECT $select_fields |
511 | 511 | FROM $user_table u |
512 | 512 | LEFT JOIN $course_user_table cu |
@@ -518,9 +518,9 @@ discard block |
||
518 | 518 | if (isset($_GET['subscribe_user_filter_value']) && |
519 | 519 | !empty($_GET['subscribe_user_filter_value']) && |
520 | 520 | api_get_setting('ProfilingFilterAddingUsers') == 'true' |
521 | - ){ |
|
521 | + ) { |
|
522 | 522 | $field_identification = explode('*', $_GET['subscribe_user_filter_value']); |
523 | - $sql .= " |
|
523 | + $sql .= " |
|
524 | 524 | LEFT JOIN $table_user_field_values field_values |
525 | 525 | ON field_values.item_id = u.user_id |
526 | 526 | WHERE |
@@ -528,8 +528,8 @@ discard block |
||
528 | 528 | u.status<>".DRH." AND |
529 | 529 | field_values.field_id = '".intval($field_identification[0])."' AND |
530 | 530 | field_values.value = '".Database::escape_string($field_identification[1])."'"; |
531 | - } else { |
|
532 | - $sql .= "WHERE cu.user_id IS NULL AND u.status<>".DRH." AND access_url_id= $url_access_id "; |
|
531 | + } else { |
|
532 | + $sql .= "WHERE cu.user_id IS NULL AND u.status<>".DRH." AND access_url_id= $url_access_id "; |
|
533 | 533 | } |
534 | 534 | } |
535 | 535 | } |
@@ -550,9 +550,9 @@ discard block |
||
550 | 550 | } |
551 | 551 | |
552 | 552 | // applying the filter of the additional user profile fields |
553 | - if (isset($_GET['subscribe_user_filter_value']) AND !empty($_GET['subscribe_user_filter_value'])){ |
|
554 | - $field_identification = explode('*',$_GET['subscribe_user_filter_value']); |
|
555 | - $sql .= " |
|
553 | + if (isset($_GET['subscribe_user_filter_value']) AND !empty($_GET['subscribe_user_filter_value'])) { |
|
554 | + $field_identification = explode('*', $_GET['subscribe_user_filter_value']); |
|
555 | + $sql .= " |
|
556 | 556 | LEFT JOIN $table_user_field_values field_values |
557 | 557 | ON field_values.item_id = u.user_id |
558 | 558 | WHERE |
@@ -561,15 +561,15 @@ discard block |
||
561 | 561 | (u.official_code <> 'ADMIN' OR u.official_code IS NULL) AND |
562 | 562 | field_values.field_id = '".intval($field_identification[0])."' AND |
563 | 563 | field_values.value = '".Database::escape_string($field_identification[1])."'"; |
564 | - } else { |
|
565 | - $sql .= "WHERE |
|
564 | + } else { |
|
565 | + $sql .= "WHERE |
|
566 | 566 | cu.user_id IS NULL AND |
567 | 567 | u.status<>".DRH." AND |
568 | 568 | (u.official_code <> 'ADMIN' OR u.official_code IS NULL) "; |
569 | 569 | } |
570 | 570 | |
571 | 571 | if (api_is_multiple_url_enabled()) { |
572 | - $sql .= "AND access_url_id = $url_access_id"; |
|
572 | + $sql .= "AND access_url_id = $url_access_id"; |
|
573 | 573 | } |
574 | 574 | |
575 | 575 | } else { |
@@ -582,8 +582,8 @@ discard block |
||
582 | 582 | |
583 | 583 | // applying the filter of the additional user profile fields |
584 | 584 | if (isset($_GET['subscribe_user_filter_value']) && !empty($_GET['subscribe_user_filter_value'])) { |
585 | - $field_identification = explode('*',$_GET['subscribe_user_filter_value']); |
|
586 | - $sql .= " |
|
585 | + $field_identification = explode('*', $_GET['subscribe_user_filter_value']); |
|
586 | + $sql .= " |
|
587 | 587 | LEFT JOIN $table_user_field_values field_values |
588 | 588 | ON field_values.item_id = u.user_id |
589 | 589 | WHERE |
@@ -591,14 +591,14 @@ discard block |
||
591 | 591 | u.status<>".DRH." AND |
592 | 592 | field_values.field_id = '".intval($field_identification[0])."' AND |
593 | 593 | field_values.value = '".Database::escape_string($field_identification[1])."'"; |
594 | - } else { |
|
595 | - $sql .= "WHERE cu.user_id IS NULL AND u.status<>".DRH." "; |
|
594 | + } else { |
|
595 | + $sql .= "WHERE cu.user_id IS NULL AND u.status<>".DRH." "; |
|
596 | 596 | } |
597 | 597 | |
598 | 598 | //showing only the courses of the current Chamilo access_url_id |
599 | 599 | |
600 | 600 | if (api_is_multiple_url_enabled()) { |
601 | - if ($url_access_id !=-1) { |
|
601 | + if ($url_access_id != -1) { |
|
602 | 602 | $sql = "SELECT $select_fields |
603 | 603 | FROM $user_table u |
604 | 604 | LEFT JOIN $course_user_table cu |
@@ -610,9 +610,9 @@ discard block |
||
610 | 610 | if (isset($_GET['subscribe_user_filter_value']) && |
611 | 611 | !empty($_GET['subscribe_user_filter_value']) && |
612 | 612 | api_get_setting('ProfilingFilterAddingUsers') == 'true' |
613 | - ){ |
|
613 | + ) { |
|
614 | 614 | $field_identification = explode('*', $_GET['subscribe_user_filter_value']); |
615 | - $sql .= " |
|
615 | + $sql .= " |
|
616 | 616 | LEFT JOIN $table_user_field_values field_values |
617 | 617 | ON field_values.item_id = u.user_id |
618 | 618 | WHERE |
@@ -622,8 +622,8 @@ discard block |
||
622 | 622 | field_values.value = '".Database::escape_string($field_identification[1])."' AND |
623 | 623 | access_url_id = $url_access_id |
624 | 624 | "; |
625 | - } else { |
|
626 | - $sql .= "WHERE cu.user_id IS NULL AND u.status<>".DRH." AND access_url_id= $url_access_id "; |
|
625 | + } else { |
|
626 | + $sql .= "WHERE cu.user_id IS NULL AND u.status<>".DRH." AND access_url_id= $url_access_id "; |
|
627 | 627 | } |
628 | 628 | } |
629 | 629 | } |
@@ -660,7 +660,7 @@ discard block |
||
660 | 660 | } |
661 | 661 | } |
662 | 662 | |
663 | - $sql .=" AND u.status != ".ANONYMOUS." "; |
|
663 | + $sql .= " AND u.status != ".ANONYMOUS." "; |
|
664 | 664 | |
665 | 665 | // Sorting and pagination (used by the sortable table) |
666 | 666 | $sql .= " ORDER BY col$column $direction "; |
@@ -669,7 +669,7 @@ discard block |
||
669 | 669 | $sql .= " LIMIT $from, $number_of_items"; |
670 | 670 | |
671 | 671 | $res = Database::query($sql); |
672 | - $users = array (); |
|
672 | + $users = array(); |
|
673 | 673 | while ($user = Database::fetch_row($res)) { |
674 | 674 | $users[] = $user; |
675 | 675 | } |
@@ -730,7 +730,7 @@ discard block |
||
730 | 730 | if ($row['0'] <> $_user['user_id']) { |
731 | 731 | // you cannot lock yourself out otherwise you could disable all the accounts |
732 | 732 | // including your own => everybody is locked out and nobody can change it anymore. |
733 | - $result = Display::return_icon($image.'.png', get_lang(ucfirst($action)), array() , ICON_SIZE_TINY); |
|
733 | + $result = Display::return_icon($image.'.png', get_lang(ucfirst($action)), array(), ICON_SIZE_TINY); |
|
734 | 734 | } |
735 | 735 | |
736 | 736 | return $result; |
@@ -735,7 +735,6 @@ |
||
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 |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | */ |
14 | 14 | $use_anonymous = true; |
15 | 15 | require_once __DIR__.'/../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 |
||
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 */ |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | '#', |
174 | 174 | get_lang('UserPicture'), |
175 | 175 | get_lang('OfficialCode'), |
176 | - get_lang('FirstName') . ', ' . get_lang('LastName'), |
|
176 | + get_lang('FirstName').', '.get_lang('LastName'), |
|
177 | 177 | get_lang('Email'), |
178 | 178 | get_lang('Phone') |
179 | 179 | ); |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | '#', |
183 | 183 | get_lang('UserPicture'), |
184 | 184 | get_lang('OfficialCode'), |
185 | - get_lang('LastName') . ', ' . get_lang('FirstName'), |
|
185 | + get_lang('LastName').', '.get_lang('FirstName'), |
|
186 | 186 | get_lang('Email'), |
187 | 187 | get_lang('Phone') |
188 | 188 | ); |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | if (api_is_multiple_url_enabled()) { |
208 | 208 | $sql .= ' , '.Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER).' au '; |
209 | 209 | } |
210 | - $sql .=" WHERE c_id = '$courseId' AND session_course_user.user_id = user.user_id "; |
|
210 | + $sql .= " WHERE c_id = '$courseId' AND session_course_user.user_id = user.user_id "; |
|
211 | 211 | $sql .= ' AND session_id = '.$sessionId; |
212 | 212 | |
213 | 213 | if (api_is_multiple_url_enabled()) { |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | $counter, |
256 | 256 | $user_image, |
257 | 257 | $user['official_code'], |
258 | - $user['firstname'] . ', ' . $user['lastname'], |
|
258 | + $user['firstname'].', '.$user['lastname'], |
|
259 | 259 | $user['email'], |
260 | 260 | $user['phone'] |
261 | 261 | ); |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | $counter, |
265 | 265 | $user_image, |
266 | 266 | $user['official_code'], |
267 | - $user['lastname'] . ', ' . $user['firstname'], |
|
267 | + $user['lastname'].', '.$user['firstname'], |
|
268 | 268 | $user['email'], |
269 | 269 | $user['phone'] |
270 | 270 | ); |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | $counter, |
344 | 344 | $user_image, |
345 | 345 | $user['official_code'], |
346 | - $user['firstname'] . ', ' . $user['lastname'], |
|
346 | + $user['firstname'].', '.$user['lastname'], |
|
347 | 347 | $user['email'], |
348 | 348 | $user['phone'] |
349 | 349 | ); |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | $counter, |
353 | 353 | $user_image, |
354 | 354 | $user['official_code'], |
355 | - $user['lastname'] . ', ' . $user['firstname'], |
|
355 | + $user['lastname'].', '.$user['firstname'], |
|
356 | 356 | $user['email'], |
357 | 357 | $user['phone'] |
358 | 358 | ); |
@@ -701,7 +701,7 @@ discard block |
||
701 | 701 | $userInfo = api_get_user_info($user_id); |
702 | 702 | $userPicture = $userInfo['avatar']; |
703 | 703 | |
704 | - $photo= '<img src="'.$userPicture.'" alt="'.$userInfo['complete_name'].'" width="22" height="22" title="'.$userInfo['complete_name'].'" />'; |
|
704 | + $photo = '<img src="'.$userPicture.'" alt="'.$userInfo['complete_name'].'" width="22" height="22" title="'.$userInfo['complete_name'].'" />'; |
|
705 | 705 | |
706 | 706 | $temp[] = $user_id; |
707 | 707 | $temp[] = $photo; |
@@ -824,7 +824,7 @@ discard block |
||
824 | 824 | if (api_get_setting('allow_user_course_subscription_by_course_admin') === 'true' or api_is_platform_admin()) { |
825 | 825 | // unregister |
826 | 826 | if ($user_id != $current_user_id || api_is_platform_admin()) { |
827 | - $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;">'. |
|
827 | + $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;">'. |
|
828 | 828 | get_lang('Unreg').'</a> '; |
829 | 829 | } else { |
830 | 830 | //$result .= Display::return_icon('unsubscribe_course_na.png', get_lang('Unreg'),'',ICON_SIZE_SMALL).'</a> '; |
@@ -834,7 +834,7 @@ discard block |
||
834 | 834 | // Show buttons for unsubscribe |
835 | 835 | if ($course_info['unsubscribe'] == 1) { |
836 | 836 | if ($user_id == $current_user_id) { |
837 | - $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;">'. |
|
837 | + $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;">'. |
|
838 | 838 | get_lang('Unreg').'</a> '; |
839 | 839 | } |
840 | 840 | } |
@@ -914,7 +914,7 @@ discard block |
||
914 | 914 | |
915 | 915 | // Actions column |
916 | 916 | $table->set_header($header_nr++, get_lang('Action'), false); |
917 | - $table->set_column_filter($header_nr-1, 'modify_filter'); |
|
917 | + $table->set_column_filter($header_nr - 1, 'modify_filter'); |
|
918 | 918 | |
919 | 919 | if (api_get_setting('allow_user_course_subscription_by_course_admin') == 'true') { |
920 | 920 | $table->set_form_actions(array('unsubscribe' => get_lang('Unreg')), 'user'); |
@@ -922,7 +922,7 @@ discard block |
||
922 | 922 | } else { |
923 | 923 | if ($course_info['unsubscribe'] == 1) { |
924 | 924 | $table->set_header($header_nr++, get_lang('Action'), false); |
925 | - $table->set_column_filter($header_nr-1, 'modify_filter'); |
|
925 | + $table->set_column_filter($header_nr - 1, 'modify_filter'); |
|
926 | 926 | } |
927 | 927 | } |
928 | 928 | |
@@ -978,19 +978,19 @@ discard block |
||
978 | 978 | echo '<div class="col-md-6">'; |
979 | 979 | echo $icon; |
980 | 980 | $actions .= '<a href="user.php?'.api_get_cidreq().'&action=export&format=csv&type='.$type.'">'. |
981 | - Display::return_icon('export_csv.png', get_lang('ExportAsCSV'),'',ICON_SIZE_MEDIUM).'</a> '; |
|
981 | + Display::return_icon('export_csv.png', get_lang('ExportAsCSV'), '', ICON_SIZE_MEDIUM).'</a> '; |
|
982 | 982 | $actions .= '<a href="user.php?'.api_get_cidreq().'&action=export&format=xls&type='.$type.'">'. |
983 | - Display::return_icon('export_excel.png', get_lang('ExportAsXLS'),'',ICON_SIZE_MEDIUM).'</a> '; |
|
983 | + Display::return_icon('export_excel.png', get_lang('ExportAsXLS'), '', ICON_SIZE_MEDIUM).'</a> '; |
|
984 | 984 | |
985 | 985 | if (api_get_setting('allow_user_course_subscription_by_course_admin') == 'true' || |
986 | 986 | api_is_platform_admin() |
987 | 987 | ) { |
988 | 988 | $actions .= '<a href="user_import.php?'.api_get_cidreq().'&action=import">'. |
989 | - Display::return_icon('import_csv.png', get_lang('ImportUsersToACourse'),'',ICON_SIZE_MEDIUM).'</a> '; |
|
989 | + Display::return_icon('import_csv.png', get_lang('ImportUsersToACourse'), '', ICON_SIZE_MEDIUM).'</a> '; |
|
990 | 990 | } |
991 | 991 | |
992 | 992 | $actions .= '<a href="user.php?'.api_get_cidreq().'&action=export&format=pdf&type='.$type.'">'. |
993 | - Display::return_icon('pdf.png', get_lang('ExportToPDF'),'',ICON_SIZE_MEDIUM).'</a> '; |
|
993 | + Display::return_icon('pdf.png', get_lang('ExportToPDF'), '', ICON_SIZE_MEDIUM).'</a> '; |
|
994 | 994 | echo $actions; |
995 | 995 | |
996 | 996 | echo '</div>'; |
@@ -17,6 +17,9 @@ |
||
17 | 17 | define('WS_ERROR_INVALID_INPUT', 3); |
18 | 18 | define('WS_ERROR_SETTING', 4); |
19 | 19 | |
20 | +/** |
|
21 | + * @param integer $code |
|
22 | + */ |
|
20 | 23 | function return_error($code) { |
21 | 24 | $fault = null; |
22 | 25 | switch ($code) { |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | } |
76 | 76 | |
77 | 77 | if ($debug) { |
78 | - error_log("checkip " . intval($check_ip)); |
|
78 | + error_log("checkip ".intval($check_ip)); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | if ($check_ip) { |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | '', |
132 | 132 | 'SOAP-ENC:Array', |
133 | 133 | array(), |
134 | - array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType' => 'tns:portalItem[]')),'tns:portalItem' |
|
134 | + array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:portalItem[]')), 'tns:portalItem' |
|
135 | 135 | ); |
136 | 136 | |
137 | 137 | $server->wsdl->addComplexType( |
@@ -146,13 +146,13 @@ discard block |
||
146 | 146 | ); |
147 | 147 | |
148 | 148 | // Register the method to expose |
149 | -$server->register('WSGetPortals', // method name |
|
150 | - array('getPortals' => 'tns:getPortals'), // input parameters |
|
151 | - array('return' => 'tns:portalList'), // output parameters |
|
152 | - 'urn:WSAccessUrl', // namespace |
|
153 | - 'urn:WSAccessUrl#WSGetPortals', // soapaction |
|
154 | - 'rpc', // style |
|
155 | - 'encoded', // use |
|
149 | +$server->register('WSGetPortals', // method name |
|
150 | + array('getPortals' => 'tns:getPortals'), // input parameters |
|
151 | + array('return' => 'tns:portalList'), // output parameters |
|
152 | + 'urn:WSAccessUrl', // namespace |
|
153 | + 'urn:WSAccessUrl#WSGetPortals', // soapaction |
|
154 | + 'rpc', // style |
|
155 | + 'encoded', // use |
|
156 | 156 | 'This service adds a user to portal' // documentation |
157 | 157 | ); |
158 | 158 | |
@@ -193,13 +193,13 @@ discard block |
||
193 | 193 | ); |
194 | 194 | |
195 | 195 | // Register the method to expose |
196 | -$server->register('WSAddUserToPortal', // method name |
|
197 | - array('addUserToPortal' => 'tns:AddUserToPortal'), // input parameters |
|
198 | - array('return' => 'xsd:string'), // output parameters |
|
199 | - 'urn:WSAccessUrl', // namespace |
|
200 | - 'urn:WSAccessUrl#WSAddUserToPortal', // soapaction |
|
201 | - 'rpc', // style |
|
202 | - 'encoded', // use |
|
196 | +$server->register('WSAddUserToPortal', // method name |
|
197 | + array('addUserToPortal' => 'tns:AddUserToPortal'), // input parameters |
|
198 | + array('return' => 'xsd:string'), // output parameters |
|
199 | + 'urn:WSAccessUrl', // namespace |
|
200 | + 'urn:WSAccessUrl#WSAddUserToPortal', // soapaction |
|
201 | + 'rpc', // style |
|
202 | + 'encoded', // use |
|
203 | 203 | 'This service adds a user to portal' // documentation |
204 | 204 | ); |
205 | 205 | |
@@ -224,13 +224,13 @@ discard block |
||
224 | 224 | } |
225 | 225 | |
226 | 226 | // Register the method to expose |
227 | -$server->register('WSRemoveUserFromPortal', // method name |
|
228 | - array('removeUserFromPortal' => 'tns:AddUserToPortal'), // input parameters |
|
229 | - array('return' => 'xsd:string'), // output parameters |
|
230 | - 'urn:WSAccessUrl', // namespace |
|
231 | - 'urn:WSAccessUrl#WSRemoveUserFromPortal', // soapaction |
|
232 | - 'rpc', // style |
|
233 | - 'encoded', // use |
|
227 | +$server->register('WSRemoveUserFromPortal', // method name |
|
228 | + array('removeUserFromPortal' => 'tns:AddUserToPortal'), // input parameters |
|
229 | + array('return' => 'xsd:string'), // output parameters |
|
230 | + 'urn:WSAccessUrl', // namespace |
|
231 | + 'urn:WSAccessUrl#WSRemoveUserFromPortal', // soapaction |
|
232 | + 'rpc', // style |
|
233 | + 'encoded', // use |
|
234 | 234 | 'This service remove a user from a portal' // documentation |
235 | 235 | ); |
236 | 236 | |
@@ -267,13 +267,13 @@ discard block |
||
267 | 267 | ); |
268 | 268 | |
269 | 269 | // Register the method to expose |
270 | -$server->register('WSGetPortalListFromUser', // method name |
|
271 | - array('getPortalListFromUser' => 'tns:getPortalListFromUser'), // input parameters |
|
272 | - array('return' => 'tns:portalList'), // output parameters |
|
273 | - 'urn:WSAccessUrl', // namespace |
|
274 | - 'urn:WSAccessUrl#WSGetPortalListFromUser', // soapaction |
|
275 | - 'rpc', // style |
|
276 | - 'encoded', // use |
|
270 | +$server->register('WSGetPortalListFromUser', // method name |
|
271 | + array('getPortalListFromUser' => 'tns:getPortalListFromUser'), // input parameters |
|
272 | + array('return' => 'tns:portalList'), // output parameters |
|
273 | + 'urn:WSAccessUrl', // namespace |
|
274 | + 'urn:WSAccessUrl#WSGetPortalListFromUser', // soapaction |
|
275 | + 'rpc', // style |
|
276 | + 'encoded', // use |
|
277 | 277 | 'This service remove a user from a portal' // documentation |
278 | 278 | ); |
279 | 279 | |
@@ -311,13 +311,13 @@ discard block |
||
311 | 311 | ); |
312 | 312 | |
313 | 313 | // Register the method to expose |
314 | -$server->register('WSGetPortalListFromCourse', // method name |
|
315 | - array('getPortalListFromCourse' => 'tns:getPortalListFromCourse'), // input parameters |
|
316 | - array('return' => 'tns:portalList'), // output parameters |
|
317 | - 'urn:WSAccessUrl', // namespace |
|
318 | - 'urn:WSAccessUrl#getPortalListFromCourse', // soapaction |
|
319 | - 'rpc', // style |
|
320 | - 'encoded', // use |
|
314 | +$server->register('WSGetPortalListFromCourse', // method name |
|
315 | + array('getPortalListFromCourse' => 'tns:getPortalListFromCourse'), // input parameters |
|
316 | + array('return' => 'tns:portalList'), // output parameters |
|
317 | + 'urn:WSAccessUrl', // namespace |
|
318 | + 'urn:WSAccessUrl#getPortalListFromCourse', // soapaction |
|
319 | + 'rpc', // style |
|
320 | + 'encoded', // use |
|
321 | 321 | 'This service remove a user from a portal' // documentation |
322 | 322 | ); |
323 | 323 | |
@@ -361,13 +361,13 @@ discard block |
||
361 | 361 | ); |
362 | 362 | |
363 | 363 | // Register the method to expose |
364 | -$server->register('WSAddCourseToPortal', // method name |
|
365 | - array('addCourseToPortal' => 'tns:addCourseToPortal'), // input parameters |
|
366 | - array('return' => 'xsd:string'), // output parameters |
|
367 | - 'urn:WSAccessUrl', // namespace |
|
368 | - 'urn:WSAccessUrl#WSAddCourseToPortal', // soapaction |
|
369 | - 'rpc', // style |
|
370 | - 'encoded', // use |
|
364 | +$server->register('WSAddCourseToPortal', // method name |
|
365 | + array('addCourseToPortal' => 'tns:addCourseToPortal'), // input parameters |
|
366 | + array('return' => 'xsd:string'), // output parameters |
|
367 | + 'urn:WSAccessUrl', // namespace |
|
368 | + 'urn:WSAccessUrl#WSAddCourseToPortal', // soapaction |
|
369 | + 'rpc', // style |
|
370 | + 'encoded', // use |
|
371 | 371 | 'This service adds a course to portal' // documentation |
372 | 372 | ); |
373 | 373 | |
@@ -394,13 +394,13 @@ discard block |
||
394 | 394 | } |
395 | 395 | |
396 | 396 | // Register the method to expose |
397 | -$server->register('WSRemoveCourseFromPortal', // method name |
|
398 | - array('removeCourseFromPortal' => 'tns:addCourseToPortal'), // input parameters |
|
399 | - array('return' => 'xsd:string'), // output parameters |
|
400 | - 'urn:WSAccessUrl', // namespace |
|
401 | - 'urn:WSAccessUrl#WSRemoveCourseFromPortal', // soapaction |
|
402 | - 'rpc', // style |
|
403 | - 'encoded', // use |
|
397 | +$server->register('WSRemoveCourseFromPortal', // method name |
|
398 | + array('removeCourseFromPortal' => 'tns:addCourseToPortal'), // input parameters |
|
399 | + array('return' => 'xsd:string'), // output parameters |
|
400 | + 'urn:WSAccessUrl', // namespace |
|
401 | + 'urn:WSAccessUrl#WSRemoveCourseFromPortal', // soapaction |
|
402 | + 'rpc', // style |
|
403 | + 'encoded', // use |
|
404 | 404 | 'This service remove a course from a portal' // documentation |
405 | 405 | ); |
406 | 406 |
@@ -58,19 +58,22 @@ discard block |
||
58 | 58 | list($ip1, $ip2) = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']); |
59 | 59 | $ip = trim($ip1); |
60 | 60 | } |
61 | - if ($debug) |
|
62 | - error_log("ip: $ip"); |
|
61 | + if ($debug) { |
|
62 | + error_log("ip: $ip"); |
|
63 | + } |
|
63 | 64 | // Check if a file that limits access from webservices exists and contains |
64 | 65 | // the restraining check |
65 | 66 | if (is_file('webservice-auth-ip.conf.php')) { |
66 | 67 | include 'webservice-auth-ip.conf.php'; |
67 | - if ($debug) |
|
68 | - error_log("webservice-auth-ip.conf.php file included"); |
|
68 | + if ($debug) { |
|
69 | + error_log("webservice-auth-ip.conf.php file included"); |
|
70 | + } |
|
69 | 71 | if (!empty($ws_auth_ip)) { |
70 | 72 | $check_ip = true; |
71 | 73 | $ip_matches = api_check_ip_in_range($ip, $ws_auth_ip); |
72 | - if ($debug) |
|
73 | - error_log("ip_matches: $ip_matches"); |
|
74 | + if ($debug) { |
|
75 | + error_log("ip_matches: $ip_matches"); |
|
76 | + } |
|
74 | 77 | } |
75 | 78 | } |
76 | 79 | |
@@ -87,8 +90,9 @@ discard block |
||
87 | 90 | |
88 | 91 | $result = api_is_valid_secret_key($secret_key, $security_key); |
89 | 92 | //error_log($secret_key.'-'.$security_key); |
90 | - if ($debug) |
|
91 | - error_log('WSHelperVerifyKey result: '.intval($result)); |
|
93 | + if ($debug) { |
|
94 | + error_log('WSHelperVerifyKey result: '.intval($result)); |
|
95 | + } |
|
92 | 96 | return $result; |
93 | 97 | } |
94 | 98 |