index.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. // Check function indexAction in:
  4. // src/Chamilo/CoreBundle/Controller/Admin/AdminController.php
  5. //
  6. exit;
  7. use Chamilo\CoreBundle\Framework\Container;
  8. /**
  9. * Index page of the admin tools
  10. * @package chamilo.admin
  11. */
  12. // Resetting the course id.
  13. $cidReset = true;
  14. // Setting the section (for the tabs).
  15. $this_section = SECTION_PLATFORM_ADMIN;
  16. // Access restrictions.
  17. api_protect_admin_script(true);
  18. $nameTools = get_lang('PlatformAdmin');
  19. $accessUrlId = 0;
  20. $adminExtraContentDir = api_get_path(SYS_APP_PATH) . "home/admin/";
  21. if (api_is_multiple_url_enabled()) {
  22. $accessUrlId = api_get_current_access_url_id();
  23. if ($accessUrlId != -1) {
  24. $urlInfo = api_get_access_url($accessUrlId);
  25. $url = api_remove_trailing_slash(preg_replace('/https?:\/\//i', '', $urlInfo['url']));
  26. $cleanUrl = str_replace('/', '-', $url);
  27. $adminExtraContentDir = api_get_path(SYS_APP_PATH) . "home/$cleanUrl/admin/";
  28. }
  29. }
  30. // Displaying the header
  31. $message = '';
  32. if (api_is_platform_admin()) {
  33. if (is_dir(api_get_path(SYS_ARCHIVE_PATH)) &&
  34. !is_writable(api_get_path(SYS_ARCHIVE_PATH))
  35. ) {
  36. $message = Display::return_message(get_lang('ArchivesDirectoryNotWriteableContactAdmin'), 'warning');
  37. }
  38. /* ACTION HANDLING */
  39. if (!empty($_POST['Register'])) {
  40. api_register_campus(!$_POST['donotlistcampus']);
  41. $message = Display :: return_message(get_lang('VersionCheckEnabled'), 'confirmation');
  42. }
  43. $keyword_url = Security::remove_XSS((empty($_GET['keyword']) ? '' : $_GET['keyword']));
  44. }
  45. if (isset($_GET['msg']) && isset($_GET['type'])) {
  46. if (in_array($_GET['msg'], array('ArchiveDirCleanupSucceeded', 'ArchiveDirCleanupFailed'))) {
  47. switch ($_GET['type']) {
  48. case 'error':
  49. $message = Display::return_message(get_lang($_GET['msg']), 'error');
  50. break;
  51. case 'confirmation':
  52. $message = Display::return_message(get_lang($_GET['msg']), 'confirm');
  53. }
  54. }
  55. }
  56. $blocks = array();
  57. // Instantiate Hook Event for Admin Block
  58. $hook = HookAdminBlock::create();
  59. if (!empty($hook)) {
  60. // If not empty, then notify Pre process to Hook Observers for Admin Block
  61. $hook->setEventData(array('blocks' => $blocks));
  62. $data = $hook->notifyAdminBlock(HOOK_EVENT_TYPE_PRE);
  63. // Check if blocks data is not null
  64. if (isset($data['blocks'])) {
  65. // Get modified blocks
  66. $blocks = $data['blocks'];
  67. }
  68. }
  69. /* Users */
  70. $blocks['users']['icon'] = Display::return_icon('members.gif', get_lang('Users'), array(), ICON_SIZE_MEDIUM, false);
  71. $blocks['users']['label'] = api_ucfirst(get_lang('Users'));
  72. $blocks['users']['class'] = 'block-admin-users';
  73. $usersBlockExtraFile = "{$adminExtraContentDir}block-admin-users_extra.html";
  74. if (file_exists($usersBlockExtraFile)) {
  75. $blocks['users']['extraContent'] = file_get_contents($usersBlockExtraFile);
  76. }
  77. if (api_is_platform_admin()) {
  78. $blocks['users']['editable'] = true;
  79. $search_form = '
  80. <form method="get" class="form-inline" action="user_list.php">
  81. <div class="form-group">
  82. <input class="form-control" type="text" name="keyword" value="">
  83. <button class="btn btn-default" type="submit">
  84. <em class="fa fa-search"></em> ' . get_lang('Search') . '
  85. </button>
  86. </div>
  87. </form>';
  88. $blocks['users']['search_form'] = $search_form;
  89. $items = array(
  90. array('url' => 'user_list.php', 'label' => get_lang('UserList')),
  91. array('url' => 'user_add.php', 'label' => get_lang('AddUsers')),
  92. array('url' => 'user_export.php', 'label' => get_lang('ExportUserListXMLCSV')),
  93. array('url' => 'user_import.php', 'label' => get_lang('ImportUserListXMLCSV')),
  94. array('url' => 'user_update_import.php', 'label' => get_lang('EditUserListCSV')),
  95. );
  96. if (isset($extAuthSource) && isset($extAuthSource['extldap']) && count($extAuthSource['extldap']) > 0) {
  97. $items[] = array('url' => 'ldap_users_list.php', 'label' => get_lang('ImportLDAPUsersIntoPlatform'));
  98. }
  99. $items[] = array('url' => 'extra_fields.php?type=user', 'label' => get_lang('ManageUserFields'));
  100. } else {
  101. $items = array(
  102. array('url' => 'user_list.php', 'label' => get_lang('UserList')),
  103. array('url' => 'user_add.php', 'label' => get_lang('AddUsers')),
  104. array('url' => 'user_import.php', 'label' => get_lang('ImportUserListXMLCSV')),
  105. );
  106. }
  107. $items[] = array('url' => 'usergroups.php', 'label' => get_lang('Classes'));
  108. $blocks['users']['items'] = $items;
  109. $blocks['users']['extra'] = null;
  110. if (api_is_platform_admin()) {
  111. /* Courses */
  112. $blocks['courses']['icon'] = Display::return_icon(
  113. 'course.png',
  114. get_lang('Courses'),
  115. array(),
  116. ICON_SIZE_MEDIUM,
  117. false
  118. );
  119. $blocks['courses']['label'] = api_ucfirst(get_lang('Courses'));
  120. $blocks['courses']['class'] = 'block-admin-courses';
  121. $blocks['courses']['editable'] = true;
  122. $coursesBlockExtraFile = "{$adminExtraContentDir}block-admin-courses_extra.html";
  123. if (file_exists($coursesBlockExtraFile)) {
  124. $blocks['courses']['extraContent'] = file_get_contents($coursesBlockExtraFile);
  125. }
  126. $search_form = ' <form method="get" class="form-inline" action="course_list.php">
  127. <div class="form-group">
  128. <input class="form-control" type="text" name="keyword" value="">
  129. <button class="btn btn-default" type="submit">
  130. <em class="fa fa-search"></em> ' . get_lang('Search') . '
  131. </button>
  132. </div>
  133. </form>';
  134. $blocks['courses']['search_form'] = $search_form;
  135. $items = array();
  136. $items[] = array('url' => 'course_list.php', 'label' => get_lang('CourseList'));
  137. $items[] = array('url' => 'course_add.php', 'label' => get_lang('AddCourse'));
  138. if (api_get_setting('course.course_validation') == 'true') {
  139. $items[] = array('url' => 'course_request_review.php', 'label' => get_lang('ReviewCourseRequests'));
  140. $items[] = array('url' => 'course_request_accepted.php', 'label' => get_lang('AcceptedCourseRequests'));
  141. $items[] = array('url' => 'course_request_rejected.php', 'label' => get_lang('RejectedCourseRequests'));
  142. }
  143. $items[] = array('url' => 'course_export.php', 'label' => get_lang('ExportCourses'));
  144. $items[] = array('url' => 'course_import.php', 'label' => get_lang('ImportCourses'));
  145. $items[] = array('url' => 'course_category.php', 'label' => get_lang('AdminCategories'));
  146. $items[] = array('url' => 'subscribe_user2course.php', 'label' => get_lang('AddUsersToACourse'));
  147. $items[] = array('url' => 'course_user_import.php', 'label' => get_lang('ImportUsersToACourse'));
  148. //$items[] = array('url'=>'course_intro_pdf_import.php', 'label' => get_lang('ImportPDFIntroToCourses'));
  149. if (api_get_setting('gradebook.gradebook_enable_grade_model') == 'true') {
  150. $items[] = array('url' => 'grade_models.php', 'label' => get_lang('GradeModel'));
  151. }
  152. if (isset($extAuthSource) && isset($extAuthSource['ldap']) && count($extAuthSource['ldap']) > 0) {
  153. $items[] = array('url' => 'ldap_import_students.php', 'label' => get_lang('ImportLDAPUsersIntoCourse'));
  154. }
  155. $items[] = array('url' => 'extra_fields.php?type=course', 'label' => get_lang('ManageCourseFields'));
  156. $blocks['courses']['items'] = $items;
  157. $blocks['courses']['extra'] = null;
  158. /* Platform */
  159. $blocks['platform']['icon'] = Display::return_icon(
  160. 'platform.png',
  161. get_lang('Platform'),
  162. array(),
  163. ICON_SIZE_MEDIUM,
  164. false
  165. );
  166. $blocks['platform']['label'] = api_ucfirst(get_lang('Platform'));
  167. $blocks['platform']['class'] = 'block-admin-platform';
  168. $blocks['platform']['editable'] = true;
  169. $platformBlockExtraFile = "{$adminExtraContentDir}block-admin-platform_extra.html";
  170. if (file_exists($platformBlockExtraFile)) {
  171. $blocks['platform']['extraContent'] = file_get_contents($platformBlockExtraFile);
  172. }
  173. $search_form = ' <form method="get" action="settings.php" class="form-inline">
  174. <div class="form-group">
  175. <input class="form-control" type="text" name="search_field" value="" >
  176. <input type="hidden" value="search_setting" name="category">
  177. <button class="btn btn-default" type="submit">
  178. <em class="fa fa-search"></em> ' . get_lang('Search') . '
  179. </button>
  180. </div>
  181. </form>';
  182. $blocks['platform']['search_form'] = $search_form;
  183. $items = array();
  184. $items[] = array('url' => 'settings.php', 'label' => get_lang('PlatformConfigSettings'));
  185. $items[] = array('url' => 'languages.php', 'label' => get_lang('Languages'));
  186. $items[] = array('url' => 'settings.php?category=Plugins', 'label' => get_lang('Plugins'));
  187. $items[] = array('url' => 'settings.php?category=Regions', 'label' => get_lang('Regions'));
  188. $items[] = array('url' => 'system_announcements.php', 'label' => get_lang('SystemAnnouncements'));
  189. $items[] = array(
  190. 'url' => api_get_path(WEB_CODE_PATH) . 'calendar/agenda_js.php?type=admin',
  191. 'label' => get_lang('GlobalAgenda')
  192. );
  193. $items[] = array('url' => 'configure_homepage.php', 'label' => get_lang('ConfigureHomePage'));
  194. $items[] = array('url' => 'configure_inscription.php', 'label' => get_lang('ConfigureInscription'));
  195. $items[] = array('url' => 'statistics/index.php', 'label' => get_lang('Statistics'));
  196. $items[] = array(
  197. 'url' => api_get_path(WEB_CODE_PATH) . 'mySpace/company_reports.php',
  198. 'label' => get_lang('Reports')
  199. );
  200. $items[] = array(
  201. 'url' => api_get_path(WEB_CODE_PATH) . 'admin/teacher_time_report.php',
  202. 'label' => get_lang('TeacherTimeReport')
  203. );
  204. /* Event settings */
  205. if (api_get_setting('mail.activate_email_template') == 'true') {
  206. $items[] = array('url' => 'event_controller.php?action=listing', 'label' => get_lang('EventMessageManagement'));
  207. }
  208. if (!empty($_configuration['multiple_access_urls'])) {
  209. if (api_is_global_platform_admin()) {
  210. $items[] = array('url' => 'access_urls.php', 'label' => get_lang('ConfigureMultipleAccessURLs'));
  211. }
  212. }
  213. if (api_get_setting('registration.allow_terms_conditions') == 'true') {
  214. $items[] = array('url' => 'legal_add.php', 'label' => get_lang('TermsAndConditions'));
  215. }
  216. $blocks['platform']['items'] = $items;
  217. $blocks['platform']['extra'] = null;
  218. }
  219. /* Sessions */
  220. $blocks['sessions']['icon'] = Display::return_icon(
  221. 'session.png',
  222. get_lang('Sessions'),
  223. array(),
  224. ICON_SIZE_MEDIUM,
  225. false
  226. );
  227. $blocks['sessions']['label'] = api_ucfirst(get_lang('Sessions'));
  228. $blocks['sessions']['class'] = 'block-admin-sessions';
  229. $sessionsBlockExtraFile = "{$adminExtraContentDir}block-admin-sessions_extra.html";
  230. if (file_exists($sessionsBlockExtraFile)) {
  231. $blocks['sessions']['extraContent'] = file_get_contents($sessionsBlockExtraFile);
  232. }
  233. if (api_is_platform_admin()) {
  234. $blocks['sessions']['editable'] = true;
  235. }
  236. $sessionPath = api_get_path(WEB_CODE_PATH).'session/';
  237. $search_form = ' <form method="GET" class="form-inline" action="'.$sessionPath.'session_list.php">
  238. <div class="form-group">
  239. <input class="form-control" type="text" name="keyword" value="">
  240. <button class="btn btn-default" type="submit">
  241. <em class="fa fa-search"></em> ' . get_lang('Search') . '
  242. </button>
  243. </div>
  244. </form>';
  245. $blocks['sessions']['search_form'] = $search_form;
  246. $items = array();
  247. $items[] = array('url' => $sessionPath.'session_list.php', 'label' => get_lang('ListSession'));
  248. $items[] = array('url' => $sessionPath.'session_add.php', 'label' => get_lang('AddSession'));
  249. $items[] = array('url' => $sessionPath.'session_category_list.php', 'label' => get_lang('ListSessionCategory'));
  250. $items[] = array('url' => $sessionPath.'session_import.php', 'label' => get_lang('ImportSessionListXMLCSV'));
  251. $items[] = array('url' => $sessionPath.'session_import_drh.php', 'label' => get_lang('ImportSessionDrhList'));
  252. if (isset($extAuthSource) && isset($extAuthSource['ldap']) && count($extAuthSource['ldap']) > 0) {
  253. $items[] = array(
  254. 'url' => 'ldap_import_students_to_session.php',
  255. 'label' => get_lang('ImportLDAPUsersIntoSession')
  256. );
  257. }
  258. $items[] = array(
  259. 'url' => $sessionPath.'session_export.php',
  260. 'label' => get_lang('ExportSessionListXMLCSV'),
  261. );
  262. $items[] = array(
  263. 'url' => '../coursecopy/copy_course_session.php',
  264. 'label' => get_lang('CopyFromCourseInSessionToAnotherSession')
  265. );
  266. if (api_is_platform_admin()) {
  267. // option only visible in development mode. Enable through code if required
  268. if (is_dir(api_get_path(SYS_TEST_PATH) . 'datafiller/')) {
  269. $items[] = array('url' => 'user_move_stats.php', 'label' => get_lang('MoveUserStats'));
  270. }
  271. $items[] = array('url' => 'career_dashboard.php', 'label' => get_lang('CareersAndPromotions'));
  272. $items[] = array('url' => 'extra_fields.php?type=session', 'label' => get_lang('ManageSessionFields'));
  273. }
  274. $blocks['sessions']['items'] = $items;
  275. $blocks['sessions']['extra'] = null;
  276. /* Settings */
  277. if (api_is_platform_admin()) {
  278. $blocks['settings']['icon'] = Display::return_icon(
  279. 'settings.png',
  280. get_lang('System'),
  281. array(),
  282. ICON_SIZE_MEDIUM,
  283. false
  284. );
  285. $blocks['settings']['label'] = api_ucfirst(get_lang('System'));
  286. $blocks['settings']['class'] = 'block-admin-settings';
  287. $items = array();
  288. $items[] = array('url' => 'special_exports.php', 'label' => get_lang('SpecialExports'));
  289. $items[] = array('url' => 'system_status.php', 'label' => get_lang('SystemStatus'));
  290. if (is_dir(api_get_path(SYS_TEST_PATH) . 'datafiller/')) {
  291. $items[] = array('url' => 'filler.php', 'label' => get_lang('DataFiller'));
  292. }
  293. $items[] = array('url' => 'archive_cleanup.php', 'label' => get_lang('ArchiveDirCleanup'));
  294. $items[] = array('url' => 'resource_sequence.php', 'label' => get_lang('ResourcesSequencing'));
  295. if (isset($_configuration['db_manager_enabled']) &&
  296. $_configuration['db_manager_enabled'] == true &&
  297. api_is_global_platform_admin()
  298. ) {
  299. $host = $_configuration['db_host'];
  300. $username = $_configuration['db_user'];
  301. $databaseName = $_configuration['main_database'];
  302. $items[] = array(
  303. 'url' => "db.php?username=$username&db=$databaseName&server=$host",
  304. 'label' => get_lang('DatabaseManager')
  305. );
  306. }
  307. $blocks['settings']['items'] = $items;
  308. $blocks['settings']['extra'] = null;
  309. $blocks['settings']['search_form'] = null;
  310. // Skills
  311. if (api_get_setting('skill.allow_skills_tool') == 'true') {
  312. $blocks['skills']['icon'] = Display::return_icon(
  313. 'skill-badges.png',
  314. get_lang('Skills'),
  315. array(),
  316. ICON_SIZE_MEDIUM,
  317. false
  318. );
  319. $blocks['skills']['label'] = get_lang('Skills');
  320. $blocks['skills']['class'] = 'block-admin-skills';
  321. $items = array();
  322. //$items[] = array('url'=>'skills.php', 'label' => get_lang('SkillsTree'));
  323. $items[] = array('url' => 'skills_wheel.php', 'label' => get_lang('SkillsWheel'));
  324. $items[] = array('url' => 'skills_import.php', 'label' => get_lang('SkillsImport'));
  325. $items[] = array('url' => 'skill_list.php', 'label' => get_lang('ManageSkills'));
  326. //$items[] = array('url'=>'skills_profile.php', 'label' => get_lang('SkillsProfile'));
  327. $items[] = array(
  328. 'url' => api_get_path(WEB_CODE_PATH) . 'social/skills_ranking.php',
  329. 'label' => get_lang('SkillsRanking')
  330. );
  331. $items[] = array('url' => 'skills_gradebook.php', 'label' => get_lang('SkillsAndGradebooks'));
  332. $items[] = array(
  333. 'url' => api_get_path(WEB_CODE_PATH) . 'admin/skill_badge.php',
  334. 'label' => get_lang('Badges')
  335. );
  336. $blocks['skills']['items'] = $items;
  337. $blocks['skills']['extra'] = null;
  338. $blocks['skills']['search_form'] = null;
  339. }
  340. /* Plugins */
  341. global $_plugins;
  342. if (count($_plugins['menu_administrator']) > 0) {
  343. $blocks['plugins']['icon'] = Display::return_icon(
  344. 'plugins.png',
  345. get_lang('Plugins'),
  346. array(),
  347. ICON_SIZE_MEDIUM,
  348. false
  349. );
  350. $blocks['plugins']['label'] = api_ucfirst(get_lang('Plugins'));
  351. $blocks['plugins']['class'] = 'block-admin-platform';
  352. $blocks['plugins']['editable'] = true;
  353. $plugin_obj = new AppPlugin();
  354. $items = array();
  355. foreach ($_plugins['menu_administrator'] as $plugin_name) {
  356. $plugin_info = $plugin_obj->getPluginInfo($plugin_name);
  357. $items[] = array(
  358. 'url' => api_get_path(WEB_CODE_PATH) . '../plugin/'.$plugin_name.'/start.php',
  359. 'label' => $plugin_info['title']
  360. );
  361. }
  362. $blocks['plugins']['items'] = $items;
  363. $blocks['plugins']['extra'] = null;
  364. }
  365. /* Chamilo.org */
  366. $blocks['chamilo']['icon'] = Display::return_icon('logo.png', 'Chamilo.org', array(), ICON_SIZE_MEDIUM, false);
  367. $blocks['chamilo']['label'] = 'Chamilo.org';
  368. $blocks['chamilo']['class'] = 'block-admin-chamilo';
  369. $items = array();
  370. $items[] = array('url' => 'http://www.chamilo.org/', 'label' => get_lang('ChamiloHomepage'));
  371. $items[] = array('url' => 'http://www.chamilo.org/forum', 'label' => get_lang('ChamiloForum'));
  372. $items[] = array('url' => '../../documentation/installation_guide.html', 'label' => get_lang('InstallationGuide'));
  373. $items[] = array('url' => '../../documentation/changelog.html', 'label' => get_lang('ChangesInLastVersion'));
  374. $items[] = array('url' => '../../documentation/credits.html', 'label' => get_lang('ContributorsList'));
  375. $items[] = array('url' => '../../documentation/security.html', 'label' => get_lang('SecurityGuide'));
  376. $items[] = array('url' => '../../documentation/optimization.html', 'label' => get_lang('OptimizationGuide'));
  377. $items[] = array('url' => 'http://www.chamilo.org/extensions', 'label' => get_lang('ChamiloExtensions'));
  378. $items[] = array(
  379. 'url' => 'http://www.chamilo.org/en/providers',
  380. 'label' => get_lang('ChamiloOfficialServicesProviders')
  381. );
  382. $blocks['chamilo']['items'] = $items;
  383. $blocks['chamilo']['extra'] = null;
  384. $blocks['chamilo']['search_form'] = null;
  385. // Version check
  386. $blocks['version_check']['icon'] = Display::return_icon('logo.png', 'Chamilo.org', array(), ICON_SIZE_MEDIUM, false);
  387. $blocks['version_check']['label'] = get_lang('VersionCheck');
  388. $blocks['version_check']['extra'] = '<div class="admin-block-version"></div>';
  389. $blocks['version_check']['search_form'] = null;
  390. $blocks['version_check']['items'] = null;
  391. $blocks['version_check']['class'] = 'block-admin-version_check';
  392. // Check Hook Event for Admin Block Object
  393. if (!empty($hook)) {
  394. // If not empty, then notify Post process to Hook Observers for Admin Block
  395. $hook->setEventData(array('blocks' => $blocks));
  396. $data = $hook->notifyAdminBlock(HOOK_EVENT_TYPE_POST);
  397. // Check if blocks data is not null
  398. if (isset($data['blocks'])) {
  399. // Get modified blocks
  400. $blocks = $data['blocks'];
  401. }
  402. }
  403. }
  404. $admin_ajax_url = api_get_path(WEB_AJAX_PATH) . 'admin.ajax.php';
  405. $tpl = Container::getTwig();
  406. // Display the Site Use Cookie Warning Validation
  407. $useCookieValidation = api_get_setting('platform.cookie_warning');
  408. if ($useCookieValidation === 'true') {
  409. if (isset($_POST['acceptCookies'])) {
  410. api_set_site_use_cookie_warning_cookie();
  411. } else if (!api_site_use_cookie_warning_cookie_exist()) {
  412. if (Template::isToolBarDisplayedForUser()) {
  413. $tpl->addGlobal('toolBarDisplayed', true);
  414. } else {
  415. $tpl->addGlobal('toolBarDisplayed', false);
  416. }
  417. $tpl->addGlobal('displayCookieUsageWarning', true);
  418. }
  419. }
  420. $tpl->addGlobal('web_admin_ajax_url', $admin_ajax_url);
  421. $tpl->addGlobal('blocks', $blocks);
  422. if (api_is_platform_admin()) {
  423. $extraContentForm = new FormValidator(
  424. 'block_extra_data',
  425. 'post',
  426. '#',
  427. null,
  428. array(
  429. 'id' => 'block-extra-data',
  430. 'class' => ''
  431. ),
  432. FormValidator::LAYOUT_BOX_NO_LABEL
  433. );
  434. $extraContentFormRenderer = $extraContentForm->getDefaultRenderer();
  435. if ($extraContentForm->validate()) {
  436. $extraData = $extraContentForm->getSubmitValues();
  437. $extraData = array_map(['Security', 'remove_XSS'], $extraData);
  438. if (!empty($extraData['block'])) {
  439. if (!is_dir($adminExtraContentDir)) {
  440. mkdir(
  441. $adminExtraContentDir,
  442. api_get_permissions_for_new_directories(),
  443. true
  444. );
  445. }
  446. if (!is_writable($adminExtraContentDir)) {
  447. die;
  448. }
  449. $fullFilePath = $adminExtraContentDir . $extraData['block'];
  450. $fullFilePath .= "_extra.html";
  451. file_put_contents($fullFilePath, $extraData['extra_content']);
  452. header('Location: '.api_get_self());
  453. exit;
  454. }
  455. }
  456. $extraContentForm->addTextarea(
  457. 'extra_content',
  458. null,
  459. ['id' => 'extra_content']
  460. );
  461. $extraContentFormRenderer->setElementTemplate(
  462. '<div class="form-group">{element}</div>',
  463. 'extra_content'
  464. );
  465. $extraContentForm->addElement(
  466. 'hidden',
  467. 'block',
  468. null,
  469. array(
  470. 'id' => 'extra-block'
  471. )
  472. );
  473. $extraContentForm->addButtonExport(
  474. get_lang('Save'),
  475. 'submit_extra_content'
  476. );
  477. $tpl->addGlobal('extraDataForm', $extraContentForm->returnForm());
  478. }
  479. // The template contains the call to the AJAX version checker
  480. //$admin_template = $tpl->get_template('admin/settings_index.tpl');
  481. echo $tpl->render('ChamiloCoreBundle:default/admin/settings_index.tpl');