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