aboutsummaryrefslogtreecommitdiffstats
path: root/storage-backend/lib
diff options
context:
space:
mode:
authorsteckbrief <steckbrief@chefmail.de>2018-10-21 00:11:53 +0200
committersteckbrief <steckbrief@chefmail.de>2018-10-21 00:11:53 +0200
commit4ff3b79b99a3919235295bf9ad055ec5a52c65ab (patch)
treeea8513d104c8810c4bd19359ed269b55faf785fe /storage-backend/lib
parentfbd9e9bd308bda0e6bbcb34837c761065af8074b (diff)
adds possibility to sort ascending or descending by timestamp
Diffstat (limited to 'storage-backend/lib')
-rw-r--r--storage-backend/lib/functions.filetransfer.inc.php17
1 files changed, 12 insertions, 5 deletions
diff --git a/storage-backend/lib/functions.filetransfer.inc.php b/storage-backend/lib/functions.filetransfer.inc.php
index b89ac7a..e0cf35b 100644
--- a/storage-backend/lib/functions.filetransfer.inc.php
+++ b/storage-backend/lib/functions.filetransfer.inc.php
@@ -24,14 +24,21 @@ function loadSlotParameters($slotUUID, $config) {
return $slotParameters;
}
-function listFiles($jid, $limit = -1, $offset = 0) {
+function listFiles($jid, $limit = -1, $offset = 0, $descending = false) {
// Read complete set of existing slots per jid (unsorted)
$slots = readSlots($jid, $limit, $offset);
- // Sort ascending by timestamp
- usort($slots, function($a, $b) {
- return $a['sent_time'] - $b['sent_time'];
- });
+ if ($descending) {
+ // Sort descending by timestamp
+ usort($slots, function($a, $b) {
+ return $b['sent_time'] - $a['sent_time'];
+ });
+ } else {
+ // Sort ascending by timestamp
+ usort($slots, function($a, $b) {
+ return $a['sent_time'] - $b['sent_time'];
+ });
+ }
// Select requested slot subset
$offsetCounter = 0;