|
@@ -33,7 +33,7 @@ $interbreadcrumb[] = array ('url' => 'group_space.php?'.api_get_cidReq(), 'name'
|
|
|
$is_group_member = GroupManager :: is_tutor_of_group(api_get_user_id(), $group_id);
|
|
|
|
|
|
if (!api_is_allowed_to_edit(false, true) && !$is_group_member) {
|
|
|
- api_not_allowed(true);
|
|
|
+ api_not_allowed(true);
|
|
|
}
|
|
|
|
|
|
/* FUNCTIONS */
|
|
@@ -41,68 +41,77 @@ if (!api_is_allowed_to_edit(false, true) && !$is_group_member) {
|
|
|
/**
|
|
|
* List all users registered to the course
|
|
|
*/
|
|
|
-function search_members_keyword($firstname, $lastname, $username, $official_code, $keyword) {
|
|
|
- if (api_strripos($firstname, $keyword) !== false || api_strripos($lastname, $keyword) !== false || api_strripos($username, $keyword) !== false || api_strripos($official_code, $keyword) !== false) {
|
|
|
- return true;
|
|
|
- } else {
|
|
|
- return false;
|
|
|
- }
|
|
|
+function search_members_keyword($firstname, $lastname, $username, $official_code, $keyword)
|
|
|
+{
|
|
|
+ if (api_strripos($firstname, $keyword) !== false ||
|
|
|
+ api_strripos($lastname, $keyword) !== false ||
|
|
|
+ api_strripos($username, $keyword) !== false ||
|
|
|
+ api_strripos($official_code, $keyword) !== false
|
|
|
+ ) {
|
|
|
+ return true;
|
|
|
+ } else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * function to sort users after getting the list in the db. Necessary because there are 2 or 3 queries. Called by usort()
|
|
|
+ * Function to sort users after getting the list in the DB.
|
|
|
+ * Necessary because there are 2 or 3 queries. Called by usort()
|
|
|
*/
|
|
|
-function sort_users($user_a, $user_b) {
|
|
|
- if (api_sort_by_first_name()) {
|
|
|
- $cmp = api_strcmp($user_a['firstname'], $user_b['firstname']);
|
|
|
- if ($cmp !== 0) {
|
|
|
- return $cmp;
|
|
|
- } else {
|
|
|
- $cmp = api_strcmp($user_a['lastname'], $user_b['lastname']);
|
|
|
- if ($cmp !== 0) {
|
|
|
- return $cmp;
|
|
|
- } else {
|
|
|
- return api_strcmp($user_a['username'], $user_b['username']);
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- $cmp = api_strcmp($user_a['lastname'], $user_b['lastname']);
|
|
|
- if ($cmp !== 0) {
|
|
|
- return $cmp;
|
|
|
- } else {
|
|
|
- $cmp = api_strcmp($user_a['firstname'], $user_b['firstname']);
|
|
|
- if ($cmp !== 0) {
|
|
|
- return $cmp;
|
|
|
- } else {
|
|
|
- return api_strcmp($user_a['username'], $user_b['username']);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+function sort_users($user_a, $user_b)
|
|
|
+{
|
|
|
+ if (api_sort_by_first_name()) {
|
|
|
+ $cmp = api_strcmp($user_a['firstname'], $user_b['firstname']);
|
|
|
+ if ($cmp !== 0) {
|
|
|
+ return $cmp;
|
|
|
+ } else {
|
|
|
+ $cmp = api_strcmp($user_a['lastname'], $user_b['lastname']);
|
|
|
+ if ($cmp !== 0) {
|
|
|
+ return $cmp;
|
|
|
+ } else {
|
|
|
+ return api_strcmp($user_a['username'], $user_b['username']);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ $cmp = api_strcmp($user_a['lastname'], $user_b['lastname']);
|
|
|
+ if ($cmp !== 0) {
|
|
|
+ return $cmp;
|
|
|
+ } else {
|
|
|
+ $cmp = api_strcmp($user_a['firstname'], $user_b['firstname']);
|
|
|
+ if ($cmp !== 0) {
|
|
|
+ return $cmp;
|
|
|
+ } else {
|
|
|
+ return api_strcmp($user_a['username'], $user_b['username']);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Function to check the given max number of members per group
|
|
|
*/
|
|
|
-function check_max_number_of_members($value) {
|
|
|
- $max_member_no_limit = $value['max_member_no_limit'];
|
|
|
- if ($max_member_no_limit == GroupManager::MEMBER_PER_GROUP_NO_LIMIT) {
|
|
|
- return true;
|
|
|
- }
|
|
|
- $max_member = $value['max_member'];
|
|
|
- return is_numeric($max_member);
|
|
|
+function check_max_number_of_members($value)
|
|
|
+{
|
|
|
+ $max_member_no_limit = $value['max_member_no_limit'];
|
|
|
+ if ($max_member_no_limit == GroupManager::MEMBER_PER_GROUP_NO_LIMIT) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ $max_member = $value['max_member'];
|
|
|
+ return is_numeric($max_member);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Function to check if the number of selected group members is valid
|
|
|
*/
|
|
|
-function check_group_members($value) {
|
|
|
- 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'])) {
|
|
|
- return array ('group_members' => get_lang('GroupTooMuchMembers'));
|
|
|
- }
|
|
|
- return true;
|
|
|
+function check_group_members($value)
|
|
|
+{
|
|
|
+ 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'])) {
|
|
|
+ return array ('group_members' => get_lang('GroupTooMuchMembers'));
|
|
|
+ }
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
/* MAIN CODE */
|
|
@@ -129,8 +138,8 @@ $form->add_textfield('name', get_lang('GroupName'));
|
|
|
$form->addElement('textarea', 'description', get_lang('Description'), array ('class' => 'span6', 'rows' => 6));
|
|
|
|
|
|
$complete_user_list = GroupManager :: fill_groups_list($current_group['id']);
|
|
|
-
|
|
|
usort($complete_user_list, 'sort_users');
|
|
|
+
|
|
|
$possible_users = array();
|
|
|
foreach ($complete_user_list as $index => $user) {
|
|
|
$possible_users[$user['user_id']] = api_get_person_name($user['firstname'], $user['lastname']).' ('.$user['username'].')';
|
|
@@ -172,7 +181,7 @@ foreach ($group_member_list as $index => $user) {
|
|
|
// possible : number_groups_left > 0 and is group member
|
|
|
$possible_users = array();
|
|
|
foreach ($complete_user_list as $index => $user) {
|
|
|
- if ($user['number_groups_left'] > 0 || in_array($user['user_id'], $selected_users) ) {
|
|
|
+ if ($user['number_groups_left'] > 0 || in_array($user['user_id'], $selected_users)) {
|
|
|
$possible_users[$user['user_id']] = api_get_person_name($user['firstname'], $user['lastname']).' ('.$user['username'].')';
|
|
|
}
|
|
|
}
|
|
@@ -205,9 +214,10 @@ $form->addGroup($group, 'max_member_group', null, '', false);
|
|
|
$form->addRule('max_member_group', get_lang('InvalidMaxNumberOfMembers'), 'callback', 'check_max_number_of_members');
|
|
|
|
|
|
// Self registration
|
|
|
-$group = array();
|
|
|
-$group[] = $form->createElement('checkbox', 'self_registration_allowed', get_lang('GroupSelfRegistration'), get_lang('GroupAllowStudentRegistration'), 1);
|
|
|
-$group[] = $form->createElement('checkbox', 'self_unregistration_allowed', null, get_lang('GroupAllowStudentUnregistration'), 1);
|
|
|
+$group = array(
|
|
|
+ $form->createElement('checkbox', 'self_registration_allowed', get_lang('GroupSelfRegistration'), get_lang('GroupAllowStudentRegistration'), 1),
|
|
|
+ $form->createElement('checkbox', 'self_unregistration_allowed', null, get_lang('GroupAllowStudentUnregistration'), 1)
|
|
|
+);
|
|
|
$form->addGroup($group, '', Display::return_icon('user.png', get_lang('GroupSelfRegistration') , array(), ICON_SIZE_SMALL).' '.get_lang('GroupSelfRegistration'), '', false);
|
|
|
|
|
|
// Documents settings
|
|
@@ -246,33 +256,35 @@ $group[] = $form->createElement('radio', 'forum_state', null, get_lang('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'), 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);
|
|
|
+$group = array(
|
|
|
+ $form->createElement('radio', 'wiki_state', get_lang('GroupWiki'), get_lang('NotAvailable'), GroupManager::TOOL_NOT_AVAILABLE),
|
|
|
+ $form->createElement('radio', 'wiki_state', null, get_lang('Public'), GroupManager::TOOL_PUBLIC),
|
|
|
+ $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'), 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);
|
|
|
+$group = array(
|
|
|
+ $form->createElement('radio', 'chat_state', get_lang('Chat'), get_lang('NotAvailable'), GroupManager::TOOL_NOT_AVAILABLE),
|
|
|
+ $form->createElement('radio', 'chat_state', null, get_lang('Public'), GroupManager::TOOL_PUBLIC),
|
|
|
+ $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
|
|
|
$form->addElement('style_submit_button', 'submit', get_lang('SaveSettings'), 'class="save"');
|
|
|
|
|
|
if ($form->validate()) {
|
|
|
- $values = $form->exportValues();
|
|
|
- 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'];
|
|
|
- }
|
|
|
- $self_registration_allowed = isset($values['self_registration_allowed']) ? 1 : 0;
|
|
|
- $self_unregistration_allowed = isset($values['self_unregistration_allowed']) ? 1 : 0;
|
|
|
-
|
|
|
- GroupManager::set_group_properties(
|
|
|
+ $values = $form->exportValues();
|
|
|
+ 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'];
|
|
|
+ }
|
|
|
+ $self_registration_allowed = isset($values['self_registration_allowed']) ? 1 : 0;
|
|
|
+ $self_unregistration_allowed = isset($values['self_unregistration_allowed']) ? 1 : 0;
|
|
|
+
|
|
|
+ GroupManager::set_group_properties(
|
|
|
$current_group['id'],
|
|
|
strip_tags($values['name']),
|
|
|
strip_tags($values['description']),
|
|
@@ -288,20 +300,20 @@ if ($form->validate()) {
|
|
|
$self_unregistration_allowed
|
|
|
);
|
|
|
|
|
|
- // Storing the tutors (we first remove all the tutors and then add only those who were selected)
|
|
|
- GroupManager :: unsubscribe_all_tutors($current_group['id']);
|
|
|
- if (isset ($_POST['group_tutors']) && count($_POST['group_tutors']) > 0) {
|
|
|
- GroupManager :: subscribe_tutors($values['group_tutors'], $current_group['id']);
|
|
|
- }
|
|
|
+ // Storing the tutors (we first remove all the tutors and then add only those who were selected)
|
|
|
+ GroupManager :: unsubscribe_all_tutors($current_group['id']);
|
|
|
+ if (isset ($_POST['group_tutors']) && count($_POST['group_tutors']) > 0) {
|
|
|
+ GroupManager :: subscribe_tutors($values['group_tutors'], $current_group['id']);
|
|
|
+ }
|
|
|
|
|
|
- // Storing the users (we first remove all users and then add only those who were selected)
|
|
|
- GroupManager :: unsubscribe_all_users($current_group['id']);
|
|
|
- if (isset ($_POST['group_members']) && count($_POST['group_members']) > 0) {
|
|
|
- GroupManager :: subscribe_users($values['group_members'], $current_group['id']);
|
|
|
- }
|
|
|
+ // Storing the users (we first remove all users and then add only those who were selected)
|
|
|
+ GroupManager :: unsubscribe_all_users($current_group['id']);
|
|
|
+ if (isset ($_POST['group_members']) && count($_POST['group_members']) > 0) {
|
|
|
+ GroupManager :: subscribe_users($values['group_members'], $current_group['id']);
|
|
|
+ }
|
|
|
|
|
|
- // Returning to the group area (note: this is inconsistent with the rest of chamilo)
|
|
|
- $cat = GroupManager :: get_category_from_group($current_group['id']);
|
|
|
+ // Returning to the group area (note: this is inconsistent with the rest of chamilo)
|
|
|
+ $cat = GroupManager :: get_category_from_group($current_group['id']);
|
|
|
if (isset($_POST['group_members']) && count($_POST['group_members']) > $max_member && $max_member != GroupManager::MEMBER_PER_GROUP_NO_LIMIT) {
|
|
|
header('Location: group.php?'.api_get_cidreq(true, false).'&action=warning_message&msg='.get_lang('GroupTooMuchMembers'));
|
|
|
} else {
|
|
@@ -316,22 +328,22 @@ $defaults['group_tutors'] = $selected_tutors;
|
|
|
$action = isset($_GET['action']) ? $_GET['action'] : '';
|
|
|
$defaults['action'] = $action;
|
|
|
if ($defaults['maximum_number_of_students'] == GroupManager::MEMBER_PER_GROUP_NO_LIMIT) {
|
|
|
- $defaults['max_member_no_limit'] = 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'];
|
|
|
+ $defaults['max_member_no_limit'] = 1;
|
|
|
+ $defaults['max_member'] = $defaults['maximum_number_of_students'];
|
|
|
}
|
|
|
|
|
|
if (!empty($_GET['keyword']) && !empty($_GET['submit'])) {
|
|
|
- $keyword_name = Security::remove_XSS($_GET['keyword']);
|
|
|
- echo '<br/>'.get_lang('SearchResultsFor').' <span style="font-style: italic ;"> '.$keyword_name.' </span><br>';
|
|
|
+ $keyword_name = Security::remove_XSS($_GET['keyword']);
|
|
|
+ echo '<br/>'.get_lang('SearchResultsFor').' <span style="font-style: italic ;"> '.$keyword_name.' </span><br>';
|
|
|
}
|
|
|
|
|
|
Display :: display_header($nameTools, 'Group');
|
|
|
|
|
|
//@todo fix this
|
|
|
if (isset($_GET['show_message_warning'])) {
|
|
|
- echo Display::display_warning_message($_GET['show_message_warning']);
|
|
|
+ echo Display::display_warning_message($_GET['show_message_warning']);
|
|
|
}
|
|
|
|
|
|
if (isset($_GET['show_message_sucess'])) {
|