From 93550fd703b5968c348f2269a620ec0ed522240c Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Tue, 22 Jun 2021 14:30:54 +0200 Subject: [PATCH] Remove unused code, replace api_display_tool_title With Display::page_subheader2 --- .../admin/access_url_add_courses_to_url.php | 2 +- .../admin/access_url_add_usergroup_to_url.php | 2 +- .../admin/access_url_add_users_to_url.php | 2 +- ...access_url_edit_course_category_to_url.php | 2 +- .../admin/access_url_edit_courses_to_url.php | 2 +- .../access_url_edit_usergroup_to_url.php | 2 +- .../admin/access_url_edit_users_to_url.php | 2 +- public/main/admin/configure_inscription.php | 2 +- public/main/admin/course_list.php | 2 +- public/main/admin/ldap_users_list.php | 2 +- public/main/admin/ldap_users_synchro.php | 2 +- public/main/admin/user_list.php | 2 +- public/main/admin/user_list_consent.php | 2 +- public/main/extra/myStudents.php | 2 +- public/main/extra/my_progress_ind.php | 50 +-- public/main/forum/forumqualify.php | 2 +- .../main/gradebook/gradebook_showlog_link.php | 2 +- public/main/inc/ajax/social.ajax.php | 6 +- public/main/inc/lib/api.lib.php | 358 +----------------- .../main/inc/lib/internationalization.lib.php | 30 -- public/main/mySpace/admin.php | 2 +- public/main/mySpace/coaches.php | 2 +- public/main/session/session_course_edit.php | 2 +- public/main/survey/surveyUtil.class.php | 1 - public/plugin/before_login/plugin.php | 2 +- 25 files changed, 60 insertions(+), 425 deletions(-) diff --git a/public/main/admin/access_url_add_courses_to_url.php b/public/main/admin/access_url_add_courses_to_url.php index 21d6dd871e..02a14184d4 100644 --- a/public/main/admin/access_url_add_courses_to_url.php +++ b/public/main/admin/access_url_add_courses_to_url.php @@ -42,7 +42,7 @@ echo Display::toolbarAction( ] ); -api_display_tool_title($tool_name); +Display::page_subheader2($tool_name); if (isset($_POST['form_sent']) && $_POST['form_sent']) { $form_sent = $_POST['form_sent']; diff --git a/public/main/admin/access_url_add_usergroup_to_url.php b/public/main/admin/access_url_add_usergroup_to_url.php index 2daa13b2cd..debeab67b6 100644 --- a/public/main/admin/access_url_add_usergroup_to_url.php +++ b/public/main/admin/access_url_add_usergroup_to_url.php @@ -39,7 +39,7 @@ echo Display::toolbarAction( ] ); -api_display_tool_title($tool_name); +Display::page_subheader2($tool_name); if (isset($_POST['form_sent']) && $_POST['form_sent']) { $form_sent = $_POST['form_sent']; diff --git a/public/main/admin/access_url_add_users_to_url.php b/public/main/admin/access_url_add_users_to_url.php index cd8dd6b0ba..eed560ff7b 100644 --- a/public/main/admin/access_url_add_users_to_url.php +++ b/public/main/admin/access_url_add_users_to_url.php @@ -40,7 +40,7 @@ echo Display::toolbarAction( ] ); -api_display_tool_title($tool_name); +Display::page_subheader2($tool_name); if ($_POST['form_sent']) { $form_sent = $_POST['form_sent']; diff --git a/public/main/admin/access_url_edit_course_category_to_url.php b/public/main/admin/access_url_edit_course_category_to_url.php index ec2aaa2f3a..cd24af78bc 100644 --- a/public/main/admin/access_url_edit_course_category_to_url.php +++ b/public/main/admin/access_url_edit_course_category_to_url.php @@ -96,7 +96,7 @@ if (isset($_POST['form_sent']) && $_POST['form_sent']) { } Display::display_header($tool_name); -api_display_tool_title($tool_name); +Display::page_subheader2($tool_name); $noUserGroupList = $userGroupList = []; $ajax_search = 'unique' == $add_type ? true : false; diff --git a/public/main/admin/access_url_edit_courses_to_url.php b/public/main/admin/access_url_edit_courses_to_url.php index d5c7950c0f..f6f4b8631d 100644 --- a/public/main/admin/access_url_edit_courses_to_url.php +++ b/public/main/admin/access_url_edit_courses_to_url.php @@ -102,7 +102,7 @@ echo Display::toolbarAction( ] ); -api_display_tool_title($tool_name); +Display::page_subheader2($tool_name); $no_course_list = $course_list = []; $ajax_search = 'unique' == $add_type ? true : false; diff --git a/public/main/admin/access_url_edit_usergroup_to_url.php b/public/main/admin/access_url_edit_usergroup_to_url.php index 9f790f23c2..6c5fbb6420 100644 --- a/public/main/admin/access_url_edit_usergroup_to_url.php +++ b/public/main/admin/access_url_edit_usergroup_to_url.php @@ -103,7 +103,7 @@ echo Display::toolbarAction( ] ); -api_display_tool_title($tool_name); +Display::page_subheader2($tool_name); $noUserGroupList = $userGroupList = []; $ajax_search = 'unique' === $add_type ? true : false; diff --git a/public/main/admin/access_url_edit_users_to_url.php b/public/main/admin/access_url_edit_users_to_url.php index c63b75d301..ba01184961 100644 --- a/public/main/admin/access_url_edit_users_to_url.php +++ b/public/main/admin/access_url_edit_users_to_url.php @@ -141,7 +141,7 @@ echo Display::toolbarAction( ] ); -api_display_tool_title($tool_name); +Display::page_subheader2($tool_name); $nosessionUsersList = $sessionUsersList = []; $ajax_search = 'unique' === $add_type ? true : false; diff --git a/public/main/admin/configure_inscription.php b/public/main/admin/configure_inscription.php index 94e805d665..87212fb2d3 100644 --- a/public/main/admin/configure_inscription.php +++ b/public/main/admin/configure_inscription.php @@ -337,7 +337,7 @@ $content = Display::page_header($tool_name); // api_not_allowed(); //} -//api_display_tool_title($tool_name); +//Display::page_subheader2($tool_name); if ('approval' == api_get_setting('allow_registration')) { $content .= Display::return_message(get_lang('Your account has to be approved'), 'normal'); } diff --git a/public/main/admin/course_list.php b/public/main/admin/course_list.php index 971259d008..b2a28962a2 100644 --- a/public/main/admin/course_list.php +++ b/public/main/admin/course_list.php @@ -139,7 +139,7 @@ function get_course_data($from, $number_of_items, $column, $direction, $dataFunc $res = Database::query($sql); $courses = []; - $languages = api_get_languages_to_array(); + $languages = api_get_languages(); $path = api_get_path(WEB_CODE_PATH); diff --git a/public/main/admin/ldap_users_list.php b/public/main/admin/ldap_users_list.php index c6123e5c87..fd41b2a3ff 100644 --- a/public/main/admin/ldap_users_list.php +++ b/public/main/admin/ldap_users_list.php @@ -28,7 +28,7 @@ if (($_GET['action']=="add_user") && ($_GET['id_session'] == strval(intval($_GET $interbreadcrumb[] = ["url" => 'index.php', "name" => get_lang('Administration')]; $tool_name = get_lang('Search for LDAP users'); //Display::display_header($tool_name); //cannot display now as we need to redirect -//api_display_tool_title($tool_name); +//Display::page_subheader2($tool_name); if (isset($_GET['action'])) { $check = Security::check_token('get'); diff --git a/public/main/admin/ldap_users_synchro.php b/public/main/admin/ldap_users_synchro.php index 0831d3a461..8abe99f465 100644 --- a/public/main/admin/ldap_users_synchro.php +++ b/public/main/admin/ldap_users_synchro.php @@ -44,7 +44,7 @@ $action = $_REQUEST['action']; $tool_name = get_lang('Synchro LDAP : Import Etudiants/Etapes dans session'); Display::display_header($tool_name); -//api_display_tool_title($tool_name); +//Display::page_subheader2($tool_name); ?>
diff --git a/public/main/admin/user_list.php b/public/main/admin/user_list.php index 79184fd12b..2af8b0a9f6 100644 --- a/public/main/admin/user_list.php +++ b/public/main/admin/user_list.php @@ -495,7 +495,7 @@ function get_user_data($from, $number_of_items, $column, $direction) if (1 == $user[7] && !empty($user['exp'])) { // check expiration date - $expiration_time = convert_sql_date($user['exp']); + $expiration_time = api_strtotime($user['exp']); // if expiration date is passed, store a special value for active field if ($expiration_time < $t) { $user[7] = '-1'; diff --git a/public/main/admin/user_list_consent.php b/public/main/admin/user_list_consent.php index 2b6c8f354d..56af639aba 100644 --- a/public/main/admin/user_list_consent.php +++ b/public/main/admin/user_list_consent.php @@ -227,7 +227,7 @@ function get_user_data($from, $number_of_items, $column, $direction) if (1 == $user[7] && !empty($user[10])) { // check expiration date - $expiration_time = convert_sql_date($user[10]); + $expiration_time = api_strtotime($user[10]); // if expiration date is passed, store a special value for active field if ($expiration_time < $t) { $user[7] = '-1'; diff --git a/public/main/extra/myStudents.php b/public/main/extra/myStudents.php index 22c7ccde8a..657bc463bd 100644 --- a/public/main/extra/myStudents.php +++ b/public/main/extra/myStudents.php @@ -1485,7 +1485,7 @@ while ($a_courses = Database::fetch_array($result2)) { } } -api_display_tool_title($nameTools); +Display::page_subheader2($nameTools); $tbl_personal_agenda = Database:: get_main_table(TABLE_PERSONAL_AGENDA); $now = date('Y-m-d'); //on compte le nombre de m% dans l'agenda pour chaque module diff --git a/public/main/extra/my_progress_ind.php b/public/main/extra/my_progress_ind.php index 568ab8c53c..c9c5c320ce 100644 --- a/public/main/extra/my_progress_ind.php +++ b/public/main/extra/my_progress_ind.php @@ -20,9 +20,9 @@ $tbl_stats_access = Database:: get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS); Display::display_header($nameTools); $result = Database::query( - "SELECT DISTINCT session.id as id, name, access_start_date date_start, access_end_date date_end - FROM session_rel_course_rel_user,session - WHERE session_id=session.id AND user_id=".$_user['user_id']." + "SELECT DISTINCT session.id as id, name, access_start_date date_start, access_end_date date_end + FROM session_rel_course_rel_user,session + WHERE session_id=session.id AND user_id=".$_user['user_id']." ORDER BY date_start, date_end, name"); $Sessions = Database::store_result($result); @@ -96,10 +96,10 @@ while ($a_courses = Database::fetch_array($result2)) { $lp_item_id = $resulta['id']; $Req3 = " SELECT Max(id) FROM c_lp_item_view - WHERE - lp_item_id = '$lp_item_id' AND - lp_view_id = '$lp_id_view' AND - c_id = '$c_id_view' AND + WHERE + lp_item_id = '$lp_item_id' AND + lp_view_id = '$lp_id_view' AND + c_id = '$c_id_view' AND status = 'completed' "; $res3 = Database::query($Req3); @@ -107,9 +107,9 @@ while ($a_courses = Database::fetch_array($result2)) { $max = $resul['0']; $Req4 = "SELECT COUNT( id ) FROM c_lp_item_view - WHERE - id = '$max' AND - c_id = '$c_id_view' + WHERE + id = '$max' AND + c_id = '$c_id_view' "; $res4 = Database::query($Req4); while ($resultat = Database::fetch_array($res4)) { @@ -123,7 +123,7 @@ while ($a_courses = Database::fetch_array($result2)) { } } -api_display_tool_title($nameTools); +Display::page_subheader2($nameTools); $now = date('Y-m-d'); $tbl_personal_agenda = Database:: get_main_table(TABLE_PERSONAL_AGENDA); @@ -133,7 +133,7 @@ $sqljtot = "SELECT COUNT( * ) AS TOT FROM $tbl_personal_agenda WHERE user = '".$_user['user_id']."' And title like 'm%' - + "; $resultjt = Database::query($sqljtot); $jour_realise = 0; @@ -150,8 +150,8 @@ while ('' == $jour_agenda) { $tour++; $date = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - $tour, date("Y"))); $sql4 = "SELECT title FROM $tbl_personal_agenda - WHERE user = '".$_user['user_id']."' AND - text='Pour le calendrier, ne pas effacer' AND + WHERE user = '".$_user['user_id']."' AND + text='Pour le calendrier, ne pas effacer' AND date like '".$date." %:%' "; $result4 = Database::query($sql4); $res4 = Database::fetch_array($result4); @@ -272,7 +272,7 @@ $diff = abs($diff); echo " ".$a_inter['level']." - $inter_date + $inter_date $inter_coment"; $exe_id = $a_inter['exe_id']; } @@ -289,7 +289,7 @@ $diff = abs($diff); $user_info = api_get_user_info(); $user_id = api_get_user_id(); //On cherche le calendrier pour ce user et le c_id de ce calendrier -$sql = "SELECT * +$sql = "SELECT * FROM user WHERE user_id = '$user_id' "; @@ -306,7 +306,7 @@ echo ' '.get_lang('Time').' '.get_lang('FirstConnexion').' '.get_lang('Progress').' - '.get_lang('fin_mod_prevue').' + '.get_lang('fin_mod_prevue').' '; //on recherche les cours où sont inscrit les user $user_c_id = $_user['user_id']; @@ -332,11 +332,11 @@ while ($a_courses = Database::fetch_array($result2)) { $time_spent_on_course = api_time_to_hms(Tracking:: get_time_spent_on_the_course($user_id, $c_id, $session_id)); // firts connection date $sql2 = "SELECT STR_TO_DATE(access_date,'%Y-%m-%d') - FROM $tbl_stats_access - WHERE - access_user_id = '$user_id' AND + FROM $tbl_stats_access + WHERE + access_user_id = '$user_id' AND c_id = '$c_id' - ORDER BY access_id ASC + ORDER BY access_id ASC LIMIT 0,1"; //Francois Belisle Kezber @@ -375,12 +375,12 @@ while ($a_courses = Database::fetch_array($result2)) { $nombre_jours_module = (int) $nombre_jours_module; //on trouve la date de fin de chaque module AND date = date_format('$first_connection_date_to_module','%Y-%m-%d') $sql = "SELECT * FROM c_cal_dates - WHERE - horaire_name = '$nom_hor' AND - c_id = '$c_id_horaire' AND + WHERE + horaire_name = '$nom_hor' AND + c_id = '$c_id_horaire' AND STR_TO_DATE(date,'%Y-%m-%d') >= STR_TO_DATE('$first_connection_date_to_module','%Y-%m-%d') ORDER BY STR_TO_DATE(date, '%Y-%m-%d') asc - LIMIT $nombre_jours_module, 18446744073709551615 + LIMIT $nombre_jours_module, 18446744073709551615 "; $res = Database::query($sql); //Database::data_seek($res,$nombre_jours_module); diff --git a/public/main/forum/forumqualify.php b/public/main/forum/forumqualify.php index 09d4ab4d47..5f6b5d6c0f 100644 --- a/public/main/forum/forumqualify.php +++ b/public/main/forum/forumqualify.php @@ -190,7 +190,7 @@ if ('learnpath' === $origin) { // the last element of the breadcrumb navigation is already set in interbreadcrumb, so give empty string Display::display_header(''); - api_display_tool_title($nameTools); + Display::page_subheader2($nameTools); } else { $interbreadcrumb[] = [ 'url' => 'index.php?'.api_get_cidreq().'&search='.$search, diff --git a/public/main/gradebook/gradebook_showlog_link.php b/public/main/gradebook/gradebook_showlog_link.php index d44836eff0..9bd7ceb038 100644 --- a/public/main/gradebook/gradebook_showlog_link.php +++ b/public/main/gradebook/gradebook_showlog_link.php @@ -23,7 +23,7 @@ $interbreadcrumb[] = [ ]; $this_section = SECTION_COURSES; Display::display_header(''); -echo Display::toolbarAction('toolbar', [api_display_tool_title(get_lang('Assessment history'))]); +Display::page_subheader2(get_lang('Assessment history')); $t_user = Database::get_main_table(TABLE_MAIN_USER); $t_link_log = Database::get_main_table(TABLE_MAIN_GRADEBOOK_LINKEVAL_LOG); diff --git a/public/main/inc/ajax/social.ajax.php b/public/main/inc/ajax/social.ajax.php index 4ba74e44b1..a7f3b2968f 100644 --- a/public/main/inc/ajax/social.ajax.php +++ b/public/main/inc/ajax/social.ajax.php @@ -159,7 +159,7 @@ switch ($action) { $result = Blog::getBlogPostFromUser($courseId, $user_id, $courseCode); if (!empty($result)) { - api_display_tool_title(api_xml_http_response_encode(get_lang('Blog'))); + Display::page_subheader2(api_xml_http_response_encode(get_lang('Blog'))); echo '
'; echo api_xml_http_response_encode($result); echo '
'; @@ -171,7 +171,7 @@ switch ($action) { $result = Blog::getBlogCommentsFromUser($courseId, $user_id, $course_code); if (!empty($result)) { echo '
'; - api_display_tool_title(api_xml_http_response_encode(get_lang('Blog comments'))); + Display::page_subheader2(api_xml_http_response_encode(get_lang('Blog comments'))); echo api_xml_http_response_encode($result); echo '
'; echo '
'; @@ -182,7 +182,7 @@ switch ($action) { } } else { echo '

'; - api_display_tool_title(api_xml_http_response_encode(get_lang('Details'))); + Display::page_subheader2(api_xml_http_response_encode(get_lang('Details'))); echo '
'; echo api_xml_http_response_encode(get_lang('User not registered in course')); echo '

'; diff --git a/public/main/inc/lib/api.lib.php b/public/main/inc/lib/api.lib.php index 8e0a75440c..f77fb46af8 100644 --- a/public/main/inc/lib/api.lib.php +++ b/public/main/inc/lib/api.lib.php @@ -175,9 +175,6 @@ define('PLATFORM_AUTH_SOURCE', 'platform'); define('CAS_AUTH_SOURCE', 'cas'); define('LDAP_AUTH_SOURCE', 'extldap'); -// CONSTANT defining the default HotPotatoes files directory -define('DIR_HOTPOTATOES', '/HotPotatoes_files'); - // event logs types define('LOG_COURSE_DELETE', 'course_deleted'); define('LOG_COURSE_CREATE', 'course_created'); @@ -304,10 +301,6 @@ define('USERNAME_PURIFIER_SHALLOW', '/\s/'); // true whether the server runs on Windows OS, false otherwise. define('IS_WINDOWS_OS', api_is_windows_os()); -// iconv extension, for PHP5 on Windows it is installed by default. -define('ICONV_INSTALLED', function_exists('iconv')); -define('MBSTRING_INSTALLED', function_exists('mb_strlen')); // mbstring extension. - // Patterns for processing paths. Examples. define('REPEATED_SLASHES_PURIFIER', '/\/{2,}/'); // $path = preg_replace(REPEATED_SLASHES_PURIFIER, '/', $path); define('VALID_WEB_PATH', '/https?:\/\/[^\/]*(\/.*)?/i'); // $is_valid_path = preg_match(VALID_WEB_PATH, $path); @@ -323,8 +316,6 @@ define('REL_HOME_PATH', 'REL_HOME_PATH'); define('WEB_PATH', 'WEB_PATH'); define('SYS_PATH', 'SYS_PATH'); define('SYMFONY_SYS_PATH', 'SYMFONY_SYS_PATH'); -//define('SYS_UPLOAD_PATH', 'SYS_UPLOAD_PATH'); -//define('WEB_UPLOAD_PATH', 'WEB_UPLOAD_PATH'); define('REL_PATH', 'REL_PATH'); define('WEB_COURSE_PATH', 'WEB_COURSE_PATH'); @@ -358,7 +349,7 @@ define('SESSION_RELATION_TYPE_COURSE_MANAGER', 1); define('COURSE_RELATION_TYPE_RRHH', 1); define('SESSION_RELATION_TYPE_RRHH', 1); -//User image sizes +// User image sizes define('USER_IMAGE_SIZE_ORIGINAL', 1); define('USER_IMAGE_SIZE_BIG', 2); define('USER_IMAGE_SIZE_MEDIUM', 3); @@ -434,11 +425,6 @@ define('HOOK_EVENT_TYPE_PRE', 0); define('HOOK_EVENT_TYPE_POST', 1); define('HOOK_EVENT_TYPE_ALL', 10); -define('CAREER_STATUS_ACTIVE', 1); -define('CAREER_STATUS_INACTIVE', 0); - -define('PROMOTION_STATUS_ACTIVE', 1); -define('PROMOTION_STATUS_INACTIVE', 0); // Group permissions define('GROUP_PERMISSION_OPEN', '1'); define('GROUP_PERMISSION_CLOSED', '2'); @@ -627,9 +613,6 @@ define('EVENT_EMAIL_TEMPLATE_INACTIVE', 0); define('SHORTCUTS_HORIZONTAL', 0); define('SHORTCUTS_VERTICAL', 1); -// Image class -define('IMAGE_PROCESSOR', 'gd'); // 'imagick' or 'gd' strings - // Course copy define('FILE_SKIP', 1); define('FILE_RENAME', 2); @@ -683,11 +666,6 @@ if (!defined('CHAMILO_LOAD_WYSIWYG')) { define('CHAMILO_LOAD_WYSIWYG', true); } -/* Constants for course home */ -define('TOOL_PUBLIC', 'Public'); -define('TOOL_PUBLIC_BUT_HIDDEN', 'PublicButHide'); -define('TOOL_COURSE_ADMIN', 'courseAdmin'); -define('TOOL_PLATFORM_ADMIN', 'platformAdmin'); define('TOOL_AUTHORING', 'toolauthoring'); define('TOOL_INTERACTION', 'toolinteraction'); define('TOOL_COURSE_PLUGIN', 'toolcourseplugin'); //all plugins that can be enabled in courses @@ -754,42 +732,7 @@ function api_get_path($path = '', $configuration = []) } $root_sys = Container::getProjectDir(); - $root_web = ''; - // If no $root_web has been set so far *and* no custom config has been passed to the function - // then re-use the previously-calculated (run-specific) $root_web and skip this complex calculation - /* - if (empty($root_web) || $emptyConfigurationParam === false || empty($configuration)) { - // Resolve master hostname. - if (!empty($configuration) && array_key_exists('root_web', $configuration)) { - $root_web = $configuration['root_web']; - } else { - $root_web = ''; - // Try guess it from server. - if (defined('SYSTEM_INSTALLATION') && SYSTEM_INSTALLATION) { - if (($pos = strpos(($requested_page_rel = api_get_self()), 'main/install')) !== false) { - $root_rel = substr($requested_page_rel, 0, $pos); - // See http://www.mediawiki.org/wiki/Manual:$wgServer - $server_protocol = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https' : 'http'; - $server_name = - isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] - : (isset($_SERVER['HOSTNAME']) ? $_SERVER['HOSTNAME'] - : (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] - : (isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] - : 'localhost'))); - if (isset($_SERVER['SERVER_PORT']) && !strpos($server_name, ':') - && (($server_protocol == 'http' - && $_SERVER['SERVER_PORT'] != 80) || ($server_protocol == 'https' && $_SERVER['SERVER_PORT'] != 443)) - ) { - $server_name .= ":".$_SERVER['SERVER_PORT']; - } - $root_web = $server_protocol.'://'.$server_name.$root_rel; - $root_sys = str_replace('\\', '/', realpath(__DIR__.'/../../../')).'/'; - } - // Here we give up, so we don't touch anything. - } - } - }*/ if (isset(Container::$container)) { $root_web = Container::$container->get('router')->generate( 'index', @@ -828,7 +771,6 @@ function api_get_path($path = '', $configuration = []) SYS_CSS_PATH => $root_sys.'public/build/css/', SYS_PLUGIN_PATH => $root_sys.'public/plugin/', SYS_ARCHIVE_PATH => $root_sys.'var/cache/', - // SYS_UPLOAD_PATH => 'var/upload/', SYS_TEST_PATH => $root_sys.'tests/', SYS_TEMPLATE_PATH => $root_sys.'public/main/template/', SYS_PUBLIC_PATH => $root_sys.'public/', @@ -843,18 +785,11 @@ function api_get_path($path = '', $configuration = []) WEB_LIBRARY_PATH => $root_web.'main/inc/lib/', WEB_LIBRARY_JS_PATH => $root_web.'main/inc/lib/javascript/', WEB_PLUGIN_PATH => $root_web.'plugin/', - // WEB_ARCHIVE_PATH => 'var/cache/', - //WEB_UPLOAD_PATH => 'var/upload/', WEB_PUBLIC_PATH => $root_web, ]; $root_rel = ''; - // Dealing with trailing slashes. - $rootWebWithSlash = api_add_trailing_slash($root_web); - $root_sys = api_add_trailing_slash($root_sys); - $root_rel = api_add_trailing_slash($root_rel); - global $virtualChamilo; if (!empty($virtualChamilo)) { $paths[SYS_ARCHIVE_PATH] = api_add_trailing_slash($virtualChamilo[SYS_ARCHIVE_PATH]); @@ -1245,16 +1180,6 @@ function api_block_anonymous_users($printHeaders = true) api_block_inactive_user(); return true; - - /*$user = api_get_user_info(); - if (!(isset($user['user_id']) && $user['user_id']) || api_is_anonymous($user['user_id'], true)) { - api_not_allowed($printHeaders); - - return false; - } - api_block_inactive_user(); - - return true;*/ } /** @@ -1351,46 +1276,6 @@ function api_get_user_id() return 0; } -/** - * Gets the list of courses a specific user is subscribed to. - * - * @param int User ID - * @param bool $fetch_session Whether to get session courses or not - NOT YET IMPLEMENTED - * - * @return array Array of courses in the form [0]=>('code'=>xxx,'db'=>xxx,'dir'=>xxx,'status'=>d) - * - * @deprecated use CourseManager::get_courses_list_by_user_id() - */ -function api_get_user_courses($userId, $fetch_session = true) -{ - // Get out if not integer - if ($userId != strval(intval($userId))) { - return []; - } - - $t_course = Database::get_main_table(TABLE_MAIN_COURSE); - $t_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER); - - $sql = "SELECT cc.id as real_id, cc.code code, cc.directory dir, cu.status status - FROM $t_course cc, $t_course_user cu - WHERE - cc.id = cu.c_id AND - cu.user_id = $userId AND - cu.relation_type <> ".COURSE_RELATION_TYPE_RRHH; - $result = Database::query($sql); - if (false === $result) { - return []; - } - - $courses = []; - while ($row = Database::fetch_array($result)) { - // we only need the database name of the course - $courses[] = $row; - } - - return $courses; -} - /** * Formats user information into a standard array * This function should be only used inside api_get_user_info(). @@ -1502,47 +1387,6 @@ function _api_format_user($user, $add_password = false, $loadAvatars = true) $result['avatar_no_query'] = ''; $result['avatar_small'] = ''; $result['avatar_medium'] = ''; - - /*if (!isset($user['avatar'])) { - $originalFile = UserManager::getUserPicture( - $user_id, - USER_IMAGE_SIZE_ORIGINAL, - null, - $result - ); - $result['avatar'] = $originalFile; - $avatarString = explode('?', $result['avatar']); - $result['avatar_no_query'] = reset($avatarString); - } else { - $result['avatar'] = $user['avatar']; - $avatarString = explode('?', $user['avatar']); - $result['avatar_no_query'] = reset($avatarString); - } - - if (!isset($user['avatar_small'])) { - $smallFile = UserManager::getUserPicture( - $user_id, - USER_IMAGE_SIZE_SMALL, - null, - $result - ); - $result['avatar_small'] = $smallFile; - } else { - $result['avatar_small'] = $user['avatar_small']; - } - - if (!isset($user['avatar_medium'])) { - $mediumFile = UserManager::getUserPicture( - $user_id, - USER_IMAGE_SIZE_MEDIUM, - null, - $result - ); - $result['avatar_medium'] = $mediumFile; - } else { - $result['avatar_medium'] = $user['avatar_medium']; - }*/ - $urlImg = api_get_path(WEB_IMG_PATH); $iconStatus = ''; $iconStatusMedium = ''; @@ -1830,48 +1674,6 @@ function api_get_user_info_from_entity( $result['avatar_no_query'] = ''; $result['avatar_small'] = ''; $result['avatar_medium'] = ''; - - /*if (!isset($user['avatar'])) { - $originalFile = UserManager::getUserPicture( - $user_id, - USER_IMAGE_SIZE_ORIGINAL, - null, - $result - ); - $result['avatar'] = $originalFile; - $avatarString = explode('?', $result['avatar']); - $result['avatar_no_query'] = reset($avatarString); - } else { - $result['avatar'] = $user['avatar']; - $avatarString = explode('?', $user['avatar']); - $result['avatar_no_query'] = reset($avatarString); - } - - if (!isset($user['avatar_small'])) { - $smallFile = UserManager::getUserPicture( - $user_id, - USER_IMAGE_SIZE_SMALL, - null, - $result - ); - $result['avatar_small'] = $smallFile; - } else { - $result['avatar_small'] = $user['avatar_small']; - } - - if (!isset($user['avatar_medium'])) { - $mediumFile = UserManager::getUserPicture( - $user_id, - USER_IMAGE_SIZE_MEDIUM, - null, - $result - ); - $result['avatar_medium'] = $mediumFile; - } else { - $result['avatar_medium'] = $user['avatar_medium']; - }*/ - - //$urlImg = api_get_path(WEB_IMG_PATH); $urlImg = '/'; $iconStatus = ''; $iconStatusMedium = ''; @@ -1953,12 +1755,12 @@ function api_get_user_entity(int $userId = 0): ?User function api_get_current_user(): ?User { - $isLoggedIn = Container::$container->get('security.authorization_checker')->isGranted('IS_AUTHENTICATED_REMEMBERED'); + $isLoggedIn = Container::getAuthorizationChecker()->isGranted('IS_AUTHENTICATED_REMEMBERED'); if (false === $isLoggedIn) { return null; } - $token = Container::$container->get('security.token_storage')->getToken(); + $token = Container::getTokenStorage()->getToken(); if (null !== $token) { return $token->getUser(); @@ -2457,24 +2259,6 @@ function api_format_course_array(Course $course = null) } $courseData['course_image'] = $image.'?filter=course_picture_small'; - - // Course large image - /*$courseData['course_image_large_source'] = ''; - if (file_exists($courseSys.'/course-pic.png')) { - $url_image = $webCourseHome.'/course-pic.png'; - $courseData['course_image_large_source'] = $courseSys.'/course-pic.png'; - } else { - $url_image = Display::return_icon( - 'session_default.png', - null, - null, - null, - null, - true, - true - ); - }*/ - $courseData['course_image_large'] = $image.'?filter=course_picture_medium'; return $courseData; @@ -2912,26 +2696,6 @@ function api_get_setting($variable) $variable = trim($variable); switch ($variable) { - /*case 'header_extra_content': - $filename = api_get_path(SYS_PATH).api_get_home_path().'header_extra_content.txt'; - if (file_exists($filename)) { - $value = file_get_contents($filename); - - return $value; - } else { - return ''; - } - break; - case 'footer_extra_content': - $filename = api_get_path(SYS_PATH).api_get_home_path().'footer_extra_content.txt'; - if (file_exists($filename)) { - $value = file_get_contents($filename); - - return $value; - } else { - return ''; - } - break;*/ case 'server_type': $test = ['dev', 'test']; $environment = Container::getEnvironment(); @@ -3038,9 +2802,8 @@ function api_get_plugin_setting($plugin, $variable) function api_get_settings_params($params) { $table = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT); - $result = Database::select('*', $table, ['where' => $params]); - return $result; + return Database::select('*', $table, ['where' => $params]); } /** @@ -3051,9 +2814,8 @@ function api_get_settings_params($params) function api_get_settings_params_simple($params) { $table = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT); - $result = Database::select('*', $table, ['where' => $params], 'one'); - return $result; + return Database::select('*', $table, ['where' => $params], 'one'); } /** @@ -3062,9 +2824,8 @@ function api_get_settings_params_simple($params) function api_delete_settings_params($params) { $table = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT); - $result = Database::delete($table, $params); - return $result; + return Database::delete($table, $params); } /** @@ -3077,8 +2838,6 @@ function api_get_self() return htmlentities($_SERVER['PHP_SELF']); } -/* USER PERMISSIONS */ - /** * Checks whether current user is a platform administrator. * @@ -3139,9 +2898,8 @@ function api_is_platform_admin_by_id($user_id = null, $url = null) $sql = "SELECT * FROM $url_user_table WHERE access_url_id = $url AND user_id = $user_id"; $res = Database::query($sql); - $result = 1 === Database::num_rows($res); - return $result; + return 1 === Database::num_rows($res); } /** @@ -3215,7 +2973,6 @@ function api_is_course_admin() } return false; - //return Session::read('is_courseAdmin'); } /** @@ -3424,52 +3181,9 @@ function api_is_session_in_category($session_id, $category_name) if (Database::num_rows($rs) > 0) { return true; - } else { - return false; } -} -/** - * Displays the title of a tool. - * Normal use: parameter is a string: - * api_display_tool_title("My Tool"). - * - * Optionally, there can be a subtitle below - * the normal title, and / or a supra title above the normal title. - * - * e.g. supra title: - * group - * GROUP PROPERTIES - * - * e.g. subtitle: - * AGENDA - * calender & events tool - * - * @author Hugues Peeters - * - * @param mixed $title_element - it could either be a string or an array - * containing 'supraTitle', 'mainTitle', - * 'subTitle' - */ -function api_display_tool_title($title_element) -{ - if (is_string($title_element)) { - $tit = $title_element; - unset($title_element); - $title_element = []; - $title_element['mainTitle'] = $tit; - } - echo '

