فهرست منبع

[svn r18264] Adding new setting "allow students to browse courses"

Julio Montoya 16 سال پیش
والد
کامیت
22091991f9
4فایلهای تغییر یافته به همراه30 افزوده شده و 24 حذف شده
  1. 8 7
      main/admin/settings.php
  2. 11 12
      main/auth/courses.php
  3. 6 2
      main/install/dokeos_main.sql
  4. 5 3
      main/install/migrate-db-1.8.5-1.8.6-pre.sql

+ 8 - 7
main/admin/settings.php

@@ -1,4 +1,4 @@
-<?php // $Id: settings.php 18238 2009-02-04 19:26:59Z ivantcholakov $
+<?php // $Id: settings.php 18264 2009-02-05 21:23:18Z juliomontoya $
 /*
 ==============================================================================
 	Dokeos - elearning and course management software
@@ -190,14 +190,15 @@ if (!empty($_GET['category']) and !in_array($_GET['category'], array('Plugins',
 			case 'radio' :
 				$values = get_settings_options($row['variable']);
 				$group = array ();
-				foreach ($values as $key => $value) {
-					$element = & $form->createElement('radio', $row['variable'], '', get_lang($value['display_text']), $value['value']);
-					if ($hide_element) {
-						$element->freeze();
+				if (is_array($values )) {
+					foreach ($values as $key => $value) {
+						$element = & $form->createElement('radio', $row['variable'], '', get_lang($value['display_text']), $value['value']);
+						if ($hide_element) {
+							$element->freeze();
+						}
+						$group[] = $element; 
 					}
-					$group[] = $element; 
 				}
-				
 				$form->addGroup($group, $row['variable'], get_lang($row['comment']), '<br />', false);
 				$default_values[$row['variable']] = $row['selected_value'];
 				break;

+ 11 - 12
main/auth/courses.php

@@ -1,4 +1,4 @@
-<?php // $Id: courses.php 18232 2009-02-04 16:20:59Z juliomontoya $
+<?php // $Id: courses.php 18264 2009-02-05 21:23:18Z juliomontoya $
 /*
 ==============================================================================
 	Dokeos - elearning and course management software
@@ -36,10 +36,7 @@
 ==============================================================================
 */
 // name of the language file that needs to be included
-$language_file = array (
-'courses',
-'registration'
-);
+$language_file = array ('courses','registration');
 
 //delete the globals["_cid"] we don't need it here 
 $cidReset = true; // Flag forcing the 'current course' reset
@@ -53,6 +50,11 @@ $this_section=SECTION_COURSES;
 // acces rights: anonymous users can't do anything usefull here
 api_block_anonymous_users();
 
+if (!(api_is_platform_admin() || api_is_course_admin() || api_is_allowed_to_create_course())) {
+	if (api_get_setting('allow_students_to_browse_courses')=='false') {	
+		api_not_allowed();		
+	}			
+}
 // include additional libraries
 include_once(api_get_path(LIBRARY_PATH) . 'debug.lib.inc.php');
 include_once(api_get_path(LIBRARY_PATH) . 'course.lib.php');
@@ -66,19 +68,18 @@ $tbl_courses_nodes      = Database::get_main_table(TABLE_MAIN_CATEGORY);
 $tbl_courseUser         = Database::get_main_table(TABLE_MAIN_COURSE_USER);
 $tbl_user               = Database::get_main_table(TABLE_MAIN_USER);
 
+
 //filter
 $safe = array();
 $safe['action'] = '';
 $actions = array('sortmycourses','createcoursecategory','subscribe','deletecoursecategory','unsubscribe');
 
