Commit e05b93ee authored by Robert Lyon's avatar Robert Lyon
Browse files

Bug 1650980: Allow filebrowser to show the size of sub folders



Allow recursive counting so that:

When in 'subfolder A' we get size of 'sub-sub folder A' and when we
are in parent of 'subfolder A' we get size of both.

behatnotneeded

Change-Id: Iea7600a7c46205fc2fe315c2c4d231cc31f83e96
Signed-off-by: default avatarRobert Lyon <robertl@catalyst.net.nz>
parent 08b6177d
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -659,6 +659,17 @@ abstract class ArtefactTypeFileBase extends ArtefactType {
                        $item->can_edit = 1;    // This will show the delete, edit buttons in filelist, but doesn't change the actual permissions in the checkbox
                    }
                }
                if ($item->artefacttype == 'folder') {
                    if ($item->childcount > 0) {
                        $foldersize = get_record_sql("SELECT SUM(aff.size) FROM {artefact} a
                                                      JOIN {artefact_file_files} aff ON aff.artefact = a.id
                                                      WHERE a.path LIKE ?", array('%/' . $item->id . '/%'));
                        $item->foldersize = ArtefactTypeFile::short_size($foldersize->sum, true);
                    }
                    else {
                        $item->foldersize = ArtefactTypeFile::short_size(0, true);
                    }
                }
            }
            $where = 'artefact IN (' . join(',', array_keys($filedata)) . ')';
            $tags = get_records_select_array('artefact_tag', $where);
+2 −1
Original line number Diff line number Diff line
@@ -230,7 +230,8 @@ function pieform_element_filebrowser_get_groupinfo($group) {
function pieform_element_filebrowser_get_path($folder) {
    $path = array();
    if ($folder) {
        $folders = ArtefactTypeFileBase::artefactchooser_folder_data(artefact_instance_from_id($folder))->data;
        $artefact = artefact_instance_from_id($folder);
        $folders = ArtefactTypeFileBase::artefactchooser_folder_data($artefact)->data;
        $f = $folder;
        while ($f) {
            $path[] = (object) array('title' => $folders[$f]->title, 'id' => $f);
+2 −2
Original line number Diff line number Diff line
@@ -99,10 +99,10 @@
            </td>

            {if $showtags && $editmeta}
            <td class="filesize">{tif $file->size ?: ''}</td>
            <td class="filesize">{if $file->foldersize}{$file->foldersize}{elseif $file->size}{$file->size}{/if}</td>
            {/if}
            {if !$showtags && !$editmeta}
            <td class="filesize">{tif $file->size ?: ''}</td>
            <td class="filesize">{if $file->foldersize}{$file->foldersize}{elseif $file->size}{$file->size}{/if}</td>
            <td class="filedate">{tif $file->mtime ?: ''}</td>
            {/if}
            {if $editmeta || $selectable}