mirror of
https://github.com/moodle/moodle.git
synced 2025-01-20 06:39:04 +01:00
Improvements to forum groups.
New forum_discussions->groupid now stores the group ID for the discussion.
This commit is contained in:
parent
d26924c4ec
commit
02509fe667
@ -129,6 +129,7 @@
|
||||
fwrite ($bf,full_tag("NAME",6,false,$for_dis->name));
|
||||
fwrite ($bf,full_tag("FIRSTPOST",6,false,$for_dis->firstpost));
|
||||
fwrite ($bf,full_tag("USERID",6,false,$for_dis->userid));
|
||||
fwrite ($bf,full_tag("GROUPID",6,false,$for_dis->groupid));
|
||||
fwrite ($bf,full_tag("ASSESSED",6,false,$for_dis->assessed));
|
||||
fwrite ($bf,full_tag("TIMEMODIFIED",6,false,$for_dis->timemodified));
|
||||
//Now print posts to xml
|
||||
|
@ -96,6 +96,10 @@ function forum_upgrade($oldversion) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($oldversion < 2004012200) {
|
||||
table_column("forum_discussions", "", "groupid", "integer", "10", "unsigned", "0", "", "userid");
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
|
@ -33,6 +33,7 @@ CREATE TABLE prefix_forum_discussions (
|
||||
name varchar(255) NOT NULL default '',
|
||||
firstpost int(10) unsigned NOT NULL default '0',
|
||||
userid int(10) unsigned NOT NULL default '0',
|
||||
groupid int(10) unsigned NOT NULL default '0',
|
||||
assessed tinyint(1) NOT NULL default '1',
|
||||
timemodified int(10) unsigned NOT NULL default '0',
|
||||
PRIMARY KEY (id)
|
||||
|
@ -39,6 +39,9 @@ function forum_upgrade($oldversion) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($oldversion < 2004012200) {
|
||||
table_column("forum_discussions", "", "groupid", "integer", "10", "unsigned", "0", "", "userid");
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
|
@ -31,6 +31,7 @@ CREATE TABLE prefix_forum_discussions (
|
||||
name varchar(255) NOT NULL default '',
|
||||
firstpost integer NOT NULL default '0',
|
||||
userid integer NOT NULL default '0',
|
||||
groupid integer NOT NULL default '0',
|
||||
assessed integer NOT NULL default '1',
|
||||
timemodified integer NOT NULL default '0'
|
||||
);
|
||||
|
@ -102,17 +102,10 @@
|
||||
$groupmode = groupmode($course, $cm);
|
||||
|
||||
if ($groupmode and !isteacheredit($course->id)) { // Groups must be kept separate
|
||||
if (!$toppost = get_record("forum_posts", "id", $discussion->firstpost)) {
|
||||
error("Could not find the top post of the discussion");
|
||||
}
|
||||
if (!$group = user_group($course->id, $toppost->userid)) { // Find the topic's group
|
||||
error("Could not find the appropriate group of this discussion");
|
||||
}
|
||||
|
||||
if ($groupmode == SEPARATEGROUPS) {
|
||||
require_login();
|
||||
|
||||
if (mygroupid($course->id) == $group->id) {
|
||||
if (mygroupid($course->id) == $discussion->groupid) {
|
||||
$canreply = true;
|
||||
} else {
|
||||
print_heading("Sorry, you can't see this discussion because you are not in this group");
|
||||
@ -121,9 +114,7 @@
|
||||
}
|
||||
|
||||
} else if ($groupmode == VISIBLEGROUPS) {
|
||||
if (mygroupid($course->id) == $group->id) {
|
||||
$canreply = true;
|
||||
}
|
||||
$canreply = (mygroupid($course->id) == $discussion->groupid);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -897,6 +897,11 @@ function forum_get_discussions($forum="0", $forumsort="d.timemodified DESC",
|
||||
} else {
|
||||
$userselect = "";
|
||||
}
|
||||
if ($currentgroup) {
|
||||
$groupselect = " AND d.groupid = '$currentgroup' ";
|
||||
} else {
|
||||
$groupselect = "";
|
||||
}
|
||||
if (empty($forumsort)) {
|
||||
$forumsort = "d.timemodified DESC";
|
||||
}
|
||||
@ -905,18 +910,11 @@ function forum_get_discussions($forum="0", $forumsort="d.timemodified DESC",
|
||||
} else {
|
||||
$postdata = "p.*";
|
||||
}
|
||||
if ($currentgroup) {
|
||||
$grouptable = ", {$CFG->prefix}groups_members gm ";
|
||||
$groupselect = " AND gm.groupid = '$currentgroup' AND u.id = gm.userid ";
|
||||
} else {
|
||||
$grouptable = "";
|
||||
$groupselect = "";
|
||||
}
|
||||
|
||||
return get_records_sql("SELECT $postdata, d.timemodified, u.firstname, u.lastname, u.email, u.picture
|
||||
FROM {$CFG->prefix}forum_discussions d,
|
||||
{$CFG->prefix}forum_posts p,
|
||||
{$CFG->prefix}user u $grouptable
|
||||
{$CFG->prefix}user u
|
||||
WHERE d.forum = '$forum'
|
||||
AND p.discussion = d.id
|
||||
AND p.parent = 0
|
||||
@ -1144,12 +1142,12 @@ function forum_make_mail_post(&$post, $user, $touser, $course,
|
||||
if ($ownpost) {
|
||||
$output .= "<a href=\"$CFG->wwwroot/mod/forum/post.php?delete=$post->id\">".get_string("delete", "forum")."</a>";
|
||||
if ($reply) {
|
||||
$output .= " | <a target=\"_blank\" href=\"$CFG->wwwroot/mod/forum/post.php?reply=$post->id\">".get_string("reply", "forum")."</a>";
|
||||
$output .= " | <a target=\"_blank\" href=\"$CFG->wwwroot/mod/forum/post.php?reply=$post->id\">".get_string("replyforum", "forum")."</a>";
|
||||
}
|
||||
$output .= " ";
|
||||
} else {
|
||||
if ($reply) {
|
||||
$output .= "<a target=\"_blank\" href=\"$CFG->wwwroot/mod/forum/post.php?reply=$post->id\">".get_string("reply", "forum")."</a> ";
|
||||
$output .= "<a target=\"_blank\" href=\"$CFG->wwwroot/mod/forum/post.php?reply=$post->id\">".get_string("replyforum", "forum")."</a> ";
|
||||
}
|
||||
}
|
||||
|
||||
@ -1840,7 +1838,8 @@ function forum_add_discussion($discussion) {
|
||||
set_field("forum_posts", "attachment", $post->attachment, "id", $post->id); //ignore errors
|
||||
}
|
||||
|
||||
// Now do the real module entry
|
||||
// Now do the main entry for the discussion,
|
||||
// linking to this first post
|
||||
|
||||
$discussion->firstpost = $post->id;
|
||||
$discussion->timemodified = $timenow;
|
||||
|
@ -105,6 +105,7 @@
|
||||
<input type="hidden" name=discussion value="<?php p($post->discussion) ?>">
|
||||
<input type="hidden" name=parent value="<?php p($post->parent) ?>">
|
||||
<input type="hidden" name=userid value="<?php p($post->userid) ?>">
|
||||
<input type="hidden" name=groupid value="<?php p($post->groupid) ?>">
|
||||
<input type="hidden" name=edit value="<?php p($post->edit) ?>">
|
||||
<input type="submit" value="<?php print_string("savechanges"); ?>">
|
||||
</td>
|
||||
|
@ -138,6 +138,7 @@
|
||||
$post->parent = 0;
|
||||
$post->subject = "";
|
||||
$post->userid = $USER->id;
|
||||
$post->groupid = get_current_group($course->id);
|
||||
$post->message = "";
|
||||
$post->format = $defaultformat;
|
||||
|
||||
@ -161,6 +162,15 @@
|
||||
if (! forum_user_can_post($forum)) {
|
||||
error("Sorry, but you can not post in this forum.");
|
||||
}
|
||||
|
||||
if ($cm = get_coursemodule_from_instance("forum", $forum->id, $course->id)) {
|
||||
if (groupmode($course, $cm) and !isteacheredit($course->id)) { // Make sure user can post here
|
||||
if (mygroupid($course->id) != $discussion->groupid) {
|
||||
error("Sorry, but you can not post in this discussion.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Load up the $post variable.
|
||||
|
||||
$post->course = $course->id;
|
||||
|
@ -200,6 +200,7 @@
|
||||
$discussion->name = backup_todb($dis_info['#']['NAME']['0']['#']);
|
||||
$discussion->firstpost = backup_todb($dis_info['#']['FIRSTPOST']['0']['#']);
|
||||
$discussion->userid = backup_todb($dis_info['#']['USERID']['0']['#']);
|
||||
$discussion->groupid = backup_todb($dis_info['#']['GROUPID']['0']['#']);
|
||||
$discussion->assessed = backup_todb($dis_info['#']['ASSESSED']['0']['#']);
|
||||
$discussion->timemodified = backup_todb($dis_info['#']['TIMEMODIFIED']['0']['#']);
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
// This fragment is called by /admin/index.php
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
$module->version = 2004011404;
|
||||
$module->version = 2004012200;
|
||||
$module->cron = 60;
|
||||
|
||||
?>
|
||||
|
Loading…
x
Reference in New Issue
Block a user