Minor - format code

1.9.x
Julio Montoya 12 years ago
parent 3dc82dc3ff
commit a7c9932e13
  1. 17
      main/group/group_category.php
  2. 113
      main/inc/lib/groupmanager.lib.php

@ -197,7 +197,22 @@ if ($form->validate()) {
$self_unreg_allowed = isset($values['self_unreg_allowed']) ? $values['self_unreg_allowed'] : 0; $self_unreg_allowed = isset($values['self_unreg_allowed']) ? $values['self_unreg_allowed'] : 0;
switch ($values['action']) { switch ($values['action']) {
case 'update_settings': case 'update_settings':
GroupManager :: update_category($values['id'], $values['title'], $values['description'], $values['doc_state'], $values['work_state'], $values['calendar_state'], $values['announcements_state'], $values['forum_state'], $values['wiki_state'], $values['chat_state'], $self_reg_allowed, $self_unreg_allowed, $max_member, $values['groups_per_user']); GroupManager::update_category(
$values['id'],
$values['title'],
$values['description'],
$values['doc_state'],
$values['work_state'],
$values['calendar_state'],
$values['announcements_state'],
$values['forum_state'],
$values['wiki_state'],
$values['chat_state'],
$self_reg_allowed,
$self_unreg_allowed,
$max_member,
$values['groups_per_user']
);
$msg = urlencode(get_lang('GroupPropertiesModified')); $msg = urlencode(get_lang('GroupPropertiesModified'));
header('Location: group.php?action=show_msg&msg='.$msg.'&category='.$values['id']); header('Location: group.php?action=show_msg&msg='.$msg.'&category='.$values['id']);
break; break;

@ -21,48 +21,50 @@ require_once 'document.lib.php';
class GroupManager class GroupManager
{ {
//- VIRTUAL_COURSE_CATEGORY: in this category groups are created based on the virtual course of a course //- VIRTUAL_COURSE_CATEGORY: in this category groups are created based on the virtual course of a course
CONST VIRTUAL_COURSE_CATEGORY = 1; const VIRTUAL_COURSE_CATEGORY = 1;
//DEFAULT_GROUP_CATEGORY: When group categories aren't available (platform-setting), all groups are created in this 'dummy'-category //DEFAULT_GROUP_CATEGORY: When group categories aren't available (platform-setting), all groups are created in this 'dummy'-category
CONST DEFAULT_GROUP_CATEGORY = 2; const DEFAULT_GROUP_CATEGORY = 2;
/** /**
* infinite * infinite
*/ */
CONST INFINITE = 99999; const INFINITE = 99999;
/** /**
* No limit on the number of users in a group * No limit on the number of users in a group
*/ */
CONST MEMBER_PER_GROUP_NO_LIMIT = 0; const MEMBER_PER_GROUP_NO_LIMIT = 0;
/** /**
* No limit on the number of groups per user * No limit on the number of groups per user
*/ */
CONST GROUP_PER_MEMBER_NO_LIMIT = 0; const GROUP_PER_MEMBER_NO_LIMIT = 0;
/** /**
* The tools of a group can have 3 states * The tools of a group can have 3 states
* - not available * - not available
* - public * - public
* - private * - private
*/ */
CONST TOOL_NOT_AVAILABLE = 0; const TOOL_NOT_AVAILABLE = 0;
CONST TOOL_PUBLIC = 1; const TOOL_PUBLIC = 1;
CONST TOOL_PRIVATE = 2; const TOOL_PRIVATE = 2;
/** /**
* Constants for the available group tools * Constants for the available group tools
*/ */
CONST GROUP_TOOL_FORUM = 0; const GROUP_TOOL_FORUM = 0;
CONST GROUP_TOOL_DOCUMENTS = 1; const GROUP_TOOL_DOCUMENTS = 1;
CONST GROUP_TOOL_CALENDAR = 2; const GROUP_TOOL_CALENDAR = 2;
CONST GROUP_TOOL_ANNOUNCEMENT = 3; const GROUP_TOOL_ANNOUNCEMENT = 3;
CONST GROUP_TOOL_WORK = 4; const GROUP_TOOL_WORK = 4;
CONST GROUP_TOOL_WIKI = 5; const GROUP_TOOL_WIKI = 5;
CONST GROUP_TOOL_CHAT = 6; const GROUP_TOOL_CHAT = 6;
//GROUP FUNCTIONS
private function __construct() private function __construct()
{ {
} }
/**
* @return array
*/
public static function get_groups() public static function get_groups()
{ {
$table_group = Database :: get_course_table(TABLE_GROUP); $table_group = Database :: get_course_table(TABLE_GROUP);
@ -100,7 +102,7 @@ class GroupManager
} }
} }
//COURSEMANAGER or STUDENT // COURSEMANAGER or STUDENT
if ($my_status_of_user_in_course == COURSEMANAGER || api_is_allowed_to_edit(null, true) || api_is_drh()) { if ($my_status_of_user_in_course == COURSEMANAGER || api_is_allowed_to_edit(null, true) || api_is_drh()) {
$can_see_groups = 1; $can_see_groups = 1;
$sql = "SELECT g.id , $sql = "SELECT g.id ,
@ -672,35 +674,58 @@ class GroupManager
/** /**
* Update group category * Update group category
* @param int $id The id of the category *
* @param string $title The title of the new category * @param int $id
* @param string $description The description of the new category * @param string $title
* @param bool $self_registration_allowed * @param string $description
* @param bool $self_unregistration_allowed * @param $doc_state
* @param int $max_number_of_students * @param $work_state
* @param int $groups_per_user * @param $calendar_state
* @param $announcements_state
* @param $forum_state
* @param $wiki_state
* @param $chat_state
* @param $self_registration_allowed
* @param $self_unregistration_allowed
* @param $maximum_number_of_students
* @param $groups_per_user
*/ */
public static function update_category ($id, $title, $description, $doc_state, $work_state, $calendar_state, $announcements_state, $forum_state, $wiki_state, $chat_state, $self_registration_allowed, $self_unregistration_allowed, $maximum_number_of_students, $groups_per_user) { public static function update_category(
$id,
$title,
$description,
$doc_state,
$work_state,
$calendar_state,
$announcements_state,
$forum_state,
$wiki_state,
$chat_state,
$self_registration_allowed,
$self_unregistration_allowed,
$maximum_number_of_students,
$groups_per_user
) {
$table_group_category = Database :: get_course_table(TABLE_GROUP_CATEGORY); $table_group_category = Database :: get_course_table(TABLE_GROUP_CATEGORY);
$id = Database::escape_string($id); $id = Database::escape_string($id);
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
$sql = "UPDATE ".$table_group_category." $sql = "UPDATE ".$table_group_category."SET
SET title='".Database::escape_string($title)."', title='".Database::escape_string($title)."',
description='".Database::escape_string($description)."', description='".Database::escape_string($description)."',
doc_state = '".Database::escape_string($doc_state)."', doc_state = '".Database::escape_string($doc_state)."',
work_state = '".Database::escape_string($work_state)."', work_state = '".Database::escape_string($work_state)."',
calendar_state = '".Database::escape_string($calendar_state)."', calendar_state = '".Database::escape_string($calendar_state)."',
announcements_state = '".Database::escape_string($announcements_state)."', announcements_state = '".Database::escape_string($announcements_state)."',
forum_state = '".Database::escape_string($forum_state)."', forum_state = '".Database::escape_string($forum_state)."',
wiki_state = '".Database::escape_string($wiki_state)."', wiki_state = '".Database::escape_string($wiki_state)."',
chat_state = '".Database::escape_string($chat_state)."', chat_state = '".Database::escape_string($chat_state)."',
groups_per_user = ".Database::escape_string($groups_per_user).", groups_per_user = ".Database::escape_string($groups_per_user).",
self_reg_allowed = '".Database::escape_string($self_registration_allowed)."', self_reg_allowed = '".Database::escape_string($self_registration_allowed)."',
self_unreg_allowed = '".Database::escape_string($self_unregistration_allowed)."', self_unreg_allowed = '".Database::escape_string($self_unregistration_allowed)."',
max_student = ".Database::escape_string($maximum_number_of_students)." max_student = ".Database::escape_string($maximum_number_of_students)."
WHERE c_id = $course_id AND id=$id"; WHERE c_id = $course_id AND id = $id";
Database::query($sql); Database::query($sql);
} }
@ -709,7 +734,8 @@ class GroupManager
* Returns the number of groups of the user with the greatest number of * Returns the number of groups of the user with the greatest number of
* subscribtions in the given category * subscribtions in the given category
*/ */
public static function get_current_max_groups_per_user ($category_id = null, $course_code = null) { public static function get_current_max_groups_per_user($category_id = null, $course_code = null)
{
$course_info = api_get_course_info ($course_code); $course_info = api_get_course_info ($course_code);
$group_table = Database :: get_course_table(TABLE_GROUP); $group_table = Database :: get_course_table(TABLE_GROUP);
$group_user_table = Database :: get_course_table(TABLE_GROUP_USER); $group_user_table = Database :: get_course_table(TABLE_GROUP_USER);
@ -730,7 +756,8 @@ class GroupManager
* @param int $id1 The id of the first category * @param int $id1 The id of the first category
* @param int $id2 The id of the second category * @param int $id2 The id of the second category
*/ */
public static function swap_category_order ($id1, $id2) { public static function swap_category_order($id1, $id2)
{
$table_group_cat = Database :: get_course_table(TABLE_GROUP_CATEGORY); $table_group_cat = Database :: get_course_table(TABLE_GROUP_CATEGORY);
$id1 = Database::escape_string($id1); $id1 = Database::escape_string($id1);
$id2 = Database::escape_string($id2); $id2 = Database::escape_string($id2);

Loading…
Cancel
Save