@@ -124,7 +124,7 @@ |
||
124 | 124 | } |
125 | 125 | |
126 | 126 | /** |
127 | - * @param $variable |
|
127 | + * @param string $variable |
|
128 | 128 | * @return mixed |
129 | 129 | */ |
130 | 130 | public function getConfigurationValue($variable) |
@@ -204,7 +204,6 @@ discard block |
||
204 | 204 | * lock = the user can no longer use this account |
205 | 205 | * @author Patrick Cool <[email protected]>, Ghent University |
206 | 206 | * @param int $active the current state of the account |
207 | - * @param int $user_id The user id |
|
208 | 207 | * @param string $url_params |
209 | 208 | * @return string Some HTML-code with the lock/unlock button |
210 | 209 | */ |
@@ -236,7 +235,7 @@ discard block |
||
236 | 235 | * @author Patrick Cool <[email protected]>, Ghent University |
237 | 236 | * @param int $status, do we want to lock the user ($status=lock) or unlock it ($status=unlock) |
238 | 237 | * @param int $user_id The user id |
239 | - * @return language variable |
|
238 | + * @return string|null variable |
|
240 | 239 | */ |
241 | 240 | function lock_unlock_user($status, $user_id) { |
242 | 241 | $user_table = Database :: get_main_table(TABLE_MAIN_USER); |
@@ -117,14 +117,12 @@ |
||
117 | 117 | // Loops while the current group is a subgroup |
118 | 118 | while (isset($groupRelations[$id]['group_id'])) { |
119 | 119 | $name = $name ? |
120 | - $groupRelations[$id]['name'] . " > " . $name : |
|
121 | - $groupRelations[$id]['name']; |
|
120 | + $groupRelations[$id]['name']." > ".$name : $groupRelations[$id]['name']; |
|
122 | 121 | $id = $groupRelations[$id]['group_id']; |
123 | 122 | } |
124 | 123 | // The base group |
125 | 124 | $name = $name ? |
126 | - $groupRelations[$id]['name'] . " > " . $name : |
|
127 | - $groupRelations[$id]['name']; |
|
125 | + $groupRelations[$id]['name']." > ".$name : $groupRelations[$id]['name']; |
|
128 | 126 | $group[3] = $status[$group[3]]; |
129 | 127 | $group['1'] = '<a href="'.api_get_path(WEB_CODE_PATH).'social/group_view.php?id='.$group['0'].'">'.$name.'</a>'; |
130 | 128 | $groups[] = $group; |
@@ -412,8 +412,9 @@ |
||
412 | 412 | //$table->set_column_filter(6, 'status_filter'); |
413 | 413 | //$table->set_column_filter(7, 'active_filter'); |
414 | 414 | //$table->set_column_filter(8, 'modify_filter'); |
415 | - if (api_is_platform_admin()) |
|
416 | - $table->set_form_actions(array('delete' => get_lang('DeleteFromPlatform'))); |
|
415 | + if (api_is_platform_admin()) { |
|
416 | + $table->set_form_actions(array('delete' => get_lang('DeleteFromPlatform'))); |
|
417 | + } |
|
417 | 418 | $table->display(); |
418 | 419 | } |
419 | 420 | Display :: display_footer(); |
@@ -16,7 +16,6 @@ |
||
16 | 16 | * @author Patrick Cool |
17 | 17 | * @author René Haentjens, added CSV file import (October 2004) |
18 | 18 | * @package chamilo.link |
19 | - |
|
20 | 19 | */ |
21 | 20 | |
22 | 21 | // Including libraries |
@@ -907,7 +907,7 @@ discard block |
||
907 | 907 | * display the edit and delete icons in the sortable table |
908 | 908 | * |
909 | 909 | * @param integer $id the id of the template |
910 | - * @return html code for the link to edit and delete the template |
|
910 | + * @return string code for the link to edit and delete the template |
|
911 | 911 | * |
912 | 912 | * @author Patrick Cool <[email protected]>, Ghent University, Belgium |
913 | 913 | * @version August 2008 |
@@ -923,7 +923,7 @@ discard block |
||
923 | 923 | * Display the image of the template in the sortable table |
924 | 924 | * |
925 | 925 | * @param string $image the image |
926 | - * @return html code for the image |
|
926 | + * @return string code for the image |
|
927 | 927 | * |
928 | 928 | * @author Patrick Cool <[email protected]>, Ghent University, Belgium |
929 | 929 | * @version August 2008 |
@@ -1120,7 +1120,7 @@ discard block |
||
1120 | 1120 | /** |
1121 | 1121 | * Returns an array containing the list of options used to populate the gradebook_number_decimals variable |
1122 | 1122 | * This function is called through a call_user_func() in the generate_settings_form function. |
1123 | - * @return array List of gradebook_number_decimals options |
|
1123 | + * @return string[] List of gradebook_number_decimals options |
|
1124 | 1124 | * |
1125 | 1125 | * @author Guillaume Viguier <[email protected]> |
1126 | 1126 | */ |
@@ -471,8 +471,9 @@ discard block |
||
471 | 471 | $extraction_path = $cssToUpload.$style_name.'/'; |
472 | 472 | for ($i = 0; $i < $num_files; $i++) { |
473 | 473 | $entry = $zip->getNameIndex($i); |
474 | - if (substr($entry, -1) == '/') |
|
475 | - continue; |
|
474 | + if (substr($entry, -1) == '/') { |
|
475 | + continue; |
|
476 | + } |
|
476 | 477 | |
477 | 478 | $pos_slash = strpos($entry, '/'); |
478 | 479 | $entry_without_first_dir = substr($entry, $pos_slash + 1); |
@@ -1231,17 +1232,21 @@ discard block |
||
1231 | 1232 | $hideme = array('disabled'); |
1232 | 1233 | } elseif ($url_info['active'] == 1) { |
1233 | 1234 | // We show the elements. |
1234 | - if (empty($row['variable'])) |
|
1235 | - $row['variable'] = 0; |
|
1236 | - if (empty($row['subkey'])) |
|
1237 | - $row['subkey'] = 0; |
|
1238 | - if (empty($row['category'])) |
|
1239 | - $row['category'] = 0; |
|
1235 | + if (empty($row['variable'])) { |
|
1236 | + $row['variable'] = 0; |
|
1237 | + } |
|
1238 | + if (empty($row['subkey'])) { |
|
1239 | + $row['subkey'] = 0; |
|
1240 | + } |
|
1241 | + if (empty($row['category'])) { |
|
1242 | + $row['category'] = 0; |
|
1243 | + } |
|
1240 | 1244 | |
1241 | 1245 | if (is_array($settings_by_access_list[ $row['variable'] ] [ $row['subkey'] ] [ $row['category'] ])) { |
1242 | 1246 | // We are sure that the other site have a selected value. |
1243 | - if ($settings_by_access_list[ $row['variable'] ] [ $row['subkey'] ] [ $row['category'] ]['selected_value'] != '') |
|
1244 | - $row['selected_value'] = $settings_by_access_list[$row['variable']] [$row['subkey']] [$row['category']]['selected_value']; |
|
1247 | + if ($settings_by_access_list[ $row['variable'] ] [ $row['subkey'] ] [ $row['category'] ]['selected_value'] != '') { |
|
1248 | + $row['selected_value'] = $settings_by_access_list[$row['variable']] [$row['subkey']] [$row['category']]['selected_value']; |
|
1249 | + } |
|
1245 | 1250 | } |
1246 | 1251 | // There is no else{} statement because we load the default $row['selected_value'] of the main Chamilo site. |
1247 | 1252 | } |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | |
130 | 130 | //Plugins NOT installed |
131 | 131 | echo Display::page_subheader(get_lang('Plugins')); |
132 | - echo '<form class="form-horizontal" name="plugins" method="post" action="'.api_get_self().'?category='.Security::remove_XSS($_GET['category']).'&sec_token=' . $token . '">'; |
|
132 | + echo '<form class="form-horizontal" name="plugins" method="post" action="'.api_get_self().'?category='.Security::remove_XSS($_GET['category']).'&sec_token='.$token.'">'; |
|
133 | 133 | echo '<table class="data_table">'; |
134 | 134 | echo '<tr>'; |
135 | 135 | echo '<th width="20px">'; |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | |
142 | 142 | $plugin_list = array(); |
143 | 143 | $my_plugin_list = $plugin_obj->get_plugin_regions(); |
144 | - foreach($my_plugin_list as $plugin_item) { |
|
144 | + foreach ($my_plugin_list as $plugin_item) { |
|
145 | 145 | $plugin_list[$plugin_item] = $plugin_item; |
146 | 146 | } |
147 | 147 | |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | if (file_exists(api_get_path(SYS_PLUGIN_PATH).$plugin.'/readme.txt')) { |
181 | 181 | echo Display::url( |
182 | 182 | "<em class='fa fa-file-text-o'></em> readme.txt", |
183 | - api_get_path(WEB_PLUGIN_PATH) . $plugin . "/readme.txt", |
|
183 | + api_get_path(WEB_PLUGIN_PATH).$plugin."/readme.txt", |
|
184 | 184 | [ |
185 | 185 | 'class' => 'btn btn-default ajax', |
186 | 186 | 'data-title' => $plugin_info['title'], |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | $show_name = ucwords(str_replace('_', ' ', $style_dir)); |
323 | 323 | |
324 | 324 | if ($is_style_changeable) { |
325 | - $list_of_names[$style_dir] = $show_name; |
|
325 | + $list_of_names[$style_dir] = $show_name; |
|
326 | 326 | } |
327 | 327 | $counter++; |
328 | 328 | } |
@@ -353,9 +353,9 @@ discard block |
||
353 | 353 | if (is_dir($dir)) { |
354 | 354 | $zip = new PclZip($arch); |
355 | 355 | // Remove path prefix except the style name and put file on disk |
356 | - $zip->create($dir, PCLZIP_OPT_REMOVE_PATH, substr($dir,0,-strlen($safe_style_dir))); |
|
356 | + $zip->create($dir, PCLZIP_OPT_REMOVE_PATH, substr($dir, 0, -strlen($safe_style_dir))); |
|
357 | 357 | //@TODO: use more generic script to download. |
358 | - $str = '<a class="btn btn-primary btn-large" href="' . api_get_path(WEB_CODE_PATH) . 'course_info/download.php?archive=' . str_replace(api_get_path(SYS_ARCHIVE_PATH), '', $arch) . '">'.get_lang('ClickHereToDownloadTheFile').'</a>'; |
|
358 | + $str = '<a class="btn btn-primary btn-large" href="'.api_get_path(WEB_CODE_PATH).'course_info/download.php?archive='.str_replace(api_get_path(SYS_ARCHIVE_PATH), '', $arch).'">'.get_lang('ClickHereToDownloadTheFile').'</a>'; |
|
359 | 359 | Display::display_normal_message($str, false); |
360 | 360 | } else { |
361 | 361 | Display::addFlash(Display::return_message(get_lang('FileNotFound'), 'warning')); |
@@ -543,7 +543,7 @@ discard block |
||
543 | 543 | if (!empty($areas_to_installed)) { |
544 | 544 | $plugin_obj->remove_all_regions($plugin); |
545 | 545 | foreach ($areas_to_installed as $region) { |
546 | - if (!empty($region) && $region != '-1' ) { |
|
546 | + if (!empty($region) && $region != '-1') { |
|
547 | 547 | $plugin_obj->add_to_region($plugin, $region); |
548 | 548 | } |
549 | 549 | } |
@@ -635,7 +635,7 @@ discard block |
||
635 | 635 | $values = api_get_settings_options('search_enabled'); |
636 | 636 | $form->addElement('header', null, get_lang('SearchEnabledTitle')); |
637 | 637 | |
638 | - $group = array (); |
|
638 | + $group = array(); |
|
639 | 639 | if (is_array($values)) { |
640 | 640 | foreach ($values as $key => $value) { |
641 | 641 | $element = & $form->createElement('radio', 'search_enabled', '', get_lang($value['display_text']), $value['value']); |
@@ -661,12 +661,12 @@ discard block |
||
661 | 661 | |
662 | 662 | if ($search_enabled == 'true') { |
663 | 663 | $values = api_get_settings_options('search_show_unlinked_results'); |
664 | - $group = array (); |
|
664 | + $group = array(); |
|
665 | 665 | foreach ($values as $key => $value) { |
666 | 666 | $element = & $form->createElement('radio', 'search_show_unlinked_results', '', get_lang($value['display_text']), $value['value']); |
667 | 667 | $group[] = $element; |
668 | 668 | } |
669 | - $form->addGroup($group, 'search_show_unlinked_results', array(get_lang('SearchShowUnlinkedResultsTitle'),get_lang('SearchShowUnlinkedResultsComment')), '', false); |
|
669 | + $form->addGroup($group, 'search_show_unlinked_results', array(get_lang('SearchShowUnlinkedResultsTitle'), get_lang('SearchShowUnlinkedResultsComment')), '', false); |
|
670 | 670 | $default_values['search_show_unlinked_results'] = api_get_setting('search_show_unlinked_results'); |
671 | 671 | |
672 | 672 | $sf_values = array(); |
@@ -674,7 +674,7 @@ discard block |
||
674 | 674 | $sf_values[$sf['code']] = $sf['name']; |
675 | 675 | } |
676 | 676 | $group = array(); |
677 | - $url = Display::div(Display::url(get_lang('AddSpecificSearchField'), 'specific_fields.php'), array('class'=>'sectioncomment')); |
|
677 | + $url = Display::div(Display::url(get_lang('AddSpecificSearchField'), 'specific_fields.php'), array('class'=>'sectioncomment')); |
|
678 | 678 | if (empty($sf_values)) { |
679 | 679 | $form->addElement('html', get_lang('SearchPrefilterPrefix').$url); |
680 | 680 | } else { |
@@ -741,10 +741,10 @@ discard block |
||
741 | 741 | $dir_is_writable = Display::return_icon('bullet_red.png', get_lang('Error')); |
742 | 742 | } |
743 | 743 | |
744 | - $data[] = array(get_lang('XapianModuleInstalled'),$xapian_loaded); |
|
745 | - $data[] = array(get_lang('DirectoryExists').' - '.$xapian_path,$dir_exists); |
|
746 | - $data[] = array(get_lang('IsWritable').' - '.$xapian_path,$dir_is_writable); |
|
747 | - $data[] = array(get_lang('SpecificSearchFieldsAvailable') ,$specific_fields_exists); |
|
744 | + $data[] = array(get_lang('XapianModuleInstalled'), $xapian_loaded); |
|
745 | + $data[] = array(get_lang('DirectoryExists').' - '.$xapian_path, $dir_exists); |
|
746 | + $data[] = array(get_lang('IsWritable').' - '.$xapian_path, $dir_is_writable); |
|
747 | + $data[] = array(get_lang('SpecificSearchFieldsAvailable'), $specific_fields_exists); |
|
748 | 748 | |
749 | 749 | echo Display::tag('h3', get_lang('Settings')); |
750 | 750 | $table = new SortableTableFromArray($data); |
@@ -754,16 +754,16 @@ discard block |
||
754 | 754 | |
755 | 755 | //@todo windows support |
756 | 756 | if (api_is_windows_os() == false) { |
757 | - $list_of_programs = array('pdftotext','ps2pdf', 'catdoc','html2text','unrtf', 'catppt', 'xls2csv'); |
|
757 | + $list_of_programs = array('pdftotext', 'ps2pdf', 'catdoc', 'html2text', 'unrtf', 'catppt', 'xls2csv'); |
|
758 | 758 | |
759 | - foreach($list_of_programs as $program) { |
|
759 | + foreach ($list_of_programs as $program) { |
|
760 | 760 | $output = $ret_val = null; |
761 | 761 | exec("which $program", $output, $ret_val); |
762 | 762 | $icon = Display::return_icon('bullet_red.png', get_lang('NotInstalled')); |
763 | 763 | if (!empty($output[0])) { |
764 | 764 | $icon = Display::return_icon('bullet_green.png', get_lang('Installed')); |
765 | 765 | } |
766 | - $data2[]= array($program, $output[0], $icon); |
|
766 | + $data2[] = array($program, $output[0], $icon); |
|
767 | 767 | } |
768 | 768 | echo Display::tag('h3', get_lang('ProgramsNeededToConvertFiles')); |
769 | 769 | $table = new SortableTableFromArray($data2); |
@@ -795,7 +795,7 @@ discard block |
||
795 | 795 | if ($action != 'add') { |
796 | 796 | echo '<div class="actions" style="margin-left: 1px;">'; |
797 | 797 | echo '<a href="settings.php?category=Templates&action=add">'. |
798 | - Display::return_icon('new_template.png', get_lang('AddTemplate'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
798 | + Display::return_icon('new_template.png', get_lang('AddTemplate'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
799 | 799 | echo '</div>'; |
800 | 800 | } |
801 | 801 | |
@@ -914,8 +914,8 @@ discard block |
||
914 | 914 | * @since Dokeos 1.8.6 |
915 | 915 | */ |
916 | 916 | function actions_filter($id) { |
917 | - $return = '<a href="settings.php?category=Templates&action=edit&id='.Security::remove_XSS($id).'">'.Display::return_icon('edit.png', get_lang('Edit'),'',ICON_SIZE_SMALL).'</a>'; |
|
918 | - $return .= '<a href="settings.php?category=Templates&action=delete&id='.Security::remove_XSS($id).'" onClick="javascript:if(!confirm('."'".get_lang('ConfirmYourChoice')."'".')) return false;">'.Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>'; |
|
917 | + $return = '<a href="settings.php?category=Templates&action=edit&id='.Security::remove_XSS($id).'">'.Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL).'</a>'; |
|
918 | + $return .= '<a href="settings.php?category=Templates&action=delete&id='.Security::remove_XSS($id).'" onClick="javascript:if(!confirm('."'".get_lang('ConfirmYourChoice')."'".')) return false;">'.Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL).'</a>'; |
|
919 | 919 | return $return; |
920 | 920 | } |
921 | 921 | |
@@ -965,7 +965,7 @@ discard block |
||
965 | 965 | $form->addElement('html_editor', 'template_text', get_lang('Text'), null, array('ToolbarSet' => 'AdminTemplates', 'Width' => '100%', 'Height' => '400')); |
966 | 966 | |
967 | 967 | // Setting the form elements: the form to upload an image to be used with the template. |
968 | - $form->addElement('file','template_image',get_lang('Image'),''); |
|
968 | + $form->addElement('file', 'template_image', get_lang('Image'), ''); |
|
969 | 969 | |
970 | 970 | // Setting the form elements: a little bit information about the template image. |
971 | 971 | $form->addElement('static', 'file_comment', '', get_lang('TemplateImageComment100x70')); |
@@ -1043,7 +1043,7 @@ discard block |
||
1043 | 1043 | // Store the information in the database (as insert or as update). |
1044 | 1044 | $table_system_template = Database :: get_main_table('system_template'); |
1045 | 1045 | if ($_GET['action'] == 'add') { |
1046 | - $content_template = Security::remove_XSS($values['template_text'], COURSEMANAGERLOWSECURITY); |
|
1046 | + $content_template = Security::remove_XSS($values['template_text'], COURSEMANAGERLOWSECURITY); |
|
1047 | 1047 | $params = [ |
1048 | 1048 | 'title' => $values['title'], |
1049 | 1049 | 'content' => $content_template, |
@@ -1053,7 +1053,7 @@ discard block |
||
1053 | 1053 | |
1054 | 1054 | // Display a feedback message. |
1055 | 1055 | Display::display_confirmation_message(get_lang('TemplateAdded')); |
1056 | - echo '<a href="settings.php?category=Templates&action=add">'.Display::return_icon('new_template.png', get_lang('AddTemplate'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
1056 | + echo '<a href="settings.php?category=Templates&action=add">'.Display::return_icon('new_template.png', get_lang('AddTemplate'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
1057 | 1057 | } else { |
1058 | 1058 | $content_template = '<head>{CSS}<style type="text/css">.text{font-weight: normal;}</style></head><body>'.Database::escape_string($values['template_text']).'</body>'; |
1059 | 1059 | $sql = "UPDATE $table_system_template set title = '".Database::escape_string($values['title'])."', content = '".$content_template."'"; |
@@ -1071,7 +1071,7 @@ discard block |
||
1071 | 1071 | display_templates(); |
1072 | 1072 | } else { |
1073 | 1073 | $token = Security::get_token(); |
1074 | - $form->addElement('hidden','sec_token'); |
|
1074 | + $form->addElement('hidden', 'sec_token'); |
|
1075 | 1075 | $form->setConstants(array('sec_token' => $token)); |
1076 | 1076 | // Display the form. |
1077 | 1077 | $form->display(); |
@@ -1171,7 +1171,7 @@ discard block |
||
1171 | 1171 | |
1172 | 1172 | $form = new FormValidator('settings', 'post', 'settings.php?category='.Security::remove_XSS($_GET['category'])); |
1173 | 1173 | |
1174 | - $form->addElement('hidden', 'search_field', (!empty($_GET['search_field'])?Security::remove_XSS($_GET['search_field']):null)); |
|
1174 | + $form->addElement('hidden', 'search_field', (!empty($_GET['search_field']) ? Security::remove_XSS($_GET['search_field']) : null)); |
|
1175 | 1175 | |
1176 | 1176 | $url_id = api_get_current_access_url_id(); |
1177 | 1177 | |
@@ -1238,9 +1238,9 @@ discard block |
||
1238 | 1238 | if (empty($row['category'])) |
1239 | 1239 | $row['category'] = 0; |
1240 | 1240 | |
1241 | - if (is_array($settings_by_access_list[ $row['variable'] ] [ $row['subkey'] ] [ $row['category'] ])) { |
|
1241 | + if (is_array($settings_by_access_list[$row['variable']] [$row['subkey']] [$row['category']])) { |
|
1242 | 1242 | // We are sure that the other site have a selected value. |
1243 | - if ($settings_by_access_list[ $row['variable'] ] [ $row['subkey'] ] [ $row['category'] ]['selected_value'] != '') |
|
1243 | + if ($settings_by_access_list[$row['variable']] [$row['subkey']] [$row['category']]['selected_value'] != '') |
|
1244 | 1244 | $row['selected_value'] = $settings_by_access_list[$row['variable']] [$row['subkey']] [$row['category']]['selected_value']; |
1245 | 1245 | } |
1246 | 1246 | // There is no else{} statement because we load the default $row['selected_value'] of the main Chamilo site. |
@@ -1261,7 +1261,7 @@ discard block |
||
1261 | 1261 | array('maxlength' => '8') |
1262 | 1262 | ); |
1263 | 1263 | $form->applyFilter($row['variable'], 'html_filter'); |
1264 | - $default_values[$row['variable']] = round($row['selected_value']/1024/1024, 1); |
|
1264 | + $default_values[$row['variable']] = round($row['selected_value'] / 1024 / 1024, 1); |
|
1265 | 1265 | } elseif ($row['variable'] == 'account_valid_duration') { |
1266 | 1266 | $form->addElement( |
1267 | 1267 | 'text', |
@@ -1289,7 +1289,7 @@ discard block |
||
1289 | 1289 | ), |
1290 | 1290 | $hideme |
1291 | 1291 | ); |
1292 | - $form->applyFilter($row['variable'],'html_filter'); |
|
1292 | + $form->applyFilter($row['variable'], 'html_filter'); |
|
1293 | 1293 | $default_values[$row['variable']] = $row['selected_value']; |
1294 | 1294 | } |
1295 | 1295 | break; |
@@ -1300,7 +1300,7 @@ discard block |
||
1300 | 1300 | if (file_exists($file)) { |
1301 | 1301 | $value = file_get_contents($file); |
1302 | 1302 | } |
1303 | - $form->addElement('textarea', $row['variable'], array(get_lang($row['title']), get_lang($row['comment'])) , array('rows'=>'10'), $hideme); |
|
1303 | + $form->addElement('textarea', $row['variable'], array(get_lang($row['title']), get_lang($row['comment'])), array('rows'=>'10'), $hideme); |
|
1304 | 1304 | $default_values[$row['variable']] = $value; |
1305 | 1305 | } elseif ($row['variable'] == 'footer_extra_content') { |
1306 | 1306 | $file = api_get_path(SYS_PATH).api_get_home_path().'footer_extra_content.txt'; |
@@ -1308,16 +1308,16 @@ discard block |
||
1308 | 1308 | if (file_exists($file)) { |
1309 | 1309 | $value = file_get_contents($file); |
1310 | 1310 | } |
1311 | - $form->addElement('textarea', $row['variable'], array(get_lang($row['title']), get_lang($row['comment'])) , array('rows'=>'10'), $hideme); |
|
1311 | + $form->addElement('textarea', $row['variable'], array(get_lang($row['title']), get_lang($row['comment'])), array('rows'=>'10'), $hideme); |
|
1312 | 1312 | $default_values[$row['variable']] = $value; |
1313 | 1313 | } else { |
1314 | - $form->addElement('textarea', $row['variable'], array(get_lang($row['title']), get_lang($row['comment'])) , array('rows'=>'10'), $hideme); |
|
1314 | + $form->addElement('textarea', $row['variable'], array(get_lang($row['title']), get_lang($row['comment'])), array('rows'=>'10'), $hideme); |
|
1315 | 1315 | $default_values[$row['variable']] = $row['selected_value']; |
1316 | 1316 | } |
1317 | 1317 | break; |
1318 | 1318 | case 'radio': |
1319 | 1319 | $values = api_get_settings_options($row['variable']); |
1320 | - $group = array (); |
|
1320 | + $group = array(); |
|
1321 | 1321 | if (is_array($values)) { |
1322 | 1322 | foreach ($values as $key => $value) { |
1323 | 1323 | $element = &$form->createElement( |
@@ -1348,7 +1348,7 @@ discard block |
||
1348 | 1348 | WHERE variable='".$row['variable']."' AND access_url = 1"; |
1349 | 1349 | |
1350 | 1350 | $result = Database::query($sql); |
1351 | - $group = array (); |
|
1351 | + $group = array(); |
|
1352 | 1352 | while ($rowkeys = Database::fetch_array($result)) { |
1353 | 1353 | // Profile tab option should be hidden when the social tool is enabled. |
1354 | 1354 | if (api_get_setting('allow_social_tool') == 'true') { |
@@ -1420,10 +1420,10 @@ discard block |
||
1420 | 1420 | |
1421 | 1421 | switch ($row['variable']) { |
1422 | 1422 | case 'pdf_export_watermark_enable': |
1423 | - $url = PDF::get_watermark(null); |
|
1423 | + $url = PDF::get_watermark(null); |
|
1424 | 1424 | |
1425 | 1425 | if ($url != false) { |
1426 | - $delete_url = '<a href="?delete_watermark">'.get_lang('DelImage').' '.Display::return_icon('delete.png',get_lang('DelImage')).'</a>'; |
|
1426 | + $delete_url = '<a href="?delete_watermark">'.get_lang('DelImage').' '.Display::return_icon('delete.png', get_lang('DelImage')).'</a>'; |
|
1427 | 1427 | $form->addElement('html', '<div style="max-height:100px; max-width:100px; margin-left:162px; margin-bottom:10px; clear:both;"><img src="'.$url.'" style="margin-bottom:10px;" />'.$delete_url.'</div>'); |
1428 | 1428 | } |
1429 | 1429 |
@@ -28,7 +28,7 @@ |
||
28 | 28 | * @param string ISO code (fr_FR, ...) |
29 | 29 | * @param int Whether the sublanguage is published (0=unpublished, 1=published) |
30 | 30 | * @param int ID del idioma padre |
31 | - * @return int New sub language ID or false on error |
|
31 | + * @return false|string New sub language ID or false on error |
|
32 | 32 | */ |
33 | 33 | function add_sub_language ($original_name,$english_name,$isocode,$sublanguage_available,$parent_id) { |
34 | 34 | $tbl_admin_languages = Database :: get_main_table(TABLE_MAIN_LANGUAGE); |
@@ -62,43 +62,43 @@ discard block |
||
62 | 62 | * inside the add_sub_language function. |
63 | 63 | */ |
64 | 64 | function check_if_language_exist ($original_name, $english_name, $isocode, $sublanguage_available) { |
65 | - $tbl_admin_languages = Database :: get_main_table(TABLE_MAIN_LANGUAGE); |
|
66 | - $sql_original_name='SELECT count(*) AS count_original_name FROM '.$tbl_admin_languages.' WHERE original_name="'.Database::escape_string($original_name).'" '; |
|
67 | - $sql_english_name='SELECT count(*) AS count_english_name FROM '.$tbl_admin_languages.' WHERE english_name="'.Database::escape_string($english_name).'" '; |
|
68 | - //$sql_isocode='SELECT count(*) AS count_isocode FROM '.$tbl_admin_languages.' WHERE isocode="'.Database::escape_string($isocode).'" '; |
|
69 | - $rs_original_name=Database::query($sql_original_name); |
|
70 | - $rs_english_name=Database::query($sql_english_name); |
|
71 | - //$rs_isocode=Database::query($sql_isocode); |
|
72 | - $count_original_name=Database::result($rs_original_name,0,'count_original_name'); |
|
73 | - $count_english_name=Database::result($rs_english_name,0,'count_english_name'); |
|
74 | - //$count_isocode=Database::result($rs_isocode,0,'count_isocode'); |
|
75 | - $has_error=false; |
|
76 | - $message_information=array(); |
|
65 | + $tbl_admin_languages = Database :: get_main_table(TABLE_MAIN_LANGUAGE); |
|
66 | + $sql_original_name='SELECT count(*) AS count_original_name FROM '.$tbl_admin_languages.' WHERE original_name="'.Database::escape_string($original_name).'" '; |
|
67 | + $sql_english_name='SELECT count(*) AS count_english_name FROM '.$tbl_admin_languages.' WHERE english_name="'.Database::escape_string($english_name).'" '; |
|
68 | + //$sql_isocode='SELECT count(*) AS count_isocode FROM '.$tbl_admin_languages.' WHERE isocode="'.Database::escape_string($isocode).'" '; |
|
69 | + $rs_original_name=Database::query($sql_original_name); |
|
70 | + $rs_english_name=Database::query($sql_english_name); |
|
71 | + //$rs_isocode=Database::query($sql_isocode); |
|
72 | + $count_original_name=Database::result($rs_original_name,0,'count_original_name'); |
|
73 | + $count_english_name=Database::result($rs_english_name,0,'count_english_name'); |
|
74 | + //$count_isocode=Database::result($rs_isocode,0,'count_isocode'); |
|
75 | + $has_error=false; |
|
76 | + $message_information=array(); |
|
77 | 77 | |
78 | - if ($count_original_name==1) { |
|
79 | - $has_error=true; |
|
80 | - $message_information['original_name']=true; |
|
81 | - } |
|
82 | - if ($count_english_name==1) { |
|
83 | - $has_error=true; |
|
84 | - $message_information['english_name']=true; |
|
85 | - } |
|
78 | + if ($count_original_name==1) { |
|
79 | + $has_error=true; |
|
80 | + $message_information['original_name']=true; |
|
81 | + } |
|
82 | + if ($count_english_name==1) { |
|
83 | + $has_error=true; |
|
84 | + $message_information['english_name']=true; |
|
85 | + } |
|
86 | 86 | |
87 | - $iso_list = api_get_platform_isocodes(); |
|
88 | - $iso_list = array_values($iso_list); |
|
87 | + $iso_list = api_get_platform_isocodes(); |
|
88 | + $iso_list = array_values($iso_list); |
|
89 | 89 | |
90 | - if (!in_array($isocode, $iso_list)) { |
|
91 | - $has_error=true; |
|
92 | - $message_information['isocode']=true; |
|
93 | - } |
|
94 | - if ($has_error===true) { |
|
95 | - $message_information['execute_add']=false; |
|
96 | - } |
|
97 | - if ($has_error===false) { |
|
98 | - $message_information['execute_add']=true; |
|
99 | - } |
|
90 | + if (!in_array($isocode, $iso_list)) { |
|
91 | + $has_error=true; |
|
92 | + $message_information['isocode']=true; |
|
93 | + } |
|
94 | + if ($has_error===true) { |
|
95 | + $message_information['execute_add']=false; |
|
96 | + } |
|
97 | + if ($has_error===false) { |
|
98 | + $message_information['execute_add']=true; |
|
99 | + } |
|
100 | 100 | |
101 | - return $message_information; |
|
101 | + return $message_information; |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
@@ -109,50 +109,50 @@ discard block |
||
109 | 109 | * @todo deprecate this function and use the static method directly |
110 | 110 | */ |
111 | 111 | function check_if_exist_language_by_id ($language_id) { |
112 | - return SubLanguageManager::check_if_exist_language_by_id($language_id); |
|
112 | + return SubLanguageManager::check_if_exist_language_by_id($language_id); |
|
113 | 113 | } |
114 | 114 | /** |
115 | - * Check if the given language is a parent of any sub-language |
|
116 | - * @param int Language ID of the presumed parent |
|
117 | - * @return bool True if this language has children, false otherwise |
|
118 | - */ |
|
115 | + * Check if the given language is a parent of any sub-language |
|
116 | + * @param int Language ID of the presumed parent |
|
117 | + * @return bool True if this language has children, false otherwise |
|
118 | + */ |
|
119 | 119 | function ckeck_if_is_parent_of_sub_language ($parent_id) { |
120 | - $sql='SELECT count(*) AS count FROM language WHERE parent_id= '.intval($parent_id).''; |
|
121 | - $rs=Database::query($sql); |
|
122 | - if (Database::num_rows($rs)>0 && Database::result($rs,0,'count')==1) { |
|
123 | - return true; |
|
124 | - } else { |
|
125 | - return false; |
|
126 | - } |
|
120 | + $sql='SELECT count(*) AS count FROM language WHERE parent_id= '.intval($parent_id).''; |
|
121 | + $rs=Database::query($sql); |
|
122 | + if (Database::num_rows($rs)>0 && Database::result($rs,0,'count')==1) { |
|
123 | + return true; |
|
124 | + } else { |
|
125 | + return false; |
|
126 | + } |
|
127 | 127 | } |
128 | 128 | /** |
129 | - * Get all information of sub-language |
|
130 | - * @param int Parent language ID |
|
131 | - * @param int Child language ID |
|
132 | - * @return array |
|
133 | - */ |
|
129 | + * Get all information of sub-language |
|
130 | + * @param int Parent language ID |
|
131 | + * @param int Child language ID |
|
132 | + * @return array |
|
133 | + */ |
|
134 | 134 | function allow_get_all_information_of_sub_language ($parent_id,$sub_language_id) { |
135 | - return SubLanguageManager::get_all_information_of_sub_language($parent_id,$sub_language_id); |
|
135 | + return SubLanguageManager::get_all_information_of_sub_language($parent_id,$sub_language_id); |
|
136 | 136 | } |
137 | 137 | /*end declare functions*/ |
138 | 138 | |
139 | 139 | //add data |
140 | 140 | |
141 | 141 | if (isset($_GET['sub_language_id']) && $_GET['sub_language_id']==strval(intval($_GET['sub_language_id']))) { |
142 | - $language_name=SubLanguageManager::get_name_of_language_by_id($_GET['sub_language_id']); |
|
143 | - if (check_if_exist_language_by_id ($_GET['sub_language_id'])===true) { |
|
144 | - $sub_language_id=$_GET['sub_language_id']; |
|
145 | - $sub_language_id_exist=true; |
|
146 | - } else { |
|
147 | - $sub_language_id_exist=false; |
|
148 | - } |
|
142 | + $language_name=SubLanguageManager::get_name_of_language_by_id($_GET['sub_language_id']); |
|
143 | + if (check_if_exist_language_by_id ($_GET['sub_language_id'])===true) { |
|
144 | + $sub_language_id=$_GET['sub_language_id']; |
|
145 | + $sub_language_id_exist=true; |
|
146 | + } else { |
|
147 | + $sub_language_id_exist=false; |
|
148 | + } |
|
149 | 149 | |
150 | 150 | } |
151 | 151 | $language_details = array(); |
152 | 152 | $language_name=''; |
153 | 153 | if (isset($_GET['id']) && $_GET['id']==strval(intval($_GET['id']))) { |
154 | 154 | $language_details = SubLanguageManager::get_all_information_of_language($_GET['id']); |
155 | - $language_name = $language_details['original_name']; |
|
155 | + $language_name = $language_details['original_name']; |
|
156 | 156 | if (check_if_exist_language_by_id ($_GET['id'])===true) { |
157 | 157 | $parent_id=$_GET['id']; |
158 | 158 | $language_id_exist=true; |
@@ -160,67 +160,67 @@ discard block |
||
160 | 160 | $language_id_exist=false; |
161 | 161 | } |
162 | 162 | } else { |
163 | - $language_id_exist=false; |
|
163 | + $language_id_exist=false; |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | //removed and register |
167 | 167 | |
168 | 168 | if ((isset($_GET['id']) && $_GET['id']==strval(intval($_GET['id']))) && (isset($_GET['sub_language_id']) && $_GET['sub_language_id']==strval(intval($_GET['sub_language_id'])))) { |
169 | - if (check_if_exist_language_by_id($_GET['id'])===true && check_if_exist_language_by_id($_GET['sub_language_id'])===true) { |
|
170 | - $get_all_information=allow_get_all_information_of_sub_language ($_GET['id'],$_GET['sub_language_id']); |
|
171 | - $original_name=$get_all_information['original_name']; |
|
172 | - $english_name=$get_all_information['english_name']; |
|
173 | - $isocode=$get_all_information['isocode']; |
|
169 | + if (check_if_exist_language_by_id($_GET['id'])===true && check_if_exist_language_by_id($_GET['sub_language_id'])===true) { |
|
170 | + $get_all_information=allow_get_all_information_of_sub_language ($_GET['id'],$_GET['sub_language_id']); |
|
171 | + $original_name=$get_all_information['original_name']; |
|
172 | + $english_name=$get_all_information['english_name']; |
|
173 | + $isocode=$get_all_information['isocode']; |
|
174 | 174 | |
175 | - } |
|
175 | + } |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | $language_name=get_lang('CreateSubLanguageForLanguage').' ( '.strtolower($language_name).' )'; |
179 | 179 | |
180 | 180 | if (ckeck_if_is_parent_of_sub_language($parent_id)===true && isset($_GET['action']) && $_GET['action']=='deletesublanguage') { |
181 | - $language_name=get_lang('DeleteSubLanguage'); |
|
181 | + $language_name=get_lang('DeleteSubLanguage'); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | $msg = ''; |
185 | 185 | |
186 | 186 | if (isset($_POST['SubmitAddNewLanguage'])) { |
187 | - $original_name=$_POST['original_name']; |
|
188 | - $english_name=$_POST['english_name']; |
|
189 | - $isocode=$_POST['isocode']; |
|
190 | - $english_name=str_replace(' ','_',$english_name); |
|
191 | - $isocode=str_replace(' ','_',$isocode); |
|
187 | + $original_name=$_POST['original_name']; |
|
188 | + $english_name=$_POST['english_name']; |
|
189 | + $isocode=$_POST['isocode']; |
|
190 | + $english_name=str_replace(' ','_',$english_name); |
|
191 | + $isocode=str_replace(' ','_',$isocode); |
|
192 | 192 | |
193 | - $sublanguage_available=$_POST['sub_language_is_visible']; |
|
194 | - $check_information=array(); |
|
195 | - $check_information=check_if_language_exist($original_name,$english_name,$isocode,$sublanguage_available); |
|
196 | - foreach ($check_information as $index_information => $value_information) { |
|
197 | - $allow_insert_info=false; |
|
198 | - if ($index_information=='original_name') { |
|
199 | - $msg .= Display::return_message(get_lang('AlreadyExists').' "'.get_lang('OriginalName').'" '.'('.$original_name.')','error'); |
|
200 | - } |
|
201 | - if ($index_information=='english_name') { |
|
202 | - $msg .= Display::return_message(get_lang('AlreadyExists').' "'.get_lang('EnglishName').'" '.'('.$english_name.')','error'); |
|
203 | - } |
|
204 | - if ($index_information=='isocode') { |
|
205 | - $msg .= Display::return_message(get_lang('CodeDoesNotExists').': '.$isocode.'','error'); |
|
206 | - } |
|
207 | - if ($index_information=='execute_add' && $value_information===true) { |
|
208 | - $allow_insert_info=true; |
|
209 | - } |
|
210 | - } |
|
193 | + $sublanguage_available=$_POST['sub_language_is_visible']; |
|
194 | + $check_information=array(); |
|
195 | + $check_information=check_if_language_exist($original_name,$english_name,$isocode,$sublanguage_available); |
|
196 | + foreach ($check_information as $index_information => $value_information) { |
|
197 | + $allow_insert_info=false; |
|
198 | + if ($index_information=='original_name') { |
|
199 | + $msg .= Display::return_message(get_lang('AlreadyExists').' "'.get_lang('OriginalName').'" '.'('.$original_name.')','error'); |
|
200 | + } |
|
201 | + if ($index_information=='english_name') { |
|
202 | + $msg .= Display::return_message(get_lang('AlreadyExists').' "'.get_lang('EnglishName').'" '.'('.$english_name.')','error'); |
|
203 | + } |
|
204 | + if ($index_information=='isocode') { |
|
205 | + $msg .= Display::return_message(get_lang('CodeDoesNotExists').': '.$isocode.'','error'); |
|
206 | + } |
|
207 | + if ($index_information=='execute_add' && $value_information===true) { |
|
208 | + $allow_insert_info=true; |
|
209 | + } |
|
210 | + } |
|
211 | 211 | |
212 | - if (strlen($original_name)>0 && strlen($english_name)>0 && strlen($isocode)>0) { |
|
213 | - if ($allow_insert_info===true && $language_id_exist===true) { |
|
214 | - $english_name=str_replace(' ','_',$english_name); |
|
212 | + if (strlen($original_name)>0 && strlen($english_name)>0 && strlen($isocode)>0) { |
|
213 | + if ($allow_insert_info===true && $language_id_exist===true) { |
|
214 | + $english_name=str_replace(' ','_',$english_name); |
|
215 | 215 | //Fixes BT#1636 |
216 | 216 | $english_name=api_strtolower($english_name); |
217 | 217 | |
218 | - $isocode=str_replace(' ','_',$isocode); |
|
219 | - $str_info='<br/>'.get_lang('OriginalName').' : '.$original_name.'<br/>'.get_lang('EnglishName').' : '.$english_name.'<br/>'.get_lang('PlatformCharsetTitle').' : '.$isocode; |
|
218 | + $isocode=str_replace(' ','_',$isocode); |
|
219 | + $str_info='<br/>'.get_lang('OriginalName').' : '.$original_name.'<br/>'.get_lang('EnglishName').' : '.$english_name.'<br/>'.get_lang('PlatformCharsetTitle').' : '.$isocode; |
|
220 | 220 | |
221 | - $mkdir_result=SubLanguageManager::add_language_directory($english_name); |
|
222 | - if ($mkdir_result) { |
|
223 | - $sl_id = add_sub_language($original_name,$english_name,$isocode,$sublanguage_available,$parent_id); |
|
221 | + $mkdir_result=SubLanguageManager::add_language_directory($english_name); |
|
222 | + if ($mkdir_result) { |
|
223 | + $sl_id = add_sub_language($original_name,$english_name,$isocode,$sublanguage_available,$parent_id); |
|
224 | 224 | if ($sl_id === false) { |
225 | 225 | SubLanguageManager::remove_language_directory($english_name); |
226 | 226 | $msg .= Display::return_message(get_lang('LanguageDirectoryNotWriteableContactAdmin'),'error'); |
@@ -232,17 +232,17 @@ discard block |
||
232 | 232 | require 'sub_language.php'; |
233 | 233 | exit(); |
234 | 234 | } |
235 | - } else { |
|
236 | - $msg .= Display::return_message(get_lang('LanguageDirectoryNotWriteableContactAdmin'),'error'); |
|
237 | - } |
|
238 | - } else { |
|
239 | - if ($language_id_exist===false) { |
|
240 | - $msg .= Display::return_message(get_lang('LanguageParentNotExist'),'error'); |
|
241 | - } |
|
242 | - } |
|
243 | - } else { |
|
235 | + } else { |
|
236 | + $msg .= Display::return_message(get_lang('LanguageDirectoryNotWriteableContactAdmin'),'error'); |
|
237 | + } |
|
238 | + } else { |
|
239 | + if ($language_id_exist===false) { |
|
240 | + $msg .= Display::return_message(get_lang('LanguageParentNotExist'),'error'); |
|
241 | + } |
|
242 | + } |
|
243 | + } else { |
|
244 | 244 | $msg .= Display::return_message(get_lang('FormHasErrorsPleaseComplete'),'error'); |
245 | - } |
|
245 | + } |
|
246 | 246 | } |
247 | 247 | |
248 | 248 | Display :: display_header($language_name); |
@@ -250,51 +250,51 @@ discard block |
||
250 | 250 | echo $msg; |
251 | 251 | |
252 | 252 | if (isset($_POST['SubmitAddDeleteLanguage'])) { |
253 | - $rs = SubLanguageManager::remove_sub_language($_GET['id'], $_GET['sub_language_id']); |
|
254 | - if ($rs===true) { |
|
255 | - Display::display_confirmation_message(get_lang('TheSubLanguageHasBeenRemoved')); |
|
256 | - } else { |
|
257 | - Display::display_error_message(get_lang('TheSubLanguageHasNotBeenRemoved')); |
|
258 | - } |
|
253 | + $rs = SubLanguageManager::remove_sub_language($_GET['id'], $_GET['sub_language_id']); |
|
254 | + if ($rs===true) { |
|
255 | + Display::display_confirmation_message(get_lang('TheSubLanguageHasBeenRemoved')); |
|
256 | + } else { |
|
257 | + Display::display_error_message(get_lang('TheSubLanguageHasNotBeenRemoved')); |
|
258 | + } |
|
259 | 259 | } |
260 | 260 | // ckeck_if_is_parent_of_sub_language($parent_id)===false |
261 | 261 | // |
262 | 262 | if (isset($_GET['action']) && $_GET['action']=='definenewsublanguage') { |
263 | - $text = $language_name; |
|
264 | - $form = new FormValidator('addsublanguage', 'post', 'sub_language_add.php?id='.Security::remove_XSS($_GET['id']).'&action=definenewsublanguage'); |
|
265 | - $class='add'; |
|
266 | - $form->addElement('header', '', $text); |
|
267 | - $form->addElement('text', 'original_name', get_lang('OriginalName'),'class="input_titles"'); |
|
268 | - $form->addRule('original_name', get_lang('ThisFieldIsRequired'), 'required'); |
|
269 | - $form->addElement('text', 'english_name', get_lang('EnglishName'),'class="input_titles"'); |
|
270 | - $form->addRule('english_name', get_lang('ThisFieldIsRequired'), 'required'); |
|
271 | - $form->addElement('text', 'isocode', get_lang('ISOCode'), 'class="input_titles"'); |
|
272 | - $form->addRule('isocode', get_lang('ThisFieldIsRequired'), 'required'); |
|
273 | - $form->addElement('static', null, ' ', '<i>en, es, fr</i>'); |
|
274 | - $form->addElement('checkbox', 'sub_language_is_visible', '', get_lang('Visibility')); |
|
275 | - $form->addButtonCreate(get_lang('CreateSubLanguage'), 'SubmitAddNewLanguage'); |
|
263 | + $text = $language_name; |
|
264 | + $form = new FormValidator('addsublanguage', 'post', 'sub_language_add.php?id='.Security::remove_XSS($_GET['id']).'&action=definenewsublanguage'); |
|
265 | + $class='add'; |
|
266 | + $form->addElement('header', '', $text); |
|
267 | + $form->addElement('text', 'original_name', get_lang('OriginalName'),'class="input_titles"'); |
|
268 | + $form->addRule('original_name', get_lang('ThisFieldIsRequired'), 'required'); |
|
269 | + $form->addElement('text', 'english_name', get_lang('EnglishName'),'class="input_titles"'); |
|
270 | + $form->addRule('english_name', get_lang('ThisFieldIsRequired'), 'required'); |
|
271 | + $form->addElement('text', 'isocode', get_lang('ISOCode'), 'class="input_titles"'); |
|
272 | + $form->addRule('isocode', get_lang('ThisFieldIsRequired'), 'required'); |
|
273 | + $form->addElement('static', null, ' ', '<i>en, es, fr</i>'); |
|
274 | + $form->addElement('checkbox', 'sub_language_is_visible', '', get_lang('Visibility')); |
|
275 | + $form->addButtonCreate(get_lang('CreateSubLanguage'), 'SubmitAddNewLanguage'); |
|
276 | 276 | //$values['original_name'] = $language_details['original_name'].'...'; -> cannot be used because of quickform filtering (freeze) |
277 | 277 | $values['english_name'] = $language_details['english_name'].'2'; |
278 | 278 | $values['isocode'] = $language_details['isocode']; |
279 | 279 | $form->setDefaults($values); |
280 | - $form->display(); |
|
280 | + $form->display(); |
|
281 | 281 | } else { |
282 | - if (isset($_GET['action']) && $_GET['action']=='deletesublanguage') { |
|
283 | - $text=$language_name; |
|
284 | - $form = new FormValidator('deletesublanguage', 'post', 'sub_language_add.php?id='.Security::remove_XSS($_GET['id']).'&sub_language_id='.Security::remove_XSS($_GET['sub_language_id'])); |
|
285 | - $class='minus'; |
|
286 | - $form->addElement('header', '', $text); |
|
287 | - $form->addElement('static', '', get_lang('OriginalName'),$original_name); |
|
288 | - $form->addElement('static', '', get_lang('EnglishName'),$english_name); |
|
289 | - $form->addElement('static', '', get_lang('PlatformCharsetTitle'),$isocode); |
|
290 | - $form->addButtonCreate(get_lang('DeleteSubLanguage'), 'SubmitAddDeleteLanguage'); |
|
291 | - $form->display(); |
|
292 | - } |
|
293 | - if (isset($_GET['action']) && $_GET['action']=='definenewsublanguage') { |
|
294 | - Display::display_normal_message(get_lang('TheSubLanguageForThisLanguageHasBeenAdded')); |
|
295 | - } |
|
282 | + if (isset($_GET['action']) && $_GET['action']=='deletesublanguage') { |
|
283 | + $text=$language_name; |
|
284 | + $form = new FormValidator('deletesublanguage', 'post', 'sub_language_add.php?id='.Security::remove_XSS($_GET['id']).'&sub_language_id='.Security::remove_XSS($_GET['sub_language_id'])); |
|
285 | + $class='minus'; |
|
286 | + $form->addElement('header', '', $text); |
|
287 | + $form->addElement('static', '', get_lang('OriginalName'),$original_name); |
|
288 | + $form->addElement('static', '', get_lang('EnglishName'),$english_name); |
|
289 | + $form->addElement('static', '', get_lang('PlatformCharsetTitle'),$isocode); |
|
290 | + $form->addButtonCreate(get_lang('DeleteSubLanguage'), 'SubmitAddDeleteLanguage'); |
|
291 | + $form->display(); |
|
292 | + } |
|
293 | + if (isset($_GET['action']) && $_GET['action']=='definenewsublanguage') { |
|
294 | + Display::display_normal_message(get_lang('TheSubLanguageForThisLanguageHasBeenAdded')); |
|
295 | + } |
|
296 | 296 | } |
297 | 297 | /** |
298 | - * Footer |
|
299 | - */ |
|
298 | + * Footer |
|
299 | + */ |
|
300 | 300 | Display :: display_footer(); |
@@ -18,8 +18,8 @@ discard block |
||
18 | 18 | $tool_name = get_lang('CreateSubLanguage'); |
19 | 19 | |
20 | 20 | // setting breadcrumbs |
21 | -$interbreadcrumb[] = array ('url' => 'index.php', 'name' => get_lang('PlatformAdmin')); |
|
22 | -$interbreadcrumb[] = array ('url' => 'languages.php', 'name' => get_lang('PlatformLanguages')); |
|
21 | +$interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin')); |
|
22 | +$interbreadcrumb[] = array('url' => 'languages.php', 'name' => get_lang('PlatformLanguages')); |
|
23 | 23 | |
24 | 24 | /** |
25 | 25 | * Add sub-language |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * @param int ID del idioma padre |
31 | 31 | * @return int New sub language ID or false on error |
32 | 32 | */ |
33 | -function add_sub_language ($original_name,$english_name,$isocode,$sublanguage_available,$parent_id) { |
|
33 | +function add_sub_language($original_name, $english_name, $isocode, $sublanguage_available, $parent_id) { |
|
34 | 34 | $tbl_admin_languages = Database :: get_main_table(TABLE_MAIN_LANGUAGE); |
35 | 35 | $original_name = Database::escape_string($original_name); |
36 | 36 | $english_name = Database::escape_string($english_name); |
@@ -61,41 +61,41 @@ discard block |
||
61 | 61 | * @todo This function is not transaction-safe and should probably be included |
62 | 62 | * inside the add_sub_language function. |
63 | 63 | */ |
64 | -function check_if_language_exist ($original_name, $english_name, $isocode, $sublanguage_available) { |
|
65 | - $tbl_admin_languages = Database :: get_main_table(TABLE_MAIN_LANGUAGE); |
|
66 | - $sql_original_name='SELECT count(*) AS count_original_name FROM '.$tbl_admin_languages.' WHERE original_name="'.Database::escape_string($original_name).'" '; |
|
67 | - $sql_english_name='SELECT count(*) AS count_english_name FROM '.$tbl_admin_languages.' WHERE english_name="'.Database::escape_string($english_name).'" '; |
|
64 | +function check_if_language_exist($original_name, $english_name, $isocode, $sublanguage_available) { |
|
65 | + $tbl_admin_languages = Database :: get_main_table(TABLE_MAIN_LANGUAGE); |
|
66 | + $sql_original_name = 'SELECT count(*) AS count_original_name FROM '.$tbl_admin_languages.' WHERE original_name="'.Database::escape_string($original_name).'" '; |
|
67 | + $sql_english_name = 'SELECT count(*) AS count_english_name FROM '.$tbl_admin_languages.' WHERE english_name="'.Database::escape_string($english_name).'" '; |
|
68 | 68 | //$sql_isocode='SELECT count(*) AS count_isocode FROM '.$tbl_admin_languages.' WHERE isocode="'.Database::escape_string($isocode).'" '; |
69 | - $rs_original_name=Database::query($sql_original_name); |
|
70 | - $rs_english_name=Database::query($sql_english_name); |
|
69 | + $rs_original_name = Database::query($sql_original_name); |
|
70 | + $rs_english_name = Database::query($sql_english_name); |
|
71 | 71 | //$rs_isocode=Database::query($sql_isocode); |
72 | - $count_original_name=Database::result($rs_original_name,0,'count_original_name'); |
|
73 | - $count_english_name=Database::result($rs_english_name,0,'count_english_name'); |
|
72 | + $count_original_name = Database::result($rs_original_name, 0, 'count_original_name'); |
|
73 | + $count_english_name = Database::result($rs_english_name, 0, 'count_english_name'); |
|
74 | 74 | //$count_isocode=Database::result($rs_isocode,0,'count_isocode'); |
75 | - $has_error=false; |
|
76 | - $message_information=array(); |
|
75 | + $has_error = false; |
|
76 | + $message_information = array(); |
|
77 | 77 | |
78 | - if ($count_original_name==1) { |
|
79 | - $has_error=true; |
|
80 | - $message_information['original_name']=true; |
|
78 | + if ($count_original_name == 1) { |
|
79 | + $has_error = true; |
|
80 | + $message_information['original_name'] = true; |
|
81 | 81 | } |
82 | - if ($count_english_name==1) { |
|
83 | - $has_error=true; |
|
84 | - $message_information['english_name']=true; |
|
82 | + if ($count_english_name == 1) { |
|
83 | + $has_error = true; |
|
84 | + $message_information['english_name'] = true; |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | $iso_list = api_get_platform_isocodes(); |
88 | 88 | $iso_list = array_values($iso_list); |
89 | 89 | |
90 | 90 | if (!in_array($isocode, $iso_list)) { |
91 | - $has_error=true; |
|
92 | - $message_information['isocode']=true; |
|
91 | + $has_error = true; |
|
92 | + $message_information['isocode'] = true; |
|
93 | 93 | } |
94 | - if ($has_error===true) { |
|
95 | - $message_information['execute_add']=false; |
|
94 | + if ($has_error === true) { |
|
95 | + $message_information['execute_add'] = false; |
|
96 | 96 | } |
97 | - if ($has_error===false) { |
|
98 | - $message_information['execute_add']=true; |
|
97 | + if ($has_error === false) { |
|
98 | + $message_information['execute_add'] = true; |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | return $message_information; |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | * @return bool |
109 | 109 | * @todo deprecate this function and use the static method directly |
110 | 110 | */ |
111 | -function check_if_exist_language_by_id ($language_id) { |
|
111 | +function check_if_exist_language_by_id($language_id) { |
|
112 | 112 | return SubLanguageManager::check_if_exist_language_by_id($language_id); |
113 | 113 | } |
114 | 114 | /** |
@@ -116,10 +116,10 @@ discard block |
||
116 | 116 | * @param int Language ID of the presumed parent |
117 | 117 | * @return bool True if this language has children, false otherwise |
118 | 118 | */ |
119 | -function ckeck_if_is_parent_of_sub_language ($parent_id) { |
|
120 | - $sql='SELECT count(*) AS count FROM language WHERE parent_id= '.intval($parent_id).''; |
|
121 | - $rs=Database::query($sql); |
|
122 | - if (Database::num_rows($rs)>0 && Database::result($rs,0,'count')==1) { |
|
119 | +function ckeck_if_is_parent_of_sub_language($parent_id) { |
|
120 | + $sql = 'SELECT count(*) AS count FROM language WHERE parent_id= '.intval($parent_id).''; |
|
121 | + $rs = Database::query($sql); |
|
122 | + if (Database::num_rows($rs) > 0 && Database::result($rs, 0, 'count') == 1) { |
|
123 | 123 | return true; |
124 | 124 | } else { |
125 | 125 | return false; |
@@ -131,117 +131,117 @@ discard block |
||
131 | 131 | * @param int Child language ID |
132 | 132 | * @return array |
133 | 133 | */ |
134 | -function allow_get_all_information_of_sub_language ($parent_id,$sub_language_id) { |
|
135 | - return SubLanguageManager::get_all_information_of_sub_language($parent_id,$sub_language_id); |
|
134 | +function allow_get_all_information_of_sub_language($parent_id, $sub_language_id) { |
|
135 | + return SubLanguageManager::get_all_information_of_sub_language($parent_id, $sub_language_id); |
|
136 | 136 | } |
137 | 137 | /*end declare functions*/ |
138 | 138 | |
139 | 139 | //add data |
140 | 140 | |
141 | -if (isset($_GET['sub_language_id']) && $_GET['sub_language_id']==strval(intval($_GET['sub_language_id']))) { |
|
142 | - $language_name=SubLanguageManager::get_name_of_language_by_id($_GET['sub_language_id']); |
|
143 | - if (check_if_exist_language_by_id ($_GET['sub_language_id'])===true) { |
|
144 | - $sub_language_id=$_GET['sub_language_id']; |
|
145 | - $sub_language_id_exist=true; |
|
141 | +if (isset($_GET['sub_language_id']) && $_GET['sub_language_id'] == strval(intval($_GET['sub_language_id']))) { |
|
142 | + $language_name = SubLanguageManager::get_name_of_language_by_id($_GET['sub_language_id']); |
|
143 | + if (check_if_exist_language_by_id($_GET['sub_language_id']) === true) { |
|
144 | + $sub_language_id = $_GET['sub_language_id']; |
|
145 | + $sub_language_id_exist = true; |
|
146 | 146 | } else { |
147 | - $sub_language_id_exist=false; |
|
147 | + $sub_language_id_exist = false; |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | } |
151 | 151 | $language_details = array(); |
152 | -$language_name=''; |
|
153 | -if (isset($_GET['id']) && $_GET['id']==strval(intval($_GET['id']))) { |
|
152 | +$language_name = ''; |
|
153 | +if (isset($_GET['id']) && $_GET['id'] == strval(intval($_GET['id']))) { |
|
154 | 154 | $language_details = SubLanguageManager::get_all_information_of_language($_GET['id']); |
155 | 155 | $language_name = $language_details['original_name']; |
156 | - if (check_if_exist_language_by_id ($_GET['id'])===true) { |
|
157 | - $parent_id=$_GET['id']; |
|
158 | - $language_id_exist=true; |
|
156 | + if (check_if_exist_language_by_id($_GET['id']) === true) { |
|
157 | + $parent_id = $_GET['id']; |
|
158 | + $language_id_exist = true; |
|
159 | 159 | } else { |
160 | - $language_id_exist=false; |
|
160 | + $language_id_exist = false; |
|
161 | 161 | } |
162 | 162 | } else { |
163 | - $language_id_exist=false; |
|
163 | + $language_id_exist = false; |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | //removed and register |
167 | 167 | |
168 | -if ((isset($_GET['id']) && $_GET['id']==strval(intval($_GET['id']))) && (isset($_GET['sub_language_id']) && $_GET['sub_language_id']==strval(intval($_GET['sub_language_id'])))) { |
|
169 | - if (check_if_exist_language_by_id($_GET['id'])===true && check_if_exist_language_by_id($_GET['sub_language_id'])===true) { |
|
170 | - $get_all_information=allow_get_all_information_of_sub_language ($_GET['id'],$_GET['sub_language_id']); |
|
171 | - $original_name=$get_all_information['original_name']; |
|
172 | - $english_name=$get_all_information['english_name']; |
|
173 | - $isocode=$get_all_information['isocode']; |
|
168 | +if ((isset($_GET['id']) && $_GET['id'] == strval(intval($_GET['id']))) && (isset($_GET['sub_language_id']) && $_GET['sub_language_id'] == strval(intval($_GET['sub_language_id'])))) { |
|
169 | + if (check_if_exist_language_by_id($_GET['id']) === true && check_if_exist_language_by_id($_GET['sub_language_id']) === true) { |
|
170 | + $get_all_information = allow_get_all_information_of_sub_language($_GET['id'], $_GET['sub_language_id']); |
|
171 | + $original_name = $get_all_information['original_name']; |
|
172 | + $english_name = $get_all_information['english_name']; |
|
173 | + $isocode = $get_all_information['isocode']; |
|
174 | 174 | |
175 | 175 | } |
176 | 176 | } |
177 | 177 | |
178 | -$language_name=get_lang('CreateSubLanguageForLanguage').' ( '.strtolower($language_name).' )'; |
|
178 | +$language_name = get_lang('CreateSubLanguageForLanguage').' ( '.strtolower($language_name).' )'; |
|
179 | 179 | |
180 | -if (ckeck_if_is_parent_of_sub_language($parent_id)===true && isset($_GET['action']) && $_GET['action']=='deletesublanguage') { |
|
181 | - $language_name=get_lang('DeleteSubLanguage'); |
|
180 | +if (ckeck_if_is_parent_of_sub_language($parent_id) === true && isset($_GET['action']) && $_GET['action'] == 'deletesublanguage') { |
|
181 | + $language_name = get_lang('DeleteSubLanguage'); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | $msg = ''; |
185 | 185 | |
186 | 186 | if (isset($_POST['SubmitAddNewLanguage'])) { |
187 | - $original_name=$_POST['original_name']; |
|
188 | - $english_name=$_POST['english_name']; |
|
189 | - $isocode=$_POST['isocode']; |
|
190 | - $english_name=str_replace(' ','_',$english_name); |
|
191 | - $isocode=str_replace(' ','_',$isocode); |
|
187 | + $original_name = $_POST['original_name']; |
|
188 | + $english_name = $_POST['english_name']; |
|
189 | + $isocode = $_POST['isocode']; |
|
190 | + $english_name = str_replace(' ', '_', $english_name); |
|
191 | + $isocode = str_replace(' ', '_', $isocode); |
|
192 | 192 | |
193 | - $sublanguage_available=$_POST['sub_language_is_visible']; |
|
194 | - $check_information=array(); |
|
195 | - $check_information=check_if_language_exist($original_name,$english_name,$isocode,$sublanguage_available); |
|
193 | + $sublanguage_available = $_POST['sub_language_is_visible']; |
|
194 | + $check_information = array(); |
|
195 | + $check_information = check_if_language_exist($original_name, $english_name, $isocode, $sublanguage_available); |
|
196 | 196 | foreach ($check_information as $index_information => $value_information) { |
197 | - $allow_insert_info=false; |
|
198 | - if ($index_information=='original_name') { |
|
199 | - $msg .= Display::return_message(get_lang('AlreadyExists').' "'.get_lang('OriginalName').'" '.'('.$original_name.')','error'); |
|
197 | + $allow_insert_info = false; |
|
198 | + if ($index_information == 'original_name') { |
|
199 | + $msg .= Display::return_message(get_lang('AlreadyExists').' "'.get_lang('OriginalName').'" '.'('.$original_name.')', 'error'); |
|
200 | 200 | } |
201 | - if ($index_information=='english_name') { |
|
202 | - $msg .= Display::return_message(get_lang('AlreadyExists').' "'.get_lang('EnglishName').'" '.'('.$english_name.')','error'); |
|
201 | + if ($index_information == 'english_name') { |
|
202 | + $msg .= Display::return_message(get_lang('AlreadyExists').' "'.get_lang('EnglishName').'" '.'('.$english_name.')', 'error'); |
|
203 | 203 | } |
204 | - if ($index_information=='isocode') { |
|
205 | - $msg .= Display::return_message(get_lang('CodeDoesNotExists').': '.$isocode.'','error'); |
|
204 | + if ($index_information == 'isocode') { |
|
205 | + $msg .= Display::return_message(get_lang('CodeDoesNotExists').': '.$isocode.'', 'error'); |
|
206 | 206 | } |
207 | - if ($index_information=='execute_add' && $value_information===true) { |
|
208 | - $allow_insert_info=true; |
|
207 | + if ($index_information == 'execute_add' && $value_information === true) { |
|
208 | + $allow_insert_info = true; |
|
209 | 209 | } |
210 | 210 | } |
211 | 211 | |
212 | - if (strlen($original_name)>0 && strlen($english_name)>0 && strlen($isocode)>0) { |
|
213 | - if ($allow_insert_info===true && $language_id_exist===true) { |
|
214 | - $english_name=str_replace(' ','_',$english_name); |
|
212 | + if (strlen($original_name) > 0 && strlen($english_name) > 0 && strlen($isocode) > 0) { |
|
213 | + if ($allow_insert_info === true && $language_id_exist === true) { |
|
214 | + $english_name = str_replace(' ', '_', $english_name); |
|
215 | 215 | //Fixes BT#1636 |
216 | - $english_name=api_strtolower($english_name); |
|
216 | + $english_name = api_strtolower($english_name); |
|
217 | 217 | |
218 | - $isocode=str_replace(' ','_',$isocode); |
|
219 | - $str_info='<br/>'.get_lang('OriginalName').' : '.$original_name.'<br/>'.get_lang('EnglishName').' : '.$english_name.'<br/>'.get_lang('PlatformCharsetTitle').' : '.$isocode; |
|
218 | + $isocode = str_replace(' ', '_', $isocode); |
|
219 | + $str_info = '<br/>'.get_lang('OriginalName').' : '.$original_name.'<br/>'.get_lang('EnglishName').' : '.$english_name.'<br/>'.get_lang('PlatformCharsetTitle').' : '.$isocode; |
|
220 | 220 | |
221 | - $mkdir_result=SubLanguageManager::add_language_directory($english_name); |
|
221 | + $mkdir_result = SubLanguageManager::add_language_directory($english_name); |
|
222 | 222 | if ($mkdir_result) { |
223 | - $sl_id = add_sub_language($original_name,$english_name,$isocode,$sublanguage_available,$parent_id); |
|
223 | + $sl_id = add_sub_language($original_name, $english_name, $isocode, $sublanguage_available, $parent_id); |
|
224 | 224 | if ($sl_id === false) { |
225 | 225 | SubLanguageManager::remove_language_directory($english_name); |
226 | - $msg .= Display::return_message(get_lang('LanguageDirectoryNotWriteableContactAdmin'),'error'); |
|
226 | + $msg .= Display::return_message(get_lang('LanguageDirectoryNotWriteableContactAdmin'), 'error'); |
|
227 | 227 | } else { |
228 | 228 | // Here we build the confirmation message and we send the user to the sub language terms definition page, using a little hack - see #3712 |
229 | - $_SESSION['msg'] = Display::return_message(get_lang('TheNewSubLanguageHasBeenAdded').$str_info.'confirm',false); |
|
229 | + $_SESSION['msg'] = Display::return_message(get_lang('TheNewSubLanguageHasBeenAdded').$str_info.'confirm', false); |
|
230 | 230 | unset($interbreadcrumb); |
231 | 231 | $_GET['sub_language_id'] = $_REQUEST['sub_language_id'] = $sl_id; |
232 | 232 | require 'sub_language.php'; |
233 | 233 | exit(); |
234 | 234 | } |
235 | 235 | } else { |
236 | - $msg .= Display::return_message(get_lang('LanguageDirectoryNotWriteableContactAdmin'),'error'); |
|
236 | + $msg .= Display::return_message(get_lang('LanguageDirectoryNotWriteableContactAdmin'), 'error'); |
|
237 | 237 | } |
238 | 238 | } else { |
239 | - if ($language_id_exist===false) { |
|
240 | - $msg .= Display::return_message(get_lang('LanguageParentNotExist'),'error'); |
|
239 | + if ($language_id_exist === false) { |
|
240 | + $msg .= Display::return_message(get_lang('LanguageParentNotExist'), 'error'); |
|
241 | 241 | } |
242 | 242 | } |
243 | 243 | } else { |
244 | - $msg .= Display::return_message(get_lang('FormHasErrorsPleaseComplete'),'error'); |
|
244 | + $msg .= Display::return_message(get_lang('FormHasErrorsPleaseComplete'), 'error'); |
|
245 | 245 | } |
246 | 246 | } |
247 | 247 | |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | |
252 | 252 | if (isset($_POST['SubmitAddDeleteLanguage'])) { |
253 | 253 | $rs = SubLanguageManager::remove_sub_language($_GET['id'], $_GET['sub_language_id']); |
254 | - if ($rs===true) { |
|
254 | + if ($rs === true) { |
|
255 | 255 | Display::display_confirmation_message(get_lang('TheSubLanguageHasBeenRemoved')); |
256 | 256 | } else { |
257 | 257 | Display::display_error_message(get_lang('TheSubLanguageHasNotBeenRemoved')); |
@@ -259,14 +259,14 @@ discard block |
||
259 | 259 | } |
260 | 260 | // ckeck_if_is_parent_of_sub_language($parent_id)===false |
261 | 261 | // |
262 | -if (isset($_GET['action']) && $_GET['action']=='definenewsublanguage') { |
|
262 | +if (isset($_GET['action']) && $_GET['action'] == 'definenewsublanguage') { |
|
263 | 263 | $text = $language_name; |
264 | 264 | $form = new FormValidator('addsublanguage', 'post', 'sub_language_add.php?id='.Security::remove_XSS($_GET['id']).'&action=definenewsublanguage'); |
265 | - $class='add'; |
|
265 | + $class = 'add'; |
|
266 | 266 | $form->addElement('header', '', $text); |
267 | - $form->addElement('text', 'original_name', get_lang('OriginalName'),'class="input_titles"'); |
|
267 | + $form->addElement('text', 'original_name', get_lang('OriginalName'), 'class="input_titles"'); |
|
268 | 268 | $form->addRule('original_name', get_lang('ThisFieldIsRequired'), 'required'); |
269 | - $form->addElement('text', 'english_name', get_lang('EnglishName'),'class="input_titles"'); |
|
269 | + $form->addElement('text', 'english_name', get_lang('EnglishName'), 'class="input_titles"'); |
|
270 | 270 | $form->addRule('english_name', get_lang('ThisFieldIsRequired'), 'required'); |
271 | 271 | $form->addElement('text', 'isocode', get_lang('ISOCode'), 'class="input_titles"'); |
272 | 272 | $form->addRule('isocode', get_lang('ThisFieldIsRequired'), 'required'); |
@@ -279,18 +279,18 @@ discard block |
||
279 | 279 | $form->setDefaults($values); |
280 | 280 | $form->display(); |
281 | 281 | } else { |
282 | - if (isset($_GET['action']) && $_GET['action']=='deletesublanguage') { |
|
283 | - $text=$language_name; |
|
282 | + if (isset($_GET['action']) && $_GET['action'] == 'deletesublanguage') { |
|
283 | + $text = $language_name; |
|
284 | 284 | $form = new FormValidator('deletesublanguage', 'post', 'sub_language_add.php?id='.Security::remove_XSS($_GET['id']).'&sub_language_id='.Security::remove_XSS($_GET['sub_language_id'])); |
285 | - $class='minus'; |
|
285 | + $class = 'minus'; |
|
286 | 286 | $form->addElement('header', '', $text); |
287 | - $form->addElement('static', '', get_lang('OriginalName'),$original_name); |
|
288 | - $form->addElement('static', '', get_lang('EnglishName'),$english_name); |
|
289 | - $form->addElement('static', '', get_lang('PlatformCharsetTitle'),$isocode); |
|
287 | + $form->addElement('static', '', get_lang('OriginalName'), $original_name); |
|
288 | + $form->addElement('static', '', get_lang('EnglishName'), $english_name); |
|
289 | + $form->addElement('static', '', get_lang('PlatformCharsetTitle'), $isocode); |
|
290 | 290 | $form->addButtonCreate(get_lang('DeleteSubLanguage'), 'SubmitAddDeleteLanguage'); |
291 | 291 | $form->display(); |
292 | 292 | } |
293 | - if (isset($_GET['action']) && $_GET['action']=='definenewsublanguage') { |
|
293 | + if (isset($_GET['action']) && $_GET['action'] == 'definenewsublanguage') { |
|
294 | 294 | Display::display_normal_message(get_lang('TheSubLanguageForThisLanguageHasBeenAdded')); |
295 | 295 | } |
296 | 296 | } |
@@ -286,7 +286,7 @@ |
||
286 | 286 | * This function defines globals. |
287 | 287 | * @param int $userId |
288 | 288 | * |
289 | -* @return bool False on failure, redirection on success |
|
289 | +* @return false|null False on failure, redirection on success |
|
290 | 290 | * @author Evie Embrechts |
291 | 291 | * @author Yannick Warnier <[email protected]> |
292 | 292 | */ |
@@ -239,8 +239,8 @@ discard block |
||
239 | 239 | if (isset($keywordListValues['keyword_status']) && |
240 | 240 | $keywordListValues['keyword_status'] == PLATFORM_ADMIN |
241 | 241 | ) { |
242 | - $query_admin_table = " , $admin_table a "; |
|
243 | - $keyword_admin = ' AND a.user_id = u.id '; |
|
242 | + $query_admin_table = " , $admin_table a "; |
|
243 | + $keyword_admin = ' AND a.user_id = u.id '; |
|
244 | 244 | $keywordListValues['keyword_status'] = '%'; |
245 | 245 | } |
246 | 246 | |
@@ -306,13 +306,13 @@ discard block |
||
306 | 306 | $firstname = $userInfo['firstname']; |
307 | 307 | $lastname = $userInfo['lastname']; |
308 | 308 | |
309 | - if (api_is_western_name_order()) { |
|
310 | - $message = sprintf(get_lang('AttemptingToLoginAs'),$firstname,$lastname, $userId); |
|
311 | - } else { |
|
312 | - $message = sprintf(get_lang('AttemptingToLoginAs'), $lastname, $firstname, $userId); |
|
313 | - } |
|
309 | + if (api_is_western_name_order()) { |
|
310 | + $message = sprintf(get_lang('AttemptingToLoginAs'),$firstname,$lastname, $userId); |
|
311 | + } else { |
|
312 | + $message = sprintf(get_lang('AttemptingToLoginAs'), $lastname, $firstname, $userId); |
|
313 | + } |
|
314 | 314 | |
315 | - if ($userId) { |
|
315 | + if ($userId) { |
|
316 | 316 | |
317 | 317 | // Logout the current user |
318 | 318 | LoginDelete(api_get_user_id()); |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | Display :: display_footer(); |
348 | 348 | exit; |
349 | 349 | |
350 | - } |
|
350 | + } |
|
351 | 351 | } |
352 | 352 | |
353 | 353 | /** |
@@ -385,7 +385,7 @@ discard block |
||
385 | 385 | }*/ |
386 | 386 | |
387 | 387 | if (!in_array($direction, array('ASC','DESC'))) { |
388 | - $direction = 'ASC'; |
|
388 | + $direction = 'ASC'; |
|
389 | 389 | } |
390 | 390 | $column = intval($column); |
391 | 391 | $from = intval($from); |
@@ -396,23 +396,23 @@ discard block |
||
396 | 396 | $sql .= " WHERE u.creator_id = ".api_get_user_id(); |
397 | 397 | } |
398 | 398 | |
399 | - $sql .= " ORDER BY col$column $direction "; |
|
400 | - $sql .= " LIMIT $from,$number_of_items"; |
|
399 | + $sql .= " ORDER BY col$column $direction "; |
|
400 | + $sql .= " LIMIT $from,$number_of_items"; |
|
401 | 401 | |
402 | - $res = Database::query($sql); |
|
402 | + $res = Database::query($sql); |
|
403 | 403 | |
404 | - $users = array (); |
|
404 | + $users = array (); |
|
405 | 405 | $t = time(); |
406 | - while ($user = Database::fetch_row($res)) { |
|
407 | - $userPicture = UserManager::getUserPicture($user[0], USER_IMAGE_SIZE_SMALL); |
|
408 | - $photo = '<img src="'.$userPicture.'" width="22" height="22" alt="'.api_get_person_name($user[2], $user[3]).'" title="'.api_get_person_name($user[2], $user[3]).'" />'; |
|
406 | + while ($user = Database::fetch_row($res)) { |
|
407 | + $userPicture = UserManager::getUserPicture($user[0], USER_IMAGE_SIZE_SMALL); |
|
408 | + $photo = '<img src="'.$userPicture.'" width="22" height="22" alt="'.api_get_person_name($user[2], $user[3]).'" title="'.api_get_person_name($user[2], $user[3]).'" />'; |
|
409 | 409 | |
410 | 410 | if ($user[7] == 1 && !empty($user[10])) { |
411 | 411 | // check expiration date |
412 | 412 | $expiration_time = convert_sql_date($user[10]); |
413 | 413 | // if expiration date is passed, store a special value for active field |
414 | 414 | if ($expiration_time < $t) { |
415 | - $user[7] = '-1'; |
|
415 | + $user[7] = '-1'; |
|
416 | 416 | } |
417 | 417 | } |
418 | 418 | |
@@ -430,9 +430,9 @@ discard block |
||
430 | 430 | api_get_local_time($user[9]), |
431 | 431 | $user[0] |
432 | 432 | ); |
433 | - } |
|
433 | + } |
|
434 | 434 | |
435 | - return $users; |
|
435 | + return $users; |
|
436 | 436 | } |
437 | 437 | |
438 | 438 | /** |
@@ -441,7 +441,7 @@ discard block |
||
441 | 441 | * @return string HTML-code with a mailto-link |
442 | 442 | */ |
443 | 443 | function email_filter($email) { |
444 | - return Display :: encrypted_mailto_link($email, $email); |
|
444 | + return Display :: encrypted_mailto_link($email, $email); |
|
445 | 445 | } |
446 | 446 | |
447 | 447 | /** |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | * @return string HTML-code with a mailto-link |
451 | 451 | */ |
452 | 452 | function user_filter($name, $params, $row) { |
453 | - return '<a href="'.api_get_path(WEB_PATH).'whoisonline.php?origin=user_list&id='.$row[0].'">'.$name.'</a>'; |
|
453 | + return '<a href="'.api_get_path(WEB_PATH).'whoisonline.php?origin=user_list&id='.$row[0].'">'.$name.'</a>'; |
|
454 | 454 | } |
455 | 455 | |
456 | 456 | /** |
@@ -461,84 +461,84 @@ discard block |
||
461 | 461 | * @return string Some HTML-code with modify-buttons |
462 | 462 | */ |
463 | 463 | function modify_filter($user_id, $url_params, $row) { |
464 | - global $charset, $_admins_list; |
|
465 | - $is_admin = in_array($user_id,$_admins_list); |
|
466 | - $statusname = api_get_status_langvars(); |
|
467 | - $user_is_anonymous = false; |
|
464 | + global $charset, $_admins_list; |
|
465 | + $is_admin = in_array($user_id,$_admins_list); |
|
466 | + $statusname = api_get_status_langvars(); |
|
467 | + $user_is_anonymous = false; |
|
468 | 468 | $current_user_status_label = $row['7']; |
469 | 469 | |
470 | - if ($current_user_status_label == $statusname[ANONYMOUS]) { |
|
471 | - $user_is_anonymous =true; |
|
472 | - } |
|
473 | - $result = ''; |
|
474 | - if (!$user_is_anonymous) { |
|
475 | - $icon = Display::return_icon('course.png', get_lang('Courses'), array('onmouseout' => 'clear_course_list (\'div_'.$user_id.'\')')); |
|
476 | - $result .= '<a href="javascript:void(0)" onclick="load_course_list(\'div_'.$user_id.'\','.$user_id.')" > |
|
470 | + if ($current_user_status_label == $statusname[ANONYMOUS]) { |
|
471 | + $user_is_anonymous =true; |
|
472 | + } |
|
473 | + $result = ''; |
|
474 | + if (!$user_is_anonymous) { |
|
475 | + $icon = Display::return_icon('course.png', get_lang('Courses'), array('onmouseout' => 'clear_course_list (\'div_'.$user_id.'\')')); |
|
476 | + $result .= '<a href="javascript:void(0)" onclick="load_course_list(\'div_'.$user_id.'\','.$user_id.')" > |
|
477 | 477 | '.$icon.' |
478 | 478 | <div class="blackboard_hide" id="div_'.$user_id.'"> </div> |
479 | 479 | </a>'; |
480 | 480 | |
481 | 481 | $icon = Display::return_icon('session.png', get_lang('Sessions'), array('onmouseout' => 'clear_session_list (\'div_s_'.$user_id.'\')')); |
482 | - $result .= '<a href="javascript:void(0)" onclick="load_session_list(\'div_s_'.$user_id.'\','.$user_id.')" > |
|
482 | + $result .= '<a href="javascript:void(0)" onclick="load_session_list(\'div_s_'.$user_id.'\','.$user_id.')" > |
|
483 | 483 | '.$icon.' |
484 | 484 | <div class="blackboard_hide" id="div_s_'.$user_id.'"> </div> |
485 | 485 | </a>'; |
486 | - } else { |
|
487 | - $result .= Display::return_icon('course_na.png',get_lang('Courses')).' '; |
|
488 | - $result .= Display::return_icon('course_na.png',get_lang('Sessions')).' '; |
|
489 | - } |
|
486 | + } else { |
|
487 | + $result .= Display::return_icon('course_na.png',get_lang('Courses')).' '; |
|
488 | + $result .= Display::return_icon('course_na.png',get_lang('Sessions')).' '; |
|
489 | + } |
|
490 | 490 | |
491 | - if (api_is_platform_admin()) { |
|
492 | - if (!$user_is_anonymous) { |
|
493 | - $result .= '<a href="user_information.php?user_id='.$user_id.'">'.Display::return_icon('synthese_view.gif', get_lang('Info')).'</a> '; |
|
494 | - } else { |
|
495 | - $result .= Display::return_icon('synthese_view_na.gif', get_lang('Info')).' '; |
|
496 | - } |
|
497 | - } |
|
491 | + if (api_is_platform_admin()) { |
|
492 | + if (!$user_is_anonymous) { |
|
493 | + $result .= '<a href="user_information.php?user_id='.$user_id.'">'.Display::return_icon('synthese_view.gif', get_lang('Info')).'</a> '; |
|
494 | + } else { |
|
495 | + $result .= Display::return_icon('synthese_view_na.gif', get_lang('Info')).' '; |
|
496 | + } |
|
497 | + } |
|
498 | 498 | |
499 | 499 | //only allow platform admins to login_as, or session admins only for students (not teachers nor other admins) |
500 | 500 | if (api_is_platform_admin() || (api_is_session_admin() && $current_user_status_label == $statusname[STUDENT])) { |
501 | - if (!$user_is_anonymous) { |
|
501 | + if (!$user_is_anonymous) { |
|
502 | 502 | if (api_global_admin_can_edit_admin($user_id)) { |
503 | 503 | $result .= '<a href="user_list.php?action=login_as&user_id='.$user_id.'&sec_token='.$_SESSION['sec_token'].'">'.Display::return_icon('login_as.png', get_lang('LoginAs')).'</a> '; |
504 | 504 | } else { |
505 | 505 | $result .= Display::return_icon('login_as_na.png', get_lang('LoginAs')).' '; |
506 | 506 | } |
507 | - } else { |
|
508 | - $result .= Display::return_icon('login_as_na.png', get_lang('LoginAs')).' '; |
|
509 | - } |
|
507 | + } else { |
|
508 | + $result .= Display::return_icon('login_as_na.png', get_lang('LoginAs')).' '; |
|
509 | + } |
|
510 | 510 | } else { |
511 | - $result .= Display::return_icon('login_as_na.png', get_lang('LoginAs')).' '; |
|
511 | + $result .= Display::return_icon('login_as_na.png', get_lang('LoginAs')).' '; |
|
512 | 512 | } |
513 | 513 | |
514 | - if ($current_user_status_label != $statusname[STUDENT]) { |
|
515 | - $result .= Display::return_icon('statistics_na.gif', get_lang('Reporting')).' '; |
|
516 | - } else { |
|
517 | - $result .= '<a href="../mySpace/myStudents.php?student='.$user_id.'">'.Display::return_icon('statistics.gif', get_lang('Reporting')).'</a> '; |
|
518 | - } |
|
514 | + if ($current_user_status_label != $statusname[STUDENT]) { |
|
515 | + $result .= Display::return_icon('statistics_na.gif', get_lang('Reporting')).' '; |
|
516 | + } else { |
|
517 | + $result .= '<a href="../mySpace/myStudents.php?student='.$user_id.'">'.Display::return_icon('statistics.gif', get_lang('Reporting')).'</a> '; |
|
518 | + } |
|
519 | 519 | |
520 | - if (api_is_platform_admin(true)) { |
|
520 | + if (api_is_platform_admin(true)) { |
|
521 | 521 | $editProfileUrl = Display::getProfileEditionLink($user_id, true); |
522 | 522 | |
523 | 523 | if (!$user_is_anonymous && api_global_admin_can_edit_admin($user_id, null, true)) { |
524 | 524 | $result .= '<a href="' . $editProfileUrl . '">'.Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).'</a> '; |
525 | - } else { |
|
525 | + } else { |
|
526 | 526 | $result .= Display::return_icon('edit_na.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).'</a> '; |
527 | - } |
|
528 | - } |
|
527 | + } |
|
528 | + } |
|
529 | 529 | |
530 | - if ($is_admin) { |
|
531 | - $result .= Display::return_icon('admin_star.png', get_lang('IsAdministrator'),array('width'=> ICON_SIZE_SMALL, 'heigth'=> ICON_SIZE_SMALL)); |
|
532 | - } else { |
|
533 | - $result .= Display::return_icon('admin_star_na.png', get_lang('IsNotAdministrator')); |
|
534 | - } |
|
530 | + if ($is_admin) { |
|
531 | + $result .= Display::return_icon('admin_star.png', get_lang('IsAdministrator'),array('width'=> ICON_SIZE_SMALL, 'heigth'=> ICON_SIZE_SMALL)); |
|
532 | + } else { |
|
533 | + $result .= Display::return_icon('admin_star_na.png', get_lang('IsNotAdministrator')); |
|
534 | + } |
|
535 | 535 | |
536 | - // actions for assigning sessions, courses or users |
|
537 | - if (api_is_session_admin()) { |
|
538 | - /*if ($row[0] == api_get_user_id()) { |
|
536 | + // actions for assigning sessions, courses or users |
|
537 | + if (api_is_session_admin()) { |
|
538 | + /*if ($row[0] == api_get_user_id()) { |
|
539 | 539 | $result .= '<a href="dashboard_add_sessions_to_user.php?user='.$user_id.'">'.Display::return_icon('view_more_stats.gif', get_lang('AssignSessions')).'</a> '; |
540 | 540 | }*/ |
541 | - } else { |
|
541 | + } else { |
|
542 | 542 | if ($current_user_status_label == $statusname[SESSIONADMIN]) { |
543 | 543 | $result .= Display::url( |
544 | 544 | Display::return_icon('view_more_stats.gif', get_lang('AssignSessions')), |
@@ -568,7 +568,7 @@ discard block |
||
568 | 568 | ); |
569 | 569 | } |
570 | 570 | } |
571 | - } |
|
571 | + } |
|
572 | 572 | |
573 | 573 | if (api_is_platform_admin()) { |
574 | 574 | $result .= ' <a href="'.api_get_path(WEB_AJAX_PATH).'agenda.ajax.php?a=get_user_agenda&user_id='.$user_id.'&modal_size=lg" class="agenda_opener ajax">'. |
@@ -586,7 +586,7 @@ discard block |
||
586 | 586 | } |
587 | 587 | } |
588 | 588 | } |
589 | - return $result; |
|
589 | + return $result; |
|
590 | 590 | } |
591 | 591 | |
592 | 592 | |
@@ -619,10 +619,10 @@ discard block |
||
619 | 619 | if ($action == 'edit') { |
620 | 620 | $result = Display::return_icon($image.'.png', get_lang('AccountExpired'), array(), 16); |
621 | 621 | } elseif ($row['0']<>$_user['user_id']) { |
622 | - // you cannot lock yourself out otherwise you could disable all the accounts including your own => everybody is locked out and nobody can change it anymore. |
|
623 | - $result = Display::return_icon($image.'.png', get_lang(ucfirst($action)), array('onclick'=>'active_user(this);', 'id'=>'img_'.$row['0']), 16).'</a>'; |
|
624 | - } |
|
625 | - return $result; |
|
622 | + // you cannot lock yourself out otherwise you could disable all the accounts including your own => everybody is locked out and nobody can change it anymore. |
|
623 | + $result = Display::return_icon($image.'.png', get_lang(ucfirst($action)), array('onclick'=>'active_user(this);', 'id'=>'img_'.$row['0']), 16).'</a>'; |
|
624 | + } |
|
625 | + return $result; |
|
626 | 626 | } |
627 | 627 | |
628 | 628 | /** |
@@ -635,8 +635,8 @@ discard block |
||
635 | 635 | * @author Patrick Cool <[email protected]>, Ghent University, Belgium |
636 | 636 | */ |
637 | 637 | function status_filter($status) { |
638 | - $statusname = api_get_status_langvars(); |
|
639 | - return $statusname[$status]; |
|
638 | + $statusname = api_get_status_langvars(); |
|
639 | + return $statusname[$status]; |
|
640 | 640 | } |
641 | 641 | |
642 | 642 | if (isset($_GET['keyword']) || isset($_GET['keyword_firstname'])) { |
@@ -652,8 +652,8 @@ discard block |
||
652 | 652 | |
653 | 653 | if (!empty($action)) { |
654 | 654 | $check = Security::check_token('get'); |
655 | - if ($check) { |
|
656 | - switch ($action) { |
|
655 | + if ($check) { |
|
656 | + switch ($action) { |
|
657 | 657 | case 'add_user_to_my_url': |
658 | 658 | $user_id = $_REQUEST["user_id"]; |
659 | 659 | $result = UrlManager::add_user_to_url($user_id, $current_access_url_id); |
@@ -663,7 +663,7 @@ discard block |
||
663 | 663 | $message = Display::return_message($message, 'confirmation'); |
664 | 664 | } |
665 | 665 | break; |
666 | - case 'show_message' : |
|
666 | + case 'show_message' : |
|
667 | 667 | if (!empty($_GET['warn'])) { |
668 | 668 | // to prevent too long messages |
669 | 669 | if ($_GET['warn'] == 'session_message') { |
@@ -681,46 +681,46 @@ discard block |
||
681 | 681 | $message .= Display::return_message(stripslashes($_GET['message']), 'confirmation'); |
682 | 682 | } |
683 | 683 | |
684 | - break; |
|
685 | - case 'delete_user' : |
|
686 | - if (api_is_platform_admin()) { |
|
684 | + break; |
|
685 | + case 'delete_user' : |
|
686 | + if (api_is_platform_admin()) { |
|
687 | 687 | $user_to_delete = $_GET['user_id']; |
688 | 688 | $current_user_id = api_get_user_id(); |
689 | 689 | |
690 | - if ($deleteUserAvailable && api_global_admin_can_edit_admin($_GET['user_id'])) { |
|
691 | - if ($user_to_delete != $current_user_id && UserManager :: delete_user($_GET['user_id'])) { |
|
692 | - $message = Display :: return_message(get_lang('UserDeleted'), 'confirmation'); |
|
693 | - } else { |
|
694 | - $message = Display :: return_message(get_lang('CannotDeleteUserBecauseOwnsCourse'), 'error'); |
|
695 | - } |
|
696 | - } else { |
|
697 | - $message = Display :: return_message(get_lang('CannotDeleteUser'),'error'); |
|
698 | - } |
|
699 | - } |
|
700 | - break; |
|
690 | + if ($deleteUserAvailable && api_global_admin_can_edit_admin($_GET['user_id'])) { |
|
691 | + if ($user_to_delete != $current_user_id && UserManager :: delete_user($_GET['user_id'])) { |
|
692 | + $message = Display :: return_message(get_lang('UserDeleted'), 'confirmation'); |
|
693 | + } else { |
|
694 | + $message = Display :: return_message(get_lang('CannotDeleteUserBecauseOwnsCourse'), 'error'); |
|
695 | + } |
|
696 | + } else { |
|
697 | + $message = Display :: return_message(get_lang('CannotDeleteUser'),'error'); |
|
698 | + } |
|
699 | + } |
|
700 | + break; |
|
701 | 701 | case 'delete' : |
702 | - if (api_is_platform_admin()) { |
|
703 | - $number_of_selected_users = count($_POST['id']); |
|
704 | - $number_of_deleted_users = 0; |
|
705 | - if (is_array($_POST['id'])) { |
|
706 | - foreach ($_POST['id'] as $index => $user_id) { |
|
707 | - if($user_id != $_user['user_id']) { |
|
708 | - if(UserManager :: delete_user($user_id)) { |
|
709 | - $number_of_deleted_users++; |
|
710 | - } |
|
711 | - } |
|
712 | - } |
|
713 | - } |
|
714 | - if ($number_of_selected_users == $number_of_deleted_users) { |
|
702 | + if (api_is_platform_admin()) { |
|
703 | + $number_of_selected_users = count($_POST['id']); |
|
704 | + $number_of_deleted_users = 0; |
|
705 | + if (is_array($_POST['id'])) { |
|
706 | + foreach ($_POST['id'] as $index => $user_id) { |
|
707 | + if($user_id != $_user['user_id']) { |
|
708 | + if(UserManager :: delete_user($user_id)) { |
|
709 | + $number_of_deleted_users++; |
|
710 | + } |
|
711 | + } |
|
712 | + } |
|
713 | + } |
|
714 | + if ($number_of_selected_users == $number_of_deleted_users) { |
|
715 | 715 | $message = Display :: return_message(get_lang('SelectedUsersDeleted'), 'confirmation'); |
716 | - } else { |
|
716 | + } else { |
|
717 | 717 | $message = Display :: return_message(get_lang('SomeUsersNotDeleted'), 'error'); |
718 | - } |
|
719 | - } |
|
720 | - break; |
|
721 | - } |
|
722 | - Security::clear_token(); |
|
723 | - } |
|
718 | + } |
|
719 | + } |
|
720 | + break; |
|
721 | + } |
|
722 | + Security::clear_token(); |
|
723 | + } |
|
724 | 724 | } |
725 | 725 | |
726 | 726 | // Create a search-box |
@@ -740,24 +740,24 @@ discard block |
||
740 | 740 | |
741 | 741 | $actions = ''; |
742 | 742 | if (api_is_platform_admin()) { |
743 | - $actions .= '<div style="float:right;">'. |
|
744 | - '<a href="'.api_get_path(WEB_CODE_PATH).'admin/user_add.php">'. |
|
745 | - Display::return_icon('new_user.png',get_lang('AddUsers'),'',ICON_SIZE_MEDIUM).'</a>'. |
|
746 | - '</div>'; |
|
743 | + $actions .= '<div style="float:right;">'. |
|
744 | + '<a href="'.api_get_path(WEB_CODE_PATH).'admin/user_add.php">'. |
|
745 | + Display::return_icon('new_user.png',get_lang('AddUsers'),'',ICON_SIZE_MEDIUM).'</a>'. |
|
746 | + '</div>'; |
|
747 | 747 | } |
748 | 748 | $actions .= $form->return_form(); |
749 | 749 | |
750 | 750 | if (isset ($_GET['keyword'])) { |
751 | - $parameters = array ('keyword' => Security::remove_XSS($_GET['keyword'])); |
|
751 | + $parameters = array ('keyword' => Security::remove_XSS($_GET['keyword'])); |
|
752 | 752 | } elseif (isset ($_GET['keyword_firstname'])) { |
753 | - $parameters['keyword_firstname'] = Security::remove_XSS($_GET['keyword_firstname']); |
|
754 | - $parameters['keyword_lastname'] = Security::remove_XSS($_GET['keyword_lastname']); |
|
755 | - $parameters['keyword_username'] = Security::remove_XSS($_GET['keyword_username']); |
|
756 | - $parameters['keyword_email'] = Security::remove_XSS($_GET['keyword_email']); |
|
757 | - $parameters['keyword_officialcode'] = Security::remove_XSS($_GET['keyword_officialcode']); |
|
758 | - $parameters['keyword_status'] = Security::remove_XSS($_GET['keyword_status']); |
|
759 | - $parameters['keyword_active'] = Security::remove_XSS($_GET['keyword_active']); |
|
760 | - $parameters['keyword_inactive'] = Security::remove_XSS($_GET['keyword_inactive']); |
|
753 | + $parameters['keyword_firstname'] = Security::remove_XSS($_GET['keyword_firstname']); |
|
754 | + $parameters['keyword_lastname'] = Security::remove_XSS($_GET['keyword_lastname']); |
|
755 | + $parameters['keyword_username'] = Security::remove_XSS($_GET['keyword_username']); |
|
756 | + $parameters['keyword_email'] = Security::remove_XSS($_GET['keyword_email']); |
|
757 | + $parameters['keyword_officialcode'] = Security::remove_XSS($_GET['keyword_officialcode']); |
|
758 | + $parameters['keyword_status'] = Security::remove_XSS($_GET['keyword_status']); |
|
759 | + $parameters['keyword_active'] = Security::remove_XSS($_GET['keyword_active']); |
|
760 | + $parameters['keyword_inactive'] = Security::remove_XSS($_GET['keyword_inactive']); |
|
761 | 761 | } |
762 | 762 | // Create a sortable table with user-data |
763 | 763 | $parameters['sec_token'] = Security::get_token(); |
@@ -768,7 +768,7 @@ discard block |
||
768 | 768 | $res_admin = Database::query($sql_admin); |
769 | 769 | $_admins_list = array(); |
770 | 770 | while ($row_admin = Database::fetch_row($res_admin)) { |
771 | - $_admins_list[] = $row_admin[0]; |
|
771 | + $_admins_list[] = $row_admin[0]; |
|
772 | 772 | } |
773 | 773 | |
774 | 774 | // Display Advanced search form. |
@@ -824,11 +824,11 @@ discard block |
||
824 | 824 | $table->set_header(2, get_lang('OfficialCode')); |
825 | 825 | |
826 | 826 | if (api_is_western_name_order()) { |
827 | - $table->set_header(3, get_lang('FirstName')); |
|
828 | - $table->set_header(4, get_lang('LastName')); |
|
827 | + $table->set_header(3, get_lang('FirstName')); |
|
828 | + $table->set_header(4, get_lang('LastName')); |
|
829 | 829 | } else { |
830 | - $table->set_header(3, get_lang('LastName')); |
|
831 | - $table->set_header(4, get_lang('FirstName')); |
|
830 | + $table->set_header(3, get_lang('LastName')); |
|
831 | + $table->set_header(4, get_lang('FirstName')); |
|
832 | 832 | } |
833 | 833 | $table->set_header(5, get_lang('LoginName')); |
834 | 834 | $table->set_header(6, get_lang('Email')); |
@@ -106,10 +106,10 @@ discard block |
||
106 | 106 | function display_advanced_search_form () { |
107 | 107 | if ($("#advanced_search_form").css("display") == "none") { |
108 | 108 | $("#advanced_search_form").css("display","block"); |
109 | - $("#img_plus_and_minus").html(\' '.Display::return_icon('div_hide.gif',get_lang('Hide'),array('style'=>'vertical-align:middle')).' '.get_lang('AdvancedSearch').'\'); |
|
109 | + $("#img_plus_and_minus").html(\' '.Display::return_icon('div_hide.gif', get_lang('Hide'), array('style'=>'vertical-align:middle')).' '.get_lang('AdvancedSearch').'\'); |
|
110 | 110 | } else { |
111 | 111 | $("#advanced_search_form").css("display","none"); |
112 | - $("#img_plus_and_minus").html(\' '.Display::return_icon('div_show.gif',get_lang('Show'),array('style'=>'vertical-align:middle')).' '.get_lang('AdvancedSearch').'\'); |
|
112 | + $("#img_plus_and_minus").html(\' '.Display::return_icon('div_show.gif', get_lang('Show'), array('style'=>'vertical-align:middle')).' '.get_lang('AdvancedSearch').'\'); |
|
113 | 113 | } |
114 | 114 | } |
115 | 115 | |
@@ -185,8 +185,8 @@ discard block |
||
185 | 185 | |
186 | 186 | // adding the filter to see the user's only of the current access_url |
187 | 187 | if ((api_is_platform_admin() || api_is_session_admin()) && api_get_multiple_access_url()) { |
188 | - $access_url_rel_user_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
189 | - $sql.= " INNER JOIN $access_url_rel_user_table url_rel_user ON (u.id=url_rel_user.user_id)"; |
|
188 | + $access_url_rel_user_table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
189 | + $sql .= " INNER JOIN $access_url_rel_user_table url_rel_user ON (u.id=url_rel_user.user_id)"; |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | $keywordList = array( |
@@ -217,11 +217,11 @@ discard block |
||
217 | 217 | if (isset($keyword_extra_data) && !empty($keyword_extra_data)) { |
218 | 218 | $extra_info = UserManager::get_extra_field_information_by_name($keyword_extra_data); |
219 | 219 | $field_id = $extra_info['id']; |
220 | - $sql.= " INNER JOIN user_field_values ufv ON u.id=ufv.user_id AND ufv.field_id=$field_id "; |
|
220 | + $sql .= " INNER JOIN user_field_values ufv ON u.id=ufv.user_id AND ufv.field_id=$field_id "; |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | if (isset($_GET['keyword']) && !empty($_GET['keyword'])) { |
224 | - $keywordFiltered = Database::escape_string("%". $_GET['keyword'] ."%"); |
|
224 | + $keywordFiltered = Database::escape_string("%".$_GET['keyword']."%"); |
|
225 | 225 | $sql .= " WHERE ( |
226 | 226 | u.firstname LIKE '$keywordFiltered' OR |
227 | 227 | u.lastname LIKE '$keywordFiltered' OR |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | |
253 | 253 | $sql .= " $query_admin_table |
254 | 254 | WHERE ( |
255 | - u.firstname LIKE '". Database::escape_string("%".$keywordListValues['keyword_firstname']."%")."' AND |
|
255 | + u.firstname LIKE '".Database::escape_string("%".$keywordListValues['keyword_firstname']."%")."' AND |
|
256 | 256 | u.lastname LIKE '". Database::escape_string("%".$keywordListValues['keyword_lastname']."%")."' AND |
257 | 257 | u.username LIKE '". Database::escape_string("%".$keywordListValues['keyword_username']."%")."' AND |
258 | 258 | u.email LIKE '". Database::escape_string("%".$keywordListValues['keyword_email']."%")."' AND |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | |
265 | 265 | if (isset($keyword_active) && !isset($keyword_inactive)) { |
266 | 266 | $sql .= " AND u.active='1'"; |
267 | - } elseif(isset($keyword_inactive) && !isset($keyword_active)) { |
|
267 | + } elseif (isset($keyword_inactive) && !isset($keyword_active)) { |
|
268 | 268 | $sql .= " AND u.active='0'"; |
269 | 269 | } |
270 | 270 | $sql .= " ) "; |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | $lastname = $userInfo['lastname']; |
308 | 308 | |
309 | 309 | if (api_is_western_name_order()) { |
310 | - $message = sprintf(get_lang('AttemptingToLoginAs'),$firstname,$lastname, $userId); |
|
310 | + $message = sprintf(get_lang('AttemptingToLoginAs'), $firstname, $lastname, $userId); |
|
311 | 311 | } else { |
312 | 312 | $message = sprintf(get_lang('AttemptingToLoginAs'), $lastname, $firstname, $userId); |
313 | 313 | } |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | Session::write('login_as', true); |
342 | 342 | |
343 | 343 | $target_url = api_get_path(WEB_PATH)."user_portal.php"; |
344 | - $message .= '<br />'.sprintf(get_lang('LoginSuccessfulGoToX'),'<a href="'.$target_url.'">'.$target_url.'</a>'); |
|
344 | + $message .= '<br />'.sprintf(get_lang('LoginSuccessfulGoToX'), '<a href="'.$target_url.'">'.$target_url.'</a>'); |
|
345 | 345 | Display :: display_header(get_lang('UserList')); |
346 | 346 | Display :: display_normal_message($message, false); |
347 | 347 | Display :: display_footer(); |
@@ -384,11 +384,11 @@ discard block |
||
384 | 384 | $sql .= "AND password LIKE '$easyPassword' "; |
385 | 385 | }*/ |
386 | 386 | |
387 | - if (!in_array($direction, array('ASC','DESC'))) { |
|
387 | + if (!in_array($direction, array('ASC', 'DESC'))) { |
|
388 | 388 | $direction = 'ASC'; |
389 | 389 | } |
390 | 390 | $column = intval($column); |
391 | - $from = intval($from); |
|
391 | + $from = intval($from); |
|
392 | 392 | $number_of_items = intval($number_of_items); |
393 | 393 | |
394 | 394 | $preventSessionAdminsToManageAllUsers = api_get_setting('prevent_session_admins_to_manage_all_users'); |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | |
402 | 402 | $res = Database::query($sql); |
403 | 403 | |
404 | - $users = array (); |
|
404 | + $users = array(); |
|
405 | 405 | $t = time(); |
406 | 406 | while ($user = Database::fetch_row($res)) { |
407 | 407 | $userPicture = UserManager::getUserPicture($user[0], USER_IMAGE_SIZE_SMALL); |
@@ -462,13 +462,13 @@ discard block |
||
462 | 462 | */ |
463 | 463 | function modify_filter($user_id, $url_params, $row) { |
464 | 464 | global $charset, $_admins_list; |
465 | - $is_admin = in_array($user_id,$_admins_list); |
|
465 | + $is_admin = in_array($user_id, $_admins_list); |
|
466 | 466 | $statusname = api_get_status_langvars(); |
467 | 467 | $user_is_anonymous = false; |
468 | 468 | $current_user_status_label = $row['7']; |
469 | 469 | |
470 | 470 | if ($current_user_status_label == $statusname[ANONYMOUS]) { |
471 | - $user_is_anonymous =true; |
|
471 | + $user_is_anonymous = true; |
|
472 | 472 | } |
473 | 473 | $result = ''; |
474 | 474 | if (!$user_is_anonymous) { |
@@ -484,8 +484,8 @@ discard block |
||
484 | 484 | <div class="blackboard_hide" id="div_s_'.$user_id.'"> </div> |
485 | 485 | </a>'; |
486 | 486 | } else { |
487 | - $result .= Display::return_icon('course_na.png',get_lang('Courses')).' '; |
|
488 | - $result .= Display::return_icon('course_na.png',get_lang('Sessions')).' '; |
|
487 | + $result .= Display::return_icon('course_na.png', get_lang('Courses')).' '; |
|
488 | + $result .= Display::return_icon('course_na.png', get_lang('Sessions')).' '; |
|
489 | 489 | } |
490 | 490 | |
491 | 491 | if (api_is_platform_admin()) { |
@@ -521,14 +521,14 @@ discard block |
||
521 | 521 | $editProfileUrl = Display::getProfileEditionLink($user_id, true); |
522 | 522 | |
523 | 523 | if (!$user_is_anonymous && api_global_admin_can_edit_admin($user_id, null, true)) { |
524 | - $result .= '<a href="' . $editProfileUrl . '">'.Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).'</a> '; |
|
524 | + $result .= '<a href="'.$editProfileUrl.'">'.Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).'</a> '; |
|
525 | 525 | } else { |
526 | 526 | $result .= Display::return_icon('edit_na.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).'</a> '; |
527 | 527 | } |
528 | 528 | } |
529 | 529 | |
530 | 530 | if ($is_admin) { |
531 | - $result .= Display::return_icon('admin_star.png', get_lang('IsAdministrator'),array('width'=> ICON_SIZE_SMALL, 'heigth'=> ICON_SIZE_SMALL)); |
|
531 | + $result .= Display::return_icon('admin_star.png', get_lang('IsAdministrator'), array('width'=> ICON_SIZE_SMALL, 'heigth'=> ICON_SIZE_SMALL)); |
|
532 | 532 | } else { |
533 | 533 | $result .= Display::return_icon('admin_star_na.png', get_lang('IsNotAdministrator')); |
534 | 534 | } |
@@ -580,7 +580,7 @@ discard block |
||
580 | 580 | api_global_admin_can_edit_admin($user_id) |
581 | 581 | ) { |
582 | 582 | // you cannot lock yourself out otherwise you could disable all the accounts including your own => everybody is locked out and nobody can change it anymore. |
583 | - $result .= ' <a href="user_list.php?action=delete_user&user_id='.$user_id.'&'.$url_params.'&sec_token='.$_SESSION['sec_token'].'" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset))."'".')) return false;">'.Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL).'</a>'; |
|
583 | + $result .= ' <a href="user_list.php?action=delete_user&user_id='.$user_id.'&'.$url_params.'&sec_token='.$_SESSION['sec_token'].'" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, $charset))."'".')) return false;">'.Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL).'</a>'; |
|
584 | 584 | } else { |
585 | 585 | $result .= Display::return_icon('delete_na.png', get_lang('Delete'), array(), ICON_SIZE_SMALL); |
586 | 586 | } |
@@ -618,7 +618,7 @@ discard block |
||
618 | 618 | |
619 | 619 | if ($action == 'edit') { |
620 | 620 | $result = Display::return_icon($image.'.png', get_lang('AccountExpired'), array(), 16); |
621 | - } elseif ($row['0']<>$_user['user_id']) { |
|
621 | + } elseif ($row['0'] <> $_user['user_id']) { |
|
622 | 622 | // you cannot lock yourself out otherwise you could disable all the accounts including your own => everybody is locked out and nobody can change it anymore. |
623 | 623 | $result = Display::return_icon($image.'.png', get_lang(ucfirst($action)), array('onclick'=>'active_user(this);', 'id'=>'img_'.$row['0']), 16).'</a>'; |
624 | 624 | } |
@@ -640,11 +640,11 @@ discard block |
||
640 | 640 | } |
641 | 641 | |
642 | 642 | if (isset($_GET['keyword']) || isset($_GET['keyword_firstname'])) { |
643 | - $interbreadcrumb[] = array ("url" => 'index.php', "name" => get_lang('PlatformAdmin')); |
|
644 | - $interbreadcrumb[] = array ("url" => 'user_list.php', "name" => get_lang('UserList')); |
|
643 | + $interbreadcrumb[] = array("url" => 'index.php', "name" => get_lang('PlatformAdmin')); |
|
644 | + $interbreadcrumb[] = array("url" => 'user_list.php', "name" => get_lang('UserList')); |
|
645 | 645 | $tool_name = get_lang('SearchUsers'); |
646 | 646 | } else { |
647 | - $interbreadcrumb[] = array ("url" => 'index.php', "name" => get_lang('PlatformAdmin')); |
|
647 | + $interbreadcrumb[] = array("url" => 'index.php', "name" => get_lang('PlatformAdmin')); |
|
648 | 648 | $tool_name = get_lang('UserList'); |
649 | 649 | } |
650 | 650 | |
@@ -657,10 +657,10 @@ discard block |
||
657 | 657 | case 'add_user_to_my_url': |
658 | 658 | $user_id = $_REQUEST["user_id"]; |
659 | 659 | $result = UrlManager::add_user_to_url($user_id, $current_access_url_id); |
660 | - if ($result ) { |
|
660 | + if ($result) { |
|
661 | 661 | $user_info = api_get_user_info($user_id); |
662 | 662 | $message = get_lang('UserAdded').' '.$user_info['firstname'].' '.$user_info['lastname'].' ('.$user_info['username'].')'; |
663 | - $message = Display::return_message($message, 'confirmation'); |
|
663 | + $message = Display::return_message($message, 'confirmation'); |
|
664 | 664 | } |
665 | 665 | break; |
666 | 666 | case 'show_message' : |
@@ -694,7 +694,7 @@ discard block |
||
694 | 694 | $message = Display :: return_message(get_lang('CannotDeleteUserBecauseOwnsCourse'), 'error'); |
695 | 695 | } |
696 | 696 | } else { |
697 | - $message = Display :: return_message(get_lang('CannotDeleteUser'),'error'); |
|
697 | + $message = Display :: return_message(get_lang('CannotDeleteUser'), 'error'); |
|
698 | 698 | } |
699 | 699 | } |
700 | 700 | break; |
@@ -704,8 +704,8 @@ discard block |
||
704 | 704 | $number_of_deleted_users = 0; |
705 | 705 | if (is_array($_POST['id'])) { |
706 | 706 | foreach ($_POST['id'] as $index => $user_id) { |
707 | - if($user_id != $_user['user_id']) { |
|
708 | - if(UserManager :: delete_user($user_id)) { |
|
707 | + if ($user_id != $_user['user_id']) { |
|
708 | + if (UserManager :: delete_user($user_id)) { |
|
709 | 709 | $number_of_deleted_users++; |
710 | 710 | } |
711 | 711 | } |
@@ -738,17 +738,17 @@ discard block |
||
738 | 738 | </a>' |
739 | 739 | ); |
740 | 740 | |
741 | -$actions = ''; |
|
741 | +$actions = ''; |
|
742 | 742 | if (api_is_platform_admin()) { |
743 | 743 | $actions .= '<div style="float:right;">'. |
744 | 744 | '<a href="'.api_get_path(WEB_CODE_PATH).'admin/user_add.php">'. |
745 | - Display::return_icon('new_user.png',get_lang('AddUsers'),'',ICON_SIZE_MEDIUM).'</a>'. |
|
745 | + Display::return_icon('new_user.png', get_lang('AddUsers'), '', ICON_SIZE_MEDIUM).'</a>'. |
|
746 | 746 | '</div>'; |
747 | 747 | } |
748 | 748 | $actions .= $form->return_form(); |
749 | 749 | |
750 | 750 | if (isset ($_GET['keyword'])) { |
751 | - $parameters = array ('keyword' => Security::remove_XSS($_GET['keyword'])); |
|
751 | + $parameters = array('keyword' => Security::remove_XSS($_GET['keyword'])); |
|
752 | 752 | } elseif (isset ($_GET['keyword_firstname'])) { |
753 | 753 | $parameters['keyword_firstname'] = Security::remove_XSS($_GET['keyword_firstname']); |
754 | 754 | $parameters['keyword_lastname'] = Security::remove_XSS($_GET['keyword_lastname']); |
@@ -757,7 +757,7 @@ discard block |
||
757 | 757 | $parameters['keyword_officialcode'] = Security::remove_XSS($_GET['keyword_officialcode']); |
758 | 758 | $parameters['keyword_status'] = Security::remove_XSS($_GET['keyword_status']); |
759 | 759 | $parameters['keyword_active'] = Security::remove_XSS($_GET['keyword_active']); |
760 | - $parameters['keyword_inactive'] = Security::remove_XSS($_GET['keyword_inactive']); |
|
760 | + $parameters['keyword_inactive'] = Security::remove_XSS($_GET['keyword_inactive']); |
|
761 | 761 | } |
762 | 762 | // Create a sortable table with user-data |
763 | 763 | $parameters['sec_token'] = Security::get_token(); |
@@ -774,15 +774,15 @@ discard block |
||
774 | 774 | // Display Advanced search form. |
775 | 775 | $form = new FormValidator('advanced_search', 'get', '', '', array(), FormValidator::LAYOUT_HORIZONTAL); |
776 | 776 | |
777 | -$form->addElement('html','<div id="advanced_search_form" style="display:none;">'); |
|
777 | +$form->addElement('html', '<div id="advanced_search_form" style="display:none;">'); |
|
778 | 778 | $form->addElement('header', get_lang('AdvancedSearch')); |
779 | -$form->addText('keyword_firstname',get_lang('FirstName'),false); |
|
780 | -$form->addText('keyword_lastname',get_lang('LastName'),false); |
|
779 | +$form->addText('keyword_firstname', get_lang('FirstName'), false); |
|
780 | +$form->addText('keyword_lastname', get_lang('LastName'), false); |
|
781 | 781 | |
782 | -$form->addText('keyword_username',get_lang('LoginName'),false); |
|
783 | -$form->addText('keyword_email',get_lang('Email'),false); |
|
782 | +$form->addText('keyword_username', get_lang('LoginName'), false); |
|
783 | +$form->addText('keyword_email', get_lang('Email'), false); |
|
784 | 784 | |
785 | -$form->addText('keyword_officialcode',get_lang('OfficialCode'),false); |
|
785 | +$form->addText('keyword_officialcode', get_lang('OfficialCode'), false); |
|
786 | 786 | |
787 | 787 | $status_options = array(); |
788 | 788 | $status_options['%'] = get_lang('All'); |
@@ -792,12 +792,12 @@ discard block |
||
792 | 792 | $status_options[SESSIONADMIN] = get_lang('SessionsAdmin'); |
793 | 793 | $status_options[PLATFORM_ADMIN] = get_lang('Administrator'); |
794 | 794 | |
795 | -$form->addElement('select','keyword_status',get_lang('Profile'), $status_options ); |
|
795 | +$form->addElement('select', 'keyword_status', get_lang('Profile'), $status_options); |
|
796 | 796 | |
797 | 797 | $active_group = array(); |
798 | -$active_group[] = $form->createElement('checkbox','keyword_active','', get_lang('Active')); |
|
799 | -$active_group[] = $form->createElement('checkbox','keyword_inactive','', get_lang('Inactive')); |
|
800 | -$form->addGroup($active_group,'',get_lang('ActiveAccount'), '<br/>',false); |
|
798 | +$active_group[] = $form->createElement('checkbox', 'keyword_active', '', get_lang('Active')); |
|
799 | +$active_group[] = $form->createElement('checkbox', 'keyword_inactive', '', get_lang('Inactive')); |
|
800 | +$form->addGroup($active_group, '', get_lang('ActiveAccount'), '<br/>', false); |
|
801 | 801 | |
802 | 802 | $form->addElement('checkbox', 'check_easy_passwords', null, get_lang('CheckEasyPasswords')); |
803 | 803 | |
@@ -808,7 +808,7 @@ discard block |
||
808 | 808 | $defaults['keyword_active'] = 1; |
809 | 809 | $defaults['keyword_inactive'] = 1; |
810 | 810 | $form->setDefaults($defaults); |
811 | -$form->addElement('html','</div>'); |
|
811 | +$form->addElement('html', '</div>'); |
|
812 | 812 | |
813 | 813 | $form = $form->returnForm(); |
814 | 814 | |
@@ -890,10 +890,10 @@ discard block |
||
890 | 890 | } |
891 | 891 | if ($add_user) { |
892 | 892 | $row_table = array(); |
893 | - $row_table[] = api_get_person_name($user['firstname'], $user['lastname']).' ('.$user['username'].') '; |
|
894 | - $row_table[] = $access_info_to_string; |
|
893 | + $row_table[] = api_get_person_name($user['firstname'], $user['lastname']).' ('.$user['username'].') '; |
|
894 | + $row_table[] = $access_info_to_string; |
|
895 | 895 | $url = api_get_self().'?action=add_user_to_my_url&user_id='.$user['id'].'&sec_token='.$_SESSION['sec_token']; |
896 | - $row_table[] = Display::url(get_lang('AddUserToMyURL'), $url, array('class' => 'btn')); |
|
896 | + $row_table[] = Display::url(get_lang('AddUserToMyURL'), $url, array('class' => 'btn')); |
|
897 | 897 | |
898 | 898 | foreach ($row_table as $cell) { |
899 | 899 | $table->setCellContents($row, $column, $cell); |
@@ -128,7 +128,7 @@ |
||
128 | 128 | /** |
129 | 129 | * Update users from the imported data |
130 | 130 | * @param array $users List of users |
131 | - * @return void |
|
131 | + * @return false|null |
|
132 | 132 | * @uses global variable $inserted_in_course, which returns the list of courses the user was inserted in |
133 | 133 | */ |
134 | 134 |
@@ -215,8 +215,8 @@ discard block |
||
215 | 215 | // We are sure that the extra field exists. |
216 | 216 | foreach ($extra_fields as $extras) { |
217 | 217 | if (isset($user[$extras[1]])) { |
218 | - $key = $extras[1]; |
|
219 | - $value = $user[$extras[1]]; |
|
218 | + $key = $extras[1]; |
|
219 | + $value = $user[$extras[1]]; |
|
220 | 220 | UserManager::update_extra_field_value($user_id, $key, $value); |
221 | 221 | } |
222 | 222 | } |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | global $current_tag; |
254 | 254 | switch ($data) { |
255 | 255 | case 'Contact': |
256 | - $user = array (); |
|
256 | + $user = array(); |
|
257 | 257 | break; |
258 | 258 | default: |
259 | 259 | $current_tag = $data; |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | |
351 | 351 | if (in_array($ext_import_file, $allowed_file_mimetype)) { |
352 | 352 | if (strcmp($file_type, 'csv') === 0 && $ext_import_file == $allowed_file_mimetype[0]) { |
353 | - $users = parse_csv_data($_FILES['import_file']['tmp_name']); |
|
353 | + $users = parse_csv_data($_FILES['import_file']['tmp_name']); |
|
354 | 354 | $errors = validate_data($users); |
355 | 355 | $error_kind_file = false; |
356 | 356 | } elseif (strcmp($file_type, 'xml') === 0 && $ext_import_file == $allowed_file_mimetype[1]) { |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | Display::display_error_message($error_message); |
425 | 425 | } |
426 | 426 | |
427 | -$form = new FormValidator('user_update_import','post','user_update_import.php'); |
|
427 | +$form = new FormValidator('user_update_import', 'post', 'user_update_import.php'); |
|
428 | 428 | $form->addElement('header', '', $tool_name); |
429 | 429 | $form->addElement('hidden', 'formSent'); |
430 | 430 | $form->addElement('file', 'import_file', get_lang('ImportFileLocation')); |
@@ -462,7 +462,10 @@ |
||
462 | 462 | <blockquote> |
463 | 463 | <pre> |
464 | 464 | <b>UserName</b>;LastName;FirstName;Email;NewUserName;Password;AuthSource;OfficialCode;PhoneNumber;Status;ExpiryDate;Active;Language;Courses;ClassId; |
465 | - xxx;xxx;xxx;xxx;xxx;xxx;xxx;xxx;xxx;user/teacher/drh;0000-00-00 00:00:00;0/1;xxx;<span style="color:red;"><?php if (count($list_reponse) > 0) echo implode(';', $list_reponse).';'; ?></span>xxx1|xxx2|xxx3;1;<br /> |
|
465 | + xxx;xxx;xxx;xxx;xxx;xxx;xxx;xxx;xxx;user/teacher/drh;0000-00-00 00:00:00;0/1;xxx;<span style="color:red;"><?php if (count($list_reponse) > 0) { |
|
466 | + echo implode(';', $list_reponse).';'; |
|
467 | +} |
|
468 | +?></span>xxx1|xxx2|xxx3;1;<br /> |
|
466 | 469 | </pre> |
467 | 470 | </blockquote> |
468 | 471 | <p><?php |
@@ -1,9 +1,9 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /* For licensing terms, see /license.txt */ |
3 | 3 | /** |
4 | - * This tool allows platform admins to add users by uploading a CSV or XML file |
|
5 | - * @package chamilo.admin |
|
6 | - */ |
|
4 | + * This tool allows platform admins to add users by uploading a CSV or XML file |
|
5 | + * @package chamilo.admin |
|
6 | + */ |
|
7 | 7 | |
8 | 8 | /** |
9 | 9 | * Validate the imported data. |
@@ -60,8 +60,8 @@ discard block |
||
60 | 60 | $user['error'] = get_lang('UserNameNotAvailable'); |
61 | 61 | $errors[] = $user; |
62 | 62 | } |
63 | - } |
|
64 | - } |
|
63 | + } |
|
64 | + } |
|
65 | 65 | |
66 | 66 | // 3. Check status. |
67 | 67 | if (isset($user['Status']) && !api_status_exists($user['Status'])) { |
@@ -242,10 +242,10 @@ discard block |
||
242 | 242 | return $users; |
243 | 243 | } |
244 | 244 | /** |
245 | - * XML-parser: handle start of element |
|
246 | - * @param string $parser Deprecated? |
|
247 | - * @param string $data The data to be parsed |
|
248 | - */ |
|
245 | + * XML-parser: handle start of element |
|
246 | + * @param string $parser Deprecated? |
|
247 | + * @param string $data The data to be parsed |
|
248 | + */ |
|
249 | 249 | function element_start($parser, $data) |
250 | 250 | { |
251 | 251 | $data = api_utf8_decode($data); |
@@ -206,7 +206,7 @@ |
||
206 | 206 | |
207 | 207 | /** |
208 | 208 | * Restores an attendance entry and fallback to attendances rendering |
209 | - * @param int $attendanceId |
|
209 | + * @param int $attendance_id |
|
210 | 210 | */ |
211 | 211 | public function attendance_restore($attendance_id) |
212 | 212 | { |
@@ -636,11 +636,11 @@ |
||
636 | 636 | } |
637 | 637 | $formToDisplay = $form->returnForm(); |
638 | 638 | } else { |
639 | - if (!empty($sessionId)) { |
|
640 | - $sessionInfo = api_get_session_info($sessionId); |
|
641 | - $startDate = $sessionInfo['access_start_date']; |
|
642 | - $endDate = $sessionInfo['access_end_date']; |
|
643 | - } |
|
639 | + if (!empty($sessionId)) { |
|
640 | + $sessionInfo = api_get_session_info($sessionId); |
|
641 | + $startDate = $sessionInfo['access_start_date']; |
|
642 | + $endDate = $sessionInfo['access_end_date']; |
|
643 | + } |
|
644 | 644 | } |
645 | 645 | |
646 | 646 | $attendance = new Attendance(); |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | $attendance->set_attendance_qualify_title($_POST['attendance_qualify_title']); |
61 | 61 | $attendance->set_attendance_weight($_POST['attendance_weight']); |
62 | 62 | $link_to_gradebook = false; |
63 | - if ( isset($_POST['attendance_qualify_gradebook']) && $_POST['attendance_qualify_gradebook'] == 1 ) { |
|
63 | + if (isset($_POST['attendance_qualify_gradebook']) && $_POST['attendance_qualify_gradebook'] == 1) { |
|
64 | 64 | $link_to_gradebook = true; |
65 | 65 | } |
66 | 66 | $attendance->category_id = $_POST['category_id']; |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | ) { |
113 | 113 | $link_to_gradebook = true; |
114 | 114 | } |
115 | - $attendance->attendance_edit($attendance_id,$link_to_gradebook); |
|
115 | + $attendance->attendance_edit($attendance_id, $link_to_gradebook); |
|
116 | 116 | Security::clear_token(); |
117 | 117 | header('location:index.php?action=attendance_list&'.api_get_cidreq()); |
118 | 118 | exit; |
@@ -543,17 +543,17 @@ discard block |
||
543 | 543 | } |
544 | 544 | } |
545 | 545 | $max_cols_per_page = 12; //10 dates + 2 name and number |
546 | - $max_dates_per_page = $max_dates_per_page_original = $max_cols_per_page - 2;//10 |
|
546 | + $max_dates_per_page = $max_dates_per_page_original = $max_cols_per_page - 2; //10 |
|
547 | 547 | $rows = count($data_table); |
548 | 548 | |
549 | 549 | if ($cols > $max_cols_per_page) { |
550 | - $number_tables = round(($cols-2)/$max_dates_per_page); |
|
550 | + $number_tables = round(($cols - 2) / $max_dates_per_page); |
|
551 | 551 | $headers = $data_table[0]; |
552 | 552 | $all = array(); |
553 | 553 | $tables = array(); |
554 | 554 | $changed = 1; |
555 | 555 | |
556 | - for ($i= 0; $i <= $rows; $i++) { |
|
556 | + for ($i = 0; $i <= $rows; $i++) { |
|
557 | 557 | $row = isset($data_table[$i]) ? $data_table[$i] : null; |
558 | 558 | $key = 1; |
559 | 559 | $max_dates_per_page = 10; |
@@ -564,7 +564,7 @@ discard block |
||
564 | 564 | foreach ($item as $value) { |
565 | 565 | if ($count_j >= $max_dates_per_page) { |
566 | 566 | $key++; |
567 | - $max_dates_per_page = $max_dates_per_page_original*$key; |
|
567 | + $max_dates_per_page = $max_dates_per_page_original * $key; |
|
568 | 568 | //magic hack |
569 | 569 | $tables[$key][$i][] = $tables[1][$i][0]; |
570 | 570 | $tables[$key][$i][] = $tables[1][$i][1]; |
@@ -622,8 +622,8 @@ discard block |
||
622 | 622 | $form = new FormValidator( |
623 | 623 | 'search', |
624 | 624 | 'post', |
625 | - api_get_self() . '?' . api_get_cidreq( |
|
626 | - ) . '&action=calendar_logins' |
|
625 | + api_get_self().'?'.api_get_cidreq( |
|
626 | + ).'&action=calendar_logins' |
|
627 | 627 | ); |
628 | 628 | $form->addDateRangePicker('range', get_lang('DateRange')); |
629 | 629 | $form->addButton('submit', get_lang('Submit')); |
@@ -529,10 +529,11 @@ |
||
529 | 529 | $result['full_name'] = api_get_person_name($user['firstname'], $user['lastname']); |
530 | 530 | foreach ($data_array['attendant_calendar'] as $class_day) { |
531 | 531 | if ($class_day['done_attendance'] == 1) { |
532 | - if ($data_users_presence[$user['user_id']][$class_day['id']]['presence'] == 1) |
|
533 | - $result[$class_day['id']] = get_lang('UserAttendedSymbol'); |
|
534 | - else |
|
535 | - $result[$class_day['id']] = '<span style="color:red">'.get_lang('UserNotAttendedSymbol').'</span>'; |
|
532 | + if ($data_users_presence[$user['user_id']][$class_day['id']]['presence'] == 1) { |
|
533 | + $result[$class_day['id']] = get_lang('UserAttendedSymbol'); |
|
534 | + } else { |
|
535 | + $result[$class_day['id']] = '<span style="color:red">'.get_lang('UserNotAttendedSymbol').'</span>'; |
|
536 | + } |
|
536 | 537 | } else { |
537 | 538 | $result[$class_day['id']] = " "; |
538 | 539 | } |
@@ -10,7 +10,7 @@ |
||
10 | 10 | require_once api_get_path(SYS_PATH).'main/auth/external_login/functions.inc.php'; |
11 | 11 | |
12 | 12 | /** |
13 | -* @return true if cas is configured |
|
13 | +* @return boolean if cas is configured |
|
14 | 14 | * |
15 | 15 | **/ |
16 | 16 | function cas_configured() { |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | * |
15 | 15 | **/ |
16 | 16 | function cas_configured() { |
17 | - global $cas_auth_ver, $cas_auth_server, $cas_auth_port, $cas_auth_uri; |
|
17 | + global $cas_auth_ver, $cas_auth_server, $cas_auth_port, $cas_auth_uri; |
|
18 | 18 | $res = false; |
19 | 19 | if (!empty($cas_auth_ver) && !empty($cas_auth_server) && !empty($cas_auth_port)) { |
20 | 20 | $res = true; |
@@ -32,23 +32,23 @@ discard block |
||
32 | 32 | |
33 | 33 | function cas_is_authenticated() |
34 | 34 | { |
35 | - global $cas_auth_ver, $cas_auth_server, $cas_auth_port, $cas_auth_uri; |
|
36 | - global $PHPCAS_CLIENT; |
|
37 | - global $logout; |
|
35 | + global $cas_auth_ver, $cas_auth_server, $cas_auth_port, $cas_auth_uri; |
|
36 | + global $PHPCAS_CLIENT; |
|
37 | + global $logout; |
|
38 | 38 | |
39 | 39 | if (!cas_configured()) { |
40 | 40 | return; |
41 | 41 | } |
42 | 42 | |
43 | - if (!is_object($PHPCAS_CLIENT)) { |
|
44 | - phpCAS::client($cas_auth_ver,$cas_auth_server,$cas_auth_port,$cas_auth_uri); |
|
45 | - phpCAS::setNoCasServerValidation(); |
|
46 | - } |
|
47 | - $auth = phpCAS::checkAuthentication(); |
|
43 | + if (!is_object($PHPCAS_CLIENT)) { |
|
44 | + phpCAS::client($cas_auth_ver,$cas_auth_server,$cas_auth_port,$cas_auth_uri); |
|
45 | + phpCAS::setNoCasServerValidation(); |
|
46 | + } |
|
47 | + $auth = phpCAS::checkAuthentication(); |
|
48 | 48 | |
49 | - if ($auth) { |
|
50 | - $login= trim(phpCAS::getUser()); |
|
51 | - /* |
|
49 | + if ($auth) { |
|
50 | + $login= trim(phpCAS::getUser()); |
|
51 | + /* |
|
52 | 52 | Get user attributes. Here are the attributes for crdp platform |
53 | 53 | sn => name |
54 | 54 | ENTPersonMailInterne => mail |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | ENTPersonProfils => profil |
57 | 57 | givenName => first name |
58 | 58 | */ |
59 | - /*$user=phpCAS::getAttributes(); |
|
59 | + /*$user=phpCAS::getAttributes(); |
|
60 | 60 | $firstName = trim($user['givenName']); |
61 | 61 | $lastName = trim($user['sn']); |
62 | 62 | $login = trim($user['ENTPersonAlias']); |
@@ -79,54 +79,54 @@ discard block |
||
79 | 79 | default: |
80 | 80 | $status=5; // Student |
81 | 81 | }*/ |
82 | - if (!$logout){ |
|
83 | - // get user info from username |
|
84 | - $tab_user_info = api_get_user_info($login); |
|
85 | - |
|
86 | - // user found in the chamilo database |
|
87 | - if (is_array($tab_user_info)) { |
|
88 | - // if option is on we update user automatically from ldap server |
|
89 | - if (api_get_setting("update_user_info_cas_with_ldap") == "true") { |
|
82 | + if (!$logout){ |
|
83 | + // get user info from username |
|
84 | + $tab_user_info = api_get_user_info($login); |
|
85 | + |
|
86 | + // user found in the chamilo database |
|
87 | + if (is_array($tab_user_info)) { |
|
88 | + // if option is on we update user automatically from ldap server |
|
89 | + if (api_get_setting("update_user_info_cas_with_ldap") == "true") { |
|
90 | 90 | $ldapuser = extldap_authenticate($login, 'nopass', true); |
91 | 91 | if ($ldapuser !== false) { |
92 | 92 | $chamilo_user = extldap_get_chamilo_user($ldapuser); |
93 | 93 | $chamilo_user['user_id'] = $tab_user_info['user_id']; |
94 | 94 | $chamilo_user['status'] = $tab_user_info['status']; |
95 | - UserManager::update_user ($chamilo_user["user_id"], $chamilo_user["firstname"], $chamilo_user["lastname"], $login, null, null, $chamilo_user["email"], $chamilo_user["status"], '', '', '', '', 1, null, 0, null,'') ; |
|
96 | - } |
|
97 | - } |
|
98 | - return $login; |
|
99 | - } |
|
100 | - // user not found |
|
101 | - else { |
|
102 | - // if option is on we can ADD user automatically from ldap server or by modify own profil |
|
103 | - $user_added = false; |
|
104 | - switch (api_get_setting("cas_add_user_activate")) { |
|
105 | - case PLATFORM_AUTH_SOURCE : |
|
106 | - // user will have to modify firstname, lastname, email in chamilo profil edit |
|
107 | - $userdata = get_lang("EditInProfil"); |
|
108 | - UserManager::create_user($userdata, $userdata, '5', $userdata, $login, 'casplaceholder', '','','','',CAS_AUTH_SOURCE); |
|
109 | - $user_added = $login; |
|
110 | - break; |
|
111 | - case LDAP_AUTH_SOURCE : |
|
112 | - // user info are read from ldap connexion |
|
113 | - // get user info from ldap server |
|
114 | - // user has already been authenticated by CAS |
|
115 | - // If user not found in LDAP, user not created |
|
116 | - $ldapuser = extldap_authenticate($login, 'nopass', true); |
|
117 | - if ($ldapuser !== false) { |
|
118 | - $chamilo_user = extldap_get_chamilo_user($ldapuser); |
|
95 | + UserManager::update_user ($chamilo_user["user_id"], $chamilo_user["firstname"], $chamilo_user["lastname"], $login, null, null, $chamilo_user["email"], $chamilo_user["status"], '', '', '', '', 1, null, 0, null,'') ; |
|
96 | + } |
|
97 | + } |
|
98 | + return $login; |
|
99 | + } |
|
100 | + // user not found |
|
101 | + else { |
|
102 | + // if option is on we can ADD user automatically from ldap server or by modify own profil |
|
103 | + $user_added = false; |
|
104 | + switch (api_get_setting("cas_add_user_activate")) { |
|
105 | + case PLATFORM_AUTH_SOURCE : |
|
106 | + // user will have to modify firstname, lastname, email in chamilo profil edit |
|
107 | + $userdata = get_lang("EditInProfil"); |
|
108 | + UserManager::create_user($userdata, $userdata, '5', $userdata, $login, 'casplaceholder', '','','','',CAS_AUTH_SOURCE); |
|
109 | + $user_added = $login; |
|
110 | + break; |
|
111 | + case LDAP_AUTH_SOURCE : |
|
112 | + // user info are read from ldap connexion |
|
113 | + // get user info from ldap server |
|
114 | + // user has already been authenticated by CAS |
|
115 | + // If user not found in LDAP, user not created |
|
116 | + $ldapuser = extldap_authenticate($login, 'nopass', true); |
|
117 | + if ($ldapuser !== false) { |
|
118 | + $chamilo_user = extldap_get_chamilo_user($ldapuser); |
|
119 | 119 | $chamilo_user['username'] = $login; |
120 | 120 | $chamilo_user['auth_source'] = CAS_AUTH_SOURCE; |
121 | 121 | $chamilo_uid = external_add_user($chamilo_user); |
122 | - $user_added = $login; |
|
123 | - } |
|
124 | - break; |
|
125 | - default : break; |
|
126 | - } |
|
127 | - return $user_added; |
|
128 | - } |
|
129 | - } |
|
122 | + $user_added = $login; |
|
123 | + } |
|
124 | + break; |
|
125 | + default : break; |
|
126 | + } |
|
127 | + return $user_added; |
|
128 | + } |
|
129 | + } |
|
130 | 130 | // //If the user is in the dokeos database and we are ,not in a logout request, we upgrade his infomration by ldap |
131 | 131 | // if (! $logout){ |
132 | 132 | // $user_table = Database::get_main_table(TABLE_MAIN_USER); |
@@ -148,10 +148,10 @@ discard block |
||
148 | 148 | // |
149 | 149 | // } |
150 | 150 | // } |
151 | - return $login; |
|
151 | + return $login; |
|
152 | 152 | } else { |
153 | - return false; |
|
154 | - } |
|
153 | + return false; |
|
154 | + } |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | /** |
@@ -41,13 +41,13 @@ discard block |
||
41 | 41 | } |
42 | 42 | |
43 | 43 | if (!is_object($PHPCAS_CLIENT)) { |
44 | - phpCAS::client($cas_auth_ver,$cas_auth_server,$cas_auth_port,$cas_auth_uri); |
|
44 | + phpCAS::client($cas_auth_ver, $cas_auth_server, $cas_auth_port, $cas_auth_uri); |
|
45 | 45 | phpCAS::setNoCasServerValidation(); |
46 | 46 | } |
47 | 47 | $auth = phpCAS::checkAuthentication(); |
48 | 48 | |
49 | 49 | if ($auth) { |
50 | - $login= trim(phpCAS::getUser()); |
|
50 | + $login = trim(phpCAS::getUser()); |
|
51 | 51 | /* |
52 | 52 | Get user attributes. Here are the attributes for crdp platform |
53 | 53 | sn => name |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | default: |
80 | 80 | $status=5; // Student |
81 | 81 | }*/ |
82 | - if (!$logout){ |
|
82 | + if (!$logout) { |
|
83 | 83 | // get user info from username |
84 | 84 | $tab_user_info = api_get_user_info($login); |
85 | 85 | |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | $chamilo_user = extldap_get_chamilo_user($ldapuser); |
93 | 93 | $chamilo_user['user_id'] = $tab_user_info['user_id']; |
94 | 94 | $chamilo_user['status'] = $tab_user_info['status']; |
95 | - UserManager::update_user ($chamilo_user["user_id"], $chamilo_user["firstname"], $chamilo_user["lastname"], $login, null, null, $chamilo_user["email"], $chamilo_user["status"], '', '', '', '', 1, null, 0, null,'') ; |
|
95 | + UserManager::update_user($chamilo_user["user_id"], $chamilo_user["firstname"], $chamilo_user["lastname"], $login, null, null, $chamilo_user["email"], $chamilo_user["status"], '', '', '', '', 1, null, 0, null, ''); |
|
96 | 96 | } |
97 | 97 | } |
98 | 98 | return $login; |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | case PLATFORM_AUTH_SOURCE : |
106 | 106 | // user will have to modify firstname, lastname, email in chamilo profil edit |
107 | 107 | $userdata = get_lang("EditInProfil"); |
108 | - UserManager::create_user($userdata, $userdata, '5', $userdata, $login, 'casplaceholder', '','','','',CAS_AUTH_SOURCE); |
|
108 | + UserManager::create_user($userdata, $userdata, '5', $userdata, $login, 'casplaceholder', '', '', '', '', CAS_AUTH_SOURCE); |
|
109 | 109 | $user_added = $login; |
110 | 110 | break; |
111 | 111 | case LDAP_AUTH_SOURCE : |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | * |
164 | 164 | * @see online_logout() |
165 | 165 | */ |
166 | -function cas_logout($uinfo=null, $location=null) |
|
166 | +function cas_logout($uinfo = null, $location = null) |
|
167 | 167 | { |
168 | 168 | global $cas_auth_ver, $cas_auth_server, $cas_auth_port, $cas_auth_uri; |
169 | 169 | global $PHPCAS_CLIENT; |
@@ -516,7 +516,7 @@ discard block |
||
516 | 516 | /** |
517 | 517 | * Logs a string in debug mode. |
518 | 518 | * |
519 | - * @param $str the string to write |
|
519 | + * @param string $str the string to write |
|
520 | 520 | * |
521 | 521 | * @private |
522 | 522 | */ |
@@ -537,7 +537,7 @@ discard block |
||
537 | 537 | * This method is used by interface methods to print an error and where the function |
538 | 538 | * was originally called from. |
539 | 539 | * |
540 | - * @param $msg the message to print |
|
540 | + * @param string $msg the message to print |
|
541 | 541 | * |
542 | 542 | * @private |
543 | 543 | */ |
@@ -664,7 +664,7 @@ discard block |
||
664 | 664 | /** |
665 | 665 | * This method returns the phpCAS version. |
666 | 666 | * |
667 | - * @return the phpCAS version. |
|
667 | + * @return string phpCAS version. |
|
668 | 668 | */ |
669 | 669 | function getVersion() { |
670 | 670 | return PHPCAS_VERSION; |
@@ -1070,7 +1070,7 @@ discard block |
||
1070 | 1070 | * @warning should not be called only after phpCAS::forceAuthentication() |
1071 | 1071 | * or phpCAS::checkAuthentication(). |
1072 | 1072 | * |
1073 | - * @return the login name of the authenticated user |
|
1073 | + * @return string login name of the authenticated user |
|
1074 | 1074 | */ |
1075 | 1075 | function getUser() { |
1076 | 1076 | global $PHPCAS_CLIENT, $PHPCAS_AUTH_CHECK_CALL; |
@@ -33,14 +33,14 @@ discard block |
||
33 | 33 | // hack by Vangelis Haniotakis to handle the absence of $_SERVER['REQUEST_URI'] in IIS |
34 | 34 | // |
35 | 35 | if (!$_SERVER['REQUEST_URI']) { |
36 | - $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] . '?' . $_SERVER['QUERY_STRING']; |
|
36 | + $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] . '?' . $_SERVER['QUERY_STRING']; |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | // |
40 | 40 | // another one by Vangelis Haniotakis also to make phpCAS work with PHP5 |
41 | 41 | // |
42 | 42 | if (version_compare(PHP_VERSION, '5', '>=')) { |
43 | - require_once (dirname(__FILE__) . '/CAS/domxml-php4-to-php5.php'); |
|
43 | + require_once (dirname(__FILE__) . '/CAS/domxml-php4-to-php5.php'); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | /** |
@@ -282,10 +282,10 @@ discard block |
||
282 | 282 | * @hideinitializer |
283 | 283 | */ |
284 | 284 | $GLOBALS['PHPCAS_INIT_CALL'] = array ( |
285 | - 'done' => FALSE, |
|
286 | - 'file' => '?', |
|
287 | - 'line' => -1, |
|
288 | - 'method' => '?' |
|
285 | + 'done' => FALSE, |
|
286 | + 'file' => '?', |
|
287 | + 'line' => -1, |
|
288 | + 'method' => '?' |
|
289 | 289 | ); |
290 | 290 | |
291 | 291 | /** |
@@ -295,11 +295,11 @@ discard block |
||
295 | 295 | * @hideinitializer |
296 | 296 | */ |
297 | 297 | $GLOBALS['PHPCAS_AUTH_CHECK_CALL'] = array ( |
298 | - 'done' => FALSE, |
|
299 | - 'file' => '?', |
|
300 | - 'line' => -1, |
|
301 | - 'method' => '?', |
|
302 | - 'result' => FALSE |
|
298 | + 'done' => FALSE, |
|
299 | + 'file' => '?', |
|
300 | + 'line' => -1, |
|
301 | + 'method' => '?', |
|
302 | + 'result' => FALSE |
|
303 | 303 | ); |
304 | 304 | |
305 | 305 | /** |
@@ -308,9 +308,9 @@ discard block |
||
308 | 308 | * @hideinitializer |
309 | 309 | */ |
310 | 310 | $GLOBALS['PHPCAS_DEBUG'] = array ( |
311 | - 'filename' => '/tmp/cas.log', |
|
312 | - 'indent' => 0, |
|
313 | - 'unique_id' => '' |
|
311 | + 'filename' => '/tmp/cas.log', |
|
312 | + 'indent' => 0, |
|
313 | + 'unique_id' => '' |
|
314 | 314 | ); |
315 | 315 | |
316 | 316 | /** @} */ |
@@ -340,1141 +340,1141 @@ discard block |
||
340 | 340 | |
341 | 341 | class phpCAS { |
342 | 342 | |
343 | - // ######################################################################## |
|
344 | - // INITIALIZATION |
|
345 | - // ######################################################################## |
|
346 | - |
|
347 | - /** |
|
348 | - * @addtogroup publicInit |
|
349 | - * @{ |
|
350 | - */ |
|
351 | - |
|
352 | - /** |
|
353 | - * phpCAS client initializer. |
|
354 | - * @note Only one of the phpCAS::client() and phpCAS::proxy functions should be |
|
355 | - * called, only once, and before all other methods (except phpCAS::getVersion() |
|
356 | - * and phpCAS::setDebug()). |
|
357 | - * |
|
358 | - * @param $server_version the version of the CAS server |
|
359 | - * @param $server_hostname the hostname of the CAS server |
|
360 | - * @param $server_port the port the CAS server is running on |
|
361 | - * @param $server_uri the URI the CAS server is responding on |
|
362 | - * @param $start_session Have phpCAS start PHP sessions (default true) |
|
363 | - * |
|
364 | - * @return a newly created CASClient object |
|
365 | - */ |
|
366 | - function client($server_version, $server_hostname, $server_port, $server_uri, $start_session = true) { |
|
367 | - global $PHPCAS_CLIENT, $PHPCAS_INIT_CALL; |
|
368 | - |
|
369 | - phpCAS :: traceBegin(); |
|
370 | - if (is_object($PHPCAS_CLIENT)) { |
|
371 | - phpCAS :: error($PHPCAS_INIT_CALL['method'] . '() has already been called (at ' . $PHPCAS_INIT_CALL['file'] . ':' . $PHPCAS_INIT_CALL['line'] . ')'); |
|
372 | - } |
|
373 | - if (gettype($server_version) != 'string') { |
|
374 | - phpCAS :: error('type mismatched for parameter $server_version (should be `string\')'); |
|
375 | - } |
|
376 | - if (gettype($server_hostname) != 'string') { |
|
377 | - phpCAS :: error('type mismatched for parameter $server_hostname (should be `string\')'); |
|
378 | - } |
|
379 | - if (gettype($server_port) != 'integer') { |
|
380 | - phpCAS :: error('type mismatched for parameter $server_port (should be `integer\')'); |
|
381 | - } |
|
382 | - if (gettype($server_uri) != 'string') { |
|
383 | - phpCAS :: error('type mismatched for parameter $server_uri (should be `string\')'); |
|
384 | - } |
|
385 | - |
|
386 | - // store where the initializer is called from |
|
387 | - $dbg = phpCAS :: backtrace(); |
|
388 | - $PHPCAS_INIT_CALL = array ( |
|
389 | - 'done' => TRUE, |
|
390 | - 'file' => $dbg[0]['file'], |
|
391 | - 'line' => $dbg[0]['line'], |
|
392 | - 'method' => __CLASS__ . '::' . __FUNCTION__ |
|
393 | - ); |
|
394 | - |
|
395 | - // initialize the global object $PHPCAS_CLIENT |
|
396 | - $PHPCAS_CLIENT = new CASClient($server_version, FALSE /*proxy*/ |
|
397 | - , $server_hostname, $server_port, $server_uri, $start_session); |
|
398 | - phpCAS :: traceEnd(); |
|
399 | - } |
|
400 | - |
|
401 | - /** |
|
402 | - * phpCAS proxy initializer. |
|
403 | - * @note Only one of the phpCAS::client() and phpCAS::proxy functions should be |
|
404 | - * called, only once, and before all other methods (except phpCAS::getVersion() |
|
405 | - * and phpCAS::setDebug()). |
|
406 | - * |
|
407 | - * @param $server_version the version of the CAS server |
|
408 | - * @param $server_hostname the hostname of the CAS server |
|
409 | - * @param $server_port the port the CAS server is running on |
|
410 | - * @param $server_uri the URI the CAS server is responding on |
|
411 | - * @param $start_session Have phpCAS start PHP sessions (default true) |
|
412 | - * |
|
413 | - * @return a newly created CASClient object |
|
414 | - */ |
|
415 | - function proxy($server_version, $server_hostname, $server_port, $server_uri, $start_session = true) { |
|
416 | - global $PHPCAS_CLIENT, $PHPCAS_INIT_CALL; |
|
417 | - |
|
418 | - phpCAS :: traceBegin(); |
|
419 | - if (is_object($PHPCAS_CLIENT)) { |
|
420 | - phpCAS :: error($PHPCAS_INIT_CALL['method'] . '() has already been called (at ' . $PHPCAS_INIT_CALL['file'] . ':' . $PHPCAS_INIT_CALL['line'] . ')'); |
|
421 | - } |
|
422 | - if (gettype($server_version) != 'string') { |
|
423 | - phpCAS :: error('type mismatched for parameter $server_version (should be `string\')'); |
|
424 | - } |
|
425 | - if (gettype($server_hostname) != 'string') { |
|
426 | - phpCAS :: error('type mismatched for parameter $server_hostname (should be `string\')'); |
|
427 | - } |
|
428 | - if (gettype($server_port) != 'integer') { |
|
429 | - phpCAS :: error('type mismatched for parameter $server_port (should be `integer\')'); |
|
430 | - } |
|
431 | - if (gettype($server_uri) != 'string') { |
|
432 | - phpCAS :: error('type mismatched for parameter $server_uri (should be `string\')'); |
|
433 | - } |
|
434 | - |
|
435 | - // store where the initialzer is called from |
|
436 | - $dbg = phpCAS :: backtrace(); |
|
437 | - $PHPCAS_INIT_CALL = array ( |
|
438 | - 'done' => TRUE, |
|
439 | - 'file' => $dbg[0]['file'], |
|
440 | - 'line' => $dbg[0]['line'], |
|
441 | - 'method' => __CLASS__ . '::' . __FUNCTION__ |
|
442 | - ); |
|
443 | - |
|
444 | - // initialize the global object $PHPCAS_CLIENT |
|
445 | - $PHPCAS_CLIENT = new CASClient($server_version, TRUE /*proxy*/ |
|
446 | - , $server_hostname, $server_port, $server_uri, $start_session); |
|
447 | - phpCAS :: traceEnd(); |
|
448 | - } |
|
449 | - |
|
450 | - /** @} */ |
|
451 | - // ######################################################################## |
|
452 | - // DEBUGGING |
|
453 | - // ######################################################################## |
|
454 | - |
|
455 | - /** |
|
456 | - * @addtogroup publicDebug |
|
457 | - * @{ |
|
458 | - */ |
|
459 | - |
|
460 | - /** |
|
461 | - * Set/unset debug mode |
|
462 | - * |
|
463 | - * @param $filename the name of the file used for logging, or FALSE to stop debugging. |
|
464 | - */ |
|
465 | - function setDebug($filename = '') { |
|
466 | - global $PHPCAS_DEBUG; |
|
467 | - |
|
468 | - if ($filename != FALSE && gettype($filename) != 'string') { |
|
469 | - phpCAS :: error('type mismatched for parameter $dbg (should be FALSE or the name of the log file)'); |
|
470 | - } |
|
471 | - |
|
472 | - if (empty ($filename)) { |
|
473 | - if (preg_match('/^Win.*/', getenv('OS'))) { |
|
474 | - if (isset ($_ENV['TMP'])) { |
|
475 | - $debugDir = $_ENV['TMP'] . '/'; |
|
476 | - } else |
|
477 | - if (isset ($_ENV['TEMP'])) { |
|
478 | - $debugDir = $_ENV['TEMP'] . '/'; |
|
479 | - } else { |
|
480 | - $debugDir = ''; |
|
481 | - } |
|
482 | - } else { |
|
483 | - $debugDir = DEFAULT_DEBUG_DIR; |
|
484 | - } |
|
485 | - $filename = $debugDir . 'phpCAS.log'; |
|
486 | - } |
|
487 | - |
|
488 | - if (empty ($PHPCAS_DEBUG['unique_id'])) { |
|
489 | - $PHPCAS_DEBUG['unique_id'] = substr(strtoupper(md5(uniqid(''))), 0, 4); |
|
490 | - } |
|
491 | - |
|
492 | - $PHPCAS_DEBUG['filename'] = $filename; |
|
493 | - |
|
494 | - phpCAS :: trace('START ******************'); |
|
495 | - } |
|
496 | - |
|
497 | - /** @} */ |
|
498 | - /** |
|
499 | - * @addtogroup internalDebug |
|
500 | - * @{ |
|
501 | - */ |
|
502 | - |
|
503 | - /** |
|
504 | - * This method is a wrapper for debug_backtrace() that is not available |
|
505 | - * in all PHP versions (>= 4.3.0 only) |
|
506 | - */ |
|
507 | - function backtrace() { |
|
508 | - if (function_exists('debug_backtrace')) { |
|
509 | - return debug_backtrace(); |
|
510 | - } else { |
|
511 | - // poor man's hack ... but it does work ... |
|
512 | - return array (); |
|
513 | - } |
|
514 | - } |
|
515 | - |
|
516 | - /** |
|
517 | - * Logs a string in debug mode. |
|
518 | - * |
|
519 | - * @param $str the string to write |
|
520 | - * |
|
521 | - * @private |
|
522 | - */ |
|
523 | - function log($str) { |
|
524 | - $indent_str = "."; |
|
525 | - global $PHPCAS_DEBUG; |
|
526 | - |
|
527 | - if ($PHPCAS_DEBUG['filename']) { |
|
528 | - for ($i = 0; $i < $PHPCAS_DEBUG['indent']; $i++) { |
|
529 | - $indent_str .= '| '; |
|
530 | - } |
|
531 | - error_log($PHPCAS_DEBUG['unique_id'] . ' ' . $indent_str . $str . "\n", 3, $PHPCAS_DEBUG['filename']); |
|
532 | - } |
|
533 | - |
|
534 | - } |
|
535 | - |
|
536 | - /** |
|
537 | - * This method is used by interface methods to print an error and where the function |
|
538 | - * was originally called from. |
|
539 | - * |
|
540 | - * @param $msg the message to print |
|
541 | - * |
|
542 | - * @private |
|
543 | - */ |
|
544 | - function error($msg) { |
|
545 | - $dbg = phpCAS :: backtrace(); |
|
546 | - $function = '?'; |
|
547 | - $file = '?'; |
|
548 | - $line = '?'; |
|
549 | - if (is_array($dbg)) { |
|
550 | - for ($i = 1; $i < sizeof($dbg); $i++) { |
|
551 | - if (is_array($dbg[$i])) { |
|
552 | - if ($dbg[$i]['class'] == __CLASS__) { |
|
553 | - $function = $dbg[$i]['function']; |
|
554 | - $file = $dbg[$i]['file']; |
|
555 | - $line = $dbg[$i]['line']; |
|
556 | - } |
|
557 | - } |
|
558 | - } |
|
559 | - } |
|
560 | - echo "<br />\n<b>phpCAS error</b>: <font color=\"FF0000\"><b>" . __CLASS__ . "::" . $function . '(): ' . htmlentities($msg) . "</b></font> in <b>" . $file . "</b> on line <b>" . $line . "</b><br />\n"; |
|
561 | - phpCAS :: trace($msg); |
|
562 | - phpCAS :: traceExit(); |
|
563 | - exit (); |
|
564 | - } |
|
565 | - |
|
566 | - /** |
|
567 | - * This method is used to log something in debug mode. |
|
568 | - */ |
|
569 | - function trace($str) { |
|
570 | - $dbg = phpCAS :: backtrace(); |
|
571 | - phpCAS :: log($str . ' [' . basename($dbg[1]['file']) . ':' . $dbg[1]['line'] . ']'); |
|
572 | - } |
|
573 | - |
|
574 | - /** |
|
575 | - * This method is used to indicate the start of the execution of a function in debug mode. |
|
576 | - */ |
|
577 | - function traceBegin() { |
|
578 | - global $PHPCAS_DEBUG; |
|
579 | - |
|
580 | - $dbg = phpCAS :: backtrace(); |
|
581 | - $str = '=> '; |
|
582 | - if (!empty ($dbg[2]['class'])) { |
|
583 | - $str .= $dbg[2]['class'] . '::'; |
|
584 | - } |
|
585 | - $str .= $dbg[2]['function'] . '('; |
|
586 | - if (is_array($dbg[2]['args'])) { |
|
587 | - foreach ($dbg[2]['args'] as $index => $arg) { |
|
588 | - if ($index != 0) { |
|
589 | - $str .= ', '; |
|
590 | - } |
|
591 | - $str .= str_replace("\n", "", var_export($arg, TRUE)); |
|
592 | - } |
|
593 | - } |
|
594 | - $str .= ') [' . basename($dbg[2]['file']) . ':' . $dbg[2]['line'] . ']'; |
|
595 | - phpCAS :: log($str); |
|
596 | - $PHPCAS_DEBUG['indent']++; |
|
597 | - } |
|
598 | - |
|
599 | - /** |
|
600 | - * This method is used to indicate the end of the execution of a function in debug mode. |
|
601 | - * |
|
602 | - * @param $res the result of the function |
|
603 | - */ |
|
604 | - function traceEnd($res = '') { |
|
605 | - global $PHPCAS_DEBUG; |
|
606 | - |
|
607 | - $PHPCAS_DEBUG['indent']--; |
|
608 | - $dbg = phpCAS :: backtrace(); |
|
609 | - $str = ''; |
|
610 | - $str .= '<= ' . str_replace("\n", "", var_export($res, TRUE)); |
|
611 | - phpCAS :: log($str); |
|
612 | - } |
|
613 | - |
|
614 | - /** |
|
615 | - * This method is used to indicate the end of the execution of the program |
|
616 | - */ |
|
617 | - function traceExit() { |
|
618 | - global $PHPCAS_DEBUG; |
|
619 | - |
|
620 | - phpCAS :: log('exit()'); |
|
621 | - while ($PHPCAS_DEBUG['indent'] > 0) { |
|
622 | - phpCAS :: log('-'); |
|
623 | - $PHPCAS_DEBUG['indent']--; |
|
624 | - } |
|
625 | - } |
|
626 | - |
|
627 | - /** @} */ |
|
628 | - // ######################################################################## |
|
629 | - // INTERNATIONALIZATION |
|
630 | - // ######################################################################## |
|
631 | - /** |
|
632 | - * @addtogroup publicLang |
|
633 | - * @{ |
|
634 | - */ |
|
635 | - |
|
636 | - /** |
|
637 | - * This method is used to set the language used by phpCAS. |
|
638 | - * @note Can be called only once. |
|
639 | - * |
|
640 | - * @param $lang a string representing the language. |
|
641 | - * |
|
642 | - * @sa PHPCAS_LANG_FRENCH, PHPCAS_LANG_ENGLISH |
|
643 | - */ |
|
644 | - function setLang($lang) { |
|
645 | - global $PHPCAS_CLIENT; |
|
646 | - if (!is_object($PHPCAS_CLIENT)) { |
|
647 | - phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()'); |
|
648 | - } |
|
649 | - if (gettype($lang) != 'string') { |
|
650 | - phpCAS :: error('type mismatched for parameter $lang (should be `string\')'); |
|
651 | - } |
|
652 | - $PHPCAS_CLIENT->setLang($lang); |
|
653 | - } |
|
654 | - |
|
655 | - /** @} */ |
|
656 | - // ######################################################################## |
|
657 | - // VERSION |
|
658 | - // ######################################################################## |
|
659 | - /** |
|
660 | - * @addtogroup public |
|
661 | - * @{ |
|
662 | - */ |
|
663 | - |
|
664 | - /** |
|
665 | - * This method returns the phpCAS version. |
|
666 | - * |
|
667 | - * @return the phpCAS version. |
|
668 | - */ |
|
669 | - function getVersion() { |
|
670 | - return PHPCAS_VERSION; |
|
671 | - } |
|
672 | - |
|
673 | - /** @} */ |
|
674 | - // ######################################################################## |
|
675 | - // HTML OUTPUT |
|
676 | - // ######################################################################## |
|
677 | - /** |
|
678 | - * @addtogroup publicOutput |
|
679 | - * @{ |
|
680 | - */ |
|
681 | - |
|
682 | - /** |
|
683 | - * This method sets the HTML header used for all outputs. |
|
684 | - * |
|
685 | - * @param $header the HTML header. |
|
686 | - */ |
|
687 | - function setHTMLHeader($header) { |
|
688 | - global $PHPCAS_CLIENT; |
|
689 | - if (!is_object($PHPCAS_CLIENT)) { |
|
690 | - phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()'); |
|
691 | - } |
|
692 | - if (gettype($header) != 'string') { |
|
693 | - phpCAS :: error('type mismatched for parameter $header (should be `string\')'); |
|
694 | - } |
|
695 | - $PHPCAS_CLIENT->setHTMLHeader($header); |
|
696 | - } |
|
697 | - |
|
698 | - /** |
|
699 | - * This method sets the HTML footer used for all outputs. |
|
700 | - * |
|
701 | - * @param $footer the HTML footer. |
|
702 | - */ |
|
703 | - function setHTMLFooter($footer) { |
|
704 | - global $PHPCAS_CLIENT; |
|
705 | - if (!is_object($PHPCAS_CLIENT)) { |
|
706 | - phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()'); |
|
707 | - } |
|
708 | - if (gettype($footer) != 'string') { |
|
709 | - phpCAS :: error('type mismatched for parameter $footer (should be `string\')'); |
|
710 | - } |
|
711 | - $PHPCAS_CLIENT->setHTMLFooter($footer); |
|
712 | - } |
|
713 | - |
|
714 | - /** @} */ |
|
715 | - // ######################################################################## |
|
716 | - // PGT STORAGE |
|
717 | - // ######################################################################## |
|
718 | - /** |
|
719 | - * @addtogroup publicPGTStorage |
|
720 | - * @{ |
|
721 | - */ |
|
722 | - |
|
723 | - /** |
|
724 | - * This method is used to tell phpCAS to store the response of the |
|
725 | - * CAS server to PGT requests onto the filesystem. |
|
726 | - * |
|
727 | - * @param $format the format used to store the PGT's (`plain' and `xml' allowed) |
|
728 | - * @param $path the path where the PGT's should be stored |
|
729 | - */ |
|
730 | - function setPGTStorageFile($format = '', $path = '') { |
|
731 | - global $PHPCAS_CLIENT, $PHPCAS_AUTH_CHECK_CALL; |
|
732 | - |
|
733 | - phpCAS :: traceBegin(); |
|
734 | - if (!is_object($PHPCAS_CLIENT)) { |
|
735 | - phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()'); |
|
736 | - } |
|
737 | - if (!$PHPCAS_CLIENT->isProxy()) { |
|
738 | - phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()'); |
|
739 | - } |
|
740 | - if ($PHPCAS_AUTH_CHECK_CALL['done']) { |
|
741 | - phpCAS :: error('this method should only be called before ' . $PHPCAS_AUTH_CHECK_CALL['method'] . '() (called at ' . $PHPCAS_AUTH_CHECK_CALL['file'] . ':' . $PHPCAS_AUTH_CHECK_CALL['line'] . ')'); |
|
742 | - } |
|
743 | - if (gettype($format) != 'string') { |
|
744 | - phpCAS :: error('type mismatched for parameter $format (should be `string\')'); |
|
745 | - } |
|
746 | - if (gettype($path) != 'string') { |
|
747 | - phpCAS :: error('type mismatched for parameter $format (should be `string\')'); |
|
748 | - } |
|
749 | - $PHPCAS_CLIENT->setPGTStorageFile($format, $path); |
|
750 | - phpCAS :: traceEnd(); |
|
751 | - } |
|
752 | - |
|
753 | - /** |
|
754 | - * This method is used to tell phpCAS to store the response of the |
|
755 | - * CAS server to PGT requests into a database. |
|
756 | - * @note The connection to the database is done only when needed. |
|
757 | - * As a consequence, bad parameters are detected only when |
|
758 | - * initializing PGT storage, except in debug mode. |
|
759 | - * |
|
760 | - * @param $user the user to access the data with |
|
761 | - * @param $password the user's password |
|
762 | - * @param $database_type the type of the database hosting the data |
|
763 | - * @param $hostname the server hosting the database |
|
764 | - * @param $port the port the server is listening on |
|
765 | - * @param $database the name of the database |
|
766 | - * @param $table the name of the table storing the data |
|
767 | - */ |
|
768 | - function setPGTStorageDB($user, $password, $database_type = '', $hostname = '', $port = 0, $database = '', $table = '') { |
|
769 | - global $PHPCAS_CLIENT, $PHPCAS_AUTH_CHECK_CALL; |
|
770 | - |
|
771 | - phpCAS :: traceBegin(); |
|
772 | - if (!is_object($PHPCAS_CLIENT)) { |
|
773 | - phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()'); |
|
774 | - } |
|
775 | - if (!$PHPCAS_CLIENT->isProxy()) { |
|
776 | - phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()'); |
|
777 | - } |
|
778 | - if ($PHPCAS_AUTH_CHECK_CALL['done']) { |
|
779 | - phpCAS :: error('this method should only be called before ' . $PHPCAS_AUTH_CHECK_CALL['method'] . '() (called at ' . $PHPCAS_AUTH_CHECK_CALL['file'] . ':' . $PHPCAS_AUTH_CHECK_CALL['line'] . ')'); |
|
780 | - } |
|
781 | - if (gettype($user) != 'string') { |
|
782 | - phpCAS :: error('type mismatched for parameter $user (should be `string\')'); |
|
783 | - } |
|
784 | - if (gettype($password) != 'string') { |
|
785 | - phpCAS :: error('type mismatched for parameter $password (should be `string\')'); |
|
786 | - } |
|
787 | - if (gettype($database_type) != 'string') { |
|
788 | - phpCAS :: error('type mismatched for parameter $database_type (should be `string\')'); |
|
789 | - } |
|
790 | - if (gettype($hostname) != 'string') { |
|
791 | - phpCAS :: error('type mismatched for parameter $hostname (should be `string\')'); |
|
792 | - } |
|
793 | - if (gettype($port) != 'integer') { |
|
794 | - phpCAS :: error('type mismatched for parameter $port (should be `integer\')'); |
|
795 | - } |
|
796 | - if (gettype($database) != 'string') { |
|
797 | - phpCAS :: error('type mismatched for parameter $database (should be `string\')'); |
|
798 | - } |
|
799 | - if (gettype($table) != 'string') { |
|
800 | - phpCAS :: error('type mismatched for parameter $table (should be `string\')'); |
|
801 | - } |
|
802 | - $PHPCAS_CLIENT->setPGTStorageDB($user, $password, $database_type, $hostname, $port, $database, $table); |
|
803 | - phpCAS :: traceEnd(); |
|
804 | - } |
|
805 | - |
|
806 | - /** @} */ |
|
807 | - // ######################################################################## |
|
808 | - // ACCESS TO EXTERNAL SERVICES |
|
809 | - // ######################################################################## |
|
810 | - /** |
|
811 | - * @addtogroup publicServices |
|
812 | - * @{ |
|
813 | - */ |
|
814 | - |
|
815 | - /** |
|
816 | - * This method is used to access an HTTP[S] service. |
|
817 | - * |
|
818 | - * @param $url the service to access. |
|
819 | - * @param $err_code an error code Possible values are PHPCAS_SERVICE_OK (on |
|
820 | - * success), PHPCAS_SERVICE_PT_NO_SERVER_RESPONSE, PHPCAS_SERVICE_PT_BAD_SERVER_RESPONSE, |
|
821 | - * PHPCAS_SERVICE_PT_FAILURE, PHPCAS_SERVICE_NOT AVAILABLE. |
|
822 | - * @param $output the output of the service (also used to give an error |
|
823 | - * message on failure). |
|
824 | - * |
|
825 | - * @return TRUE on success, FALSE otherwise (in this later case, $err_code |
|
826 | - * gives the reason why it failed and $output contains an error message). |
|
827 | - */ |
|
828 | - function serviceWeb($url, & $err_code, & $output) { |
|
829 | - global $PHPCAS_CLIENT, $PHPCAS_AUTH_CHECK_CALL; |
|
830 | - |
|
831 | - phpCAS :: traceBegin(); |
|
832 | - if (!is_object($PHPCAS_CLIENT)) { |
|
833 | - phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()'); |
|
834 | - } |
|
835 | - if (!$PHPCAS_CLIENT->isProxy()) { |
|
836 | - phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()'); |
|
837 | - } |
|
838 | - if (!$PHPCAS_AUTH_CHECK_CALL['done']) { |
|
839 | - phpCAS :: error('this method should only be called after the programmer is sure the user has been authenticated (by calling ' . __CLASS__ . '::checkAuthentication() or ' . __CLASS__ . '::forceAuthentication()'); |
|
840 | - } |
|
841 | - if (!$PHPCAS_AUTH_CHECK_CALL['result']) { |
|
842 | - phpCAS :: error('authentication was checked (by ' . $PHPCAS_AUTH_CHECK_CALL['method'] . '() at ' . $PHPCAS_AUTH_CHECK_CALL['file'] . ':' . $PHPCAS_AUTH_CHECK_CALL['line'] . ') but the method returned FALSE'); |
|
843 | - } |
|
844 | - if (gettype($url) != 'string') { |
|
845 | - phpCAS :: error('type mismatched for parameter $url (should be `string\')'); |
|
846 | - } |
|
847 | - |
|
848 | - $res = $PHPCAS_CLIENT->serviceWeb($url, $err_code, $output); |
|
849 | - |
|
850 | - phpCAS :: traceEnd($res); |
|
851 | - return $res; |
|
852 | - } |
|
853 | - |
|
854 | - /** |
|
855 | - * This method is used to access an IMAP/POP3/NNTP service. |
|
856 | - * |
|
857 | - * @param $url a string giving the URL of the service, including the mailing box |
|
858 | - * for IMAP URLs, as accepted by imap_open(). |
|
859 | - * @param $service a string giving for CAS retrieve Proxy ticket |
|
860 | - * @param $flags options given to imap_open(). |
|
861 | - * @param $err_code an error code Possible values are PHPCAS_SERVICE_OK (on |
|
862 | - * success), PHPCAS_SERVICE_PT_NO_SERVER_RESPONSE, PHPCAS_SERVICE_PT_BAD_SERVER_RESPONSE, |
|
863 | - * PHPCAS_SERVICE_PT_FAILURE, PHPCAS_SERVICE_NOT AVAILABLE. |
|
864 | - * @param $err_msg an error message on failure |
|
865 | - * @param $pt the Proxy Ticket (PT) retrieved from the CAS server to access the URL |
|
866 | - * on success, FALSE on error). |
|
867 | - * |
|
868 | - * @return an IMAP stream on success, FALSE otherwise (in this later case, $err_code |
|
869 | - * gives the reason why it failed and $err_msg contains an error message). |
|
870 | - */ |
|
871 | - function serviceMail($url, $service, $flags, & $err_code, & $err_msg, & $pt) { |
|
872 | - global $PHPCAS_CLIENT, $PHPCAS_AUTH_CHECK_CALL; |
|
873 | - |
|
874 | - phpCAS :: traceBegin(); |
|
875 | - if (!is_object($PHPCAS_CLIENT)) { |
|
876 | - phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()'); |
|
877 | - } |
|
878 | - if (!$PHPCAS_CLIENT->isProxy()) { |
|
879 | - phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()'); |
|
880 | - } |
|
881 | - if (!$PHPCAS_AUTH_CHECK_CALL['done']) { |
|
882 | - phpCAS :: error('this method should only be called after the programmer is sure the user has been authenticated (by calling ' . __CLASS__ . '::checkAuthentication() or ' . __CLASS__ . '::forceAuthentication()'); |
|
883 | - } |
|
884 | - if (!$PHPCAS_AUTH_CHECK_CALL['result']) { |
|
885 | - phpCAS :: error('authentication was checked (by ' . $PHPCAS_AUTH_CHECK_CALL['method'] . '() at ' . $PHPCAS_AUTH_CHECK_CALL['file'] . ':' . $PHPCAS_AUTH_CHECK_CALL['line'] . ') but the method returned FALSE'); |
|
886 | - } |
|
887 | - if (gettype($url) != 'string') { |
|
888 | - phpCAS :: error('type mismatched for parameter $url (should be `string\')'); |
|
889 | - } |
|
890 | - |
|
891 | - if (gettype($flags) != 'integer') { |
|
892 | - phpCAS :: error('type mismatched for parameter $flags (should be `integer\')'); |
|
893 | - } |
|
894 | - |
|
895 | - $res = $PHPCAS_CLIENT->serviceMail($url, $service, $flags, $err_code, $err_msg, $pt); |
|
896 | - |
|
897 | - phpCAS :: traceEnd($res); |
|
898 | - return $res; |
|
899 | - } |
|
900 | - |
|
901 | - /** @} */ |
|
902 | - // ######################################################################## |
|
903 | - // AUTHENTICATION |
|
904 | - // ######################################################################## |
|
905 | - /** |
|
906 | - * @addtogroup publicAuth |
|
907 | - * @{ |
|
908 | - */ |
|
909 | - |
|
910 | - /** |
|
911 | - * Set the times authentication will be cached before really accessing the CAS server in gateway mode: |
|
912 | - * - -1: check only once, and then never again (until you pree login) |
|
913 | - * - 0: always check |
|
914 | - * - n: check every "n" time |
|
915 | - * |
|
916 | - * @param $n an integer. |
|
917 | - */ |
|
918 | - function setCacheTimesForAuthRecheck($n) { |
|
919 | - global $PHPCAS_CLIENT; |
|
920 | - if (!is_object($PHPCAS_CLIENT)) { |
|
921 | - phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()'); |
|
922 | - } |
|
923 | - if (gettype($n) != 'integer') { |
|
924 | - phpCAS :: error('type mismatched for parameter $header (should be `string\')'); |
|
925 | - } |
|
926 | - $PHPCAS_CLIENT->setCacheTimesForAuthRecheck($n); |
|
927 | - } |
|
928 | - |
|
929 | - /** |
|
930 | - * This method is called to check if the user is authenticated (use the gateway feature). |
|
931 | - * @return TRUE when the user is authenticated; otherwise FALSE. |
|
932 | - */ |
|
933 | - function checkAuthentication() { |
|
934 | - global $PHPCAS_CLIENT, $PHPCAS_AUTH_CHECK_CALL; |
|
935 | - |
|
936 | - phpCAS :: traceBegin(); |
|
937 | - if (!is_object($PHPCAS_CLIENT)) { |
|
938 | - phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()'); |
|
939 | - } |
|
940 | - |
|
941 | - $auth = $PHPCAS_CLIENT->checkAuthentication(); |
|
942 | - |
|
943 | - // store where the authentication has been checked and the result |
|
944 | - $dbg = phpCAS :: backtrace(); |
|
945 | - $PHPCAS_AUTH_CHECK_CALL = array ( |
|
946 | - 'done' => TRUE, |
|
947 | - 'file' => $dbg[0]['file'], |
|
948 | - 'line' => $dbg[0]['line'], |
|
949 | - 'method' => __CLASS__ . '::' . __FUNCTION__, |
|
950 | - 'result' => $auth |
|
951 | - ); |
|
952 | - phpCAS :: traceEnd($auth); |
|
953 | - return $auth; |
|
954 | - } |
|
955 | - |
|
956 | - /** |
|
957 | - * This method is called to force authentication if the user was not already |
|
958 | - * authenticated. If the user is not authenticated, halt by redirecting to |
|
959 | - * the CAS server. |
|
960 | - */ |
|
961 | - function forceAuthentication() { |
|
962 | - global $PHPCAS_CLIENT, $PHPCAS_AUTH_CHECK_CALL; |
|
963 | - |
|
964 | - phpCAS :: traceBegin(); |
|
965 | - if (!is_object($PHPCAS_CLIENT)) { |
|
966 | - phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()'); |
|
967 | - } |
|
968 | - |
|
969 | - $auth = $PHPCAS_CLIENT->forceAuthentication(); |
|
970 | - |
|
971 | - // store where the authentication has been checked and the result |
|
972 | - $dbg = phpCAS :: backtrace(); |
|
973 | - $PHPCAS_AUTH_CHECK_CALL = array ( |
|
974 | - 'done' => TRUE, |
|
975 | - 'file' => $dbg[0]['file'], |
|
976 | - 'line' => $dbg[0]['line'], |
|
977 | - 'method' => __CLASS__ . '::' . __FUNCTION__, |
|
978 | - 'result' => $auth |
|
979 | - ); |
|
980 | - |
|
981 | - if (!$auth) { |
|
982 | - phpCAS :: trace('user is not authenticated, redirecting to the CAS server'); |
|
983 | - $PHPCAS_CLIENT->forceAuthentication(); |
|
984 | - } else { |
|
985 | - phpCAS :: trace('no need to authenticate (user `' . phpCAS :: getUser() . '\' is already authenticated)'); |
|
986 | - } |
|
987 | - |
|
988 | - phpCAS :: traceEnd(); |
|
989 | - return $auth; |
|
990 | - } |
|
991 | - |
|
992 | - /** |
|
993 | - * This method is called to renew the authentication. |
|
994 | - **/ |
|
995 | - function renewAuthentication() { |
|
996 | - global $PHPCAS_CLIENT, $PHPCAS_AUTH_CHECK_CALL; |
|
997 | - |
|
998 | - phpCAS :: traceBegin(); |
|
999 | - if (!is_object($PHPCAS_CLIENT)) { |
|
1000 | - phpCAS :: error('this method should not be called before' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()'); |
|
1001 | - } |
|
1002 | - |
|
1003 | - // store where the authentication has been checked and the result |
|
1004 | - $dbg = phpCAS :: backtrace(); |
|
1005 | - $PHPCAS_AUTH_CHECK_CALL = array ( |
|
1006 | - 'done' => TRUE, |
|
1007 | - 'file' => $dbg[0]['file'], |
|
1008 | - 'line' => $dbg[0]['line'], |
|
1009 | - 'method' => __CLASS__ . '::' . __FUNCTION__, |
|
1010 | - 'result' => $auth |
|
1011 | - ); |
|
1012 | - |
|
1013 | - $PHPCAS_CLIENT->renewAuthentication(); |
|
1014 | - phpCAS :: traceEnd(); |
|
1015 | - } |
|
1016 | - |
|
1017 | - /** |
|
1018 | - * This method has been left from version 0.4.1 for compatibility reasons. |
|
1019 | - */ |
|
1020 | - function authenticate() { |
|
1021 | - phpCAS :: error('this method is deprecated. You should use ' . __CLASS__ . '::forceAuthentication() instead'); |
|
1022 | - } |
|
1023 | - |
|
1024 | - /** |
|
1025 | - * This method is called to check if the user is authenticated (previously or by |
|
1026 | - * tickets given in the URL). |
|
1027 | - * |
|
1028 | - * @return TRUE when the user is authenticated. |
|
1029 | - */ |
|
1030 | - function isAuthenticated() { |
|
1031 | - global $PHPCAS_CLIENT, $PHPCAS_AUTH_CHECK_CALL; |
|
1032 | - |
|
1033 | - phpCAS :: traceBegin(); |
|
1034 | - if (!is_object($PHPCAS_CLIENT)) { |
|
1035 | - phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()'); |
|
1036 | - } |
|
1037 | - |
|
1038 | - // call the isAuthenticated method of the global $PHPCAS_CLIENT object |
|
1039 | - $auth = $PHPCAS_CLIENT->isAuthenticated(); |
|
1040 | - |
|
1041 | - // store where the authentication has been checked and the result |
|
1042 | - $dbg = phpCAS :: backtrace(); |
|
1043 | - $PHPCAS_AUTH_CHECK_CALL = array ( |
|
1044 | - 'done' => TRUE, |
|
1045 | - 'file' => $dbg[0]['file'], |
|
1046 | - 'line' => $dbg[0]['line'], |
|
1047 | - 'method' => __CLASS__ . '::' . __FUNCTION__, |
|
1048 | - 'result' => $auth |
|
1049 | - ); |
|
1050 | - phpCAS :: traceEnd($auth); |
|
1051 | - return $auth; |
|
1052 | - } |
|
1053 | - |
|
1054 | - /** |
|
1055 | - * Checks whether authenticated based on $_SESSION. Useful to avoid |
|
1056 | - * server calls. |
|
1057 | - * @return true if authenticated, false otherwise. |
|
1058 | - * @since 0.4.22 by Brendan Arnold |
|
1059 | - */ |
|
1060 | - function isSessionAuthenticated() { |
|
1061 | - global $PHPCAS_CLIENT; |
|
1062 | - if (!is_object($PHPCAS_CLIENT)) { |
|
1063 | - phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()'); |
|
1064 | - } |
|
1065 | - return ($PHPCAS_CLIENT->isSessionAuthenticated()); |
|
1066 | - } |
|
1067 | - |
|
1068 | - /** |
|
1069 | - * This method returns the CAS user's login name. |
|
1070 | - * @warning should not be called only after phpCAS::forceAuthentication() |
|
1071 | - * or phpCAS::checkAuthentication(). |
|
1072 | - * |
|
1073 | - * @return the login name of the authenticated user |
|
1074 | - */ |
|
1075 | - function getUser() { |
|
1076 | - global $PHPCAS_CLIENT, $PHPCAS_AUTH_CHECK_CALL; |
|
1077 | - if (!is_object($PHPCAS_CLIENT)) { |
|
1078 | - phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()'); |
|
1079 | - } |
|
1080 | - if (!$PHPCAS_AUTH_CHECK_CALL['done']) { |
|
1081 | - phpCAS :: error('this method should only be called after ' . __CLASS__ . '::forceAuthentication() or ' . __CLASS__ . '::isAuthenticated()'); |
|
1082 | - } |
|
1083 | - if (!$PHPCAS_AUTH_CHECK_CALL['result']) { |
|
1084 | - phpCAS :: error('authentication was checked (by ' . $PHPCAS_AUTH_CHECK_CALL['method'] . '() at ' . $PHPCAS_AUTH_CHECK_CALL['file'] . ':' . $PHPCAS_AUTH_CHECK_CALL['line'] . ') but the method returned FALSE'); |
|
1085 | - } |
|
1086 | - return $PHPCAS_CLIENT->getUser(); |
|
1087 | - } |
|
1088 | - |
|
1089 | - /** |
|
1090 | - * This method returns the CAS user's login name. |
|
1091 | - * @warning should not be called only after phpCAS::forceAuthentication() |
|
1092 | - * or phpCAS::checkAuthentication(). |
|
1093 | - * |
|
1094 | - * @return the login name of the authenticated user |
|
1095 | - */ |
|
1096 | - function getAttributes() { |
|
1097 | - global $PHPCAS_CLIENT, $PHPCAS_AUTH_CHECK_CALL; |
|
1098 | - if (!is_object($PHPCAS_CLIENT)) { |
|
1099 | - phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()'); |
|
1100 | - } |
|
1101 | - if (!$PHPCAS_AUTH_CHECK_CALL['done']) { |
|
1102 | - phpCAS :: error('this method should only be called after ' . __CLASS__ . '::forceAuthentication() or ' . __CLASS__ . '::isAuthenticated()'); |
|
1103 | - } |
|
1104 | - if (!$PHPCAS_AUTH_CHECK_CALL['result']) { |
|
1105 | - phpCAS :: error('authentication was checked (by ' . $PHPCAS_AUTH_CHECK_CALL['method'] . '() at ' . $PHPCAS_AUTH_CHECK_CALL['file'] . ':' . $PHPCAS_AUTH_CHECK_CALL['line'] . ') but the method returned FALSE'); |
|
1106 | - } |
|
1107 | - return $PHPCAS_CLIENT->getAttributes(); |
|
1108 | - } |
|
1109 | - /** |
|
1110 | - * Handle logout requests. |
|
1111 | - */ |
|
1112 | - function handleLogoutRequests($check_client = true, $allowed_clients = false) { |
|
1113 | - global $PHPCAS_CLIENT; |
|
1114 | - if (!is_object($PHPCAS_CLIENT)) { |
|
1115 | - phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()'); |
|
1116 | - } |
|
1117 | - return ($PHPCAS_CLIENT->handleLogoutRequests($check_client, $allowed_clients)); |
|
1118 | - } |
|
1119 | - |
|
1120 | - /** |
|
1121 | - * This method returns the URL to be used to login. |
|
1122 | - * or phpCAS::isAuthenticated(). |
|
1123 | - * |
|
1124 | - * @return the login name of the authenticated user |
|
1125 | - */ |
|
1126 | - function getServerLoginURL() { |
|
1127 | - global $PHPCAS_CLIENT; |
|
1128 | - if (!is_object($PHPCAS_CLIENT)) { |
|
1129 | - phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()'); |
|
1130 | - } |
|
1131 | - return $PHPCAS_CLIENT->getServerLoginURL(); |
|
1132 | - } |
|
1133 | - |
|
1134 | - /** |
|
1135 | - * Set the login URL of the CAS server. |
|
1136 | - * @param $url the login URL |
|
1137 | - * @since 0.4.21 by Wyman Chan |
|
1138 | - */ |
|
1139 | - function setServerLoginURL($url = '') { |
|
1140 | - global $PHPCAS_CLIENT; |
|
1141 | - phpCAS :: traceBegin(); |
|
1142 | - if (!is_object($PHPCAS_CLIENT)) { |
|
1143 | - phpCAS :: error('this method should only be called after |
|
343 | + // ######################################################################## |
|
344 | + // INITIALIZATION |
|
345 | + // ######################################################################## |
|
346 | + |
|
347 | + /** |
|
348 | + * @addtogroup publicInit |
|
349 | + * @{ |
|
350 | + */ |
|
351 | + |
|
352 | + /** |
|
353 | + * phpCAS client initializer. |
|
354 | + * @note Only one of the phpCAS::client() and phpCAS::proxy functions should be |
|
355 | + * called, only once, and before all other methods (except phpCAS::getVersion() |
|
356 | + * and phpCAS::setDebug()). |
|
357 | + * |
|
358 | + * @param $server_version the version of the CAS server |
|
359 | + * @param $server_hostname the hostname of the CAS server |
|
360 | + * @param $server_port the port the CAS server is running on |
|
361 | + * @param $server_uri the URI the CAS server is responding on |
|
362 | + * @param $start_session Have phpCAS start PHP sessions (default true) |
|
363 | + * |
|
364 | + * @return a newly created CASClient object |
|
365 | + */ |
|
366 | + function client($server_version, $server_hostname, $server_port, $server_uri, $start_session = true) { |
|
367 | + global $PHPCAS_CLIENT, $PHPCAS_INIT_CALL; |
|
368 | + |
|
369 | + phpCAS :: traceBegin(); |
|
370 | + if (is_object($PHPCAS_CLIENT)) { |
|
371 | + phpCAS :: error($PHPCAS_INIT_CALL['method'] . '() has already been called (at ' . $PHPCAS_INIT_CALL['file'] . ':' . $PHPCAS_INIT_CALL['line'] . ')'); |
|
372 | + } |
|
373 | + if (gettype($server_version) != 'string') { |
|
374 | + phpCAS :: error('type mismatched for parameter $server_version (should be `string\')'); |
|
375 | + } |
|
376 | + if (gettype($server_hostname) != 'string') { |
|
377 | + phpCAS :: error('type mismatched for parameter $server_hostname (should be `string\')'); |
|
378 | + } |
|
379 | + if (gettype($server_port) != 'integer') { |
|
380 | + phpCAS :: error('type mismatched for parameter $server_port (should be `integer\')'); |
|
381 | + } |
|
382 | + if (gettype($server_uri) != 'string') { |
|
383 | + phpCAS :: error('type mismatched for parameter $server_uri (should be `string\')'); |
|
384 | + } |
|
385 | + |
|
386 | + // store where the initializer is called from |
|
387 | + $dbg = phpCAS :: backtrace(); |
|
388 | + $PHPCAS_INIT_CALL = array ( |
|
389 | + 'done' => TRUE, |
|
390 | + 'file' => $dbg[0]['file'], |
|
391 | + 'line' => $dbg[0]['line'], |
|
392 | + 'method' => __CLASS__ . '::' . __FUNCTION__ |
|
393 | + ); |
|
394 | + |
|
395 | + // initialize the global object $PHPCAS_CLIENT |
|
396 | + $PHPCAS_CLIENT = new CASClient($server_version, FALSE /*proxy*/ |
|
397 | + , $server_hostname, $server_port, $server_uri, $start_session); |
|
398 | + phpCAS :: traceEnd(); |
|
399 | + } |
|
400 | + |
|
401 | + /** |
|
402 | + * phpCAS proxy initializer. |
|
403 | + * @note Only one of the phpCAS::client() and phpCAS::proxy functions should be |
|
404 | + * called, only once, and before all other methods (except phpCAS::getVersion() |
|
405 | + * and phpCAS::setDebug()). |
|
406 | + * |
|
407 | + * @param $server_version the version of the CAS server |
|
408 | + * @param $server_hostname the hostname of the CAS server |
|
409 | + * @param $server_port the port the CAS server is running on |
|
410 | + * @param $server_uri the URI the CAS server is responding on |
|
411 | + * @param $start_session Have phpCAS start PHP sessions (default true) |
|
412 | + * |
|
413 | + * @return a newly created CASClient object |
|
414 | + */ |
|
415 | + function proxy($server_version, $server_hostname, $server_port, $server_uri, $start_session = true) { |
|
416 | + global $PHPCAS_CLIENT, $PHPCAS_INIT_CALL; |
|
417 | + |
|
418 | + phpCAS :: traceBegin(); |
|
419 | + if (is_object($PHPCAS_CLIENT)) { |
|
420 | + phpCAS :: error($PHPCAS_INIT_CALL['method'] . '() has already been called (at ' . $PHPCAS_INIT_CALL['file'] . ':' . $PHPCAS_INIT_CALL['line'] . ')'); |
|
421 | + } |
|
422 | + if (gettype($server_version) != 'string') { |
|
423 | + phpCAS :: error('type mismatched for parameter $server_version (should be `string\')'); |
|
424 | + } |
|
425 | + if (gettype($server_hostname) != 'string') { |
|
426 | + phpCAS :: error('type mismatched for parameter $server_hostname (should be `string\')'); |
|
427 | + } |
|
428 | + if (gettype($server_port) != 'integer') { |
|
429 | + phpCAS :: error('type mismatched for parameter $server_port (should be `integer\')'); |
|
430 | + } |
|
431 | + if (gettype($server_uri) != 'string') { |
|
432 | + phpCAS :: error('type mismatched for parameter $server_uri (should be `string\')'); |
|
433 | + } |
|
434 | + |
|
435 | + // store where the initialzer is called from |
|
436 | + $dbg = phpCAS :: backtrace(); |
|
437 | + $PHPCAS_INIT_CALL = array ( |
|
438 | + 'done' => TRUE, |
|
439 | + 'file' => $dbg[0]['file'], |
|
440 | + 'line' => $dbg[0]['line'], |
|
441 | + 'method' => __CLASS__ . '::' . __FUNCTION__ |
|
442 | + ); |
|
443 | + |
|
444 | + // initialize the global object $PHPCAS_CLIENT |
|
445 | + $PHPCAS_CLIENT = new CASClient($server_version, TRUE /*proxy*/ |
|
446 | + , $server_hostname, $server_port, $server_uri, $start_session); |
|
447 | + phpCAS :: traceEnd(); |
|
448 | + } |
|
449 | + |
|
450 | + /** @} */ |
|
451 | + // ######################################################################## |
|
452 | + // DEBUGGING |
|
453 | + // ######################################################################## |
|
454 | + |
|
455 | + /** |
|
456 | + * @addtogroup publicDebug |
|
457 | + * @{ |
|
458 | + */ |
|
459 | + |
|
460 | + /** |
|
461 | + * Set/unset debug mode |
|
462 | + * |
|
463 | + * @param $filename the name of the file used for logging, or FALSE to stop debugging. |
|
464 | + */ |
|
465 | + function setDebug($filename = '') { |
|
466 | + global $PHPCAS_DEBUG; |
|
467 | + |
|
468 | + if ($filename != FALSE && gettype($filename) != 'string') { |
|
469 | + phpCAS :: error('type mismatched for parameter $dbg (should be FALSE or the name of the log file)'); |
|
470 | + } |
|
471 | + |
|
472 | + if (empty ($filename)) { |
|
473 | + if (preg_match('/^Win.*/', getenv('OS'))) { |
|
474 | + if (isset ($_ENV['TMP'])) { |
|
475 | + $debugDir = $_ENV['TMP'] . '/'; |
|
476 | + } else |
|
477 | + if (isset ($_ENV['TEMP'])) { |
|
478 | + $debugDir = $_ENV['TEMP'] . '/'; |
|
479 | + } else { |
|
480 | + $debugDir = ''; |
|
481 | + } |
|
482 | + } else { |
|
483 | + $debugDir = DEFAULT_DEBUG_DIR; |
|
484 | + } |
|
485 | + $filename = $debugDir . 'phpCAS.log'; |
|
486 | + } |
|
487 | + |
|
488 | + if (empty ($PHPCAS_DEBUG['unique_id'])) { |
|
489 | + $PHPCAS_DEBUG['unique_id'] = substr(strtoupper(md5(uniqid(''))), 0, 4); |
|
490 | + } |
|
491 | + |
|
492 | + $PHPCAS_DEBUG['filename'] = $filename; |
|
493 | + |
|
494 | + phpCAS :: trace('START ******************'); |
|
495 | + } |
|
496 | + |
|
497 | + /** @} */ |
|
498 | + /** |
|
499 | + * @addtogroup internalDebug |
|
500 | + * @{ |
|
501 | + */ |
|
502 | + |
|
503 | + /** |
|
504 | + * This method is a wrapper for debug_backtrace() that is not available |
|
505 | + * in all PHP versions (>= 4.3.0 only) |
|
506 | + */ |
|
507 | + function backtrace() { |
|
508 | + if (function_exists('debug_backtrace')) { |
|
509 | + return debug_backtrace(); |
|
510 | + } else { |
|
511 | + // poor man's hack ... but it does work ... |
|
512 | + return array (); |
|
513 | + } |
|
514 | + } |
|
515 | + |
|
516 | + /** |
|
517 | + * Logs a string in debug mode. |
|
518 | + * |
|
519 | + * @param $str the string to write |
|
520 | + * |
|
521 | + * @private |
|
522 | + */ |
|
523 | + function log($str) { |
|
524 | + $indent_str = "."; |
|
525 | + global $PHPCAS_DEBUG; |
|
526 | + |
|
527 | + if ($PHPCAS_DEBUG['filename']) { |
|
528 | + for ($i = 0; $i < $PHPCAS_DEBUG['indent']; $i++) { |
|
529 | + $indent_str .= '| '; |
|
530 | + } |
|
531 | + error_log($PHPCAS_DEBUG['unique_id'] . ' ' . $indent_str . $str . "\n", 3, $PHPCAS_DEBUG['filename']); |
|
532 | + } |
|
533 | + |
|
534 | + } |
|
535 | + |
|
536 | + /** |
|
537 | + * This method is used by interface methods to print an error and where the function |
|
538 | + * was originally called from. |
|
539 | + * |
|
540 | + * @param $msg the message to print |
|
541 | + * |
|
542 | + * @private |
|
543 | + */ |
|
544 | + function error($msg) { |
|
545 | + $dbg = phpCAS :: backtrace(); |
|
546 | + $function = '?'; |
|
547 | + $file = '?'; |
|
548 | + $line = '?'; |
|
549 | + if (is_array($dbg)) { |
|
550 | + for ($i = 1; $i < sizeof($dbg); $i++) { |
|
551 | + if (is_array($dbg[$i])) { |
|
552 | + if ($dbg[$i]['class'] == __CLASS__) { |
|
553 | + $function = $dbg[$i]['function']; |
|
554 | + $file = $dbg[$i]['file']; |
|
555 | + $line = $dbg[$i]['line']; |
|
556 | + } |
|
557 | + } |
|
558 | + } |
|
559 | + } |
|
560 | + echo "<br />\n<b>phpCAS error</b>: <font color=\"FF0000\"><b>" . __CLASS__ . "::" . $function . '(): ' . htmlentities($msg) . "</b></font> in <b>" . $file . "</b> on line <b>" . $line . "</b><br />\n"; |
|
561 | + phpCAS :: trace($msg); |
|
562 | + phpCAS :: traceExit(); |
|
563 | + exit (); |
|
564 | + } |
|
565 | + |
|
566 | + /** |
|
567 | + * This method is used to log something in debug mode. |
|
568 | + */ |
|
569 | + function trace($str) { |
|
570 | + $dbg = phpCAS :: backtrace(); |
|
571 | + phpCAS :: log($str . ' [' . basename($dbg[1]['file']) . ':' . $dbg[1]['line'] . ']'); |
|
572 | + } |
|
573 | + |
|
574 | + /** |
|
575 | + * This method is used to indicate the start of the execution of a function in debug mode. |
|
576 | + */ |
|
577 | + function traceBegin() { |
|
578 | + global $PHPCAS_DEBUG; |
|
579 | + |
|
580 | + $dbg = phpCAS :: backtrace(); |
|
581 | + $str = '=> '; |
|
582 | + if (!empty ($dbg[2]['class'])) { |
|
583 | + $str .= $dbg[2]['class'] . '::'; |
|
584 | + } |
|
585 | + $str .= $dbg[2]['function'] . '('; |
|
586 | + if (is_array($dbg[2]['args'])) { |
|
587 | + foreach ($dbg[2]['args'] as $index => $arg) { |
|
588 | + if ($index != 0) { |
|
589 | + $str .= ', '; |
|
590 | + } |
|
591 | + $str .= str_replace("\n", "", var_export($arg, TRUE)); |
|
592 | + } |
|
593 | + } |
|
594 | + $str .= ') [' . basename($dbg[2]['file']) . ':' . $dbg[2]['line'] . ']'; |
|
595 | + phpCAS :: log($str); |
|
596 | + $PHPCAS_DEBUG['indent']++; |
|
597 | + } |
|
598 | + |
|
599 | + /** |
|
600 | + * This method is used to indicate the end of the execution of a function in debug mode. |
|
601 | + * |
|
602 | + * @param $res the result of the function |
|
603 | + */ |
|
604 | + function traceEnd($res = '') { |
|
605 | + global $PHPCAS_DEBUG; |
|
606 | + |
|
607 | + $PHPCAS_DEBUG['indent']--; |
|
608 | + $dbg = phpCAS :: backtrace(); |
|
609 | + $str = ''; |
|
610 | + $str .= '<= ' . str_replace("\n", "", var_export($res, TRUE)); |
|
611 | + phpCAS :: log($str); |
|
612 | + } |
|
613 | + |
|
614 | + /** |
|
615 | + * This method is used to indicate the end of the execution of the program |
|
616 | + */ |
|
617 | + function traceExit() { |
|
618 | + global $PHPCAS_DEBUG; |
|
619 | + |
|
620 | + phpCAS :: log('exit()'); |
|
621 | + while ($PHPCAS_DEBUG['indent'] > 0) { |
|
622 | + phpCAS :: log('-'); |
|
623 | + $PHPCAS_DEBUG['indent']--; |
|
624 | + } |
|
625 | + } |
|
626 | + |
|
627 | + /** @} */ |
|
628 | + // ######################################################################## |
|
629 | + // INTERNATIONALIZATION |
|
630 | + // ######################################################################## |
|
631 | + /** |
|
632 | + * @addtogroup publicLang |
|
633 | + * @{ |
|
634 | + */ |
|
635 | + |
|
636 | + /** |
|
637 | + * This method is used to set the language used by phpCAS. |
|
638 | + * @note Can be called only once. |
|
639 | + * |
|
640 | + * @param $lang a string representing the language. |
|
641 | + * |
|
642 | + * @sa PHPCAS_LANG_FRENCH, PHPCAS_LANG_ENGLISH |
|
643 | + */ |
|
644 | + function setLang($lang) { |
|
645 | + global $PHPCAS_CLIENT; |
|
646 | + if (!is_object($PHPCAS_CLIENT)) { |
|
647 | + phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()'); |
|
648 | + } |
|
649 | + if (gettype($lang) != 'string') { |
|
650 | + phpCAS :: error('type mismatched for parameter $lang (should be `string\')'); |
|
651 | + } |
|
652 | + $PHPCAS_CLIENT->setLang($lang); |
|
653 | + } |
|
654 | + |
|
655 | + /** @} */ |
|
656 | + // ######################################################################## |
|
657 | + // VERSION |
|
658 | + // ######################################################################## |
|
659 | + /** |
|
660 | + * @addtogroup public |
|
661 | + * @{ |
|
662 | + */ |
|
663 | + |
|
664 | + /** |
|
665 | + * This method returns the phpCAS version. |
|
666 | + * |
|
667 | + * @return the phpCAS version. |
|
668 | + */ |
|
669 | + function getVersion() { |
|
670 | + return PHPCAS_VERSION; |
|
671 | + } |
|
672 | + |
|
673 | + /** @} */ |
|
674 | + // ######################################################################## |
|
675 | + // HTML OUTPUT |
|
676 | + // ######################################################################## |
|
677 | + /** |
|
678 | + * @addtogroup publicOutput |
|
679 | + * @{ |
|
680 | + */ |
|
681 | + |
|
682 | + /** |
|
683 | + * This method sets the HTML header used for all outputs. |
|
684 | + * |
|
685 | + * @param $header the HTML header. |
|
686 | + */ |
|
687 | + function setHTMLHeader($header) { |
|
688 | + global $PHPCAS_CLIENT; |
|
689 | + if (!is_object($PHPCAS_CLIENT)) { |
|
690 | + phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()'); |
|
691 | + } |
|
692 | + if (gettype($header) != 'string') { |
|
693 | + phpCAS :: error('type mismatched for parameter $header (should be `string\')'); |
|
694 | + } |
|
695 | + $PHPCAS_CLIENT->setHTMLHeader($header); |
|
696 | + } |
|
697 | + |
|
698 | + /** |
|
699 | + * This method sets the HTML footer used for all outputs. |
|
700 | + * |
|
701 | + * @param $footer the HTML footer. |
|
702 | + */ |
|
703 | + function setHTMLFooter($footer) { |
|
704 | + global $PHPCAS_CLIENT; |
|
705 | + if (!is_object($PHPCAS_CLIENT)) { |
|
706 | + phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()'); |
|
707 | + } |
|
708 | + if (gettype($footer) != 'string') { |
|
709 | + phpCAS :: error('type mismatched for parameter $footer (should be `string\')'); |
|
710 | + } |
|
711 | + $PHPCAS_CLIENT->setHTMLFooter($footer); |
|
712 | + } |
|
713 | + |
|
714 | + /** @} */ |
|
715 | + // ######################################################################## |
|
716 | + // PGT STORAGE |
|
717 | + // ######################################################################## |
|
718 | + /** |
|
719 | + * @addtogroup publicPGTStorage |
|
720 | + * @{ |
|
721 | + */ |
|
722 | + |
|
723 | + /** |
|
724 | + * This method is used to tell phpCAS to store the response of the |
|
725 | + * CAS server to PGT requests onto the filesystem. |
|
726 | + * |
|
727 | + * @param $format the format used to store the PGT's (`plain' and `xml' allowed) |
|
728 | + * @param $path the path where the PGT's should be stored |
|
729 | + */ |
|
730 | + function setPGTStorageFile($format = '', $path = '') { |
|
731 | + global $PHPCAS_CLIENT, $PHPCAS_AUTH_CHECK_CALL; |
|
732 | + |
|
733 | + phpCAS :: traceBegin(); |
|
734 | + if (!is_object($PHPCAS_CLIENT)) { |
|
735 | + phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()'); |
|
736 | + } |
|
737 | + if (!$PHPCAS_CLIENT->isProxy()) { |
|
738 | + phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()'); |
|
739 | + } |
|
740 | + if ($PHPCAS_AUTH_CHECK_CALL['done']) { |
|
741 | + phpCAS :: error('this method should only be called before ' . $PHPCAS_AUTH_CHECK_CALL['method'] . '() (called at ' . $PHPCAS_AUTH_CHECK_CALL['file'] . ':' . $PHPCAS_AUTH_CHECK_CALL['line'] . ')'); |
|
742 | + } |
|
743 | + if (gettype($format) != 'string') { |
|
744 | + phpCAS :: error('type mismatched for parameter $format (should be `string\')'); |
|
745 | + } |
|
746 | + if (gettype($path) != 'string') { |
|
747 | + phpCAS :: error('type mismatched for parameter $format (should be `string\')'); |
|
748 | + } |
|
749 | + $PHPCAS_CLIENT->setPGTStorageFile($format, $path); |
|
750 | + phpCAS :: traceEnd(); |
|
751 | + } |
|
752 | + |
|
753 | + /** |
|
754 | + * This method is used to tell phpCAS to store the response of the |
|
755 | + * CAS server to PGT requests into a database. |
|
756 | + * @note The connection to the database is done only when needed. |
|
757 | + * As a consequence, bad parameters are detected only when |
|
758 | + * initializing PGT storage, except in debug mode. |
|
759 | + * |
|
760 | + * @param $user the user to access the data with |
|
761 | + * @param $password the user's password |
|
762 | + * @param $database_type the type of the database hosting the data |
|
763 | + * @param $hostname the server hosting the database |
|
764 | + * @param $port the port the server is listening on |
|
765 | + * @param $database the name of the database |
|
766 | + * @param $table the name of the table storing the data |
|
767 | + */ |
|
768 | + function setPGTStorageDB($user, $password, $database_type = '', $hostname = '', $port = 0, $database = '', $table = '') { |
|
769 | + global $PHPCAS_CLIENT, $PHPCAS_AUTH_CHECK_CALL; |
|
770 | + |
|
771 | + phpCAS :: traceBegin(); |
|
772 | + if (!is_object($PHPCAS_CLIENT)) { |
|
773 | + phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()'); |
|
774 | + } |
|
775 | + if (!$PHPCAS_CLIENT->isProxy()) { |
|
776 | + phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()'); |
|
777 | + } |
|
778 | + if ($PHPCAS_AUTH_CHECK_CALL['done']) { |
|
779 | + phpCAS :: error('this method should only be called before ' . $PHPCAS_AUTH_CHECK_CALL['method'] . '() (called at ' . $PHPCAS_AUTH_CHECK_CALL['file'] . ':' . $PHPCAS_AUTH_CHECK_CALL['line'] . ')'); |
|
780 | + } |
|
781 | + if (gettype($user) != 'string') { |
|
782 | + phpCAS :: error('type mismatched for parameter $user (should be `string\')'); |
|
783 | + } |
|
784 | + if (gettype($password) != 'string') { |
|
785 | + phpCAS :: error('type mismatched for parameter $password (should be `string\')'); |
|
786 | + } |
|
787 | + if (gettype($database_type) != 'string') { |
|
788 | + phpCAS :: error('type mismatched for parameter $database_type (should be `string\')'); |
|
789 | + } |
|
790 | + if (gettype($hostname) != 'string') { |
|
791 | + phpCAS :: error('type mismatched for parameter $hostname (should be `string\')'); |
|
792 | + } |
|
793 | + if (gettype($port) != 'integer') { |
|
794 | + phpCAS :: error('type mismatched for parameter $port (should be `integer\')'); |
|
795 | + } |
|
796 | + if (gettype($database) != 'string') { |
|
797 | + phpCAS :: error('type mismatched for parameter $database (should be `string\')'); |
|
798 | + } |
|
799 | + if (gettype($table) != 'string') { |
|
800 | + phpCAS :: error('type mismatched for parameter $table (should be `string\')'); |
|
801 | + } |
|
802 | + $PHPCAS_CLIENT->setPGTStorageDB($user, $password, $database_type, $hostname, $port, $database, $table); |
|
803 | + phpCAS :: traceEnd(); |
|
804 | + } |
|
805 | + |
|
806 | + /** @} */ |
|
807 | + // ######################################################################## |
|
808 | + // ACCESS TO EXTERNAL SERVICES |
|
809 | + // ######################################################################## |
|
810 | + /** |
|
811 | + * @addtogroup publicServices |
|
812 | + * @{ |
|
813 | + */ |
|
814 | + |
|
815 | + /** |
|
816 | + * This method is used to access an HTTP[S] service. |
|
817 | + * |
|
818 | + * @param $url the service to access. |
|
819 | + * @param $err_code an error code Possible values are PHPCAS_SERVICE_OK (on |
|
820 | + * success), PHPCAS_SERVICE_PT_NO_SERVER_RESPONSE, PHPCAS_SERVICE_PT_BAD_SERVER_RESPONSE, |
|
821 | + * PHPCAS_SERVICE_PT_FAILURE, PHPCAS_SERVICE_NOT AVAILABLE. |
|
822 | + * @param $output the output of the service (also used to give an error |
|
823 | + * message on failure). |
|
824 | + * |
|
825 | + * @return TRUE on success, FALSE otherwise (in this later case, $err_code |
|
826 | + * gives the reason why it failed and $output contains an error message). |
|
827 | + */ |
|
828 | + function serviceWeb($url, & $err_code, & $output) { |
|
829 | + global $PHPCAS_CLIENT, $PHPCAS_AUTH_CHECK_CALL; |
|
830 | + |
|
831 | + phpCAS :: traceBegin(); |
|
832 | + if (!is_object($PHPCAS_CLIENT)) { |
|
833 | + phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()'); |
|
834 | + } |
|
835 | + if (!$PHPCAS_CLIENT->isProxy()) { |
|
836 | + phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()'); |
|
837 | + } |
|
838 | + if (!$PHPCAS_AUTH_CHECK_CALL['done']) { |
|
839 | + phpCAS :: error('this method should only be called after the programmer is sure the user has been authenticated (by calling ' . __CLASS__ . '::checkAuthentication() or ' . __CLASS__ . '::forceAuthentication()'); |
|
840 | + } |
|
841 | + if (!$PHPCAS_AUTH_CHECK_CALL['result']) { |
|
842 | + phpCAS :: error('authentication was checked (by ' . $PHPCAS_AUTH_CHECK_CALL['method'] . '() at ' . $PHPCAS_AUTH_CHECK_CALL['file'] . ':' . $PHPCAS_AUTH_CHECK_CALL['line'] . ') but the method returned FALSE'); |
|
843 | + } |
|
844 | + if (gettype($url) != 'string') { |
|
845 | + phpCAS :: error('type mismatched for parameter $url (should be `string\')'); |
|
846 | + } |
|
847 | + |
|
848 | + $res = $PHPCAS_CLIENT->serviceWeb($url, $err_code, $output); |
|
849 | + |
|
850 | + phpCAS :: traceEnd($res); |
|
851 | + return $res; |
|
852 | + } |
|
853 | + |
|
854 | + /** |
|
855 | + * This method is used to access an IMAP/POP3/NNTP service. |
|
856 | + * |
|
857 | + * @param $url a string giving the URL of the service, including the mailing box |
|
858 | + * for IMAP URLs, as accepted by imap_open(). |
|
859 | + * @param $service a string giving for CAS retrieve Proxy ticket |
|
860 | + * @param $flags options given to imap_open(). |
|
861 | + * @param $err_code an error code Possible values are PHPCAS_SERVICE_OK (on |
|
862 | + * success), PHPCAS_SERVICE_PT_NO_SERVER_RESPONSE, PHPCAS_SERVICE_PT_BAD_SERVER_RESPONSE, |
|
863 | + * PHPCAS_SERVICE_PT_FAILURE, PHPCAS_SERVICE_NOT AVAILABLE. |
|
864 | + * @param $err_msg an error message on failure |
|
865 | + * @param $pt the Proxy Ticket (PT) retrieved from the CAS server to access the URL |
|
866 | + * on success, FALSE on error). |
|
867 | + * |
|
868 | + * @return an IMAP stream on success, FALSE otherwise (in this later case, $err_code |
|
869 | + * gives the reason why it failed and $err_msg contains an error message). |
|
870 | + */ |
|
871 | + function serviceMail($url, $service, $flags, & $err_code, & $err_msg, & $pt) { |
|
872 | + global $PHPCAS_CLIENT, $PHPCAS_AUTH_CHECK_CALL; |
|
873 | + |
|
874 | + phpCAS :: traceBegin(); |
|
875 | + if (!is_object($PHPCAS_CLIENT)) { |
|
876 | + phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()'); |
|
877 | + } |
|
878 | + if (!$PHPCAS_CLIENT->isProxy()) { |
|
879 | + phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()'); |
|
880 | + } |
|
881 | + if (!$PHPCAS_AUTH_CHECK_CALL['done']) { |
|
882 | + phpCAS :: error('this method should only be called after the programmer is sure the user has been authenticated (by calling ' . __CLASS__ . '::checkAuthentication() or ' . __CLASS__ . '::forceAuthentication()'); |
|
883 | + } |
|
884 | + if (!$PHPCAS_AUTH_CHECK_CALL['result']) { |
|
885 | + phpCAS :: error('authentication was checked (by ' . $PHPCAS_AUTH_CHECK_CALL['method'] . '() at ' . $PHPCAS_AUTH_CHECK_CALL['file'] . ':' . $PHPCAS_AUTH_CHECK_CALL['line'] . ') but the method returned FALSE'); |
|
886 | + } |
|
887 | + if (gettype($url) != 'string') { |
|
888 | + phpCAS :: error('type mismatched for parameter $url (should be `string\')'); |
|
889 | + } |
|
890 | + |
|
891 | + if (gettype($flags) != 'integer') { |
|
892 | + phpCAS :: error('type mismatched for parameter $flags (should be `integer\')'); |
|
893 | + } |
|
894 | + |
|
895 | + $res = $PHPCAS_CLIENT->serviceMail($url, $service, $flags, $err_code, $err_msg, $pt); |
|
896 | + |
|
897 | + phpCAS :: traceEnd($res); |
|
898 | + return $res; |
|
899 | + } |
|
900 | + |
|
901 | + /** @} */ |
|
902 | + // ######################################################################## |
|
903 | + // AUTHENTICATION |
|
904 | + // ######################################################################## |
|
905 | + /** |
|
906 | + * @addtogroup publicAuth |
|
907 | + * @{ |
|
908 | + */ |
|
909 | + |
|
910 | + /** |
|
911 | + * Set the times authentication will be cached before really accessing the CAS server in gateway mode: |
|
912 | + * - -1: check only once, and then never again (until you pree login) |
|
913 | + * - 0: always check |
|
914 | + * - n: check every "n" time |
|
915 | + * |
|
916 | + * @param $n an integer. |
|
917 | + */ |
|
918 | + function setCacheTimesForAuthRecheck($n) { |
|
919 | + global $PHPCAS_CLIENT; |
|
920 | + if (!is_object($PHPCAS_CLIENT)) { |
|
921 | + phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()'); |
|
922 | + } |
|
923 | + if (gettype($n) != 'integer') { |
|
924 | + phpCAS :: error('type mismatched for parameter $header (should be `string\')'); |
|
925 | + } |
|
926 | + $PHPCAS_CLIENT->setCacheTimesForAuthRecheck($n); |
|
927 | + } |
|
928 | + |
|
929 | + /** |
|
930 | + * This method is called to check if the user is authenticated (use the gateway feature). |
|
931 | + * @return TRUE when the user is authenticated; otherwise FALSE. |
|
932 | + */ |
|
933 | + function checkAuthentication() { |
|
934 | + global $PHPCAS_CLIENT, $PHPCAS_AUTH_CHECK_CALL; |
|
935 | + |
|
936 | + phpCAS :: traceBegin(); |
|
937 | + if (!is_object($PHPCAS_CLIENT)) { |
|
938 | + phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()'); |
|
939 | + } |
|
940 | + |
|
941 | + $auth = $PHPCAS_CLIENT->checkAuthentication(); |
|
942 | + |
|
943 | + // store where the authentication has been checked and the result |
|
944 | + $dbg = phpCAS :: backtrace(); |
|
945 | + $PHPCAS_AUTH_CHECK_CALL = array ( |
|
946 | + 'done' => TRUE, |
|
947 | + 'file' => $dbg[0]['file'], |
|
948 | + 'line' => $dbg[0]['line'], |
|
949 | + 'method' => __CLASS__ . '::' . __FUNCTION__, |
|
950 | + 'result' => $auth |
|
951 | + ); |
|
952 | + phpCAS :: traceEnd($auth); |
|
953 | + return $auth; |
|
954 | + } |
|
955 | + |
|
956 | + /** |
|
957 | + * This method is called to force authentication if the user was not already |
|
958 | + * authenticated. If the user is not authenticated, halt by redirecting to |
|
959 | + * the CAS server. |
|
960 | + */ |
|
961 | + function forceAuthentication() { |
|
962 | + global $PHPCAS_CLIENT, $PHPCAS_AUTH_CHECK_CALL; |
|
963 | + |
|
964 | + phpCAS :: traceBegin(); |
|
965 | + if (!is_object($PHPCAS_CLIENT)) { |
|
966 | + phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()'); |
|
967 | + } |
|
968 | + |
|
969 | + $auth = $PHPCAS_CLIENT->forceAuthentication(); |
|
970 | + |
|
971 | + // store where the authentication has been checked and the result |
|
972 | + $dbg = phpCAS :: backtrace(); |
|
973 | + $PHPCAS_AUTH_CHECK_CALL = array ( |
|
974 | + 'done' => TRUE, |
|
975 | + 'file' => $dbg[0]['file'], |
|
976 | + 'line' => $dbg[0]['line'], |
|
977 | + 'method' => __CLASS__ . '::' . __FUNCTION__, |
|
978 | + 'result' => $auth |
|
979 | + ); |
|
980 | + |
|
981 | + if (!$auth) { |
|
982 | + phpCAS :: trace('user is not authenticated, redirecting to the CAS server'); |
|
983 | + $PHPCAS_CLIENT->forceAuthentication(); |
|
984 | + } else { |
|
985 | + phpCAS :: trace('no need to authenticate (user `' . phpCAS :: getUser() . '\' is already authenticated)'); |
|
986 | + } |
|
987 | + |
|
988 | + phpCAS :: traceEnd(); |
|
989 | + return $auth; |
|
990 | + } |
|
991 | + |
|
992 | + /** |
|
993 | + * This method is called to renew the authentication. |
|
994 | + **/ |
|
995 | + function renewAuthentication() { |
|
996 | + global $PHPCAS_CLIENT, $PHPCAS_AUTH_CHECK_CALL; |
|
997 | + |
|
998 | + phpCAS :: traceBegin(); |
|
999 | + if (!is_object($PHPCAS_CLIENT)) { |
|
1000 | + phpCAS :: error('this method should not be called before' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()'); |
|
1001 | + } |
|
1002 | + |
|
1003 | + // store where the authentication has been checked and the result |
|
1004 | + $dbg = phpCAS :: backtrace(); |
|
1005 | + $PHPCAS_AUTH_CHECK_CALL = array ( |
|
1006 | + 'done' => TRUE, |
|
1007 | + 'file' => $dbg[0]['file'], |
|
1008 | + 'line' => $dbg[0]['line'], |
|
1009 | + 'method' => __CLASS__ . '::' . __FUNCTION__, |
|
1010 | + 'result' => $auth |
|
1011 | + ); |
|
1012 | + |
|
1013 | + $PHPCAS_CLIENT->renewAuthentication(); |
|
1014 | + phpCAS :: traceEnd(); |
|
1015 | + } |
|
1016 | + |
|
1017 | + /** |
|
1018 | + * This method has been left from version 0.4.1 for compatibility reasons. |
|
1019 | + */ |
|
1020 | + function authenticate() { |
|
1021 | + phpCAS :: error('this method is deprecated. You should use ' . __CLASS__ . '::forceAuthentication() instead'); |
|
1022 | + } |
|
1023 | + |
|
1024 | + /** |
|
1025 | + * This method is called to check if the user is authenticated (previously or by |
|
1026 | + * tickets given in the URL). |
|
1027 | + * |
|
1028 | + * @return TRUE when the user is authenticated. |
|
1029 | + */ |
|
1030 | + function isAuthenticated() { |
|
1031 | + global $PHPCAS_CLIENT, $PHPCAS_AUTH_CHECK_CALL; |
|
1032 | + |
|
1033 | + phpCAS :: traceBegin(); |
|
1034 | + if (!is_object($PHPCAS_CLIENT)) { |
|
1035 | + phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()'); |
|
1036 | + } |
|
1037 | + |
|
1038 | + // call the isAuthenticated method of the global $PHPCAS_CLIENT object |
|
1039 | + $auth = $PHPCAS_CLIENT->isAuthenticated(); |
|
1040 | + |
|
1041 | + // store where the authentication has been checked and the result |
|
1042 | + $dbg = phpCAS :: backtrace(); |
|
1043 | + $PHPCAS_AUTH_CHECK_CALL = array ( |
|
1044 | + 'done' => TRUE, |
|
1045 | + 'file' => $dbg[0]['file'], |
|
1046 | + 'line' => $dbg[0]['line'], |
|
1047 | + 'method' => __CLASS__ . '::' . __FUNCTION__, |
|
1048 | + 'result' => $auth |
|
1049 | + ); |
|
1050 | + phpCAS :: traceEnd($auth); |
|
1051 | + return $auth; |
|
1052 | + } |
|
1053 | + |
|
1054 | + /** |
|
1055 | + * Checks whether authenticated based on $_SESSION. Useful to avoid |
|
1056 | + * server calls. |
|
1057 | + * @return true if authenticated, false otherwise. |
|
1058 | + * @since 0.4.22 by Brendan Arnold |
|
1059 | + */ |
|
1060 | + function isSessionAuthenticated() { |
|
1061 | + global $PHPCAS_CLIENT; |
|
1062 | + if (!is_object($PHPCAS_CLIENT)) { |
|
1063 | + phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()'); |
|
1064 | + } |
|
1065 | + return ($PHPCAS_CLIENT->isSessionAuthenticated()); |
|
1066 | + } |
|
1067 | + |
|
1068 | + /** |
|
1069 | + * This method returns the CAS user's login name. |
|
1070 | + * @warning should not be called only after phpCAS::forceAuthentication() |
|
1071 | + * or phpCAS::checkAuthentication(). |
|
1072 | + * |
|
1073 | + * @return the login name of the authenticated user |
|
1074 | + */ |
|
1075 | + function getUser() { |
|
1076 | + global $PHPCAS_CLIENT, $PHPCAS_AUTH_CHECK_CALL; |
|
1077 | + if (!is_object($PHPCAS_CLIENT)) { |
|
1078 | + phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()'); |
|
1079 | + } |
|
1080 | + if (!$PHPCAS_AUTH_CHECK_CALL['done']) { |
|
1081 | + phpCAS :: error('this method should only be called after ' . __CLASS__ . '::forceAuthentication() or ' . __CLASS__ . '::isAuthenticated()'); |
|
1082 | + } |
|
1083 | + if (!$PHPCAS_AUTH_CHECK_CALL['result']) { |
|
1084 | + phpCAS :: error('authentication was checked (by ' . $PHPCAS_AUTH_CHECK_CALL['method'] . '() at ' . $PHPCAS_AUTH_CHECK_CALL['file'] . ':' . $PHPCAS_AUTH_CHECK_CALL['line'] . ') but the method returned FALSE'); |
|
1085 | + } |
|
1086 | + return $PHPCAS_CLIENT->getUser(); |
|
1087 | + } |
|
1088 | + |
|
1089 | + /** |
|
1090 | + * This method returns the CAS user's login name. |
|
1091 | + * @warning should not be called only after phpCAS::forceAuthentication() |
|
1092 | + * or phpCAS::checkAuthentication(). |
|
1093 | + * |
|
1094 | + * @return the login name of the authenticated user |
|
1095 | + */ |
|
1096 | + function getAttributes() { |
|
1097 | + global $PHPCAS_CLIENT, $PHPCAS_AUTH_CHECK_CALL; |
|
1098 | + if (!is_object($PHPCAS_CLIENT)) { |
|
1099 | + phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()'); |
|
1100 | + } |
|
1101 | + if (!$PHPCAS_AUTH_CHECK_CALL['done']) { |
|
1102 | + phpCAS :: error('this method should only be called after ' . __CLASS__ . '::forceAuthentication() or ' . __CLASS__ . '::isAuthenticated()'); |
|
1103 | + } |
|
1104 | + if (!$PHPCAS_AUTH_CHECK_CALL['result']) { |
|
1105 | + phpCAS :: error('authentication was checked (by ' . $PHPCAS_AUTH_CHECK_CALL['method'] . '() at ' . $PHPCAS_AUTH_CHECK_CALL['file'] . ':' . $PHPCAS_AUTH_CHECK_CALL['line'] . ') but the method returned FALSE'); |
|
1106 | + } |
|
1107 | + return $PHPCAS_CLIENT->getAttributes(); |
|
1108 | + } |
|
1109 | + /** |
|
1110 | + * Handle logout requests. |
|
1111 | + */ |
|
1112 | + function handleLogoutRequests($check_client = true, $allowed_clients = false) { |
|
1113 | + global $PHPCAS_CLIENT; |
|
1114 | + if (!is_object($PHPCAS_CLIENT)) { |
|
1115 | + phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()'); |
|
1116 | + } |
|
1117 | + return ($PHPCAS_CLIENT->handleLogoutRequests($check_client, $allowed_clients)); |
|
1118 | + } |
|
1119 | + |
|
1120 | + /** |
|
1121 | + * This method returns the URL to be used to login. |
|
1122 | + * or phpCAS::isAuthenticated(). |
|
1123 | + * |
|
1124 | + * @return the login name of the authenticated user |
|
1125 | + */ |
|
1126 | + function getServerLoginURL() { |
|
1127 | + global $PHPCAS_CLIENT; |
|
1128 | + if (!is_object($PHPCAS_CLIENT)) { |
|
1129 | + phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()'); |
|
1130 | + } |
|
1131 | + return $PHPCAS_CLIENT->getServerLoginURL(); |
|
1132 | + } |
|
1133 | + |
|
1134 | + /** |
|
1135 | + * Set the login URL of the CAS server. |
|
1136 | + * @param $url the login URL |
|
1137 | + * @since 0.4.21 by Wyman Chan |
|
1138 | + */ |
|
1139 | + function setServerLoginURL($url = '') { |
|
1140 | + global $PHPCAS_CLIENT; |
|
1141 | + phpCAS :: traceBegin(); |
|
1142 | + if (!is_object($PHPCAS_CLIENT)) { |
|
1143 | + phpCAS :: error('this method should only be called after |
|
1144 | 1144 | ' . __CLASS__ . '::client()'); |
1145 | - } |
|
1146 | - if (gettype($url) != 'string') { |
|
1147 | - phpCAS :: error('type mismatched for parameter $url (should be |
|
1145 | + } |
|
1146 | + if (gettype($url) != 'string') { |
|
1147 | + phpCAS :: error('type mismatched for parameter $url (should be |
|
1148 | 1148 | `string\')'); |
1149 | - } |
|
1150 | - $PHPCAS_CLIENT->setServerLoginURL($url); |
|
1151 | - phpCAS :: traceEnd(); |
|
1152 | - } |
|
1153 | - |
|
1154 | - /** |
|
1155 | - * Set the serviceValidate URL of the CAS server. |
|
1156 | - * Used only in CAS 1.0 validations |
|
1157 | - * @param $url the serviceValidate URL |
|
1158 | - * @since 1.1.0 by Joachim Fritschi |
|
1159 | - */ |
|
1160 | - function setServerServiceValidateURL($url = '') { |
|
1161 | - global $PHPCAS_CLIENT; |
|
1162 | - phpCAS :: traceBegin(); |
|
1163 | - if (!is_object($PHPCAS_CLIENT)) { |
|
1164 | - phpCAS :: error('this method should only be called after |
|
1149 | + } |
|
1150 | + $PHPCAS_CLIENT->setServerLoginURL($url); |
|
1151 | + phpCAS :: traceEnd(); |
|
1152 | + } |
|
1153 | + |
|
1154 | + /** |
|
1155 | + * Set the serviceValidate URL of the CAS server. |
|
1156 | + * Used only in CAS 1.0 validations |
|
1157 | + * @param $url the serviceValidate URL |
|
1158 | + * @since 1.1.0 by Joachim Fritschi |
|
1159 | + */ |
|
1160 | + function setServerServiceValidateURL($url = '') { |
|
1161 | + global $PHPCAS_CLIENT; |
|
1162 | + phpCAS :: traceBegin(); |
|
1163 | + if (!is_object($PHPCAS_CLIENT)) { |
|
1164 | + phpCAS :: error('this method should only be called after |
|
1165 | 1165 | ' . __CLASS__ . '::client()'); |
1166 | - } |
|
1167 | - if (gettype($url) != 'string') { |
|
1168 | - phpCAS :: error('type mismatched for parameter $url (should be |
|
1166 | + } |
|
1167 | + if (gettype($url) != 'string') { |
|
1168 | + phpCAS :: error('type mismatched for parameter $url (should be |
|
1169 | 1169 | `string\')'); |
1170 | - } |
|
1171 | - $PHPCAS_CLIENT->setServerServiceValidateURL($url); |
|
1172 | - phpCAS :: traceEnd(); |
|
1173 | - } |
|
1174 | - |
|
1175 | - /** |
|
1176 | - * Set the proxyValidate URL of the CAS server. |
|
1177 | - * Used for all CAS 2.0 validations |
|
1178 | - * @param $url the proxyValidate URL |
|
1179 | - * @since 1.1.0 by Joachim Fritschi |
|
1180 | - */ |
|
1181 | - function setServerProxyValidateURL($url = '') { |
|
1182 | - global $PHPCAS_CLIENT; |
|
1183 | - phpCAS :: traceBegin(); |
|
1184 | - if (!is_object($PHPCAS_CLIENT)) { |
|
1185 | - phpCAS :: error('this method should only be called after |
|
1170 | + } |
|
1171 | + $PHPCAS_CLIENT->setServerServiceValidateURL($url); |
|
1172 | + phpCAS :: traceEnd(); |
|
1173 | + } |
|
1174 | + |
|
1175 | + /** |
|
1176 | + * Set the proxyValidate URL of the CAS server. |
|
1177 | + * Used for all CAS 2.0 validations |
|
1178 | + * @param $url the proxyValidate URL |
|
1179 | + * @since 1.1.0 by Joachim Fritschi |
|
1180 | + */ |
|
1181 | + function setServerProxyValidateURL($url = '') { |
|
1182 | + global $PHPCAS_CLIENT; |
|
1183 | + phpCAS :: traceBegin(); |
|
1184 | + if (!is_object($PHPCAS_CLIENT)) { |
|
1185 | + phpCAS :: error('this method should only be called after |
|
1186 | 1186 | ' . __CLASS__ . '::client()'); |
1187 | - } |
|
1188 | - if (gettype($url) != 'string') { |
|
1189 | - phpCAS :: error('type mismatched for parameter $url (should be |
|
1187 | + } |
|
1188 | + if (gettype($url) != 'string') { |
|
1189 | + phpCAS :: error('type mismatched for parameter $url (should be |
|
1190 | 1190 | `string\')'); |
1191 | - } |
|
1192 | - $PHPCAS_CLIENT->setServerProxyValidateURL($url); |
|
1193 | - phpCAS :: traceEnd(); |
|
1194 | - } |
|
1195 | - |
|
1196 | - /** |
|
1197 | - * Set the samlValidate URL of the CAS server. |
|
1198 | - * @param $url the samlValidate URL |
|
1199 | - * @since 1.1.0 by Joachim Fritschi |
|
1200 | - */ |
|
1201 | - function setServerSamlValidateURL($url = '') { |
|
1202 | - global $PHPCAS_CLIENT; |
|
1203 | - phpCAS :: traceBegin(); |
|
1204 | - if (!is_object($PHPCAS_CLIENT)) { |
|
1205 | - phpCAS :: error('this method should only be called after |
|
1191 | + } |
|
1192 | + $PHPCAS_CLIENT->setServerProxyValidateURL($url); |
|
1193 | + phpCAS :: traceEnd(); |
|
1194 | + } |
|
1195 | + |
|
1196 | + /** |
|
1197 | + * Set the samlValidate URL of the CAS server. |
|
1198 | + * @param $url the samlValidate URL |
|
1199 | + * @since 1.1.0 by Joachim Fritschi |
|
1200 | + */ |
|
1201 | + function setServerSamlValidateURL($url = '') { |
|
1202 | + global $PHPCAS_CLIENT; |
|
1203 | + phpCAS :: traceBegin(); |
|
1204 | + if (!is_object($PHPCAS_CLIENT)) { |
|
1205 | + phpCAS :: error('this method should only be called after |
|
1206 | 1206 | ' . __CLASS__ . '::client()'); |
1207 | - } |
|
1208 | - if (gettype($url) != 'string') { |
|
1209 | - phpCAS :: error('type mismatched for parameter $url (should be |
|
1207 | + } |
|
1208 | + if (gettype($url) != 'string') { |
|
1209 | + phpCAS :: error('type mismatched for parameter $url (should be |
|
1210 | 1210 | `string\')'); |
1211 | - } |
|
1212 | - $PHPCAS_CLIENT->setServerSamlValidateURL($url); |
|
1213 | - phpCAS :: traceEnd(); |
|
1214 | - } |
|
1215 | - |
|
1216 | - /** |
|
1217 | - * This method returns the URL to be used to login. |
|
1218 | - * or phpCAS::isAuthenticated(). |
|
1219 | - * |
|
1220 | - * @return the login name of the authenticated user |
|
1221 | - */ |
|
1222 | - function getServerLogoutURL() { |
|
1223 | - global $PHPCAS_CLIENT; |
|
1224 | - if (!is_object($PHPCAS_CLIENT)) { |
|
1225 | - phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()'); |
|
1226 | - } |
|
1227 | - return $PHPCAS_CLIENT->getServerLogoutURL(); |
|
1228 | - } |
|
1229 | - |
|
1230 | - /** |
|
1231 | - * Set the logout URL of the CAS server. |
|
1232 | - * @param $url the logout URL |
|
1233 | - * @since 0.4.21 by Wyman Chan |
|
1234 | - */ |
|
1235 | - function setServerLogoutURL($url = '') { |
|
1236 | - global $PHPCAS_CLIENT; |
|
1237 | - phpCAS :: traceBegin(); |
|
1238 | - if (!is_object($PHPCAS_CLIENT)) { |
|
1239 | - phpCAS :: error('this method should only be called after |
|
1211 | + } |
|
1212 | + $PHPCAS_CLIENT->setServerSamlValidateURL($url); |
|
1213 | + phpCAS :: traceEnd(); |
|
1214 | + } |
|
1215 | + |
|
1216 | + /** |
|
1217 | + * This method returns the URL to be used to login. |
|
1218 | + * or phpCAS::isAuthenticated(). |
|
1219 | + * |
|
1220 | + * @return the login name of the authenticated user |
|
1221 | + */ |
|
1222 | + function getServerLogoutURL() { |
|
1223 | + global $PHPCAS_CLIENT; |
|
1224 | + if (!is_object($PHPCAS_CLIENT)) { |
|
1225 | + phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()'); |
|
1226 | + } |
|
1227 | + return $PHPCAS_CLIENT->getServerLogoutURL(); |
|
1228 | + } |
|
1229 | + |
|
1230 | + /** |
|
1231 | + * Set the logout URL of the CAS server. |
|
1232 | + * @param $url the logout URL |
|
1233 | + * @since 0.4.21 by Wyman Chan |
|
1234 | + */ |
|
1235 | + function setServerLogoutURL($url = '') { |
|
1236 | + global $PHPCAS_CLIENT; |
|
1237 | + phpCAS :: traceBegin(); |
|
1238 | + if (!is_object($PHPCAS_CLIENT)) { |
|
1239 | + phpCAS :: error('this method should only be called after |
|
1240 | 1240 | ' . __CLASS__ . '::client()'); |
1241 | - } |
|
1242 | - if (gettype($url) != 'string') { |
|
1243 | - phpCAS :: error('type mismatched for parameter $url (should be |
|
1241 | + } |
|
1242 | + if (gettype($url) != 'string') { |
|
1243 | + phpCAS :: error('type mismatched for parameter $url (should be |
|
1244 | 1244 | `string\')'); |
1245 | - } |
|
1246 | - $PHPCAS_CLIENT->setServerLogoutURL($url); |
|
1247 | - phpCAS :: traceEnd(); |
|
1248 | - } |
|
1249 | - |
|
1250 | - /** |
|
1251 | - * This method is used to logout from CAS. |
|
1252 | - * @params $params an array that contains the optional url and service parameters that will be passed to the CAS server |
|
1253 | - * @public |
|
1254 | - */ |
|
1255 | - function logout($params = "") { |
|
1256 | - global $PHPCAS_CLIENT; |
|
1257 | - phpCAS :: traceBegin(); |
|
1258 | - if (!is_object($PHPCAS_CLIENT)) { |
|
1259 | - phpCAS :: error('this method should only be called after ' . __CLASS__ . '::client() or' . __CLASS__ . '::proxy()'); |
|
1260 | - } |
|
1261 | - $parsedParams = array (); |
|
1262 | - if ($params != "") { |
|
1263 | - if (is_string($params)) { |
|
1264 | - phpCAS :: error('method `phpCAS::logout($url)\' is now deprecated, use `phpCAS::logoutWithUrl($url)\' instead'); |
|
1265 | - } |
|
1266 | - if (!is_array($params)) { |
|
1267 | - phpCAS :: error('type mismatched for parameter $params (should be `array\')'); |
|
1268 | - } |
|
1269 | - foreach ($params as $key => $value) { |
|
1270 | - if ($key != "service" && $key != "url") { |
|
1271 | - phpCAS :: error('only `url\' and `service\' parameters are allowed for method `phpCAS::logout($params)\''); |
|
1272 | - } |
|
1273 | - $parsedParams[$key] = $value; |
|
1274 | - } |
|
1275 | - } |
|
1276 | - $PHPCAS_CLIENT->logout($parsedParams); |
|
1277 | - // never reached |
|
1278 | - phpCAS :: traceEnd(); |
|
1279 | - } |
|
1280 | - |
|
1281 | - /** |
|
1282 | - * This method is used to logout from CAS. Halts by redirecting to the CAS server. |
|
1283 | - * @param $service a URL that will be transmitted to the CAS server |
|
1284 | - */ |
|
1285 | - function logoutWithRedirectService($service) { |
|
1286 | - global $PHPCAS_CLIENT; |
|
1287 | - phpCAS :: traceBegin(); |
|
1288 | - if (!is_object($PHPCAS_CLIENT)) { |
|
1289 | - phpCAS :: error('this method should only be called after ' . __CLASS__ . '::client() or' . __CLASS__ . '::proxy()'); |
|
1290 | - } |
|
1291 | - if (!is_string($service)) { |
|
1292 | - phpCAS :: error('type mismatched for parameter $service (should be `string\')'); |
|
1293 | - } |
|
1294 | - $PHPCAS_CLIENT->logout(array ( |
|
1295 | - "service" => $service |
|
1296 | - )); |
|
1297 | - // never reached |
|
1298 | - phpCAS :: traceEnd(); |
|
1299 | - } |
|
1300 | - |
|
1301 | - /** |
|
1302 | - * This method is used to logout from CAS. Halts by redirecting to the CAS server. |
|
1303 | - * @param $url a URL that will be transmitted to the CAS server |
|
1304 | - */ |
|
1305 | - function logoutWithUrl($url) { |
|
1306 | - global $PHPCAS_CLIENT; |
|
1307 | - phpCAS :: traceBegin(); |
|
1308 | - if (!is_object($PHPCAS_CLIENT)) { |
|
1309 | - phpCAS :: error('this method should only be called after ' . __CLASS__ . '::client() or' . __CLASS__ . '::proxy()'); |
|
1310 | - } |
|
1311 | - if (!is_string($url)) { |
|
1312 | - phpCAS :: error('type mismatched for parameter $url (should be `string\')'); |
|
1313 | - } |
|
1314 | - $PHPCAS_CLIENT->logout(array ( |
|
1315 | - "url" => $url |
|
1316 | - )); |
|
1317 | - // never reached |
|
1318 | - phpCAS :: traceEnd(); |
|
1319 | - } |
|
1320 | - |
|
1321 | - /** |
|
1322 | - * This method is used to logout from CAS. Halts by redirecting to the CAS server. |
|
1323 | - * @param $service a URL that will be transmitted to the CAS server |
|
1324 | - * @param $url a URL that will be transmitted to the CAS server |
|
1325 | - */ |
|
1326 | - function logoutWithRedirectServiceAndUrl($service, $url) { |
|
1327 | - global $PHPCAS_CLIENT; |
|
1328 | - phpCAS :: traceBegin(); |
|
1329 | - if (!is_object($PHPCAS_CLIENT)) { |
|
1330 | - phpCAS :: error('this method should only be called after ' . __CLASS__ . '::client() or' . __CLASS__ . '::proxy()'); |
|
1331 | - } |
|
1332 | - if (!is_string($service)) { |
|
1333 | - phpCAS :: error('type mismatched for parameter $service (should be `string\')'); |
|
1334 | - } |
|
1335 | - if (!is_string($url)) { |
|
1336 | - phpCAS :: error('type mismatched for parameter $url (should be `string\')'); |
|
1337 | - } |
|
1338 | - $PHPCAS_CLIENT->logout(array ( |
|
1339 | - "service" => $service, |
|
1340 | - "url" => $url |
|
1341 | - )); |
|
1342 | - // never reached |
|
1343 | - phpCAS :: traceEnd(); |
|
1344 | - } |
|
1345 | - |
|
1346 | - /** |
|
1347 | - * Set the fixed URL that will be used by the CAS server to transmit the PGT. |
|
1348 | - * When this method is not called, a phpCAS script uses its own URL for the callback. |
|
1349 | - * |
|
1350 | - * @param $url the URL |
|
1351 | - */ |
|
1352 | - function setFixedCallbackURL($url = '') { |
|
1353 | - global $PHPCAS_CLIENT; |
|
1354 | - phpCAS :: traceBegin(); |
|
1355 | - if (!is_object($PHPCAS_CLIENT)) { |
|
1356 | - phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()'); |
|
1357 | - } |
|
1358 | - if (!$PHPCAS_CLIENT->isProxy()) { |
|
1359 | - phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()'); |
|
1360 | - } |
|
1361 | - if (gettype($url) != 'string') { |
|
1362 | - phpCAS :: error('type mismatched for parameter $url (should be `string\')'); |
|
1363 | - } |
|
1364 | - $PHPCAS_CLIENT->setCallbackURL($url); |
|
1365 | - phpCAS :: traceEnd(); |
|
1366 | - } |
|
1367 | - |
|
1368 | - /** |
|
1369 | - * Set the fixed URL that will be set as the CAS service parameter. When this |
|
1370 | - * method is not called, a phpCAS script uses its own URL. |
|
1371 | - * |
|
1372 | - * @param $url the URL |
|
1373 | - */ |
|
1374 | - function setFixedServiceURL($url) { |
|
1375 | - global $PHPCAS_CLIENT; |
|
1376 | - phpCAS :: traceBegin(); |
|
1377 | - if (!is_object($PHPCAS_CLIENT)) { |
|
1378 | - phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()'); |
|
1379 | - } |
|
1380 | - if (gettype($url) != 'string') { |
|
1381 | - phpCAS :: error('type mismatched for parameter $url (should be `string\')'); |
|
1382 | - } |
|
1383 | - $PHPCAS_CLIENT->setURL($url); |
|
1384 | - phpCAS :: traceEnd(); |
|
1385 | - } |
|
1386 | - |
|
1387 | - /** |
|
1388 | - * Get the URL that is set as the CAS service parameter. |
|
1389 | - */ |
|
1390 | - function getServiceURL() { |
|
1391 | - global $PHPCAS_CLIENT; |
|
1392 | - if (!is_object($PHPCAS_CLIENT)) { |
|
1393 | - phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()'); |
|
1394 | - } |
|
1395 | - return ($PHPCAS_CLIENT->getURL()); |
|
1396 | - } |
|
1397 | - |
|
1398 | - /** |
|
1399 | - * Retrieve a Proxy Ticket from the CAS server. |
|
1400 | - */ |
|
1401 | - function retrievePT($target_service, & $err_code, & $err_msg) { |
|
1402 | - global $PHPCAS_CLIENT; |
|
1403 | - if (!is_object($PHPCAS_CLIENT)) { |
|
1404 | - phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()'); |
|
1405 | - } |
|
1406 | - if (gettype($target_service) != 'string') { |
|
1407 | - phpCAS :: error('type mismatched for parameter $target_service(should be `string\')'); |
|
1408 | - } |
|
1409 | - return ($PHPCAS_CLIENT->retrievePT($target_service, $err_code, $err_msg)); |
|
1410 | - } |
|
1411 | - |
|
1412 | - /** |
|
1413 | - * Set the certificate of the CAS server. |
|
1414 | - * |
|
1415 | - * @param $cert the PEM certificate |
|
1416 | - */ |
|
1417 | - function setCasServerCert($cert) { |
|
1418 | - global $PHPCAS_CLIENT; |
|
1419 | - phpCAS :: traceBegin(); |
|
1420 | - if (!is_object($PHPCAS_CLIENT)) { |
|
1421 | - phpCAS :: error('this method should only be called after ' . __CLASS__ . '::client() or' . __CLASS__ . '::proxy()'); |
|
1422 | - } |
|
1423 | - if (gettype($cert) != 'string') { |
|
1424 | - phpCAS :: error('type mismatched for parameter $cert (should be `string\')'); |
|
1425 | - } |
|
1426 | - $PHPCAS_CLIENT->setCasServerCert($cert); |
|
1427 | - phpCAS :: traceEnd(); |
|
1428 | - } |
|
1429 | - |
|
1430 | - /** |
|
1431 | - * Set the certificate of the CAS server CA. |
|
1432 | - * |
|
1433 | - * @param $cert the CA certificate |
|
1434 | - */ |
|
1435 | - function setCasServerCACert($cert) { |
|
1436 | - global $PHPCAS_CLIENT; |
|
1437 | - phpCAS :: traceBegin(); |
|
1438 | - if (!is_object($PHPCAS_CLIENT)) { |
|
1439 | - phpCAS :: error('this method should only be called after ' . __CLASS__ . '::client() or' . __CLASS__ . '::proxy()'); |
|
1440 | - } |
|
1441 | - if (gettype($cert) != 'string') { |
|
1442 | - phpCAS :: error('type mismatched for parameter $cert (should be `string\')'); |
|
1443 | - } |
|
1444 | - $PHPCAS_CLIENT->setCasServerCACert($cert); |
|
1445 | - phpCAS :: traceEnd(); |
|
1446 | - } |
|
1447 | - |
|
1448 | - /** |
|
1449 | - * Set no SSL validation for the CAS server. |
|
1450 | - */ |
|
1451 | - function setNoCasServerValidation() { |
|
1452 | - global $PHPCAS_CLIENT; |
|
1453 | - phpCAS :: traceBegin(); |
|
1454 | - if (!is_object($PHPCAS_CLIENT)) { |
|
1455 | - phpCAS :: error('this method should only be called after ' . __CLASS__ . '::client() or' . __CLASS__ . '::proxy()'); |
|
1456 | - } |
|
1457 | - $PHPCAS_CLIENT->setNoCasServerValidation(); |
|
1458 | - phpCAS :: traceEnd(); |
|
1459 | - } |
|
1460 | - |
|
1461 | - /** @} */ |
|
1462 | - |
|
1463 | - /** |
|
1464 | - * Change CURL options. |
|
1465 | - * CURL is used to connect through HTTPS to CAS server |
|
1466 | - * @param $key the option key |
|
1467 | - * @param $value the value to set |
|
1468 | - */ |
|
1469 | - function setExtraCurlOption($key, $value) { |
|
1470 | - global $PHPCAS_CLIENT; |
|
1471 | - phpCAS :: traceBegin(); |
|
1472 | - if (!is_object($PHPCAS_CLIENT)) { |
|
1473 | - phpCAS :: error('this method should only be called after ' . __CLASS__ . '::client() or' . __CLASS__ . '::proxy()'); |
|
1474 | - } |
|
1475 | - $PHPCAS_CLIENT->setExtraCurlOption($key, $value); |
|
1476 | - phpCAS :: traceEnd(); |
|
1477 | - } |
|
1245 | + } |
|
1246 | + $PHPCAS_CLIENT->setServerLogoutURL($url); |
|
1247 | + phpCAS :: traceEnd(); |
|
1248 | + } |
|
1249 | + |
|
1250 | + /** |
|
1251 | + * This method is used to logout from CAS. |
|
1252 | + * @params $params an array that contains the optional url and service parameters that will be passed to the CAS server |
|
1253 | + * @public |
|
1254 | + */ |
|
1255 | + function logout($params = "") { |
|
1256 | + global $PHPCAS_CLIENT; |
|
1257 | + phpCAS :: traceBegin(); |
|
1258 | + if (!is_object($PHPCAS_CLIENT)) { |
|
1259 | + phpCAS :: error('this method should only be called after ' . __CLASS__ . '::client() or' . __CLASS__ . '::proxy()'); |
|
1260 | + } |
|
1261 | + $parsedParams = array (); |
|
1262 | + if ($params != "") { |
|
1263 | + if (is_string($params)) { |
|
1264 | + phpCAS :: error('method `phpCAS::logout($url)\' is now deprecated, use `phpCAS::logoutWithUrl($url)\' instead'); |
|
1265 | + } |
|
1266 | + if (!is_array($params)) { |
|
1267 | + phpCAS :: error('type mismatched for parameter $params (should be `array\')'); |
|
1268 | + } |
|
1269 | + foreach ($params as $key => $value) { |
|
1270 | + if ($key != "service" && $key != "url") { |
|
1271 | + phpCAS :: error('only `url\' and `service\' parameters are allowed for method `phpCAS::logout($params)\''); |
|
1272 | + } |
|
1273 | + $parsedParams[$key] = $value; |
|
1274 | + } |
|
1275 | + } |
|
1276 | + $PHPCAS_CLIENT->logout($parsedParams); |
|
1277 | + // never reached |
|
1278 | + phpCAS :: traceEnd(); |
|
1279 | + } |
|
1280 | + |
|
1281 | + /** |
|
1282 | + * This method is used to logout from CAS. Halts by redirecting to the CAS server. |
|
1283 | + * @param $service a URL that will be transmitted to the CAS server |
|
1284 | + */ |
|
1285 | + function logoutWithRedirectService($service) { |
|
1286 | + global $PHPCAS_CLIENT; |
|
1287 | + phpCAS :: traceBegin(); |
|
1288 | + if (!is_object($PHPCAS_CLIENT)) { |
|
1289 | + phpCAS :: error('this method should only be called after ' . __CLASS__ . '::client() or' . __CLASS__ . '::proxy()'); |
|
1290 | + } |
|
1291 | + if (!is_string($service)) { |
|
1292 | + phpCAS :: error('type mismatched for parameter $service (should be `string\')'); |
|
1293 | + } |
|
1294 | + $PHPCAS_CLIENT->logout(array ( |
|
1295 | + "service" => $service |
|
1296 | + )); |
|
1297 | + // never reached |
|
1298 | + phpCAS :: traceEnd(); |
|
1299 | + } |
|
1300 | + |
|
1301 | + /** |
|
1302 | + * This method is used to logout from CAS. Halts by redirecting to the CAS server. |
|
1303 | + * @param $url a URL that will be transmitted to the CAS server |
|
1304 | + */ |
|
1305 | + function logoutWithUrl($url) { |
|
1306 | + global $PHPCAS_CLIENT; |
|
1307 | + phpCAS :: traceBegin(); |
|
1308 | + if (!is_object($PHPCAS_CLIENT)) { |
|
1309 | + phpCAS :: error('this method should only be called after ' . __CLASS__ . '::client() or' . __CLASS__ . '::proxy()'); |
|
1310 | + } |
|
1311 | + if (!is_string($url)) { |
|
1312 | + phpCAS :: error('type mismatched for parameter $url (should be `string\')'); |
|
1313 | + } |
|
1314 | + $PHPCAS_CLIENT->logout(array ( |
|
1315 | + "url" => $url |
|
1316 | + )); |
|
1317 | + // never reached |
|
1318 | + phpCAS :: traceEnd(); |
|
1319 | + } |
|
1320 | + |
|
1321 | + /** |
|
1322 | + * This method is used to logout from CAS. Halts by redirecting to the CAS server. |
|
1323 | + * @param $service a URL that will be transmitted to the CAS server |
|
1324 | + * @param $url a URL that will be transmitted to the CAS server |
|
1325 | + */ |
|
1326 | + function logoutWithRedirectServiceAndUrl($service, $url) { |
|
1327 | + global $PHPCAS_CLIENT; |
|
1328 | + phpCAS :: traceBegin(); |
|
1329 | + if (!is_object($PHPCAS_CLIENT)) { |
|
1330 | + phpCAS :: error('this method should only be called after ' . __CLASS__ . '::client() or' . __CLASS__ . '::proxy()'); |
|
1331 | + } |
|
1332 | + if (!is_string($service)) { |
|
1333 | + phpCAS :: error('type mismatched for parameter $service (should be `string\')'); |
|
1334 | + } |
|
1335 | + if (!is_string($url)) { |
|
1336 | + phpCAS :: error('type mismatched for parameter $url (should be `string\')'); |
|
1337 | + } |
|
1338 | + $PHPCAS_CLIENT->logout(array ( |
|
1339 | + "service" => $service, |
|
1340 | + "url" => $url |
|
1341 | + )); |
|
1342 | + // never reached |
|
1343 | + phpCAS :: traceEnd(); |
|
1344 | + } |
|
1345 | + |
|
1346 | + /** |
|
1347 | + * Set the fixed URL that will be used by the CAS server to transmit the PGT. |
|
1348 | + * When this method is not called, a phpCAS script uses its own URL for the callback. |
|
1349 | + * |
|
1350 | + * @param $url the URL |
|
1351 | + */ |
|
1352 | + function setFixedCallbackURL($url = '') { |
|
1353 | + global $PHPCAS_CLIENT; |
|
1354 | + phpCAS :: traceBegin(); |
|
1355 | + if (!is_object($PHPCAS_CLIENT)) { |
|
1356 | + phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()'); |
|
1357 | + } |
|
1358 | + if (!$PHPCAS_CLIENT->isProxy()) { |
|
1359 | + phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()'); |
|
1360 | + } |
|
1361 | + if (gettype($url) != 'string') { |
|
1362 | + phpCAS :: error('type mismatched for parameter $url (should be `string\')'); |
|
1363 | + } |
|
1364 | + $PHPCAS_CLIENT->setCallbackURL($url); |
|
1365 | + phpCAS :: traceEnd(); |
|
1366 | + } |
|
1367 | + |
|
1368 | + /** |
|
1369 | + * Set the fixed URL that will be set as the CAS service parameter. When this |
|
1370 | + * method is not called, a phpCAS script uses its own URL. |
|
1371 | + * |
|
1372 | + * @param $url the URL |
|
1373 | + */ |
|
1374 | + function setFixedServiceURL($url) { |
|
1375 | + global $PHPCAS_CLIENT; |
|
1376 | + phpCAS :: traceBegin(); |
|
1377 | + if (!is_object($PHPCAS_CLIENT)) { |
|
1378 | + phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()'); |
|
1379 | + } |
|
1380 | + if (gettype($url) != 'string') { |
|
1381 | + phpCAS :: error('type mismatched for parameter $url (should be `string\')'); |
|
1382 | + } |
|
1383 | + $PHPCAS_CLIENT->setURL($url); |
|
1384 | + phpCAS :: traceEnd(); |
|
1385 | + } |
|
1386 | + |
|
1387 | + /** |
|
1388 | + * Get the URL that is set as the CAS service parameter. |
|
1389 | + */ |
|
1390 | + function getServiceURL() { |
|
1391 | + global $PHPCAS_CLIENT; |
|
1392 | + if (!is_object($PHPCAS_CLIENT)) { |
|
1393 | + phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()'); |
|
1394 | + } |
|
1395 | + return ($PHPCAS_CLIENT->getURL()); |
|
1396 | + } |
|
1397 | + |
|
1398 | + /** |
|
1399 | + * Retrieve a Proxy Ticket from the CAS server. |
|
1400 | + */ |
|
1401 | + function retrievePT($target_service, & $err_code, & $err_msg) { |
|
1402 | + global $PHPCAS_CLIENT; |
|
1403 | + if (!is_object($PHPCAS_CLIENT)) { |
|
1404 | + phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()'); |
|
1405 | + } |
|
1406 | + if (gettype($target_service) != 'string') { |
|
1407 | + phpCAS :: error('type mismatched for parameter $target_service(should be `string\')'); |
|
1408 | + } |
|
1409 | + return ($PHPCAS_CLIENT->retrievePT($target_service, $err_code, $err_msg)); |
|
1410 | + } |
|
1411 | + |
|
1412 | + /** |
|
1413 | + * Set the certificate of the CAS server. |
|
1414 | + * |
|
1415 | + * @param $cert the PEM certificate |
|
1416 | + */ |
|
1417 | + function setCasServerCert($cert) { |
|
1418 | + global $PHPCAS_CLIENT; |
|
1419 | + phpCAS :: traceBegin(); |
|
1420 | + if (!is_object($PHPCAS_CLIENT)) { |
|
1421 | + phpCAS :: error('this method should only be called after ' . __CLASS__ . '::client() or' . __CLASS__ . '::proxy()'); |
|
1422 | + } |
|
1423 | + if (gettype($cert) != 'string') { |
|
1424 | + phpCAS :: error('type mismatched for parameter $cert (should be `string\')'); |
|
1425 | + } |
|
1426 | + $PHPCAS_CLIENT->setCasServerCert($cert); |
|
1427 | + phpCAS :: traceEnd(); |
|
1428 | + } |
|
1429 | + |
|
1430 | + /** |
|
1431 | + * Set the certificate of the CAS server CA. |
|
1432 | + * |
|
1433 | + * @param $cert the CA certificate |
|
1434 | + */ |
|
1435 | + function setCasServerCACert($cert) { |
|
1436 | + global $PHPCAS_CLIENT; |
|
1437 | + phpCAS :: traceBegin(); |
|
1438 | + if (!is_object($PHPCAS_CLIENT)) { |
|
1439 | + phpCAS :: error('this method should only be called after ' . __CLASS__ . '::client() or' . __CLASS__ . '::proxy()'); |
|
1440 | + } |
|
1441 | + if (gettype($cert) != 'string') { |
|
1442 | + phpCAS :: error('type mismatched for parameter $cert (should be `string\')'); |
|
1443 | + } |
|
1444 | + $PHPCAS_CLIENT->setCasServerCACert($cert); |
|
1445 | + phpCAS :: traceEnd(); |
|
1446 | + } |
|
1447 | + |
|
1448 | + /** |
|
1449 | + * Set no SSL validation for the CAS server. |
|
1450 | + */ |
|
1451 | + function setNoCasServerValidation() { |
|
1452 | + global $PHPCAS_CLIENT; |
|
1453 | + phpCAS :: traceBegin(); |
|
1454 | + if (!is_object($PHPCAS_CLIENT)) { |
|
1455 | + phpCAS :: error('this method should only be called after ' . __CLASS__ . '::client() or' . __CLASS__ . '::proxy()'); |
|
1456 | + } |
|
1457 | + $PHPCAS_CLIENT->setNoCasServerValidation(); |
|
1458 | + phpCAS :: traceEnd(); |
|
1459 | + } |
|
1460 | + |
|
1461 | + /** @} */ |
|
1462 | + |
|
1463 | + /** |
|
1464 | + * Change CURL options. |
|
1465 | + * CURL is used to connect through HTTPS to CAS server |
|
1466 | + * @param $key the option key |
|
1467 | + * @param $value the value to set |
|
1468 | + */ |
|
1469 | + function setExtraCurlOption($key, $value) { |
|
1470 | + global $PHPCAS_CLIENT; |
|
1471 | + phpCAS :: traceBegin(); |
|
1472 | + if (!is_object($PHPCAS_CLIENT)) { |
|
1473 | + phpCAS :: error('this method should only be called after ' . __CLASS__ . '::client() or' . __CLASS__ . '::proxy()'); |
|
1474 | + } |
|
1475 | + $PHPCAS_CLIENT->setExtraCurlOption($key, $value); |
|
1476 | + phpCAS :: traceEnd(); |
|
1477 | + } |
|
1478 | 1478 | |
1479 | 1479 | } |
1480 | 1480 |
@@ -33,14 +33,14 @@ discard block |
||
33 | 33 | // hack by Vangelis Haniotakis to handle the absence of $_SERVER['REQUEST_URI'] in IIS |
34 | 34 | // |
35 | 35 | if (!$_SERVER['REQUEST_URI']) { |
36 | - $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] . '?' . $_SERVER['QUERY_STRING']; |
|
36 | + $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'].'?'.$_SERVER['QUERY_STRING']; |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | // |
40 | 40 | // another one by Vangelis Haniotakis also to make phpCAS work with PHP5 |
41 | 41 | // |
42 | 42 | if (version_compare(PHP_VERSION, '5', '>=')) { |
43 | - require_once (dirname(__FILE__) . '/CAS/domxml-php4-to-php5.php'); |
|
43 | + require_once (dirname(__FILE__).'/CAS/domxml-php4-to-php5.php'); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | /** |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | * |
282 | 282 | * @hideinitializer |
283 | 283 | */ |
284 | -$GLOBALS['PHPCAS_INIT_CALL'] = array ( |
|
284 | +$GLOBALS['PHPCAS_INIT_CALL'] = array( |
|
285 | 285 | 'done' => FALSE, |
286 | 286 | 'file' => '?', |
287 | 287 | 'line' => -1, |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | * |
295 | 295 | * @hideinitializer |
296 | 296 | */ |
297 | -$GLOBALS['PHPCAS_AUTH_CHECK_CALL'] = array ( |
|
297 | +$GLOBALS['PHPCAS_AUTH_CHECK_CALL'] = array( |
|
298 | 298 | 'done' => FALSE, |
299 | 299 | 'file' => '?', |
300 | 300 | 'line' => -1, |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | * |
308 | 308 | * @hideinitializer |
309 | 309 | */ |
310 | -$GLOBALS['PHPCAS_DEBUG'] = array ( |
|
310 | +$GLOBALS['PHPCAS_DEBUG'] = array( |
|
311 | 311 | 'filename' => '/tmp/cas.log', |
312 | 312 | 'indent' => 0, |
313 | 313 | 'unique_id' => '' |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | // ######################################################################## |
321 | 321 | |
322 | 322 | // include client class |
323 | -include_once (dirname(__FILE__) . '/CAS/client.php'); |
|
323 | +include_once (dirname(__FILE__).'/CAS/client.php'); |
|
324 | 324 | |
325 | 325 | // ######################################################################## |
326 | 326 | // INTERFACE CLASS |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | |
369 | 369 | phpCAS :: traceBegin(); |
370 | 370 | if (is_object($PHPCAS_CLIENT)) { |
371 | - phpCAS :: error($PHPCAS_INIT_CALL['method'] . '() has already been called (at ' . $PHPCAS_INIT_CALL['file'] . ':' . $PHPCAS_INIT_CALL['line'] . ')'); |
|
371 | + phpCAS :: error($PHPCAS_INIT_CALL['method'].'() has already been called (at '.$PHPCAS_INIT_CALL['file'].':'.$PHPCAS_INIT_CALL['line'].')'); |
|
372 | 372 | } |
373 | 373 | if (gettype($server_version) != 'string') { |
374 | 374 | phpCAS :: error('type mismatched for parameter $server_version (should be `string\')'); |
@@ -385,11 +385,11 @@ discard block |
||
385 | 385 | |
386 | 386 | // store where the initializer is called from |
387 | 387 | $dbg = phpCAS :: backtrace(); |
388 | - $PHPCAS_INIT_CALL = array ( |
|
388 | + $PHPCAS_INIT_CALL = array( |
|
389 | 389 | 'done' => TRUE, |
390 | 390 | 'file' => $dbg[0]['file'], |
391 | 391 | 'line' => $dbg[0]['line'], |
392 | - 'method' => __CLASS__ . '::' . __FUNCTION__ |
|
392 | + 'method' => __CLASS__.'::'.__FUNCTION__ |
|
393 | 393 | ); |
394 | 394 | |
395 | 395 | // initialize the global object $PHPCAS_CLIENT |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | |
418 | 418 | phpCAS :: traceBegin(); |
419 | 419 | if (is_object($PHPCAS_CLIENT)) { |
420 | - phpCAS :: error($PHPCAS_INIT_CALL['method'] . '() has already been called (at ' . $PHPCAS_INIT_CALL['file'] . ':' . $PHPCAS_INIT_CALL['line'] . ')'); |
|
420 | + phpCAS :: error($PHPCAS_INIT_CALL['method'].'() has already been called (at '.$PHPCAS_INIT_CALL['file'].':'.$PHPCAS_INIT_CALL['line'].')'); |
|
421 | 421 | } |
422 | 422 | if (gettype($server_version) != 'string') { |
423 | 423 | phpCAS :: error('type mismatched for parameter $server_version (should be `string\')'); |
@@ -434,11 +434,11 @@ discard block |
||
434 | 434 | |
435 | 435 | // store where the initialzer is called from |
436 | 436 | $dbg = phpCAS :: backtrace(); |
437 | - $PHPCAS_INIT_CALL = array ( |
|
437 | + $PHPCAS_INIT_CALL = array( |
|
438 | 438 | 'done' => TRUE, |
439 | 439 | 'file' => $dbg[0]['file'], |
440 | 440 | 'line' => $dbg[0]['line'], |
441 | - 'method' => __CLASS__ . '::' . __FUNCTION__ |
|
441 | + 'method' => __CLASS__.'::'.__FUNCTION__ |
|
442 | 442 | ); |
443 | 443 | |
444 | 444 | // initialize the global object $PHPCAS_CLIENT |
@@ -472,17 +472,17 @@ discard block |
||
472 | 472 | if (empty ($filename)) { |
473 | 473 | if (preg_match('/^Win.*/', getenv('OS'))) { |
474 | 474 | if (isset ($_ENV['TMP'])) { |
475 | - $debugDir = $_ENV['TMP'] . '/'; |
|
475 | + $debugDir = $_ENV['TMP'].'/'; |
|
476 | 476 | } else |
477 | 477 | if (isset ($_ENV['TEMP'])) { |
478 | - $debugDir = $_ENV['TEMP'] . '/'; |
|
478 | + $debugDir = $_ENV['TEMP'].'/'; |
|
479 | 479 | } else { |
480 | 480 | $debugDir = ''; |
481 | 481 | } |
482 | 482 | } else { |
483 | 483 | $debugDir = DEFAULT_DEBUG_DIR; |
484 | 484 | } |
485 | - $filename = $debugDir . 'phpCAS.log'; |
|
485 | + $filename = $debugDir.'phpCAS.log'; |
|
486 | 486 | } |
487 | 487 | |
488 | 488 | if (empty ($PHPCAS_DEBUG['unique_id'])) { |
@@ -509,7 +509,7 @@ discard block |
||
509 | 509 | return debug_backtrace(); |
510 | 510 | } else { |
511 | 511 | // poor man's hack ... but it does work ... |
512 | - return array (); |
|
512 | + return array(); |
|
513 | 513 | } |
514 | 514 | } |
515 | 515 | |
@@ -528,7 +528,7 @@ discard block |
||
528 | 528 | for ($i = 0; $i < $PHPCAS_DEBUG['indent']; $i++) { |
529 | 529 | $indent_str .= '| '; |
530 | 530 | } |
531 | - error_log($PHPCAS_DEBUG['unique_id'] . ' ' . $indent_str . $str . "\n", 3, $PHPCAS_DEBUG['filename']); |
|
531 | + error_log($PHPCAS_DEBUG['unique_id'].' '.$indent_str.$str."\n", 3, $PHPCAS_DEBUG['filename']); |
|
532 | 532 | } |
533 | 533 | |
534 | 534 | } |
@@ -557,7 +557,7 @@ discard block |
||
557 | 557 | } |
558 | 558 | } |
559 | 559 | } |
560 | - echo "<br />\n<b>phpCAS error</b>: <font color=\"FF0000\"><b>" . __CLASS__ . "::" . $function . '(): ' . htmlentities($msg) . "</b></font> in <b>" . $file . "</b> on line <b>" . $line . "</b><br />\n"; |
|
560 | + echo "<br />\n<b>phpCAS error</b>: <font color=\"FF0000\"><b>".__CLASS__."::".$function.'(): '.htmlentities($msg)."</b></font> in <b>".$file."</b> on line <b>".$line."</b><br />\n"; |
|
561 | 561 | phpCAS :: trace($msg); |
562 | 562 | phpCAS :: traceExit(); |
563 | 563 | exit (); |
@@ -568,7 +568,7 @@ discard block |
||
568 | 568 | */ |
569 | 569 | function trace($str) { |
570 | 570 | $dbg = phpCAS :: backtrace(); |
571 | - phpCAS :: log($str . ' [' . basename($dbg[1]['file']) . ':' . $dbg[1]['line'] . ']'); |
|
571 | + phpCAS :: log($str.' ['.basename($dbg[1]['file']).':'.$dbg[1]['line'].']'); |
|
572 | 572 | } |
573 | 573 | |
574 | 574 | /** |
@@ -580,9 +580,9 @@ discard block |
||
580 | 580 | $dbg = phpCAS :: backtrace(); |
581 | 581 | $str = '=> '; |
582 | 582 | if (!empty ($dbg[2]['class'])) { |
583 | - $str .= $dbg[2]['class'] . '::'; |
|
583 | + $str .= $dbg[2]['class'].'::'; |
|
584 | 584 | } |
585 | - $str .= $dbg[2]['function'] . '('; |
|
585 | + $str .= $dbg[2]['function'].'('; |
|
586 | 586 | if (is_array($dbg[2]['args'])) { |
587 | 587 | foreach ($dbg[2]['args'] as $index => $arg) { |
588 | 588 | if ($index != 0) { |
@@ -591,7 +591,7 @@ discard block |
||
591 | 591 | $str .= str_replace("\n", "", var_export($arg, TRUE)); |
592 | 592 | } |
593 | 593 | } |
594 | - $str .= ') [' . basename($dbg[2]['file']) . ':' . $dbg[2]['line'] . ']'; |
|
594 | + $str .= ') ['.basename($dbg[2]['file']).':'.$dbg[2]['line'].']'; |
|
595 | 595 | phpCAS :: log($str); |
596 | 596 | $PHPCAS_DEBUG['indent']++; |
597 | 597 | } |
@@ -607,7 +607,7 @@ discard block |
||
607 | 607 | $PHPCAS_DEBUG['indent']--; |
608 | 608 | $dbg = phpCAS :: backtrace(); |
609 | 609 | $str = ''; |
610 | - $str .= '<= ' . str_replace("\n", "", var_export($res, TRUE)); |
|
610 | + $str .= '<= '.str_replace("\n", "", var_export($res, TRUE)); |
|
611 | 611 | phpCAS :: log($str); |
612 | 612 | } |
613 | 613 | |
@@ -644,7 +644,7 @@ discard block |
||
644 | 644 | function setLang($lang) { |
645 | 645 | global $PHPCAS_CLIENT; |
646 | 646 | if (!is_object($PHPCAS_CLIENT)) { |
647 | - phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()'); |
|
647 | + phpCAS :: error('this method should not be called before '.__CLASS__.'::client() or '.__CLASS__.'::proxy()'); |
|
648 | 648 | } |
649 | 649 | if (gettype($lang) != 'string') { |
650 | 650 | phpCAS :: error('type mismatched for parameter $lang (should be `string\')'); |
@@ -687,7 +687,7 @@ discard block |
||
687 | 687 | function setHTMLHeader($header) { |
688 | 688 | global $PHPCAS_CLIENT; |
689 | 689 | if (!is_object($PHPCAS_CLIENT)) { |
690 | - phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()'); |
|
690 | + phpCAS :: error('this method should not be called before '.__CLASS__.'::client() or '.__CLASS__.'::proxy()'); |
|
691 | 691 | } |
692 | 692 | if (gettype($header) != 'string') { |
693 | 693 | phpCAS :: error('type mismatched for parameter $header (should be `string\')'); |
@@ -703,7 +703,7 @@ discard block |
||
703 | 703 | function setHTMLFooter($footer) { |
704 | 704 | global $PHPCAS_CLIENT; |
705 | 705 | if (!is_object($PHPCAS_CLIENT)) { |
706 | - phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()'); |
|
706 | + phpCAS :: error('this method should not be called before '.__CLASS__.'::client() or '.__CLASS__.'::proxy()'); |
|
707 | 707 | } |
708 | 708 | if (gettype($footer) != 'string') { |
709 | 709 | phpCAS :: error('type mismatched for parameter $footer (should be `string\')'); |
@@ -732,13 +732,13 @@ discard block |
||
732 | 732 | |
733 | 733 | phpCAS :: traceBegin(); |
734 | 734 | if (!is_object($PHPCAS_CLIENT)) { |
735 | - phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()'); |
|
735 | + phpCAS :: error('this method should only be called after '.__CLASS__.'::proxy()'); |
|
736 | 736 | } |
737 | 737 | if (!$PHPCAS_CLIENT->isProxy()) { |
738 | - phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()'); |
|
738 | + phpCAS :: error('this method should only be called after '.__CLASS__.'::proxy()'); |
|
739 | 739 | } |
740 | 740 | if ($PHPCAS_AUTH_CHECK_CALL['done']) { |
741 | - phpCAS :: error('this method should only be called before ' . $PHPCAS_AUTH_CHECK_CALL['method'] . '() (called at ' . $PHPCAS_AUTH_CHECK_CALL['file'] . ':' . $PHPCAS_AUTH_CHECK_CALL['line'] . ')'); |
|
741 | + phpCAS :: error('this method should only be called before '.$PHPCAS_AUTH_CHECK_CALL['method'].'() (called at '.$PHPCAS_AUTH_CHECK_CALL['file'].':'.$PHPCAS_AUTH_CHECK_CALL['line'].')'); |
|
742 | 742 | } |
743 | 743 | if (gettype($format) != 'string') { |
744 | 744 | phpCAS :: error('type mismatched for parameter $format (should be `string\')'); |
@@ -770,13 +770,13 @@ discard block |
||
770 | 770 | |
771 | 771 | phpCAS :: traceBegin(); |
772 | 772 | if (!is_object($PHPCAS_CLIENT)) { |
773 | - phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()'); |
|
773 | + phpCAS :: error('this method should only be called after '.__CLASS__.'::proxy()'); |
|
774 | 774 | } |
775 | 775 | if (!$PHPCAS_CLIENT->isProxy()) { |
776 | - phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()'); |
|
776 | + phpCAS :: error('this method should only be called after '.__CLASS__.'::proxy()'); |
|
777 | 777 | } |
778 | 778 | if ($PHPCAS_AUTH_CHECK_CALL['done']) { |
779 | - phpCAS :: error('this method should only be called before ' . $PHPCAS_AUTH_CHECK_CALL['method'] . '() (called at ' . $PHPCAS_AUTH_CHECK_CALL['file'] . ':' . $PHPCAS_AUTH_CHECK_CALL['line'] . ')'); |
|
779 | + phpCAS :: error('this method should only be called before '.$PHPCAS_AUTH_CHECK_CALL['method'].'() (called at '.$PHPCAS_AUTH_CHECK_CALL['file'].':'.$PHPCAS_AUTH_CHECK_CALL['line'].')'); |
|
780 | 780 | } |
781 | 781 | if (gettype($user) != 'string') { |
782 | 782 | phpCAS :: error('type mismatched for parameter $user (should be `string\')'); |
@@ -830,16 +830,16 @@ discard block |
||
830 | 830 | |
831 | 831 | phpCAS :: traceBegin(); |
832 | 832 | if (!is_object($PHPCAS_CLIENT)) { |
833 | - phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()'); |
|
833 | + phpCAS :: error('this method should only be called after '.__CLASS__.'::proxy()'); |
|
834 | 834 | } |
835 | 835 | if (!$PHPCAS_CLIENT->isProxy()) { |
836 | - phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()'); |
|
836 | + phpCAS :: error('this method should only be called after '.__CLASS__.'::proxy()'); |
|
837 | 837 | } |
838 | 838 | if (!$PHPCAS_AUTH_CHECK_CALL['done']) { |
839 | - phpCAS :: error('this method should only be called after the programmer is sure the user has been authenticated (by calling ' . __CLASS__ . '::checkAuthentication() or ' . __CLASS__ . '::forceAuthentication()'); |
|
839 | + phpCAS :: error('this method should only be called after the programmer is sure the user has been authenticated (by calling '.__CLASS__.'::checkAuthentication() or '.__CLASS__.'::forceAuthentication()'); |
|
840 | 840 | } |
841 | 841 | if (!$PHPCAS_AUTH_CHECK_CALL['result']) { |
842 | - phpCAS :: error('authentication was checked (by ' . $PHPCAS_AUTH_CHECK_CALL['method'] . '() at ' . $PHPCAS_AUTH_CHECK_CALL['file'] . ':' . $PHPCAS_AUTH_CHECK_CALL['line'] . ') but the method returned FALSE'); |
|
842 | + phpCAS :: error('authentication was checked (by '.$PHPCAS_AUTH_CHECK_CALL['method'].'() at '.$PHPCAS_AUTH_CHECK_CALL['file'].':'.$PHPCAS_AUTH_CHECK_CALL['line'].') but the method returned FALSE'); |
|
843 | 843 | } |
844 | 844 | if (gettype($url) != 'string') { |
845 | 845 | phpCAS :: error('type mismatched for parameter $url (should be `string\')'); |
@@ -873,16 +873,16 @@ discard block |
||
873 | 873 | |
874 | 874 | phpCAS :: traceBegin(); |
875 | 875 | if (!is_object($PHPCAS_CLIENT)) { |
876 | - phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()'); |
|
876 | + phpCAS :: error('this method should only be called after '.__CLASS__.'::proxy()'); |
|
877 | 877 | } |
878 | 878 | if (!$PHPCAS_CLIENT->isProxy()) { |
879 | - phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()'); |
|
879 | + phpCAS :: error('this method should only be called after '.__CLASS__.'::proxy()'); |
|
880 | 880 | } |
881 | 881 | if (!$PHPCAS_AUTH_CHECK_CALL['done']) { |
882 | - phpCAS :: error('this method should only be called after the programmer is sure the user has been authenticated (by calling ' . __CLASS__ . '::checkAuthentication() or ' . __CLASS__ . '::forceAuthentication()'); |
|
882 | + phpCAS :: error('this method should only be called after the programmer is sure the user has been authenticated (by calling '.__CLASS__.'::checkAuthentication() or '.__CLASS__.'::forceAuthentication()'); |
|
883 | 883 | } |
884 | 884 | if (!$PHPCAS_AUTH_CHECK_CALL['result']) { |
885 | - phpCAS :: error('authentication was checked (by ' . $PHPCAS_AUTH_CHECK_CALL['method'] . '() at ' . $PHPCAS_AUTH_CHECK_CALL['file'] . ':' . $PHPCAS_AUTH_CHECK_CALL['line'] . ') but the method returned FALSE'); |
|
885 | + phpCAS :: error('authentication was checked (by '.$PHPCAS_AUTH_CHECK_CALL['method'].'() at '.$PHPCAS_AUTH_CHECK_CALL['file'].':'.$PHPCAS_AUTH_CHECK_CALL['line'].') but the method returned FALSE'); |
|
886 | 886 | } |
887 | 887 | if (gettype($url) != 'string') { |
888 | 888 | phpCAS :: error('type mismatched for parameter $url (should be `string\')'); |
@@ -918,7 +918,7 @@ discard block |
||
918 | 918 | function setCacheTimesForAuthRecheck($n) { |
919 | 919 | global $PHPCAS_CLIENT; |
920 | 920 | if (!is_object($PHPCAS_CLIENT)) { |
921 | - phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()'); |
|
921 | + phpCAS :: error('this method should not be called before '.__CLASS__.'::client() or '.__CLASS__.'::proxy()'); |
|
922 | 922 | } |
923 | 923 | if (gettype($n) != 'integer') { |
924 | 924 | phpCAS :: error('type mismatched for parameter $header (should be `string\')'); |
@@ -935,18 +935,18 @@ discard block |
||
935 | 935 | |
936 | 936 | phpCAS :: traceBegin(); |
937 | 937 | if (!is_object($PHPCAS_CLIENT)) { |
938 | - phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()'); |
|
938 | + phpCAS :: error('this method should not be called before '.__CLASS__.'::client() or '.__CLASS__.'::proxy()'); |
|
939 | 939 | } |
940 | 940 | |
941 | 941 | $auth = $PHPCAS_CLIENT->checkAuthentication(); |
942 | 942 | |
943 | 943 | // store where the authentication has been checked and the result |
944 | 944 | $dbg = phpCAS :: backtrace(); |
945 | - $PHPCAS_AUTH_CHECK_CALL = array ( |
|
945 | + $PHPCAS_AUTH_CHECK_CALL = array( |
|
946 | 946 | 'done' => TRUE, |
947 | 947 | 'file' => $dbg[0]['file'], |
948 | 948 | 'line' => $dbg[0]['line'], |
949 | - 'method' => __CLASS__ . '::' . __FUNCTION__, |
|
949 | + 'method' => __CLASS__.'::'.__FUNCTION__, |
|
950 | 950 | 'result' => $auth |
951 | 951 | ); |
952 | 952 | phpCAS :: traceEnd($auth); |
@@ -963,18 +963,18 @@ discard block |
||
963 | 963 | |
964 | 964 | phpCAS :: traceBegin(); |
965 | 965 | if (!is_object($PHPCAS_CLIENT)) { |
966 | - phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()'); |
|
966 | + phpCAS :: error('this method should not be called before '.__CLASS__.'::client() or '.__CLASS__.'::proxy()'); |
|
967 | 967 | } |
968 | 968 | |
969 | 969 | $auth = $PHPCAS_CLIENT->forceAuthentication(); |
970 | 970 | |
971 | 971 | // store where the authentication has been checked and the result |
972 | 972 | $dbg = phpCAS :: backtrace(); |
973 | - $PHPCAS_AUTH_CHECK_CALL = array ( |
|
973 | + $PHPCAS_AUTH_CHECK_CALL = array( |
|
974 | 974 | 'done' => TRUE, |
975 | 975 | 'file' => $dbg[0]['file'], |
976 | 976 | 'line' => $dbg[0]['line'], |
977 | - 'method' => __CLASS__ . '::' . __FUNCTION__, |
|
977 | + 'method' => __CLASS__.'::'.__FUNCTION__, |
|
978 | 978 | 'result' => $auth |
979 | 979 | ); |
980 | 980 | |
@@ -982,7 +982,7 @@ discard block |
||
982 | 982 | phpCAS :: trace('user is not authenticated, redirecting to the CAS server'); |
983 | 983 | $PHPCAS_CLIENT->forceAuthentication(); |
984 | 984 | } else { |
985 | - phpCAS :: trace('no need to authenticate (user `' . phpCAS :: getUser() . '\' is already authenticated)'); |
|
985 | + phpCAS :: trace('no need to authenticate (user `'.phpCAS :: getUser().'\' is already authenticated)'); |
|
986 | 986 | } |
987 | 987 | |
988 | 988 | phpCAS :: traceEnd(); |
@@ -997,16 +997,16 @@ discard block |
||
997 | 997 | |
998 | 998 | phpCAS :: traceBegin(); |
999 | 999 | if (!is_object($PHPCAS_CLIENT)) { |
1000 | - phpCAS :: error('this method should not be called before' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()'); |
|
1000 | + phpCAS :: error('this method should not be called before'.__CLASS__.'::client() or '.__CLASS__.'::proxy()'); |
|
1001 | 1001 | } |
1002 | 1002 | |
1003 | 1003 | // store where the authentication has been checked and the result |
1004 | 1004 | $dbg = phpCAS :: backtrace(); |
1005 | - $PHPCAS_AUTH_CHECK_CALL = array ( |
|
1005 | + $PHPCAS_AUTH_CHECK_CALL = array( |
|
1006 | 1006 | 'done' => TRUE, |
1007 | 1007 | 'file' => $dbg[0]['file'], |
1008 | 1008 | 'line' => $dbg[0]['line'], |
1009 | - 'method' => __CLASS__ . '::' . __FUNCTION__, |
|
1009 | + 'method' => __CLASS__.'::'.__FUNCTION__, |
|
1010 | 1010 | 'result' => $auth |
1011 | 1011 | ); |
1012 | 1012 | |
@@ -1018,7 +1018,7 @@ discard block |
||
1018 | 1018 | * This method has been left from version 0.4.1 for compatibility reasons. |
1019 | 1019 | */ |
1020 | 1020 | function authenticate() { |
1021 | - phpCAS :: error('this method is deprecated. You should use ' . __CLASS__ . '::forceAuthentication() instead'); |
|
1021 | + phpCAS :: error('this method is deprecated. You should use '.__CLASS__.'::forceAuthentication() instead'); |
|
1022 | 1022 | } |
1023 | 1023 | |
1024 | 1024 | /** |
@@ -1032,7 +1032,7 @@ discard block |
||
1032 | 1032 | |
1033 | 1033 | phpCAS :: traceBegin(); |
1034 | 1034 | if (!is_object($PHPCAS_CLIENT)) { |
1035 | - phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()'); |
|
1035 | + phpCAS :: error('this method should not be called before '.__CLASS__.'::client() or '.__CLASS__.'::proxy()'); |
|
1036 | 1036 | } |
1037 | 1037 | |
1038 | 1038 | // call the isAuthenticated method of the global $PHPCAS_CLIENT object |
@@ -1040,11 +1040,11 @@ discard block |
||
1040 | 1040 | |
1041 | 1041 | // store where the authentication has been checked and the result |
1042 | 1042 | $dbg = phpCAS :: backtrace(); |
1043 | - $PHPCAS_AUTH_CHECK_CALL = array ( |
|
1043 | + $PHPCAS_AUTH_CHECK_CALL = array( |
|
1044 | 1044 | 'done' => TRUE, |
1045 | 1045 | 'file' => $dbg[0]['file'], |
1046 | 1046 | 'line' => $dbg[0]['line'], |
1047 | - 'method' => __CLASS__ . '::' . __FUNCTION__, |
|
1047 | + 'method' => __CLASS__.'::'.__FUNCTION__, |
|
1048 | 1048 | 'result' => $auth |
1049 | 1049 | ); |
1050 | 1050 | phpCAS :: traceEnd($auth); |
@@ -1060,7 +1060,7 @@ discard block |
||
1060 | 1060 | function isSessionAuthenticated() { |
1061 | 1061 | global $PHPCAS_CLIENT; |
1062 | 1062 | if (!is_object($PHPCAS_CLIENT)) { |
1063 | - phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()'); |
|
1063 | + phpCAS :: error('this method should not be called before '.__CLASS__.'::client() or '.__CLASS__.'::proxy()'); |
|
1064 | 1064 | } |
1065 | 1065 | return ($PHPCAS_CLIENT->isSessionAuthenticated()); |
1066 | 1066 | } |
@@ -1075,13 +1075,13 @@ discard block |
||
1075 | 1075 | function getUser() { |
1076 | 1076 | global $PHPCAS_CLIENT, $PHPCAS_AUTH_CHECK_CALL; |
1077 | 1077 | if (!is_object($PHPCAS_CLIENT)) { |
1078 | - phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()'); |
|
1078 | + phpCAS :: error('this method should not be called before '.__CLASS__.'::client() or '.__CLASS__.'::proxy()'); |
|
1079 | 1079 | } |
1080 | 1080 | if (!$PHPCAS_AUTH_CHECK_CALL['done']) { |
1081 | - phpCAS :: error('this method should only be called after ' . __CLASS__ . '::forceAuthentication() or ' . __CLASS__ . '::isAuthenticated()'); |
|
1081 | + phpCAS :: error('this method should only be called after '.__CLASS__.'::forceAuthentication() or '.__CLASS__.'::isAuthenticated()'); |
|
1082 | 1082 | } |
1083 | 1083 | if (!$PHPCAS_AUTH_CHECK_CALL['result']) { |
1084 | - phpCAS :: error('authentication was checked (by ' . $PHPCAS_AUTH_CHECK_CALL['method'] . '() at ' . $PHPCAS_AUTH_CHECK_CALL['file'] . ':' . $PHPCAS_AUTH_CHECK_CALL['line'] . ') but the method returned FALSE'); |
|
1084 | + phpCAS :: error('authentication was checked (by '.$PHPCAS_AUTH_CHECK_CALL['method'].'() at '.$PHPCAS_AUTH_CHECK_CALL['file'].':'.$PHPCAS_AUTH_CHECK_CALL['line'].') but the method returned FALSE'); |
|
1085 | 1085 | } |
1086 | 1086 | return $PHPCAS_CLIENT->getUser(); |
1087 | 1087 | } |
@@ -1096,13 +1096,13 @@ discard block |
||
1096 | 1096 | function getAttributes() { |
1097 | 1097 | global $PHPCAS_CLIENT, $PHPCAS_AUTH_CHECK_CALL; |
1098 | 1098 | if (!is_object($PHPCAS_CLIENT)) { |
1099 | - phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()'); |
|
1099 | + phpCAS :: error('this method should not be called before '.__CLASS__.'::client() or '.__CLASS__.'::proxy()'); |
|
1100 | 1100 | } |
1101 | 1101 | if (!$PHPCAS_AUTH_CHECK_CALL['done']) { |
1102 | - phpCAS :: error('this method should only be called after ' . __CLASS__ . '::forceAuthentication() or ' . __CLASS__ . '::isAuthenticated()'); |
|
1102 | + phpCAS :: error('this method should only be called after '.__CLASS__.'::forceAuthentication() or '.__CLASS__.'::isAuthenticated()'); |
|
1103 | 1103 | } |
1104 | 1104 | if (!$PHPCAS_AUTH_CHECK_CALL['result']) { |
1105 | - phpCAS :: error('authentication was checked (by ' . $PHPCAS_AUTH_CHECK_CALL['method'] . '() at ' . $PHPCAS_AUTH_CHECK_CALL['file'] . ':' . $PHPCAS_AUTH_CHECK_CALL['line'] . ') but the method returned FALSE'); |
|
1105 | + phpCAS :: error('authentication was checked (by '.$PHPCAS_AUTH_CHECK_CALL['method'].'() at '.$PHPCAS_AUTH_CHECK_CALL['file'].':'.$PHPCAS_AUTH_CHECK_CALL['line'].') but the method returned FALSE'); |
|
1106 | 1106 | } |
1107 | 1107 | return $PHPCAS_CLIENT->getAttributes(); |
1108 | 1108 | } |
@@ -1112,7 +1112,7 @@ discard block |
||
1112 | 1112 | function handleLogoutRequests($check_client = true, $allowed_clients = false) { |
1113 | 1113 | global $PHPCAS_CLIENT; |
1114 | 1114 | if (!is_object($PHPCAS_CLIENT)) { |
1115 | - phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()'); |
|
1115 | + phpCAS :: error('this method should not be called before '.__CLASS__.'::client() or '.__CLASS__.'::proxy()'); |
|
1116 | 1116 | } |
1117 | 1117 | return ($PHPCAS_CLIENT->handleLogoutRequests($check_client, $allowed_clients)); |
1118 | 1118 | } |
@@ -1126,7 +1126,7 @@ discard block |
||
1126 | 1126 | function getServerLoginURL() { |
1127 | 1127 | global $PHPCAS_CLIENT; |
1128 | 1128 | if (!is_object($PHPCAS_CLIENT)) { |
1129 | - phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()'); |
|
1129 | + phpCAS :: error('this method should not be called before '.__CLASS__.'::client() or '.__CLASS__.'::proxy()'); |
|
1130 | 1130 | } |
1131 | 1131 | return $PHPCAS_CLIENT->getServerLoginURL(); |
1132 | 1132 | } |
@@ -1141,7 +1141,7 @@ discard block |
||
1141 | 1141 | phpCAS :: traceBegin(); |
1142 | 1142 | if (!is_object($PHPCAS_CLIENT)) { |
1143 | 1143 | phpCAS :: error('this method should only be called after |
1144 | - ' . __CLASS__ . '::client()'); |
|
1144 | + ' . __CLASS__.'::client()'); |
|
1145 | 1145 | } |
1146 | 1146 | if (gettype($url) != 'string') { |
1147 | 1147 | phpCAS :: error('type mismatched for parameter $url (should be |
@@ -1162,7 +1162,7 @@ discard block |
||
1162 | 1162 | phpCAS :: traceBegin(); |
1163 | 1163 | if (!is_object($PHPCAS_CLIENT)) { |
1164 | 1164 | phpCAS :: error('this method should only be called after |
1165 | - ' . __CLASS__ . '::client()'); |
|
1165 | + ' . __CLASS__.'::client()'); |
|
1166 | 1166 | } |
1167 | 1167 | if (gettype($url) != 'string') { |
1168 | 1168 | phpCAS :: error('type mismatched for parameter $url (should be |
@@ -1183,7 +1183,7 @@ discard block |
||
1183 | 1183 | phpCAS :: traceBegin(); |
1184 | 1184 | if (!is_object($PHPCAS_CLIENT)) { |
1185 | 1185 | phpCAS :: error('this method should only be called after |
1186 | - ' . __CLASS__ . '::client()'); |
|
1186 | + ' . __CLASS__.'::client()'); |
|
1187 | 1187 | } |
1188 | 1188 | if (gettype($url) != 'string') { |
1189 | 1189 | phpCAS :: error('type mismatched for parameter $url (should be |
@@ -1203,7 +1203,7 @@ discard block |
||
1203 | 1203 | phpCAS :: traceBegin(); |
1204 | 1204 | if (!is_object($PHPCAS_CLIENT)) { |
1205 | 1205 | phpCAS :: error('this method should only be called after |
1206 | - ' . __CLASS__ . '::client()'); |
|
1206 | + ' . __CLASS__.'::client()'); |
|
1207 | 1207 | } |
1208 | 1208 | if (gettype($url) != 'string') { |
1209 | 1209 | phpCAS :: error('type mismatched for parameter $url (should be |
@@ -1222,7 +1222,7 @@ discard block |
||
1222 | 1222 | function getServerLogoutURL() { |
1223 | 1223 | global $PHPCAS_CLIENT; |
1224 | 1224 | if (!is_object($PHPCAS_CLIENT)) { |
1225 | - phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()'); |
|
1225 | + phpCAS :: error('this method should not be called before '.__CLASS__.'::client() or '.__CLASS__.'::proxy()'); |
|
1226 | 1226 | } |
1227 | 1227 | return $PHPCAS_CLIENT->getServerLogoutURL(); |
1228 | 1228 | } |
@@ -1237,7 +1237,7 @@ discard block |
||
1237 | 1237 | phpCAS :: traceBegin(); |
1238 | 1238 | if (!is_object($PHPCAS_CLIENT)) { |
1239 | 1239 | phpCAS :: error('this method should only be called after |
1240 | - ' . __CLASS__ . '::client()'); |
|
1240 | + ' . __CLASS__.'::client()'); |
|
1241 | 1241 | } |
1242 | 1242 | if (gettype($url) != 'string') { |
1243 | 1243 | phpCAS :: error('type mismatched for parameter $url (should be |
@@ -1256,9 +1256,9 @@ discard block |
||
1256 | 1256 | global $PHPCAS_CLIENT; |
1257 | 1257 | phpCAS :: traceBegin(); |
1258 | 1258 | if (!is_object($PHPCAS_CLIENT)) { |
1259 | - phpCAS :: error('this method should only be called after ' . __CLASS__ . '::client() or' . __CLASS__ . '::proxy()'); |
|
1259 | + phpCAS :: error('this method should only be called after '.__CLASS__.'::client() or'.__CLASS__.'::proxy()'); |
|
1260 | 1260 | } |
1261 | - $parsedParams = array (); |
|
1261 | + $parsedParams = array(); |
|
1262 | 1262 | if ($params != "") { |
1263 | 1263 | if (is_string($params)) { |
1264 | 1264 | phpCAS :: error('method `phpCAS::logout($url)\' is now deprecated, use `phpCAS::logoutWithUrl($url)\' instead'); |
@@ -1286,12 +1286,12 @@ discard block |
||
1286 | 1286 | global $PHPCAS_CLIENT; |
1287 | 1287 | phpCAS :: traceBegin(); |
1288 | 1288 | if (!is_object($PHPCAS_CLIENT)) { |
1289 | - phpCAS :: error('this method should only be called after ' . __CLASS__ . '::client() or' . __CLASS__ . '::proxy()'); |
|
1289 | + phpCAS :: error('this method should only be called after '.__CLASS__.'::client() or'.__CLASS__.'::proxy()'); |
|
1290 | 1290 | } |
1291 | 1291 | if (!is_string($service)) { |
1292 | 1292 | phpCAS :: error('type mismatched for parameter $service (should be `string\')'); |
1293 | 1293 | } |
1294 | - $PHPCAS_CLIENT->logout(array ( |
|
1294 | + $PHPCAS_CLIENT->logout(array( |
|
1295 | 1295 | "service" => $service |
1296 | 1296 | )); |
1297 | 1297 | // never reached |
@@ -1306,12 +1306,12 @@ discard block |
||
1306 | 1306 | global $PHPCAS_CLIENT; |
1307 | 1307 | phpCAS :: traceBegin(); |
1308 | 1308 | if (!is_object($PHPCAS_CLIENT)) { |
1309 | - phpCAS :: error('this method should only be called after ' . __CLASS__ . '::client() or' . __CLASS__ . '::proxy()'); |
|
1309 | + phpCAS :: error('this method should only be called after '.__CLASS__.'::client() or'.__CLASS__.'::proxy()'); |
|
1310 | 1310 | } |
1311 | 1311 | if (!is_string($url)) { |
1312 | 1312 | phpCAS :: error('type mismatched for parameter $url (should be `string\')'); |
1313 | 1313 | } |
1314 | - $PHPCAS_CLIENT->logout(array ( |
|
1314 | + $PHPCAS_CLIENT->logout(array( |
|
1315 | 1315 | "url" => $url |
1316 | 1316 | )); |
1317 | 1317 | // never reached |
@@ -1327,7 +1327,7 @@ discard block |
||
1327 | 1327 | global $PHPCAS_CLIENT; |
1328 | 1328 | phpCAS :: traceBegin(); |
1329 | 1329 | if (!is_object($PHPCAS_CLIENT)) { |
1330 | - phpCAS :: error('this method should only be called after ' . __CLASS__ . '::client() or' . __CLASS__ . '::proxy()'); |
|
1330 | + phpCAS :: error('this method should only be called after '.__CLASS__.'::client() or'.__CLASS__.'::proxy()'); |
|
1331 | 1331 | } |
1332 | 1332 | if (!is_string($service)) { |
1333 | 1333 | phpCAS :: error('type mismatched for parameter $service (should be `string\')'); |
@@ -1335,7 +1335,7 @@ discard block |
||
1335 | 1335 | if (!is_string($url)) { |
1336 | 1336 | phpCAS :: error('type mismatched for parameter $url (should be `string\')'); |
1337 | 1337 | } |
1338 | - $PHPCAS_CLIENT->logout(array ( |
|
1338 | + $PHPCAS_CLIENT->logout(array( |
|
1339 | 1339 | "service" => $service, |
1340 | 1340 | "url" => $url |
1341 | 1341 | )); |
@@ -1353,10 +1353,10 @@ discard block |
||
1353 | 1353 | global $PHPCAS_CLIENT; |
1354 | 1354 | phpCAS :: traceBegin(); |
1355 | 1355 | if (!is_object($PHPCAS_CLIENT)) { |
1356 | - phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()'); |
|
1356 | + phpCAS :: error('this method should only be called after '.__CLASS__.'::proxy()'); |
|
1357 | 1357 | } |
1358 | 1358 | if (!$PHPCAS_CLIENT->isProxy()) { |
1359 | - phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()'); |
|
1359 | + phpCAS :: error('this method should only be called after '.__CLASS__.'::proxy()'); |
|
1360 | 1360 | } |
1361 | 1361 | if (gettype($url) != 'string') { |
1362 | 1362 | phpCAS :: error('type mismatched for parameter $url (should be `string\')'); |
@@ -1375,7 +1375,7 @@ discard block |
||
1375 | 1375 | global $PHPCAS_CLIENT; |
1376 | 1376 | phpCAS :: traceBegin(); |
1377 | 1377 | if (!is_object($PHPCAS_CLIENT)) { |
1378 | - phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()'); |
|
1378 | + phpCAS :: error('this method should only be called after '.__CLASS__.'::proxy()'); |
|
1379 | 1379 | } |
1380 | 1380 | if (gettype($url) != 'string') { |
1381 | 1381 | phpCAS :: error('type mismatched for parameter $url (should be `string\')'); |
@@ -1390,7 +1390,7 @@ discard block |
||
1390 | 1390 | function getServiceURL() { |
1391 | 1391 | global $PHPCAS_CLIENT; |
1392 | 1392 | if (!is_object($PHPCAS_CLIENT)) { |
1393 | - phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()'); |
|
1393 | + phpCAS :: error('this method should only be called after '.__CLASS__.'::proxy()'); |
|
1394 | 1394 | } |
1395 | 1395 | return ($PHPCAS_CLIENT->getURL()); |
1396 | 1396 | } |
@@ -1401,7 +1401,7 @@ discard block |
||
1401 | 1401 | function retrievePT($target_service, & $err_code, & $err_msg) { |
1402 | 1402 | global $PHPCAS_CLIENT; |
1403 | 1403 | if (!is_object($PHPCAS_CLIENT)) { |
1404 | - phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()'); |
|
1404 | + phpCAS :: error('this method should only be called after '.__CLASS__.'::proxy()'); |
|
1405 | 1405 | } |
1406 | 1406 | if (gettype($target_service) != 'string') { |
1407 | 1407 | phpCAS :: error('type mismatched for parameter $target_service(should be `string\')'); |
@@ -1418,7 +1418,7 @@ discard block |
||
1418 | 1418 | global $PHPCAS_CLIENT; |
1419 | 1419 | phpCAS :: traceBegin(); |
1420 | 1420 | if (!is_object($PHPCAS_CLIENT)) { |
1421 | - phpCAS :: error('this method should only be called after ' . __CLASS__ . '::client() or' . __CLASS__ . '::proxy()'); |
|
1421 | + phpCAS :: error('this method should only be called after '.__CLASS__.'::client() or'.__CLASS__.'::proxy()'); |
|
1422 | 1422 | } |
1423 | 1423 | if (gettype($cert) != 'string') { |
1424 | 1424 | phpCAS :: error('type mismatched for parameter $cert (should be `string\')'); |
@@ -1436,7 +1436,7 @@ discard block |
||
1436 | 1436 | global $PHPCAS_CLIENT; |
1437 | 1437 | phpCAS :: traceBegin(); |
1438 | 1438 | if (!is_object($PHPCAS_CLIENT)) { |
1439 | - phpCAS :: error('this method should only be called after ' . __CLASS__ . '::client() or' . __CLASS__ . '::proxy()'); |
|
1439 | + phpCAS :: error('this method should only be called after '.__CLASS__.'::client() or'.__CLASS__.'::proxy()'); |
|
1440 | 1440 | } |
1441 | 1441 | if (gettype($cert) != 'string') { |
1442 | 1442 | phpCAS :: error('type mismatched for parameter $cert (should be `string\')'); |
@@ -1452,7 +1452,7 @@ discard block |
||
1452 | 1452 | global $PHPCAS_CLIENT; |
1453 | 1453 | phpCAS :: traceBegin(); |
1454 | 1454 | if (!is_object($PHPCAS_CLIENT)) { |
1455 | - phpCAS :: error('this method should only be called after ' . __CLASS__ . '::client() or' . __CLASS__ . '::proxy()'); |
|
1455 | + phpCAS :: error('this method should only be called after '.__CLASS__.'::client() or'.__CLASS__.'::proxy()'); |
|
1456 | 1456 | } |
1457 | 1457 | $PHPCAS_CLIENT->setNoCasServerValidation(); |
1458 | 1458 | phpCAS :: traceEnd(); |
@@ -1470,7 +1470,7 @@ discard block |
||
1470 | 1470 | global $PHPCAS_CLIENT; |
1471 | 1471 | phpCAS :: traceBegin(); |
1472 | 1472 | if (!is_object($PHPCAS_CLIENT)) { |
1473 | - phpCAS :: error('this method should only be called after ' . __CLASS__ . '::client() or' . __CLASS__ . '::proxy()'); |
|
1473 | + phpCAS :: error('this method should only be called after '.__CLASS__.'::client() or'.__CLASS__.'::proxy()'); |
|
1474 | 1474 | } |
1475 | 1475 | $PHPCAS_CLIENT->setExtraCurlOption($key, $value); |
1476 | 1476 | phpCAS :: traceEnd(); |