Add group visibility see BT#9425

1.10.x
Julio Montoya 10 years ago
parent 21e6fcacf5
commit fb84c74b5c
  1. 2
      main/attendance/attendance_calendar.php
  2. 2
      main/attendance/attendance_sheet.php
  3. 15
      main/group/group.php
  4. 4
      main/group/group_space.php
  5. 2
      main/group/member_settings.php
  6. 6
      main/group/settings.php
  7. 4
      main/group/tutor_settings.php
  8. 1
      main/inc/lib/add_course.lib.inc.php
  9. 13
      main/inc/lib/formvalidator/FormValidator.class.php
  10. 94
      main/inc/lib/groupmanager.lib.php
  11. 2
      main/install/db_main.sql
  12. 4
      main/install/migrate-db-1.9.0-1.10.0-pre.sql

@ -47,7 +47,7 @@ if (isset($error_checkdate) && $error_checkdate) {
Display::display_error_message($message, false);
}
$groupList = GroupManager::get_group_list();
$groupList = GroupManager::get_group_list(null, null, 1);
$groupIdList = array('--');
foreach ($groupList as $group) {
$groupIdList[$group['id']] = $group['name'];

@ -75,7 +75,7 @@ if (api_is_allowed_to_edit(null, true) ||
$form->addElement('select', 'filter', get_lang('Filter'), $values, array('id' => 'filter_id'));
$groupList = GroupManager::get_group_list();
$groupList = GroupManager::get_group_list(null, null, 1);
$groupIdList = array('--');
foreach ($groupList as $group) {
$groupIdList[$group['id']] = $group['name'];

@ -14,9 +14,9 @@
* @author Isaac Flores, code cleaning and improvements
* @package chamilo.group
*/
/* INIT SECTION */
// Name of the language file that needs to be included
$language_file = 'group';
$language_file = array('group', 'document');
require_once '../inc/global.inc.php';
@ -73,6 +73,14 @@ $my_get_id = isset($_GET['id']) ? Security::remove_XSS($_GET['id']) : null;
if (isset($_GET['action']) && $is_allowed_in_course) {
switch ($_GET['action']) {
case 'set_visible':
GroupManager::setVisible($my_get_id);
Display :: display_confirmation_message(get_lang('ItemUpdated'));
break;
case 'set_invisible':
GroupManager::setInvisible($my_get_id);
Display :: display_confirmation_message(get_lang('ItemUpdated'));
break;
case 'self_reg':
if (GroupManager::is_self_registration_allowed($userId, $my_group_id)) {
GroupManager::subscribe_users($userId, $my_group_id);
@ -138,7 +146,6 @@ if (api_is_allowed_to_edit(false, true)) {
GroupManager :: delete_groups($my_get_id);
Display :: display_confirmation_message(get_lang('GroupDel'));
break;
case 'fill_one':
GroupManager :: fill_groups($my_get_id);
Display :: display_confirmation_message(get_lang('GroupFilledGroups'));
@ -191,7 +198,7 @@ echo '</div>';
/* List all categories */
if (api_get_setting('allow_group_categories') == 'true') {
foreach ($group_cats as $index => $category) {
$group_list = GroupManager :: get_group_list($category['id']);
$group_list = GroupManager::get_group_list($category['id']);
$label = Display::label(count($group_list).' '.get_lang('ExistingGroups'), 'info');
$actions = null;

@ -34,7 +34,7 @@ if (empty($current_group)) {
$this_section = SECTION_COURSES;
$nameTools = get_lang('GroupSpace');
$interbreadcrumb[] = array ('url' => 'group.php', 'name' => get_lang('Groups'));
$interbreadcrumb[] = array('url' => 'group.php', 'name' => get_lang('Groups'));
/* Ensure all private groups // Juan Carlos Raña Trabado */
@ -57,7 +57,7 @@ if ($current_group['doc_state'] != 1 &&
$current_group['chat_state'] != 1 &&
$forum_state_public != 1
) {
if (!api_is_allowed_to_edit(null,true) &&
if (!api_is_allowed_to_edit(null, true) &&
!GroupManager::is_user_in_group($user_id, $group_id)) {
api_not_allowed($print_headers);
}

@ -178,7 +178,7 @@ $group_members_element = $form->addElement(
$form->addFormRule('check_group_members');
// submit button
$form->addElement('style_submit_button', 'submit', get_lang('SaveSettings'), 'class="save"');
$form->addButtonSave(get_lang('SaveSettings'));
if ($form->validate()) {
$values = $form->exportValues();

@ -11,8 +11,6 @@
* @todo course admin functionality to create groups based on who is in which course (or class).
*/
/* INIT SECTION */
// Name of the language file that needs to be included
$language_file = 'group';
@ -70,7 +68,7 @@ $form->addElement('html', '</div>');
$form->addElement('html', '<div class="span6">');
// Description
$form->addElement('textarea', 'description', get_lang('Description'), array ('class' => 'span6', 'rows' => 6));
$form->addElement('textarea', 'description', get_lang('Description'));
$form->addElement('html', '</div>');
$form->addElement('html', '<div class="span12">');
@ -148,7 +146,7 @@ $form->addGroup($group, '', Display::return_icon('chat.png', get_lang('Chat'), a
$form->addElement('html', '</div>');
$form->addElement('html', '<div class="span12">');
// Submit button
$form->addElement('style_submit_button', 'submit', get_lang('SaveSettings'), 'class="save"');
$form->addButtonSave(get_lang('SaveSettings'));
$form->addElement('html', '</div>');
if ($form->validate()) {

@ -11,8 +11,6 @@
* @todo course admin functionality to create groups based on who is in which course (or class).
*/
/* INIT SECTION */
// Name of the language file that needs to be included
$language_file = 'group';
@ -155,7 +153,7 @@ if (!empty($complete_user_list)) {
$group_tutors_element = $form->addElement('advmultiselect', 'group_tutors', get_lang('GroupTutors'), $possible_users, 'style="width: 280px;"');
// submit button
$form->addElement('style_submit_button', 'submit', get_lang('SaveSettings'), 'class="save"');
$form->addButtonSave(get_lang('SaveSettings'));
if ($form->validate()) {
$values = $form->exportValues();

@ -1162,6 +1162,7 @@ class AddCourse
$add_to_all_tables
id int unsigned NOT NULL auto_increment,
name varchar(100) default NULL,
status tinyint DEFAULT 1,
category_id int unsigned NOT NULL default 0,
description text,
max_student int unsigned NOT NULL default 8,

@ -253,6 +253,14 @@ EOT;
);
}
/**
* @param string $label
*/
public function addButtonSave($label, $name = 'submit')
{
$this->addButton($name, $label, 'check', 'primary');
}
/**
* @param string $label
*/
@ -292,8 +300,11 @@ EOT;
* Shortcut to search button
* @param string $label
*/
public function addButtonSearch($label)
public function addButtonSearch($label = null)
{
if (empty($label)) {
$label = get_lang('Search');
}
return $this->addButton('submit', $label, 'search');
}

@ -78,7 +78,7 @@ class GroupManager
* @param string $course_code Default is current course
* @return array An array with all information about the groups.
*/
public static function get_group_list($category = null, $course_code = null)
public static function get_group_list($category = null, $course_code = null, $status = null)
{
$course_info = api_get_course_info($course_code);
$session_id = api_get_session_id();
@ -96,6 +96,7 @@ class GroupManager
g.self_registration_allowed,
g.self_unregistration_allowed,
g.session_id,
g.status,
ug.user_id is_member
FROM $table_group g
LEFT JOIN $table_group_user ug
@ -118,6 +119,10 @@ class GroupManager
$session_condition = api_get_session_condition($session_id, true);
}
if (!is_null($status)) {
$sql .= " AND g.status = '".intval($status)."' ";
}
$sql .= " AND g.c_id = $course_id ";
if (!empty($session_condition)) {
@ -471,6 +476,7 @@ class GroupManager
if ($db_object) {
$result['id'] = $db_object->id;
$result['name'] = $db_object->name;
$result['status'] = $db_object->status;
$result['tutor_id'] = isset($db_object->tutor_id) ? $db_object->tutor_id : null;
$result['description'] = $db_object->description;
$result['maximum_number_of_students'] = $db_object->max_student;
@ -1949,24 +1955,28 @@ class GroupManager
return false;
}
$user_is_in_group = self :: is_user_in_group($user_id, $group_id);
$user_is_in_group = self::is_user_in_group($user_id, $group_id);
// Check group properties
$group_info = self :: get_group_properties($group_id);
$groupInfo = self::get_group_properties($group_id);
if (empty($groupInfo)) {
return false;
}
if (empty($group_info)) {
if (!$user_is_in_group && $groupInfo['status'] == 0) {
return false;
}
if ($group_info[$state_key] == self::TOOL_NOT_AVAILABLE) {
if ($groupInfo[$state_key] == self::TOOL_NOT_AVAILABLE) {
return false;
} elseif ($group_info[$state_key] == self::TOOL_PUBLIC) {
} elseif ($groupInfo[$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
} elseif ($groupInfo['tutor_id'] == $user_id) { //this tutor implementation was dropped
return true;
} elseif ($group_info[$state_key] == self::TOOL_PRIVATE && !$user_is_in_group) {
} elseif ($groupInfo[$state_key] == self::TOOL_PRIVATE && !$user_is_in_group) {
return false;
} else {
return $user_is_in_group;
@ -2139,13 +2149,21 @@ class GroupManager
// Create a new table-row
$row = array();
if (!api_is_allowed_to_edit(false, true)) {
if ($this_group['status'] == 0) {
continue;
}
}
// Checkbox
if (api_is_allowed_to_edit(false, true) && count($group_list) > 1) {
$row[] = $this_group['id'];
}
// Group name
if ((api_is_allowed_to_edit(false, true) ||
(
in_array($user_id, $tutorsids_of_group) ||
$this_group['is_member'] ||
self::user_has_access($user_id, $this_group['id'], self::GROUP_TOOL_FORUM) ||
@ -2155,10 +2173,16 @@ class GroupManager
self::user_has_access($user_id, $this_group['id'], self::GROUP_TOOL_WORK) ||
self::user_has_access($user_id, $this_group['id'], self::GROUP_TOOL_WIKI) ||
self::user_has_access($user_id, $this_group['id'], self::GROUP_TOOL_CHAT)
)
)
&& !(api_is_course_coach() && intval($this_group['session_id']) != $session_id)
) {
$group_name = '<a href="group_space.php?cidReq='.api_get_course_id().'&amp;origin='.$orig.'&amp;gidReq='.$this_group['id'].'">'.
$groupNameClass = null;
if ($this_group['status'] == 0) {
$groupNameClass = 'muted';
}
$group_name = '<a class="'.$groupNameClass.'" href="group_space.php?cidReq='.api_get_course_id().'&amp;origin='.$orig.'&amp;gidReq='.$this_group['id'].'">'.
Security::remove_XSS($this_group['name']).'</a> ';
if (!empty($user_id) && !empty($this_group['id_tutor']) && $user_id == $this_group['id_tutor']) {
$group_name .= Display::label(get_lang('OneMyGroups'), 'success');
@ -2218,10 +2242,20 @@ class GroupManager
}
$url = api_get_path(WEB_CODE_PATH).'group/';
// Edit-links
if (api_is_allowed_to_edit(false, true) && !(api_is_course_coach() && intval($this_group['session_id']) != $session_id)) {
if (api_is_allowed_to_edit(false, true) &&
!(api_is_course_coach() && intval($this_group['session_id']) != $session_id)
) {
$edit_actions = '<a href="'.$url.'settings.php?'.api_get_cidreq(true, false).'&gidReq='.$this_group['id'].'" title="'.get_lang('Edit').'">'.
Display::return_icon('edit.png', get_lang('EditGroup'),'',ICON_SIZE_SMALL).'</a>&nbsp;';
if ($this_group['status'] == 1) {
$edit_actions .= '<a href="' . api_get_self() . '?' . api_get_cidreq(true,false) . '&category=' . $category_id . '&amp;action=set_invisible&amp;id=' . $this_group['id'] . '" title="' . get_lang('Hide') . '">' .
Display::return_icon('visible.png', get_lang('Hide'), '', ICON_SIZE_SMALL) . '</a>&nbsp;';
} else {
$edit_actions .= '<a href="' . api_get_self() . '?' . api_get_cidreq(true, false) . '&category=' . $category_id . '&amp;action=set_visible&amp;id=' . $this_group['id'] . '" title="' . get_lang('Show') . '">' .
Display::return_icon('invisible.png', get_lang('Show'), '', ICON_SIZE_SMALL) . '</a>&nbsp;';
}
$edit_actions .= '<a href="'.$url.'member_settings.php?'.api_get_cidreq(true, false).'&gidReq='.$this_group['id'].'" title="'.get_lang('GroupMembers').'">'.
Display::return_icon('user.png', get_lang('GroupMembers'), '', ICON_SIZE_SMALL).'</a>&nbsp;';
@ -2694,7 +2728,45 @@ class GroupManager
$url = api_get_path(WEB_CODE_PATH).'group/group_overview.php?'.api_get_cidreq();
$form = new FormValidator('search_groups', 'get', $url, null, array(), FormValidator::LAYOUT_INLINE);
$form->addElement('text', 'keyword');
$form->addElement('button', 'submit', get_lang('Search'));
$form->addButtonSearch();
return $form->toHtml();
}
/**
* @param int $groupId
* @param int $status
*/
public static function setStatus($groupId, $status)
{
$groupInfo = self::get_group_properties($groupId);
$courseId = api_get_course_int_id();
if (!empty($groupInfo)) {
$table = Database::get_course_table(TABLE_GROUP);
$params = array(
'status' => intval($status)
);
Database::update(
$table,
$params,
array('c_id = ? AND id = ?' => array($courseId, $groupId))
);
}
}
/**
* @param int $groupId
*/
public static function setVisible($groupId)
{
self::setStatus($groupId, 1);
}
/**
* @param int $groupId
*/
public static function setInvisible($groupId)
{
self::setStatus($groupId, 0);
}
}

@ -3482,4 +3482,4 @@ CREATE TABLE c_attendance_calendar_rel_group (
-- Version
UPDATE settings_current SET selected_value = '1.10.0.20' WHERE variable = 'chamilo_database_version';
UPDATE settings_current SET selected_value = '1.10.0.21' WHERE variable = 'chamilo_database_version';

@ -95,12 +95,12 @@ ALTER TABLE c_survey ADD visible_results INT UNSIGNED DEFAULT 0;
ALTER TABLE c_lp_item ADD COLUMN prerequisite_min_score float;
ALTER TABLE c_lp_item ADD COLUMN prerequisite_max_score float;
ALTER TABLE c_student_publication ADD COLUMN document_id int DEFAULT 0;
ALTER TABLE c_group_info ADD COLUMN status tinyint DEFAULT 1;
CREATE TABLE IF NOT EXISTS c_student_publication_rel_document (id INT PRIMARY KEY NOT NULL AUTO_INCREMENT, work_id INT NOT NULL, document_id INT NOT NULL, c_id INT NOT NULL);
CREATE TABLE IF NOT EXISTS c_student_publication_rel_user (id INT PRIMARY KEY NOT NULL AUTO_INCREMENT, work_id INT NOT NULL, user_id INT NOT NULL, c_id INT NOT NULL);
CREATE TABLE IF NOT EXISTS c_student_publication_comment (id INT PRIMARY KEY NOT NULL AUTO_INCREMENT, work_id INT NOT NULL, c_id INT NOT NULL, comment text, file VARCHAR(255), user_id int NOT NULL, sent_at datetime NOT NULL);
CREATE TABLE IF NOT EXISTS c_attendance_calendar_rel_group (id int NOT NULL auto_increment PRIMARY KEY, c_id INT NOT NULL, group_id INT NOT NULL, calendar_id INT NOT NULL);
-- Do not move this query
UPDATE settings_current SET selected_value = '1.10.0.20' WHERE variable = 'chamilo_database_version';
UPDATE settings_current SET selected_value = '1.10.0.21' WHERE variable = 'chamilo_database_version';

Loading…
Cancel
Save