index.php 19 KB

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