[svn r16962] Fixes two bugs in group forums (see FS#3225 and FS#3270)

skala
Yannick Warnier 17 years ago
parent 35d1e1bd9f
commit 2afef30dd7
  1. 4
      main/group/group_category.php
  2. 8
      main/group/group_edit.php
  3. 40
      main/group/group_space.php
  4. 1
      main/inc/lib/add_course.lib.inc.php
  5. 47
      main/inc/lib/groupmanager.lib.php
  6. 3
      main/install/migrate-db-1.8.5-1.8.6-pre.sql

@ -1,5 +1,5 @@
<?php
// $Id: group_category.php 16248 2008-09-05 13:30:55Z elixir_inter $
// $Id: group_category.php 16962 2008-11-26 20:40:18Z yannoo $
/*
==============================================================================
Dokeos - elearning and course management software
@ -81,7 +81,7 @@ if (get_setting('allow_group_categories') == 'true')
{
$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, 'calendar_state' => TOOL_PRIVATE, 'announcements_state' => TOOL_PRIVATE, 'max_student' => 0);
$category = array ('groups_per_user' => 1, 'doc_state' => TOOL_PRIVATE, 'work_state' => TOOL_PRIVATE, 'wiki_state' => TOOL_PRIVATE, 'calendar_state' => TOOL_PRIVATE, 'announcements_state'=> TOOL_PRIVATE, 'forum_state' => TOOL_PRIVATE, 'max_student' => 0);
}
}
else

@ -186,6 +186,11 @@ $form->addElement('radio', 'announcements_state', get_lang('GroupAnnouncements')
$form->addElement('radio', 'announcements_state', null, get_lang('Public'), TOOL_PUBLIC);
$form->addElement('radio', 'announcements_state', null, get_lang('Private'), 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);
// 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);
@ -201,7 +206,6 @@ else{
$complete_user_list = CourseManager :: get_user_list_from_course_code($_course['id']);
}
usort($complete_user_list, 'sort_users');
@ -277,7 +281,7 @@ if ($form->validate())
}
$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']), $max_member, $values['doc_state'], $values['work_state'], $values['calendar_state'], $values['announcements_state'], $values['wiki_state'], $self_registration_allowed, $self_unregistration_allowed);
GroupManager :: set_group_properties($current_group['id'], strip_tags($values['name']), strip_tags($values['description']), $max_member, $values['doc_state'], $values['work_state'], $values['calendar_state'], $values['announcements_state'], $values['forum_state'],$values['wiki_state'], $self_registration_allowed, $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']);

@ -1,4 +1,4 @@
<?php //$Id: group_space.php 16873 2008-11-22 23:22:02Z herodoto $
<?php //$Id: group_space.php 16962 2008-11-26 20:40:18Z yannoo $
/*
==============================================================================
Dokeos - elearning and course management software
@ -125,11 +125,6 @@ if( isset($_GET['action']))
break;
}
}
/*
-----------------------------------------------------------
Main Display Area
@ -146,9 +141,6 @@ if (!empty($current_group['description']))
{
echo '<blockquote>'.stripslashes($current_group['description']).'</blockquote>';
}
/*
* Group Tools
*/
@ -156,15 +148,15 @@ if (!empty($current_group['description']))
if (api_is_allowed_to_edit(false,true) OR GroupManager :: is_user_in_group($_SESSION['_user']['user_id'], $current_group['id']))
{
$tools = '';
// link to the forum of this group
$forums_of_groups = get_forums_of_group($current_group['id']);
if (is_array($forums_of_groups))
{
foreach ($forums_of_groups as $key => $value)
{
if($value['forum_group_public_private'] == 'public' || ($user_subscribe_to_current_group && $value['forum_group_public_private'] == 'private') || $user_is_tutor || api_is_allowed_to_edit(false,true))
{
$tools.= Display::return_icon('forum.gif', get_lang("GroupForum")) . ' <a href="../forum/viewforum.php?forum='.$value['forum_id'].'">'.$value['forum_title'].'</a><br />';
}
if (is_array($forums_of_groups)) {
if ( $current_group['forum_state'] != TOOL_NOT_AVAILABLE ) {
foreach ($forums_of_groups as $key => $value) {
if ($value['forum_group_public_private'] == 'public' || ($user_subscribe_to_current_group && $value['forum_group_public_private'] == 'private') || $user_is_tutor || api_is_allowed_to_edit(false,true)) {
$tools.= Display::return_icon('forum.gif', get_lang("GroupForum")) . ' <a href="../forum/viewforum.php?forum='.$value['forum_id'].'">'.$value['forum_title'].'</a><br />';
}
}
}
}
if( $current_group['doc_state'] != TOOL_NOT_AVAILABLE )
@ -204,14 +196,14 @@ if (api_is_allowed_to_edit(false,true) OR GroupManager :: is_user_in_group($_SES
else
{
$tools = '';
// link to the forum of this group
$forums_of_groups = get_forums_of_group($current_group['id']);
if (is_array($forums_of_groups))
{
foreach ($forums_of_groups as $key => $value)
{
if($value['forum_group_public_private'] == 'public' )
{
$tools.= Display::return_icon('forum.gif', get_lang("GroupForum")) . ' <a href="../forum/viewforum.php?forum='.$value['forum_id'].'">'.$value['forum_title'].'</a><br />';
if (is_array($forums_of_groups)) {
if ( $current_group['forum_state'] == TOOL_PUBLIC ) {
foreach ($forums_of_groups as $key => $value) {
if ($value['forum_group_public_private'] == 'public' ) {
$tools.= Display::return_icon('forum.gif', get_lang("GroupForum")) . ' <a href="../forum/viewforum.php?forum='.$value['forum_id'].'">'.$value['forum_title'].'</a><br />';
}
}
}
}

@ -970,6 +970,7 @@ function update_Db_course($courseDbName)
calendar_state tinyint unsigned NOT NULL default 0,
work_state tinyint unsigned NOT NULL default 0,
announcements_state tinyint unsigned NOT NULL default 0,
forum_state tinyint unsigned NOT NULL default 0,
wiki_state tinyint unsigned NOT NULL default 1,
secret_directory varchar(255) default NULL,
self_registration_allowed tinyint unsigned NOT NULL default '0',

@ -176,7 +176,7 @@ class GroupManager
{
$places = $category['max_student'];
}
$sql = "INSERT INTO ".$table_group." SET category_id='".$category_id."', max_student = '".$places."', doc_state = '".$category['doc_state']."', calendar_state = '".$category['calendar_state']."', work_state = '".$category['work_state']."', announcements_state = '".$category['announcements_state']."', wiki_state = '".$category['wiki_state']."', self_registration_allowed = '".$category['self_reg_allowed']."', self_unregistration_allowed = '".$category['self_unreg_allowed']."', session_id=".intval($_SESSION['id_session']);
$sql = "INSERT INTO ".$table_group." SET category_id='".$category_id."', max_student = '".$places."', doc_state = '".$category['doc_state']."', calendar_state = '".$category['calendar_state']."', work_state = '".$category['work_state']."', announcements_state = '".$category['announcements_state']."', forum_state = '".$category['forum_state']."', wiki_state = '".$category['wiki_state']."', self_registration_allowed = '".$category['self_reg_allowed']."', self_unregistration_allowed = '".$category['self_unreg_allowed']."', session_id=".intval($_SESSION['id_session']);
api_sql_query($sql,__FILE__,__LINE__);
$lastId = mysql_insert_id();
/*$secret_directory = uniqid("")."_team_".$lastId;
@ -398,7 +398,7 @@ class GroupManager
/**
* Get group properties
* @param int $group_id The group from which properties are requested.
* @return array All properties. Array-keys are name, tutor_id, description, maximum_number_of_students, directory
* @return array All properties. Array-keys are name, tutor_id, description, maximum_number_of_students, directory and visibility of tools
*/
function get_group_properties($group_id)
{
@ -418,6 +418,7 @@ class GroupManager
$result['work_state'] = $db_object->work_state;
$result['calendar_state'] = $db_object->calendar_state;
$result['announcements_state'] = $db_object->announcements_state;
$result['forum_state'] = $db_object->forum_state;
$result['wiki_state'] = $db_object->wiki_state;
$result['directory'] = $db_object->secret_directory;
$result['self_registration_allowed'] = $db_object->self_registration_allowed;
@ -427,25 +428,31 @@ class GroupManager
/**
* Set group properties
* Changes the group's properties.
* @param int $group_id
* @param string $name
* @param string $description
* @param int $tutor_id
* @param int $maximum_number_of_students
* @param bool $self_registration_allowed
* @param bool $self_unregistration_allowed
* @return bool TRUE if properties are successfully changed.
* @param int Group Id
* @param string Group name
* @param string Group description
* @param int Max number of students in group
* @param int Document tool's visibility (0=none,1=private,2=public)
* @param int Work tool's visibility (0=none,1=private,2=public)
* @param int Calendar tool's visibility (0=none,1=private,2=public)
* @param int Announcement tool's visibility (0=none,1=private,2=public)
* @param int Forum tool's visibility (0=none,1=private,2=public)
* @param int Wiki tool's visibility (0=none,1=private,2=public)
* @param bool Whether self registration is allowed or not
* @param bool Whether self unregistration is allowed or not
* @return bool TRUE if properties are successfully changed, false otherwise
*/
function set_group_properties($group_id, $name, $description, $maximum_number_of_students, $doc_state, $work_state, $calendar_state, $announcements_state, $wiki_state, $self_registration_allowed, $self_unregistration_allowed)
{
function set_group_properties($group_id, $name, $description, $maximum_number_of_students, $doc_state, $work_state, $calendar_state, $announcements_state, $forum_state,$wiki_state, $self_registration_allowed, $self_unregistration_allowed) {
$table_group = Database :: get_course_table(TABLE_GROUP);
//$table_forum = Database :: get_course_table(TABLE_FORUM);
$table_forum = Database :: get_course_table(TABLE_FORUM);
//$forum_id = get_forums_of_group($group_id);
$sql = "UPDATE ".$table_group."
SET name='".trim($name)."',
doc_state = '".$doc_state."',
work_state = '".$work_state."',
calendar_state = '".$calendar_state."',
announcements_state = '".$announcements_state."',
forum_state = '".$forum_state."',
wiki_state = '".$wiki_state."',
description='".trim($description)."',
max_student=".$maximum_number_of_students.",
@ -453,8 +460,18 @@ class GroupManager
self_unregistration_allowed='".$self_unregistration_allowed."'
WHERE id=".$group_id;
$result = api_sql_query($sql,__FILE__,__LINE__);
//$sql = "UPDATE ".$table_forum." SET forum_name='".trim($name)."' WHERE forum_id=".$forum_id;
//$result &= api_sql_query($sql,__FILE__,__LINE__);
//Here we are updating a field in the table forum_forum that perhaps duplicates the table group_info.forum_state cvargas
$forum_state = (int) $forum_state;
if ($forum_state!==0) {
$sql2 = "UPDATE ".$table_forum." SET ";
if ($forum_state===1) {
$sql2 .= " forum_group_public_private='public' ";
} else if ($forum_state===2) {
$sql2 .= " forum_group_public_private='private' ";
}
$sql2 .=" WHERE forum_of_group=".$group_id;
$result2 = api_sql_query($sql2,__FILE__,__LINE__);
}
return $result;
}
/**

@ -126,4 +126,5 @@ UPDATE forum_notification SET post_id=NULL WHERE post_id='';
ALTER TABLE forum_notification CHANGE post_id post_id INT NULL;
ALTER TABLE forum_thread ADD thread_weight smallint default 0;
ALTER TABLE forum_notification CHANGE post_id post_id INT NULL;
ALTER TABLE quiz_answer CHANGE hotspot_coordinates hotspot_coordinates text;
ALTER TABLE quiz_answer CHANGE hotspot_coordinates hotspot_coordinates text;
ALTER TABLE group_info ADD forum_state TINYINT NULL AFTER announcements_state;

Loading…
Cancel
Save