index.php 24 KB

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