Merged from 1.7

This commit is contained in:
vyshane 2006-11-13 07:32:21 +00:00
parent 90a0c73001
commit a4ea3ef30a

View File

@ -1823,11 +1823,6 @@ function forum_make_mail_post(&$post, $user, $touser, $course,
$post->discussion.'&amp;parent='.$post->parent.'">'.get_string('parent', 'forum').'</a>'; $post->discussion.'&amp;parent='.$post->parent.'">'.get_string('parent', 'forum').'</a>';
} }
if ($ownpost) {
$commands[] = '<a target="_blank" href="'.$CFG->wwwroot.'/mod/forum/post.php?delete='.$post->id.'">'.
get_string('delete', 'forum').'</a>';
}
if ($reply) { if ($reply) {
$commands[] = '<a target="_blank" href="'.$CFG->wwwroot.'/mod/forum/post.php?reply='.$post->id.'">'. $commands[] = '<a target="_blank" href="'.$CFG->wwwroot.'/mod/forum/post.php?reply='.$post->id.'">'.
get_string('reply', 'forum').'</a>'; get_string('reply', 'forum').'</a>';
@ -2036,9 +2031,6 @@ function forum_print_post(&$post, $courseid, $ownpost=false, $reply=false, $link
$commands[] = '<a href="'.$CFG->wwwroot.'/mod/forum/discuss.php?d='. $commands[] = '<a href="'.$CFG->wwwroot.'/mod/forum/discuss.php?d='.
$post->discussion.'#'.$post->parent.'">'.$strparent.'</a>'; $post->discussion.'#'.$post->parent.'">'.$strparent.'</a>';
} }
$editownpost = $ownpost && has_capability('mod/forum:replypost', $modcontext);
} else {
$editownpost = $ownpost && has_capability('mod/forum:startdiscussion', $modcontext);
} }
$forumtype = get_field('forum', 'type', 'id', $post->forum); $forumtype = get_field('forum', 'type', 'id', $post->forum);
@ -2054,7 +2046,7 @@ function forum_print_post(&$post, $courseid, $ownpost=false, $reply=false, $link
if ($editownpost or $editanypost) { if ($ownpost or $editanypost) {
if (($age < $CFG->maxeditingtime) or $editanypost) { if (($age < $CFG->maxeditingtime) or $editanypost) {
$commands[] = '<a href="'.$CFG->wwwroot.'/mod/forum/post.php?edit='.$post->id.'">'.$stredit.'</a>'; $commands[] = '<a href="'.$CFG->wwwroot.'/mod/forum/post.php?edit='.$post->id.'">'.$stredit.'</a>';
} }
@ -2073,7 +2065,7 @@ function forum_print_post(&$post, $courseid, $ownpost=false, $reply=false, $link
$commands[] = '<a href="'.$CFG->wwwroot.'/mod/forum/post.php?delete='.$post->id.'">'.$strdelete.'</a>'; $commands[] = '<a href="'.$CFG->wwwroot.'/mod/forum/post.php?delete='.$post->id.'">'.$strdelete.'</a>';
} }
if ($reply and has_capability('mod/forum:replypost', $modcontext)) { if ($reply) {
$commands[] = '<a href="'.$CFG->wwwroot.'/mod/forum/post.php?reply='.$post->id.'">'.$strreply.'</a>'; $commands[] = '<a href="'.$CFG->wwwroot.'/mod/forum/post.php?reply='.$post->id.'">'.$strreply.'</a>';
} }
@ -2934,10 +2926,6 @@ function forum_user_can_post_discussion($forum, $currentgroup=false, $groupmode=
return false; return false;
} }
if (has_capability('moodle/legacy:guest', $context, NULL, false)) { // User is a guest here!
return false;
}
if ($forum->type == "eachuser") { if ($forum->type == "eachuser") {
return (!forum_user_has_posted_discussion($forum->id, $USER->id)); return (!forum_user_has_posted_discussion($forum->id, $USER->id));
} else if ($currentgroup) { } else if ($currentgroup) {
@ -2969,11 +2957,11 @@ function forum_user_can_post($forum, $user=NULL) {
$context = get_context_instance(CONTEXT_MODULE, $cm->id); $context = get_context_instance(CONTEXT_MODULE, $cm->id);
if (isset($user)) { if (isset($user)) {
$canreply = has_capability('mod/forum:replypost', $context, $user->id, false) && $canreply = has_capability('mod/forum:replypost', $context, $user->id, false)
!has_capability('moodle/legacy:guest', $context, $user->id, false); && !has_capability('moodle/legacy:guest', $context, $user->id, false);
} else { } else {
$canreply = has_capability('mod/forum:replypost', $context, NULL, false) && $canreply = has_capability('mod/forum:replypost', $context, NULL, false)
!has_capability('moodle/legacy:guest', $context, NULL, false); && !has_capability('moodle/legacy:guest', $context, NULL, false);
} }
return $canreply; return $canreply;
@ -3143,10 +3131,14 @@ function forum_print_latest_discussions($course, $forum, $maxdiscussions=5, $dis
$visiblegroups = $currentgroup; $visiblegroups = $currentgroup;
} }
/// If the user can post discussions, then this is a good place to put the button for it /// If the user can post discussions, then this is a good place to put the
//add group mode in there, to test for visible group /// button for it. We do not show the button if we are showing site news
if (forum_user_can_post_discussion($forum, $currentgroup, $groupmode) || /// and the current user is a guest.
has_capability('moodle/legacy:guest', $context, NULL, false)) {
// TODO: Add group mode in there, to test for visible group.
if (forum_user_can_post_discussion($forum, $currentgroup, $groupmode)
|| (has_capability('moodle/legacy:guest', $context, NULL, false)
&& $course->id != SITEID)) {
echo '<div class="singlebutton forumaddnew">'; echo '<div class="singlebutton forumaddnew">';
echo "<form name=\"newdiscussionform\" method=\"get\" action=\"$CFG->wwwroot/mod/forum/post.php\">"; echo "<form name=\"newdiscussionform\" method=\"get\" action=\"$CFG->wwwroot/mod/forum/post.php\">";