index.php 25 KB

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