Commit 57a9d96e authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Remove hardcoded references to 'tutor' role in core code (bug #827762)



Change-Id: I7e72a77375cff65dd20189ba1b93cf9dbda3be42
Signed-off-by: default avatarRichard Mansfield <richard.mansfield@catalyst.net.nz>
parent 279d965e
......@@ -45,29 +45,32 @@ $jointype = param_variable('jointype');
// add members to group and cannot remove anyone. Group admins can do anything.
// With regard to invitation, both admins and tutors can invite people.
foreach (array_unique(array_merge($initialgroups, $resultgroups)) as $groupid) {
if (!group_user_access($groupid)) {
$allgroups = array_unique(array_merge($initialgroups, $resultgroups));
$groupdata = get_records_select_assoc(
'group',
'id IN (' . join(',', array_fill(0, count($allgroups), '?')) . ')',
$allgroups
);
foreach (group_get_grouptypes() as $grouptype) {
safe_require('grouptype', $grouptype);
}
foreach ($allgroups as $groupid) {
if (!$loggedinrole = group_user_access($groupid)) {
json_reply('local', get_string('accessdenied', 'error'));
break;
}
switch (group_user_access($groupid)) {
case 'member':
json_reply('local', get_string('accessdenied', 'error'));
break;
case 'tutor':
if ($usertype = group_user_access($groupid, $userid)) {
if (($usertype == 'member') && in_array($groupid, array_diff($initialgroups, $resultgroups))) {
json_reply('local', get_string('cantremovemember', 'group'));
}
elseif ($usertype != 'member' && in_array($groupid, array_diff($initialgroups, $resultgroups))) {
json_reply('local', get_string('cantremoveuserisadmin', 'group'));
}
}
if ($loggedinrole == 'admin') {
continue;
}
if (!in_array($loggedinrole, call_static_method('GroupType' . $groupdata[$groupid]->grouptype, 'get_view_assessing_roles'))) {
json_reply('local', get_string('accessdenied', 'error'));
}
if (group_user_access($groupid, $userid) && in_array($groupid, array_diff($initialgroups, $resultgroups))) {
json_reply('local', get_string('cantremovememberfromgroup', 'group', hsc($groupdata[$groupid]->name)));
}
}
$groupdata = get_records_select_assoc('group', 'id IN (' . join(',', array_unique(array_merge($initialgroups, $resultgroups))) . ')');
if ($jointype == 'controlled') {
db_begin();
//remove group membership
......
......@@ -31,3 +31,4 @@ $string['name'] = 'Course';
$string['admin'] = 'Admin';
$string['tutor'] = 'Tutor';
$string['member'] = 'Member';
$string['youaregrouptutor'] = 'You are a tutor in this group';
......@@ -92,8 +92,7 @@ $string['changedgroupmembership'] = 'Group membership updated sucessfully.';
$string['changedgroupmembershipsubject'] = 'Your group memberships have been changed';
$string['addedtogroupsmessage'] = "%s has added you to the group(s):\n\n%s\n\n";
$string['removedfromgroupsmessage'] = "%s has removed you from the group(s):\n\n%s\n\n";
$string['cantremoveuserisadmin'] = "Tutor cannot remove admins and other tutorsmembers.";
$string['cantremovemember'] = "Tutor cannot remove members.";
$string['cantremovememberfromgroup'] = "You cannot remove users from %s";
$string['current'] = "Current";
$string['requests'] = "Requests";
$string['invites'] = "Invites";
......@@ -115,13 +114,6 @@ $string['memberchangesuccess'] = 'Membership status changed successfully';
$string['viewreleasedsubject'] = 'Your page "%s" has been released from %s by %s';
$string['viewreleasedmessage'] = 'Your page "%s" has been released from %s by %s';
$string['viewreleasedsuccess'] = 'Page was released successfully';
$string['groupmembershipchangesubject'] = 'Group membership: %s';
$string['groupmembershipchangedmessagetutor'] = 'You have been promoted to a tutor in this group';
$string['groupmembershipchangedmessagemember'] = 'You have been demoted from a tutor in this group';
$string['groupmembershipchangedmessageremove'] = 'You have been removed from this group';
$string['groupmembershipchangedmessagedeclinerequest'] = 'Your request to join this group has been declined';
$string['groupmembershipchangedmessageaddedtutor'] = 'You have been added as a tutor in this group';
$string['groupmembershipchangedmessageaddedmember'] = 'You have been added as a member in this group';
$string['leavegroup'] = 'Leave this group';
$string['joingroup'] = 'Join this group';
$string['requestjoingroup'] = 'Request to join this group';
......@@ -168,7 +160,6 @@ $string['nogroups'] = 'No groups';
$string['deletespecifiedgroup'] = 'Delete group \'%s\'';
$string['requestjoinspecifiedgroup'] = 'Request to join group \'%s\'';
$string['youaregroupmember'] = 'You are a member of this group';
$string['youaregrouptutor'] = 'You are a tutor in this group';
$string['youaregroupadmin'] = 'You are an admin in this group';
$string['youowngroup'] = 'You own this group';
$string['groupsnotin'] = 'Groups I\'m not in';
......
......@@ -93,7 +93,6 @@ $string['loggedin'] = 'Logged In Users';
$string['friends'] = 'Friends';
$string['groups'] = 'Groups';
$string['users'] = 'Users';
$string['tutors'] = 'tutors';
$string['everyoneingroup'] = 'Everyone in Group';
// secret url
......@@ -177,7 +176,6 @@ $string['canteditsubmitted'] = 'You can\'t edit this page because it has been su
$string['Submitted'] = 'Submitted';
$string['submittedforassessment'] = 'Submitted for assessment';
$string['addtutors'] = 'Add Tutors';
$string['viewcreatedsuccessfully'] = 'Page created successfully';
$string['viewaccesseditedsuccessfully'] = 'Page access saved successfully';
$string['viewsavedsuccessfully'] = 'Page saved successfully';
......
......@@ -466,13 +466,13 @@ function group_update($new, $create=false) {
}
}
// When group type changes from course to standard, make sure that tutors
// are demoted to members.
// @todo: avoid mentioning roles other than 'admin', 'member' except in grouptype
// classes, unless grouptypes disappear soon.
if ($old->grouptype == 'course' && $new->grouptype != 'course') {
set_field('group_member', 'role', 'member', 'group', $new->id, 'role', 'tutor');
}
// When the group type changes, make sure everyone has a valid role.
$allowedroles = call_static_method('GroupType' . $new->grouptype, 'get_roles');
set_field_select(
'group_member', 'role', 'member',
'"group" = ? AND NOT role IN (' . join(',', array_fill(0, count($allowedroles), '?')) . ')',
array_merge(array($new->id), $allowedroles)
);
// When a group changes from public -> private or vice versa, set the
// appropriate access permissions on the group homepage view.
......
<ul class="groupuserstatus">
{if $group->membershiptype == 'member'}
<li class="member">
{str tag="youaregroup$group->role" section="group"}
{if $group->role == 'member' || $group->role == 'admin'}
{str tag="youaregroup$group->role" section="group"}
{else}
{str tag="youaregroup$group->role" section="grouptype.$group->grouptype"}
{/if}
</li>
{if $group->canleave}
<li class="leavegroup"><a href ="{$WWWROOT}group/leave.php?id={$group->id}&amp;returnto={$returnto}" class="btn-leavegroup"><span class="icon">{str tag="leavegroup" section="group"}</span></a></li>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment