index.php 23 KB

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