mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
Merged MDL-10990 (5) revert in 1.9
This commit is contained in:
parent
94519ff59b
commit
7d225563bd
1 changed files with 16 additions and 32 deletions
|
@ -3823,24 +3823,14 @@ function forum_user_can_post_discussion($forum, $currentgroup=-1, $groupmode=-1,
|
||||||
// $forum is an object
|
// $forum is an object
|
||||||
global $USER, $SESSION, $COURSE;
|
global $USER, $SESSION, $COURSE;
|
||||||
|
|
||||||
// shortcut - guest and not-logged-in users can not post
|
if (!$cm) {
|
||||||
if (isguestuser() or !isloggedin()) {
|
debugging('missing cm', DEBUG_DEVELOPER);
|
||||||
return false;
|
if (!$cm = get_coursemodule_from_instance('forum', $forum->id, $forum->course)) {
|
||||||
}
|
error('Course Module ID was incorrect');
|
||||||
|
|
||||||
if (!$context) {
|
|
||||||
if (!$cm) {
|
|
||||||
debugging('missing cm', DEBUG_DEVELOPER);
|
|
||||||
if (!$cm = get_coursemodule_from_instance('forum', $forum->id, $forum->course)) {
|
|
||||||
error('Course Module ID was incorrect');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
|
||||||
}
|
}
|
||||||
|
if (!$context) {
|
||||||
// normal users with temporary guest access can not add discussions
|
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||||
if (has_capability('moodle/legacy:guest', $context, $USER->id, false)) {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($currentgroup == -1) {
|
if ($currentgroup == -1) {
|
||||||
|
@ -3891,15 +3881,6 @@ function forum_user_can_post_discussion($forum, $currentgroup=-1, $groupmode=-1,
|
||||||
* @param $user - user object
|
* @param $user - user object
|
||||||
*/
|
*/
|
||||||
function forum_user_can_post($forum, $user=NULL, $cm=NULL, $context=NULL) {
|
function forum_user_can_post($forum, $user=NULL, $cm=NULL, $context=NULL) {
|
||||||
global $USER;
|
|
||||||
if (empty($user)) {
|
|
||||||
$user = $USER;
|
|
||||||
}
|
|
||||||
|
|
||||||
// shortcut - guest and not-logged-in users can not post
|
|
||||||
if (isguestuser($user) or empty($user->id)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$context) {
|
if (!$context) {
|
||||||
if (!$cm) {
|
if (!$cm) {
|
||||||
|
@ -3911,18 +3892,21 @@ function forum_user_can_post($forum, $user=NULL, $cm=NULL, $context=NULL) {
|
||||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// normal users with temporary guest access can not post
|
|
||||||
if (has_capability('moodle/legacy:guest', $context, $user->id, false)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($forum->type == 'news') {
|
if ($forum->type == 'news') {
|
||||||
$capname = 'mod/forum:replynews';
|
$capname = 'mod/forum:replynews';
|
||||||
} else {
|
} else {
|
||||||
$capname = 'mod/forum:replypost';
|
$capname = 'mod/forum:replypost';
|
||||||
}
|
}
|
||||||
|
|
||||||
return has_capability($capname, $context, $user->id, false);
|
if (!empty($user)) {
|
||||||
|
$canreply = has_capability($capname, $context, $user->id, false)
|
||||||
|
&& !has_capability('moodle/legacy:guest', $context, $user->id, false);
|
||||||
|
} else {
|
||||||
|
$canreply = has_capability($capname, $context, NULL, false)
|
||||||
|
&& !has_capability('moodle/legacy:guest', $context, NULL, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $canreply;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -4110,7 +4094,7 @@ function forum_print_latest_discussions($course, $forum, $maxdiscussions=5, $dis
|
||||||
// and the current user is a guest.
|
// and the current user is a guest.
|
||||||
|
|
||||||
if (forum_user_can_post_discussion($forum, $currentgroup, $groupmode, $cm, $context) ||
|
if (forum_user_can_post_discussion($forum, $currentgroup, $groupmode, $cm, $context) ||
|
||||||
($forum->type != 'news' and (isguestuser() or !isloggedin())) ) {
|
($forum->type != 'news' && has_capability('moodle/legacy:guest', $context, NULL, false)) ) {
|
||||||
|
|
||||||
echo '<div class="singlebutton forumaddnew">';
|
echo '<div class="singlebutton forumaddnew">';
|
||||||
echo "<form id=\"newdiscussionform\" method=\"get\" action=\"$CFG->wwwroot/mod/forum/post.php\">";
|
echo "<form id=\"newdiscussionform\" method=\"get\" action=\"$CFG->wwwroot/mod/forum/post.php\">";
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue