diff options
author | Bjoern Schiessle <schiessle@owncloud.com> | 2014-03-03 17:30:16 +0100 |
---|---|---|
committer | Bjoern Schiessle <schiessle@owncloud.com> | 2014-03-25 17:47:24 +0100 |
commit | 154277ab1139c0705be2947c4c9995794c7d092b (patch) | |
tree | ec2637ee214878268e58af83a5b270b87d1a6019 /lib | |
parent | ecde48fce8b0cc580161da539b44899c406cd10d (diff) | |
download | nextcloud-server-154277ab1139c0705be2947c4c9995794c7d092b.tar.gz nextcloud-server-154277ab1139c0705be2947c4c9995794c7d092b.zip |
seperate formatResults()
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/share/share.php | 49 |
1 files changed, 31 insertions, 18 deletions
diff --git a/lib/private/share/share.php b/lib/private/share/share.php index 69d93797ba0..f6f2ac8ccf8 100644 --- a/lib/private/share/share.php +++ b/lib/private/share/share.php @@ -1217,24 +1217,7 @@ class Share extends \OC\Share\Constants { if (empty($items) && $limit == 1) { return false; } - if ($format == self::FORMAT_NONE) { - return $items; - } else if ($format == self::FORMAT_STATUSES) { - $statuses = array(); - foreach ($items as $item) { - if ($item['share_type'] == self::SHARE_TYPE_LINK) { - $statuses[$item[$column]]['link'] = true; - } else if (!isset($statuses[$item[$column]])) { - $statuses[$item[$column]]['link'] = false; - } - if ($fileDependent) { - $statuses[$item[$column]]['path'] = $item['path']; - } - } - return $statuses; - } else { - return $backend->formatItems($items, $format, $parameters); - } + return self::formatResult($items, $column, $backend, $format, $parameters); } else if ($limit == 1 || (isset($uidOwner) && isset($item))) { return false; } @@ -1597,4 +1580,34 @@ class Share extends \OC\Share\Constants { $row['stime'] = (int) $row['stime']; } } + + /** + * @brief format result + * @param array $items result + * @prams string $column is it a file share or a general share ('file_target' or 'item_target') + * @params \OCP\Share_Backend $backend sharing backend + * @param int $format + * @param array additional format parameters + * @return array formate result + */ + private static function formatResult($items, $column, $backend, $format = self::FORMAT_NONE , $parameters = null) { + if ($format === self::FORMAT_NONE) { + return $items; + } else if ($format === self::FORMAT_STATUSES) { + $statuses = array(); + foreach ($items as $item) { + if ($item['share_type'] === self::SHARE_TYPE_LINK) { + $statuses[$item[$column]]['link'] = true; + } else if (!isset($statuses[$item[$column]])) { + $statuses[$item[$column]]['link'] = false; + } + if ('file_target') { + $statuses[$item[$column]]['path'] = $item['path']; + } + } + return $statuses; + } else { + return $backend->formatItems($items, $format, $parameters); + } + } } |