Index: mod/forum/lib.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/forum/lib.php,v retrieving revision 1.609.2.58 diff -u -r1.609.2.58 lib.php --- mod/forum/lib.php 20 Apr 2008 19:37:28 -0000 1.609.2.58 +++ mod/forum/lib.php 7 May 2008 08:45:05 -0000 @@ -6408,13 +6408,14 @@ * @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 $editingteacherroles - array of roles that have moodle/legacy:editingteacher * @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(), +function forum_convert_to_roles($forum, $forummodid, $editingteacherroles=array(), $teacherroles=array(), $studentroles=array(), $guestroles=array(), $cmid=NULL) { global $CFG; @@ -6559,6 +6560,9 @@ foreach ($studentroles as $studentrole) { assign_capability('mod/forum:rate', CAP_ALLOW, $studentrole->id, $context->id); } + foreach ($editingteacherroles as $teacherrole) { + assign_capability('mod/forum:rate', CAP_ALLOW, $teacherrole->id, $context->id); + } foreach ($teacherroles as $teacherrole) { assign_capability('mod/forum:rate', CAP_ALLOW, $teacherrole->id, $context->id); } @@ -6567,6 +6571,9 @@ foreach ($studentroles as $studentrole) { assign_capability('mod/forum:rate', CAP_PREVENT, $studentrole->id, $context->id); } + foreach ($editingteacherroles as $teacherrole) { + assign_capability('mod/forum:rate', CAP_ALLOW, $teacherrole->id, $context->id); + } foreach ($teacherroles as $teacherrole) { assign_capability('mod/forum:rate', CAP_ALLOW, $teacherrole->id, $context->id); } @@ -6582,6 +6589,9 @@ foreach ($studentroles as $studentrole) { assign_capability('mod/forum:viewanyrating', CAP_PREVENT, $studentrole->id, $context->id); } + foreach ($editingteacherroles as $teacherrole) { + assign_capability('mod/forum:viewanyrating', CAP_ALLOW, $teacherrole->id, $context->id); + } foreach ($teacherroles as $teacherrole) { assign_capability('mod/forum:viewanyrating', CAP_ALLOW, $teacherrole->id, $context->id); } @@ -6590,6 +6600,9 @@ foreach ($studentroles as $studentrole) { assign_capability('mod/forum:viewanyrating', CAP_ALLOW, $studentrole->id, $context->id); } + foreach ($editingteacherroles as $teacherrole) { + assign_capability('mod/forum:viewanyrating', CAP_ALLOW, $teacherrole->id, $context->id); + } foreach ($teacherroles as $teacherrole) { assign_capability('mod/forum:viewanyrating', CAP_ALLOW, $teacherrole->id, $context->id); } @@ -6611,6 +6624,9 @@ foreach ($studentroles as $studentrole) { assign_capability('moodle/site:accessallgroups', CAP_PREVENT, $studentrole->id, $context->id); } + foreach ($editingteacherroles as $teacherrole) { + assign_capability('moodle/site:accessallgroups', CAP_ALLOW, $teacherrole->id, $context->id); + } foreach ($teacherroles as $teacherrole) { assign_capability('moodle/site:accessallgroups', CAP_ALLOW, $teacherrole->id, $context->id); } @@ -6619,6 +6635,9 @@ foreach ($studentroles as $studentrole) { assign_capability('moodle/site:accessallgroups', CAP_ALLOW, $studentrole->id, $context->id); } + foreach ($editingteacherroles as $teacherrole) { + assign_capability('moodle/site:accessallgroups', CAP_ALLOW, $teacherrole->id, $context->id); + } foreach ($teacherroles as $teacherrole) { assign_capability('moodle/site:accessallgroups', CAP_ALLOW, $teacherrole->id, $context->id); } Index: mod/forum/restorelib.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/forum/restorelib.php,v retrieving revision 1.60.4.5 diff -u -r1.60.4.5 restorelib.php --- mod/forum/restorelib.php 30 Apr 2008 01:45:45 -0000 1.60.4.5 +++ mod/forum/restorelib.php 7 May 2008 08:45:05 -0000 @@ -161,21 +161,33 @@ $forummod = get_record('modules', 'name', 'forum'); - if (!$teacherroles = get_roles_with_capability('moodle/legacy:teacher', CAP_ALLOW)) { - notice('Default teacher role was not found. Roles and permissions '. + if (!$editingteacherroles = get_roles_with_capability('moodle/legacy:editingteacher', CAP_ALLOW)) { + if (!defined('RESTORE_SILENTLY')) { + notify('Default editing teacher role was not found. Roles and permissions '. 'for all your forums will have to be manually set.'); + } + } + if (!$teacherroles = get_roles_with_capability('moodle/legacy:teacher', CAP_ALLOW)) { + if (!defined('RESTORE_SILENTLY')) { + notify('Default teacher role was not found. Roles and permissions '. + 'for all your forums will have to be manually set.'); + } } if (!$studentroles = get_roles_with_capability('moodle/legacy:student', CAP_ALLOW)) { - notice('Default student role was not found. Roles and permissions '. - 'for all your forums will have to be manually set.'); + if (!defined('RESTORE_SILENTLY')) { + notify('Default student role was not found. Roles and permissions '. + 'for all your forums will have to be manually set.'); + } } if (!$guestroles = get_roles_with_capability('moodle/legacy:guest', CAP_ALLOW)) { - notice('Default guest role was not found. Roles and permissions '. - 'for teacher forums will have to be manually set.'); + if (!defined('RESTORE_SILENTLY')) { + notify('Default guest role was not found. Roles and permissions '. + 'for teacher forums will have to be manually set.'); + } } require_once($CFG->dirroot.'/mod/forum/lib.php'); forum_convert_to_roles($forum, $forummod->id, - $teacherroles, $studentroles, $guestroles, + $editingteacherroles, $teacherroles, $studentroles, $guestroles, $restore->mods['forum']->instances[$mod->id]->restored_as_course_module); } Index: mod/forum/db/mysql.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/forum/db/Attic/mysql.php,v retrieving revision 1.57 diff -u -r1.57 mysql.php --- mod/forum/db/mysql.php 26 Oct 2006 22:39:12 -0000 1.57 +++ mod/forum/db/mysql.php 7 May 2008 08:45:05 -0000 @@ -242,6 +242,10 @@ if ($forums = get_records('forum')) { + if (!$editingteacherroles = get_roles_with_capability('moodle/legacy:editingteacher', CAP_ALLOW)) { + notify('Default editing teacher role was not found. Roles and permissions '. + 'for all your forums will have to be manually set after this upgrade.'); + } if (!$teacherroles = get_roles_with_capability('moodle/legacy:teacher', CAP_ALLOW)) { notify('Default teacher role was not found. Roles and permissions '. 'for all your forums will have to be manually set after '. @@ -258,7 +262,7 @@ 'this upgrade.'); } foreach ($forums as $forum) { - if (!forum_convert_to_roles($forum, $forummod->id, $teacherroles, + if (!forum_convert_to_roles($forum, $forummod->id, $editingteacherroles, $teacherroles, $studentroles, $guestroles)) { notify('Forum with id '.$forum->id.' was not upgraded'); } Index: mod/forum/db/postgres7.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/forum/db/Attic/postgres7.php,v retrieving revision 1.52 diff -u -r1.52 postgres7.php --- mod/forum/db/postgres7.php 26 Oct 2006 22:46:07 -0000 1.52 +++ mod/forum/db/postgres7.php 7 May 2008 08:45:05 -0000 @@ -192,6 +192,10 @@ if ($forums = get_records('forum')) { + if (!$editingteacherroles = get_roles_with_capability('moodle/legacy:editingteacher', CAP_ALLOW)) { + notify('Default editing teacher role was not found. Roles and permissions '. + 'for all your forums will have to be manually set after this upgrade.'); + } if (!$teacherroles = get_roles_with_capability('moodle/legacy:teacher', CAP_ALLOW)) { notify('Default teacher role was not found. Roles and permissions '. 'for all your forums will have to be manually set after '. @@ -208,7 +212,7 @@ 'this upgrade.'); } foreach ($forums as $forum) { - if (!forum_convert_to_roles($forum, $forummod->id, $teacherroles, + if (!forum_convert_to_roles($forum, $forummod->id, $editingteacherroles, $teacherroles, $studentroles, $guestroles)) { notify('Forum with id '.$forum->id.' was not upgraded'); }