index.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476
  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 '../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_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_PATH) . "home/$cleanUrl/admin/";
  25. }
  26. }
  27. // Displaying the header
  28. $message = '';
  29. if (api_is_platform_admin()) {
  30. if (is_dir(api_get_path(SYS_ARCHIVE_PATH)) && !is_writable(api_get_path(SYS_ARCHIVE_PATH))) {
  31. $message = Display::return_message(get_lang('ArchivesDirectoryNotWriteableContactAdmin'), 'warning');
  32. }
  33. /* ACTION HANDLING */
  34. if (!empty($_POST['Register'])) {
  35. api_register_campus(!$_POST['donotlistcampus']);
  36. $message = Display :: return_message(get_lang('VersionCheckEnabled'), 'confirmation');
  37. }
  38. $keyword_url = Security::remove_XSS((empty($_GET['keyword']) ? '' : $_GET['keyword']));
  39. }
  40. if (isset($_GET['msg']) && isset($_GET['type'])) {
  41. if (in_array($_GET['msg'], array('ArchiveDirCleanupSucceeded', 'ArchiveDirCleanupFailed'))) {
  42. switch ($_GET['type']) {
  43. case 'error':
  44. $message = Display::return_message(get_lang($_GET['msg']), 'error');
  45. break;
  46. case 'confirmation':
  47. $message = Display::return_message(get_lang($_GET['msg']), 'confirm');
  48. }
  49. }
  50. }
  51. $blocks = array();
  52. // Instantiate Hook Event for Admin Block
  53. $hook = HookAdminBlock::create();
  54. if (!empty($hook)) {
  55. // If not empty, then notify Pre process to Hook Observers for Admin Block
  56. $hook->setEventData(array('blocks' => $blocks));
  57. $data = $hook->notifyAdminBlock(HOOK_EVENT_TYPE_PRE);
  58. // Check if blocks data is not null
  59. if (isset($data['blocks'])) {
  60. // Get modified blocks
  61. $blocks = $data['blocks'];
  62. }
  63. }
  64. /* Users */
  65. $blocks['users']['icon'] = Display::return_icon('members.gif', get_lang('Users'), array(), ICON_SIZE_SMALL, false);
  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. if (api_is_platform_admin()) {
  73. $blocks['users']['editable'] = true;
  74. $search_form = '
  75. <form method="get" class="form-inline" action="user_list.php">
  76. <div class="form-group">
  77. <input class="form-control" type="text" name="keyword" value="">
  78. <button class="btn btn-default" type="submit"><i class="fa fa-search"></i> '.get_lang('Search').'</button>
  79. </div>
  80. </form>';
  81. $blocks['users']['search_form'] = $search_form;
  82. $items = array(
  83. array('url'=>'user_list.php', 'label' => get_lang('UserList')),
  84. array('url'=>'user_add.php', 'label' => get_lang('AddUsers')),
  85. array('url'=>'user_export.php', 'label' => get_lang('ExportUserListXMLCSV')),
  86. array('url'=>'user_import.php', 'label' => get_lang('ImportUserListXMLCSV')),
  87. array('url'=>'user_update_import.php', 'label' => get_lang('EditUserListCSV')),
  88. );
  89. $items[] = array('url'=>'group_add.php', 'label' => get_lang('AddGroups'));
  90. $items[] = array('url'=>'group_list.php', 'label' => get_lang('GroupList'));
  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. } else {
  96. $items = array(
  97. array('url'=>'user_list.php', 'label' => get_lang('UserList')),
  98. array('url'=>'user_add.php', 'label' => get_lang('AddUsers')),
  99. array('url'=>'user_import.php', 'label' => get_lang('ImportUserListXMLCSV')),
  100. );
  101. }
  102. $items[] = array('url'=>'usergroups.php', 'label' => get_lang('Classes'));
  103. $blocks['users']['items'] = $items;
  104. $blocks['users']['extra'] = null;
  105. if (api_is_platform_admin()) {
  106. /* Courses */
  107. $blocks['courses']['icon'] = Display::return_icon('course.gif', get_lang('Courses'), array(), ICON_SIZE_MEDIUM, false);
  108. $blocks['courses']['label'] = api_ucfirst(get_lang('Courses'));
  109. $blocks['courses']['class'] = 'block-admin-courses';
  110. $blocks['courses']['editable'] = true;
  111. $coursesBlockExtraFile = "{$adminExtraContentDir}block-admin-courses_extra.html";
  112. if (file_exists($coursesBlockExtraFile)) {
  113. $blocks['courses']['extraContent'] = file_get_contents($coursesBlockExtraFile);
  114. }
  115. $search_form = ' <form method="get" class="form-inline" action="course_list.php">
  116. <div class="form-group">
  117. <input class="form-control" type="text" name="keyword" value="">
  118. <button class="btn btn-default" type="submit"><i class="fa fa-search"></i> '.get_lang('Search').'</button>
  119. </div>
  120. </form>';
  121. $blocks['courses']['search_form'] = $search_form;
  122. $items = array();
  123. $items[] = array('url'=>'course_list.php', 'label' => get_lang('CourseList'));
  124. $items[] = array('url'=>'course_add.php', 'label' => get_lang('AddCourse'));
  125. if (api_get_setting('course_validation') == 'true') {
  126. $items[] = array('url'=>'course_request_review.php', 'label' => get_lang('ReviewCourseRequests'));
  127. $items[] = array('url'=>'course_request_accepted.php', 'label' => get_lang('AcceptedCourseRequests'));
  128. $items[] = array('url'=>'course_request_rejected.php', 'label' => get_lang('RejectedCourseRequests'));
  129. }
  130. $items[] = array('url'=>'course_export.php', 'label' => get_lang('ExportCourses'));
  131. $items[] = array('url'=>'course_import.php', 'label' => get_lang('ImportCourses'));
  132. $items[] = array('url'=>'course_category.php', 'label' => get_lang('AdminCategories'));
  133. $items[] = array('url'=>'subscribe_user2course.php', 'label' => get_lang('AddUsersToACourse'));
  134. $items[] = array('url'=>'course_user_import.php', 'label' => get_lang('ImportUsersToACourse'));
  135. //$items[] = array('url'=>'course_intro_pdf_import.php', 'label' => get_lang('ImportPDFIntroToCourses'));
  136. if (api_get_setting('gradebook_enable_grade_model') == 'true') {
  137. $items[] = array('url'=>'grade_models.php', 'label' => get_lang('GradeModel'));
  138. }
  139. if (isset($extAuthSource) && isset($extAuthSource['ldap']) && count($extAuthSource['ldap']) > 0) {
  140. $items[] = array('url'=>'ldap_import_students.php', 'label' => get_lang('ImportLDAPUsersIntoCourse'));
  141. }
  142. $items[] = array('url'=>'extra_fields.php?type=course', 'label' => get_lang('ManageCourseFields'));
  143. $blocks['courses']['items'] = $items;
  144. $blocks['courses']['extra'] = null;
  145. /* Platform */
  146. $blocks['platform']['icon'] = Display::return_icon('platform.png', get_lang('Platform'), array(), ICON_SIZE_MEDIUM, false);
  147. $blocks['platform']['label'] = api_ucfirst(get_lang('Platform'));
  148. $blocks['platform']['class'] = 'block-admin-platform';
  149. $blocks['platform']['editable'] = true;
  150. $platformBlockExtraFile = "{$adminExtraContentDir}block-admin-platform_extra.html";
  151. if (file_exists($platformBlockExtraFile)) {
  152. $blocks['platform']['extraContent'] = file_get_contents($platformBlockExtraFile);
  153. }
  154. $search_form = ' <form method="get" action="settings.php" class="form-inline">
  155. <div class="form-group">
  156. <input class="form-control" type="text" name="search_field" value="" >
  157. <input type="hidden" value="search_setting" name="category">
  158. <button class="btn btn-default" type="submit"><i class="fa fa-search"></i> '.get_lang('Search').'</button>
  159. </div>
  160. </form>';
  161. $blocks['platform']['search_form'] = $search_form;
  162. $items = array();
  163. $items[] = array('url'=>'settings.php', 'label' => get_lang('PlatformConfigSettings'));
  164. $items[] = array('url'=>'settings.php?category=Plugins','label' => get_lang('Plugins'));
  165. $items[] = array('url'=>'settings.php?category=Regions','label' => get_lang('Regions'));
  166. $items[] = array('url'=>'system_announcements.php', 'label' => get_lang('SystemAnnouncements'));
  167. $items[] = array('url'=> api_get_path(WEB_CODE_PATH).'calendar/agenda_js.php?type=admin', 'label' => get_lang('GlobalAgenda'));
  168. $items[] = array('url'=>'configure_homepage.php', 'label' => get_lang('ConfigureHomePage'));
  169. $items[] = array('url'=>'configure_inscription.php', 'label' => get_lang('ConfigureInscription'));
  170. $items[] = array('url'=>'statistics/index.php', 'label' => get_lang('Statistics'));
  171. $items[] = array('url'=> api_get_path(WEB_CODE_PATH).'mySpace/company_reports.php', 'label' => get_lang('Reports'));
  172. $items[] = array(
  173. 'url'=> api_get_path(WEB_CODE_PATH) . 'admin/teacher_time_report.php',
  174. 'label' => get_lang('TeacherTimeReport')
  175. );
  176. /* Event settings */
  177. if (api_get_setting('activate_email_template') == 'true') {
  178. $items[] = array('url'=>'event_controller.php?action=listing', 'label' => get_lang('EventMessageManagement'));
  179. }
  180. if (!empty($_configuration['multiple_access_urls'])) {
  181. if (api_is_global_platform_admin()) {
  182. $items[] = array('url'=>'access_urls.php', 'label' => get_lang('ConfigureMultipleAccessURLs'));
  183. }
  184. }
  185. if (api_get_setting('allow_reservation') == 'true') {
  186. $items[] = array('url'=>'../reservation/m_category.php', 'label' => get_lang('BookingSystem'));
  187. }
  188. if (api_get_setting('allow_terms_conditions') == 'true') {
  189. $items[] = array('url'=>'legal_add.php', 'label' => get_lang('TermsAndConditions'));
  190. }
  191. $blocks['platform']['items'] = $items;
  192. $blocks['platform']['extra'] = null;
  193. }
  194. /* Sessions */
  195. $blocks['sessions']['icon'] = Display::return_icon('session.png', get_lang('Sessions'), array(), ICON_SIZE_SMALL, false);
  196. $blocks['sessions']['label'] = api_ucfirst(get_lang('Sessions'));
  197. $blocks['sessions']['class'] = 'block-admin-sessions';
  198. $sessionsBlockExtraFile = "{$adminExtraContentDir}block-admin-sessions_extra.html";
  199. if (file_exists($sessionsBlockExtraFile)) {
  200. $blocks['sessions']['extraContent'] = file_get_contents($sessionsBlockExtraFile);
  201. }
  202. if (api_is_platform_admin()) {
  203. $blocks['sessions']['editable'] = true;
  204. }
  205. $search_form = ' <form method="GET" class="form-inline" action="session_list.php">
  206. <div class="form-group">
  207. <input class="form-control" type="text" name="keyword" value="">
  208. <button class="btn btn-default" type="submit"><i class="fa fa-search"></i> '.get_lang('Search').'</button>
  209. </div>
  210. </form>';
  211. $blocks['sessions']['search_form'] = $search_form;
  212. $items = array();
  213. $items[] = array('url'=>'session_list.php', 'label' => get_lang('ListSession'));
  214. $items[] = array('url'=>'session_add.php', 'label' => get_lang('AddSession'));
  215. $items[] = array('url'=>'session_category_list.php', 'label' => get_lang('ListSessionCategory'));
  216. $items[] = array('url'=>'session_import.php', 'label' => get_lang('ImportSessionListXMLCSV'));
  217. $items[] = array('url'=>'session_import_drh.php', 'label' => get_lang('ImportSessionDrhList'));
  218. if (isset($extAuthSource) && isset($extAuthSource['ldap']) && count($extAuthSource['ldap']) > 0) {
  219. $items[] = array('url'=>'ldap_import_students_to_session.php', 'label' => get_lang('ImportLDAPUsersIntoSession'));
  220. }
  221. $items[] = array('url'=>'session_export.php', 'label' => get_lang('ExportSessionListXMLCSV'));
  222. $items[] = array('url'=>'../coursecopy/copy_course_session.php', 'label' => get_lang('CopyFromCourseInSessionToAnotherSession'));
  223. if (api_is_platform_admin()) {
  224. if (is_dir(api_get_path(SYS_TEST_PATH).'datafiller/')) { // option only visible in development mode. Enable through code if required
  225. $items[] = array('url'=>'user_move_stats.php', 'label' => get_lang('MoveUserStats'));
  226. }
  227. $items[] = array('url'=>'career_dashboard.php', 'label' => get_lang('CareersAndPromotions'));
  228. }
  229. $items[] = array('url'=>'extra_fields.php?type=session', 'label' => get_lang('ManageSessionFields'));
  230. $blocks['sessions']['items'] = $items;
  231. $blocks['sessions']['extra'] = null;
  232. /* Settings */
  233. if (api_is_platform_admin()) {
  234. $blocks['settings']['icon'] = Display::return_icon('settings.png', get_lang('System'), array(), ICON_SIZE_SMALL, false);
  235. $blocks['settings']['label'] = api_ucfirst(get_lang('System'));
  236. $blocks['settings']['class'] = 'block-admin-settings';
  237. $items = array();
  238. $items[] = array('url'=>'special_exports.php', 'label' => get_lang('SpecialExports'));
  239. if (!empty($_configuration['db_admin_path'])) {
  240. $items[] = array('url'=>$_configuration['db_admin_path'], 'label' => get_lang('AdminDatabases').' ('.get_lang('DBManagementOnlyForServerAdmin').') ');
  241. }
  242. $items[] = array('url'=>'system_status.php', 'label' => get_lang('SystemStatus'));
  243. if (is_dir(api_get_path(SYS_TEST_PATH).'datafiller/')) {
  244. $items[] = array('url'=>'filler.php', 'label' => get_lang('DataFiller'));
  245. }
  246. $items[] = array('url'=>'archive_cleanup.php', 'label' => get_lang('ArchiveDirCleanup'));
  247. if (isset($_configuration['db_manager_enabled']) &&
  248. $_configuration['db_manager_enabled'] == true &&
  249. api_is_global_platform_admin()
  250. ) {
  251. $host = $_configuration['db_host'];
  252. $username = $_configuration['db_user'];
  253. $databaseName = $_configuration['main_database'];
  254. $items[] = array('url'=>"db.php?username=$username&db=$databaseName&server=$host", 'label' => get_lang('Database Manager'));
  255. }
  256. $blocks['settings']['items'] = $items;
  257. $blocks['settings']['extra'] = null;
  258. $blocks['settings']['search_form'] = null;
  259. // Skills
  260. if (api_get_setting('allow_skills_tool') == 'true') {
  261. $blocks['skills']['icon'] = Display::return_icon('logo.png', get_lang('Skills'), array(), ICON_SIZE_SMALL, false);
  262. $blocks['skills']['label'] = get_lang('Skills');
  263. $blocks['skills']['class'] = 'block-admin-skills';
  264. $items = array();
  265. //$items[] = array('url'=>'skills.php', 'label' => get_lang('SkillsTree'));
  266. $items[] = array('url'=>'skills_wheel.php', 'label' => get_lang('SkillsWheel'));
  267. $items[] = array('url'=>'skills_import.php', 'label' => get_lang('SkillsImport'));
  268. //$items[] = array('url'=>'skills_profile.php', 'label' => get_lang('SkillsProfile'));
  269. $items[] = array('url'=>api_get_path(WEB_CODE_PATH).'social/skills_ranking.php', 'label' => get_lang('SkillsRanking'));
  270. $items[] = array('url'=>'skills_gradebook.php', 'label' => get_lang('SkillsAndGradebooks'));
  271. $items[] = array('url'=> api_get_path(WEB_CODE_PATH) . 'admin/skill_badge.php', 'label' => get_lang('Badges'));
  272. $blocks['skills']['items'] = $items;
  273. $blocks['skills']['extra'] = null;
  274. $blocks['skills']['search_form'] = null;
  275. }
  276. /* Chamilo.org */
  277. $blocks['chamilo']['icon'] = Display::return_icon('logo.png', 'Chamilo.org', array(), ICON_SIZE_SMALL, false);
  278. $blocks['chamilo']['label'] = 'Chamilo.org';
  279. $blocks['chamilo']['class'] = 'block-admin-chamilo';
  280. $items = array();
  281. $items[] = array('url'=>'http://www.chamilo.org/', 'label' => get_lang('ChamiloHomepage'));
  282. $items[] = array('url'=>'http://www.chamilo.org/forum', 'label' => get_lang('ChamiloForum'));
  283. $items[] = array('url'=>'../../documentation/installation_guide.html', 'label' => get_lang('InstallationGuide'));
  284. $items[] = array('url'=>'../../documentation/changelog.html', 'label' => get_lang('ChangesInLastVersion'));
  285. $items[] = array('url'=>'../../documentation/credits.html', 'label' => get_lang('ContributorsList'));
  286. $items[] = array('url'=>'../../documentation/security.html', 'label' => get_lang('SecurityGuide'));
  287. $items[] = array('url'=>'../../documentation/optimization.html', 'label' => get_lang('OptimizationGuide'));
  288. $items[] = array('url'=>'http://www.chamilo.org/extensions', 'label' => get_lang('ChamiloExtensions'));
  289. $items[] = array('url'=>'http://www.chamilo.org/en/providers', 'label' => get_lang('ChamiloOfficialServicesProviders'));
  290. $blocks['chamilo']['items'] = $items;
  291. $blocks['chamilo']['extra'] = null;
  292. $blocks['chamilo']['search_form'] = null;
  293. //Version check
  294. $blocks['version_check']['icon'] = Display::return_icon('logo.png', 'Chamilo.org', array(), ICON_SIZE_SMALL, false);
  295. $blocks['version_check']['label'] = get_lang('VersionCheck');
  296. $blocks['version_check']['extra'] = '<div class="admin-block-version"></div>';
  297. $blocks['version_check']['search_form'] = null;
  298. $blocks['version_check']['items'] = null;
  299. $blocks['version_check']['class'] = 'block-admin-version_check';
  300. // Check Hook Event for Admin Block Object
  301. if (!empty($hook)) {
  302. // If not empty, then notify Post process to Hook Observers for Admin Block
  303. $hook->setEventData(array('blocks' => $blocks));
  304. $data = $hook->notifyAdminBlock(HOOK_EVENT_TYPE_POST);
  305. // Check if blocks data is not null
  306. if (isset($data['blocks'])) {
  307. // Get modified blocks
  308. $blocks = $data['blocks'];
  309. }
  310. }
  311. }
  312. $admin_ajax_url = api_get_path(WEB_AJAX_PATH).'admin.ajax.php';
  313. $tpl = new Template();
  314. // Display the Site Use Cookie Warning Validation
  315. $useCookieValidation = api_get_configuration_value('cookie_warning');
  316. if ($useCookieValidation) {
  317. if (isset($_POST['acceptCookies'])) {
  318. api_set_site_use_cookie_warning_cookie();
  319. } else if (!api_site_use_cookie_warning_cookie_exist()) {
  320. if (Template::isToolBarDisplayedForUser()) {
  321. $tpl->assign('toolBarDisplayed', true);
  322. } else {
  323. $tpl->assign('toolBarDisplayed', false);
  324. }
  325. $tpl->assign('displayCookieUsageWarning', true);
  326. }
  327. }
  328. $tpl->assign('web_admin_ajax_url', $admin_ajax_url);
  329. $tpl->assign('blocks', $blocks);
  330. if (api_is_platform_admin()) {
  331. $extraContentForm = new FormValidator(
  332. 'block_extra_data',
  333. 'post',
  334. '#',
  335. null,
  336. array(
  337. 'id' => 'block-extra-data',
  338. 'class' => ''
  339. ),
  340. FormValidator::LAYOUT_BOX_NO_LABEL
  341. );
  342. $extraContentFormRenderer = $extraContentForm->getDefaultRenderer();
  343. if ($extraContentForm->validate()) {
  344. $extraData = $extraContentForm->getSubmitValues();
  345. $extraData = array_map(['Security', 'remove_XSS'], $extraData);
  346. if (!empty($extraData['block'])) {
  347. if (!is_dir($adminExtraContentDir)) {
  348. mkdir(
  349. $adminExtraContentDir,
  350. api_get_permissions_for_new_directories(),
  351. true
  352. );
  353. }
  354. if (!is_writable($adminExtraContentDir)) {
  355. die;
  356. }
  357. $fullFilePath = $adminExtraContentDir . $extraData['block'];
  358. $fullFilePath .= "_extra.html";
  359. file_put_contents($fullFilePath, $extraData['extra_content']);
  360. Header::location(api_get_self());
  361. }
  362. }
  363. $extraContentForm->addTextarea(
  364. 'extra_content',
  365. null,
  366. ['id' => 'extra_content']
  367. );
  368. $extraContentFormRenderer->setElementTemplate(
  369. '<div class="form-group">{element}</div>',
  370. 'extra_content'
  371. );
  372. $extraContentForm->addElement(
  373. 'hidden',
  374. 'block',
  375. null,
  376. array(
  377. 'id' => 'extra-block'
  378. )
  379. );
  380. $extraContentForm->addButtonExport(
  381. get_lang('Save'),
  382. 'submit_extra_content'
  383. );
  384. $tpl->assign('extraDataForm', $extraContentForm->returnForm());
  385. }
  386. // The template contains the call to the AJAX version checker
  387. $admin_template = $tpl->get_template('admin/settings_index.tpl');
  388. $content = $tpl->fetch($admin_template);
  389. $tpl->assign('content', $content);
  390. $tpl->assign('message', $message);
  391. $tpl->display_one_col_template();
  392. // Note: version checking mechanism has now been moved to main/inc/ajax/admin.ajax.php