index.php 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920
  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. [
  87. 'url' => 'user_list.php',
  88. 'label' => get_lang('UserList'),
  89. ],
  90. [
  91. 'url' => 'user_add.php',
  92. 'label' => get_lang('AddUsers'),
  93. ],
  94. [
  95. 'url' => 'user_export.php',
  96. 'label' => get_lang('ExportUserListXMLCSV'),
  97. ],
  98. [
  99. 'url' => 'user_import.php',
  100. 'label' => get_lang('ImportUserListXMLCSV'),
  101. ],
  102. [
  103. 'url' => 'user_update_import.php',
  104. 'label' => get_lang('EditUserListCSV'),
  105. ],
  106. ];
  107. if (isset($extAuthSource) && isset($extAuthSource['extldap']) && count($extAuthSource['extldap']) > 0) {
  108. $items[] = [
  109. 'url' => 'ldap_users_list.php',
  110. 'label' => get_lang('ImportLDAPUsersIntoPlatform'),
  111. ];
  112. }
  113. $items[] = [
  114. 'url' => 'extra_fields.php?type=user',
  115. 'label' => get_lang('ManageUserFields'),
  116. ];
  117. $items[] = [
  118. 'url' => 'usergroups.php',
  119. 'label' => get_lang('Classes'),
  120. ];
  121. if (api_get_configuration_value('show_link_request_hrm_user')) {
  122. $items[] = [
  123. 'url' => 'user_linking_requests.php',
  124. 'label' => get_lang('UserLinkingRequests'),
  125. ];
  126. }
  127. } else {
  128. $items = [
  129. [
  130. 'url' => 'user_list.php',
  131. 'label' => get_lang('UserList'),
  132. ],
  133. [
  134. 'url' => 'user_add.php',
  135. 'label' => get_lang('AddUsers'),
  136. ],
  137. [
  138. 'url' => 'user_import.php',
  139. 'label' => get_lang('ImportUserListXMLCSV'),
  140. ],
  141. [
  142. 'url' => 'usergroups.php',
  143. 'label' => get_lang('Classes'),
  144. ],
  145. ];
  146. if (api_is_session_admin()) {
  147. if ('true' === api_get_setting('limit_session_admin_role')) {
  148. $items = array_filter($items, function (array $item) {
  149. $urls = ['user_list.php', 'user_add.php'];
  150. return in_array($item['url'], $urls);
  151. });
  152. }
  153. if (true === api_get_configuration_value('limit_session_admin_list_users')) {
  154. $items = array_filter($items, function (array $item) {
  155. $urls = ['user_list.php'];
  156. return !in_array($item['url'], $urls);
  157. });
  158. }
  159. }
  160. }
  161. $blocks['users']['items'] = $items;
  162. $blocks['users']['extra'] = null;
  163. if (api_is_platform_admin()) {
  164. /* Courses */
  165. $blocks['courses']['icon'] = Display::return_icon(
  166. 'course.png',
  167. get_lang('Courses'),
  168. [],
  169. ICON_SIZE_MEDIUM,
  170. false
  171. );
  172. $blocks['courses']['label'] = api_ucfirst(get_lang('Courses'));
  173. $blocks['courses']['class'] = 'block-admin-courses';
  174. $blocks['courses']['editable'] = true;
  175. $coursesBlockExtraFile = "{$adminExtraContentDir}block-admin-courses_extra.html";
  176. if (file_exists($coursesBlockExtraFile)) {
  177. $blocks['courses']['extraContent'] = file_get_contents($coursesBlockExtraFile);
  178. }
  179. $search_form = ' <form method="get" class="form-inline" action="course_list.php">
  180. <div class="form-group">
  181. <input class="form-control" type="text" name="keyword" value=""
  182. aria-label="'.get_lang('Search').'">
  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['courses']['search_form'] = $search_form;
  189. $items = [];
  190. $items[] = [
  191. 'url' => 'course_list.php',
  192. 'label' => get_lang('CourseList'),
  193. ];
  194. $items[] = [
  195. 'url' => 'course_add.php',
  196. 'label' => get_lang('AddCourse'),
  197. ];
  198. if (api_get_setting('course_validation') == 'true') {
  199. $items[] = [
  200. 'url' => 'course_request_review.php',
  201. 'label' => get_lang('ReviewCourseRequests'),
  202. ];
  203. $items[] = [
  204. 'url' => 'course_request_accepted.php',
  205. 'label' => get_lang('AcceptedCourseRequests'),
  206. ];
  207. $items[] = [
  208. 'url' => 'course_request_rejected.php',
  209. 'label' => get_lang('RejectedCourseRequests'),
  210. ];
  211. }
  212. $items[] = [
  213. 'url' => 'course_export.php',
  214. 'label' => get_lang('ExportCourses'),
  215. ];
  216. $items[] = [
  217. 'url' => 'course_import.php',
  218. 'label' => get_lang('ImportCourses'),
  219. ];
  220. $items[] = [
  221. 'url' => 'course_category.php',
  222. 'label' => get_lang('AdminCategories'),
  223. ];
  224. $items[] = [
  225. 'url' => 'subscribe_user2course.php',
  226. 'label' => get_lang('AddUsersToACourse'),
  227. ];
  228. $items[] = [
  229. 'url' => 'course_user_import.php',
  230. 'label' => get_lang('ImportUsersToACourse'),
  231. ];
  232. //$items[] = [
  233. // 'url'=>'course_intro_pdf_import.php',
  234. // 'label' => get_lang('ImportPDFIntroToCourses'),
  235. //];
  236. if (api_get_setting('gradebook_enable_grade_model') == 'true') {
  237. $items[] = [
  238. 'url' => 'grade_models.php',
  239. 'label' => get_lang('GradeModel'),
  240. ];
  241. }
  242. if (isset($extAuthSource) && isset($extAuthSource['ldap']) && count($extAuthSource['ldap']) > 0) {
  243. $items[] = [
  244. 'url' => 'ldap_import_students.php',
  245. 'label' => get_lang('ImportLDAPUsersIntoCourse'),
  246. ];
  247. }
  248. $items[] = [
  249. 'url' => 'extra_fields.php?type=course',
  250. 'label' => get_lang('ManageCourseFields'),
  251. ];
  252. $items[] = [
  253. 'url' => 'questions.php',
  254. 'label' => get_lang('Questions'),
  255. ];
  256. $blocks['courses']['items'] = $items;
  257. $blocks['courses']['extra'] = null;
  258. /* Platform */
  259. $blocks['platform']['icon'] = Display::return_icon(
  260. 'platform.png',
  261. get_lang('Platform'),
  262. [],
  263. ICON_SIZE_MEDIUM,
  264. false
  265. );
  266. $blocks['platform']['label'] = api_ucfirst(get_lang('Platform'));
  267. $blocks['platform']['class'] = 'block-admin-platform';
  268. $blocks['platform']['editable'] = true;
  269. $platformBlockExtraFile = "{$adminExtraContentDir}block-admin-platform_extra.html";
  270. if (file_exists($platformBlockExtraFile)) {
  271. $blocks['platform']['extraContent'] = file_get_contents($platformBlockExtraFile);
  272. }
  273. $search_form = ' <form method="get" action="settings.php" class="form-inline">
  274. <div class="form-group">
  275. <input class="form-control"
  276. type="text"
  277. name="search_field" value=""
  278. aria-label="'.get_lang('Search').'" >
  279. <input type="hidden" value="search_setting" name="category">
  280. <button class="btn btn-default" type="submit">
  281. <em class="fa fa-search"></em> '.get_lang('Search').'
  282. </button>
  283. </div>
  284. </form>';
  285. $blocks['platform']['search_form'] = $search_form;
  286. $items = [];
  287. $items[] = [
  288. 'url' => 'settings.php',
  289. 'label' => get_lang('PlatformConfigSettings'),
  290. ];
  291. $items[] = [
  292. 'url' => 'languages.php',
  293. 'label' => get_lang('Languages'),
  294. ];
  295. $items[] = [
  296. 'url' => 'settings.php?category=Plugins',
  297. 'label' => get_lang('Plugins'),
  298. ];
  299. $items[] = [
  300. 'url' => 'settings.php?category=Regions',
  301. 'label' => get_lang('Regions'),
  302. ];
  303. $items[] = [
  304. 'url' => 'system_announcements.php',
  305. 'label' => get_lang('SystemAnnouncements'),
  306. ];
  307. $items[] = [
  308. 'url' => api_get_path(WEB_CODE_PATH).'calendar/agenda_js.php?type=admin',
  309. 'label' => get_lang('GlobalAgenda'),
  310. ];
  311. $items[] = [
  312. 'url' => 'configure_homepage.php',
  313. 'label' => get_lang('ConfigureHomePage'),
  314. ];
  315. $items[] = [
  316. 'url' => 'configure_inscription.php',
  317. 'label' => get_lang('ConfigureInscription'),
  318. ];
  319. $items[] = [
  320. 'url' => 'statistics/index.php',
  321. 'label' => get_lang('Statistics'),
  322. ];
  323. $items[] = [
  324. 'url' => api_get_path(WEB_CODE_PATH).'mySpace/company_reports.php',
  325. 'label' => get_lang('Reports'),
  326. ];
  327. $items[] = [
  328. 'url' => api_get_path(WEB_CODE_PATH).'admin/teacher_time_report.php',
  329. 'label' => get_lang('TeacherTimeReport'),
  330. ];
  331. if (api_get_configuration_value('chamilo_cms')) {
  332. $items[] = [
  333. 'url' => api_get_path(WEB_PATH).'web/app_dev.php/administration/dashboard',
  334. 'label' => get_lang('CMS'),
  335. ];
  336. }
  337. /* Event settings */
  338. if (api_get_setting('activate_email_template') == 'true') {
  339. // @deprecated to be removed in 2.x
  340. $items[] = [
  341. 'url' => 'event_controller.php?action=listing',
  342. 'label' => get_lang('EventMessageManagement'),
  343. ];
  344. }
  345. $items[] = [
  346. 'url' => 'extra_field_list.php',
  347. 'label' => get_lang('ExtraFields'),
  348. ];
  349. if (!empty($_configuration['multiple_access_urls'])) {
  350. if (api_is_global_platform_admin()) {
  351. $items[] = [
  352. 'url' => 'access_urls.php',
  353. 'label' => get_lang('ConfigureMultipleAccessURLs'),
  354. ];
  355. }
  356. }
  357. if (api_get_plugin_setting('dictionary', 'enable_plugin_dictionary') == 'true') {
  358. $items[] = [
  359. 'url' => api_get_path(WEB_PLUGIN_PATH).'dictionary/terms.php',
  360. 'label' => get_lang('Dictionary'),
  361. ];
  362. }
  363. if (api_get_setting('allow_terms_conditions') == 'true') {
  364. $items[] = [
  365. 'url' => 'legal_add.php',
  366. 'label' => get_lang('TermsAndConditions'),
  367. ];
  368. }
  369. if (api_get_configuration_value('mail_template_system')) {
  370. $items[] = [
  371. 'url' => api_get_path(WEB_CODE_PATH).'mail_template/list.php',
  372. 'label' => get_lang('MailTemplate'),
  373. ];
  374. }
  375. $blocks['platform']['items'] = $items;
  376. $blocks['platform']['extra'] = null;
  377. }
  378. /* Sessions */
  379. $blocks['sessions']['icon'] = Display::return_icon(
  380. 'session.png',
  381. get_lang('Sessions'),
  382. [],
  383. ICON_SIZE_MEDIUM,
  384. false
  385. );
  386. $blocks['sessions']['label'] = api_ucfirst(get_lang('Sessions'));
  387. $blocks['sessions']['class'] = 'block-admin-sessions';
  388. $sessionsBlockExtraFile = "{$adminExtraContentDir}block-admin-sessions_extra.html";
  389. if (file_exists($sessionsBlockExtraFile)) {
  390. $blocks['sessions']['extraContent'] = file_get_contents($sessionsBlockExtraFile);
  391. }
  392. if (api_is_platform_admin()) {
  393. $blocks['sessions']['editable'] = true;
  394. }
  395. $sessionPath = api_get_path(WEB_CODE_PATH).'session/';
  396. $search_form = ' <form method="GET" class="form-inline" action="'.$sessionPath.'session_list.php">
  397. <div class="form-group">
  398. <input class="form-control"
  399. type="text"
  400. name="keyword"
  401. value=""
  402. aria-label="'.get_lang('Search').'">
  403. <button class="btn btn-default" type="submit">
  404. <em class="fa fa-search"></em> '.get_lang('Search').'
  405. </button>
  406. </div>
  407. </form>';
  408. $blocks['sessions']['search_form'] = $search_form;
  409. $items = [];
  410. $items[] = [
  411. 'url' => $sessionPath.'session_list.php',
  412. 'label' => get_lang('ListSession'),
  413. ];
  414. $items[] = [
  415. 'url' => $sessionPath.'session_add.php',
  416. 'label' => get_lang('AddSession'),
  417. ];
  418. $items[] = [
  419. 'url' => $sessionPath.'session_category_list.php',
  420. 'label' => get_lang('ListSessionCategory'),
  421. ];
  422. $items[] = [
  423. 'url' => $sessionPath.'session_import.php',
  424. 'label' => get_lang('ImportSessionListXMLCSV'),
  425. ];
  426. $items[] = [
  427. 'url' => $sessionPath.'session_import_drh.php',
  428. 'label' => get_lang('ImportSessionDrhList'),
  429. ];
  430. if (isset($extAuthSource) && isset($extAuthSource['ldap']) && count($extAuthSource['ldap']) > 0) {
  431. $items[] = [
  432. 'url' => 'ldap_import_students_to_session.php',
  433. 'label' => get_lang('ImportLDAPUsersIntoSession'),
  434. ];
  435. }
  436. $items[] = [
  437. 'url' => $sessionPath.'session_export.php',
  438. 'label' => get_lang('ExportSessionListXMLCSV'),
  439. ];
  440. if (api_is_global_platform_admin()) {
  441. $items[] = [
  442. 'url' => '../coursecopy/copy_course_session.php',
  443. 'label' => get_lang('CopyFromCourseInSessionToAnotherSession'),
  444. ];
  445. }
  446. $allowCareer = api_get_configuration_value('allow_session_admin_read_careers');
  447. if (api_is_platform_admin() || ($allowCareer && api_is_session_admin())) {
  448. // option only visible in development mode. Enable through code if required
  449. if (is_dir(api_get_path(SYS_TEST_PATH).'datafiller/')) {
  450. $items[] = [
  451. 'url' => 'user_move_stats.php',
  452. 'label' => get_lang('MoveUserStats'),
  453. ];
  454. }
  455. $items[] = [
  456. 'url' => 'career_dashboard.php',
  457. 'label' => get_lang('CareersAndPromotions'),
  458. ];
  459. $items[] = [
  460. 'url' => 'extra_fields.php?type=session',
  461. 'label' => get_lang('ManageSessionFields'),
  462. ];
  463. $items[] = [
  464. 'url' => 'resource_sequence.php',
  465. 'label' => get_lang('ResourcesSequencing'),
  466. ];
  467. }
  468. $blocks['sessions']['items'] = $items;
  469. $blocks['sessions']['extra'] = null;
  470. /* Settings */
  471. if (api_is_platform_admin()) {
  472. $blocks['settings']['icon'] = Display::return_icon(
  473. 'settings.png',
  474. get_lang('System'),
  475. [],
  476. ICON_SIZE_MEDIUM,
  477. false
  478. );
  479. $blocks['settings']['label'] = api_ucfirst(get_lang('System'));
  480. $blocks['settings']['class'] = 'block-admin-settings';
  481. $items = [];
  482. $items[] = [
  483. 'url' => 'archive_cleanup.php',
  484. 'label' => get_lang('ArchiveDirCleanup'),
  485. ];
  486. $items[] = [
  487. 'url' => 'special_exports.php',
  488. 'label' => get_lang('SpecialExports'),
  489. ];
  490. $items[] = [
  491. 'url' => 'system_status.php',
  492. 'label' => get_lang('SystemStatus'),
  493. ];
  494. if (is_dir(api_get_path(SYS_TEST_PATH).'datafiller/')) {
  495. $items[] = [
  496. 'url' => 'filler.php',
  497. 'label' => get_lang('DataFiller'),
  498. ];
  499. }
  500. if (is_dir(api_get_path(SYS_TEST_PATH))) {
  501. $items[] = [
  502. 'url' => 'email_tester.php',
  503. 'label' => get_lang('EMailTester'),
  504. ];
  505. }
  506. $items[] = [
  507. 'url' => api_get_path(WEB_CODE_PATH).'ticket/tickets.php',
  508. 'label' => get_lang('TicketSystem'),
  509. ];
  510. if (api_get_configuration_value('db_manager_enabled') == true &&
  511. api_is_global_platform_admin()
  512. ) {
  513. $host = $_configuration['db_host'];
  514. $username = $_configuration['db_user'];
  515. $databaseName = $_configuration['main_database'];
  516. $items[] = [
  517. 'url' => "db.php?username=$username&db=$databaseName&server=$host",
  518. 'label' => get_lang('DatabaseManager'),
  519. ];
  520. }
  521. $blocks['settings']['items'] = $items;
  522. $blocks['settings']['extra'] = null;
  523. $blocks['settings']['search_form'] = null;
  524. // Skills
  525. if (Skill::isToolAvailable()) {
  526. $blocks['skills']['icon'] = Display::return_icon(
  527. 'skill-badges.png',
  528. get_lang('Skills'),
  529. [],
  530. ICON_SIZE_MEDIUM,
  531. false
  532. );
  533. $blocks['skills']['label'] = get_lang('Skills');
  534. $blocks['skills']['class'] = 'block-admin-skills';
  535. $items = [];
  536. $items[] = [
  537. 'url' => 'skills_wheel.php',
  538. 'label' => get_lang('SkillsWheel'),
  539. ];
  540. $items[] = [
  541. 'url' => 'skills_import.php',
  542. 'label' => get_lang('SkillsImport'),
  543. ];
  544. $items[] = [
  545. 'url' => 'skill_list.php',
  546. 'label' => get_lang('ManageSkills'),
  547. ];
  548. $items[] = [
  549. 'url' => 'skill.php',
  550. 'label' => get_lang('ManageSkillsLevels'),
  551. ];
  552. $items[] = [
  553. 'url' => api_get_path(WEB_CODE_PATH).'social/skills_ranking.php',
  554. 'label' => get_lang('SkillsRanking'),
  555. ];
  556. $items[] = [
  557. 'url' => 'skills_gradebook.php',
  558. 'label' => get_lang('SkillsAndGradebooks'),
  559. ];
  560. /*$items[] = [
  561. 'url' => api_get_path(WEB_CODE_PATH).'admin/skill_badge.php',
  562. 'label' => get_lang('Badges'),
  563. ];*/
  564. $blocks['skills']['items'] = $items;
  565. $blocks['skills']['extra'] = null;
  566. $blocks['skills']['search_form'] = null;
  567. }
  568. $allow = api_get_configuration_value('gradebook_dependency');
  569. if ($allow) {
  570. $blocks['gradebook']['icon'] = Display::return_icon(
  571. 'gradebook.png',
  572. get_lang('Gradebook'),
  573. [],
  574. ICON_SIZE_MEDIUM,
  575. false
  576. );
  577. $blocks['gradebook']['label'] = get_lang('Gradebook');
  578. $blocks['gradebook']['class'] = 'block-admin-gradebook';
  579. $items = [];
  580. $items[] = [
  581. 'url' => 'gradebook_list.php',
  582. 'label' => get_lang('List'),
  583. ];
  584. $blocks['gradebook']['items'] = $items;
  585. $blocks['gradebook']['extra'] = null;
  586. $blocks['gradebook']['search_form'] = null;
  587. }
  588. }
  589. if (api_is_platform_admin()) {
  590. /* Plugins */
  591. global $_plugins;
  592. if (isset($_plugins['menu_administrator']) &&
  593. count($_plugins['menu_administrator']) > 0
  594. ) {
  595. $menuAdministratorItems = $_plugins['menu_administrator'];
  596. if ($menuAdministratorItems) {
  597. $blocks['plugins']['icon'] = Display::return_icon(
  598. 'plugins.png',
  599. get_lang('Plugins'),
  600. [],
  601. ICON_SIZE_MEDIUM,
  602. false
  603. );
  604. $blocks['plugins']['label'] = get_lang('Plugins');
  605. $blocks['plugins']['class'] = 'block-admin-platform';
  606. $blocks['plugins']['editable'] = true;
  607. $plugin_obj = new AppPlugin();
  608. $items = [];
  609. foreach ($menuAdministratorItems as $pluginName) {
  610. $pluginInfo = $plugin_obj->getPluginInfo($pluginName, true);
  611. /** @var \Plugin $plugin */
  612. $plugin = $pluginInfo['obj'];
  613. $pluginUrl = $plugin->getAdminUrl();
  614. if (empty($pluginUrl)) {
  615. continue;
  616. }
  617. $items[] = [
  618. 'url' => $pluginUrl,
  619. 'label' => $pluginInfo['title'],
  620. ];
  621. }
  622. $blocks['plugins']['items'] = $items;
  623. $blocks['plugins']['extra'] = '';
  624. }
  625. }
  626. if (!api_get_configuration_value('disable_gdpr')) {
  627. // Data protection
  628. $blocks['data_privacy']['icon'] = Display::return_icon(
  629. 'platform.png',
  630. get_lang('Platform'),
  631. [],
  632. ICON_SIZE_MEDIUM,
  633. false
  634. );
  635. $blocks['data_privacy']['label'] = api_ucfirst(get_lang('PersonalDataPrivacy'));
  636. $blocks['data_privacy']['class'] = 'block-admin-platform';
  637. $blocks['data_privacy']['editable'] = false;
  638. $items = [];
  639. $items[] = [
  640. 'url' => api_get_path(WEB_CODE_PATH).'admin/user_list_consent.php',
  641. 'label' => get_lang('UserList'),
  642. ];
  643. $blocks['data_privacy']['items'] = $items;
  644. $blocks['data_privacy']['extra'] = null;
  645. $blocks['data_privacy']['search_form'] = null;
  646. }
  647. /* Chamilo.org */
  648. $blocks['chamilo']['icon'] = Display::return_icon(
  649. 'platform.png',
  650. 'Chamilo.org',
  651. [],
  652. ICON_SIZE_MEDIUM,
  653. false
  654. );
  655. $blocks['chamilo']['label'] = 'Chamilo.org';
  656. $blocks['chamilo']['class'] = 'block-admin-chamilo';
  657. $items = [];
  658. $items[] = [
  659. 'url' => 'https://chamilo.org/',
  660. 'label' => get_lang('ChamiloHomepage'),
  661. ];
  662. $items[] = [
  663. 'url' => 'https://forum.chamilo.org/',
  664. 'label' => get_lang('ChamiloForum'),
  665. ];
  666. $items[] = [
  667. 'url' => '../../documentation/installation_guide.html',
  668. 'label' => get_lang('InstallationGuide'),
  669. ];
  670. $items[] = [
  671. 'url' => '../../documentation/changelog.html',
  672. 'label' => get_lang('ChangesInLastVersion'),
  673. ];
  674. $items[] = [
  675. 'url' => '../../documentation/credits.html',
  676. 'label' => get_lang('ContributorsList'),
  677. ];
  678. $items[] = [
  679. 'url' => '../../documentation/security.html',
  680. 'label' => get_lang('SecurityGuide'),
  681. ];
  682. $items[] = [
  683. 'url' => '../../documentation/optimization.html',
  684. 'label' => get_lang('OptimizationGuide'),
  685. ];
  686. $items[] = [
  687. 'url' => 'https://chamilo.org/extensions',
  688. 'label' => get_lang('ChamiloExtensions'),
  689. ];
  690. $items[] = [
  691. 'url' => 'https://chamilo.org/providers',
  692. 'label' => get_lang('ChamiloOfficialServicesProviders'),
  693. ];
  694. $blocks['chamilo']['items'] = $items;
  695. $blocks['chamilo']['extra'] = null;
  696. $blocks['chamilo']['search_form'] = null;
  697. // Version check
  698. $blocks['version_check']['icon'] = Display::return_icon(
  699. 'platform.png',
  700. 'Chamilo.org',
  701. [],
  702. ICON_SIZE_MEDIUM,
  703. false
  704. );
  705. $blocks['version_check']['label'] = get_lang('VersionCheck');
  706. $blocks['version_check']['extra'] = '<div class="admin-block-version"></div>';
  707. $blocks['version_check']['search_form'] = null;
  708. $blocks['version_check']['items'] = '<div class="block-admin-version_check"></div>';
  709. $blocks['version_check']['class'] = '';
  710. // Check Hook Event for Admin Block Object
  711. if (!empty($hook)) {
  712. // If not empty, then notify Post process to Hook Observers for Admin Block
  713. $hook->setEventData(['blocks' => $blocks]);
  714. $data = $hook->notifyAdminBlock(HOOK_EVENT_TYPE_POST);
  715. // Check if blocks data is not null
  716. if (isset($data['blocks'])) {
  717. // Get modified blocks
  718. $blocks = $data['blocks'];
  719. }
  720. }
  721. //Hack for fix migration on session_rel_user
  722. $tableColumns = Database::getManager()
  723. ->getConnection()
  724. ->getSchemaManager()
  725. ->listTableColumns(
  726. Database::get_main_table(TABLE_MAIN_SESSION_USER)
  727. );
  728. if (!array_key_exists('duration', $tableColumns)) {
  729. try {
  730. $dbSchema = Database::getManager()->getConnection()->getSchemaManager();
  731. $durationColumn = new \Doctrine\DBAL\Schema\Column(
  732. 'duration',
  733. Doctrine\DBAL\Types\Type::getType(\Doctrine\DBAL\Types\Type::INTEGER),
  734. ['notnull' => false]
  735. );
  736. $tableDiff = new \Doctrine\DBAL\Schema\TableDiff('session_rel_user', [$durationColumn]);
  737. $dbSchema->alterTable($tableDiff);
  738. } catch (Exception $e) {
  739. error_log($e->getMessage());
  740. }
  741. }
  742. //end hack
  743. }
  744. $admin_ajax_url = api_get_path(WEB_AJAX_PATH).'admin.ajax.php';
  745. $tpl = new Template();
  746. // Display the Site Use Cookie Warning Validation
  747. $useCookieValidation = api_get_setting('cookie_warning');
  748. if ($useCookieValidation === 'true') {
  749. if (isset($_POST['acceptCookies'])) {
  750. api_set_site_use_cookie_warning_cookie();
  751. } elseif (!api_site_use_cookie_warning_cookie_exist()) {
  752. if (Template::isToolBarDisplayedForUser()) {
  753. $tpl->assign('toolBarDisplayed', true);
  754. } else {
  755. $tpl->assign('toolBarDisplayed', false);
  756. }
  757. $tpl->assign('displayCookieUsageWarning', true);
  758. }
  759. }
  760. $tpl->assign('web_admin_ajax_url', $admin_ajax_url);
  761. $tpl->assign('blocks', $blocks);
  762. if (api_is_platform_admin()) {
  763. $extraContentForm = new FormValidator(
  764. 'block_extra_data',
  765. 'post',
  766. '#',
  767. null,
  768. [
  769. 'id' => 'block-extra-data',
  770. 'class' => '',
  771. ],
  772. FormValidator::LAYOUT_BOX_NO_LABEL
  773. );
  774. $extraContentFormRenderer = $extraContentForm->getDefaultRenderer();
  775. if ($extraContentForm->validate()) {
  776. $extraData = $extraContentForm->getSubmitValues();
  777. $extraData = array_map(['Security', 'remove_XSS'], $extraData);
  778. if (!empty($extraData['block'])) {
  779. if (!is_dir($adminExtraContentDir)) {
  780. mkdir(
  781. $adminExtraContentDir,
  782. api_get_permissions_for_new_directories(),
  783. true
  784. );
  785. }
  786. if (!is_writable($adminExtraContentDir)) {
  787. die;
  788. }
  789. $fullFilePath = $adminExtraContentDir.$extraData['block'];
  790. $fullFilePath .= "_extra.html";
  791. file_put_contents($fullFilePath, $extraData['extra_content']);
  792. header('Location: '.api_get_self());
  793. exit;
  794. }
  795. }
  796. $extraContentForm->addTextarea(
  797. 'extra_content',
  798. null,
  799. ['id' => 'extra_content']
  800. );
  801. $extraContentFormRenderer->setElementTemplate(
  802. '<div class="form-group">{element}</div>',
  803. 'extra_content'
  804. );
  805. $extraContentForm->addElement(
  806. 'hidden',
  807. 'block',
  808. null,
  809. [
  810. 'id' => 'extra-block',
  811. ]
  812. );
  813. $extraContentForm->addButtonExport(
  814. get_lang('Save'),
  815. 'submit_extra_content'
  816. );
  817. $tpl->assign('extraDataForm', $extraContentForm->returnForm());
  818. }
  819. // The template contains the call to the AJAX version checker
  820. $admin_template = $tpl->get_template('admin/settings_index.tpl');
  821. $content = $tpl->fetch($admin_template);
  822. $tpl->assign('content', $content);
  823. $tpl->display_one_col_template();