/** * @Route("{version}/update") * @Method({"GET"}) */ public function upgradeAction($version) { /** @var \Knp\Console\Application $console */ $console = $this->get('console'); $console->addCommands(array(new \Doctrine\DBAL\Tools\Console\Command\RunSqlCommand(), new \Doctrine\DBAL\Tools\Console\Command\ImportCommand(), new \Doctrine\DBAL\Migrations\Tools\Console\Command\DiffCommand(), new \Doctrine\DBAL\Migrations\Tools\Console\Command\ExecuteCommand(), new \Doctrine\DBAL\Migrations\Tools\Console\Command\GenerateCommand(), new \Doctrine\DBAL\Migrations\Tools\Console\Command\MigrateCommand(), new \Doctrine\DBAL\Migrations\Tools\Console\Command\StatusCommand(), new \Doctrine\DBAL\Migrations\Tools\Console\Command\VersionCommand(), new \Chash\Command\Chash\SetupCommand(), new \Chash\Command\Database\RunSQLCommand(), new \Chash\Command\Database\DumpCommand(), new \Chash\Command\Database\RestoreCommand(), new \Chash\Command\Database\SQLCountCommand(), new \Chash\Command\Database\FullBackupCommand(), new \Chash\Command\Database\DropDatabaseCommand(), new \Chash\Command\Database\ShowConnInfoCommand(), new \Chash\Command\Files\CleanDataFilesCommand(), new \Chash\Command\Files\CleanTempFolderCommand(), new \Chash\Command\Files\CleanConfigFilesCommand(), new \Chash\Command\Files\MailConfCommand(), new \Chash\Command\Files\SetPermissionsAfterInstallCommand(), new \Chash\Command\Files\GenerateTempFileStructureCommand(), new \Chash\Command\Installation\InstallCommand(), new \Chash\Command\Installation\WipeCommand(), new \Chash\Command\Installation\StatusCommand(), new \Chash\Command\Installation\UpgradeCommand())); $helpers = array('configuration' => new \Chash\Helpers\ConfigurationHelper()); $helperSet = $console->getHelperSet(); foreach ($helpers as $name => $helper) { $helperSet->set($helper, $name); } $command = $console->get('chamilo:upgrade'); $version = '1.11.0'; $def = $command->getDefinition(); $input = new \Symfony\Component\Console\Input\ArrayInput(array('name', '--path' => $this->get('sys_root'), 'version' => $version, '--temp-folder' => $this->get('sys_temp_path'), '--migration-yml-path' => api_remove_trailing_slash($this->get('sys_temp_path')), '--migration-class-path' => $this->get('sys_root') . 'vendor/chamilo/chash/src/Chash/Migrations', '--download-package' => 'true', '--silent' => 'true'), $def); $output = new BufferedOutput(); $result = $command->run($input, $output); if ($result) { } $output = $output->getBuffer(); $template = $this->get('template'); $template->assign('output', $output); $response = $template->render_template($this->getTemplatePath() . 'upgrade.tpl'); return new Response($response, 200, array()); }
// 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'); }
/** * 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) ); //} }
/** * 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); }
$lpPathInfo = $lp->generate_lp_folder($course_info); if (empty($lpPathInfo)) { exit; } require_once api_get_path(LIBRARY_PATH) . 'fileDisplay.lib.php'; require_once api_get_path(LIBRARY_PATH) . 'document.lib.php'; require_once api_get_path(LIBRARY_PATH) . 'fileUpload.lib.php'; foreach (array('video', 'audio') as $type) { if (isset($_FILES["{$type}-blob"])) { $fileName = $_POST["{$type}-filename"]; //$file = $_FILES["${type}-blob"]["tmp_name"]; $file = $_FILES["{$type}-blob"]; $fileInfo = pathinfo($fileName); $file['name'] = 'rec_' . date('Y-m-d_His') . '_' . uniqid() . '.' . $fileInfo['extension']; $file['file'] = $file; $lpPathInfo['dir'] = api_remove_trailing_slash($lpPathInfo['dir']); $result = DocumentManager::upload_document($file, $lpPathInfo['dir'], $file['name'], null, 0, 'overwrite', false, false); if (!empty($result) && is_array($result)) { $newDocId = $result['id']; $courseId = $result['c_id']; $lp->set_modified_on(); $lpItem = new learnpathItem($_REQUEST['lp_item_id']); $lpItem->add_audio_from_documents($newDocId); $data = DocumentManager::get_document_data_by_id($newDocId, $course_info['code']); echo $data['document_url']; exit; } } } break; default:
$page .= '<div id="lp_sidebar" class="col-md-4">'; $page .= $_SESSION['oLP']->return_new_tree(null, true); // Show the template list. $page .= '</div>'; $recordVoiceForm = Display::page_subheader(get_lang('RecordYourVoice')); $page .= '<div id="doc_form" class="col-md-8">'; $tpl = new Template(null); $tpl->assign('unique_file_id', api_get_unique_id()); $tpl->assign('course_code', api_get_course_id()); $tpl->assign('php_session_id', session_id()); $tpl->assign('filename', $lp_item->get_title() . '_nano.wav'); $tpl->assign('enable_nanogong', api_get_setting('enable_nanogong') == 'true' ? 1 : 0); $tpl->assign('enable_wami', api_get_setting('enable_wami_record') == 'true' ? 1 : 0); $tpl->assign('cur_dir_path', '/audio'); $tpl->assign('lp_item_id', $lp_item_id); $tpl->assign('lp_dir', api_remove_trailing_slash($lpPathInfo['dir'])); $recordVoiceForm .= $tpl->fetch('default/learnpath/record_voice.tpl'); $form->addElement('header', get_lang('Or')); $form->addElement('header', get_lang('AudioFile')); $form->addElement('html', sprintf(get_lang('AudioFileForItemX'), $lp_item->get_title())); if (!empty($file)) { $audioPlayer = '<div id="preview">' . Display::getMediaPlayer($file, array('url' => $urlFile)) . "</div>"; $form->addElement('label', get_lang('Listen'), $audioPlayer); $url = api_get_path(WEB_CODE_PATH) . 'newscorm/lp_controller.php?lp_id=' . $_SESSION['oLP']->get_id() . '&action=add_audio&id=' . $lp_item_id . '&delete_file=1&' . api_get_cidreq(); $form->addElement('label', null, Display::url(get_lang('RemoveAudio'), $url, array('class' => 'btn btn-danger'))); } else { $form->addElement('file', 'file'); $form->addElement('hidden', 'id', $lp_item_id); $form->addButtonSave(get_lang('Save')); } $form->addElement('header', get_lang('Or'));
/** * Get home path * @return string */ function api_get_home_path() { $home = 'app/home/'; 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 .= '/'; $home = 'app/home/' . $clean_url; } return $home; }
// This is the main configuration file of the system before the upgrade. // Old configuration file. // Don't change to include_once $oldConfigPath = api_get_path(SYS_CODE_PATH) . 'inc/conf/configuration.php'; if (file_exists($oldConfigPath)) { include $oldConfigPath; } } if (!isset($_GET['running'])) { $dbHostForm = 'localhost'; $dbUsernameForm = 'root'; $dbPassForm = ''; $dbNameForm = 'chamilo'; $dbPortForm = 3306; // Extract the path to append to the url if Chamilo is not installed on the web root directory. $urlAppendPath = api_remove_trailing_slash(api_get_path(REL_PATH)); $urlForm = api_get_path(WEB_PATH); $pathForm = api_get_path(SYS_PATH); $emailForm = 'webmaster@localhost'; if (!empty($_SERVER['SERVER_ADMIN'])) { $emailForm = $_SERVER['SERVER_ADMIN']; } $email_parts = explode('@', $emailForm); if (isset($email_parts[1]) && $email_parts[1] == 'localhost') { $emailForm .= '.localdomain'; } $adminLastName = get_lang('DefaultInstallAdminLastname'); $adminFirstName = get_lang('DefaultInstallAdminFirstname'); $loginForm = 'admin'; $passForm = api_generate_password(); $campusForm = 'My campus';
/** * 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 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; }
function api_get_home_path() { return null; $home = 'home/'; $access_url_id = api_get_current_access_url_id(); if (api_get_multiple_access_url() && $access_url_id != -1) { $url_info = api_get_current_access_url_info(); $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/" means that the multiple URL was not well configured we don't rename the $home variable if ($clean_url != 'localhost/') { //$home = 'home/'.$clean_url; } $home = 'home/' . $clean_url; } return $home; }
$page .= '<div id="lp_sidebar" class="col-md-4">'; $page .= $learnPath->return_new_tree(null, true); // Show the template list. $page .= '</div>'; $recordVoiceForm = Display::page_subheader(get_lang('RecordYourVoice')); $page .= '<div id="doc_form" class="col-md-8">'; $tpl = \Chamilo\CoreBundle\Framework\Container::getTwig(); $tpl->addGlobal('unique_file_id', api_get_unique_id()); $tpl->addGlobal('course_code', api_get_course_id()); $tpl->addGlobal('php_session_id', session_id()); $tpl->addGlobal('filename', $lp_item->get_title() . '_nano.wav'); $tpl->addGlobal('enable_nanogong', api_get_setting('document.enable_nanogong') == 'true' ? 1 : 0); $tpl->addGlobal('enable_wami', api_get_setting('document.enable_wami_record') == 'true' ? 1 : 0); $tpl->addGlobal('cur_dir_path', '/audio'); $tpl->addGlobal('lp_item_id', $lp_item_id); $tpl->addGlobal('lp_dir', api_remove_trailing_slash($lpPathInfo['dir'])); $recordVoiceForm .= $tpl->render('@template_style/learnpath/record_voice.html.twig'); $form->addElement('header', get_lang('Or')); $form->addElement('header', get_lang('AudioFile')); $form->addElement('html', sprintf(get_lang('AudioFileForItemX'), $lp_item->get_title())); if (!empty($file)) { $audioPlayer = '<div id="preview">' . Display::getMediaPlayer($file, array('url' => $urlFile)) . "</div>"; $form->addElement('label', get_lang('Listen'), $audioPlayer); $url = api_get_path(WEB_CODE_PATH) . 'newscorm/lp_controller.php?lp_id=' . $learnPath->get_id() . '&action=add_audio&id=' . $lp_item_id . '&delete_file=1&' . api_get_cidreq(); $form->addElement('label', null, Display::url(get_lang('RemoveAudio'), $url, array('class' => 'btn btn-danger'))); } else { $form->addElement('file', 'file'); $form->addElement('hidden', 'id', $lp_item_id); $form->addButtonSave(get_lang('Save')); } $form->addElement('header', get_lang('Or'));
/** * @param array $course * @param string $lp_name * @param int $creatorId * * @return array */ public function generate_lp_folder($course, $lp_name = '', $creatorId = 0) { $filepath = ''; $dir = '/learning_path/'; if (empty($lp_name)) { $lp_name = $this->name; } $creatorId = empty($creatorId) ? api_get_user_id() : $creatorId; $folder = self::generate_learning_path_folder($course, $creatorId); // Limits title size $title = api_substr(api_replace_dangerous_char($lp_name), 0, 80); $dir = $dir . $title; // Creating LP folder $documentId = null; if ($folder) { $filepath = api_get_path(SYS_COURSE_PATH) . $course['path'] . '/document'; if (!is_dir($filepath . '/' . $dir)) { $folderData = create_unexisting_directory($course, $creatorId, 0, 0, 0, $filepath, $dir, $lp_name); if (!empty($folderData)) { $folder = true; } $documentId = $folderData['id']; } else { $folder = true; } $dir = $dir . '/'; if ($folder) { $filepath = api_get_path(SYS_COURSE_PATH) . $course['path'] . '/document' . $dir; } } if (empty($documentId)) { $dir = api_remove_trailing_slash($dir); $documentId = DocumentManager::get_document_id($course, $dir, 0); } $array = array('dir' => $dir, 'filepath' => $filepath, 'folder' => $folder, 'id' => $documentId); return $array; }
/** * @return null|string */ public function returnMenu() { return null; $navigation = $this->navigation_array; $navigation = $navigation['navigation']; // Displaying the tabs $lang = api_get_user_language(); // 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_current_access_url_info(); $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 = $this->app['path.data'] . '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 = $this->app['path.data'] . 'home/'; } $ext = '.html'; $menutabs = 'home_tabs'; $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); } $home_top = api_to_system_encoding($home_top, api_detect_encoding(strip_tags($home_top))); $open = str_replace('{rel_path}', $this->app['path.data'], $home_top); $open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open))); $lis = ''; if (!empty($open)) { if (strpos($open, 'show_menu') === false) { if (api_is_anonymous()) { $navigation[SECTION_CAMPUS] = null; } } else { $lis .= $open; } } if (count($navigation) > 0 || !empty($lis)) { $pre_lis = ''; foreach ($navigation as $section => $navigation_info) { if (isset($GLOBALS['this_section'])) { $current = $section == $GLOBALS['this_section'] ? ' id="current" class="active" ' : ''; } 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; }