### Eclipse Workspace Patch 1.0 #P moodle20t Index: mod/forum/db/access.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/forum/db/access.php,v retrieving revision 1.21 diff -u -r1.21 access.php --- mod/forum/db/access.php 16 Dec 2009 22:22:39 -0000 1.21 +++ mod/forum/db/access.php 28 Mar 2010 21:42:18 -0000 @@ -54,11 +54,12 @@ 'captype' => 'read', 'contextlevel' => CONTEXT_MODULE, 'legacy' => array( + 'frontpage' => CAP_ALLOW, // needed especially for news on the frontpage 'guest' => CAP_ALLOW, 'student' => CAP_ALLOW, 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'admin' => CAP_ALLOW + 'manager' => CAP_ALLOW ) ), @@ -69,7 +70,7 @@ 'legacy' => array( 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'admin' => CAP_ALLOW + 'manager' => CAP_ALLOW ) ), @@ -83,7 +84,7 @@ 'student' => CAP_ALLOW, 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'admin' => CAP_ALLOW + 'manager' => CAP_ALLOW ) ), @@ -97,7 +98,7 @@ 'student' => CAP_ALLOW, 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'admin' => CAP_ALLOW + 'manager' => CAP_ALLOW ) ), @@ -110,7 +111,7 @@ 'legacy' => array( 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'admin' => CAP_ALLOW + 'manager' => CAP_ALLOW ) ), @@ -123,7 +124,7 @@ 'legacy' => array( 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'admin' => CAP_ALLOW + 'manager' => CAP_ALLOW ) ), @@ -135,7 +136,7 @@ 'student' => CAP_ALLOW, 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'admin' => CAP_ALLOW + 'manager' => CAP_ALLOW ) ), @@ -146,7 +147,7 @@ 'legacy' => array( 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'admin' => CAP_ALLOW + 'manager' => CAP_ALLOW ) ), @@ -157,7 +158,7 @@ 'legacy' => array( 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'admin' => CAP_ALLOW + 'manager' => CAP_ALLOW ) ), @@ -171,7 +172,7 @@ 'student' => CAP_ALLOW, 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'admin' => CAP_ALLOW + 'manager' => CAP_ALLOW ) ), @@ -183,7 +184,7 @@ 'student' => CAP_ALLOW, 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'admin' => CAP_ALLOW + 'manager' => CAP_ALLOW ) ), @@ -194,7 +195,7 @@ 'legacy' => array( 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'admin' => CAP_ALLOW + 'manager' => CAP_ALLOW ) ), @@ -205,7 +206,7 @@ 'legacy' => array( 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'admin' => CAP_ALLOW + 'manager' => CAP_ALLOW ) ), @@ -216,7 +217,7 @@ 'legacy' => array( 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'admin' => CAP_ALLOW + 'manager' => CAP_ALLOW ) ), @@ -229,7 +230,7 @@ 'legacy' => array( 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'admin' => CAP_ALLOW + 'manager' => CAP_ALLOW ) ), @@ -240,7 +241,7 @@ 'legacy' => array( 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'admin' => CAP_ALLOW + 'manager' => CAP_ALLOW ) ), @@ -251,7 +252,7 @@ 'legacy' => array( 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'admin' => CAP_ALLOW + 'manager' => CAP_ALLOW ) ), @@ -264,7 +265,7 @@ 'legacy' => array( 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'admin' => CAP_ALLOW + 'manager' => CAP_ALLOW ) ), @@ -298,7 +299,7 @@ 'legacy' => array( 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'admin' => CAP_ALLOW + 'manager' => CAP_ALLOW ) ), 'mod/forum:exportpost' => array( @@ -310,7 +311,7 @@ 'legacy' => array( 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'admin' => CAP_ALLOW + 'manager' => CAP_ALLOW ) ), 'mod/forum:exportownpost' => array( @@ -322,7 +323,7 @@ 'legacy' => array( 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'admin' => CAP_ALLOW, + 'manager' => CAP_ALLOW, 'student' => CAP_ALLOW, ) ), Index: grade/export/txt/db/access.php =================================================================== RCS file: /cvsroot/moodle/moodle/grade/export/txt/db/access.php,v retrieving revision 1.6 diff -u -r1.6 access.php --- grade/export/txt/db/access.php 4 Nov 2009 19:24:15 -0000 1.6 +++ grade/export/txt/db/access.php 28 Mar 2010 21:41:18 -0000 @@ -24,7 +24,7 @@ 'legacy' => array( 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'admin' => CAP_ALLOW + 'manager' => CAP_ALLOW ) ), @@ -33,7 +33,7 @@ 'captype' => 'read', 'contextlevel' => CONTEXT_COURSE, 'legacy' => array( - 'admin' => CAP_ALLOW + 'manager' => CAP_ALLOW ) ) Index: mod/data/tabs.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/data/tabs.php,v retrieving revision 1.34 diff -u -r1.34 tabs.php --- mod/data/tabs.php 1 Nov 2009 14:55:32 -0000 1.34 +++ mod/data/tabs.php 28 Mar 2010 21:42:09 -0000 @@ -48,7 +48,7 @@ // Add an advanced search tab. $row[] = new tabobject('asearch', $CFG->wwwroot.'/mod/data/view.php?d='.$data->id.'&mode=asearch', get_string('search', 'data')); - if (isloggedin()) { + if (isloggedin()) { // just a perf shortcut if (data_user_can_add_entry($data, $currentgroup, $groupmode)) { // took out participation list here! $addstring = empty($editentry) ? get_string('add', 'data') : get_string('editentry', 'data'); $row[] = new tabobject('add', $CFG->wwwroot.'/mod/data/edit.php?d='.$data->id, $addstring); Index: mod/data/rate.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/data/rate.php,v retrieving revision 1.22 diff -u -r1.22 rate.php --- mod/data/rate.php 16 Jan 2010 15:40:06 -0000 1.22 +++ mod/data/rate.php 28 Mar 2010 21:42:08 -0000 @@ -23,10 +23,6 @@ require_login($course, false, $cm); -if (isguestuser()) { - print_error('guestrate', 'data'); -} - $context = get_context_instance(CONTEXT_MODULE, $cm->id); require_capability('mod/data:rate', $context); Index: mod/data/edit.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/data/edit.php,v retrieving revision 1.62 diff -u -r1.62 edit.php --- mod/data/edit.php 5 Mar 2010 05:37:09 -0000 1.62 +++ mod/data/edit.php 28 Mar 2010 21:42:06 -0000 @@ -74,7 +74,7 @@ require_login($course->id, false, $cm); -if (!isloggedin() or has_capability('moodle/legacy:guest', get_context_instance(CONTEXT_SYSTEM), 0, false)) { +if (isguestuser()) { redirect('view.php?d='.$data->id); } Index: mod/data/restorelib.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/data/restorelib.php,v retrieving revision 1.41 diff -u -r1.41 restorelib.php --- mod/data/restorelib.php 18 Dec 2009 18:11:13 -0000 1.41 +++ mod/data/restorelib.php 28 Mar 2010 21:42:09 -0000 @@ -146,15 +146,15 @@ // backup_version to make sure. if (isset($database->participants) && isset($database->assesspublic)) { - if (!$teacherroles = get_roles_with_capability('moodle/legacy:teacher', CAP_ALLOW)) { + if (!$teacherroles = get_archetype_roles('teacher')) { notice('Default 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)) { + if (!$studentroles = get_archetype_roles('student')) { notice('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)) { + if (!$guestroles = get_archetype_roles('guest')) { notice('Default guest role was not found. Roles and permissions '. 'for all your database modules will have to be manually set.'); } Index: mod/data/lib.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/data/lib.php,v retrieving revision 1.265 diff -u -r1.265 lib.php --- mod/data/lib.php 22 Mar 2010 03:04:01 -0000 1.265 +++ mod/data/lib.php 28 Mar 2010 21:42:08 -0000 @@ -723,7 +723,7 @@ function data_isowner($record) { global $USER, $DB; - if (!isloggedin()) { + if (!isloggedin()) { // perf shortcut return false; } @@ -1527,7 +1527,7 @@ $cm = get_coursemodule_from_instance('data', $data->id); $context = get_context_instance(CONTEXT_MODULE, $cm->id); - if ($data->assessed and !empty($USER->id) and (has_capability('mod/data:rate', $context) or has_capability('mod/data:viewrating', $context) or data_isowner($record->id))) { + if ($data->assessed and isloggedin() and (has_capability('mod/data:rate', $context) or has_capability('mod/data:viewrating', $context) or data_isowner($record->id))) { if ($ratingsscale = make_grades_menu($data->scale)) { $ratingsmenuused = false; @@ -1748,9 +1748,9 @@ * @param object $data a data object with the same attributes as a record * from the data database table * @param int $datamodid the id of the data module, from the modules table - * @param array $teacherroles array of roles that have moodle/legacy:teacher - * @param array $studentroles array of roles that have moodle/legacy:student - * @param array $guestroles array of roles that have moodle/legacy:guest + * @param array $teacherroles array of roles that have archetype teacher + * @param array $studentroles array of roles that have archetype student + * @param array $guestroles array of roles that have archetype guest * @param int $cmid the course_module id for this data instance * @return boolean data module was converted or not */ @@ -2505,7 +2505,7 @@ if ($rs = $DB->get_recordset_sql($recordssql, array($data->courseid))) { foreach ($rs as $record) { if (array_key_exists($record->userid, $notenrolled) or !$record->userexists or $record->userdeleted - or !has_capability('moodle/course:view', $course_context , $record->userid)) { + or !is_enrolled($course_context, $record->userid)) { $DB->delete_records('data_ratings', array('recordid'=>$record->id)); $DB->delete_records('comments', array('itemid'=>$record->id, 'commentarea'=>'database_entry')); $DB->delete_records('data_content', array('recordid'=>$record->id)); @@ -2841,7 +2841,7 @@ $numentries = data_numentries($data); /// Check the number of entries required against the number of entries already made (doesn't apply to teachers) - if ($data->requiredentries > 0 && $numentries < $data->requiredentries && !has_capability('mod/data:manageentries', $cm->context)) { + if ($data->requiredentries > 0 && $numentries < $data->requiredentries && !has_capability('mod/data:manageentries', get_context_instance(CONTEXT_MODULE, $cm->id))) { $data->entriesleft = $data->requiredentries - $numentries; $key = $navigation->add(get_string('entrieslefttoadd', 'data', $data)); $navigation->get($key)->add_class('note'); Index: mod/glossary/lib.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/glossary/lib.php,v retrieving revision 1.287 diff -u -r1.287 lib.php --- mod/glossary/lib.php 22 Mar 2010 03:04:01 -0000 1.287 +++ mod/glossary/lib.php 28 Mar 2010 21:42:20 -0000 @@ -947,7 +947,7 @@ $return .= get_string('entryishidden','glossary'); } - if (has_capability('mod/glossary:manageentries', $context) or (!empty($USER->id) and has_capability('mod/glossary:write', $context) and $entry->userid == $USER->id)) { + if (has_capability('mod/glossary:manageentries', $context) or (isloggedin() and has_capability('mod/glossary:write', $context) and $entry->userid == $USER->id)) { // only teachers can export entries so check it out if (has_capability('mod/glossary:export', $context) and !$ismainglossary and !$importedentry) { $mainglossary = $DB->get_record('glossary', array('mainglossary'=>1,'course'=>$course->id)); @@ -1756,7 +1756,7 @@ $context = get_context_instance(CONTEXT_MODULE, $cm->id); $ratingsmenuused = false; - if (!empty($ratings) and !empty($USER->id)) { + if (!empty($ratings) and isloggedin()) { $useratings = true; if ($ratings->assesstimestart and $ratings->assesstimefinish) { if ($entry->timecreated < $ratings->assesstimestart or $entry->timecreated > $ratings->assesstimefinish) { @@ -2605,7 +2605,7 @@ if ($rs = $DB->get_recordset_sql($entriessql, $params)) { foreach ($rs as $entry) { if (array_key_exists($entry->userid, $notenrolled) or !$entry->userexists or $entry->userdeleted - or !has_capability('moodle/course:view', $course_context , $entry->userid)) { + or !is_enrolled($course_context , $entry->userid)) { $DB->delete_records('glossary_ratings', array('entryid'=>$entry->id)); $DB->delete_records('glossary_comments', array('entryid'=>$entry->id)); $DB->delete_records('glossary_entries', array('id'=>$entry->id)); Index: mod/glossary/view.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/glossary/view.php,v retrieving revision 1.163 diff -u -r1.163 view.php --- mod/glossary/view.php 15 Mar 2010 07:59:30 -0000 1.163 +++ mod/glossary/view.php 28 Mar 2010 21:42:21 -0000 @@ -297,7 +297,7 @@ $CFG->enablerssfeeds && $CFG->glossary_enablerssfeeds && $glossary->rsstype && $glossary->rssarticles) { $tooltiptext = get_string("rsssubscriberss","glossary",format_string($glossary->name,true)); - if (empty($USER->id)) { + if (!isloggedin()) { $userid = 0; } else { $userid = $USER->id; Index: mod/glossary/sql.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/glossary/sql.php,v retrieving revision 1.47 diff -u -r1.47 sql.php --- mod/glossary/sql.php 1 Nov 2009 15:04:07 -0000 1.47 +++ mod/glossary/sql.php 28 Mar 2010 21:42:21 -0000 @@ -39,7 +39,7 @@ $params = array('gid1'=>$glossary->id, 'gid2'=>$glossary->id, 'myid'=>$USER->id, 'hook'=>$hook); $userid = ''; - if ( !empty($USER->id) ) { + if ( isloggedin() ) { $userid = "OR ge.userid = :myid"; } switch ($tab) { Index: mod/glossary/index.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/glossary/index.php,v retrieving revision 1.42 diff -u -r1.42 index.php --- mod/glossary/index.php 20 Mar 2010 22:15:59 -0000 1.42 +++ mod/glossary/index.php 28 Mar 2010 21:42:18 -0000 @@ -103,7 +103,7 @@ if ($glossary->rsstype and $glossary->rssarticles) { //Calculate the tolltip text $tooltiptext = get_string("rsssubscriberss","glossary",format_string($glossary->name)); - if (empty($USER->id)) { + if (!isloggedin()) { $userid = 0; } else { $userid = $USER->id; Index: mod/glossary/edit.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/glossary/edit.php,v retrieving revision 1.98 diff -u -r1.98 edit.php --- mod/glossary/edit.php 16 Jan 2010 15:40:01 -0000 1.98 +++ mod/glossary/edit.php 28 Mar 2010 21:42:18 -0000 @@ -19,10 +19,6 @@ $context = get_context_instance(CONTEXT_MODULE, $cm->id); -if (isguestuser()) { - print_error('guestnoedit', 'glossary', "$CFG->wwwroot/mod/glossary/view.php?id=$cmid"); -} - if (!$glossary = $DB->get_record('glossary', array('id'=>$cm->instance))) { print_error('invalidid', 'glossary'); } @@ -34,6 +30,10 @@ $PAGE->set_url($url); if ($id) { // if entry is specified + if (isguestuser()) { + print_error('guestnoedit', 'glossary', "$CFG->wwwroot/mod/glossary/view.php?id=$cmid"); + } + if (!$entry = $DB->get_record('glossary_entries', array('id'=>$id, 'glossaryid'=>$glossary->id))) { print_error('invalidentry'); } @@ -58,6 +58,7 @@ } else { // new entry require_capability('mod/glossary:write', $context); + // note: guest user does not have any write capability $entry = new object(); $entry->id = null; } Index: mod/glossary/db/access.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/glossary/db/access.php,v retrieving revision 1.13 diff -u -r1.13 access.php --- mod/glossary/db/access.php 4 Nov 2009 19:24:15 -0000 1.13 +++ mod/glossary/db/access.php 28 Mar 2010 21:42:21 -0000 @@ -40,7 +40,7 @@ 'student' => CAP_ALLOW, 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'admin' => CAP_ALLOW + 'manager' => CAP_ALLOW ) ), @@ -53,7 +53,7 @@ 'legacy' => array( 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'admin' => CAP_ALLOW + 'manager' => CAP_ALLOW ) ), @@ -66,7 +66,7 @@ 'legacy' => array( 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'admin' => CAP_ALLOW + 'manager' => CAP_ALLOW ) ), @@ -80,7 +80,7 @@ 'student' => CAP_ALLOW, 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'admin' => CAP_ALLOW + 'manager' => CAP_ALLOW ) ), @@ -93,7 +93,7 @@ 'legacy' => array( 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'admin' => CAP_ALLOW + 'manager' => CAP_ALLOW ) ), @@ -106,7 +106,7 @@ 'legacy' => array( 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'admin' => CAP_ALLOW + 'manager' => CAP_ALLOW ) ), @@ -117,7 +117,7 @@ 'legacy' => array( 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'admin' => CAP_ALLOW + 'manager' => CAP_ALLOW ) ), @@ -130,7 +130,7 @@ 'legacy' => array( 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'admin' => CAP_ALLOW + 'manager' => CAP_ALLOW ) ), @@ -141,7 +141,7 @@ 'legacy' => array( 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'admin' => CAP_ALLOW + 'manager' => CAP_ALLOW ) ), @@ -152,7 +152,7 @@ 'legacy' => array( 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'admin' => CAP_ALLOW + 'manager' => CAP_ALLOW ) ), @@ -165,7 +165,7 @@ 'legacy' => array( 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'admin' => CAP_ALLOW + 'manager' => CAP_ALLOW ) ), @@ -176,7 +176,7 @@ 'legacy' => array( 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'admin' => CAP_ALLOW, + 'manager' => CAP_ALLOW, 'student' => CAP_ALLOW, ) ), Index: lang/en_utf8/role.php =================================================================== RCS file: /cvsroot/moodle/moodle/lang/en_utf8/role.php,v retrieving revision 1.101 diff -u -r1.101 role.php --- lang/en_utf8/role.php 7 Mar 2010 09:28:56 -0000 1.101 +++ lang/en_utf8/role.php 28 Mar 2010 21:41:22 -0000 @@ -14,6 +14,7 @@ $string['allowroletoswitch'] = 'Allow users with role $a->fromrole to switch roles to the role $a->targetrole'; $string['allowswitch'] = 'Allow role switches'; $string['allsiteusers'] = 'All site users'; +$string['archetype'] = 'Role archetype'; $string['assignanotherrole'] = 'Assign another role'; $string['assignerror'] = 'Error while assigning the role $a->role to user $a->user.'; $string['assignrolenameincontext'] = 'Assign role \'$a->role\' in $a->context'; @@ -23,6 +24,14 @@ $string['assignglobalroles'] = 'Assign system roles'; $string['assignmentcontext'] = 'Assignment context'; $string['assignmentoptions'] = 'Assignment options'; +$string['archetypecoursecreator'] = 'ARCHETYPE: Course Creator'; +$string['archetypeeditingteacher'] = 'ARCHETYPE: Teacher (editing)'; +$string['archetypefrontpage'] = 'ARCHETYPE: Authenticated user on frontpage'; +$string['archetypeguest'] = 'ARCHETYPE: Guest'; +$string['archetypemanager'] = 'ARCHETYPE: Manager'; +$string['archetypestudent'] = 'ARCHETYPE: Student'; +$string['archetypeteacher'] = 'ARCHETYPE: Teacher (non-editing)'; +$string['archetypeuser'] = 'ARCHETYPE: Authenticated user'; $string['backtoallroles'] = 'Back to the list of all roles'; $string['backup:backupcourse'] = 'Backup courses'; $string['backup:downloadfile'] = 'Download files from backup areas'; @@ -59,6 +68,8 @@ $string['comment:delete'] = 'Delete comments'; $string['comment:post'] = 'Post comments'; $string['comment:view'] = 'Read comments'; +$string['confirmaddadmin'] = 'Do you really want to add user $a as new site administrator?'; +$string['confirmdeladmin'] = 'Do you really want to remove user $a from the list of site administrators?'; $string['context'] = 'Context'; $string['course:activityvisibility'] = 'Hide/show activities'; $string['course:bulkmessaging'] = 'Send a message to many people'; @@ -110,14 +121,16 @@ $string['errorbadroleshortname'] = 'Incorrect role short name'; $string['errorexistsrolename'] = 'Role name already exists'; $string['errorexistsroleshortname'] = 'Role name already exists'; +$string['existingadmins'] = 'Current site administrators'; $string['existingusers'] = '$a existing users'; $string['explanation'] = 'Explanation'; $string['explainpermission'] = 'Explain permission'; $string['explainpermissionsinfo'] = '
To use this table: