index.php 19 KB

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