index.php 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724
  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. header('Location: '.api_get_path(WEB_PATH).'admin');
  12. exit;
  13. // Setting the section (for the tabs).
  14. $this_section = SECTION_PLATFORM_ADMIN;
  15. // Access restrictions.
  16. api_protect_admin_script(true);
  17. $nameTools = get_lang('PlatformAdmin');
  18. $accessUrlId = 0;
  19. $adminExtraContentDir = api_get_path(SYS_APP_PATH)."home/admin/";
  20. if (api_is_multiple_url_enabled()) {
  21. $accessUrlId = api_get_current_access_url_id();
  22. if ($accessUrlId != -1) {
  23. $urlInfo = api_get_access_url($accessUrlId);
  24. $url = api_remove_trailing_slash(preg_replace('/https?:\/\//i', '', $urlInfo['url']));
  25. $cleanUrl = str_replace('/', '-', $url);
  26. $adminExtraContentDir = api_get_path(SYS_APP_PATH)."home/$cleanUrl/admin/";
  27. }
  28. }
  29. // Displaying the header
  30. if (api_is_platform_admin()) {
  31. if (is_dir(api_get_path(SYS_ARCHIVE_PATH)) &&
  32. !is_writable(api_get_path(SYS_ARCHIVE_PATH))
  33. ) {
  34. Display::addFlash(
  35. Display::return_message(get_lang('ArchivesDirectoryNotWriteableContactAdmin'), 'warning')
  36. );
  37. }
  38. /* ACTION HANDLING */
  39. if (!empty($_POST['Register'])) {
  40. api_register_campus(!$_POST['donotlistcampus']);
  41. $message = Display :: return_message(get_lang('VersionCheckEnabled'), 'confirmation');
  42. Display::addFlash($message);
  43. }
  44. $keyword_url = Security::remove_XSS((empty($_GET['keyword']) ? '' : $_GET['keyword']));
  45. }
  46. $blocks = array();
  47. // Instantiate Hook Event for Admin Block
  48. $hook = HookAdminBlock::create();
  49. if (!empty($hook)) {
  50. // If not empty, then notify Pre process to Hook Observers for Admin Block
  51. $hook->setEventData(array('blocks' => $blocks));
  52. $data = $hook->notifyAdminBlock(HOOK_EVENT_TYPE_PRE);
  53. // Check if blocks data is not null
  54. if (isset($data['blocks'])) {
  55. // Get modified blocks
  56. $blocks = $data['blocks'];
  57. }
  58. }
  59. /* Users */
  60. $blocks['users']['icon'] = Display::return_icon(
  61. 'members.png',
  62. get_lang('Users'),
  63. array(),
  64. ICON_SIZE_MEDIUM,
  65. false
  66. );
  67. $blocks['users']['label'] = api_ucfirst(get_lang('Users'));
  68. $blocks['users']['class'] = 'block-admin-users';
  69. $usersBlockExtraFile = "{$adminExtraContentDir}block-admin-users_extra.html";
  70. if (file_exists($usersBlockExtraFile)) {
  71. $blocks['users']['extraContent'] = file_get_contents($usersBlockExtraFile);
  72. }
  73. $search_form = '
  74. <form method="get" class="form-inline" action="user_list.php">
  75. <div class="form-group">
  76. <input class="form-control" type="text" name="keyword" value=""
  77. aria-label="'.get_lang('Search').'">
  78. <button class="btn btn-default" type="submit">
  79. <em class="fa fa-search"></em> ' . get_lang('Search').'
  80. </button>
  81. </div>
  82. </form>';
  83. $blocks['users']['search_form'] = $search_form;
  84. if (api_is_platform_admin()) {
  85. $blocks['users']['editable'] = true;
  86. $items = array(
  87. array('url' => 'user_list.php', 'label' => get_lang('UserList')),
  88. array('url' => 'user_add.php', 'label' => get_lang('AddUsers')),
  89. array('url' => 'user_export.php', 'label' => get_lang('ExportUserListXMLCSV')),
  90. array('url' => 'user_import.php', 'label' => get_lang('ImportUserListXMLCSV')),
  91. array('url' => 'user_update_import.php', 'label' => get_lang('EditUserListCSV')),
  92. );
  93. if (isset($extAuthSource) && isset($extAuthSource['extldap']) && count($extAuthSource['extldap']) > 0) {
  94. $items[] = array('url' => 'ldap_users_list.php', 'label' => get_lang('ImportLDAPUsersIntoPlatform'));
  95. }
  96. $items[] = array('url' => 'extra_fields.php?type=user', 'label' => get_lang('ManageUserFields'));
  97. $items[] = array('url'=>'usergroups.php', 'label' => get_lang('Classes'));
  98. $items[] = ['url' => 'user_linking_requests.php', 'label' => get_lang('UserLinkingRequests')];
  99. } elseif (api_is_session_admin() && api_get_configuration_value('limit_session_admin_role')) {
  100. $items = array(
  101. array('url' => 'user_list.php', 'label' => get_lang('UserList')),
  102. array('url' => 'user_add.php', 'label' => get_lang('AddUsers')),
  103. );
  104. } else {
  105. $items = [
  106. array('url' => 'user_list.php', 'label' => get_lang('UserList')),
  107. array('url' => 'user_add.php', 'label' => get_lang('AddUsers')),
  108. array('url' => 'user_import.php', 'label' => get_lang('ImportUserListXMLCSV')),
  109. array('url' => 'usergroups.php', 'label' => get_lang('Classes')),
  110. ];
  111. }
  112. $blocks['users']['items'] = $items;
  113. $blocks['users']['extra'] = null;
  114. if (api_is_platform_admin()) {
  115. /* Courses */
  116. $blocks['courses']['icon'] = Display::return_icon(
  117. 'course.png',
  118. get_lang('Courses'),
  119. array(),
  120. ICON_SIZE_MEDIUM,
  121. false
  122. );
  123. $blocks['courses']['label'] = api_ucfirst(get_lang('Courses'));
  124. $blocks['courses']['class'] = 'block-admin-courses';
  125. $blocks['courses']['editable'] = true;
  126. $coursesBlockExtraFile = "{$adminExtraContentDir}block-admin-courses_extra.html";
  127. if (file_exists($coursesBlockExtraFile)) {
  128. $blocks['courses']['extraContent'] = file_get_contents($coursesBlockExtraFile);
  129. }
  130. $search_form = ' <form method="get" class="form-inline" action="course_list.php">
  131. <div class="form-group">
  132. <input class="form-control" type="text" name="keyword" value=""
  133. aria-label="'.get_lang('Search').'">
  134. <button class="btn btn-default" type="submit">
  135. <em class="fa fa-search"></em> ' . get_lang('Search').'
  136. </button>
  137. </div>
  138. </form>';
  139. $blocks['courses']['search_form'] = $search_form;
  140. $items = array();
  141. $items[] = array('url' => 'course_list.php', 'label' => get_lang('CourseList'));
  142. $items[] = array('url' => 'course_add.php', 'label' => get_lang('AddCourse'));
  143. if (api_get_setting('course_validation') == 'true') {
  144. $items[] = array('url' => 'course_request_review.php', 'label' => get_lang('ReviewCourseRequests'));
  145. $items[] = array('url' => 'course_request_accepted.php', 'label' => get_lang('AcceptedCourseRequests'));
  146. $items[] = array('url' => 'course_request_rejected.php', 'label' => get_lang('RejectedCourseRequests'));
  147. }
  148. $items[] = array('url' => 'course_export.php', 'label' => get_lang('ExportCourses'));
  149. $items[] = array('url' => 'course_import.php', 'label' => get_lang('ImportCourses'));
  150. $items[] = array('url' => 'course_category.php', 'label' => get_lang('AdminCategories'));
  151. $items[] = array('url' => 'subscribe_user2course.php', 'label' => get_lang('AddUsersToACourse'));
  152. $items[] = array('url' => 'course_user_import.php', 'label' => get_lang('ImportUsersToACourse'));
  153. //$items[] = array('url'=>'course_intro_pdf_import.php', 'label' => get_lang('ImportPDFIntroToCourses'));
  154. if (api_get_setting('gradebook_enable_grade_model') == 'true') {
  155. $items[] = array('url' => 'grade_models.php', 'label' => get_lang('GradeModel'));
  156. }
  157. if (isset($extAuthSource) && isset($extAuthSource['ldap']) && count($extAuthSource['ldap']) > 0) {
  158. $items[] = array('url' => 'ldap_import_students.php', 'label' => get_lang('ImportLDAPUsersIntoCourse'));
  159. }
  160. $items[] = array('url' => 'extra_fields.php?type=course', 'label' => get_lang('ManageCourseFields'));
  161. $blocks['courses']['items'] = $items;
  162. $blocks['courses']['extra'] = null;
  163. /* Platform */
  164. $blocks['platform']['icon'] = Display::return_icon(
  165. 'platform.png',
  166. get_lang('Platform'),
  167. array(),
  168. ICON_SIZE_MEDIUM,
  169. false
  170. );
  171. $blocks['platform']['label'] = api_ucfirst(get_lang('Platform'));
  172. $blocks['platform']['class'] = 'block-admin-platform';
  173. $blocks['platform']['editable'] = true;
  174. $platformBlockExtraFile = "{$adminExtraContentDir}block-admin-platform_extra.html";
  175. if (file_exists($platformBlockExtraFile)) {
  176. $blocks['platform']['extraContent'] = file_get_contents($platformBlockExtraFile);
  177. }
  178. $search_form = ' <form method="get" action="settings.php" class="form-inline">
  179. <div class="form-group">
  180. <input class="form-control"
  181. type="text"
  182. name="search_field" value=""
  183. aria-label="'.get_lang('Search').'" >
  184. <input type="hidden" value="search_setting" name="category">
  185. <button class="btn btn-default" type="submit">
  186. <em class="fa fa-search"></em> ' . get_lang('Search').'
  187. </button>
  188. </div>
  189. </form>';
  190. $blocks['platform']['search_form'] = $search_form;
  191. $items = array();
  192. $items[] = array('url' => 'settings.php', 'label' => get_lang('PlatformConfigSettings'));
  193. $items[] = array('url' => 'languages.php', 'label' => get_lang('Languages'));
  194. $items[] = array('url' => 'settings.php?category=Plugins', 'label' => get_lang('Plugins'));
  195. $items[] = array('url' => 'settings.php?category=Regions', 'label' => get_lang('Regions'));
  196. $items[] = array('url' => 'system_announcements.php', 'label' => get_lang('SystemAnnouncements'));
  197. $items[] = array(
  198. 'url' => api_get_path(WEB_CODE_PATH).'calendar/agenda_js.php?type=admin',
  199. 'label' => get_lang('GlobalAgenda')
  200. );
  201. $items[] = array('url' => 'configure_homepage.php', 'label' => get_lang('ConfigureHomePage'));
  202. $items[] = array('url' => 'configure_inscription.php', 'label' => get_lang('ConfigureInscription'));
  203. $items[] = array('url' => 'statistics/index.php', 'label' => get_lang('Statistics'));
  204. $items[] = array(
  205. 'url' => api_get_path(WEB_CODE_PATH).'mySpace/company_reports.php',
  206. 'label' => get_lang('Reports')
  207. );
  208. $items[] = array(
  209. 'url' => api_get_path(WEB_CODE_PATH).'admin/teacher_time_report.php',
  210. 'label' => get_lang('TeacherTimeReport')
  211. );
  212. if (api_get_configuration_value('chamilo_cms')) {
  213. $items[] = array(
  214. 'url' => api_get_path(WEB_PATH).'web/app_dev.php/administration/dashboard',
  215. 'label' => get_lang('CMS')
  216. );
  217. }
  218. /* Event settings */
  219. if (api_get_setting('activate_email_template') == 'true') {
  220. $items[] = array('url' => 'event_controller.php?action=listing', 'label' => get_lang('EventMessageManagement'));
  221. }
  222. $items[] = array('url' => 'extra_field_list.php', 'label' => get_lang('ExtraFields'));
  223. if (!empty($_configuration['multiple_access_urls'])) {
  224. if (api_is_global_platform_admin()) {
  225. $items[] = array('url' => 'access_urls.php', 'label' => get_lang('ConfigureMultipleAccessURLs'));
  226. }
  227. }
  228. if (api_get_setting('allow_terms_conditions') == 'true') {
  229. $items[] = array('url' => 'legal_add.php', 'label' => get_lang('TermsAndConditions'));
  230. }
  231. $blocks['platform']['items'] = $items;
  232. $blocks['platform']['extra'] = null;
  233. }
  234. /* Sessions */
  235. $blocks['sessions']['icon'] = Display::return_icon(
  236. 'session.png',
  237. get_lang('Sessions'),
  238. array(),
  239. ICON_SIZE_MEDIUM,
  240. false
  241. );
  242. $blocks['sessions']['label'] = api_ucfirst(get_lang('Sessions'));
  243. $blocks['sessions']['class'] = 'block-admin-sessions';
  244. $sessionsBlockExtraFile = "{$adminExtraContentDir}block-admin-sessions_extra.html";
  245. if (file_exists($sessionsBlockExtraFile)) {
  246. $blocks['sessions']['extraContent'] = file_get_contents($sessionsBlockExtraFile);
  247. }
  248. if (api_is_platform_admin()) {
  249. $blocks['sessions']['editable'] = true;
  250. }
  251. $sessionPath = api_get_path(WEB_CODE_PATH).'session/';
  252. $search_form = ' <form method="GET" class="form-inline" action="'.$sessionPath.'session_list.php">
  253. <div class="form-group">
  254. <input class="form-control"
  255. type="text"
  256. name="keyword"
  257. value=""
  258. aria-label="'.get_lang('Search').'">
  259. <button class="btn btn-default" type="submit">
  260. <em class="fa fa-search"></em> ' . get_lang('Search').'
  261. </button>
  262. </div>
  263. </form>';
  264. $blocks['sessions']['search_form'] = $search_form;
  265. $items = array();
  266. $items[] = array('url' => $sessionPath.'session_list.php', 'label' => get_lang('ListSession'));
  267. $items[] = array('url' => $sessionPath.'session_add.php', 'label' => get_lang('AddSession'));
  268. $items[] = array('url' => $sessionPath.'session_category_list.php', 'label' => get_lang('ListSessionCategory'));
  269. $items[] = array('url' => $sessionPath.'session_import.php', 'label' => get_lang('ImportSessionListXMLCSV'));
  270. $items[] = array('url' => $sessionPath.'session_import_drh.php', 'label' => get_lang('ImportSessionDrhList'));
  271. if (isset($extAuthSource) && isset($extAuthSource['ldap']) && count($extAuthSource['ldap']) > 0) {
  272. $items[] = array(
  273. 'url' => 'ldap_import_students_to_session.php',
  274. 'label' => get_lang('ImportLDAPUsersIntoSession')
  275. );
  276. }
  277. $items[] = array(
  278. 'url' => $sessionPath.'session_export.php',
  279. 'label' => get_lang('ExportSessionListXMLCSV'),
  280. );
  281. if (api_is_global_platform_admin()) {
  282. $items[] = array(
  283. 'url' => '../coursecopy/copy_course_session.php',
  284. 'label' => get_lang('CopyFromCourseInSessionToAnotherSession')
  285. );
  286. }
  287. if (api_is_platform_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 = array();
  309. $items[] = array(
  310. 'url' => 'special_exports.php',
  311. 'label' => get_lang('SpecialExports')
  312. );
  313. $items[] = array(
  314. 'url' => 'system_status.php',
  315. 'label' => get_lang('SystemStatus')
  316. );
  317. if (is_dir(api_get_path(SYS_TEST_PATH).'datafiller/')) {
  318. $items[] = array(
  319. 'url' => 'filler.php',
  320. 'label' => get_lang('DataFiller')
  321. );
  322. }
  323. $items[] = array(
  324. 'url' => 'archive_cleanup.php',
  325. 'label' => get_lang('ArchiveDirCleanup')
  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 = [];
  427. $plugin_obj = new AppPlugin();
  428. $items = array();
  429. foreach ($_plugins['menu_administrator'] as $pluginName) {
  430. $menuAdministratorItems[] = $pluginName;
  431. }
  432. if ($menuAdministratorItems) {
  433. $blocks['plugins']['icon'] = Display::return_icon(
  434. 'plugins.png',
  435. get_lang('Plugins'),
  436. array(),
  437. ICON_SIZE_MEDIUM,
  438. false
  439. );
  440. $blocks['plugins']['label'] = api_ucfirst(get_lang('Plugins'));
  441. $blocks['plugins']['class'] = 'block-admin-platform';
  442. $blocks['plugins']['editable'] = true;
  443. $plugin_obj = new AppPlugin();
  444. $items = array();
  445. foreach ($menuAdministratorItems as $plugin_name) {
  446. $plugin_info = $plugin_obj->getPluginInfo($plugin_name);
  447. if ($plugin_info['is_admin_plugin'] === false) {
  448. continue;
  449. }
  450. if ($plugin_info['is_admin_plugin']) {
  451. $itemUrl = '/admin.php';
  452. } elseif ($plugin_info['is_admin_plugin']) {
  453. $itemUrl = '/start.php';
  454. }
  455. $itemUrl = $pluginName.'/start.php';
  456. if (file_exists(api_get_path(SYS_PLUGIN_PATH).$itemUrl)) {
  457. $items[] = array(
  458. 'url' => api_get_path(WEB_PLUGIN_PATH).$itemUrl,
  459. 'label' => $plugin_info['title']
  460. );
  461. continue;
  462. }
  463. $itemUrl = $pluginName.'/admin.php';
  464. if (file_exists(api_get_path(SYS_PLUGIN_PATH).$itemUrl)) {
  465. $items[] = array(
  466. 'url' => api_get_path(WEB_PLUGIN_PATH).$itemUrl,
  467. 'label' => $plugin_info['title']
  468. );
  469. }
  470. }
  471. $blocks['plugins']['items'] = $items;
  472. $blocks['plugins']['extra'] = null;
  473. }
  474. }
  475. /* Chamilo.org */
  476. $blocks['chamilo']['icon'] = Display::return_icon(
  477. 'platform.png',
  478. 'Chamilo.org',
  479. array(),
  480. ICON_SIZE_MEDIUM,
  481. false
  482. );
  483. $blocks['chamilo']['label'] = 'Chamilo.org';
  484. $blocks['chamilo']['class'] = 'block-admin-chamilo';
  485. $items = array();
  486. $items[] = array('url' => 'http://www.chamilo.org/', 'label' => get_lang('ChamiloHomepage'));
  487. $items[] = array('url' => 'http://www.chamilo.org/forum', 'label' => get_lang('ChamiloForum'));
  488. $items[] = array('url' => '../../documentation/installation_guide.html', 'label' => get_lang('InstallationGuide'));
  489. $items[] = array('url' => '../../documentation/changelog.html', 'label' => get_lang('ChangesInLastVersion'));
  490. $items[] = array('url' => '../../documentation/credits.html', 'label' => get_lang('ContributorsList'));
  491. $items[] = array('url' => '../../documentation/security.html', 'label' => get_lang('SecurityGuide'));
  492. $items[] = array('url' => '../../documentation/optimization.html', 'label' => get_lang('OptimizationGuide'));
  493. $items[] = array('url' => 'http://www.chamilo.org/extensions', 'label' => get_lang('ChamiloExtensions'));
  494. $items[] = array(
  495. 'url' => 'http://www.chamilo.org/en/providers',
  496. 'label' => get_lang('ChamiloOfficialServicesProviders')
  497. );
  498. $blocks['chamilo']['items'] = $items;
  499. $blocks['chamilo']['extra'] = null;
  500. $blocks['chamilo']['search_form'] = null;
  501. // Version check
  502. $blocks['version_check']['icon'] = Display::return_icon(
  503. 'platform.png',
  504. 'Chamilo.org',
  505. array(),
  506. ICON_SIZE_MEDIUM,
  507. false
  508. );
  509. $blocks['version_check']['label'] = get_lang('VersionCheck');
  510. $blocks['version_check']['extra'] = '<div class="admin-block-version"></div>';
  511. $blocks['version_check']['search_form'] = null;
  512. $blocks['version_check']['items'] = '<div class="block-admin-version_check"></div>';
  513. $blocks['version_check']['class'] = '';
  514. // Check Hook Event for Admin Block Object
  515. if (!empty($hook)) {
  516. // If not empty, then notify Post process to Hook Observers for Admin Block
  517. $hook->setEventData(array('blocks' => $blocks));
  518. $data = $hook->notifyAdminBlock(HOOK_EVENT_TYPE_POST);
  519. // Check if blocks data is not null
  520. if (isset($data['blocks'])) {
  521. // Get modified blocks
  522. $blocks = $data['blocks'];
  523. }
  524. }
  525. //Hack for fix migration on session_rel_user
  526. $tableColumns = Database::getManager()
  527. ->getConnection()
  528. ->getSchemaManager()
  529. ->listTableColumns(
  530. Database::get_main_table(TABLE_MAIN_SESSION_USER)
  531. );
  532. if (!array_key_exists('duration', $tableColumns)) {
  533. try {
  534. $dbSchema = Database::getManager()->getConnection()->getSchemaManager();
  535. $durationColumn = new \Doctrine\DBAL\Schema\Column(
  536. 'duration',
  537. Doctrine\DBAL\Types\Type::getType(\Doctrine\DBAL\Types\Type::INTEGER),
  538. ['notnull' => false]
  539. );
  540. $tableDiff = new \Doctrine\DBAL\Schema\TableDiff('session_rel_user', [$durationColumn]);
  541. $dbSchema->alterTable($tableDiff);
  542. } catch (Exception $e) {
  543. error_log($e->getMessage());
  544. }
  545. }
  546. //end hack
  547. }
  548. $admin_ajax_url = api_get_path(WEB_AJAX_PATH).'admin.ajax.php';
  549. $tpl = new Template();
  550. // Display the Site Use Cookie Warning Validation
  551. $useCookieValidation = api_get_setting('cookie_warning');
  552. if ($useCookieValidation === 'true') {
  553. if (isset($_POST['acceptCookies'])) {
  554. api_set_site_use_cookie_warning_cookie();
  555. } elseif (!api_site_use_cookie_warning_cookie_exist()) {
  556. if (Template::isToolBarDisplayedForUser()) {
  557. $tpl->assign('toolBarDisplayed', true);
  558. } else {
  559. $tpl->assign('toolBarDisplayed', false);
  560. }
  561. $tpl->assign('displayCookieUsageWarning', true);
  562. }
  563. }
  564. $tpl->assign('web_admin_ajax_url', $admin_ajax_url);
  565. $tpl->assign('blocks', $blocks);
  566. if (api_is_platform_admin()) {
  567. $extraContentForm = new FormValidator(
  568. 'block_extra_data',
  569. 'post',
  570. '#',
  571. null,
  572. array(
  573. 'id' => 'block-extra-data',
  574. 'class' => ''
  575. ),
  576. FormValidator::LAYOUT_BOX_NO_LABEL
  577. );
  578. $extraContentFormRenderer = $extraContentForm->getDefaultRenderer();
  579. if ($extraContentForm->validate()) {
  580. $extraData = $extraContentForm->getSubmitValues();
  581. $extraData = array_map(['Security', 'remove_XSS'], $extraData);
  582. if (!empty($extraData['block'])) {
  583. if (!is_dir($adminExtraContentDir)) {
  584. mkdir(
  585. $adminExtraContentDir,
  586. api_get_permissions_for_new_directories(),
  587. true
  588. );
  589. }
  590. if (!is_writable($adminExtraContentDir)) {
  591. die;
  592. }
  593. $fullFilePath = $adminExtraContentDir.$extraData['block'];
  594. $fullFilePath .= "_extra.html";
  595. file_put_contents($fullFilePath, $extraData['extra_content']);
  596. header('Location: '.api_get_self());
  597. exit;
  598. }
  599. }
  600. $extraContentForm->addTextarea(
  601. 'extra_content',
  602. null,
  603. ['id' => 'extra_content']
  604. );
  605. $extraContentFormRenderer->setElementTemplate(
  606. '<div class="form-group">{element}</div>',
  607. 'extra_content'
  608. );
  609. $extraContentForm->addElement(
  610. 'hidden',
  611. 'block',
  612. null,
  613. array(
  614. 'id' => 'extra-block'
  615. )
  616. );
  617. $extraContentForm->addButtonExport(
  618. get_lang('Save'),
  619. 'submit_extra_content'
  620. );
  621. $tpl->assign('extraDataForm', $extraContentForm->returnForm());
  622. }
  623. // The template contains the call to the AJAX version checker
  624. $admin_template = $tpl->get_template('admin/settings_index.tpl');
  625. $content = $tpl->fetch($admin_template);
  626. $tpl->assign('content', $content);
  627. $tpl->display_one_col_template();