From a4ea3ef30a7459c925f88310ad0c408732f64954 Mon Sep 17 00:00:00 2001 From: vyshane Date: Mon, 13 Nov 2006 07:32:21 +0000 Subject: [PATCH] Merged from 1.7 --- mod/forum/lib.php | 36 ++++++++++++++---------------------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/mod/forum/lib.php b/mod/forum/lib.php index af8ced1d830..3cc15f0976d 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -1823,11 +1823,6 @@ function forum_make_mail_post(&$post, $user, $touser, $course, $post->discussion.'&parent='.$post->parent.'">'.get_string('parent', 'forum').''; } - if ($ownpost) { - $commands[] = ''. - get_string('delete', 'forum').''; - } - if ($reply) { $commands[] = ''. get_string('reply', 'forum').''; @@ -2036,9 +2031,6 @@ function forum_print_post(&$post, $courseid, $ownpost=false, $reply=false, $link $commands[] = ''.$strparent.''; } - $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); @@ -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) { $commands[] = ''.$stredit.''; } @@ -2073,7 +2065,7 @@ function forum_print_post(&$post, $courseid, $ownpost=false, $reply=false, $link $commands[] = ''.$strdelete.''; } - if ($reply and has_capability('mod/forum:replypost', $modcontext)) { + if ($reply) { $commands[] = ''.$strreply.''; } @@ -2934,10 +2926,6 @@ function forum_user_can_post_discussion($forum, $currentgroup=false, $groupmode= return false; } - if (has_capability('moodle/legacy:guest', $context, NULL, false)) { // User is a guest here! - return false; - } - if ($forum->type == "eachuser") { return (!forum_user_has_posted_discussion($forum->id, $USER->id)); } else if ($currentgroup) { @@ -2969,11 +2957,11 @@ function forum_user_can_post($forum, $user=NULL) { $context = get_context_instance(CONTEXT_MODULE, $cm->id); if (isset($user)) { - $canreply = has_capability('mod/forum:replypost', $context, $user->id, false) && - !has_capability('moodle/legacy:guest', $context, $user->id, false); + $canreply = has_capability('mod/forum:replypost', $context, $user->id, false) + && !has_capability('moodle/legacy:guest', $context, $user->id, false); } else { - $canreply = has_capability('mod/forum:replypost', $context, NULL, false) && - !has_capability('moodle/legacy:guest', $context, NULL, false); + $canreply = has_capability('mod/forum:replypost', $context, NULL, false) + && !has_capability('moodle/legacy:guest', $context, NULL, false); } return $canreply; @@ -3143,10 +3131,14 @@ function forum_print_latest_discussions($course, $forum, $maxdiscussions=5, $dis $visiblegroups = $currentgroup; } -/// If the user can post discussions, then this is a good place to put the button for it - //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)) { +/// If the user can post discussions, then this is a good place to put the +/// button for it. We do not show the button if we are showing site news +/// and the current user is a guest. + + // 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 '
'; echo "
wwwroot/mod/forum/post.php\">";