'; - if (!empty($title_element['supraTitle'])) { - echo ''.$title_element['supraTitle'].'
'; - } - if (!empty($title_element['mainTitle'])) { - echo $title_element['mainTitle']; - } - if (!empty($title_element['subTitle'])) { - echo '
'.$title_element['subTitle'].''; - } - echo '

'; + return false; } /** @@ -3796,7 +3510,6 @@ function api_is_allowed_to_session_edit($tutor = false, $coach = false) */ function api_is_allowed($tool, $action, $task_id = 0) { - $_user = api_get_user_info(); $_course = api_get_course_info(); if (api_is_course_admin()) { @@ -3844,15 +3557,11 @@ function api_is_allowed($tool, $action, $task_id = 0) } /** - * Tells whether this user is an anonymous user. - * - * @param int $user_id User ID (optional, will take session ID if not provided) - * @param bool $db_check Whether to check in the database (true) or simply in - * the session (false) to see if the current user is the anonymous user + * Current user is anon? * * @return bool true if this user is anonymous, false otherwise */ -function api_is_anonymous($user_id = null, $db_check = false) +function api_is_anonymous() { return !Container::getAuthorizationChecker()->isGranted('IS_AUTHENTICATED_FULLY'); } @@ -3872,27 +3581,6 @@ function api_not_allowed( throw new Exception('You are not allowed'); } -/** - * Gets a UNIX timestamp from a database (MySQL) datetime format string. - * - * @param $last_post_datetime standard output date in a sql query - * - * @return int timestamp - * - * @author Toon Van Hoecke - * - * @version October 2003 - * @desc convert sql date to unix timestamp - */ -function convert_sql_date($last_post_datetime) -{ - [$last_post_date, $last_post_time] = explode(' ', $last_post_datetime); - [$year, $month, $day] = explode('-', $last_post_date); - [$hour, $min, $sec] = explode(':', $last_post_time); - - return mktime((int) $hour, (int) $min, (int) $sec, (int) $month, (int) $day, (int) $year); -} - /** * Displays a combo box so the user can select his/her preferred language. * @@ -4109,24 +3797,6 @@ function api_get_languages() return $languages; } -/** - * Returns a list of all the languages that are made available by the admin. - * - * @return array - */ -function api_get_languages_to_array() -{ - $tbl_language = Database::get_main_table(TABLE_MAIN_LANGUAGE); - $sql = "SELECT * FROM $tbl_language WHERE available='1' ORDER BY original_name ASC"; - $result = Database::query($sql); - $languages = []; - while ($row = Database::fetch_array($result)) { - $languages[$row['english_name']] = $row['original_name']; - } - - return $languages; -} - /** * Returns the id (the database id) of a language. * @@ -4412,8 +4082,6 @@ function api_time_to_hms($seconds, $space = ':', $showSeconds = true, $roundMinu return $hours.$space.$min.$seconds; } -/* FILE SYSTEM RELATED FUNCTIONS */ - /** * Returns the permissions to be assigned to every newly created directory by the web-server. * The return value is based on the platform administrator's setting @@ -5918,8 +5586,6 @@ function api_is_global_platform_admin($user_id = null) // The admin is registered in the first "main" site with access_url_id = 1 if (in_array(1, $urlList)) { return true; - } else { - return false; } } @@ -5962,10 +5628,10 @@ function api_global_admin_can_edit_admin( } else { return true; } - } else { - return false; } } + + return false; } /** diff --git a/public/main/inc/lib/internationalization.lib.php b/public/main/inc/lib/internationalization.lib.php index bc55e9e871..f9548ef4e6 100644 --- a/public/main/inc/lib/internationalization.lib.php +++ b/public/main/inc/lib/internationalization.lib.php @@ -1960,36 +1960,6 @@ function _api_mb_internal_encoding($encoding = 'UTF-8') return mb_internal_encoding($encoding); } -/** - * Checks whether the specified encoding is supported by the PHP iconv extension. - * - * @param string $encoding the specified encoding - * - * @return bool returns TRUE when the specified encoding is supported, FALSE othewise - */ -function _api_iconv_supports($encoding) -{ - static $supported = []; - if (!isset($supported[$encoding])) { - if (ICONV_INSTALLED) { - $enc = api_refine_encoding_id($encoding); - if ('HTML-ENTITIES' != $enc) { - $test_string = ''; - for ($i = 32; $i < 128; $i++) { - $test_string .= chr($i); - } - $supported[$encoding] = (@iconv_strlen($test_string, $enc)) ? true : false; - } else { - $supported[$encoding] = false; - } - } else { - $supported[$encoding] = false; - } - } - - return $supported[$encoding]; -} - /** * Given a date object, return a human or ISO format, with or without h:m:s. * diff --git a/public/main/mySpace/admin.php b/public/main/mySpace/admin.php index a49c34822e..f66aceaa39 100644 --- a/public/main/mySpace/admin.php +++ b/public/main/mySpace/admin.php @@ -17,7 +17,7 @@ api_block_anonymous_users(); $interbreadcrumb[] = ["url" => "index.php", "name" => get_lang('Reporting')]; Display::display_header($nameTools); $data = []; -api_display_tool_title($nameTools); +Display::page_subheader2($nameTools); // Database Table Definitions $tbl_course = Database::get_main_table(TABLE_MAIN_COURSE); diff --git a/public/main/mySpace/coaches.php b/public/main/mySpace/coaches.php index 400cbf0ca8..792700000c 100644 --- a/public/main/mySpace/coaches.php +++ b/public/main/mySpace/coaches.php @@ -20,7 +20,7 @@ if (isset($_GET["id_student"])) { Display::display_header($nameTools); -api_display_tool_title($nameTools); +Display::page_subheader2($nameTools); $data = []; $tbl_course = Database::get_main_table(TABLE_MAIN_COURSE); $tbl_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER); diff --git a/public/main/session/session_course_edit.php b/public/main/session/session_course_edit.php index 7c026415fb..1081cc5d86 100644 --- a/public/main/session/session_course_edit.php +++ b/public/main/session/session_course_edit.php @@ -142,7 +142,7 @@ if (!api_is_platform_admin() && api_is_teacher()) { Display::display_header($tool_name); $tool_name = get_lang('Edit session course'); -api_display_tool_title($tool_name); +Display::page_subheader2($tool_name); $form = new FormValidator( 'form', diff --git a/public/main/survey/surveyUtil.class.php b/public/main/survey/surveyUtil.class.php index ecaa451b66..334baf341a 100644 --- a/public/main/survey/surveyUtil.class.php +++ b/public/main/survey/surveyUtil.class.php @@ -2486,7 +2486,6 @@ class SurveyUtil SessionEntity $session = null, CGroup $group = null ): ?CSurveyInvitation { - $invitation = new CSurveyInvitation(); $invitation ->setUser($user) diff --git a/public/plugin/before_login/plugin.php b/public/plugin/before_login/plugin.php index edb135866f..59ed64bdca 100644 --- a/public/plugin/before_login/plugin.php +++ b/public/plugin/before_login/plugin.php @@ -20,7 +20,7 @@ $plugin_info['author'] = 'Julio Montoya'; // The plugin configuration. $form = new FormValidator('form'); -$form->addSelect('language', get_lang('Language'), api_get_languages_to_array()); +$form->addSelectLanguage('language', get_lang('Language')); $form->addElement('header', 'Option 1'); $form->addElement('textarea', 'option1', get_lang('Description'), ['rows' => 10, 'class' => 'span6']);