Commit 303986c7 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Fix permissions checkboxes on group files

parent 0ab399cb
......@@ -41,15 +41,7 @@ function pieform_element_filebrowser(Pieform $form, $element) {
$userid = ($group || $institution) ? null : $USER->get('id');
if ($group) {
$groupinfo = array(
'roles' => group_get_role_info($group),
'perms' => group_get_default_artefact_permissions($group),
'perm' => array(),
);
foreach (current($groupinfo['perms']) as $k => $v) {
$groupinfo['perm'][$k] = get_string($k);
}
$smarty->assign('groupinfo', $groupinfo);
$smarty->assign('groupinfo', pieform_element_filebrowser_get_groupinfo($group));
}
$folder = $element['folder'];
......@@ -103,6 +95,20 @@ function pieform_element_filebrowser(Pieform $form, $element) {
return $smarty->fetch('artefact:file:form/filebrowser.tpl');
}
function pieform_element_filebrowser_get_groupinfo($group) {
$groupinfo = array(
'roles' => group_get_role_info($group),
'perms' => group_get_default_artefact_permissions($group),
'perm' => array(),
);
foreach (current($groupinfo['perms']) as $k => $v) {
$groupinfo['perm'][$k] = get_string($k);
}
return $groupinfo;
}
function pieform_element_filebrowser_get_path($folder) {
$path = array();
if ($folder) {
......
......@@ -102,7 +102,6 @@ function FileBrowser(idprefix, folderid, config, globalconfig) {
}
this.fileexists = function (filename, id) {
logDebug(id);
for (var i in self.filedata) {
if (self.filedata[i].title == filename && (!id || i != id)) {
return true;
......@@ -183,7 +182,7 @@ function FileBrowser(idprefix, folderid, config, globalconfig) {
replaceChildNodes($(self.id + '_edit_messages'));
forEach(getElementsByTagAndClassName('input', 'permission', self.id + '_edit_row'), function (elem) {
var perm = getNodeAttribute(elem, 'name').split(':');
if (self.filedata[id].permissions[perm[1]][perm[2]] == 1) {
if (self.filedata[id].permissions[perm[1]] && self.filedata[id].permissions[perm[1]][perm[2]] == 1) {
elem.checked = true;
}
});
......
......@@ -30,7 +30,7 @@
</div>
</td>
</tr>
{if $group}
{if $groupinfo}
<tr>
<th><label>{str tag=Permissions}</label></th>
<td>
......
......@@ -77,14 +77,14 @@
</div>
<div id="{$prefix}_filelist_container">
{include file="artefact:file:form/filelist.tpl" prefix=$prefix filelist=$filelist editable=$config.edit selectable=$config.select highlight=$highlight edit=$edit querybase=$querybase}
{include file="artefact:file:form/filelist.tpl" prefix=$prefix filelist=$filelist editable=$config.edit selectable=$config.select highlight=$highlight edit=$edit querybase=$querybase groupinfo=$groupinfo}
</div>
{* Edit form used when js is available *}
{if $edit <= 0}
<table class="hidden">
<tbody id="{$prefix}_edit_placeholder">
{include file="artefact:file:form/editfile.tpl" prefix=$prefix}
{include file="artefact:file:form/editfile.tpl" prefix=$prefix groupinfo=$groupinfo}
</tbody>
</table>
{/if}
......
......@@ -45,7 +45,7 @@
</td>
</tr>
{if $edit == $file->id}
{include file="artefact:file:form/editfile.tpl" prefix=$prefix fileinfo=$file}
{include file="artefact:file:form/editfile.tpl" prefix=$prefix fileinfo=$file groupinfo=$groupinfo}
{/if}
{/foreach}
</tbody>
......
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