Index: mod/data/lib.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/data/lib.php,v retrieving revision 1.137.2.31 diff -u -r1.137.2.31 lib.php --- mod/data/lib.php 24 Apr 2008 17:10:03 -0000 1.137.2.31 +++ mod/data/lib.php 7 May 2008 08:15:20 -0000 @@ -1506,13 +1506,14 @@ * @param $data - a data object with the same attributes as a record * from the data database table * @param $datamodid - the id of the data 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 data instance * @return boolean - data module was converted or not */ -function data_convert_to_roles($data, $teacherroles=array(), $studentroles=array(), $cmid=NULL) { +function data_convert_to_roles($data, $editingteacherroles=array(), $teacherroles=array(), $studentroles=array(), $cmid=NULL) { global $CFG; @@ -1544,6 +1545,9 @@ foreach ($studentroles as $studentrole) { assign_capability('mod/data:writeentry', CAP_PREVENT, $studentrole->id, $context->id); } + foreach ($editingteacherroles as $teacherrole) { + assign_capability('mod/data:writeentry', CAP_ALLOW, $teacherrole->id, $context->id); + } foreach ($teacherroles as $teacherrole) { assign_capability('mod/data:writeentry', CAP_ALLOW, $teacherrole->id, $context->id); } @@ -1552,6 +1556,9 @@ foreach ($studentroles as $studentrole) { assign_capability('mod/data:writeentry', CAP_ALLOW, $studentrole->id, $context->id); } + foreach ($editingteacherroles as $teacherrole) { + assign_capability('mod/data:writeentry', CAP_ALLOW, $teacherrole->id, $context->id); + } foreach ($teacherroles as $teacherrole) { assign_capability('mod/data:writeentry', CAP_ALLOW, $teacherrole->id, $context->id); } @@ -1567,6 +1574,9 @@ foreach ($studentroles as $studentrole) { assign_capability('mod/data:rate', CAP_PREVENT, $studentrole->id, $context->id); } + foreach ($editingteacherroles as $teacherrole) { + assign_capability('mod/data:rate', CAP_PREVENT, $teacherrole->id, $context->id); + } foreach ($teacherroles as $teacherrole) { assign_capability('mod/data:rate', CAP_PREVENT, $teacherrole->id, $context->id); } @@ -1575,6 +1585,9 @@ foreach ($studentroles as $studentrole) { assign_capability('mod/data:rate', CAP_ALLOW, $studentrole->id, $context->id); } + foreach ($editingteacherroles as $teacherrole) { + assign_capability('mod/data:rate', CAP_ALLOW, $teacherrole->id, $context->id); + } foreach ($teacherroles as $teacherrole) { assign_capability('mod/data:rate', CAP_ALLOW, $teacherrole->id, $context->id); } @@ -1583,6 +1596,9 @@ foreach ($studentroles as $studentrole) { assign_capability('mod/data:rate', CAP_PREVENT, $studentrole->id, $context->id); } + foreach ($editingteacherroles as $teacherrole) { + assign_capability('mod/data:rate', CAP_ALLOW, $teacherrole->id, $context->id); + } foreach ($teacherroles as $teacherrole) { assign_capability('mod/data:rate', CAP_ALLOW, $teacherrole->id, $context->id); } @@ -1597,6 +1613,9 @@ foreach ($studentroles as $studentrole) { assign_capability('mod/data:viewrating', CAP_PREVENT, $studentrole->id, $context->id); } + foreach ($editingteacherroles as $teacherrole) { + assign_capability('mod/data:viewrating', CAP_ALLOW, $teacherrole->id, $context->id); + } foreach ($teacherroles as $teacherrole) { assign_capability('mod/data:viewrating', CAP_ALLOW, $teacherrole->id, $context->id); } @@ -1605,6 +1624,9 @@ foreach ($studentroles as $studentrole) { assign_capability('mod/data:viewrating', CAP_ALLOW, $studentrole->id, $context->id); } + foreach ($editingteacherroles as $teacherrole) { + assign_capability('mod/data:viewrating', CAP_ALLOW, $teacherrole->id, $context->id); + } foreach ($teacherroles as $teacherrole) { assign_capability('mod/data:viewrating', CAP_ALLOW, $teacherrole->id, $context->id); } @@ -1622,6 +1644,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); } @@ -1630,6 +1655,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/data/restorelib.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/data/restorelib.php,v retrieving revision 1.27.2.2 diff -u -r1.27.2.2 restorelib.php --- mod/data/restorelib.php 17 Mar 2008 21:34:00 -0000 1.27.2.2 +++ mod/data/restorelib.php 7 May 2008 08:15:20 -0000 @@ -131,19 +131,31 @@ if (isset($database->participants) && isset($database->assesspublic)) { if (!$teacherroles = get_roles_with_capability('moodle/legacy:teacher', CAP_ALLOW)) { - notice('Default teacher role was not found. Roles and permissions '. - 'for your database modules will have to be manually set.'); + if (!defined('RESTORE_SILENTLY')) { + notify('Default teacher role was not found. Roles and permissions '. + 'for your database modules will have to be manually set.'); + } + } + 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 your database modules 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 database modules will have to be manually set.'); + if (!defined('RESTORE_SILENTLY')) { + notify('Default student role was not found. Roles and permissions '. + 'for all your database modules 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 all your database modules will have to be manually set.'); + if (!defined('RESTORE_SILENTLY')) { + notify('Default guest role was not found. Roles and permissions '. + 'for all your database modules will have to be manually set.'); + } } require_once($CFG->dirroot.'/mod/data/lib.php'); - data_convert_to_roles($database, $teacherroles, $studentroles, + data_convert_to_roles($database, $editingteacherroles, $teacherroles, $studentroles, $restore->mods['data']->instances[$mod->id]->restored_as_course_module); } @@ -725,4 +737,4 @@ return $status; } -?> \ No newline at end of file +?> Index: mod/data/db/mysql.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/data/db/Attic/mysql.php,v retrieving revision 1.23 diff -u -r1.23 mysql.php --- mod/data/db/mysql.php 13 Dec 2006 20:26:12 -0000 1.23 +++ mod/data/db/mysql.php 7 May 2008 08:15:20 -0000 @@ -85,6 +85,10 @@ if ($data = get_records('data')) { + 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 '. @@ -96,7 +100,7 @@ 'this upgrade.'); } foreach ($data as $d) { - if (!data_convert_to_roles($d, $teacherroles, $studentroles)) { + if (!data_convert_to_roles($d, $editingteacherroles, $teacherroles, $studentroles)) { notify('Data with id '.$d->id.' was not upgraded'); } } Index: mod/data/db/postgres7.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/data/db/Attic/postgres7.php,v retrieving revision 1.22 diff -u -r1.22 postgres7.php --- mod/data/db/postgres7.php 13 Dec 2006 20:26:12 -0000 1.22 +++ mod/data/db/postgres7.php 7 May 2008 08:15:20 -0000 @@ -169,6 +169,10 @@ if ($data = get_records('data')) { + 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 '. @@ -180,7 +184,7 @@ 'this upgrade.'); } foreach ($data as $d) { - if (!data_convert_to_roles($d, $teacherroles, $studentroles)) { + if (!data_convert_to_roles($d, $editingteacherroles, $teacherroles, $studentroles)) { notify('Data with id '.$d->id.' was not upgraded'); } }