index.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Index page of the admin tools
  5. * @package chamilo.admin
  6. */
  7. // Resetting the course id.
  8. $cidReset = true;
  9. // Including some necessary chamilo files.
  10. require_once __DIR__.'/../inc/global.inc.php';
  11. // Setting the section (for the tabs).
  12. $this_section = SECTION_PLATFORM_ADMIN;
  13. // Access restrictions.
  14. api_protect_admin_script(true);
  15. $nameTools = get_lang('PlatformAdmin');
  16. $accessUrlId = 0;
  17. $adminExtraContentDir = api_get_path(SYS_APP_PATH)."home/admin/";
  18. if (api_is_multiple_url_enabled()) {
  19. $accessUrlId = api_get_current_access_url_id();
  20. if ($accessUrlId != -1) {
  21. $urlInfo = api_get_access_url($accessUrlId);
  22. $url = api_remove_trailing_slash(preg_replace('/https?:\/\//i', '', $urlInfo['url']));
  23. $cleanUrl = str_replace('/', '-', $url);
  24. $adminExtraContentDir = api_get_path(SYS_APP_PATH)."home/$cleanUrl/admin/";
  25. }
  26. }
  27. // Displaying the header
  28. if (api_is_platform_admin()) {
  29. if (is_dir(api_get_path(SYS_ARCHIVE_PATH)) &&
  30. !is_writable(api_get_path(SYS_ARCHIVE_PATH))
  31. ) {
  32. Display::addFlash(
  33. Display::return_message(get_lang('ArchivesDirectoryNotWriteableContactAdmin'), 'warning')
  34. );
  35. }
  36. /* ACTION HANDLING */
  37. if (!empty($_POST['Register'])) {
  38. api_register_campus(!$_POST['donotlistcampus']);
  39. $message = Display :: return_message(get_lang('VersionCheckEnabled'), 'confirmation');
  40. Display::addFlash($message);
  41. }
  42. $keyword_url = Security::remove_XSS((empty($_GET['keyword']) ? '' : $_GET['keyword']));
  43. }
  44. $blocks = array();
  45. // Instantiate Hook Event for Admin Block
  46. $hook = HookAdminBlock::create();
  47. if (!empty($hook)) {
  48. // If not empty, then notify Pre process to Hook Observers for Admin Block
  49. $hook->setEventData(array('blocks' => $blocks));
  50. $data = $hook->notifyAdminBlock(HOOK_EVENT_TYPE_PRE);
  51. // Check if blocks data is not null
  52. if (isset($data['blocks'])) {
  53. // Get modified blocks
  54. $blocks = $data['blocks'];
  55. }
  56. }
  57. /* Users */
  58. $blocks['users']['icon'] = Display::return_icon('members.png', get_lang('Users'), array(), ICON_SIZE_MEDIUM, false);
  59. $blocks['users']['label'] = api_ucfirst(get_lang('Users'));
  60. $blocks['users']['class'] = 'block-admin-users';
  61. $usersBlockExtraFile = "{$adminExtraContentDir}block-admin-users_extra.html";
  62. if (file_exists($usersBlockExtraFile)) {
  63. $blocks['users']['extraContent'] = file_get_contents($usersBlockExtraFile);
  64. }
  65. if (api_is_platform_admin()) {
  66. $blocks['users']['editable'] = true;
  67. $search_form = '
  68. <form method="get" class="form-inline" action="user_list.php">
  69. <div class="form-group">
  70. <input class="form-control" type="text" name="keyword" value="">
  71. <button class="btn btn-default" type="submit">
  72. <em class="fa fa-search"></em> ' . get_lang('Search').'
  73. </button>
  74. </div>
  75. </form>';
  76. $blocks['users']['search_form'] = $search_form;
  77. $items = array(
  78. array('url' => 'user_list.php', 'label' => get_lang('UserList')),
  79. array('url' => 'user_add.php', 'label' => get_lang('AddUsers')),
  80. array('url' => 'user_export.php', 'label' => get_lang('ExportUserListXMLCSV')),
  81. array('url' => 'user_import.php', 'label' => get_lang('ImportUserListXMLCSV')),
  82. array('url' => 'user_update_import.php', 'label' => get_lang('EditUserListCSV')),
  83. );
  84. if (isset($extAuthSource) && isset($extAuthSource['extldap']) && count($extAuthSource['extldap']) > 0) {
  85. $items[] = array('url' => 'ldap_users_list.php', 'label' => get_lang('ImportLDAPUsersIntoPlatform'));
  86. }
  87. $items[] = array('url' => 'extra_fields.php?type=user', 'label' => get_lang('ManageUserFields'));
  88. $items[] = array('url'=>'usergroups.php', 'label' => get_lang('Classes'));
  89. } elseif (api_is_session_admin() && api_get_configuration_value('limit_session_admin_role')) {
  90. $items = array(
  91. array('url' => 'user_list.php', 'label' => get_lang('UserList')),
  92. array('url' => 'user_add.php', 'label' => get_lang('AddUsers')),
  93. );
  94. } else {
  95. $items = array(
  96. array('url' => 'user_list.php', 'label' => get_lang('UserList')),
  97. array('url' => 'user_add.php', 'label' => get_lang('AddUsers')),
  98. array('url' => 'user_import.php', 'label' => get_lang('ImportUserListXMLCSV')),
  99. array('url' => 'usergroups.php', 'label' => get_lang('Classes')),
  100. );
  101. }
  102. $blocks['users']['items'] = $items;
  103. $blocks['users']['extra'] = null;
  104. if (api_is_platform_admin()) {
  105. /* Courses */
  106. $blocks['courses']['icon'] = Display::return_icon(
  107. 'course.png',
  108. get_lang('Courses'),
  109. array(),
  110. ICON_SIZE_MEDIUM,
  111. false
  112. );
  113. $blocks['courses']['label'] = api_ucfirst(get_lang('Courses'));
  114. $blocks['courses']['class'] = 'block-admin-courses';
  115. $blocks['courses']['editable'] = true;
  116. $coursesBlockExtraFile = "{$adminExtraContentDir}block-admin-courses_extra.html";
  117. if (file_exists($coursesBlockExtraFile)) {
  118. $blocks['courses']['extraContent'] = file_get_contents($coursesBlockExtraFile);
  119. }
  120. $search_form = ' <form method="get" class="form-inline" action="course_list.php">
  121. <div class="form-group">
  122. <input class="form-control" type="text" name="keyword" value="">
  123. <button class="btn btn-default" type="submit">
  124. <em class="fa fa-search"></em> ' . get_lang('Search').'
  125. </button>
  126. </div>
  127. </form>';
  128. $blocks['courses']['search_form'] = $search_form;
  129. $items = array();
  130. $items[] = array('url' => 'course_list.php', 'label' => get_lang('CourseList'));
  131. $items[] = array('url' => 'course_add.php', 'label' => get_lang('AddCourse'));
  132. if (api_get_setting('course_validation') == 'true') {
  133. $items[] = array('url' => 'course_request_review.php', 'label' => get_lang('ReviewCourseRequests'));
  134. $items[] = array('url' => 'course_request_accepted.php', 'label' => get_lang('AcceptedCourseRequests'));
  135. $items[] = array('url' => 'course_request_rejected.php', 'label' => get_lang('RejectedCourseRequests'));
  136. }
  137. $items[] = array('url' => 'course_export.php', 'label' => get_lang('ExportCourses'));
  138. $items[] = array('url' => 'course_import.php', 'label' => get_lang('ImportCourses'));
  139. $items[] = array('url' => 'course_category.php', 'label' => get_lang('AdminCategories'));
  140. $items[] = array('url' => 'subscribe_user2course.php', 'label' => get_lang('AddUsersToACourse'));
  141. $items[] = array('url' => 'course_user_import.php', 'label' => get_lang('ImportUsersToACourse'));
  142. //$items[] = array('url'=>'course_intro_pdf_import.php', 'label' => get_lang('ImportPDFIntroToCourses'));
  143. if (api_get_setting('gradebook_enable_grade_model') == 'true') {
  144. $items[] = array('url' => 'grade_models.php', 'label' => get_lang('GradeModel'));
  145. }
  146. if (isset($extAuthSource) && isset($extAuthSource['ldap']) && count($extAuthSource['ldap']) > 0) {
  147. $items[] = array('url' => 'ldap_import_students.php', 'label' => get_lang('ImportLDAPUsersIntoCourse'));
  148. }
  149. $items[] = array('url' => 'extra_fields.php?type=course', 'label' => get_lang('ManageCourseFields'));
  150. $blocks['courses']['items'] = $items;
  151. $blocks['courses']['extra'] = null;
  152. /* Platform */
  153. $blocks['platform']['icon'] = Display::return_icon(
  154. 'platform.png',
  155. get_lang('Platform'),
  156. array(),
  157. ICON_SIZE_MEDIUM,
  158. false
  159. );
  160. $blocks['platform']['label'] = api_ucfirst(get_lang('Platform'));
  161. $blocks['platform']['class'] = 'block-admin-platform';
  162. $blocks['platform']['editable'] = true;
  163. $platformBlockExtraFile = "{$adminExtraContentDir}block-admin-platform_extra.html";
  164. if (file_exists($platformBlockExtraFile)) {
  165. $blocks['platform']['extraContent'] = file_get_contents($platformBlockExtraFile);
  166. }
  167. $search_form = ' <form method="get" action="settings.php" class="form-inline">
  168. <div class="form-group">
  169. <input class="form-control" type="text" name="search_field" value="" >
  170. <input type="hidden" value="search_setting" name="category">
  171. <button class="btn btn-default" type="submit">
  172. <em class="fa fa-search"></em> ' . get_lang('Search').'
  173. </button>
  174. </div>
  175. </form>';
  176. $blocks['platform']['search_form'] = $search_form;
  177. $items = array();
  178. $items[] = array('url' => 'settings.php', 'label' => get_lang('PlatformConfigSettings'));
  179. $items[] = array('url' => 'languages.php', 'label' => get_lang('Languages'));
  180. $items[] = array('url' => 'settings.php?category=Plugins', 'label' => get_lang('Plugins'));
  181. $items[] = array('url' => 'settings.php?category=Regions', 'label' => get_lang('Regions'));
  182. $items[] = array('url' => 'system_announcements.php', 'label' => get_lang('SystemAnnouncements'));
  183. $items[] = array(
  184. 'url' => api_get_path(WEB_CODE_PATH).'calendar/agenda_js.php?type=admin',
  185. 'label' => get_lang('GlobalAgenda')
  186. );
  187. $items[] = array('url' => 'configure_homepage.php', 'label' => get_lang('ConfigureHomePage'));
  188. $items[] = array('url' => 'configure_inscription.php', 'label' => get_lang('ConfigureInscription'));
  189. $items[] = array('url' => 'statistics/index.php', 'label' => get_lang('Statistics'));
  190. $items[] = array(
  191. 'url' => api_get_path(WEB_CODE_PATH).'mySpace/company_reports.php',
  192. 'label' => get_lang('Reports')
  193. );
  194. $items[] = array(
  195. 'url' => api_get_path(WEB_CODE_PATH).'admin/teacher_time_report.php',
  196. 'label' => get_lang('TeacherTimeReport')
  197. );
  198. if (api_get_configuration_value('chamilo_cms')) {
  199. $items[] = array(
  200. 'url' => api_get_path(WEB_PATH) . 'web/app_dev.php/administration/dashboard',
  201. 'label' => get_lang('CMS')
  202. );
  203. }
  204. /* Event settings */
  205. if (api_get_setting('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('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 (is_dir(api_get_path(SYS_TEST_PATH))) {
  296. $items[] = ['url' => 'email_tester.php', 'label' => get_lang('EMailTester')];
  297. }
  298. $items[] = ['url' => api_get_path(WEB_CODE_PATH).'ticket/tickets.php', 'label' => get_lang('TicketSystem')];
  299. if (api_get_configuration_value('db_manager_enabled') == true && api_is_global_platform_admin()) {
  300. $host = $_configuration['db_host'];
  301. $username = $_configuration['db_user'];
  302. $databaseName = $_configuration['main_database'];
  303. $items[] = array(
  304. 'url' => "db.php?username=$username&db=$databaseName&server=$host",
  305. 'label' => get_lang('DatabaseManager')
  306. );
  307. }
  308. $blocks['settings']['items'] = $items;
  309. $blocks['settings']['extra'] = null;
  310. $blocks['settings']['search_form'] = null;
  311. // Skills
  312. if (api_get_setting('allow_skills_tool') == 'true') {
  313. $blocks['skills']['icon'] = Display::return_icon(
  314. 'skill-badges.png',
  315. get_lang('Skills'),
  316. array(),
  317. ICON_SIZE_MEDIUM,
  318. false
  319. );
  320. $blocks['skills']['label'] = get_lang('Skills');
  321. $blocks['skills']['class'] = 'block-admin-skills';
  322. $items = array();
  323. //$items[] = array('url'=>'skills.php', 'label' => get_lang('SkillsTree'));
  324. $items[] = array('url' => 'skills_wheel.php', 'label' => get_lang('SkillsWheel'));
  325. $items[] = array('url' => 'skills_import.php', 'label' => get_lang('SkillsImport'));
  326. $items[] = array('url' => 'skill_list.php', 'label' => get_lang('ManageSkills'));
  327. $items[] = array('url'=>'skill.php', 'label' => get_lang('ManageSkillsLevels'));
  328. //$items[] = array('url'=>'skills_profile.php', 'label' => get_lang('SkillsProfile'));
  329. $items[] = array(
  330. 'url' => api_get_path(WEB_CODE_PATH).'social/skills_ranking.php',
  331. 'label' => get_lang('SkillsRanking')
  332. );
  333. $items[] = array('url' => 'skills_gradebook.php', 'label' => get_lang('SkillsAndGradebooks'));
  334. $items[] = array(
  335. 'url' => api_get_path(WEB_CODE_PATH).'admin/skill_badge.php',
  336. 'label' => get_lang('Badges')
  337. );
  338. $blocks['skills']['items'] = $items;
  339. $blocks['skills']['extra'] = null;
  340. $blocks['skills']['search_form'] = null;
  341. }
  342. /* Plugins */
  343. global $_plugins;
  344. if (isset($_plugins['menu_administrator']) && count($_plugins['menu_administrator']) > 0) {
  345. $menuAdministratorItems = [];
  346. $plugin_obj = new AppPlugin();
  347. $items = array();
  348. foreach ($_plugins['menu_administrator'] as $pluginName) {
  349. $menuAdministratorItems[] = $pluginName;
  350. }
  351. if ($menuAdministratorItems) {
  352. $blocks['plugins']['icon'] = Display::return_icon(
  353. 'plugins.png',
  354. get_lang('Plugins'),
  355. array(),
  356. ICON_SIZE_MEDIUM,
  357. false
  358. );
  359. $blocks['plugins']['label'] = api_ucfirst(get_lang('Plugins'));
  360. $blocks['plugins']['class'] = 'block-admin-platform';
  361. $blocks['plugins']['editable'] = true;
  362. $plugin_obj = new AppPlugin();
  363. $items = array();
  364. foreach ($menuAdministratorItems as $plugin_name) {
  365. $plugin_info = $plugin_obj->getPluginInfo($plugin_name);
  366. if ($plugin_info['is_admin_plugin']) {
  367. $itemUrl = '/admin.php';
  368. } elseif ($plugin_info['is_admin_plugin']) {
  369. $itemUrl = '/start.php';
  370. }
  371. if (!file_exists(api_get_path(SYS_PLUGIN_PATH).$pluginName.$itemUrl)) {
  372. continue;
  373. }
  374. $items[] = array(
  375. 'url' => api_get_path(WEB_PLUGIN_PATH).$plugin_name.$itemUrl,
  376. 'label' => $plugin_info['title']
  377. );
  378. }
  379. $blocks['plugins']['items'] = $items;
  380. $blocks['plugins']['extra'] = null;
  381. }
  382. }
  383. /* Chamilo.org */
  384. $blocks['chamilo']['icon'] = Display::return_icon('platform.png', 'Chamilo.org', array(), ICON_SIZE_MEDIUM, false);
  385. $blocks['chamilo']['label'] = 'Chamilo.org';
  386. $blocks['chamilo']['class'] = 'block-admin-chamilo';
  387. $items = array();
  388. $items[] = array('url' => 'http://www.chamilo.org/', 'label' => get_lang('ChamiloHomepage'));
  389. $items[] = array('url' => 'http://www.chamilo.org/forum', 'label' => get_lang('ChamiloForum'));
  390. $items[] = array('url' => '../../documentation/installation_guide.html', 'label' => get_lang('InstallationGuide'));
  391. $items[] = array('url' => '../../documentation/changelog.html', 'label' => get_lang('ChangesInLastVersion'));
  392. $items[] = array('url' => '../../documentation/credits.html', 'label' => get_lang('ContributorsList'));
  393. $items[] = array('url' => '../../documentation/security.html', 'label' => get_lang('SecurityGuide'));
  394. $items[] = array('url' => '../../documentation/optimization.html', 'label' => get_lang('OptimizationGuide'));
  395. $items[] = array('url' => 'http://www.chamilo.org/extensions', 'label' => get_lang('ChamiloExtensions'));
  396. $items[] = array(
  397. 'url' => 'http://www.chamilo.org/en/providers',
  398. 'label' => get_lang('ChamiloOfficialServicesProviders')
  399. );
  400. $blocks['chamilo']['items'] = $items;
  401. $blocks['chamilo']['extra'] = null;
  402. $blocks['chamilo']['search_form'] = null;
  403. // Version check
  404. $blocks['version_check']['icon'] = Display::return_icon('platform.png', 'Chamilo.org', array(), ICON_SIZE_MEDIUM, false);
  405. $blocks['version_check']['label'] = get_lang('VersionCheck');
  406. $blocks['version_check']['extra'] = '<div class="admin-block-version"></div>';
  407. $blocks['version_check']['search_form'] = null;
  408. $blocks['version_check']['items'] = null;
  409. $blocks['version_check']['class'] = 'block-admin-version_check';
  410. // Check Hook Event for Admin Block Object
  411. if (!empty($hook)) {
  412. // If not empty, then notify Post process to Hook Observers for Admin Block
  413. $hook->setEventData(array('blocks' => $blocks));
  414. $data = $hook->notifyAdminBlock(HOOK_EVENT_TYPE_POST);
  415. // Check if blocks data is not null
  416. if (isset($data['blocks'])) {
  417. // Get modified blocks
  418. $blocks = $data['blocks'];
  419. }
  420. }
  421. //Hack for fix migration on session_rel_user
  422. $tableColumns = Database::getManager()
  423. ->getConnection()
  424. ->getSchemaManager()
  425. ->listTableColumns(
  426. Database::get_main_table(TABLE_MAIN_SESSION_USER)
  427. );
  428. if (!array_key_exists('duration', $tableColumns)) {
  429. try {
  430. $dbSchema = Database::getManager()->getConnection()->getSchemaManager();
  431. $durationColumn = new \Doctrine\DBAL\Schema\Column(
  432. 'duration',
  433. Doctrine\DBAL\Types\Type::getType(\Doctrine\DBAL\Types\Type::INTEGER),
  434. ['notnull' => false]
  435. );
  436. $tableDiff = new \Doctrine\DBAL\Schema\TableDiff('session_rel_user', [$durationColumn]);
  437. $dbSchema->alterTable($tableDiff);
  438. } catch (Exception $e) {
  439. error_log($e->getMessage());
  440. }
  441. }
  442. //end hack
  443. }
  444. $admin_ajax_url = api_get_path(WEB_AJAX_PATH).'admin.ajax.php';
  445. $tpl = new Template();
  446. // Display the Site Use Cookie Warning Validation
  447. $useCookieValidation = api_get_setting('cookie_warning');
  448. if ($useCookieValidation === 'true') {
  449. if (isset($_POST['acceptCookies'])) {
  450. api_set_site_use_cookie_warning_cookie();
  451. } else if (!api_site_use_cookie_warning_cookie_exist()) {
  452. if (Template::isToolBarDisplayedForUser()) {
  453. $tpl->assign('toolBarDisplayed', true);
  454. } else {
  455. $tpl->assign('toolBarDisplayed', false);
  456. }
  457. $tpl->assign('displayCookieUsageWarning', true);
  458. }
  459. }
  460. $tpl->assign('web_admin_ajax_url', $admin_ajax_url);
  461. $tpl->assign('blocks', $blocks);
  462. if (api_is_platform_admin()) {
  463. $extraContentForm = new FormValidator(
  464. 'block_extra_data',
  465. 'post',
  466. '#',
  467. null,
  468. array(
  469. 'id' => 'block-extra-data',
  470. 'class' => ''
  471. ),
  472. FormValidator::LAYOUT_BOX_NO_LABEL
  473. );
  474. $extraContentFormRenderer = $extraContentForm->getDefaultRenderer();
  475. if ($extraContentForm->validate()) {
  476. $extraData = $extraContentForm->getSubmitValues();
  477. $extraData = array_map(['Security', 'remove_XSS'], $extraData);
  478. if (!empty($extraData['block'])) {
  479. if (!is_dir($adminExtraContentDir)) {
  480. mkdir(
  481. $adminExtraContentDir,
  482. api_get_permissions_for_new_directories(),
  483. true
  484. );
  485. }
  486. if (!is_writable($adminExtraContentDir)) {
  487. die;
  488. }
  489. $fullFilePath = $adminExtraContentDir.$extraData['block'];
  490. $fullFilePath .= "_extra.html";
  491. file_put_contents($fullFilePath, $extraData['extra_content']);
  492. header('Location: '.api_get_self());
  493. exit;
  494. }
  495. }
  496. $extraContentForm->addTextarea(
  497. 'extra_content',
  498. null,
  499. ['id' => 'extra_content']
  500. );
  501. $extraContentFormRenderer->setElementTemplate(
  502. '<div class="form-group">{element}</div>',
  503. 'extra_content'
  504. );
  505. $extraContentForm->addElement(
  506. 'hidden',
  507. 'block',
  508. null,
  509. array(
  510. 'id' => 'extra-block'
  511. )
  512. );
  513. $extraContentForm->addButtonExport(
  514. get_lang('Save'),
  515. 'submit_extra_content'
  516. );
  517. $tpl->assign('extraDataForm', $extraContentForm->returnForm());
  518. }
  519. // The template contains the call to the AJAX version checker
  520. $admin_template = $tpl->get_template('admin/settings_index.tpl');
  521. $content = $tpl->fetch($admin_template);
  522. $tpl->assign('content', $content);
  523. $tpl->display_one_col_template();