/** * Room constructor. */ public function __construct() { $this->table = \Database::get_main_table('plugin_openmeetings'); $this->name = 'C' . api_get_real_course_id() . '-' . api_get_session_id(); $accessUrl = api_get_access_url(api_get_current_access_url_id()); $this->externalRoomType = substr($accessUrl['url'], strpos($accessUrl['url'], '://') + 3, -1); if (strcmp($this->externalRoomType, 'localhost') == 0) { $this->externalRoomType = substr(api_get_path(WEB_PATH), strpos(api_get_path(WEB_PATH), '://') + 3, -1); } $this->externalRoomType = 'chamilolms.' . $this->externalRoomType; }
/** * Constructor (generates a connection to the API and the Chamilo settings * required for the connection to the video conference server) */ public function __construct() { global $_configuration; // initialize video server settings from global settings $plugin = \OpenMeetingsPlugin::create(); $om_plugin = $plugin->get('tool_enable'); $om_host = $plugin->get('host'); $om_user = $plugin->get('user'); $om_pass = $plugin->get('pass'); $accessUrl = api_get_access_url($_configuration['access_url']); $this->externalType = substr($accessUrl['url'], strpos($accessUrl['url'], '://') + 3, -1); if (strcmp($this->externalType, 'localhost') == 0) { $this->externalType = substr(api_get_path(WEB_PATH), strpos(api_get_path(WEB_PATH), '://') + 3, -1); } $this->externalType = 'chamilolms.' . $this->externalType; $this->table = \Database::get_main_table('plugin_openmeetings'); if ($om_plugin) { $user_info = api_get_user_info(); $this->user_complete_name = $user_info['complete_name']; $this->user = $om_user; $this->pass = $om_pass; $this->url = $om_host; // Setting OM api define('CONFIG_OPENMEETINGS_USER', $this->user); define('CONFIG_OPENMEETINGS_PASS', $this->pass); define('CONFIG_OPENMEETINGS_SERVER_URL', $this->url); $this->gateway = new \OpenMeetingsGateway($this->url, $this->user, $this->pass); $this->plugin_enabled = $om_plugin; // The room has a name composed of C + course ID + '-' + session ID $this->chamiloCourseId = api_get_course_int_id(); $this->chamiloSessionId = api_get_session_id(); $this->roomName = 'C' . $this->chamiloCourseId . '-' . $this->chamiloSessionId; $return = $this->gateway->loginUser(); if ($return == 0) { $msg = 'Could not initiate session with server through OpenMeetingsGateway::loginUser()'; error_log(__FILE__ . '+' . __LINE__ . ': ' . $msg); die($msg); } $this->sessionId = $this->gateway->sessionId; } }
function get_settings($category = null) { $url_id = api_get_current_access_url_id(); $settings_by_access_list = array(); if ($url_id == 1) { $settings = api_get_settings($category, 'group', $url_id); } else { $url_info = api_get_access_url($url_id); if ($url_info['active'] == 1) { // The default settings of Chamilo $settings = api_get_settings($category, 'group', 1, 0); // The settings that are changeable from a particular site. $settings_by_access = api_get_settings($category, 'group', $url_id, 1); foreach ($settings_by_access as $row) { if (empty($row['variable'])) { $row['variable'] = 0; } if (empty($row['subkey'])) { $row['subkey'] = 0; } if (empty($row['category'])) { $row['category'] = 0; } // One more validation if is changeable. if ($row['access_url_changeable'] == 1) { $settings_by_access_list[$row['variable']][$row['subkey']][$row['category']] = $row; } else { $settings_by_access_list[$row['variable']][$row['subkey']][$row['category']] = array(); } } } } if (isset($category) && $category == 'search_setting') { if (!empty($_REQUEST['search_field'])) { $settings = search_setting($_REQUEST['search_field']); } } return array('settings' => $settings, 'settings_by_access_list' => $settings_by_access_list); }
/** * This function returns an icon path that represents the favicon of the website of which the url given. * Defaults to the current Chamilo favicon * @param string URL of website where to look for favicon.ico * @param string Optional second URL of website where to look for favicon.ico * @return string Path of icon to load */ public static function get_favicon_from_url($url1, $url2 = null) { $icon_link = ''; $url = $url1; if (empty($url1)) { $url = $url2; if (empty($url)) { $url = api_get_access_url(api_get_current_access_url_id()); $url = $url[0]; } } if (!empty($url)) { $pieces = parse_url($url); $icon_link = $pieces['scheme'] . '://' . $pieces['host'] . '/favicon.ico'; } return $icon_link; }
/** * This function sends the actual password to the user * * @param int $user * @author Olivier Cauberghe <*****@*****.**>, Ghent University */ public static function send_password_to_user($user, $by_username = false) { $email_subject = "[" . api_get_setting('platform.site_name') . "] " . get_lang('LoginRequest'); // SUBJECT if ($by_username) { // Show only for lost password $user_account_list = self::get_user_account_list($user, false, $by_username); // BODY $email_to = $user['email']; } else { $user_account_list = self::get_user_account_list($user); // BODY $email_to = $user[0]['email']; } $portal_url = api_get_path(WEB_PATH); if (api_is_multiple_url_enabled()) { $access_url_id = api_get_current_access_url_id(); if ($access_url_id != -1) { $url = api_get_access_url($access_url_id); $portal_url = $url['url']; } } $email_body = get_lang('YourAccountParam') . " " . $portal_url . "\n\n{$user_account_list}"; // SEND MESSAGE $sender_name = api_get_person_name(api_get_setting('admin.administrator_name'), api_get_setting('admin.administrator_surname'), null, PERSON_NAME_EMAIL_ADDRESS); $email_admin = api_get_setting('admin.administrator_email'); if (api_mail_html('', $email_to, $email_subject, $email_body, $sender_name, $email_admin) == 1) { return get_lang('YourPasswordHasBeenReset'); } else { $admin_email = Display::encrypted_mailto_link(api_get_setting('admin.administrator_email'), api_get_person_name(api_get_setting('admin.administrator_name'), api_get_setting('admin.administrator_surname'))); return sprintf(get_lang('ThisPlatformWasUnableToSendTheEmailPleaseContactXForMoreInformation'), $admin_email); } }
echo get_lang('ComingSoon'); } Display::display_footer(); exit; } } } $tool_name = get_lang('Registration', null, !empty($_POST['language']) ? $_POST['language'] : $_user['language']); if (api_get_setting('registration.allow_terms_conditions') == 'true' && $user_already_registered_show_terms) { $tool_name = get_lang('TermsAndConditions'); } $home = api_get_path(SYS_APP_PATH) . 'home/'; if (api_is_multiple_url_enabled()) { $access_url_id = api_get_current_access_url_id(); if ($access_url_id != -1) { $url_info = api_get_access_url($access_url_id); $url = api_remove_trailing_slash(preg_replace('/https?:\\/\\//i', '', $url_info['url'])); $clean_url = api_replace_dangerous_char($url); $clean_url = str_replace('/', '-', $clean_url); $clean_url .= '/'; $home_old = api_get_path(SYS_APP_PATH) . 'home/'; $home = api_get_path(SYS_APP_PATH) . 'home/' . $clean_url; } } if (file_exists($home . 'register_top_' . $user_selected_language . '.html')) { $home_top_temp = @(string) file_get_contents($home . 'register_top_' . $user_selected_language . '.html'); $open = str_replace('{rel_path}', api_get_path(REL_PATH), $home_top_temp); $open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open))); if (!empty($open)) { $content = '<div class="well_border">' . $open . '</div>'; }
/** * Set header parameters * @param bool $sendHeaders send headers */ private function set_header_parameters($sendHeaders) { global $httpHeadXtra, $interbreadcrumb, $language_file, $_configuration, $this_section; $_course = api_get_course_info(); $help = $this->help; $nameTools = $this->title; $navigation = return_navigation_array(); $this->menu_navigation = $navigation['menu_navigation']; $this->assign('system_charset', api_get_system_encoding()); if (isset($httpHeadXtra) && $httpHeadXtra) { foreach ($httpHeadXtra as &$thisHttpHead) { header($thisHttpHead); } } $this->assign('online_button', Display::return_icon('statusonline.png', null, null, ICON_SIZE_ATOM)); $this->assign('offline_button', Display::return_icon('statusoffline.png', null, null, ICON_SIZE_ATOM)); // Get language iso-code for this page - ignore errors $this->assign('document_language', api_get_language_isocode()); $course_title = isset($_course['name']) ? $_course['name'] : null; $title_list = array(); $title_list[] = api_get_setting('platform.institution'); $title_list[] = api_get_setting('platform.site_name'); if (!empty($course_title)) { $title_list[] = $course_title; } if ($nameTools != '') { $title_list[] = $nameTools; } $title_string = ''; for ($i = 0; $i < count($title_list); $i++) { $title_string .= $title_list[$i]; if (isset($title_list[$i + 1])) { $item = trim($title_list[$i + 1]); if (!empty($item)) { $title_string .= ' - '; } } } $this->assign('title_string', $title_string); //Setting the theme and CSS files $css = $this->setCssFiles(); $this->set_js_files(); $this->setCssCustomFiles($css); //$this->set_js_files_post(); $browser = api_browser_support('check_browser'); if ($browser[0] == 'Internet Explorer' && $browser[1] >= '11') { $browser_head = '<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE9" />'; $this->assign('browser_specific_head', $browser_head); } // Implementation of prefetch. // See http://cdn.chamilo.org/main/img/online.png for details $prefetch = ''; if (!empty($_configuration['cdn_enable'])) { $prefetch .= '<meta http-equiv="x-dns-prefetch-control" content="on">'; foreach ($_configuration['cdn'] as $host => $exts) { $prefetch .= '<link rel="dns-prefetch" href="' . $host . '">'; } } $this->assign('prefetch', $prefetch); $this->assign('text_direction', api_get_text_direction()); $this->assign('section_name', 'section-' . $this_section); //Defaul root chamilo favicon $favico = '<link rel="shortcut icon" href="' . api_get_path(WEB_PATH) . 'favicon.ico" type="image/x-icon" />'; //Added to verify if in the current Chamilo Theme exist a favicon $favicoThemeUrl = api_get_path(SYS_CSS_PATH) . 'themes/' . $this->theme . '/images/'; //If exist pick the current chamilo theme favicon if (is_file($favicoThemeUrl . 'favicon.ico')) { $favico = '<link rel="shortcut icon" href="' . api_get_path(WEB_CSS_PATH) . 'themes/' . $this->theme . '/images/favicon.ico" type="image/x-icon" />'; } if (api_is_multiple_url_enabled()) { $access_url_id = api_get_current_access_url_id(); if ($access_url_id != -1) { $url_info = api_get_access_url($access_url_id); $url = api_remove_trailing_slash(preg_replace('/https?:\\/\\//i', '', $url_info['url'])); $clean_url = api_replace_dangerous_char($url); $clean_url = str_replace('/', '-', $clean_url); $clean_url .= '/'; $homep = api_get_path(REL_PATH) . 'home/' . $clean_url; //homep for Home Path $icon_real_homep = api_get_path(SYS_APP_PATH) . 'home/' . $clean_url; //we create the new dir for the new sites if (is_file($icon_real_homep . 'favicon.ico')) { $favico = '<link rel="shortcut icon" href="' . $homep . 'favicon.ico" type="image/x-icon" />'; } } } $this->assign('favico', $favico); $this->setHelp(); //@todo move this in the template $bug_notification_link = ''; if (api_get_setting('show_link_bug_notification') == 'true' && $this->user_is_logged_in) { $bug_notification_link = '<li class="report"> <a href="http://support.chamilo.org/projects/chamilo-18/wiki/How_to_report_bugs" target="_blank"> <img src="' . api_get_path(WEB_IMG_PATH) . 'bug.large.png" style="vertical-align: middle;" alt="' . get_lang('ReportABug') . '" title="' . get_lang('ReportABug') . '"/></a> </li>'; } $this->assign('bug_notification_link', $bug_notification_link); $notification = return_notification_menu(); $this->assign('notification_menu', $notification); $resize = ''; if (api_get_setting('accessibility_font_resize') == 'true') { $resize .= '<div class="resize_font">'; $resize .= '<div class="btn-group">'; $resize .= '<a title="' . get_lang('DecreaseFontSize') . '" href="#" class="decrease_font btn btn-default"><em class="fa fa-font"></em></a>'; $resize .= '<a title="' . get_lang('ResetFontSize') . '" href="#" class="reset_font btn btn-default"><em class="fa fa-font"></em></a>'; $resize .= '<a title="' . get_lang('IncreaseFontSize') . '" href="#" class="increase_font btn btn-default"><em class="fa fa-font"></em></a>'; $resize .= '</div>'; $resize .= '</div>'; } $this->assign('accessibility', $resize); // Preparing values for the menu // Logout link $hideLogout = api_get_setting('hide_logout_button'); if ($hideLogout === 'true') { $this->assign('logout_link', null); } else { $this->assign('logout_link', api_get_path(WEB_PATH) . 'index.php?logout=logout&uid=' . api_get_user_id()); } //Profile link if (api_get_setting('social.allow_social_tool') == 'true') { $profile_url = api_get_path(WEB_CODE_PATH) . 'social/home.php'; $profile_link = Display::url(get_lang('Profile'), $profile_url); } else { $profile_url = api_get_path(WEB_CODE_PATH) . 'auth/profile.php'; $profile_link = Display::url(get_lang('Profile'), $profile_url); } $this->assign('profile_link', $profile_link); $this->assign('profile_url', $profile_url); //Message link $message_link = null; $message_url = null; if (api_get_setting('message.allow_message_tool') == 'true') { $message_url = api_get_path(WEB_CODE_PATH) . 'messages/inbox.php'; $message_link = '<a href="' . api_get_path(WEB_CODE_PATH) . 'messages/inbox.php">' . get_lang('Inbox') . '</a>'; } $this->assign('message_link', $message_link); $this->assign('message_url', $message_url); $institution = api_get_setting('platform.institution'); $portal_name = empty($institution) ? api_get_setting('platform.site_name') : $institution; $this->assign('portal_name', $portal_name); //Menu $menu = return_menu(); $this->assign('menu', $menu); // Setting notifications $count_unread_message = 0; if (api_get_setting('message.allow_message_tool') == 'true') { // get count unread message and total invitations $count_unread_message = MessageManager::get_number_of_messages(true); } $total_invitations = 0; if (api_get_setting('social.allow_social_tool') == 'true') { $number_of_new_messages_of_friend = SocialManager::get_message_number_invitation_by_user_id(api_get_user_id()); $usergroup = new UserGroup(); $group_pending_invitations = $usergroup->get_groups_by_user(api_get_user_id(), GROUP_USER_PERMISSION_PENDING_INVITATION, false); if (!empty($group_pending_invitations)) { $group_pending_invitations = count($group_pending_invitations); } else { $group_pending_invitations = 0; } $total_invitations = intval($number_of_new_messages_of_friend) + $group_pending_invitations + intval($count_unread_message); } $total_invitations = !empty($total_invitations) ? Display::badge($total_invitations) : null; $this->assign('user_notifications', $total_invitations); // Block Breadcrumb $breadcrumb = return_breadcrumb($interbreadcrumb, $language_file, $nameTools); $this->assign('breadcrumb', $breadcrumb); //Extra content $extra_header = null; if (!api_is_platform_admin()) { $extra_header = trim(api_get_setting('header_extra_content')); } $this->assign('header_extra_content', $extra_header); if ($sendHeaders) { header('Content-Type: text/html; charset=' . api_get_system_encoding()); header('X-Powered-By: ' . $_configuration['software_name'] . ' ' . substr($_configuration['system_version'], 0, 1)); } $socialMeta = ''; $metaTitle = api_get_setting('meta_title'); if (!empty($metaTitle)) { $socialMeta .= '<meta name="twitter:card" content="summary" />' . "\n"; $socialMeta .= '<meta property="og:title" content="' . $metaTitle . '" />' . "\n"; $socialMeta .= '<meta property="og:url" content="' . api_get_path(WEB_PATH) . '" />' . "\n"; $metaDescription = api_get_setting('meta_description'); if (!empty($metaDescription)) { $socialMeta .= '<meta property="og:description" content="' . $metaDescription . '" />' . "\n"; } $metaSite = api_get_setting('meta_twitter_site'); if (!empty($metaSite)) { $socialMeta .= '<meta name="twitter:site" content="' . $metaSite . '" />' . "\n"; $metaCreator = api_get_setting('meta_twitter_creator'); if (!empty($metaCreator)) { $socialMeta .= '<meta name="twitter:creator" content="' . $metaCreator . '" />' . "\n"; } } $metaImage = api_get_setting('meta_image_path'); if (!empty($metaImage)) { if (is_file(api_get_path(SYS_PATH) . $metaImage)) { $path = api_get_path(WEB_PATH) . $metaImage; $socialMeta .= '<meta property="og:image" content="' . $path . '" />' . "\n"; } } } $this->assign('social_meta', $socialMeta); }
/** * Send the invitation by mail. * * @param invitedUser - the userId (course user) or emailaddress of additional user * $param $invitation_code - the unique invitation code for the URL * @return void */ static function send_invitation_mail($invitedUser, $invitation_code, $invitation_title, $invitation_text) { global $_user, $_course, $_configuration; $portal_url = api_get_path(WEB_CODE_PATH); if (api_is_multiple_url_enabled()) { $access_url_id = api_get_current_access_url_id(); if ($access_url_id != -1) { $url = api_get_access_url($access_url_id); $portal_url = $url['url']; } } // Replacing the **link** part with a valid link for the user $survey_link = api_get_path(WEB_CODE_PATH) . 'survey/fillsurvey.php?course=' . $_course['code'] . '&invitationcode=' . $invitation_code; $text_link = '<a href="' . $survey_link . '">' . get_lang('ClickHereToAnswerTheSurvey') . "</a><br />\r\n<br />\r\n" . get_lang('OrCopyPasteTheFollowingUrl') . " <br />\r\n " . $survey_link; $replace_count = 0; $full_invitation_text = api_str_ireplace('**link**', $text_link, $invitation_text, $replace_count); if ($replace_count < 1) { $full_invitation_text = $full_invitation_text . "<br />\r\n<br />\r\n" . $text_link; } // Sending the mail $sender_name = api_get_person_name($_user['firstName'], $_user['lastName'], null, PERSON_NAME_EMAIL_ADDRESS); $sender_email = $_user['mail']; $sender_user_id = api_get_user_id(); $replyto = array(); if (api_get_setting('survey_email_sender_noreply') == 'noreply') { $noReply = api_get_setting('noreply_email_address'); if (!empty($noReply)) { $sender_name = $noReply; $sender_email = $noReply; $sender_user_id = null; } } // Optionally: finding the e-mail of the user if (is_numeric($invitedUser)) { MessageManager::send_message($invitedUser, $invitation_title, $full_invitation_text, null, null, null, null, null, null, $sender_user_id); } else { /** @todo check if the address is a valid email */ $recipient_email = $invitedUser; @api_mail_html(null, $recipient_email, $invitation_title, $full_invitation_text, $sender_name, $sender_email); } }
/** * Set header parameters */ private function set_header_parameters() { global $httpHeadXtra, $_course, $interbreadcrumb, $language_file, $noPHP_SELF, $_configuration, $this_section; $help = $this->help; $nameTools = $this->title; $navigation = return_navigation_array(); $this->menu_navigation = $navigation['menu_navigation']; $this->assign('system_charset', api_get_system_encoding()); if (isset($httpHeadXtra) && $httpHeadXtra) { foreach ($httpHeadXtra as & $thisHttpHead) { header($thisHttpHead); } } $this->assign('online_button', Display::return_icon('online.png')); $this->assign('offline_button',Display::return_icon('offline.png')); // Get language iso-code for this page - ignore errors $this->assign('document_language', api_get_language_isocode()); $course_title = isset($_course['name']) ? $_course['name'] : null; $title_list = array(); $title_list[] = api_get_setting('Institution'); $title_list[] = api_get_setting('siteName'); if (!empty($course_title)) { $title_list[] = $course_title; } if ($nameTools != '') { $title_list[] = $nameTools; } $title_string = ''; for ($i = 0; $i < count($title_list); $i++) { $title_string .= $title_list[$i]; if (isset($title_list[$i + 1])) { $item = trim($title_list[$i + 1]); if (!empty($item)) { $title_string .= ' - '; } } } $this->assign('title_string', $title_string); //Setting the theme and CSS files $this->set_css_files(); $this->set_js_files(); //$this->set_js_files_post(); $browser = api_browser_support('check_browser'); if ($browser[0] == 'Internet Explorer' && $browser[1] >= '11') { $browser_head = '<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE9" />'; $this->assign('browser_specific_head', $browser_head); } // Implementation of prefetch. // See http://cdn.chamilo.org/main/img/online.png for details $prefetch = ''; if (!empty($_configuration['cdn_enable'])) { $prefetch .= '<meta http-equiv="x-dns-prefetch-control" content="on">'; foreach ($_configuration['cdn'] as $host => $exts) { $prefetch .= '<link rel="dns-prefetch" href="'.$host.'">'; } } $this->assign('prefetch', $prefetch); $this->assign('text_direction', api_get_text_direction()); $this->assign('section_name', 'section-'.$this_section); $favico = '<link rel="shortcut icon" href="'.api_get_path(WEB_PATH).'favicon.ico" type="image/x-icon" />'; if (isset($_configuration['multiple_access_urls']) && $_configuration['multiple_access_urls']) { $access_url_id = api_get_current_access_url_id(); if ($access_url_id != -1) { $url_info = api_get_access_url($access_url_id); $url = api_remove_trailing_slash(preg_replace('/https?:\/\//i', '', $url_info['url'])); $clean_url = replace_dangerous_char($url); $clean_url = str_replace('/', '-', $clean_url); $clean_url .= '/'; $homep = api_get_path(REL_PATH).'home/'.$clean_url; //homep for Home Path $icon_real_homep = api_get_path(SYS_PATH).'home/'.$clean_url; //we create the new dir for the new sites if (is_file($icon_real_homep.'favicon.ico')) { $favico = '<link rel="shortcut icon" href="'.$homep.'favicon.ico" type="image/x-icon" />'; } } } $this->assign('favico', $favico); $this->set_help(); //@todo move this in the template $bug_notification_link = ''; if (api_get_setting('show_link_bug_notification') == 'true' && $this->user_is_logged_in) { $bug_notification_link = '<li class="report"> <a href="http://support.chamilo.org/projects/chamilo-18/wiki/How_to_report_bugs" target="_blank"> <img src="'.api_get_path(WEB_IMG_PATH).'bug.large.png" style="vertical-align: middle;" alt="'.get_lang('ReportABug').'" title="'.get_lang( 'ReportABug' ).'"/></a> </li>'; } $this->assign('bug_notification_link', $bug_notification_link); $notification = return_notification_menu(); $this->assign('notification_menu', $notification); //Preparing values for the menu //Logout link if (isset($_configuration['hide_logout_button']) && $_configuration['hide_logout_button'] == 'true') { $this->assign('logout_link', null); } else { $this->assign('logout_link', api_get_path(WEB_PATH).'index.php?logout=logout&uid='.api_get_user_id()); } //Profile link if (api_get_setting('allow_social_tool') == 'true') { $profile_url = api_get_path(WEB_CODE_PATH).'social/home.php'; $profile_link = Display::url(get_lang('Profile'), $profile_url); } else { $profile_url = api_get_path(WEB_CODE_PATH).'auth/profile.php'; $profile_link = Display::url(get_lang('Profile'), $profile_url); } $this->assign('profile_link', $profile_link); $this->assign('profile_url', $profile_url); //Message link $message_link = null; $message_url = null; if (api_get_setting('allow_message_tool') == 'true') { $message_url = api_get_path(WEB_CODE_PATH).'messages/inbox.php'; $message_link = '<a href="'.api_get_path(WEB_CODE_PATH).'messages/inbox.php">'.get_lang('Inbox').'</a>'; } $this->assign('message_link', $message_link); $this->assign('message_url', $message_url); $institution = api_get_setting('Institution'); $portal_name = empty($institution) ? api_get_setting('siteName') : $institution; $this->assign('portal_name', $portal_name); //Menu $menu = return_menu(); $this->assign('menu', $menu); //Setting notifications $count_unread_message = 0; if (api_get_setting('allow_message_tool') == 'true') { // get count unread message and total invitations $count_unread_message = MessageManager::get_number_of_messages(true); } $total_invitations = 0; if (api_get_setting('allow_social_tool') == 'true') { $number_of_new_messages_of_friend = SocialManager::get_message_number_invitation_by_user_id( api_get_user_id() ); $group_pending_invitations = GroupPortalManager::get_groups_by_user( api_get_user_id(), GROUP_USER_PERMISSION_PENDING_INVITATION, false ); $group_pending_invitations = 0; if (!empty($group_pending_invitations)) { $group_pending_invitations = count($group_pending_invitations); } $total_invitations = intval($number_of_new_messages_of_friend) + $group_pending_invitations + intval( $count_unread_message ); } $total_invitations = (!empty($total_invitations) ? Display::badge($total_invitations) : null); $this->assign('user_notifications', $total_invitations); //Breadcrumb $breadcrumb = return_breadcrumb($interbreadcrumb, $language_file, $nameTools); $this->assign('breadcrumb', $breadcrumb); //Extra content $extra_header = null; if (!api_is_platform_admin()) { $extra_header = trim(api_get_setting('header_extra_content')); } $this->assign('header_extra_content', $extra_header); //if ($this->show_header == 1) { header('Content-Type: text/html; charset='.api_get_system_encoding()); header( 'X-Powered-By: '.$_configuration['software_name'].' '.substr($_configuration['system_version'], 0, 1) ); //} }
/** * Get home path * @return string */ function api_get_home_path() { // FIX : Start the routing determination from central path definition $home = api_get_path(SYS_HOME_PATH); if (api_get_multiple_access_url()) { $access_url_id = api_get_current_access_url_id(); $url_info = api_get_access_url($access_url_id); $url = api_remove_trailing_slash(preg_replace('/https?:\\/\\//i', '', $url_info['url'])); $clean_url = api_replace_dangerous_char($url); $clean_url = str_replace('/', '-', $clean_url); $clean_url .= '/'; if ($clean_url != 'localhost/') { return "{$home}{$clean_url}"; } } return $home; }
function generate_settings_form($settings, $settings_by_access_list) { global $_configuration, $settings_to_avoid, $convert_byte_to_mega_list; $table_settings_current = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT); $form = new FormValidator('settings', 'post', 'settings.php?category=' . Security::remove_XSS($_GET['category'])); $form->addElement('hidden', 'search_field', !empty($_GET['search_field']) ? Security::remove_XSS($_GET['search_field']) : null); $url_id = api_get_current_access_url_id(); if (!empty($_configuration['multiple_access_urls']) && api_is_global_platform_admin() && $url_id == 1) { $group = array(); $group[] = $form->createElement('button', 'mark_all', get_lang('MarkAll')); $group[] = $form->createElement('button', 'unmark_all', get_lang('UnmarkAll')); $form->addGroup($group, 'buttons_in_action_right'); } $default_values = array(); $url_info = api_get_access_url($url_id); $i = 0; foreach ($settings as $row) { if (in_array($row['variable'], array_keys($settings_to_avoid))) { continue; } if (!empty($_configuration['multiple_access_urls'])) { if (api_is_global_platform_admin()) { if ($row['access_url_locked'] == 0) { if ($url_id == 1) { if ($row['access_url_changeable'] == '1') { $form->addElement('html', '<div style="float: right;"><a class="share_this_setting" data_status = "0" data_to_send = "' . $row['variable'] . '" href="javascript:void(0);">' . Display::return_icon('shared_setting.png', get_lang('ChangeSharedSetting')) . '</a></div>'); } else { $form->addElement('html', '<div style="float: right;"><a class="share_this_setting" data_status = "1" data_to_send = "' . $row['variable'] . '" href="javascript:void(0);">' . Display::return_icon('shared_setting_na.png', get_lang('ChangeSharedSetting')) . '</a></div>'); } } else { if ($row['access_url_changeable'] == '1') { $form->addElement('html', '<div style="float: right;">' . Display::return_icon('shared_setting.png', get_lang('ChangeSharedSetting')) . '</div>'); } else { $form->addElement('html', '<div style="float: right;">' . Display::return_icon('shared_setting_na.png', get_lang('ChangeSharedSetting')) . '</div>'); } } } } } $hideme = array(); $hide_element = false; if ($_configuration['access_url'] != 1) { if ($row['access_url_changeable'] == 0) { // We hide the element in other cases (checkbox, radiobutton) we 'freeze' the element. $hide_element = true; $hideme = array('disabled'); } elseif ($url_info['active'] == 1) { // We show the elements. if (empty($row['variable'])) { $row['variable'] = 0; } if (empty($row['subkey'])) { $row['subkey'] = 0; } if (empty($row['category'])) { $row['category'] = 0; } if (is_array($settings_by_access_list[$row['variable']][$row['subkey']][$row['category']])) { // We are sure that the other site have a selected value. if ($settings_by_access_list[$row['variable']][$row['subkey']][$row['category']]['selected_value'] != '') { $row['selected_value'] = $settings_by_access_list[$row['variable']][$row['subkey']][$row['category']]['selected_value']; } } // There is no else{} statement because we load the default $row['selected_value'] of the main Chamilo site. } } switch ($row['type']) { case 'textfield': if (in_array($row['variable'], $convert_byte_to_mega_list)) { $form->addElement('text', $row['variable'], array(get_lang($row['title']), get_lang($row['comment']), get_lang('MB')), array('maxlength' => '8')); $form->applyFilter($row['variable'], 'html_filter'); $default_values[$row['variable']] = round($row['selected_value'] / 1024 / 1024, 1); } elseif ($row['variable'] == 'account_valid_duration') { $form->addElement('text', $row['variable'], array(get_lang($row['title']), get_lang($row['comment'])), array('maxlength' => '5')); $form->applyFilter($row['variable'], 'html_filter'); $default_values[$row['variable']] = $row['selected_value']; // For platform character set selection: Conversion of the textfield to a select box with valid values. } elseif ($row['variable'] == 'platform_charset') { continue; } else { $hideme['class'] = 'col-md-4'; $form->addElement('text', $row['variable'], array(get_lang($row['title']), get_lang($row['comment'])), $hideme); $form->applyFilter($row['variable'], 'html_filter'); $default_values[$row['variable']] = $row['selected_value']; } break; case 'textarea': if ($row['variable'] == 'header_extra_content') { $file = api_get_path(SYS_PATH) . api_get_home_path() . 'header_extra_content.txt'; $value = ''; if (file_exists($file)) { $value = file_get_contents($file); } $form->addElement('textarea', $row['variable'], array(get_lang($row['title']), get_lang($row['comment'])), array('rows' => '10'), $hideme); $default_values[$row['variable']] = $value; } elseif ($row['variable'] == 'footer_extra_content') { $file = api_get_path(SYS_PATH) . api_get_home_path() . 'footer_extra_content.txt'; $value = ''; if (file_exists($file)) { $value = file_get_contents($file); } $form->addElement('textarea', $row['variable'], array(get_lang($row['title']), get_lang($row['comment'])), array('rows' => '10'), $hideme); $default_values[$row['variable']] = $value; } else { $form->addElement('textarea', $row['variable'], array(get_lang($row['title']), get_lang($row['comment'])), array('rows' => '10'), $hideme); $default_values[$row['variable']] = $row['selected_value']; } break; case 'radio': $values = api_get_settings_options($row['variable']); $group = array(); if (is_array($values)) { foreach ($values as $key => $value) { $element =& $form->createElement('radio', $row['variable'], '', get_lang($value['display_text']), $value['value']); if ($hide_element) { $element->freeze(); } $group[] = $element; } } $form->addGroup($group, $row['variable'], array(get_lang($row['title']), get_lang($row['comment'])), '', false); $default_values[$row['variable']] = $row['selected_value']; break; case 'checkbox': // 1. We collect all the options of this variable. $sql = "SELECT * FROM {$table_settings_current}\n WHERE variable='" . $row['variable'] . "' AND access_url = 1"; $result = Database::query($sql); $group = array(); while ($rowkeys = Database::fetch_array($result)) { // Profile tab option should be hidden when the social tool is enabled. if (api_get_setting('social.allow_social_tool') == 'true') { if ($rowkeys['variable'] == 'show_tabs' && $rowkeys['subkey'] == 'my_profile') { continue; } } // Hiding the gradebook option. if ($rowkeys['variable'] == 'show_tabs' && $rowkeys['subkey'] == 'my_gradebook') { continue; } $element =& $form->createElement('checkbox', $rowkeys['subkey'], '', get_lang($rowkeys['subkeytext'])); if ($row['access_url_changeable'] == 1) { // 2. We look into the DB if there is a setting for a specific access_url. $access_url = $_configuration['access_url']; if (empty($access_url)) { $access_url = 1; } $sql = "SELECT selected_value FROM {$table_settings_current}\n WHERE\n variable='" . $rowkeys['variable'] . "' AND\n subkey='" . $rowkeys['subkey'] . "' AND\n subkeytext='" . $rowkeys['subkeytext'] . "' AND\n access_url = {$access_url}"; $result_access = Database::query($sql); $row_access = Database::fetch_array($result_access); if ($row_access['selected_value'] == 'true' && !$form->isSubmitted()) { $element->setChecked(true); } } else { if ($rowkeys['selected_value'] == 'true' && !$form->isSubmitted()) { $element->setChecked(true); } } if ($hide_element) { $element->freeze(); } $group[] = $element; } $form->addGroup($group, $row['variable'], array(get_lang($row['title']), get_lang($row['comment'])), ''); break; case 'link': $form->addElement('static', null, array(get_lang($row['title']), get_lang($row['comment'])), get_lang('CurrentValue') . ' : ' . $row['selected_value'], $hideme); break; case 'select': /* * To populate the list of options, the select type dynamically calls a function that must be called select_ + the name of the variable being displayed. * The functions being called must be added to the file settings.lib.php. */ $form->addElement('select', $row['variable'], array(get_lang($row['title']), get_lang($row['comment'])), call_user_func('select_' . $row['variable']), $hideme); $default_values[$row['variable']] = $row['selected_value']; break; case 'custom': break; } switch ($row['variable']) { case 'pdf_export_watermark_enable': $url = PDF::get_watermark(null); if ($url != false) { $delete_url = '<a href="?delete_watermark">' . get_lang('DelImage') . ' ' . Display::return_icon('delete.png', get_lang('DelImage')) . '</a>'; $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>'); } $form->addElement('file', 'pdf_export_watermark_path', get_lang('AddWaterMark')); $allowed_picture_types = array('jpg', 'jpeg', 'png', 'gif'); $form->addRule('pdf_export_watermark_path', get_lang('OnlyImagesAllowed') . ' (' . implode(',', $allowed_picture_types) . ')', 'filetype', $allowed_picture_types); break; case 'timezone_value': $timezone = $row['selected_value']; if (empty($timezone)) { $timezone = _api_get_timezone(); } $form->addElement('html', sprintf(get_lang('LocalTimeUsingPortalTimezoneXIsY'), $timezone, api_get_local_time())); break; } } // end for if (!empty($settings)) { $form->setDefaults($default_values); } $form->addHtml('<div class="bottom_actions">'); $form->addButtonSave(get_lang('SaveSettings')); $form->addHtml('</div>'); return $form; }
function return_menu() { $navigation = return_navigation_array(); $navigation = $navigation['navigation']; // Displaying the tabs $lang = ''; //el for "Edit Language" if (!empty($_SESSION['user_language_choice'])) { $lang = $_SESSION['user_language_choice']; } elseif (!empty($_SESSION['_user']['language'])) { $lang = $_SESSION['_user']['language']; } else { $lang = get_setting('platformLanguage'); } //Preparing home folder for multiple urls if (api_get_multiple_access_url()) { $access_url_id = api_get_current_access_url_id(); if ($access_url_id != -1) { $url_info = api_get_access_url($access_url_id); $url = api_remove_trailing_slash(preg_replace('/https?:\\/\\//i', '', $url_info['url'])); $clean_url = replace_dangerous_char($url); $clean_url = str_replace('/', '-', $clean_url); $clean_url .= '/'; $homep = api_get_path(SYS_PATH) . 'home/' . $clean_url; //homep for Home Path //we create the new dir for the new sites if (!is_dir($homep)) { mkdir($homep, api_get_permissions_for_new_directories()); } } } else { $homep = api_get_path(SYS_PATH) . 'home/'; } $ext = '.html'; $menutabs = 'home_tabs'; $mtloggedin = 'home_tabs_logged_in'; $home_top = ''; if (is_file($homep . $menutabs . '_' . $lang . $ext) && is_readable($homep . $menutabs . '_' . $lang . $ext)) { $home_top = @(string) file_get_contents($homep . $menutabs . '_' . $lang . $ext); } elseif (is_file($homep . $menutabs . $lang . $ext) && is_readable($homep . $menutabs . $lang . $ext)) { $home_top = @(string) file_get_contents($homep . $menutabs . $lang . $ext); } else { //$errorMsg = get_lang('HomePageFilesNotReadable'); } $home_top = api_to_system_encoding($home_top, api_detect_encoding(strip_tags($home_top))); $open = str_replace('{rel_path}', api_get_path(REL_PATH), $home_top); $open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open))); $open_mtloggedin = ''; if (api_get_user_id() && !api_is_anonymous()) { if (is_file($homep . $mtloggedin . '_' . $lang . $ext) && is_readable($homep . $mtloggedin . '_' . $lang . $ext)) { $home_top = @(string) file_get_contents($homep . $mtloggedin . '_' . $lang . $ext); $home_top = str_replace('::private', '', $home_top); } elseif (is_file($homep . $mtloggedin . $lang . $ext) && is_readable($homep . $mtloggedin . $lang . $ext)) { $home_top = @(string) file_get_contents($homep . $mtloggedin . $lang . $ext); $home_top = str_replace('::private', '', $home_top); } else { //$errorMsg = get_lang('HomePageFilesNotReadable'); } $home_top = api_to_system_encoding($home_top, api_detect_encoding(strip_tags($home_top))); $open_mtloggedin = str_replace('{rel_path}', api_get_path(REL_PATH), $home_top); $open_mtloggedin = api_to_system_encoding($open_mtloggedin, api_detect_encoding(strip_tags($open_mtloggedin))); } $lis = ''; if (!empty($open) or !empty($open_mtloggedin)) { if (strpos($open . $open_mtloggedin, 'show_menu') === false) { if (api_is_anonymous()) { $navigation[SECTION_CAMPUS] = null; } } else { //$lis .= Display::tag('li', $open); if (api_get_user_id() && !api_is_anonymous()) { $lis .= $open_mtloggedin; } else { $lis .= $open; } } } if (count($navigation) > 0 || !empty($lis)) { $pre_lis = ''; foreach ($navigation as $section => $navigation_info) { $key = !empty($navigation_info['key']) ? 'tab-' . $navigation_info['key'] : ''; if (isset($GLOBALS['this_section'])) { $current = $section == $GLOBALS['this_section'] ? ' id="current" class="active ' . $key . '" ' : ' class="' . $key . '"'; } else { $current = ''; } if (!empty($navigation_info['title'])) { $pre_lis .= '<li' . $current . '><a href="' . $navigation_info['url'] . '" target="_top">' . $navigation_info['title'] . '</a></li>'; } } $lis = $pre_lis . $lis; } $menu = null; if (!empty($lis)) { $menu .= $lis; } return $menu; }
} $charset = 'UTF-8'; // Enables the portablity layer and configures PHP for UTF-8 \Patchwork\Utf8\Bootup::initAll(); // Start session after the internationalization library has been initialized. ChamiloSession::instance()->start($alreadyInstalled); // Remove quotes added by PHP - get_magic_quotes_gpc() is deprecated in PHP 5 see #2970 if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()) { array_walk_recursive_limited($_GET, 'stripslashes', true); array_walk_recursive_limited($_POST, 'stripslashes', true); array_walk_recursive_limited($_COOKIE, 'stripslashes', true); array_walk_recursive_limited($_REQUEST, 'stripslashes', true); } // access_url == 1 is the default chamilo location if ($_configuration['access_url'] != 1) { $url_info = api_get_access_url($_configuration['access_url']); if ($url_info['active'] == 1) { $settings_by_access =& api_get_settings(null, 'list', $_configuration['access_url'], 1); foreach ($settings_by_access as &$row) { if (empty($row['variable'])) { $row['variable'] = 0; } if (empty($row['subkey'])) { $row['subkey'] = 0; } if (empty($row['category'])) { $row['category'] = 0; } $settings_by_access_list[$row['variable']][$row['subkey']][$row['category']] = $row; } }
/** * Gets a link to the resource from the present location, depending on item ID. * @param string $type Type of link expected * @param integer $item_id Learnpath item ID * @return string $provided_toc Link to the lp_item resource */ public function get_link($type = 'http', $item_id = null, $provided_toc = false) { $course_id = $this->get_course_int_id(); if ($this->debug > 0) { error_log('New LP - In learnpath::get_link(' . $type . ',' . $item_id . ')', 0); } if (empty($item_id)) { if ($this->debug > 2) { error_log('New LP - In learnpath::get_link() - no item id given in learnpath::get_link(), using current: ' . $this->get_current_item_id(), 0); } $item_id = $this->get_current_item_id(); } if (empty($item_id)) { if ($this->debug > 2) { error_log('New LP - In learnpath::get_link() - no current item id found in learnpath object', 0); } //still empty, this means there was no item_id given and we are not in an object context or //the object property is empty, return empty link $item_id = $this->first(); return ''; } $file = ''; $lp_table = Database::get_course_table(TABLE_LP_MAIN); $lp_item_table = Database::get_course_table(TABLE_LP_ITEM); $lp_item_view_table = Database::get_course_table(TABLE_LP_ITEM_VIEW); $item_id = intval($item_id); $sql = "SELECT\n l.lp_type as ltype,\n l.path as lpath,\n li.item_type as litype,\n li.path as lipath,\n li.parameters as liparams\n \t\tFROM {$lp_table} l\n INNER JOIN {$lp_item_table} li\n ON (li.lp_id = l.id AND l.c_id = {$course_id} AND li.c_id = {$course_id} )\n \t\tWHERE li.id = {$item_id} "; if ($this->debug > 2) { error_log('New LP - In learnpath::get_link() - selecting item ' . $sql, 0); } $res = Database::query($sql); if (Database::num_rows($res) > 0) { $row = Database::fetch_array($res); $lp_type = $row['ltype']; $lp_path = $row['lpath']; $lp_item_type = $row['litype']; $lp_item_path = $row['lipath']; $lp_item_params = $row['liparams']; if (empty($lp_item_params) && strpos($lp_item_path, '?') !== false) { list($lp_item_path, $lp_item_params) = explode('?', $lp_item_path); } $sys_course_path = api_get_path(SYS_COURSE_PATH) . api_get_course_path(); if ($type == 'http') { $course_path = api_get_path(WEB_COURSE_PATH) . api_get_course_path(); //web path } else { $course_path = $sys_course_path; //system path } // Fixed issue BT#1272 - If the item type is a Chamilo Item (quiz, link, etc), then change the lp type to thread it as a normal Chamilo LP not a SCO. if (in_array($lp_item_type, array('quiz', 'document', 'link', 'forum', 'thread', 'student_publication'))) { $lp_type = 1; } if ($this->debug > 2) { error_log('New LP - In learnpath::get_link() - $lp_type ' . $lp_type, 0); error_log('New LP - In learnpath::get_link() - $lp_item_type ' . $lp_item_type, 0); } // Now go through the specific cases to get the end of the path // @todo Use constants instead of int values. switch ($lp_type) { case 1: if ($lp_item_type == 'dokeos_chapter') { $file = 'lp_content.php?type=dir'; } else { require_once 'resourcelinker.inc.php'; $file = rl_get_resource_link_for_learnpath($course_id, $this->get_id(), $item_id, $this->get_view_id()); if ($this->debug > 0) { error_log('rl_get_resource_link_for_learnpath - file: ' . $file, 0); } if ($lp_item_type == 'link') { if (Link::is_youtube_link($file)) { $src = Link::get_youtube_video_id($file); $file = api_get_path(WEB_CODE_PATH) . 'newscorm/embed.php?type=youtube&source=' . $src; } elseif (Link::isVimeoLink($file)) { $src = Link::getVimeoLinkId($file); $file = api_get_path(WEB_CODE_PATH) . 'newscorm/embed.php?type=vimeo&source=' . $src; } else { // If the current site is HTTPS and the link is // HTTP, browsers will refuse opening the link $urlId = api_get_current_access_url_id(); $url = api_get_access_url($urlId, false); $protocol = substr($url['url'], 0, 5); if ($protocol === 'https') { $linkProtocol = substr($file, 0, 5); if ($linkProtocol === 'http:') { //this is the special intervention case $file = api_get_path(WEB_CODE_PATH) . 'newscorm/embed.php?type=nonhttps&source=' . urlencode($file); } } } } else { // Check how much attempts of a exercise exits in lp $lp_item_id = $this->get_current_item_id(); $lp_view_id = $this->get_view_id(); $prevent_reinit = null; if (isset($this->items[$this->current])) { $prevent_reinit = $this->items[$this->current]->get_prevent_reinit(); } if (empty($provided_toc)) { if ($this->debug > 0) { error_log('In learnpath::get_link() Loading get_toc ', 0); } $list = $this->get_toc(); } else { if ($this->debug > 0) { error_log('In learnpath::get_link() Loading get_toc from "cache" ', 0); } $list = $provided_toc; } $type_quiz = false; foreach ($list as $toc) { if ($toc['id'] == $lp_item_id && $toc['type'] == 'quiz') { $type_quiz = true; } } if ($type_quiz) { $lp_item_id = intval($lp_item_id); $lp_view_id = intval($lp_view_id); $sql = "SELECT count(*) FROM {$lp_item_view_table}\n WHERE\n c_id = {$course_id} AND\n lp_item_id='" . $lp_item_id . "' AND\n lp_view_id ='" . $lp_view_id . "' AND\n status='completed'"; $result = Database::query($sql); $row_count = Database::fetch_row($result); $count_item_view = (int) $row_count[0]; $not_multiple_attempt = 0; if ($prevent_reinit === 1 && $count_item_view > 0) { $not_multiple_attempt = 1; } $file .= '¬_multiple_attempt=' . $not_multiple_attempt; } $tmp_array = explode('/', $file); $document_name = $tmp_array[count($tmp_array) - 1]; if (strpos($document_name, '_DELETED_')) { $file = 'blank.php?error=document_deleted'; } } } break; case 2: if ($this->debug > 2) { error_log('New LP - In learnpath::get_link() ' . __LINE__ . ' - Item type: ' . $lp_item_type, 0); } if ($lp_item_type != 'dir') { // Quite complex here: // We want to make sure 'http://' (and similar) links can // be loaded as is (withouth the Chamilo path in front) but // some contents use this form: resource.htm?resource=http://blablabla // which means we have to find a protocol at the path's start, otherwise // it should not be considered as an external URL. //if ($this->prerequisites_match($item_id)) { if (preg_match('#^[a-zA-Z]{2,5}://#', $lp_item_path) != 0) { if ($this->debug > 2) { error_log('New LP - In learnpath::get_link() ' . __LINE__ . ' - Found match for protocol in ' . $lp_item_path, 0); } // Distant url, return as is. $file = $lp_item_path; } else { if ($this->debug > 2) { error_log('New LP - In learnpath::get_link() ' . __LINE__ . ' - No starting protocol in ' . $lp_item_path, 0); } // Prevent getting untranslatable urls. $lp_item_path = preg_replace('/%2F/', '/', $lp_item_path); $lp_item_path = preg_replace('/%3A/', ':', $lp_item_path); // Prepare the path. $file = $course_path . '/scorm/' . $lp_path . '/' . $lp_item_path; // TODO: Fix this for urls with protocol header. $file = str_replace('//', '/', $file); $file = str_replace(':/', '://', $file); if (substr($lp_path, -1) == '/') { $lp_path = substr($lp_path, 0, -1); } if (!is_file(realpath($sys_course_path . '/scorm/' . $lp_path . '/' . $lp_item_path))) { // if file not found. $decoded = html_entity_decode($lp_item_path); list($decoded) = explode('?', $decoded); if (!is_file(realpath($sys_course_path . '/scorm/' . $lp_path . '/' . $decoded))) { require_once 'resourcelinker.inc.php'; $file = rl_get_resource_link_for_learnpath($course_id, $this->get_id(), $item_id, $this->get_view_id()); if (empty($file)) { $file = 'blank.php?error=document_not_found'; } else { $tmp_array = explode('/', $file); $document_name = $tmp_array[count($tmp_array) - 1]; if (strpos($document_name, '_DELETED_')) { $file = 'blank.php?error=document_deleted'; } else { $file = 'blank.php?error=document_not_found'; } } } else { $file = $course_path . '/scorm/' . $lp_path . '/' . $decoded; } } } // We want to use parameters if they were defined in the imsmanifest if (strpos($file, 'blank.php') === false) { $file .= (strstr($file, '?') === false ? '?' : '') . $lp_item_params; } } else { $file = 'lp_content.php?type=dir'; } break; case 3: if ($this->debug > 2) { error_log('New LP - In learnpath::get_link() ' . __LINE__ . ' - Item type: ' . $lp_item_type, 0); } // Formatting AICC HACP append URL. $aicc_append = '?aicc_sid=' . urlencode(session_id()) . '&aicc_url=' . urlencode(api_get_path(WEB_CODE_PATH) . 'newscorm/aicc_hacp.php') . '&'; if (!empty($lp_item_params)) { $aicc_append .= $lp_item_params . '&'; } if ($lp_item_type != 'dir') { // Quite complex here: // We want to make sure 'http://' (and similar) links can // be loaded as is (withouth the Chamilo path in front) but // some contents use this form: resource.htm?resource=http://blablabla // which means we have to find a protocol at the path's start, otherwise // it should not be considered as an external URL. if (preg_match('#^[a-zA-Z]{2,5}://#', $lp_item_path) != 0) { if ($this->debug > 2) { error_log('New LP - In learnpath::get_link() ' . __LINE__ . ' - Found match for protocol in ' . $lp_item_path, 0); } // Distant url, return as is. $file = $lp_item_path; // Enabled and modified by Ivan Tcholakov, 16-OCT-2008. /* if (stristr($file,'<servername>') !== false) { $file = str_replace('<servername>', $course_path.'/scorm/'.$lp_path.'/', $lp_item_path); } */ if (stripos($file, '<servername>') !== false) { //$file = str_replace('<servername>',$course_path.'/scorm/'.$lp_path.'/',$lp_item_path); $web_course_path = str_replace('https://', '', str_replace('http://', '', $course_path)); $file = str_replace('<servername>', $web_course_path . '/scorm/' . $lp_path, $lp_item_path); } // $file .= $aicc_append; } else { if ($this->debug > 2) { error_log('New LP - In learnpath::get_link() ' . __LINE__ . ' - No starting protocol in ' . $lp_item_path, 0); } // Prevent getting untranslatable urls. $lp_item_path = preg_replace('/%2F/', '/', $lp_item_path); $lp_item_path = preg_replace('/%3A/', ':', $lp_item_path); // Prepare the path - lp_path might be unusable because it includes the "aicc" subdir name. $file = $course_path . '/scorm/' . $lp_path . '/' . $lp_item_path; // TODO: Fix this for urls with protocol header. $file = str_replace('//', '/', $file); $file = str_replace(':/', '://', $file); $file .= $aicc_append; } } else { $file = 'lp_content.php?type=dir'; } break; case 4: break; default: break; } // Replace & by & because & will break URL with params $file = !empty($file) ? str_replace('&', '&', $file) : ''; } if ($this->debug > 2) { error_log('New LP - In learnpath::get_link() - returning "' . $file . '" from get_link', 0); } return $file; }
/** * This function allows the platform admin to choose the default stylesheet * @author Patrick Cool <*****@*****.**>, Ghent University */ function handle_stylesheets() { global $_configuration; // Current style $currentstyle = api_get_setting('stylesheets'); $is_style_changeable = false; if ($_configuration['access_url'] != 1) { $style_info = api_get_settings('stylesheets', '', 1, 0); $url_info = api_get_access_url($_configuration['access_url']); if ($style_info[0]['access_url_changeable'] == 1 && $url_info['active'] == 1) { $is_style_changeable = true; echo '<div class="actions" id="stylesheetuploadlink">'; Display::display_icon('theme_add.gif'); echo '<a href="" onclick="document.getElementById(\'newstylesheetform\').style.display = \'block\'; document.getElementById(\'stylesheetuploadlink\').style.display = \'none\';return false; ">' . get_lang('UploadNewStylesheet') . '</a>'; echo '</div>'; } } else { $is_style_changeable = true; echo '<div class="actions" id="stylesheetuploadlink">'; Display::display_icon('theme_add.gif'); echo '<a href="" onclick="document.getElementById(\'newstylesheetform\').style.display = \'block\'; document.getElementById(\'stylesheetuploadlink\').style.display = \'none\';return false; ">' . get_lang('UploadNewStylesheet') . '</a>'; echo '</div>'; } $form = new FormValidator('stylesheet_upload', 'post', 'settings.php?category=stylesheets&showuploadform=true'); $form->addElement('text', 'name_stylesheet', get_lang('NameStylesheet'), array('size' => '40', 'maxlength' => '40')); $form->addRule('name_stylesheet', get_lang('ThisFieldIsRequired'), 'required'); $form->addElement('file', 'new_stylesheet', get_lang('UploadNewStylesheet')); $allowed_file_types = array('css'); $form->addRule('new_stylesheet', get_lang('InvalidExtension') . ' (' . implode(',', $allowed_file_types) . ')', 'filetype', $allowed_file_types); $form->addRule('new_stylesheet', get_lang('ThisFieldIsRequired'), 'required'); $form->addElement('style_submit_button', 'stylesheet_upload', get_lang('Ok'), array('class' => 'save')); if ($form->validate() and is_writable(api_get_path(SYS_CODE_PATH) . 'css/')) { $values = $form->exportValues(); $picture_element =& $form->getElement('new_stylesheet'); $picture = $picture_element->getValue(); upload_stylesheet($values, $picture); Display::display_confirmation_message(get_lang('StylesheetAdded')); } else { if (!is_writable(api_get_path(SYS_CODE_PATH) . 'css/')) { Display::display_error_message(api_get_path(SYS_CODE_PATH) . 'css/' . get_lang('IsNotWritable')); } else { if ($_GET['showuploadform'] == 'true') { echo '<div id="newstylesheetform">'; } else { echo '<div id="newstylesheetform" style="display: none;">'; } // uploading a new stylesheet if ($_configuration['access_url'] == 1) { $form->display(); } else { if ($is_style_changeable) { $form->display(); } } echo '</div>'; } } // Preview of the stylesheet echo '<div><iframe src="style_preview.php" width="100%" height="300" name="preview"></iframe></div>'; echo '<form name="stylesheets" method="post" action="' . api_get_self() . '?category=' . Security::remove_XSS($_GET['category']) . '">'; if ($handle = @opendir(api_get_path(SYS_PATH) . 'main/css/')) { $counter = 1; while (false !== ($style_dir = readdir($handle))) { if (substr($style_dir, 0, 1) == '.') { continue; } $dirpath = api_get_path(SYS_PATH) . 'main/css/' . $style_dir; if (is_dir($dirpath)) { if ($style_dir != '.' && $style_dir != '..') { if ($currentstyle == $style_dir or $style_dir == 'dokeos_classic' and !$currentstyle) { $selected = 'checked="checked"'; } else { $selected = ''; } $show_name = get_lang(str_replace(' ', '', ucwords(str_replace('_', ' ', $style_dir)))); if ($is_style_changeable) { echo "<input type=\"radio\" name=\"style\" value=\"" . $style_dir . "\" " . $selected . " onClick=\"parent.preview.location='style_preview.php?style=" . $style_dir . "';\"/>"; echo '<a href="style_preview.php?style=' . $style_dir . '" target="preview">' . $show_name . '</a>'; } else { echo '<a href="style_preview.php?style=' . $style_dir . '" target="preview">' . $show_name . '</a>'; } //echo '<div id="Layer'.$counter.'" style="position:relative; width:687px; z-index:2; visibility: hidden;">'; //echo '<a href="#" onClick="MM_showHideLayers(\'Layer'.$counter.'\',\'\',\'hide\')">'.get_lang('Close').'</a>'; //echo '<iframe src="style_preview.php?style='.$file.'" width="100%" style="float:right;"></iframe></div>'; echo "<br />\n"; $counter++; } } } @closedir($handle); } if ($is_style_changeable) { echo '<button class="save" type="submit" name="submit_stylesheets"> ' . get_lang('SaveSettings') . ' </button></form>'; } }
//$auth_source = $user['password']['auth_source']; //$password = '******'; } else { //$auth_source = PLATFORM_AUTH_SOURCE; //$password = $user['password']['password_auto'] == '1' ? api_generate_password() : $user['password']['password']; } $auth_source = $userInfo['auth_source']; $password = $user['password']['password_auto'] == '1' ? api_generate_password() : $user['password']['password']; UserManager::update_user($userId, $userInfo['firstname'], $userInfo['lastname'], $userInfo['username'], $password, $auth_source, $userInfo['email'], $userInfo['status'], $userInfo['official_code'], $userInfo['phone'], $userInfo['picture_uri'], $userInfo['expiration_date'], $userInfo['active'], $userInfo['creator_id'], $userInfo['hr_dept_id'], null, $userInfo['language'], null, false, $resetPassword); if (!empty($email) && $send_mail) { $emailsubject = '[' . api_get_setting('platform.site_name') . '] ' . get_lang('YourReg') . ' ' . api_get_setting('platform.site_name'); $portal_url = api_get_path(WEB_PATH); if (api_is_multiple_url_enabled()) { $access_url_id = api_get_current_access_url_id(); if ($access_url_id != -1) { $url = api_get_access_url($access_url_id); $portal_url = $url['url']; } } $emailbody = get_lang('Dear') . " " . stripslashes(api_get_person_name($userInfo['firstname'], $userInfo['lastname'])) . ",\n\n" . get_lang('YouAreReg') . " " . api_get_setting('platform.site_name') . " " . get_lang('WithTheFollowingSettings') . "\n\n" . get_lang('Username') . " : " . $username . "\n" . get_lang('Pass') . " : " . stripslashes($password) . "\n\n" . get_lang('Address') . " " . api_get_setting('platform.site_name') . " " . get_lang('Is') . " : " . $portal_url . "\n\n" . get_lang('Problem') . "\n\n" . get_lang('SignatureFormula') . ",\n\n" . api_get_person_name(api_get_setting('admin.administrator_name'), api_get_setting('admin.administrator_surname')) . "\n" . get_lang('Manager') . " " . api_get_setting('platform.site_name') . "\nT. " . api_get_setting('admin.administrator_phone') . "\n" . get_lang('Email') . " : " . api_get_setting('admin.administrator_email'); $emailbody = nl2br($emailbody); api_mail_html(api_get_person_name($userInfo['firstname'], $userInfo['lastname'], null, PERSON_NAME_EMAIL_ADDRESS), $email, $emailsubject, $emailbody); } Security::clear_token(); $tok = Security::get_token(); header('Location: ' . $url . '&message=1'); exit; } } else { if (isset($_POST['submit'])) { Security::clear_token();
function api_set_settings_and_plugins() { global $_configuration; $_setting = array(); $_plugins = array(); // access_url == 1 is the default chamilo location $settings_by_access_list = array(); $access_url_id = api_get_current_access_url_id(); if ($access_url_id != 1) { $url_info = api_get_access_url($_configuration['access_url']); if ($url_info['active'] == 1) { $settings_by_access =& api_get_settings(null, 'list', $_configuration['access_url'], 1); foreach ($settings_by_access as &$row) { if (empty($row['variable'])) { $row['variable'] = 0; } if (empty($row['subkey'])) { $row['subkey'] = 0; } if (empty($row['category'])) { $row['category'] = 0; } $settings_by_access_list[$row['variable']][$row['subkey']][$row['category']] = $row; } } } $result = api_get_settings(null, 'list', 1); foreach ($result as &$row) { if ($access_url_id != 1) { if ($url_info['active'] == 1) { $var = empty($row['variable']) ? 0 : $row['variable']; $subkey = empty($row['subkey']) ? 0 : $row['subkey']; $category = empty($row['category']) ? 0 : $row['category']; } if ($row['access_url_changeable'] == 1 && $url_info['active'] == 1) { if (isset($settings_by_access_list[$var]) && $settings_by_access_list[$var][$subkey][$category]['selected_value'] != '') { if ($row['subkey'] == null) { $_setting[$row['variable']] = $settings_by_access_list[$var][$subkey][$category]['selected_value']; } else { $_setting[$row['variable']][$row['subkey']] = $settings_by_access_list[$var][$subkey][$category]['selected_value']; } } else { if ($row['subkey'] == null) { $_setting[$row['variable']] = $row['selected_value']; } else { $_setting[$row['variable']][$row['subkey']] = $row['selected_value']; } } } else { if ($row['subkey'] == null) { $_setting[$row['variable']] = $row['selected_value']; } else { $_setting[$row['variable']][$row['subkey']] = $row['selected_value']; } } } else { if ($row['subkey'] == null) { $_setting[$row['variable']] = $row['selected_value']; } else { $_setting[$row['variable']][$row['subkey']] = $row['selected_value']; } } } $result = api_get_settings('Plugins', 'list', $access_url_id); $_plugins = array(); foreach ($result as &$row) { $key =& $row['variable']; if (is_string($_setting[$key])) { $_setting[$key] = array(); } $_setting[$key][] = $row['selected_value']; $_plugins[$key][] = $row['selected_value']; } $_SESSION['_setting'] = $_setting; $_SESSION['_plugins'] = $_plugins; }
*/ // Resetting the course id. $cidReset = true; // Including some necessary chamilo files. require_once '../inc/global.inc.php'; // Setting the section (for the tabs). $this_section = SECTION_PLATFORM_ADMIN; // Access restrictions. api_protect_admin_script(true); $nameTools = get_lang('PlatformAdmin'); $accessUrlId = 0; $adminExtraContentDir = api_get_path(SYS_PATH) . "home/admin/"; if (api_is_multiple_url_enabled()) { $accessUrlId = api_get_current_access_url_id(); if ($accessUrlId != -1) { $urlInfo = api_get_access_url($accessUrlId); $url = api_remove_trailing_slash(preg_replace('/https?:\\/\\//i', '', $urlInfo['url'])); $cleanUrl = str_replace('/', '-', $url); $adminExtraContentDir = api_get_path(SYS_PATH) . "home/{$cleanUrl}/admin/"; } } // Displaying the header $message = ''; if (api_is_platform_admin()) { if (is_dir(api_get_path(SYS_ARCHIVE_PATH)) && !is_writable(api_get_path(SYS_ARCHIVE_PATH))) { $message = Display::return_message(get_lang('ArchivesDirectoryNotWriteableContactAdmin'), 'warning'); } /* ACTION HANDLING */ if (!empty($_POST['Register'])) { api_register_campus(!$_POST['donotlistcampus']); $message = Display::return_message(get_lang('VersionCheckEnabled'), 'confirmation');
/** * Return agenda items of the week */ function get_week_agendaitems($courses_dbs, $month, $year, $week = '') { global $_user; global $_configuration; global $setting_agenda_link; $TABLEAGENDA = Database::get_main_table(TABLE_MAIN_SYSTEM_CALENDAR); $items = array(); // The default value of the week if ($week == '') { $week_number = date("W", time()); } else { $week_number = $week; } $start_end = calculate_start_end_of_week($week_number, $year); $start_filter = $start_end['start']['year'] . "-" . $start_end['start']['month'] . "-" . $start_end['start']['day']; $end_filter = $start_end['end']['year'] . "-" . $start_end['end']['month'] . "-" . $start_end['end']['day']; // get agenda-items for every course foreach ($courses_dbs as $key => $array_course_info) { //databases of the courses $TABLEAGENDA = Database::get_main_table(TABLE_MAIN_SYSTEM_CALENDAR); //$TABLE_ITEMPROPERTY = Database :: get_course_table(TABLE_ITEM_PROPERTY, $array_course_info["db"]); // getting all the groups of the user for the current course // $group_memberships = GroupManager :: get_group_ids($array_course_info["db"], $_user['user_id']); // if the user is administrator of that course we show all the agenda items //if ($array_course_info['status'] == '1') //{ //echo "course admin"; $sqlquery = "SELECT DISTINCT * FROM " . $TABLEAGENDA . " ORDER BY start_date"; //} // if the user is not an administrator of that course //else //{ //echo "GEEN course admin"; /* if (is_array($group_memberships) && count($group_memberships)>0) { $sqlquery = "SELECT * FROM ".$TABLEAGENDA." ORDER BY a.start_date"; } else*/ //{ // $sqlquery = "SELECT * FROM ".$TABLEAGENDA." ORDER BY a.start_date"; //} //} //echo "<pre>".$sqlquery."</pre>"; // $sqlquery = "SELECT * FROM $agendadb WHERE (DAYOFMONTH(day)>='$start_day' AND DAYOFMONTH(day)<='$end_day') // AND (MONTH(day)>='$start_month' AND MONTH(day)<='$end_month') // AND (YEAR(day)>='$start_year' AND YEAR(day)<='$end_year')"; $result = Database::query($sqlquery); $portal_url = $_configuration['root_web']; if ($_configuration['multiple_access_urls']) { $access_url_id = api_get_current_access_url_id(); if ($access_url_id != -1) { $url = api_get_access_url($access_url_id); $portal_url = $url['url']; } } while ($item = Database::fetch_array($result)) { $agendaday_string = api_convert_and_format_date($item['start_date'], "%d", date_default_timezone_get()); $agendaday = intval($agendaday_string); $time = api_convert_and_format_date($item['start_date'], TIME_NO_SEC_FORMAT, date_default_timezone_get()); if ($setting_agenda_link == 'coursecode') { $title = $array_course_info['title']; $agenda_link = api_substr($title, 0, 14); } else { $agenda_link = Display::return_icon('course_home.gif'); } $URL = $portal_url . "main/admin/agenda.php?cidReq=" . urlencode($array_course_info["code"]) . "&day={$agendaday}&month={$month}&year={$year}#{$agendaday}"; // RH //Patrick Cool: to highlight the relevant agenda item $items[$agendaday][$item['start_time']] .= "<i>{$time}</i> <a href=\"{$URL}\" title=\"" . $array_course_info["name"] . "\">" . $agenda_link . "</a> " . $item['title'] . "<br />"; } } // sorting by hour for every day $agendaitems = array(); while (list($agendaday, $tmpitems) = each($items)) { sort($tmpitems); while (list($key, $val) = each($tmpitems)) { $agendaitems[$agendaday] .= $val; } } //print_r($agendaitems); return $agendaitems; }