mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 04:30:15 +01:00
Added course module groupmodes in convertion to roles logic
This commit is contained in:
parent
df44078448
commit
2a1b4af377
@ -4448,14 +4448,14 @@ function forum_reset_course_form($course) {
|
||||
* @param $forum - a forum object with the same attributes as a record
|
||||
* from the forum database table
|
||||
* @param $forummodid - the id of the forum module, from the modules table
|
||||
* @param $studentroles - array of roles that have the moodle/legacy:student
|
||||
* capability
|
||||
* @param $guestroles - array of roles that have the moodle/legacy:guest
|
||||
* capability
|
||||
* @param $teacherroles - array of roles that have moodle/legacy:teacher
|
||||
* @param $studentroles - array of roles that have moodle/legacy:student
|
||||
* @param $guestroles - array of roles that have moodle/legacy:guest
|
||||
* @param $cmid - the course_module id for this forum instance
|
||||
* @return boolean - forum was converted or not
|
||||
*/
|
||||
function forum_convert_to_roles($forum, $forummodid, $teacherroles=array(), $studentroles=array(), $guestroles=array(), $cmid=NULL) {
|
||||
function forum_convert_to_roles($forum, $forummodid, $teacherroles=array(),
|
||||
$studentroles=array(), $guestroles=array(), $cmid=NULL) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
@ -4634,6 +4634,35 @@ function forum_convert_to_roles($forum, $forummodid, $teacherroles=array(), $stu
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (empty($cm)) {
|
||||
$cm = get_record('course_modules', 'id', $cmid);
|
||||
}
|
||||
|
||||
// $cm->groupmode:
|
||||
// 0 - No groups
|
||||
// 1 - Separate groups
|
||||
// 2 - Visible groups
|
||||
switch ($cm->groupmode) {
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
foreach ($studentroles as $studentrole) {
|
||||
assign_capability('moodle/site:accessallgroups', CAP_PREVENT, $studentrole->id, $context->id);
|
||||
}
|
||||
foreach ($teacherroles as $teacherrole) {
|
||||
assign_capability('moodle/site:accessallgroups', CAP_ALLOW, $teacherrole->id, $context->id);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
foreach ($studentroles as $studentrole) {
|
||||
assign_capability('moodle/site:accessallgroups', CAP_ALLOW, $studentrole->id, $context->id);
|
||||
}
|
||||
foreach ($teacherroles as $teacherrole) {
|
||||
assign_capability('moodle/site:accessallgroups', CAP_ALLOW, $teacherrole->id, $context->id);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -171,9 +171,8 @@
|
||||
// we need to convert the forum to use Roles. It means the backup
|
||||
// was made pre Moodle 1.7. We check the backup_version to make
|
||||
// sure.
|
||||
if (($restore->backup_version < 2006082300) ||
|
||||
(isset($forum->open) && isset($forum->assesspublic))) {
|
||||
|
||||
if (isset($forum->open) && isset($forum->assesspublic)) {
|
||||
|
||||
$forummod = get_record('modules', 'name', 'forum');
|
||||
|
||||
if (!$teacherroles = get_roles_with_capability('moodle/legacy:teacher', CAP_ALLOW)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user