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