mirror of
https://github.com/moodle/moodle.git
synced 2025-08-07 01:46:45 +02:00
ROLES AND PERMISSIONS - FIRST CHECK-IN
======================================= WARNING: DEV IS CURRENTLY VERY UNSTABLE. This is a mega-checkin of the new Roles system. A lot of changes have been made in core and modules. Currently there are a lot of rough edges and known problems. We are working hard on these .. .the reason for getting this into HEAD at this stage is enable us to move faster (our branch was diverging from HEAD too much). Please keep an eye on http://docs.moodle.org/en/Roles for current status and information for developers on how to use the new Roles system.
This commit is contained in:
parent
394577c3e4
commit
bbbf2d4015
139 changed files with 40452 additions and 2001 deletions
|
@ -18,20 +18,24 @@
|
|||
}
|
||||
|
||||
if ($cm = get_coursemodule_from_instance("forum", $forum->id, $course->id)) {
|
||||
if (groupmode($course, $cm) and !isteacheredit($course->id)) { // Make sure user is allowed
|
||||
if (! mygroupid($course->id)) {
|
||||
error("Sorry, but you must be a group member to subscribe.");
|
||||
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
if (groupmode($course, $cm) and
|
||||
!has_capability('mod/forum:viewdiscussionsfromallgroups', $context->id)) {
|
||||
if (!mygroupid($course->id)) {
|
||||
error('Sorry, but you must be a group member to subscribe.');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$cm->id = 0;
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
}
|
||||
|
||||
if ($user) {
|
||||
if (!isteacher($course->id)) {
|
||||
error("Only teachers can subscribe/unsubscribe other people!");
|
||||
if (!has_capability('mod/forum:managesubscriptions', $context->id)) {
|
||||
error('You do not have the permission to subscribe/unsubscribe other people!');
|
||||
}
|
||||
if (! $user = get_record("user", "id", $user)) {
|
||||
if (!$user = get_record("user", "id", $user)) {
|
||||
error("User ID was incorrect");
|
||||
}
|
||||
} else {
|
||||
|
@ -43,7 +47,7 @@
|
|||
if (isguest()) { // Guests can't subscribe
|
||||
$wwwroot = $CFG->wwwroot.'/login/index.php';
|
||||
if (!empty($CFG->loginhttps)) {
|
||||
$wwwroot = str_replace('http:','https:', $wwwroot);
|
||||
$wwwroot = str_replace('http','https', $wwwroot);
|
||||
}
|
||||
|
||||
$strforums = get_string('modulenameplural', 'forum');
|
||||
|
@ -63,15 +67,9 @@
|
|||
exit;
|
||||
}
|
||||
|
||||
if ($forum->type == "teacher") {
|
||||
if (!isteacher($course->id)) {
|
||||
error("You must be a $course->teacher to subscribe to this forum");
|
||||
}
|
||||
}
|
||||
|
||||
$returnto = forum_go_back_to("index.php?id=$course->id");
|
||||
|
||||
if ($force and isteacher($course->id)) {
|
||||
if ($force and has_capability('mod/forum:managesubscriptions', $context->id)) {
|
||||
if (forum_is_forcesubscribed($forum->id)) {
|
||||
forum_forcesubscribe($forum->id, 0);
|
||||
redirect($returnto, get_string("everyonecanchoose", "forum"), 1);
|
||||
|
@ -97,7 +95,8 @@
|
|||
}
|
||||
|
||||
} else { // subscribe
|
||||
if ($forum->forcesubscribe == FORUM_DISALLOWSUBSCRIBE && !isteacher($forum->course)) {
|
||||
if ($forum->forcesubscribe == FORUM_DISALLOWSUBSCRIBE &&
|
||||
!has_capability('mod/forum:managesubscriptions', $context->id)) {
|
||||
error(get_string('disallowsubscribe'),$_SERVER["HTTP_REFERER"]);
|
||||
}
|
||||
if (forum_subscribe($user->id, $forum->id) ) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue