Commit fb265a61 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Fix role strings on edit view access

parent 824261d8
......@@ -84,6 +84,7 @@ $string['grouplower'] = 'group';
$string['tutors'] = 'tutors';
$string['loggedinlower'] = 'logged in users';
$string['publiclower'] = 'public';
$string['everyoneingroup'] = 'Everyone in Group';
// view user
$string['inviteusertojoingroup'] = 'Invite this user to join a group';
......
......@@ -265,16 +265,19 @@ class View {
// Get access for users and groups
$extradata = get_records_sql_array("
SELECT 'user' AS type, usr AS id, NULL AS role, startdate, stopdate
SELECT 'user' AS type, usr AS id, NULL AS role, NULL AS grouptype, startdate, stopdate
FROM {view_access_usr}
WHERE view = ?
UNION
SELECT 'group', \"group\", role, startdate, stopdate FROM {view_access_group}
SELECT 'group', \"group\", role, grouptype, startdate, stopdate FROM {view_access_group}
INNER JOIN {group} g ON (\"group\" = g.id AND g.deleted = ?)
WHERE view = ?", array($this->id, 0, $this->id));
if ($extradata) {
foreach ($extradata as &$extraitem) {
$extraitem = (array)$extraitem;
if ($extraitem['role']) {
$extraitem['roledisplay'] = get_string($extraitem['role'], 'grouptype.'.$extraitem['grouptype']);
}
}
$data = array_merge($data, $extradata);
}
......
......@@ -71,7 +71,7 @@ function renderAccessListItem(item) {
var row = TABLE({'class': cssClass},
TBODY(null,
TR(null,
TH(null, name, (item.role ? ' ' + item.role : '')),
TH(null, name, (item.role ? ' - ' + item.roledisplay : '')),
TD({'class': 'right'}, removeButton)
),
TR(null,
......@@ -219,16 +219,20 @@ searchTable.rowfunction = function(rowdata, rownumber, globaldata) {
}
else if (rowdata.type == 'group') {
rowdata.role = null;
var options = [OPTION({'value':null, 'selected':true}, '{{str tag=all}}')];
var options = [OPTION({'value':null, 'selected':true}, '{{str tag=everyoneingroup section=view}}')];
for (r in globaldata.roles[rowdata.grouptype]) {
options.push(OPTION({'value':globaldata.roles[rowdata.grouptype][r].name}, globaldata.roles[rowdata.grouptype][r].display));
}
roleSelector = SELECT({'name':'role'}, options);
connect(roleSelector, 'onchange', function() {
rowdata.role = this.value;
if (this.value) {
rowdata.roledisplay = scrapeText(this.childNodes[this.selectedIndex]);
}
});
appendChildNodes(buttonTD, roleSelector);
identityNodes.push(A({'href': config.wwwroot + 'group/view.php?id=' + rowdata.id, 'target': '_blank'}, rowdata.name));
identityNodes.push(" - ");
identityNodes.push(roleSelector);
}
return TR({'class': 'r' + (rownumber % 2)},
......
......@@ -47,7 +47,7 @@ switch ($type) {
$roles = get_records_array('grouptype_roles');
$data['roles'] = array();
foreach ($roles as $r) {
$data['roles'][$r->grouptype][] = array('name' => $r->role, 'display' => get_string($r->role));
$data['roles'][$r->grouptype][] = array('name' => $r->role, 'display' => get_string($r->role, 'grouptype.'.$r->grouptype));
}
break;
}
......
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