index.php 25 KB

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