summaryrefslogtreecommitdiffstats
path: root/apps/files/lib
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2014-11-18 18:53:45 +0100
committerVincent Petry <pvince81@owncloud.com>2014-12-15 12:10:54 +0100
commita5bb66f4a723bce5c5fbe919a48cd5133204ef62 (patch)
treeb2e067bde8aaa1de6973adc7760fafb1e37e9084 /apps/files/lib
parentc6be491a89a4eebe15bcb20f6e0b01f23a093761 (diff)
downloadnextcloud-server-a5bb66f4a723bce5c5fbe919a48cd5133204ef62.tar.gz
nextcloud-server-a5bb66f4a723bce5c5fbe919a48cd5133204ef62.zip
Added favorites feature to the files app
Diffstat (limited to 'apps/files/lib')
-rw-r--r--apps/files/lib/helper.php25
1 files changed, 25 insertions, 0 deletions
diff --git a/apps/files/lib/helper.php b/apps/files/lib/helper.php
index 97b9d8e7044..7adca3ffa6d 100644
--- a/apps/files/lib/helper.php
+++ b/apps/files/lib/helper.php
@@ -122,6 +122,9 @@ class Helper
$entry['size'] = $i['size'];
$entry['type'] = $i['type'];
$entry['etag'] = $i['etag'];
+ if (isset($i['tags'])) {
+ $entry['tags'] = $i['tags'];
+ }
if (isset($i['displayname_owner'])) {
$entry['shareOwner'] = $i['displayname_owner'];
}
@@ -171,11 +174,33 @@ class Helper
*/
public static function getFiles($dir, $sortAttribute = 'name', $sortDescending = false) {
$content = \OC\Files\Filesystem::getDirectoryContent($dir);
+ $content = self::populateTags($content);
return self::sortFiles($content, $sortAttribute, $sortDescending);
}
/**
+ * Populate the result set with file tags
+ *
+ * @param array file list
+ * @return file list populated with tags
+ */
+ public static function populateTags($fileList) {
+ $filesById = array();
+ foreach ($fileList as $fileData) {
+ $filesById[$fileData['fileid']] = $fileData;
+ }
+ $tagger = \OC::$server->getTagManager()->load('files');
+ $tags = $tagger->getTagsForObjects(array_keys($filesById));
+ if ($tags) {
+ foreach ($tags as $fileId => $fileTags) {
+ $filesById[$fileId]['tags'] = $fileTags;
+ }
+ }
+ return $fileList;
+ }
+
+ /**
* Sort the given file info array
*
* @param \OCP\Files\FileInfo[] $files files to sort