index.php 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700
  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_linking_requests.php', 'label' => get_lang('UserLinkingRequests')];
  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. // @deprecated to be removed in 2.x
  219. $items[] = array('url' => 'event_controller.php?action=listing', 'label' => get_lang('EventMessageManagement'));
  220. }
  221. $items[] = array('url' => 'extra_field_list.php', 'label' => get_lang('ExtraFields'));
  222. if (!empty($_configuration['multiple_access_urls'])) {
  223. if (api_is_global_platform_admin()) {
  224. $items[] = array('url' => 'access_urls.php', 'label' => get_lang('ConfigureMultipleAccessURLs'));
  225. }
  226. }
  227. if (api_get_setting('allow_terms_conditions') == 'true') {
  228. $items[] = array('url' => 'legal_add.php', 'label' => get_lang('TermsAndConditions'));
  229. }
  230. $blocks['platform']['items'] = $items;
  231. $blocks['platform']['extra'] = null;
  232. }
  233. /* Sessions */
  234. $blocks['sessions']['icon'] = Display::return_icon(
  235. 'session.png',
  236. get_lang('Sessions'),
  237. array(),
  238. ICON_SIZE_MEDIUM,
  239. false
  240. );
  241. $blocks['sessions']['label'] = api_ucfirst(get_lang('Sessions'));
  242. $blocks['sessions']['class'] = 'block-admin-sessions';
  243. $sessionsBlockExtraFile = "{$adminExtraContentDir}block-admin-sessions_extra.html";
  244. if (file_exists($sessionsBlockExtraFile)) {
  245. $blocks['sessions']['extraContent'] = file_get_contents($sessionsBlockExtraFile);
  246. }
  247. if (api_is_platform_admin()) {
  248. $blocks['sessions']['editable'] = true;
  249. }
  250. $sessionPath = api_get_path(WEB_CODE_PATH).'session/';
  251. $search_form = ' <form method="GET" class="form-inline" action="'.$sessionPath.'session_list.php">
  252. <div class="form-group">
  253. <input class="form-control"
  254. type="text"
  255. name="keyword"
  256. value=""
  257. aria-label="'.get_lang('Search').'">
  258. <button class="btn btn-default" type="submit">
  259. <em class="fa fa-search"></em> ' . get_lang('Search').'
  260. </button>
  261. </div>
  262. </form>';
  263. $blocks['sessions']['search_form'] = $search_form;
  264. $items = array();
  265. $items[] = array('url' => $sessionPath.'session_list.php', 'label' => get_lang('ListSession'));
  266. $items[] = array('url' => $sessionPath.'session_add.php', 'label' => get_lang('AddSession'));
  267. $items[] = array('url' => $sessionPath.'session_category_list.php', 'label' => get_lang('ListSessionCategory'));
  268. $items[] = array('url' => $sessionPath.'session_import.php', 'label' => get_lang('ImportSessionListXMLCSV'));
  269. $items[] = array('url' => $sessionPath.'session_import_drh.php', 'label' => get_lang('ImportSessionDrhList'));
  270. if (isset($extAuthSource) && isset($extAuthSource['ldap']) && count($extAuthSource['ldap']) > 0) {
  271. $items[] = array(
  272. 'url' => 'ldap_import_students_to_session.php',
  273. 'label' => get_lang('ImportLDAPUsersIntoSession')
  274. );
  275. }
  276. $items[] = array(
  277. 'url' => $sessionPath.'session_export.php',
  278. 'label' => get_lang('ExportSessionListXMLCSV'),
  279. );
  280. if (api_is_global_platform_admin()) {
  281. $items[] = array(
  282. 'url' => '../coursecopy/copy_course_session.php',
  283. 'label' => get_lang('CopyFromCourseInSessionToAnotherSession')
  284. );
  285. }
  286. $allowCareer = api_get_configuration_value('allow_session_admin_read_careers');
  287. if (api_is_platform_admin() || ($allowCareer && api_is_session_admin())) {
  288. // option only visible in development mode. Enable through code if required
  289. if (is_dir(api_get_path(SYS_TEST_PATH).'datafiller/')) {
  290. $items[] = array('url' => 'user_move_stats.php', 'label' => get_lang('MoveUserStats'));
  291. }
  292. $items[] = array('url' => 'career_dashboard.php', 'label' => get_lang('CareersAndPromotions'));
  293. $items[] = array('url' => 'extra_fields.php?type=session', 'label' => get_lang('ManageSessionFields'));
  294. }
  295. $blocks['sessions']['items'] = $items;
  296. $blocks['sessions']['extra'] = null;
  297. /* Settings */
  298. if (api_is_platform_admin()) {
  299. $blocks['settings']['icon'] = Display::return_icon(
  300. 'settings.png',
  301. get_lang('System'),
  302. array(),
  303. ICON_SIZE_MEDIUM,
  304. false
  305. );
  306. $blocks['settings']['label'] = api_ucfirst(get_lang('System'));
  307. $blocks['settings']['class'] = 'block-admin-settings';
  308. $items = [];
  309. $items[] = array(
  310. 'url' => 'archive_cleanup.php',
  311. 'label' => get_lang('ArchiveDirCleanup')
  312. );
  313. $items[] = array(
  314. 'url' => 'special_exports.php',
  315. 'label' => get_lang('SpecialExports')
  316. );
  317. $items[] = array(
  318. 'url' => 'system_status.php',
  319. 'label' => get_lang('SystemStatus')
  320. );
  321. if (is_dir(api_get_path(SYS_TEST_PATH).'datafiller/')) {
  322. $items[] = array(
  323. 'url' => 'filler.php',
  324. 'label' => get_lang('DataFiller')
  325. );
  326. }
  327. $items[] = array(
  328. 'url' => 'resource_sequence.php',
  329. 'label' => get_lang('ResourcesSequencing')
  330. );
  331. if (is_dir(api_get_path(SYS_TEST_PATH))) {
  332. $items[] = [
  333. 'url' => 'email_tester.php',
  334. 'label' => get_lang('EMailTester')
  335. ];
  336. }
  337. $items[] = [
  338. 'url' => api_get_path(WEB_CODE_PATH).'ticket/tickets.php',
  339. 'label' => get_lang('TicketSystem')
  340. ];
  341. if (api_get_configuration_value('db_manager_enabled') == true &&
  342. api_is_global_platform_admin()
  343. ) {
  344. $host = $_configuration['db_host'];
  345. $username = $_configuration['db_user'];
  346. $databaseName = $_configuration['main_database'];
  347. $items[] = array(
  348. 'url' => "db.php?username=$username&db=$databaseName&server=$host",
  349. 'label' => get_lang('DatabaseManager')
  350. );
  351. }
  352. $blocks['settings']['items'] = $items;
  353. $blocks['settings']['extra'] = null;
  354. $blocks['settings']['search_form'] = null;
  355. // Skills
  356. if (Skill::isToolAvailable()) {
  357. $blocks['skills']['icon'] = Display::return_icon(
  358. 'skill-badges.png',
  359. get_lang('Skills'),
  360. array(),
  361. ICON_SIZE_MEDIUM,
  362. false
  363. );
  364. $blocks['skills']['label'] = get_lang('Skills');
  365. $blocks['skills']['class'] = 'block-admin-skills';
  366. $items = array();
  367. $items[] = array(
  368. 'url' => 'skills_wheel.php',
  369. 'label' => get_lang('SkillsWheel')
  370. );
  371. $items[] = array(
  372. 'url' => 'skills_import.php',
  373. 'label' => get_lang('SkillsImport')
  374. );
  375. $items[] = array(
  376. 'url' => 'skill_list.php',
  377. 'label' => get_lang('ManageSkills')
  378. );
  379. $items[] = array(
  380. 'url' => 'skill.php',
  381. 'label' => get_lang('ManageSkillsLevels')
  382. );
  383. $items[] = array(
  384. 'url' => api_get_path(WEB_CODE_PATH).'social/skills_ranking.php',
  385. 'label' => get_lang('SkillsRanking')
  386. );
  387. $items[] = array(
  388. 'url' => 'skills_gradebook.php',
  389. 'label' => get_lang('SkillsAndGradebooks')
  390. );
  391. /*$items[] = array(
  392. 'url' => api_get_path(WEB_CODE_PATH).'admin/skill_badge.php',
  393. 'label' => get_lang('Badges')
  394. );*/
  395. $blocks['skills']['items'] = $items;
  396. $blocks['skills']['extra'] = null;
  397. $blocks['skills']['search_form'] = null;
  398. }
  399. $allow = api_get_configuration_value('gradebook_dependency');
  400. if ($allow) {
  401. $blocks['gradebook']['icon'] = Display::return_icon(
  402. 'gradebook.png',
  403. get_lang('Gradebook'),
  404. array(),
  405. ICON_SIZE_MEDIUM,
  406. false
  407. );
  408. $blocks['gradebook']['label'] = get_lang('Gradebook');
  409. $blocks['gradebook']['class'] = 'block-admin-gradebook';
  410. $items = array();
  411. $items[] = array(
  412. 'url' => 'gradebook_list.php',
  413. 'label' => get_lang('List')
  414. );
  415. $blocks['gradebook']['items'] = $items;
  416. $blocks['gradebook']['extra'] = null;
  417. $blocks['gradebook']['search_form'] = null;
  418. }
  419. }
  420. if (api_is_platform_admin()) {
  421. /* Plugins */
  422. global $_plugins;
  423. if (isset($_plugins['menu_administrator']) &&
  424. count($_plugins['menu_administrator']) > 0
  425. ) {
  426. $menuAdministratorItems = $_plugins['menu_administrator'];
  427. if ($menuAdministratorItems) {
  428. $blocks['plugins']['icon'] = Display::return_icon(
  429. 'plugins.png',
  430. get_lang('Plugins'),
  431. array(),
  432. ICON_SIZE_MEDIUM,
  433. false
  434. );
  435. $blocks['plugins']['label'] = get_lang('Plugins');
  436. $blocks['plugins']['class'] = 'block-admin-platform';
  437. $blocks['plugins']['editable'] = true;
  438. $plugin_obj = new AppPlugin();
  439. $items = array();
  440. foreach ($menuAdministratorItems as $pluginName) {
  441. $pluginInfo = $plugin_obj->getPluginInfo($pluginName, true);
  442. /** @var \Plugin $plugin */
  443. $plugin = $pluginInfo['obj'];
  444. $pluginUrl = $plugin->getAdminUrl();
  445. if (empty($pluginUrl)) {
  446. continue;
  447. }
  448. $items[] = array(
  449. 'url' => $pluginUrl,
  450. 'label' => $pluginInfo['title']
  451. );
  452. }
  453. $blocks['plugins']['items'] = $items;
  454. $blocks['plugins']['extra'] = '';
  455. }
  456. }
  457. /* Chamilo.org */
  458. $blocks['chamilo']['icon'] = Display::return_icon(
  459. 'platform.png',
  460. 'Chamilo.org',
  461. array(),
  462. ICON_SIZE_MEDIUM,
  463. false
  464. );
  465. $blocks['chamilo']['label'] = 'Chamilo.org';
  466. $blocks['chamilo']['class'] = 'block-admin-chamilo';
  467. $items = array();
  468. $items[] = array('url' => 'http://www.chamilo.org/', 'label' => get_lang('ChamiloHomepage'));
  469. $items[] = array('url' => 'http://www.chamilo.org/forum', 'label' => get_lang('ChamiloForum'));
  470. $items[] = array('url' => '../../documentation/installation_guide.html', 'label' => get_lang('InstallationGuide'));
  471. $items[] = array('url' => '../../documentation/changelog.html', 'label' => get_lang('ChangesInLastVersion'));
  472. $items[] = array('url' => '../../documentation/credits.html', 'label' => get_lang('ContributorsList'));
  473. $items[] = array('url' => '../../documentation/security.html', 'label' => get_lang('SecurityGuide'));
  474. $items[] = array('url' => '../../documentation/optimization.html', 'label' => get_lang('OptimizationGuide'));
  475. $items[] = array('url' => 'http://www.chamilo.org/extensions', 'label' => get_lang('ChamiloExtensions'));
  476. $items[] = array(
  477. 'url' => 'http://www.chamilo.org/en/providers',
  478. 'label' => get_lang('ChamiloOfficialServicesProviders')
  479. );
  480. $blocks['chamilo']['items'] = $items;
  481. $blocks['chamilo']['extra'] = null;
  482. $blocks['chamilo']['search_form'] = null;
  483. // Version check
  484. $blocks['version_check']['icon'] = Display::return_icon(
  485. 'platform.png',
  486. 'Chamilo.org',
  487. array(),
  488. ICON_SIZE_MEDIUM,
  489. false
  490. );
  491. $blocks['version_check']['label'] = get_lang('VersionCheck');
  492. $blocks['version_check']['extra'] = '<div class="admin-block-version"></div>';
  493. $blocks['version_check']['search_form'] = null;
  494. $blocks['version_check']['items'] = '<div class="block-admin-version_check"></div>';
  495. $blocks['version_check']['class'] = '';
  496. // Check Hook Event for Admin Block Object
  497. if (!empty($hook)) {
  498. // If not empty, then notify Post process to Hook Observers for Admin Block
  499. $hook->setEventData(array('blocks' => $blocks));
  500. $data = $hook->notifyAdminBlock(HOOK_EVENT_TYPE_POST);
  501. // Check if blocks data is not null
  502. if (isset($data['blocks'])) {
  503. // Get modified blocks
  504. $blocks = $data['blocks'];
  505. }
  506. }
  507. //Hack for fix migration on session_rel_user
  508. $tableColumns = Database::getManager()
  509. ->getConnection()
  510. ->getSchemaManager()
  511. ->listTableColumns(
  512. Database::get_main_table(TABLE_MAIN_SESSION_USER)
  513. );
  514. if (!array_key_exists('duration', $tableColumns)) {
  515. try {
  516. $dbSchema = Database::getManager()->getConnection()->getSchemaManager();
  517. $durationColumn = new \Doctrine\DBAL\Schema\Column(
  518. 'duration',
  519. Doctrine\DBAL\Types\Type::getType(\Doctrine\DBAL\Types\Type::INTEGER),
  520. ['notnull' => false]
  521. );
  522. $tableDiff = new \Doctrine\DBAL\Schema\TableDiff('session_rel_user', [$durationColumn]);
  523. $dbSchema->alterTable($tableDiff);
  524. } catch (Exception $e) {
  525. error_log($e->getMessage());
  526. }
  527. }
  528. //end hack
  529. }
  530. $admin_ajax_url = api_get_path(WEB_AJAX_PATH).'admin.ajax.php';
  531. $tpl = new Template();
  532. // Display the Site Use Cookie Warning Validation
  533. $useCookieValidation = api_get_setting('cookie_warning');
  534. if ($useCookieValidation === 'true') {
  535. if (isset($_POST['acceptCookies'])) {
  536. api_set_site_use_cookie_warning_cookie();
  537. } elseif (!api_site_use_cookie_warning_cookie_exist()) {
  538. if (Template::isToolBarDisplayedForUser()) {
  539. $tpl->assign('toolBarDisplayed', true);
  540. } else {
  541. $tpl->assign('toolBarDisplayed', false);
  542. }
  543. $tpl->assign('displayCookieUsageWarning', true);
  544. }
  545. }
  546. $tpl->assign('web_admin_ajax_url', $admin_ajax_url);
  547. $tpl->assign('blocks', $blocks);
  548. if (api_is_platform_admin()) {
  549. $extraContentForm = new FormValidator(
  550. 'block_extra_data',
  551. 'post',
  552. '#',
  553. null,
  554. array(
  555. 'id' => 'block-extra-data',
  556. 'class' => ''
  557. ),
  558. FormValidator::LAYOUT_BOX_NO_LABEL
  559. );
  560. $extraContentFormRenderer = $extraContentForm->getDefaultRenderer();
  561. if ($extraContentForm->validate()) {
  562. $extraData = $extraContentForm->getSubmitValues();
  563. $extraData = array_map(['Security', 'remove_XSS'], $extraData);
  564. if (!empty($extraData['block'])) {
  565. if (!is_dir($adminExtraContentDir)) {
  566. mkdir(
  567. $adminExtraContentDir,
  568. api_get_permissions_for_new_directories(),
  569. true
  570. );
  571. }
  572. if (!is_writable($adminExtraContentDir)) {
  573. die;
  574. }
  575. $fullFilePath = $adminExtraContentDir.$extraData['block'];
  576. $fullFilePath .= "_extra.html";
  577. file_put_contents($fullFilePath, $extraData['extra_content']);
  578. header('Location: '.api_get_self());
  579. exit;
  580. }
  581. }
  582. $extraContentForm->addTextarea(
  583. 'extra_content',
  584. null,
  585. ['id' => 'extra_content']
  586. );
  587. $extraContentFormRenderer->setElementTemplate(
  588. '<div class="form-group">{element}</div>',
  589. 'extra_content'
  590. );
  591. $extraContentForm->addElement(
  592. 'hidden',
  593. 'block',
  594. null,
  595. array(
  596. 'id' => 'extra-block'
  597. )
  598. );
  599. $extraContentForm->addButtonExport(
  600. get_lang('Save'),
  601. 'submit_extra_content'
  602. );
  603. $tpl->assign('extraDataForm', $extraContentForm->returnForm());
  604. }
  605. // The template contains the call to the AJAX version checker
  606. $admin_template = $tpl->get_template('admin/settings_index.tpl');
  607. $content = $tpl->fetch($admin_template);
  608. $tpl->assign('content', $content);
  609. $tpl->display_one_col_template();