index.php 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. use Chamilo\CoreBundle\Framework\Container;
  4. use Chamilo\CoreBundle\Hook\HookAdminBlock;
  5. use League\Flysystem\Filesystem;
  6. /**
  7. * Index page of the admin tools.
  8. *
  9. * @package chamilo.admin
  10. */
  11. // Resetting the course id.
  12. $cidReset = true;
  13. // Including some necessary chamilo files.
  14. require_once __DIR__.'/../inc/global.inc.php';
  15. // Setting the section (for the tabs).
  16. $this_section = SECTION_PLATFORM_ADMIN;
  17. // Access restrictions.
  18. api_protect_admin_script(true);
  19. $nameTools = get_lang('Administration');
  20. $accessUrlId = 0;
  21. // Displaying the header
  22. if (api_is_platform_admin()) {
  23. if (is_dir(api_get_path(SYS_ARCHIVE_PATH)) &&
  24. !is_writable(api_get_path(SYS_ARCHIVE_PATH))
  25. ) {
  26. Display::addFlash(
  27. Display::return_message(get_lang('The app/cache/ directory, used by this tool, is not writeable. Please contact your platform administrator.'), 'warning')
  28. );
  29. }
  30. /* ACTION HANDLING */
  31. if (!empty($_POST['Register'])) {
  32. api_register_campus(!$_POST['donotlistcampus']);
  33. $message = Display:: return_message(get_lang('Version check enabled'), 'confirmation');
  34. Display::addFlash($message);
  35. }
  36. $keyword_url = Security::remove_XSS((empty($_GET['keyword']) ? '' : $_GET['keyword']));
  37. }
  38. $blocks = [];
  39. // Instantiate Hook Event for Admin Block
  40. $hook = Container::instantiateHook(HookAdminBlock::class);
  41. if (!empty($hook)) {
  42. // If not empty, then notify Pre process to Hook Observers for Admin Block
  43. $hook->setEventData(['blocks' => $blocks]);
  44. $data = $hook->notifyAdminBlock(HOOK_EVENT_TYPE_PRE);
  45. // Check if blocks data is not null
  46. if (isset($data['blocks'])) {
  47. // Get modified blocks
  48. $blocks = $data['blocks'];
  49. }
  50. }
  51. /* Users */
  52. $blocks['users']['icon'] = Display::return_icon(
  53. 'members.png',
  54. get_lang('User management'),
  55. [],
  56. ICON_SIZE_MEDIUM,
  57. false
  58. );
  59. $blocks['users']['description'] = get_lang('Here you can manage registered users within your platform');
  60. $blocks['users']['label'] = api_ucfirst(get_lang('User management'));
  61. $blocks['users']['class'] = 'block-admin-users';
  62. $search_form = '
  63. <form method="get" class="form-inline" action="user_list.php">
  64. <div class="form-group mb-2">
  65. <input class="form-control" type="text" name="keyword" value=""
  66. aria-label="'.get_lang('Search').'">
  67. </div>
  68. <button class="btn btn-primary mb-2" type="submit">
  69. <em class="fa fa-search"></em> '.get_lang('Search').'
  70. </button>
  71. </form>';
  72. $blocks['users']['search_form'] = $search_form;
  73. if (api_is_platform_admin()) {
  74. $blocks['users']['editable'] = true;
  75. $items = [
  76. ['url' => 'user_list.php', 'label' => get_lang('User list')],
  77. ['url' => 'user_add.php', 'label' => get_lang('Add a user')],
  78. ['url' => 'user_export.php', 'label' => get_lang('ExportUser listXMLCSV')],
  79. ['url' => 'user_import.php', 'label' => get_lang('ImportUser listXMLCSV')],
  80. ['url' => 'user_update_import.php', 'label' => get_lang('EditUser listCSV')],
  81. ];
  82. if (isset($extAuthSource) && isset($extAuthSource['extldap']) && count($extAuthSource['extldap']) > 0) {
  83. $items[] = ['url' => 'ldap_users_list.php', 'label' => get_lang('Import LDAP users into the platform')];
  84. }
  85. $items[] = ['url' => 'extra_fields.php?type=user', 'label' => get_lang('Profiling')];
  86. $items[] = ['url' => 'usergroups.php', 'label' => get_lang('Classes')];
  87. if (!api_get_configuration_value('disable_gdpr')) {
  88. $items[] = ['url' => 'user_list_consent.php', 'label' => get_lang('Users in consents list')];
  89. }
  90. if (api_get_configuration_value('show_link_request_hrm_user')) {
  91. $items[] = ['url' => 'user_linking_requests.php', 'label' => get_lang('Student linking requests')];
  92. }
  93. } else {
  94. $items = [
  95. ['url' => 'user_list.php', 'label' => get_lang('User list')],
  96. ['url' => 'user_add.php', 'label' => get_lang('Add a user')],
  97. ['url' => 'user_import.php', 'label' => get_lang('ImportUser listXMLCSV')],
  98. ['url' => 'usergroups.php', 'label' => get_lang('Classes')],
  99. ];
  100. if (api_is_session_admin()) {
  101. if ('true' === api_get_setting('limit_session_admin_role')) {
  102. $items = array_filter($items, function (array $item) {
  103. $urls = ['user_list.php', 'user_add.php'];
  104. return in_array($item['url'], $urls);
  105. });
  106. }
  107. if (true === api_get_configuration_value('limit_session_admin_list_users')) {
  108. $items = array_filter($items, function (array $item) {
  109. $urls = ['user_list.php'];
  110. return !in_array($item['url'], $urls);
  111. });
  112. }
  113. }
  114. }
  115. $blocks['users']['items'] = $items;
  116. $blocks['users']['extra'] = null;
  117. if (api_is_platform_admin()) {
  118. /* Courses */
  119. $blocks['courses']['icon'] = Display::return_icon(
  120. 'course.png',
  121. get_lang('Course management'),
  122. [],
  123. ICON_SIZE_MEDIUM,
  124. false
  125. );
  126. $blocks['courses']['label'] = api_ucfirst(get_lang('Course management'));
  127. $blocks['courses']['description'] = get_lang('Create and manage your courses in a simple way');
  128. $blocks['courses']['class'] = 'block-admin-courses';
  129. $blocks['courses']['editable'] = true;
  130. $search_form = ' <form method="get" class="form-inline" action="course_list.php">
  131. <div class="form-group mb-2">
  132. <input class="form-control" type="text" name="keyword" value=""
  133. aria-label="'.get_lang('Search').'">
  134. </div>
  135. <button class="btn btn-primary mb-2" type="submit">
  136. <em class="fa fa-search"></em> '.get_lang('Search').'
  137. </button>
  138. </form>';
  139. $blocks['courses']['search_form'] = $search_form;
  140. $items = [];
  141. $items[] = ['url' => 'course_list.php', 'label' => get_lang('Course list')];
  142. $items[] = ['url' => 'course_add.php', 'label' => get_lang('Add course')];
  143. if (api_get_setting('course_validation') == 'true') {
  144. $items[] = ['url' => 'course_request_review.php', 'label' => get_lang('Review incoming course requests')];
  145. $items[] = ['url' => 'course_request_accepted.php', 'label' => get_lang('Accepted course requests')];
  146. $items[] = ['url' => 'course_request_rejected.php', 'label' => get_lang('Rejected course requests')];
  147. }
  148. $items[] = ['url' => 'course_export.php', 'label' => get_lang('Export courses')];
  149. $items[] = ['url' => 'course_import.php', 'label' => get_lang('Import courses list')];
  150. $items[] = ['url' => 'course_category.php', 'label' => get_lang('Courses categories')];
  151. $items[] = ['url' => 'subscribe_user2course.php', 'label' => get_lang('Add a userToACourse')];
  152. $items[] = ['url' => 'course_user_import.php', 'label' => get_lang('Import users list')];
  153. if (api_get_setting('gradebook_enable_grade_model') == 'true') {
  154. $items[] = ['url' => 'grade_models.php', 'label' => get_lang('Grading model')];
  155. }
  156. if (isset($extAuthSource) && isset($extAuthSource['ldap']) && count($extAuthSource['ldap']) > 0) {
  157. $items[] = ['url' => 'ldap_import_students.php', 'label' => get_lang('Import LDAP users into a course')];
  158. }
  159. $items[] = ['url' => 'extra_fields.php?type=course', 'label' => get_lang('Manage extra fields for courses')];
  160. $items[] = [
  161. 'url' => api_get_path(WEB_CODE_PATH).'admin/teacher_time_report.php',
  162. 'label' => get_lang('Teachers time report'),
  163. ];
  164. $blocks['courses']['items'] = $items;
  165. $blocks['courses']['extra'] = null;
  166. /* Sessions */
  167. $blocks['sessions']['icon'] = Display::return_icon(
  168. 'session.png',
  169. get_lang('Sessions management'),
  170. [],
  171. ICON_SIZE_MEDIUM,
  172. false
  173. );
  174. $blocks['sessions']['label'] = api_ucfirst(get_lang('Sessions management'));
  175. $blocks['sessions']['description'] = get_lang('Create course packages for a certain time with training sessions.');
  176. $blocks['sessions']['class'] = 'block-admin-sessions';
  177. if (api_is_platform_admin()) {
  178. $blocks['sessions']['editable'] = true;
  179. }
  180. $sessionPath = api_get_path(WEB_CODE_PATH).'session/';
  181. $search_form = ' <form method="GET" class="form-inline" action="'.$sessionPath.'session_list.php">
  182. <div class="form-group mb-2">
  183. <input class="form-control"
  184. type="text"
  185. name="keyword"
  186. value=""
  187. aria-label="'.get_lang('Search').'">
  188. </div>
  189. <button class="btn btn-primary mb-2" type="submit">
  190. <em class="fa fa-search"></em> '.get_lang('Search').'
  191. </button>
  192. </form>';
  193. $blocks['sessions']['search_form'] = $search_form;
  194. $items = [];
  195. $items[] = ['url' => $sessionPath.'session_list.php', 'label' => get_lang('Training sessions list')];
  196. $items[] = ['url' => $sessionPath.'session_add.php', 'label' => get_lang('Add a training session')];
  197. $items[] = ['url' => $sessionPath.'session_category_list.php', 'label' => get_lang('Training sessions listCategory')];
  198. $items[] = ['url' => $sessionPath.'session_import.php', 'label' => get_lang('Import sessions list')];
  199. $items[] = ['url' => $sessionPath.'session_import_drh.php', 'label' => get_lang('Import list of HR directors into sessions')];
  200. if (isset($extAuthSource) && isset($extAuthSource['ldap']) && count($extAuthSource['ldap']) > 0) {
  201. $items[] = [
  202. 'url' => 'ldap_import_students_to_session.php',
  203. 'label' => get_lang('Import LDAP users into a session'),
  204. ];
  205. }
  206. $items[] = [
  207. 'url' => $sessionPath.'session_export.php',
  208. 'label' => get_lang('Export sessions list'),
  209. ];
  210. if (api_is_global_platform_admin()) {
  211. $items[] = [
  212. 'url' => '../coursecopy/copy_course_session.php',
  213. 'label' => get_lang('Copy from course in session to another session'),
  214. ];
  215. }
  216. $allowCareer = api_get_configuration_value('allow_session_admin_read_careers');
  217. if (api_is_platform_admin() || ($allowCareer && api_is_session_admin())) {
  218. // option only visible in development mode. Enable through code if required
  219. if (is_dir(api_get_path(SYS_TEST_PATH).'datafiller/')) {
  220. $items[] = ['url' => 'user_move_stats.php', 'label' => get_lang('Move users results from/to a session')];
  221. }
  222. $items[] = ['url' => 'career_dashboard.php', 'label' => get_lang('Careers and promotions')];
  223. $items[] = ['url' => 'extra_fields.php?type=session', 'label' => get_lang('Manage session fields')];
  224. }
  225. $blocks['sessions']['items'] = $items;
  226. $blocks['sessions']['extra'] = null;
  227. // Skills
  228. if (Skill::isToolAvailable()) {
  229. $blocks['skills']['icon'] = Display::return_icon(
  230. 'skill-badges.png',
  231. get_lang('Skills'),
  232. [],
  233. ICON_SIZE_MEDIUM,
  234. false
  235. );
  236. $blocks['skills']['label'] = get_lang('Skills and gradebook');
  237. $blocks['skills']['description'] = get_lang('Manage the skills of your users, through courses and badges');
  238. $blocks['skills']['class'] = 'block-admin-skills';
  239. $items = [];
  240. $items[] = [
  241. 'url' => 'skills_wheel.php',
  242. 'label' => get_lang('Skills wheel'),
  243. ];
  244. $items[] = [
  245. 'url' => 'skills_import.php',
  246. 'label' => get_lang('Skills import'),
  247. ];
  248. $items[] = [
  249. 'url' => 'skill_list.php',
  250. 'label' => get_lang('Manage skills'),
  251. ];
  252. $items[] = [
  253. 'url' => 'skill.php',
  254. 'label' => get_lang('Manage skillsLevels'),
  255. ];
  256. $items[] = [
  257. 'url' => api_get_path(WEB_CODE_PATH).'social/skills_ranking.php',
  258. 'label' => get_lang('Skills ranking'),
  259. ];
  260. $items[] = [
  261. 'url' => 'skills_gradebook.php',
  262. 'label' => get_lang('Skills and assessments'),
  263. ];
  264. /*$items[] = array(
  265. 'url' => api_get_path(WEB_CODE_PATH).'admin/skill_badge.php',
  266. 'label' => get_lang('Badges')
  267. );*/
  268. $allow = api_get_configuration_value('gradebook_dependency');
  269. if (!$allow) {
  270. $items[] = [
  271. 'url' => 'gradebook_list.php',
  272. 'label' => get_lang('List of qualifications'),
  273. ];
  274. }
  275. $blocks['skills']['items'] = $items;
  276. $blocks['skills']['extra'] = null;
  277. $blocks['skills']['search_form'] = null;
  278. }
  279. /* Platform */
  280. $blocks['platform']['icon'] = Display::return_icon(
  281. 'platform.png',
  282. get_lang('Platform management'),
  283. [],
  284. ICON_SIZE_MEDIUM,
  285. false
  286. );
  287. $blocks['platform']['label'] = api_ucfirst(get_lang('Platform management'));
  288. $blocks['platform']['description'] = get_lang('Configure your platform, view reports, publish and send announcements globally');
  289. $blocks['platform']['class'] = 'block-admin-platform';
  290. $blocks['platform']['editable'] = true;
  291. $search_form = ' <form method="get" action="'.api_get_path(WEB_PUBLIC_PATH).'admin/settings/search_settings'.'" class="form-inline">
  292. <div class="form-group mb-2">
  293. <input class="form-control"
  294. type="text"
  295. name="keyword" value=""
  296. aria-label="'.get_lang('Search').'" >
  297. </div>
  298. <button class="btn btn-primary mb-2" type="submit">
  299. <em class="fa fa-search"></em> '.get_lang('Search').'
  300. </button>
  301. </form>';
  302. $blocks['platform']['search_form'] = $search_form;
  303. //$url = Container::getRouter()->generate('chamilo_platform_settings', ['namespace' => 'platform']);
  304. $url = api_get_path(WEB_PUBLIC_PATH).'admin/settings/platform';
  305. $items = [];
  306. $items[] = ['url' => $url, 'label' => get_lang('Configuration settings')];
  307. $items[] = ['url' => 'languages.php', 'label' => get_lang('Languages')];
  308. $items[] = ['url' => 'settings.php?category=Plugins', 'label' => get_lang('Plugins')];
  309. $items[] = ['url' => 'settings.php?category=Regions', 'label' => get_lang('Regions')];
  310. $items[] = ['url' => 'system_announcements.php', 'label' => get_lang('Portal news')];
  311. $items[] = [
  312. 'url' => api_get_path(WEB_CODE_PATH).'calendar/agenda_js.php?type=admin',
  313. 'label' => get_lang('Global agenda'),
  314. ];
  315. // Replaced by page blocks
  316. //$items[] = ['url' => 'configure_homepage.php', 'label' => get_lang('Edit portal homepage')];
  317. $items[] = ['url' => 'configure_inscription.php', 'label' => get_lang('Setting the registration page')];
  318. $items[] = ['url' => 'statistics/index.php', 'label' => get_lang('Statistics')];
  319. $items[] = [
  320. 'url' => api_get_path(WEB_CODE_PATH).'mySpace/company_reports.php',
  321. 'label' => get_lang('Reports'),
  322. ];
  323. $items[] = [
  324. 'url' => api_get_path(WEB_CODE_PATH).'admin/teacher_time_report.php',
  325. 'label' => get_lang('Teachers time report'),
  326. ];
  327. if (api_get_configuration_value('chamilo_cms')) {
  328. $items[] = [
  329. 'url' => api_get_path(WEB_PATH).'web/app_dev.php/administration/dashboard',
  330. 'label' => get_lang('CMS'),
  331. ];
  332. }
  333. $items[] = ['url' => 'extra_field_list.php', 'label' => get_lang('Extra fields')];
  334. if (!empty($_configuration['multiple_access_urls'])) {
  335. if (api_is_global_platform_admin()) {
  336. $items[] = ['url' => 'access_urls.php', 'label' => get_lang('Configure multiple access URL')];
  337. }
  338. }
  339. if (api_get_plugin_setting('dictionary', 'enable_plugin_dictionary') == 'true') {
  340. $items[] = [
  341. 'url' => api_get_path(WEB_PLUGIN_PATH).'dictionary/terms.php',
  342. 'label' => get_lang('Dictionary'),
  343. ];
  344. }
  345. if (api_get_setting('allow_terms_conditions') == 'true') {
  346. $items[] = ['url' => 'legal_add.php', 'label' => get_lang('Terms and Conditions')];
  347. }
  348. $items[] = ['url' => api_get_path(WEB_PUBLIC_PATH).'admin/lti/', 'label' => get_lang('External tools')];
  349. $blocks['platform']['items'] = $items;
  350. $blocks['platform']['extra'] = null;
  351. }
  352. /* Settings */
  353. if (api_is_platform_admin()) {
  354. $blocks['settings']['icon'] = Display::return_icon(
  355. 'settings.png',
  356. get_lang('System'),
  357. [],
  358. ICON_SIZE_MEDIUM,
  359. false
  360. );
  361. $blocks['settings']['label'] = api_ucfirst(get_lang('System'));
  362. $blocks['settings']['description'] = get_lang('View the status of your server, perform performance tests');
  363. $blocks['settings']['class'] = 'block-admin-settings';
  364. $items = [];
  365. $items[] = [
  366. 'url' => 'archive_cleanup.php',
  367. 'label' => get_lang('Cleanup of cache and temporary files'),
  368. ];
  369. $items[] = [
  370. 'url' => 'special_exports.php',
  371. 'label' => get_lang('Special exports'),
  372. ];
  373. /*$items[] = [
  374. 'url' => 'periodic_export.php',
  375. 'label' => get_lang('PeriodicExport'),
  376. ];*/
  377. $items[] = [
  378. 'url' => 'system_status.php',
  379. 'label' => get_lang('System status'),
  380. ];
  381. if (is_dir(api_get_path(SYS_TEST_PATH).'datafiller/')) {
  382. $items[] = [
  383. 'url' => 'filler.php',
  384. 'label' => get_lang('Data filler'),
  385. ];
  386. }
  387. $items[] = [
  388. 'url' => 'resource_sequence.php',
  389. 'label' => get_lang('Resources sequencing'),
  390. ];
  391. if (is_dir(api_get_path(SYS_TEST_PATH))) {
  392. $items[] = [
  393. 'url' => 'email_tester.php',
  394. 'label' => get_lang('E-mail tester'),
  395. ];
  396. }
  397. $items[] = [
  398. 'url' => api_get_path(WEB_CODE_PATH).'ticket/tickets.php',
  399. 'label' => get_lang('Tickets'),
  400. ];
  401. if (api_get_configuration_value('db_manager_enabled') == true &&
  402. api_is_global_platform_admin()
  403. ) {
  404. $host = $_configuration['db_host'];
  405. $username = $_configuration['db_user'];
  406. $databaseName = $_configuration['main_database'];
  407. $items[] = [
  408. 'url' => "db.php?username=$username&db=$databaseName&server=$host",
  409. 'label' => get_lang('Database manager'),
  410. ];
  411. }
  412. $blocks['settings']['items'] = $items;
  413. $blocks['settings']['extra'] = null;
  414. $blocks['settings']['search_form'] = null;
  415. }
  416. if (api_is_platform_admin()) {
  417. /* Plugins */
  418. global $_plugins;
  419. if (isset($_plugins['menu_administrator']) &&
  420. count($_plugins['menu_administrator']) > 0
  421. ) {
  422. $menuAdministratorItems = $_plugins['menu_administrator'];
  423. if ($menuAdministratorItems) {
  424. $blocks['plugins']['icon'] = Display::return_icon(
  425. 'plugins.png',
  426. get_lang('Plugins'),
  427. [],
  428. ICON_SIZE_MEDIUM,
  429. false
  430. );
  431. $blocks['plugins']['label'] = get_lang('Plugins');
  432. $blocks['plugins']['class'] = 'block-admin-platform';
  433. $blocks['plugins']['editable'] = true;
  434. $plugin_obj = new AppPlugin();
  435. $items = [];
  436. foreach ($menuAdministratorItems as $pluginName) {
  437. $pluginInfo = $plugin_obj->getPluginInfo($pluginName, true);
  438. /** @var \Plugin $plugin */
  439. $plugin = $pluginInfo['obj'];
  440. $pluginUrl = $plugin->getAdminUrl();
  441. if (empty($pluginUrl)) {
  442. continue;
  443. }
  444. $items[] = [
  445. 'url' => $pluginUrl,
  446. 'label' => $pluginInfo['title'],
  447. ];
  448. }
  449. $blocks['plugins']['items'] = $items;
  450. $blocks['plugins']['extra'] = '';
  451. }
  452. }
  453. /* Chamilo.org */
  454. $blocks['chamilo']['icon'] = Display::return_icon(
  455. 'platform.png',
  456. 'Chamilo.org',
  457. [],
  458. ICON_SIZE_MEDIUM,
  459. false
  460. );
  461. $blocks['chamilo']['label'] = 'Chamilo.org';
  462. $blocks['chamilo']['description'] = get_lang('Learn more about Chamilo and its use, official references links');
  463. $blocks['chamilo']['class'] = 'block-admin-chamilo';
  464. $items = [];
  465. $items[] = ['url' => 'http://www.chamilo.org/', 'label' => get_lang('Chamilo homepage')];
  466. $items[] = ['url' => 'http://www.chamilo.org/forum', 'label' => get_lang('Chamilo forum')];
  467. $items[] = ['url' => '../../documentation/installation_guide.html', 'label' => get_lang('Installation guide')];
  468. $items[] = ['url' => '../../documentation/changelog.html', 'label' => get_lang('Changes in last version')];
  469. $items[] = ['url' => '../../documentation/credits.html', 'label' => get_lang('Contributors list')];
  470. $items[] = ['url' => '../../documentation/security.html', 'label' => get_lang('Security guide')];
  471. $items[] = ['url' => '../../documentation/optimization.html', 'label' => get_lang('Optimization guide')];
  472. $items[] = ['url' => 'http://www.chamilo.org/extensions', 'label' => get_lang('Chamilo extensions')];
  473. $items[] = [
  474. 'url' => 'http://www.chamilo.org/en/providers',
  475. 'label' => get_lang('Chamilo official services providers'),
  476. ];
  477. $blocks['chamilo']['items'] = $items;
  478. $blocks['chamilo']['extra'] = null;
  479. $blocks['chamilo']['search_form'] = null;
  480. // Version check
  481. $blocks['version_check']['icon'] = Display::return_icon(
  482. 'platform.png',
  483. 'Chamilo.org',
  484. [],
  485. ICON_SIZE_MEDIUM,
  486. false
  487. );
  488. $blocks['version_check']['label'] = get_lang('Version Check');
  489. $blocks['version_check']['extra'] = '<div class="admin-block-version"></div>';
  490. $blocks['version_check']['search_form'] = null;
  491. $blocks['version_check']['items'] = '<div class="block-admin-version_check"></div>';
  492. $blocks['version_check']['class'] = '';
  493. // Check Hook Event for Admin Block Object
  494. if (!empty($hook)) {
  495. // If not empty, then notify Post process to Hook Observers for Admin Block
  496. $hook->setEventData(['blocks' => $blocks]);
  497. $data = $hook->notifyAdminBlock(HOOK_EVENT_TYPE_POST);
  498. // Check if blocks data is not null
  499. if (isset($data['blocks'])) {
  500. // Get modified blocks
  501. $blocks = $data['blocks'];
  502. }
  503. }
  504. //Hack for fix migration on session_rel_user
  505. $tableColumns = Database::getManager()
  506. ->getConnection()
  507. ->getSchemaManager()
  508. ->listTableColumns(
  509. Database::get_main_table(TABLE_MAIN_SESSION_USER)
  510. );
  511. if (!array_key_exists('duration', $tableColumns)) {
  512. try {
  513. $dbSchema = Database::getManager()->getConnection()->getSchemaManager();
  514. $durationColumn = new \Doctrine\DBAL\Schema\Column(
  515. 'duration',
  516. Doctrine\DBAL\Types\Type::getType(\Doctrine\DBAL\Types\Type::INTEGER),
  517. ['notnull' => false]
  518. );
  519. $tableDiff = new \Doctrine\DBAL\Schema\TableDiff('session_rel_user', [$durationColumn]);
  520. $dbSchema->alterTable($tableDiff);
  521. } catch (Exception $e) {
  522. error_log($e->getMessage());
  523. }
  524. }
  525. //end hack
  526. }
  527. $admin_ajax_url = api_get_path(WEB_AJAX_PATH).'admin.ajax.php';
  528. $tpl = new Template();
  529. // Display the Site Use Cookie Warning Validation
  530. $useCookieValidation = api_get_setting('cookie_warning');
  531. if ($useCookieValidation === 'true') {
  532. if (isset($_POST['acceptCookies'])) {
  533. api_set_site_use_cookie_warning_cookie();
  534. } elseif (!api_site_use_cookie_warning_cookie_exist()) {
  535. if (Template::isToolBarDisplayedForUser()) {
  536. $tpl->assign('toolBarDisplayed', true);
  537. } else {
  538. $tpl->assign('toolBarDisplayed', false);
  539. }
  540. $tpl->assign('displayCookieUsageWarning', true);
  541. }
  542. }
  543. $tpl->assign('web_admin_ajax_url', $admin_ajax_url);
  544. $tpl->assign('web_public', api_get_path(WEB_PUBLIC_PATH));
  545. $tpl->assign('blocks_admin', $blocks);
  546. if (api_is_platform_admin()) {
  547. $extraContentForm = new FormValidator(
  548. 'block_extra_data',
  549. 'post',
  550. '#',
  551. null,
  552. [
  553. 'id' => 'block-extra-data',
  554. 'class' => '',
  555. ],
  556. FormValidator::LAYOUT_BOX_NO_LABEL
  557. );
  558. $extraContentFormRenderer = $extraContentForm->getDefaultRenderer();
  559. if ($extraContentForm->validate()) {
  560. $extraData = $extraContentForm->getSubmitValues();
  561. $extraData = array_map(['Security', 'remove_XSS'], $extraData);
  562. if (!empty($extraData['block'])) {
  563. //$fileSystem->put('admin/'.$extraData['block'].'_extra.html', $extraData['extra_content']);
  564. header('Location: '.api_get_self());
  565. exit;
  566. }
  567. }
  568. $extraContentForm->addTextarea(
  569. 'extra_content',
  570. null,
  571. ['id' => 'extra_content']
  572. );
  573. $extraContentFormRenderer->setElementTemplate(
  574. '<div class="form-group">{element}</div>',
  575. 'extra_content'
  576. );
  577. $extraContentForm->addElement(
  578. 'hidden',
  579. 'block',
  580. null,
  581. [
  582. 'id' => 'extra-block',
  583. ]
  584. );
  585. $extraContentForm->addButtonExport(
  586. get_lang('Save'),
  587. 'submit_extra_content'
  588. );
  589. $tpl->assign('extraDataForm', $extraContentForm->returnForm());
  590. }
  591. // The template contains the call to the AJAX version checker
  592. $template = $tpl->get_template('admin/index.html.twig');
  593. $content = $tpl->fetch($template);
  594. $tpl->assign('content', $content);
  595. $tpl->display_one_col_template();
  596. //$tpl->display($template);