Commit 0d7c8913 authored by Nigel McNie's avatar Nigel McNie Committed by Nigel McNie
Browse files

Fixed bug 406 (Add Community Tutor only in View Access option missing)

parent f67df426
......@@ -283,7 +283,8 @@ function joinRequestControl() {
INPUT({'type': 'hidden', 'name': 'id', 'value': {$id}}),
INPUT({'type': 'hidden', 'name': 'joincontrol', 'value': 'request'}),
INPUT({'type': 'text', 'name': 'reason'}),
INPUT({'type': 'submit', 'value': '{$requeststr}'})));
' ',
INPUT({'type': 'submit', 'class': 'submit', 'value': '{$requeststr}'})));
insertSiblingNodesAfter('joinrequest', form);
return false;
}
......
......@@ -419,6 +419,7 @@ $string['memberrequests'] = 'Membership requests';
$string['submittedviews'] = 'Submitted views';
$string['releaseview'] = 'Release view';
$string['tutor'] = 'Tutor';
$string['tutors'] = 'Tutors';
$string['member'] = 'Member';
$string['remove'] = 'Remove';
$string['updatemembership'] = 'Update membership';
......
......@@ -69,6 +69,7 @@ $string['format.listchildren'] = 'List children of this Artefact';
$string['format.renderfull'] = 'Display entire artefact';
$string['format.rendermetadata'] = 'Display metadata for this Artefact';
$string['addtutors'] = 'Add Tutors';
$string['viewcreatedsuccessfully'] = 'View created successfully';
......
......@@ -79,6 +79,9 @@ function pieform_render_viewacl_getvaluebytype($type, $id) {
case 'group':
return get_field('group', 'name', 'id', $id);
break;
case 'community':
return get_field('community', 'name', 'id', $id);
break;
}
return "$type: $id";
}
......
......@@ -155,6 +155,9 @@ tr.required th {
.right {
text-align: right;
}
.fullwidth {
width: 100%;
}
.fl {
float: left;
}
......
......@@ -60,7 +60,7 @@
</tbody>
</table>
{if $tutor}
<input type="button" value="{str tag='updatemembership'}" onClick="return updateMembership();" / id="communitymembers_update">
<input type="button" class="button" value="{str tag='updatemembership'}" onClick="return updateMembership();" / id="communitymembers_update">
{/if}
</div>
{/if}
......
......@@ -54,7 +54,7 @@ function renderAccessListItem(item) {
var row = TABLE(null,
TBODY(null,
TR(null,
TH(null, item.name),
TH(null, item.name + (item.tutoronly ? ' ' + '{{str tag=tutors}}' : '')),
TD({'class': 'right'}, removeButton)
),
TR(null,
......@@ -65,10 +65,24 @@ function renderAccessListItem(item) {
'name': 'accesslist[' + count + '][type]',
'value': item.type
}),
(item.id ?
INPUT({
'type': 'hidden',
'name': 'accesslist[' + count + '][id]',
'value': item.id})
'value': item.id
})
:
null
),
(typeof(item.tutoronly) != 'undefined' ?
INPUT({
'type': 'hidden',
'name': 'accesslist[' + count + '][tutoronly]',
'value': item.tutoronly
})
:
null
)
)
)
)
......@@ -171,19 +185,33 @@ searchTable.pagerOptions = {
}
searchTable.query = '';
searchTable.rowfunction = function(rowdata, rownumber, globaldata) {
var addButton = BUTTON({'type': 'button', 'class': 'button'}, '{{str tag=add}}');
rowdata.type = searchTable.type;
var buttonTD = TD({'style': 'white-space:nowrap;'});
var addButton = BUTTON({'type': 'button', 'class': 'button'}, '{{str tag=add}}');
connect(addButton, 'onclick', function() {
rowdata.tutoronly = 0;
appendChildNodes('accesslist', renderAccessListItem(rowdata));
});
var profileIcon = null;
appendChildNodes(buttonTD, addButton);
var profileIcon, tutorAddButton = null;
if (rowdata.type == 'user') {
profileIcon = IMG({'src': config.wwwroot + 'thumb.php?type=profileicon&size=40x40&id=' + rowdata.id});
}
return TR({'class': 'r' + (rownumber%2)},
TD({'class': 'c', 'style': 'width:3em'}, addButton),
TD(null, rowdata.name),
TD({'class': 'c', 'style': 'width:40px'}, profileIcon)
else if (rowdata.type == 'community') {
tutorAddButton = BUTTON({'type': 'button', 'class': 'button'}, '{{str tag=addtutors section=view}}');
connect(tutorAddButton, 'onclick', function() {
rowdata.tutoronly = 1;
appendChildNodes('accesslist', renderAccessListItem(rowdata));
});
appendChildNodes(buttonTD, tutorAddButton);
}
return TR({'class': 'r' + (rownumber % 2)},
buttonTD,
TD({'class': 'fullwidth'}, rowdata.name),
TD({'class': 'center', 'style': 'width:40px'}, profileIcon)
);
}
searchTable.updateOnLoad();
......@@ -201,7 +229,7 @@ addLoadEvent(function () {
var accesslist = {{$accesslist}};
if (accesslist) {
forEach(accesslist, function(item) {
debugObject(item);
log(item);
renderAccessListItem(item);
});
}
......
......@@ -101,7 +101,7 @@ function createview4_submit(Pieform $form, $values) {
}
}
else {
throw new OMGWTFException();
throw new UserException('Invalid block type');
}
}
......@@ -129,6 +129,7 @@ function createview4_submit(Pieform $form, $values) {
break;
case 'community':
$accessrecord->community = $item['id'];
$accessrecord->tutoronly = $item['tutoronly'];
insert_record('view_access_community', $accessrecord);
break;
}
......
......@@ -74,6 +74,7 @@ UNION
if ($extradata) {
foreach ($extradata as &$extraitem) {
$extraitem = (array)$extraitem;
$extraitem['tutoronly'] = (int)$extraitem['tutoronly'];
}
$data = array_merge($data, $extradata);
}
......@@ -186,6 +187,7 @@ function editviewaccess_submit(Pieform $form, $values) {
break;
case 'community':
$accessrecord->community = $item['id'];
$accessrecord->tutoronly = $item['tutoronly'];
insert_record('view_access_community', $accessrecord);
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