diff --git a/main/calendar/agenda.inc.php b/main/calendar/agenda.inc.php index 81bbc74237..896b35155e 100644 --- a/main/calendar/agenda.inc.php +++ b/main/calendar/agenda.inc.php @@ -93,7 +93,7 @@ function get_calendar_items($select_month, $select_year, $select_day = false) { $new_group_memberships=array(); foreach($group_memberships as $id) { // did i have access to the same - $has_access = GroupManager::user_has_access(api_get_user_id(),$id,GROUP_TOOL_CALENDAR); + $has_access = GroupManager::user_has_access(api_get_user_id(),$id, GroupManager::GROUP_TOOL_CALENDAR); $result = GroupManager::get_group_properties($id); if ($has_access && $result['calendar_state']!='0' ) { $new_group_memberships[]=$id; @@ -126,7 +126,7 @@ function get_calendar_items($select_month, $select_year, $select_day = false) { elseif (!empty($_SESSION['group'])) { if (!empty($group_id)) { $result = GroupManager::get_group_properties($group_id); - $has_access = GroupManager::user_has_access(api_get_user_id(),$group_id,GROUP_TOOL_CALENDAR); + $has_access = GroupManager::user_has_access(api_get_user_id(),$group_id,GroupManager::GROUP_TOOL_CALENDAR); //echo '
';print_R($result);
 
                 // lastedit
@@ -1434,7 +1434,7 @@ function show_user_group_filter_form() {
 	    $option = "";
 		foreach($group_list as $this_group) {
 			// echo "";
-			$has_access = GroupManager::user_has_access(api_get_user_id(),$this_group['id'],GROUP_TOOL_CALENDAR);
+			$has_access = GroupManager::user_has_access(api_get_user_id(),$this_group['id'], GroupManager::GROUP_TOOL_CALENDAR);
 			$result = GroupManager::get_group_properties($this_group['id']);
 
 			if ($result['calendar_state']!='0') {
diff --git a/main/forum/index.php b/main/forum/index.php
index 0349cd9a62..321167e6a1 100644
--- a/main/forum/index.php
+++ b/main/forum/index.php
@@ -281,7 +281,7 @@ if (is_array($forum_categories_list)) {
                         if ($forum['forum_of_group'] == '0') {    
                             $show_forum = true;
                         } else {
-                            $show_forum = GroupManager::user_has_access($user_id, $forum['forum_of_group'], GROUP_TOOL_FORUM); 
+                            $show_forum = GroupManager::user_has_access($user_id, $forum['forum_of_group'], GroupManager::GROUP_TOOL_FORUM); 
                         }
                     }
 
diff --git a/main/forum/newthread.php b/main/forum/newthread.php
index 813c2e3240..918147974a 100644
--- a/main/forum/newthread.php
+++ b/main/forum/newthread.php
@@ -112,7 +112,7 @@ if (!$_user['user_id'] AND $current_forum['allow_anonymous'] <> 1) {
 
 // 5. Check user access
 if ($current_forum['forum_of_group'] != 0) {
-    $show_forum = GroupManager::user_has_access(api_get_user_id(), $current_forum['forum_of_group'], GROUP_TOOL_FORUM);
+    $show_forum = GroupManager::user_has_access(api_get_user_id(), $current_forum['forum_of_group'], GroupManager::GROUP_TOOL_FORUM);
     if (!$show_forum) {
         api_not_allowed();
     }
diff --git a/main/forum/reply.php b/main/forum/reply.php
index b6141d1689..9503d49097 100644
--- a/main/forum/reply.php
+++ b/main/forum/reply.php
@@ -85,7 +85,7 @@ if (!$_user['user_id'] AND $current_forum['allow_anonymous'] == 0) {
 }
 
 if ($current_forum['forum_of_group'] != 0) {
-    $show_forum = GroupManager::user_has_access(api_get_user_id(), $current_forum['forum_of_group'], GROUP_TOOL_FORUM);
+    $show_forum = GroupManager::user_has_access(api_get_user_id(), $current_forum['forum_of_group'], GroupManager::GROUP_TOOL_FORUM);
     if (!$show_forum) {
         api_not_allowed();
     }
diff --git a/main/forum/viewforum.php b/main/forum/viewforum.php
index 48132ee7f7..1cf46db039 100644
--- a/main/forum/viewforum.php
+++ b/main/forum/viewforum.php
@@ -75,7 +75,7 @@ if (!empty($group_id)) {
     $group_properties           = GroupManager::get_group_properties($group_id);
         
     //User has access in the group?
-    $user_has_access_in_group   = GroupManager::user_has_access($userid, $group_id, GROUP_TOOL_FORUM);
+    $user_has_access_in_group   = GroupManager::user_has_access($userid, $group_id, GroupManager::GROUP_TOOL_FORUM);
     
     $is_group_tutor = GroupManager::is_tutor_of_group(api_get_user_id(), $group_id);
         
diff --git a/main/group/group.php b/main/group/group.php
index 22b56c9936..371e65a238 100644
--- a/main/group/group.php
+++ b/main/group/group.php
@@ -25,7 +25,7 @@ $current_course_tool  = TOOL_GROUP;
 // Notice for unauthorized people.
 api_protect_course_script(true);
 
-$htmlHeadXtra[] = '';
 $nameTools = get_lang('GroupManagement');
-
-/*	Libraries */
-require_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php';
-
 $course_id = api_get_course_int_id();
 
 // Create default category if it doesn't exist when group categories aren't allowed
 if (api_get_setting('allow_group_categories') == 'false') {
 	$cat_table = Database::get_course_table(TABLE_GROUP_CATEGORY);
-	$sql = "SELECT * FROM $cat_table WHERE c_id = $course_id AND id = '".DEFAULT_GROUP_CATEGORY."'";
+	$sql = "SELECT * FROM $cat_table WHERE c_id = $course_id AND id = '".GroupManager::DEFAULT_GROUP_CATEGORY."'";
 	$res = Database::query($sql);
 	$num = Database::num_rows($res);
 	if ($num == 0) {
@@ -63,6 +59,7 @@ if (!isset ($_GET['origin']) || $_GET['origin'] != 'learnpath') {
 		api_not_allowed(true);
 	}
 }
+
 Display::display_header(get_lang('Groups'));
 
 // Tool introduction
@@ -143,7 +140,7 @@ if (api_is_allowed_to_edit(false, true)) {
 				GroupManager :: unsubscribe_all_users($my_get_id);
 				Display :: display_confirmation_message(get_lang('GroupEmptied'));
 				break;
-			case 'fill_one':
+			case 'fill_one':                
 				GroupManager :: fill_groups($my_get_id);
 				Display :: display_confirmation_message(get_lang('GroupFilledGroups'));
 				break;
@@ -245,12 +242,12 @@ foreach ($group_cats as $index => $category) {
 			if ((api_is_allowed_to_edit(false, true) ||
 					in_array($_user['user_id'], $tutorsids_of_group) ||
 					$this_group['is_member'] ||
-					GroupManager::user_has_access($_user['user_id'], $this_group['id'], GROUP_TOOL_FORUM) ||
-					GroupManager::user_has_access($_user['user_id'], $this_group['id'], GROUP_TOOL_DOCUMENTS) ||
-					GroupManager::user_has_access($_user['user_id'], $this_group['id'], GROUP_TOOL_CALENDAR) ||
-					GroupManager::user_has_access($_user['user_id'], $this_group['id'], GROUP_TOOL_ANNOUNCEMENT) ||
-					GroupManager::user_has_access($_user['user_id'], $this_group['id'], GROUP_TOOL_WORK) ||
-					GroupManager::user_has_access($_user['user_id'], $this_group['id'], GROUP_TOOL_WIKI))
+					GroupManager::user_has_access($_user['user_id'], $this_group['id'], GroupManager::GROUP_TOOL_FORUM) ||
+					GroupManager::user_has_access($_user['user_id'], $this_group['id'], GroupManager::GROUP_TOOL_DOCUMENTS) ||
+					GroupManager::user_has_access($_user['user_id'], $this_group['id'], GroupManager::GROUP_TOOL_CALENDAR) ||
+					GroupManager::user_has_access($_user['user_id'], $this_group['id'], GroupManager::GROUP_TOOL_ANNOUNCEMENT) ||
+					GroupManager::user_has_access($_user['user_id'], $this_group['id'], GroupManager::GROUP_TOOL_WORK) ||
+					GroupManager::user_has_access($_user['user_id'], $this_group['id'], GroupManager::GROUP_TOOL_WIKI))
 					&& !(api_is_course_coach() && intval($this_group['session_id']) != intval($_SESSION['id_session']))) {
 				$orig = isset($origin) ? $origin : null;
 				$group_name = ''.stripslashes($this_group['name']).'';
@@ -291,7 +288,7 @@ foreach ($group_cats as $index => $category) {
             
 		
             // Max number of members in group
-            $max_members = ($this_group['maximum_number_of_members'] == MEMBER_PER_GROUP_NO_LIMIT ? ' ' : ' / '.$this_group['maximum_number_of_members']);
+            $max_members = ($this_group['maximum_number_of_members'] == GroupManager::MEMBER_PER_GROUP_NO_LIMIT ? ' ' : ' / '.$this_group['maximum_number_of_members']);
             
             
 			// Number of members in group
diff --git a/main/group/group_category.php b/main/group/group_category.php
index 0ee6c10e1e..d8924acb27 100644
--- a/main/group/group_category.php
+++ b/main/group/group_category.php
@@ -15,8 +15,6 @@ $current_course_tool  = TOOL_GROUP;
 // Notice for unauthorized people.
 api_protect_course_script(true);
 
-require_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php';
-
 if (!api_is_allowed_to_edit(false,true) || !(isset ($_GET['id']) || isset ($_POST['id']) || isset ($_GET['action']) || isset ($_POST['action']))) {
 	api_not_allowed();
 }
@@ -26,7 +24,7 @@ if (!api_is_allowed_to_edit(false,true) || !(isset ($_GET['id']) || isset ($_POS
  */
 function check_max_number_of_members($value) {
 	$max_member_no_limit = $value['max_member_no_limit'];
-	if ($max_member_no_limit == MEMBER_PER_GROUP_NO_LIMIT) {
+	if ($max_member_no_limit == GroupManager::MEMBER_PER_GROUP_NO_LIMIT) {
 		return true;
 	}
 	$max_member = $value['max_member'];
@@ -38,7 +36,7 @@ function check_max_number_of_members($value) {
  */
 function check_groups_per_user($value) {
 	$groups_per_user = $value['groups_per_user'];
-	if (isset ($_POST['id']) && intval($groups_per_user) != GROUP_PER_MEMBER_NO_LIMIT && GroupManager :: get_current_max_groups_per_user($_POST['id']) > intval($groups_per_user)) {
+	if (isset ($_POST['id']) && intval($groups_per_user) != GroupManager::GROUP_PER_MEMBER_NO_LIMIT && GroupManager::get_current_max_groups_per_user($_POST['id']) > intval($groups_per_user)) {
 		return false;
 	}
 	return true;
@@ -51,7 +49,16 @@ if (api_get_setting('allow_group_categories') == 'true') {
 	} else {
 		$nameTools = get_lang('AddCategory');
 		// Default values for new category
-		$category = array ('groups_per_user' => 1, 'doc_state' => TOOL_PRIVATE, 'work_state' => TOOL_PRIVATE, 'wiki_state' => TOOL_PRIVATE , 'chat_state' => TOOL_PRIVATE, 'calendar_state' => TOOL_PRIVATE, 'announcements_state'=> TOOL_PRIVATE, 'forum_state' => TOOL_PRIVATE, 'max_student' => 0);
+		$category = array(
+            'groups_per_user' => 1, 
+            'doc_state' => GroupManager::TOOL_PRIVATE, 
+            'work_state' => GroupManager::TOOL_PRIVATE, 
+            'wiki_state' => GroupManager::TOOL_PRIVATE , 
+            'chat_state' => GroupManager::TOOL_PRIVATE, 
+            'calendar_state' => GroupManager::TOOL_PRIVATE, 
+            'announcements_state'=> GroupManager::TOOL_PRIVATE, 
+            'forum_state' => GroupManager::TOOL_PRIVATE, 
+            'max_student' => 0);
 	}
 } else {
 	$category = GroupManager :: get_category($_GET['id']);
@@ -102,7 +109,7 @@ $possible_values = array ();
 for ($i = 1; $i <= 10; $i ++) {
 	$possible_values[$i] = $i;
 }
-$possible_values[GROUP_PER_MEMBER_NO_LIMIT] = get_lang('All');
+$possible_values[GroupManager::GROUP_PER_MEMBER_NO_LIMIT] = get_lang('All');
 $group[] = & $form->createElement('select', 'groups_per_user', null, $possible_values);
 $group[] = & $form->createElement('static', null, null, get_lang('QtyOfUserCanSubscribe_PartAfterNumber'));
 $form->addGroup($group, 'limit_group', get_lang('GroupLimit'), ' ', false);
@@ -114,7 +121,7 @@ $form->addElement('html', '

'.get_lang('De $form->addElement('html', '
'); // Members per group -$form->addElement('radio', 'max_member_no_limit', get_lang('GroupLimit'), get_lang('NoLimit'), MEMBER_PER_GROUP_NO_LIMIT); +$form->addElement('radio', 'max_member_no_limit', get_lang('GroupLimit'), get_lang('NoLimit'), GroupManager::MEMBER_PER_GROUP_NO_LIMIT); $group = array (); $group[] = & $form->createElement('radio', 'max_member_no_limit', null, get_lang('MaximumOfParticipants'), 1); $group[] = & $form->createElement('text', 'max_member', null, array ('size' => 2)); @@ -127,39 +134,39 @@ $form->addElement('checkbox', 'self_reg_allowed', get_lang('GroupSelfRegistratio $form->addElement('checkbox', 'self_unreg_allowed', null, get_lang('GroupAllowStudentUnregistration'), 1); // Documents settings -$form->addElement('radio', 'doc_state', get_lang('GroupDocument'), get_lang('NotAvailable'), TOOL_NOT_AVAILABLE); -$form->addElement('radio', 'doc_state', null, get_lang('Public'), TOOL_PUBLIC); -$form->addElement('radio', 'doc_state', null, get_lang('Private'), TOOL_PRIVATE); +$form->addElement('radio', 'doc_state', get_lang('GroupDocument'), get_lang('NotAvailable'), GroupManager::TOOL_NOT_AVAILABLE); +$form->addElement('radio', 'doc_state', null, get_lang('Public'), GroupManager::TOOL_PUBLIC); +$form->addElement('radio', 'doc_state', null, get_lang('Private'), GroupManager::TOOL_PRIVATE); // Work settings -$form->addElement('radio', 'work_state', get_lang('GroupWork'), get_lang('NotAvailable'), TOOL_NOT_AVAILABLE); -$form->addElement('radio', 'work_state', null, get_lang('Public'), TOOL_PUBLIC); -$form->addElement('radio', 'work_state', null, get_lang('Private'), TOOL_PRIVATE); +$form->addElement('radio', 'work_state', get_lang('GroupWork'), get_lang('NotAvailable'), GroupManager::TOOL_NOT_AVAILABLE); +$form->addElement('radio', 'work_state', null, get_lang('Public'), GroupManager::TOOL_PUBLIC); +$form->addElement('radio', 'work_state', null, get_lang('Private'), GroupManager::TOOL_PRIVATE); // Calendar settings -$form->addElement('radio', 'calendar_state', get_lang('GroupCalendar'), get_lang('NotAvailable'), TOOL_NOT_AVAILABLE); -$form->addElement('radio', 'calendar_state', null, get_lang('Public'), TOOL_PUBLIC); -$form->addElement('radio', 'calendar_state', null, get_lang('Private'), TOOL_PRIVATE); +$form->addElement('radio', 'calendar_state', get_lang('GroupCalendar'), get_lang('NotAvailable'), GroupManager::TOOL_NOT_AVAILABLE); +$form->addElement('radio', 'calendar_state', null, get_lang('Public'), GroupManager::TOOL_PUBLIC); +$form->addElement('radio', 'calendar_state', null, get_lang('Private'), GroupManager::TOOL_PRIVATE); // Announcements settings -$form->addElement('radio', 'announcements_state', get_lang('GroupAnnouncements'), get_lang('NotAvailable'), TOOL_NOT_AVAILABLE); -$form->addElement('radio', 'announcements_state', null, get_lang('Public'), TOOL_PUBLIC); -$form->addElement('radio', 'announcements_state', null, get_lang('Private'), TOOL_PRIVATE); +$form->addElement('radio', 'announcements_state', get_lang('GroupAnnouncements'), get_lang('NotAvailable'), GroupManager::TOOL_NOT_AVAILABLE); +$form->addElement('radio', 'announcements_state', null, get_lang('Public'), GroupManager::TOOL_PUBLIC); +$form->addElement('radio', 'announcements_state', null, get_lang('Private'), GroupManager::TOOL_PRIVATE); // Forum settings -$form->addElement('radio', 'forum_state', get_lang('GroupForum'), get_lang('NotAvailable'), TOOL_NOT_AVAILABLE); -$form->addElement('radio', 'forum_state', null, get_lang('Public'), TOOL_PUBLIC); -$form->addElement('radio', 'forum_state', null, get_lang('Private'), TOOL_PRIVATE); +$form->addElement('radio', 'forum_state', get_lang('GroupForum'), get_lang('NotAvailable'), GroupManager::TOOL_NOT_AVAILABLE); +$form->addElement('radio', 'forum_state', null, get_lang('Public'), GroupManager::TOOL_PUBLIC); +$form->addElement('radio', 'forum_state', null, get_lang('Private'), GroupManager::TOOL_PRIVATE); // Wiki Settings -$form->addElement('radio', 'wiki_state', get_lang('GroupWiki'), get_lang('NotAvailable'), TOOL_NOT_AVAILABLE); -$form->addElement('radio', 'wiki_state', null, get_lang('Public'), TOOL_PUBLIC); -$form->addElement('radio', 'wiki_state', null, get_lang('Private'), TOOL_PRIVATE); +$form->addElement('radio', 'wiki_state', get_lang('GroupWiki'), get_lang('NotAvailable'), GroupManager::TOOL_NOT_AVAILABLE); +$form->addElement('radio', 'wiki_state', null, get_lang('Public'), GroupManager::TOOL_PUBLIC); +$form->addElement('radio', 'wiki_state', null, get_lang('Private'), GroupManager::TOOL_PRIVATE); // Chat Settings -$form->addElement('radio', 'chat_state', get_lang('Chat'), get_lang('NotAvailable'), TOOL_NOT_AVAILABLE); -$form->addElement('radio', 'chat_state', null, get_lang('Public'), TOOL_PUBLIC); -$form->addElement('radio', 'chat_state', null, get_lang('Private'), TOOL_PRIVATE); +$form->addElement('radio', 'chat_state', get_lang('Chat'), get_lang('NotAvailable'), GroupManager::TOOL_NOT_AVAILABLE); +$form->addElement('radio', 'chat_state', null, get_lang('Public'), GroupManager::TOOL_PUBLIC); +$form->addElement('radio', 'chat_state', null, get_lang('Private'), GroupManager::TOOL_PRIVATE); // Submit $form->addElement('style_submit_button', 'submit', get_lang('PropModify'), 'class="save"'); @@ -167,8 +174,8 @@ $form->addElement('style_submit_button', 'submit', get_lang('PropModify'), 'clas // If form validates -> save data if ($form->validate()) { $values = $form->exportValues(); - if ($values['max_member_no_limit'] == MEMBER_PER_GROUP_NO_LIMIT) { - $max_member = MEMBER_PER_GROUP_NO_LIMIT; + if ($values['max_member_no_limit'] == GroupManager::MEMBER_PER_GROUP_NO_LIMIT) { + $max_member = GroupManager::MEMBER_PER_GROUP_NO_LIMIT; } else { $max_member = $values['max_member']; } @@ -198,8 +205,8 @@ echo ''; $defaults = $category; $defaults['action'] = $action; -if ($defaults['max_student'] == MEMBER_PER_GROUP_NO_LIMIT) { - $defaults['max_member_no_limit'] = MEMBER_PER_GROUP_NO_LIMIT; +if ($defaults['max_student'] == GroupManager::MEMBER_PER_GROUP_NO_LIMIT) { + $defaults['max_member_no_limit'] = GroupManager::MEMBER_PER_GROUP_NO_LIMIT; } else { $defaults['max_member_no_limit'] = 1; $defaults['max_member'] = $defaults['max_student']; diff --git a/main/group/group_creation.php b/main/group/group_creation.php index f51c5382cd..eb95bb1870 100644 --- a/main/group/group_creation.php +++ b/main/group/group_creation.php @@ -43,7 +43,7 @@ if (isset ($_POST['action'])) { $group['places'] = $_POST['group_0_places']; } if (api_get_setting('allow_group_categories') == 'false') { - $group['category'] = DEFAULT_GROUP_CATEGORY; + $group['category'] = GroupManager::DEFAULT_GROUP_CATEGORY; } elseif ($_POST['same_category']) { $group['category'] = $_POST['group_0_category']; } @@ -135,7 +135,7 @@ elseif (isset($_POST['number_of_groups'])) { $group_id = GroupManager :: get_number_of_groups() + 1; foreach ($group_categories as $index => $category) { // Don't allow new groups in the virtual course category! - if ($category['id'] != VIRTUAL_COURSE_CATEGORY) { + if ($category['id'] != GroupManager::VIRTUAL_COURSE_CATEGORY) { $cat_options[$category['id']] = $category['title']; } } @@ -310,7 +310,7 @@ EOT; $cat_options = array (); foreach ($group_categories as $index => $category) { // Don't allow new groups in the virtual course category! - if ($category['id'] != VIRTUAL_COURSE_CATEGORY) { + if ($category['id'] != GroupManager::VIRTUAL_COURSE_CATEGORY) { $cat_options[$category['id']] = $category['title']; } } diff --git a/main/group/group_edit.php b/main/group/group_edit.php index 09da332c91..c393c99336 100644 --- a/main/group/group_edit.php +++ b/main/group/group_edit.php @@ -90,7 +90,7 @@ function sort_users($user_a, $user_b) { */ function check_max_number_of_members($value) { $max_member_no_limit = $value['max_member_no_limit']; - if ($max_member_no_limit == MEMBER_PER_GROUP_NO_LIMIT) { + if ($max_member_no_limit == GroupManager::MEMBER_PER_GROUP_NO_LIMIT) { return true; } $max_member = $value['max_member']; @@ -101,7 +101,7 @@ function check_max_number_of_members($value) { * Function to check if the number of selected group members is valid */ function check_group_members($value) { - if ($value['max_member_no_limit'] == MEMBER_PER_GROUP_NO_LIMIT) { + if ($value['max_member_no_limit'] == GroupManager::MEMBER_PER_GROUP_NO_LIMIT) { return true; } if (isset($value['max_member']) && isset($value['group_members']) && $value['max_member'] < count($value['group_members'])) { @@ -207,7 +207,7 @@ $form->addFormRule('check_group_members'); //$form->addGroup($group, 'tutor_group', get_lang('GroupTutor'), '', false); // Members per group -$form->addElement('radio', 'max_member_no_limit', get_lang('GroupLimit'), get_lang('NoLimit'), MEMBER_PER_GROUP_NO_LIMIT); +$form->addElement('radio', 'max_member_no_limit', get_lang('GroupLimit'), get_lang('NoLimit'), GroupManager::MEMBER_PER_GROUP_NO_LIMIT); $group = array(); $group[] = & $form->createElement('radio', 'max_member_no_limit', null, get_lang('MaximumOfParticipants'), 1); $group[] = & $form->createElement('text', 'max_member', null, array('class' => 'span1')); @@ -223,52 +223,52 @@ $form->addGroup($group, '', Display::return_icon('user.png', get_lang('GroupSelf // Documents settings $group = array(); -$group[] = $form->createElement('radio', 'doc_state', get_lang('GroupDocument'), get_lang('NotAvailable'), TOOL_NOT_AVAILABLE); -$group[] = $form->createElement('radio', 'doc_state', null, get_lang('Public'), TOOL_PUBLIC); -$group[] = $form->createElement('radio', 'doc_state', null, get_lang('Private'), TOOL_PRIVATE); +$group[] = $form->createElement('radio', 'doc_state', get_lang('GroupDocument'), get_lang('NotAvailable'), GroupManager::TOOL_NOT_AVAILABLE); +$group[] = $form->createElement('radio', 'doc_state', null, get_lang('Public'), GroupManager::TOOL_PUBLIC); +$group[] = $form->createElement('radio', 'doc_state', null, get_lang('Private'), GroupManager::TOOL_PRIVATE); $form->addGroup($group, '', Display::return_icon('folder.png', get_lang('GroupDocument') , array(), ICON_SIZE_SMALL).' '.get_lang('GroupDocument'), '', false); // Work settings $group = array(); -$group[] = $form->createElement('radio', 'work_state', get_lang('GroupWork'), get_lang('NotAvailable'), TOOL_NOT_AVAILABLE); -$group[] = $form->createElement('radio', 'work_state', null, get_lang('Public'), TOOL_PUBLIC); -$group[] = $form->createElement('radio', 'work_state', null, get_lang('Private'), TOOL_PRIVATE); +$group[] = $form->createElement('radio', 'work_state', get_lang('GroupWork'), get_lang('NotAvailable'), GroupManager::TOOL_NOT_AVAILABLE); +$group[] = $form->createElement('radio', 'work_state', null, get_lang('Public'), GroupManager::TOOL_PUBLIC); +$group[] = $form->createElement('radio', 'work_state', null, get_lang('Private'), GroupManager::TOOL_PRIVATE); $form->addGroup($group, '', Display::return_icon('work.png', get_lang('GroupWork') , array(), ICON_SIZE_SMALL).' '.get_lang('GroupWork'), '', false); // Calendar settings $group = array(); -$group[] = $form->createElement('radio', 'calendar_state', get_lang('GroupCalendar'), get_lang('NotAvailable'), TOOL_NOT_AVAILABLE); -$group[] = $form->createElement('radio', 'calendar_state', null, get_lang('Public'), TOOL_PUBLIC); -$group[] = $form->createElement('radio', 'calendar_state', null, get_lang('Private'), TOOL_PRIVATE); +$group[] = $form->createElement('radio', 'calendar_state', get_lang('GroupCalendar'), get_lang('NotAvailable'), GroupManager::TOOL_NOT_AVAILABLE); +$group[] = $form->createElement('radio', 'calendar_state', null, get_lang('Public'), GroupManager::TOOL_PUBLIC); +$group[] = $form->createElement('radio', 'calendar_state', null, get_lang('Private'), GroupManager::TOOL_PRIVATE); $form->addGroup($group, '', Display::return_icon('agenda.png', get_lang('GroupCalendar') , array(), ICON_SIZE_SMALL).' '.get_lang('GroupCalendar'), '', false); // Announcements settings $group = array(); -$group[] = $form->createElement('radio', 'announcements_state', get_lang('GroupAnnouncements'), get_lang('NotAvailable'), TOOL_NOT_AVAILABLE); -$group[] = $form->createElement('radio', 'announcements_state', null, get_lang('Public'), TOOL_PUBLIC); -$group[] = $form->createElement('radio', 'announcements_state', null, get_lang('Private'), TOOL_PRIVATE); +$group[] = $form->createElement('radio', 'announcements_state', get_lang('GroupAnnouncements'), get_lang('NotAvailable'), GroupManager::TOOL_NOT_AVAILABLE); +$group[] = $form->createElement('radio', 'announcements_state', null, get_lang('Public'), GroupManager::TOOL_PUBLIC); +$group[] = $form->createElement('radio', 'announcements_state', null, get_lang('Private'), GroupManager::TOOL_PRIVATE); $form->addGroup($group, '', Display::return_icon('announce.png', get_lang('GroupAnnouncements') , array(), ICON_SIZE_SMALL).' '.get_lang('GroupAnnouncements'), '', false); //Forum settings $group = array(); -$group[] = $form->createElement('radio', 'forum_state', get_lang('GroupForum'), get_lang('NotAvailable'), TOOL_NOT_AVAILABLE); -$group[] = $form->createElement('radio', 'forum_state', null, get_lang('Public'), TOOL_PUBLIC); -$group[] = $form->createElement('radio', 'forum_state', null, get_lang('Private'), TOOL_PRIVATE); +$group[] = $form->createElement('radio', 'forum_state', get_lang('GroupForum'), get_lang('NotAvailable'), GroupManager::TOOL_NOT_AVAILABLE); +$group[] = $form->createElement('radio', 'forum_state', null, get_lang('Public'), GroupManager::TOOL_PUBLIC); +$group[] = $form->createElement('radio', 'forum_state', null, get_lang('Private'), GroupManager::TOOL_PRIVATE); $form->addGroup($group, '', Display::return_icon('forum.png', get_lang('GroupForum') , array(), ICON_SIZE_SMALL).' '.get_lang('GroupForum'), '', false); // Wiki settings $group = array(); -$group[] = $form->createElement('radio', 'wiki_state', get_lang('GroupWiki'), get_lang('NotAvailable'), TOOL_NOT_AVAILABLE); -$group[] = $form->createElement('radio', 'wiki_state', null, get_lang('Public'), TOOL_PUBLIC); -$group[] = $form->createElement('radio', 'wiki_state', null, get_lang('Private'), TOOL_PRIVATE); +$group[] = $form->createElement('radio', 'wiki_state', get_lang('GroupWiki'), get_lang('NotAvailable'), GroupManager::TOOL_NOT_AVAILABLE); +$group[] = $form->createElement('radio', 'wiki_state', null, get_lang('Public'), GroupManager::TOOL_PUBLIC); +$group[] = $form->createElement('radio', 'wiki_state', null, get_lang('Private'), GroupManager::TOOL_PRIVATE); $form->addGroup($group, '', Display::return_icon('wiki.png', get_lang('GroupWiki') , array(), ICON_SIZE_SMALL).' '.get_lang('GroupWiki'), '', false); // Chat settings $group = array(); -$group[] = $form->createElement('radio', 'chat_state', get_lang('Chat'), get_lang('NotAvailable'), TOOL_NOT_AVAILABLE); -$group[] = $form->createElement('radio', 'chat_state', null, get_lang('Public'), TOOL_PUBLIC); -$group[] = $form->createElement('radio', 'chat_state', null, get_lang('Private'), TOOL_PRIVATE); +$group[] = $form->createElement('radio', 'chat_state', get_lang('Chat'), get_lang('NotAvailable'), GroupManager::TOOL_NOT_AVAILABLE); +$group[] = $form->createElement('radio', 'chat_state', null, get_lang('Public'), GroupManager::TOOL_PUBLIC); +$group[] = $form->createElement('radio', 'chat_state', null, get_lang('Private'), GroupManager::TOOL_PRIVATE); $form->addGroup($group, '', Display::return_icon('chat.png', get_lang('Chat') , array(), ICON_SIZE_SMALL).' '.get_lang('Chat'), '', false); // submit button @@ -276,8 +276,8 @@ $form->addElement('style_submit_button', 'submit', get_lang('PropModify'), 'clas if ($form->validate()) { $values = $form->exportValues(); - if ($values['max_member_no_limit'] == MEMBER_PER_GROUP_NO_LIMIT) { - $max_member = MEMBER_PER_GROUP_NO_LIMIT; + if ($values['max_member_no_limit'] == GroupManager::MEMBER_PER_GROUP_NO_LIMIT) { + $max_member = GroupManager::MEMBER_PER_GROUP_NO_LIMIT; } else { $max_member = $values['max_member']; } @@ -298,9 +298,9 @@ if ($form->validate()) { } // Returning to the group area (note: this is inconsistent with the rest of chamilo) - //var_dump(count($_POST['group_members']), $max_member, MEMBER_PER_GROUP_NO_LIMIT); + //var_dump(count($_POST['group_members']), $max_member, GroupManager::MEMBER_PER_GROUP_NO_LIMIT); $cat = GroupManager :: get_category_from_group($current_group['id']); - if (isset($_POST['group_members']) && count($_POST['group_members']) > $max_member && $max_member != MEMBER_PER_GROUP_NO_LIMIT) { + if (isset($_POST['group_members']) && count($_POST['group_members']) > $max_member && $max_member != GroupManager::MEMBER_PER_GROUP_NO_LIMIT) { header('Location:group_edit.php?show_message='.get_lang('GroupTooMuchMembers')); } else { header('Location: '.$values['referer'].'?action=show_msg&msg='.get_lang('GroupSettingsModified').'&category='.$cat['id']); @@ -312,8 +312,8 @@ $defaults['group_members'] = $selected_users; $defaults['group_tutors'] = $selected_tutors; $action = isset($_GET['action']) ? $_GET['action'] : ''; $defaults['action'] = $action; -if ($defaults['maximum_number_of_students'] == MEMBER_PER_GROUP_NO_LIMIT) { - $defaults['max_member_no_limit'] = MEMBER_PER_GROUP_NO_LIMIT; +if ($defaults['maximum_number_of_students'] == GroupManager::MEMBER_PER_GROUP_NO_LIMIT) { + $defaults['max_member_no_limit'] = GroupManager::MEMBER_PER_GROUP_NO_LIMIT; } else { $defaults['max_member_no_limit'] = 1; $defaults['max_member'] = $defaults['maximum_number_of_students']; diff --git a/main/group/group_space.php b/main/group/group_space.php index c193a4fab9..2ff27a6e8c 100644 --- a/main/group/group_space.php +++ b/main/group/group_space.php @@ -143,7 +143,7 @@ if (api_is_allowed_to_edit(false, true) OR GroupManager :: is_user_in_group(api_ $forums_of_groups = get_forums_of_group($current_group['id']); if (is_array($forums_of_groups)) { - if ($current_group['forum_state'] != TOOL_NOT_AVAILABLE ) { + if ($current_group['forum_state'] != GroupManager::TOOL_NOT_AVAILABLE ) { foreach ($forums_of_groups as $key => $value) { if ($value['forum_group_public_private'] == 'public' || (/*!empty($user_subscribe_to_current_group) && */ $value['forum_group_public_private'] == 'private') || !empty($user_is_tutor) || api_is_allowed_to_edit(false, true)) { $tools .= '
  • '.Display::return_icon('forum.png', get_lang('Forum').': '.$value['forum_title'] , array(), 32).'
  • '; @@ -151,27 +151,27 @@ if (api_is_allowed_to_edit(false, true) OR GroupManager :: is_user_in_group(api_ } } } - if ($current_group['doc_state'] != TOOL_NOT_AVAILABLE ) { + if ($current_group['doc_state'] != GroupManager::TOOL_NOT_AVAILABLE ) { // Link to the documents area of this group $tools .= '
  • '.Display::return_icon('folder.png', get_lang('GroupDocument'), array(), 32).'
  • '; } - if ($current_group['calendar_state'] != TOOL_NOT_AVAILABLE) { + if ($current_group['calendar_state'] != GroupManager::TOOL_NOT_AVAILABLE) { // Link to a group-specific part of agenda $tools .= '
  • '.Display::return_icon('agenda.png', get_lang('GroupCalendar'), array(), 32).'
  • '; } - if ($current_group['work_state'] != TOOL_NOT_AVAILABLE) { + if ($current_group['work_state'] != GroupManager::TOOL_NOT_AVAILABLE) { // Link to the works area of this group $tools .= '
  • '.Display::return_icon('work.png', get_lang('GroupWork'), array(), 32).'
  • '; } - if ($current_group['announcements_state'] != TOOL_NOT_AVAILABLE) { + if ($current_group['announcements_state'] != GroupManager::TOOL_NOT_AVAILABLE) { // Link to a group-specific part of announcements $tools .= '
  • '.Display::return_icon('announce.png', get_lang('GroupAnnouncements'), array(), 32).'
  • '; } - if ($current_group['wiki_state'] != TOOL_NOT_AVAILABLE) { + if ($current_group['wiki_state'] != GroupManager::TOOL_NOT_AVAILABLE) { // Link to the wiki area of this group $tools .= '
  • '.Display::return_icon('wiki.png', get_lang('GroupWiki'), array(), 32).'
  • '; } - if ($current_group['chat_state'] != TOOL_NOT_AVAILABLE) { + if ($current_group['chat_state'] != GroupManager::TOOL_NOT_AVAILABLE) { // Link to the chat area of this group if (api_get_course_setting('allow_open_chat_window')) { $tools .= "
  • ".Display::return_icon('chat.png', get_lang('Chat'),'',ICON_SIZE_MEDIUM)."
  • "; @@ -192,7 +192,7 @@ echo ''; // Link to the forum of this group $forums_of_groups = get_forums_of_group($current_group['id']); if (is_array($forums_of_groups)) { - if ( $current_group['forum_state'] == TOOL_PUBLIC ) { + if ( $current_group['forum_state'] == GroupManager::TOOL_PUBLIC ) { foreach ($forums_of_groups as $key => $value) { if ($value['forum_group_public_private'] == 'public' ) { $tools.= '
  • '.Display::return_icon('forum.png', get_lang('GroupForum'), array(), 32).'
  • '; @@ -200,27 +200,27 @@ echo ''; } } } - if ($current_group['doc_state'] == TOOL_PUBLIC) { + if ($current_group['doc_state'] == GroupManager::TOOL_PUBLIC) { // Link to the documents area of this group $tools .= '
  • '.Display::return_icon('folder.png', get_lang('GroupDocument'), array(), 32).'
  • '; } - if ($current_group['calendar_state'] == TOOL_PUBLIC) { + if ($current_group['calendar_state'] == GroupManager::TOOL_PUBLIC) { // Link to a group-specific part of agenda $tools .= '
  • '.Display::return_icon('agenda.png', get_lang('GroupCalendar'), array(), 32).'
  • '; } - if ($current_group['work_state'] == TOOL_PUBLIC) { + if ($current_group['work_state'] == GroupManager::TOOL_PUBLIC) { // Link to the works area of this group $tools .= '
  • '.Display::return_icon('work.png', get_lang('GroupWork'), array(), 32).'
  • '; } - if ($current_group['announcements_state'] == TOOL_PUBLIC) { + if ($current_group['announcements_state'] == GroupManager::TOOL_PUBLIC) { // Link to a group-specific part of announcements $tools .= '
  • '.Display::return_icon('announce.png', get_lang('GroupAnnouncements'), array(), 32).'
  • '; } - if ($current_group['wiki_state'] == TOOL_PUBLIC) { + if ($current_group['wiki_state'] == GroupManager::TOOL_PUBLIC) { // Link to the wiki area of this group $tools .= '
  • '.Display::return_icon('wiki.png', get_lang('GroupWiki'), array(), 32).'
  • '; } - if ($current_group['chat_state'] == TOOL_PUBLIC ) { + if ($current_group['chat_state'] == GroupManager::TOOL_PUBLIC ) { // Link to the chat area of this group if (api_get_course_setting('allow_open_chat_window')) { $tools .= "
  • ".Display::return_icon('chat.png', get_lang("Chat"), array(), 32)."
  • "; diff --git a/main/inc/lib/groupmanager.lib.php b/main/inc/lib/groupmanager.lib.php index 1fec8ea884..531ac04822 100644 --- a/main/inc/lib/groupmanager.lib.php +++ b/main/inc/lib/groupmanager.lib.php @@ -12,47 +12,6 @@ require_once 'fileManage.lib.php'; require_once 'fileUpload.lib.php'; require_once 'document.lib.php'; -/** - * infinite - */ -define("INFINITE", "99999"); -/** - * No limit on the number of users in a group - */ -define("MEMBER_PER_GROUP_NO_LIMIT", "0"); -/** - * No limit on the number of groups per user - */ -define("GROUP_PER_MEMBER_NO_LIMIT", "0"); -/** - * The tools of a group can have 3 states - * - not available - * - public - * - private - */ -define("TOOL_NOT_AVAILABLE", "0"); -define("TOOL_PUBLIC", "1"); -define("TOOL_PRIVATE", "2"); -/** - * Constants for the available group tools - */ -define("GROUP_TOOL_FORUM", "0"); -define("GROUP_TOOL_DOCUMENTS", "1"); -define("GROUP_TOOL_CALENDAR","2"); -define("GROUP_TOOL_ANNOUNCEMENT","3"); -define("GROUP_TOOL_WORK","4"); -define("GROUP_TOOL_WIKI", "5"); -define("GROUP_TOOL_CHAT", "6"); - -/** - * Fixed id's for group categories - * - VIRTUAL_COURSE_CATEGORY: in this category groups are created based on the - * virtual course of a course - * - DEFAULT_GROUP_CATEGORY: When group categories aren't available (platform- - * setting), all groups are created in this 'dummy'-category - */ -define("VIRTUAL_COURSE_CATEGORY", 1); -define("DEFAULT_GROUP_CATEGORY", 2); /** * This library contains some functions for group-management. * @author Bart Mollet @@ -61,6 +20,49 @@ define("DEFAULT_GROUP_CATEGORY", 2); * be used outside a session. */ class GroupManager { + //- VIRTUAL_COURSE_CATEGORY: in this category groups are created based on the virtual course of a course + CONST VIRTUAL_COURSE_CATEGORY = 1; + + //DEFAULT_GROUP_CATEGORY: When group categories aren't available (platform-setting), all groups are created in this 'dummy'-category + CONST DEFAULT_GROUP_CATEGORY = 2; + + /** + * infinite + */ + CONST INFINITE = 99999; + /** + * No limit on the number of users in a group + */ + CONST MEMBER_PER_GROUP_NO_LIMIT = 0; + /** + * No limit on the number of groups per user + */ + CONST GROUP_PER_MEMBER_NO_LIMIT = 0; + /** + * The tools of a group can have 3 states + * - not available + * - public + * - private + */ + CONST TOOL_NOT_AVAILABLE = 0; + CONST TOOL_PUBLIC = 1; + CONST TOOL_PRIVATE = 2; + /** + * Constants for the available group tools + */ + CONST GROUP_TOOL_FORUM = 0; + CONST GROUP_TOOL_DOCUMENTS = 1; + CONST GROUP_TOOL_CALENDAR = 2; + CONST GROUP_TOOL_ANNOUNCEMENT = 3; + CONST GROUP_TOOL_WORK = 4; + CONST GROUP_TOOL_WIKI = 5; + CONST GROUP_TOOL_CHAT = 6; + + + + + + //GROUP FUNCTIONS private function __construct() { } @@ -173,7 +175,7 @@ class GroupManager { $groups = array (); $thisGroup= array(); while ($thisGroup = Database::fetch_array($groupList)) { - if ($thisGroup['category_id'] == VIRTUAL_COURSE_CATEGORY) { + if ($thisGroup['category_id'] == self::VIRTUAL_COURSE_CATEGORY) { $sql = "SELECT title FROM $table_course WHERE code = '".$thisGroup['name']."'"; $obj = Database::fetch_object(Database::query($sql)); $thisGroup['name'] = $obj->title; @@ -288,7 +290,7 @@ class GroupManager { public static function create_subgroups ($group_id, $number_of_groups) { $course_id = api_get_course_int_id(); $table_group = Database :: get_course_table(TABLE_GROUP); - $category_id = self :: create_category('Subgroups', '', TOOL_PRIVATE, TOOL_PRIVATE, 0, 0, 1, 1); + $category_id = self :: create_category('Subgroups', '', GroupManager::TOOL_PRIVATE, GroupManager::TOOL_PRIVATE, 0, 0, 1, 1); $users = self :: get_users($group_id); $group_ids = array (); @@ -310,12 +312,12 @@ class GroupManager { * Create groups from all virtual courses in the given course. */ public static function create_groups_from_virtual_courses() { - self :: delete_category(VIRTUAL_COURSE_CATEGORY); - $id = self :: create_category(get_lang('GroupsFromVirtualCourses'), '', TOOL_NOT_AVAILABLE, TOOL_NOT_AVAILABLE, 0, 0, 1, 1); + self :: delete_category(self::VIRTUAL_COURSE_CATEGORY); + $id = self :: create_category(get_lang('GroupsFromVirtualCourses'), '', GroupManager::TOOL_NOT_AVAILABLE, GroupManager::TOOL_NOT_AVAILABLE, 0, 0, 1, 1); $table_group_cat = Database :: get_course_table(TABLE_GROUP_CATEGORY); $course_id = api_get_course_int_id(); - $sql = "UPDATE ".$table_group_cat." SET id=".VIRTUAL_COURSE_CATEGORY." WHERE c_id = $course_id AND id=$id"; + $sql = "UPDATE ".$table_group_cat." SET id=".self::VIRTUAL_COURSE_CATEGORY." WHERE c_id = $course_id AND id=$id"; Database::query($sql); $course = api_get_course_info(); $course['code'] = $course['sysCode']; @@ -332,7 +334,7 @@ class GroupManager { $members[] = $user['user_id']; } } - $id = self :: create_group($group_course['code'], VIRTUAL_COURSE_CATEGORY, 0, count($members)); + $id = self :: create_group($group_course['code'], self::VIRTUAL_COURSE_CATEGORY, 0, count($members)); self :: subscribe_users($members, $id); $ids[] = $id; } @@ -668,7 +670,7 @@ class GroupManager { max_student = '".Database::escape_string($maximum_number_of_students)."' "; Database::query($sql); $id = Database::insert_id(); - if ($id == VIRTUAL_COURSE_CATEGORY) { + if ($id == self::VIRTUAL_COURSE_CATEGORY) { $sql = "UPDATE ".$table_group_category." SET id = ". ($id +1)." WHERE c_id = $course_id AND id = $id"; Database::query($sql); return $id +1; @@ -848,8 +850,10 @@ class GroupManager { * @return void */ public static function fill_groups ($group_ids) { + global $_course; + $group_ids = is_array($group_ids) ? $group_ids : array ($group_ids); - $group_ids = array_map('intval',$group_ids); + $group_ids = array_map('intval', $group_ids); if (api_is_course_coach()) { for ($i=0 ; $i< count($group_ids) ; $i++) { @@ -862,8 +866,7 @@ class GroupManager { return false; } } - - global $_course; + $category = self::get_category_from_group($group_ids[0]); $groups_per_user = $category['groups_per_user']; @@ -871,25 +874,23 @@ class GroupManager { $group_user_table = Database :: get_course_table(TABLE_GROUP_USER); $session_id = api_get_session_id(); - $complete_user_list = CourseManager :: get_real_and_linked_user_list($_course['code'], true, $session_id); - $number_groups_per_user = ($groups_per_user == GROUP_PER_MEMBER_NO_LIMIT ? INFINITE : $groups_per_user); + $complete_user_list = CourseManager :: get_real_and_linked_user_list($_course['code'], true, $session_id); + $number_groups_per_user = ($groups_per_user == self::GROUP_PER_MEMBER_NO_LIMIT ? self::INFINITE : $groups_per_user); /* * Retrieve all the groups where enrollment is still allowed * (reverse) ordered by the number of place available */ - $course_id = api_get_course_int_id(); - + $course_id = api_get_course_int_id(); $sql = "SELECT g.id gid, g.max_student-count(ug.user_id) nbPlaces, g.max_student FROM ".$group_table." g - LEFT JOIN ".$group_user_table." ug - ON g.id = ug.group_id - WHERE - g.c_id = $course_id AND + LEFT JOIN ".$group_user_table." ug ON + g.c_id = $course_id AND ug.c_id = $course_id AND g.id = ug.group_id + WHERE g.id IN (".implode(',', $group_ids).") GROUP BY (g.id) - HAVING (nbPlaces > 0 OR g.max_student = ".MEMBER_PER_GROUP_NO_LIMIT.") + HAVING (nbPlaces > 0 OR g.max_student = ".GroupManager::MEMBER_PER_GROUP_NO_LIMIT.") ORDER BY nbPlaces DESC"; $sql_result = Database::query($sql); $group_available_place = array (); @@ -976,7 +977,7 @@ class GroupManager { $db_result = Database::query("SELECT max_student FROM $table_group WHERE c_id = $course_id AND id = $group_id"); $db_object = Database::fetch_object($db_result); if ($db_object->max_student == 0) { - return INFINITE; + return self::INFINITE; } return $db_object->max_student; } @@ -1072,8 +1073,8 @@ class GroupManager { $result = CourseManager :: is_user_subscribed_in_real_or_linked_course($user_id, $course_code); $result = !self :: is_subscribed($user_id, $group_id); $result &= (self :: number_of_students($group_id) < self :: maximum_number_of_students($group_id)); - if ($category['groups_per_user'] == GROUP_PER_MEMBER_NO_LIMIT) { - $category['groups_per_user'] = INFINITE; + if ($category['groups_per_user'] == self::GROUP_PER_MEMBER_NO_LIMIT) { + $category['groups_per_user'] = self::INFINITE; } $result &= (self :: user_in_number_of_groups($user_id, $category['id']) < $category['groups_per_user']); $result &= !self :: is_tutor_of_group($user_id, $group_id); @@ -1411,7 +1412,7 @@ class GroupManager { public static function get_complete_list_of_users_that_can_be_added_to_group ($course_code, $group_id) { global $_course, $_user; $category = self :: get_category_from_group($group_id, $course_code); - $number_of_groups_limit = $category['groups_per_user'] == GROUP_PER_MEMBER_NO_LIMIT ? INFINITE : $category['groups_per_user']; + $number_of_groups_limit = $category['groups_per_user'] == self::GROUP_PER_MEMBER_NO_LIMIT ? self::INFINITE : $category['groups_per_user']; $real_course_code = $_course['sysCode']; $real_course_info = Database :: get_course_info($real_course_code); $real_course_user_list = CourseManager :: get_user_list_from_course_code($real_course_code); @@ -1535,25 +1536,25 @@ class GroupManager { } switch ($tool) { - case GROUP_TOOL_FORUM : + case self::GROUP_TOOL_FORUM : $state_key = 'forum_state'; break; - case GROUP_TOOL_DOCUMENTS : + case self::GROUP_TOOL_DOCUMENTS : $state_key = 'doc_state'; break; - case GROUP_TOOL_CALENDAR : + case self::GROUP_TOOL_CALENDAR : $state_key = 'calendar_state'; break; - case GROUP_TOOL_ANNOUNCEMENT : + case self::GROUP_TOOL_ANNOUNCEMENT : $state_key = 'announcements_state'; break; - case GROUP_TOOL_WORK : + case self::GROUP_TOOL_WORK : $state_key = 'work_state'; break; - case GROUP_TOOL_WIKI : + case self::GROUP_TOOL_WIKI : $state_key = 'wiki_state'; break; - case GROUP_TOOL_CHAT : + case self::GROUP_TOOL_CHAT : $state_key = 'chat_state'; break; default: @@ -1570,24 +1571,24 @@ class GroupManager { if (!empty($category_group_info)) { //if exists check the category group status first - if ($category_group_info[$state_key] == TOOL_NOT_AVAILABLE) { + if ($category_group_info[$state_key] == GroupManager::TOOL_NOT_AVAILABLE) { return false; - } elseif($category_group_info[$state_key] == TOOL_PRIVATE && !$user_is_in_group) { + } elseif($category_group_info[$state_key] == GroupManager::TOOL_PRIVATE && !$user_is_in_group) { return false; } } //is_user_in_group() is more complete that the is_subscribed() function - if ($group_info[$state_key] == TOOL_NOT_AVAILABLE) { + if ($group_info[$state_key] == GroupManager::TOOL_NOT_AVAILABLE) { return false; - } elseif ($group_info[$state_key] == TOOL_PUBLIC) { + } elseif ($group_info[$state_key] == self::TOOL_PUBLIC) { return true; } elseif (api_is_allowed_to_edit(false,true)) { return true; } elseif($group_info['tutor_id'] == $user_id) { //this tutor implementation was dropped return true; - } elseif($group_info[$state_key] == TOOL_PRIVATE && !$user_is_in_group) { + } elseif($group_info[$state_key] == GroupManager::TOOL_PRIVATE && !$user_is_in_group) { return false; } else { return $user_is_in_group; @@ -1647,7 +1648,7 @@ class GroupManager { $group_user_table = Database :: get_course_table(TABLE_GROUP_USER); $session_id = api_get_session_id(); $complete_user_list = CourseManager :: get_real_and_linked_user_list($_course['sysCode'], true, $session_id); - $number_groups_per_user = ($groups_per_user == GROUP_PER_MEMBER_NO_LIMIT ? INFINITE : $groups_per_user); + $number_groups_per_user = ($groups_per_user == self::GROUP_PER_MEMBER_NO_LIMIT ? self::INFINITE : $groups_per_user); $course_id = api_get_course_int_id(); /* * Retrieve all the groups where enrollment is still allowed @@ -1661,7 +1662,7 @@ class GroupManager { ug.c_id = $course_id AND g.id IN (".implode(',', $group_ids).") GROUP BY (g.id) - HAVING (nbPlaces > 0 OR g.max_student = ".MEMBER_PER_GROUP_NO_LIMIT.") + HAVING (nbPlaces > 0 OR g.max_student = ".GroupManager::MEMBER_PER_GROUP_NO_LIMIT.") ORDER BY nbPlaces DESC"; $sql_result = Database::query($sql); $group_available_place = array (); diff --git a/main/tracking/courseLog.php b/main/tracking/courseLog.php index 578784748e..75c6962758 100644 --- a/main/tracking/courseLog.php +++ b/main/tracking/courseLog.php @@ -708,4 +708,4 @@ if ($_GET['studentlist'] == 'false') { $table->display(); } -Display::display_footer(); +Display::display_footer(); \ No newline at end of file diff --git a/main/work/work.php b/main/work/work.php index e054e3afcf..08d63b3e7f 100644 --- a/main/work/work.php +++ b/main/work/work.php @@ -188,7 +188,7 @@ if (!empty($group_id)) { $show_work = true; } else { // you are not a teacher - $show_work = GroupManager::user_has_access($user_id, $group_id, GROUP_TOOL_WORK); + $show_work = GroupManager::user_has_access($user_id, $group_id, GroupManager::GROUP_TOOL_WORK); } if (!$show_work) {