index.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  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');
  9. // Resetting the course id.
  10. $cidReset = true;
  11. // Including some necessary chamilo files.
  12. require_once '../inc/global.inc.php';
  13. require_once api_get_path(SYS_CODE_PATH).'admin/statistics/statistics.lib.php';
  14. require_once api_get_path(LIBRARY_PATH).'urlmanager.lib.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('PlatformAdmin');
  20. $htmlHeadXtra[] = api_get_jquery_ui_js();
  21. // Displaying the header
  22. $message = '';
  23. if (api_is_platform_admin()) {
  24. if (is_dir(api_get_path(SYS_CODE_PATH).'install/') && is_readable(api_get_path(SYS_CODE_PATH).'install/index.php')) {
  25. $message = Display::return_message(get_lang('InstallDirAccessibleSecurityThreat'),'warning');
  26. }
  27. /* ACTION HANDLING */
  28. if (!empty($_POST['Register'])) {
  29. register_site();
  30. $message = Display :: return_message(get_lang('VersionCheckEnabled'),'confirmation');
  31. }
  32. $keyword_url = Security::remove_XSS((empty($_GET['keyword']) ? '' : $_GET['keyword']));
  33. }
  34. if (isset($_GET['msg']) && isset($_GET['type'])) {
  35. if (in_array($_GET['msg'], array('ArchiveDirCleanupSucceeded', 'ArchiveDirCleanupFailed')))
  36. switch($_GET['type']) {
  37. case 'error':
  38. $message = Display::return_message(get_lang($_GET['msg']), 'error');
  39. break;
  40. case 'confirmation':
  41. $message = Display::return_message(get_lang($_GET['msg']), 'confirm');
  42. }
  43. }
  44. $blocks = array();
  45. /* Users */
  46. $blocks['users']['icon'] = Display::return_icon('members.gif', get_lang('Users'));
  47. $blocks['users']['label'] = api_ucfirst(get_lang('Users'));
  48. if (api_is_platform_admin()) {
  49. $search_form = ' <form method="get" action="user_list.php">
  50. <input type="text" name="keyword" value="">
  51. <button class="search" type="submit">'.get_lang('Search').'</button>
  52. </form>';
  53. $blocks['users']['search_form'] = $search_form;
  54. $items = array(
  55. array('url'=>'user_list.php', 'label' => get_lang('UserList')),
  56. array('url'=>'user_add.php', 'label' => get_lang('AddUsers')),
  57. array('url'=>'user_export.php', 'label' => get_lang('ExportUserListXMLCSV')),
  58. array('url'=>'user_import.php', 'label' => get_lang('ImportUserListXMLCSV')),
  59. );
  60. if (api_get_setting('allow_social_tool') == 'true') {
  61. $items[] = array('url'=>'group_add.php', 'label' => get_lang('AddGroups'));
  62. $items[] = array('url'=>'group_list.php', 'label' => get_lang('GroupList'));
  63. }
  64. if (isset($extAuthSource) && isset($extAuthSource['ldap']) && count($extAuthSource['ldap']) > 0) {
  65. $items[] = array('url'=>'ldap_users_list.php', 'label' => get_lang('ImportLDAPUsersIntoPlatform'));
  66. }
  67. $items[] = array('url'=>'user_fields.php', 'label' => get_lang('ManageUserFields'));
  68. } else {
  69. $items = array(
  70. array('url'=>'user_list.php', 'label' => get_lang('UserList')),
  71. array('url'=>'../mySpace/user_add.php', 'label' => get_lang('AddUsers')),
  72. array('url'=>'user_import.php', 'label' => get_lang('ImportUserListXMLCSV')),
  73. );
  74. }
  75. $blocks['users']['items'] = $items;
  76. if (api_is_platform_admin()) {
  77. /* Courses */
  78. $blocks['courses']['icon'] = Display::return_icon('course.gif', get_lang('Courses'));
  79. $blocks['courses']['label'] = api_ucfirst(get_lang('Courses'));
  80. $search_form = ' <form method="get" action="course_list.php">
  81. <input type="text" name="keyword" value="">
  82. <button class="search" type="submit">'.get_lang('Search').'</button>
  83. </form>';
  84. $blocks['courses']['search_form'] = $search_form;
  85. $items = array();
  86. $items[] = array('url'=>'course_list.php', 'label' => get_lang('CourseList'));
  87. if (api_get_setting('course_validation') != 'true') {
  88. $items[] = array('url'=>'course_add.php', 'label' => get_lang('AddCourse'));
  89. } else {
  90. $items[] = array('url'=>'course_request_review.php', 'label' => get_lang('ReviewCourseRequests'));
  91. $items[] = array('url'=>'course_request_accepted.php', 'label' => get_lang('ReviewCourseRequests'));
  92. $items[] = array('url'=>'course_request_rejected.php', 'label' => get_lang('ReviewCourseRequests'));
  93. }
  94. $items[] = array('url'=>'course_export.php', 'label' => get_lang('ExportCourses'));
  95. $items[] = array('url'=>'course_import.php', 'label' => get_lang('ImportCourses'));
  96. $items[] = array('url'=>'course_category.php', 'label' => get_lang('AdminCategories'));
  97. $items[] = array('url'=>'subscribe_user2course.php', 'label' => get_lang('AddUsersToACourse'));
  98. $items[] = array('url'=>'course_user_import.php', 'label' => get_lang('ImportUsersToACourse'));
  99. if (isset($extAuthSource) && isset($extAuthSource['ldap']) && count($extAuthSource['ldap']) > 0) {
  100. $items[] = array('url'=>'ldap_import_students.php', 'label' => get_lang('ImportLDAPUsersIntoCourse'));
  101. }
  102. $blocks['courses']['items'] = $items;
  103. /* Platform */
  104. $blocks['platform']['icon'] = Display::return_icon('platform.png', get_lang('Platform'), array(), ICON_SIZE_MEDIUM);
  105. $blocks['platform']['label'] = api_ucfirst(get_lang('Platform'));
  106. $items = array();
  107. $items[] = array('url'=>'settings.php', 'label' => get_lang('PlatformConfigSettings'));
  108. $items[] = array('url'=>'system_announcements.php', 'label' => get_lang('SystemAnnouncements'));
  109. $items[] = array('url'=>api_get_path(WEB_CODE_PATH).'calendar/agenda_js.php?type=admin', 'label' => get_lang('GlobalAgenda'));
  110. $items[] = array('url'=>'configure_homepage.php', 'label' => get_lang('ConfigureHomePage'));
  111. $items[] = array('url'=>'configure_inscription.php', 'label' => get_lang('ConfigureInscription'));
  112. $items[] = array('url'=>'statistics/index.php', 'label' => get_lang('Statistics'));
  113. if (!empty($_configuration['multiple_access_urls'])) {
  114. if (api_is_global_platform_admin()) {
  115. $items[] = array('url'=>'access_urls.php', 'label' => get_lang('ConfigureMultipleAccessURLs'));
  116. }
  117. }
  118. if (api_get_setting('allow_reservation') == 'true') {
  119. $items[] = array('url'=>'../reservation/m_category.php', 'label' => get_lang('BookingSystem'));
  120. }
  121. if (api_get_setting('allow_terms_conditions') == 'true') {
  122. $items[] = array('url'=>'legal_add.php', 'label' => get_lang('TermsAndConditions'));
  123. }
  124. $blocks['platform']['items'] = $items;
  125. }
  126. /* Sessions */
  127. if (api_get_setting('use_session_mode') == 'true') {
  128. $blocks['sessions']['icon'] = Display::return_icon('session.png', get_lang('Sessions'), array(), ICON_SIZE_SMALL);
  129. $blocks['sessions']['label'] = api_ucfirst(get_lang('Sessions'));
  130. $search_form = ' <form method="POST" action="session_list.php">
  131. <input type="text" name="keyword" value="">
  132. <button class="search" type="submit">'.get_lang('Search').'</button>
  133. </form>';
  134. $blocks['sessions']['search_form'] = $search_form;
  135. $items = array();
  136. $items[] = array('url'=>'session_list.php', 'label' => get_lang('ListSession'));
  137. $items[] = array('url'=>'session_add.php', 'label' => get_lang('AddSession'));
  138. $items[] = array('url'=>'session_category_list.php', 'label' => get_lang('ListSessionCategory'));
  139. $items[] = array('url'=>'session_import.php', 'label' => get_lang('ImportSessionListXMLCSV'));
  140. if (isset($extAuthSource) && isset($extAuthSource['ldap']) && count($extAuthSource['ldap']) > 0) {
  141. $items[] = array('url'=>'ldap_import_students_to_session.php', 'label' => get_lang('ImportLDAPUsersIntoSession'));
  142. }
  143. $items[] = array('url'=>'session_export.php', 'label' => get_lang('ExportSessionListXMLCSV'));
  144. $items[] = array('url'=>'../coursecopy/copy_course_session.php', 'label' => get_lang('CopyFromCourseInSessionToAnotherSession'));
  145. $items[] = array('url'=>'session_list.php', 'label' => get_lang('ListSession'));
  146. if (is_dir(api_get_path(SYS_TEST_PATH).'datafiller/')) { // option only visible in development mode. Enable through code if required
  147. $items[] = array('url'=>'user_move_stats.php', 'label' => get_lang('MoveUserStats'));
  148. }
  149. $items[] = array('url'=>'career_dashboard.php', 'label' => get_lang('CareersAndPromotions'));
  150. $items[] = array('url'=>'usergroups.php', 'label' => get_lang('Classes'));
  151. $blocks['sessions']['items'] = $items;
  152. } elseif (api_is_platform_admin()) {
  153. $blocks['classes']['items'] = $items;
  154. $blocks['classes']['icon'] = Display::return_icon('group.gif', get_lang('AdminClasses'));
  155. $blocks['classes']['label'] = api_ucfirst(get_lang('AdminClasses'));
  156. $search_form = ' <form method="POST" action="class_list.php">
  157. <input type="text" name="keyword" value="">
  158. <button class="search" type="submit">.'.get_lang('Search').'</button>
  159. </form>';
  160. $blocks['classes']['search_form'] = $search_form;
  161. $items = array();
  162. $items[] = array('url'=>'class_list.php', 'label' => get_lang('ClassList'));
  163. $items[] = array('url'=>'class_add.php', 'label' => get_lang('AddClasses'));
  164. $items[] = array('url'=>'class_import.php', 'label' => get_lang('ImportClassListCSV'));
  165. $items[] = array('url'=>'class_user_import.php', 'label' => get_lang('AddUsersToAClass'));
  166. $items[] = array('url'=>'subscribe_class2course.php', 'label' => get_lang('AddClassesToACourse'));
  167. $blocks['classes']['items'] = $items;
  168. }
  169. /* Settings */
  170. if (api_is_platform_admin()) {
  171. $blocks['settings']['icon'] = Display::return_icon('settings.png', get_lang('System'));
  172. $blocks['settings']['label'] = api_ucfirst(get_lang('System'));
  173. $items = array();
  174. $items[] = array('url'=>'special_exports.php', 'label' => get_lang('SpecialExports'));
  175. if (!empty($_configuration['db_admin_path'])) {
  176. $items[] = array('url'=>$_configuration['db_admin_path'], 'label' => get_lang('AdminDatabases').' ('.get_lang('DBManagementOnlyForServerAdmin').') ');
  177. }
  178. $items[] = array('url'=>'system_status.php', 'label' => get_lang('SystemStatus'));
  179. if (is_dir(api_get_path(SYS_TEST_PATH).'datafiller/')) {
  180. $items[] = array('url'=>'filler.php', 'label' => get_lang('DataFiller'));
  181. }
  182. if (api_is_global_platform_admin()) {
  183. $items[] = array('url'=>'archive_cleanup.php', 'label' => get_lang('ArchiveDirCleanup'));
  184. }
  185. $blocks['settings']['items'] = $items;
  186. /* Extensions */
  187. $blocks['extensions']['icon'] = Display::return_icon('visio_meeting.gif', get_lang('ConfigureExtensions'));
  188. $blocks['extensions']['label'] = api_ucfirst(get_lang('ConfigureExtensions'));
  189. $items = array();
  190. $items[] = array('url'=>'configure_extensions.php?display=visio', 'label' => get_lang('Visioconf'));
  191. $items[] = array('url'=>'configure_extensions.php?display=ppt2lp', 'label' => get_lang('Ppt2lp'));
  192. //$items[] = array('url'=>'configure_extensions.php?display=ephorus', 'label' => get_lang('EphorusPlagiarismPrevention'));
  193. $items[] = array('url'=>'configure_extensions.php?display=search', 'label' => get_lang('SearchEngine'));
  194. $items[] = array('url'=>'configure_extensions.php?display=serverstats', 'label' => get_lang('ServerStatistics'));
  195. $items[] = array('url'=>'configure_extensions.php?display=bandwidthstats', 'label' => get_lang('BandWidthStatistics'));
  196. $blocks['extensions']['items'] = $items;
  197. //Skills
  198. $blocks['skills']['icon'] = Display::return_icon('logo.gif', get_lang('Skills'));
  199. $blocks['skills']['label'] = get_lang('Skills');
  200. $items = array();
  201. $items[] = array('url'=>'skills.php', 'label' => get_lang('SkillsTree'));
  202. $items[] = array('url'=>'skills_profile.php', 'label' => get_lang('SkillsProfile'));
  203. $items[] = array('url'=>'skills_gradebook.php', 'label' => get_lang('SkillsAndGradebooks'));
  204. $blocks['skills']['items'] = $items;
  205. /* Chamilo.org */
  206. $blocks['chamilo']['icon'] = Display::return_icon('logo.gif', 'Chamilo.org');
  207. $blocks['chamilo']['label'] = 'Chamilo.org';
  208. $items = array();
  209. $items[] = array('url'=>'http://www.chamilo.org/', 'label' => get_lang('ChamiloHomepage'));
  210. $items[] = array('url'=>'http://www.chamilo.org/forum', 'label' => get_lang('ChamiloForum'));
  211. $items[] = array('url'=>'../../documentation/installation_guide.html', 'label' => get_lang('InstallationGuide'));
  212. $items[] = array('url'=>'../../documentation/changelog.html', 'label' => get_lang('ChangesInLastVersion'));
  213. $items[] = array('url'=>'../../documentation/credits.html', 'label' => get_lang('ContributorsList'));
  214. $items[] = array('url'=>'../../documentation/security.html', 'label' => get_lang('SecurityGuide'));
  215. $items[] = array('url'=>'../../documentation/optimization.html', 'label' => get_lang('OptimizationGuide'));
  216. $items[] = array('url'=>'http://www.chamilo.org/extensions', 'label' => get_lang('ChamiloExtensions'));
  217. $blocks['chamilo']['items'] = $items;
  218. // Try to display a maximum before we check the chamilo version and all that.
  219. //session_write_close(); //close session to avoid blocking concurrent access
  220. //flush(); //send data to client as much as allowed by the web server
  221. //ob_flush();
  222. $blocks['chamilo']['extra'] = '<br />'.get_lang('VersionCheck').': '.version_check().'';
  223. }
  224. $tpl = new Template();
  225. $tpl->assign('blocks', $blocks);
  226. $admin_template = $tpl->get_template('admin/settings_index.tpl');
  227. $content = $tpl->fetch($admin_template);
  228. $tpl->assign('content', $content);
  229. $tpl->assign('message', $message);
  230. $tpl->display_one_col_template();
  231. /**
  232. * Displays either the text for the registration or the message that the installation is (not) up to date
  233. *
  234. * @return string html code
  235. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  236. * @version august 2006
  237. * @todo have a 6monthly re-registration
  238. */
  239. function version_check() {
  240. $tbl_settings = Database :: get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
  241. $sql = 'SELECT selected_value FROM '.$tbl_settings.' WHERE variable="registered" ';
  242. $result = Database::query($sql);
  243. $row = Database::fetch_array($result, 'ASSOC');
  244. // The site has not been registered yet.
  245. $return = '';
  246. if ($row['selected_value'] == 'false') {
  247. $return .= '<form action="'.api_get_self().'" id="VersionCheck" name="VersionCheck" method="post">';
  248. $return .= get_lang('VersionCheckExplanation');
  249. $return .= '<input type="checkbox" name="donotlistcampus" value="1" id="checkbox" />'.get_lang('HideCampusFromPublicDokeosPlatformsList');
  250. $return .= '<button type="submit" class="save" name="Register" value="'.get_lang('EnableVersionCheck').'" id="register" />'.get_lang('EnableVersionCheck').'</button>';
  251. $return .= '</form>';
  252. } else {
  253. $return = 'site registered. ';
  254. $return .= check_system_version();
  255. }
  256. return $return;
  257. }
  258. /**
  259. * This setting changes the registration status for the campus
  260. *
  261. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  262. * @version August 2006
  263. *
  264. * @todo the $_settings should be reloaded here. => write api function for this and use this in global.inc.php also.
  265. */
  266. function register_site() {
  267. $tbl_settings = Database :: get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
  268. $sql = "UPDATE $tbl_settings SET selected_value='true' WHERE variable='registered'";
  269. $result = Database::query($sql);
  270. if ($_POST['donotlistcampus']) {
  271. $sql = "UPDATE $tbl_settings SET selected_value='true' WHERE variable='donotlistcampus'";
  272. $result = Database::query($sql);
  273. }
  274. // Reload the settings.
  275. }
  276. /**
  277. * Check if the current installation is up to date
  278. * The code is borrowed from phpBB and slighlty modified
  279. * @author The phpBB Group <support@phpbb.com> (the code)
  280. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University (the modifications)
  281. * @copyright (C) 2001 The phpBB Group
  282. * @return language string with some layout (color)
  283. */
  284. function check_system_version() {
  285. global $_configuration;
  286. $system_version = trim($_configuration['system_version']); // the chamilo version of your installation
  287. if (ini_get('allow_url_fopen') == 1) {
  288. // The number of courses
  289. $number_of_courses = statistics::count_courses();
  290. // The number of users
  291. $number_of_users = statistics::count_users();
  292. $version_url = 'http://version.chamilo.org/version.php?url='.urlencode(api_get_path(WEB_PATH)).'&campus='.urlencode(api_get_setting('siteName')).'&contact='.urlencode(api_get_setting('emailAdministrator')).'&version='.urlencode($system_version).'&numberofcourses='.urlencode($number_of_courses).'&numberofusers='.urlencode($number_of_users).'&donotlistcampus='.api_get_setting('donotlistcampus').'&organisation='.urlencode(api_get_setting('Institution')).'&language='.api_get_setting('platformLanguage').'&adminname='.urlencode(api_get_setting('administratorName').' '.api_get_setting('administratorSurname'));
  293. $handle = @fopen($version_url, 'r');
  294. if ($handle !== false) {
  295. $version_info = trim(@fread($handle, 1024));
  296. if ($system_version != $version_info) {
  297. $output = '<br /><span style="color:red">' . get_lang('YourVersionNotUpToDate') . '. '.get_lang('LatestVersionIs').' <b>Chamilo '.$version_info.'</b>. '.get_lang('YourVersionIs').' <b>Chamilo '.$system_version. '</b>. '.str_replace('http://www.chamilo.org', '<a href="http://www.chamilo.org">http://www.chamilo.org</a>', get_lang('PleaseVisitDokeos')).'</span>';
  298. } else {
  299. $output = '<br /><span style="color:green">'.get_lang('VersionUpToDate').': Chamilo '.$version_info.'</span>';
  300. }
  301. } else {
  302. $output = '<span style="color:red">' . get_lang('ImpossibleToContactVersionServerPleaseTryAgain') . '</span>';
  303. }
  304. } else {
  305. $output = '<span style="color:red">' . get_lang('AllowurlfopenIsSetToOff') . '</span>';
  306. }
  307. return $output;
  308. }