Commit 52ab75a7 authored by Marcelo Ortega's avatar Marcelo Ortega Committed by Aaron Wells

Bug #1298144 Don't show "Download as zip file" link when not needed

When:

1) The folder is empty
2) When the folder only contains folders that are also empty

behatnotneeded

Change-Id: I7e86a3ff051ff9d46a4b68e763574abfe0c6b14d
parent 2df2012e
......@@ -158,7 +158,14 @@ function pieform_element_filebrowser(Pieform $form, $element) {
$filters = isset($element['filters']) ? $element['filters'] : null;
$filedata = ArtefactTypeFileBase::get_my_files_data($folder, $userid, $group, $institution, $filters);
$smarty->assign('filelist', $filedata);
// Only allow 'Download folder content as zip' link if theres some kind of content (file or subfolder with content)
$addzipdownloadlink = false;
foreach ($filedata as $k => $v) {
if (empty($v->isparent) && ($v->artefacttype != 'folder' || ($v->artefacttype == 'folder' && !empty($v->childcount)))) {
$addzipdownloadlink = true;
}
}
$smarty->assign('downloadfolderaszip', $addzipdownloadlink);
$configstr = json_encode($config);
$fileliststr = json_encode($filedata);
......@@ -311,6 +318,14 @@ function pieform_element_filebrowser_build_filelist($form, $element, $folder, $h
$filters = isset($element['filters']) ? $element['filters'] : null;
$filedata = ArtefactTypeFileBase::get_my_files_data($folder, $userid, $group, $institution, $filters);
// Only allow 'Download folder content as zip' link if theres some kind of content (file or subfolder with content)
$addzipdownloadlink = false;
foreach ($filedata as $k => $v) {
if (empty($v->isparent) && ($v->artefacttype != 'folder' || ($v->artefacttype == 'folder' && !empty($v->childcount)))) {
$addzipdownloadlink = true;
}
}
$smarty->assign('downloadfolderaszip', $addzipdownloadlink);
$switchwidth = ArtefactTypeFileBase::get_switch_width();
......
......@@ -177,7 +177,7 @@
</tbody>
</table>
</div>
{if !$selectable}
{if !$selectable && $downloadfolderaszip}
<a id="downloadfolder" class="panel-footer text-small" href="{$WWWROOT}artefact/file/downloadfolder.php?{$folderparams|safe}">
<span class="icon icon-download" role="presentation" aria-hidden="true"></span>
<span>{str tag=downloadfolderziplink section=artefact.file}</span>
......
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