-if(in_array(htmlentities($_GET['action']),$actions))
-{
+if(in_array(htmlentities($_GET['action']),$actions)) {
 	$safe['action'] = htmlentities($_GET['action']);
 }
 
 // title of the page
-if ($safe['action'] == 'sortmycourses' OR !isset($safe['action']))
-{
+if ($safe['action'] == 'sortmycourses' OR !isset($safe['action'])) {
 	$nameTools = get_lang('SortMyCourses');
 }
 if ($safe['action'] == 'createcoursecategory')
@@ -90,11 +91,9 @@ if ($safe['action'] == 'subscribe')
 	$nameTools = get_lang('SubscribeToCourse');
 }
 
-
 // breadcrumbs
 $interbreadcrumb[] = array('url'=>api_get_path(WEB_PATH).'user_portal.php', 'name'=> get_lang('MyCourses'));
-if (empty($nameTools))
-{
+if (empty($nameTools)) {
 	$nameTools=get_lang('CourseManagement');
 }
 else

+ 6 - 2
main/install/dokeos_main.sql

@@ -652,7 +652,8 @@ VALUES
 ('allow_reservation', NULL, 'radio', 'Tools', 'false', 'AllowReservationTitle', 'AllowReservationComment', NULL, NULL, 0),
 ('profile','apikeys','checkbox','User','false','ProfileChangesTitle','ProfileChangesComment',NULL,'ApiKeys', 0),
 ('allow_message_tool', NULL, 'radio', 'Tools', 'false', 'AllowMessageToolTitle', 'AllowMessageToolComment', NULL, NULL,0),
-('allow_social_tool', NULL, 'radio', 'Tools', 'false', 'AllowSocialToolTitle', 'AllowSocialToolComment', NULL, NULL, 0);
+('allow_social_tool', NULL, 'radio', 'Tools', 'false', 'AllowSocialToolTitle', 'AllowSocialToolComment', NULL, NULL, 0),
+('allow_students_to_browse_courses',NULL,'radio','Platform','true','AllowStudentsToBrowseCoursesTitle','AllowStudentsToBrowseCoursesComment',NULL,NULL, 1);
 UNLOCK TABLES;
 /*!40000 ALTER TABLE settings_current ENABLE KEYS */;
 
@@ -810,7 +811,10 @@ VALUES
 ('allow_message_tool', 'true', 'Yes'),
 ('allow_message_tool', 'false', 'No'),
 ('allow_social_tool', 'true', 'Yes'),
-('allow_social_tool', 'false', 'No');
+('allow_social_tool', 'false', 'No'),
+('allow_students_to_browse_courses','true','Yes'),
+('allow_students_to_browse_courses','false','No');
+
 UNLOCK TABLES;
 
 /*!40000 ALTER TABLE settings_options ENABLE KEYS */;

+ 5 - 3
main/install/migrate-db-1.8.5-1.8.6-pre.sql

@@ -98,13 +98,15 @@ UPDATE settings_current SET access_url_changeable = 1 WHERE variable='show_email
 UPDATE settings_current SET access_url_changeable = 1 WHERE variable='show_different_course_language';
 UPDATE settings_current SET access_url_changeable = 1 WHERE variable='display_categories_on_homepage';
 INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext) VALUES ('advanced_filemanager',NULL,'radio','Platform','false','AdvancedFileManagerTitle','AdvancedFileManagerComment',NULL,NULL);
-INSERT INTO settings_current(variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('allow_message_tool', NULL, 'radio', 'Tools', 'false', 'AllowMessageToolTitle', 'AllowMessageToolComment', NULL, NULL,0);
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('allow_message_tool', NULL, 'radio', 'Tools', 'false', 'AllowMessageToolTitle', 'AllowMessageToolComment', NULL, NULL,0);
 INSERT INTO settings_options (variable, value, display_text) VALUES ('allow_message_tool', 'true', 'Yes');
 INSERT INTO settings_options (variable, value, display_text) VALUES ('allow_message_tool', 'false', 'No');
-INSERT INTO settings_current(variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('allow_social_tool', NULL, 'radio', 'Tools', 'false', 'AllowSocialToolTitle', 'AllowSocialToolComment', NULL, NULL, 0);
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('allow_social_tool', NULL, 'radio', 'Tools', 'false', 'AllowSocialToolTitle', 'AllowSocialToolComment', NULL, NULL, 0);
 INSERT INTO settings_options (variable, value, display_text) VALUES ('allow_social_tool', 'true', 'Yes');
 INSERT INTO settings_options (variable, value, display_text) VALUES ('allow_social_tool', 'false', 'No');
-
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('allow_students_to_browse_courses', NULL, 'radio', 'Platform', 'true', 'AllowStudentsToBrowseCoursesTitle', 'AllowStudentsToBrowseCoursesComment', NULL, NULL, 1);
+INSERT INTO settings_options (variable, value, display_text) VALUES ('allow_students_to_browse_courses', 'true', 'Yes');
+INSERT INTO settings_options (variable, value, display_text) VALUES ('allow_students_to_browse_courses', 'false', 'No');
 
 -- xxSTATSxx
 ALTER TABLE track_e_exercices ADD status varchar(20) NOT NULL default '';