summaryrefslogtreecommitdiffstats
path: root/apps/files
diff options
context:
space:
mode:
authorMichael Jobst <mjobst+github@tecratech.de>2016-11-10 09:13:25 +0100
committerMorris Jobke <hey@morrisjobke.de>2017-04-11 11:54:13 -0500
commit81b1dc4930204ca7210b595e631a4c4ce46fb79d (patch)
tree77e867b192923d51b054f529e0ab5e4a1623d204 /apps/files
parent45a6e376995a3ef6618b12ee65e6f903e846b1a5 (diff)
downloadnextcloud-server-81b1dc4930204ca7210b595e631a4c4ce46fb79d.tar.gz
nextcloud-server-81b1dc4930204ca7210b595e631a4c4ce46fb79d.zip
share api expanded by tags (#26583)
* share api expanded by tags * Modified files_sharing JS Unit tests * modified tests. renamed request parameter. refactoring * Update Share20OCS.php Added missing function description * Update Helper.php Added missing function description * Update Helper.php implicit boolean conversion to !empty() * Update Share20OCSTest.php Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Diffstat (limited to 'apps/files')
-rw-r--r--apps/files/ajax/list.php1
-rw-r--r--apps/files/js/tagsplugin.js7
-rw-r--r--apps/files/lib/Helper.php29
3 files changed, 30 insertions, 7 deletions
diff --git a/apps/files/ajax/list.php b/apps/files/ajax/list.php
index 2cd09765435..d91db8744c4 100644
--- a/apps/files/ajax/list.php
+++ b/apps/files/ajax/list.php
@@ -71,7 +71,6 @@ try {
$files = \OCA\Files\Helper::getFiles($dir, $sortAttribute, $sortDirection);
}
- $files = \OCA\Files\Helper::populateTags($files);
$data['directory'] = $dir;
$data['files'] = \OCA\Files\Helper::formatFileInfos($files);
$data['permissions'] = $permissions;
diff --git a/apps/files/js/tagsplugin.js b/apps/files/js/tagsplugin.js
index 67bd9c667c8..9bd20be4bf8 100644
--- a/apps/files/js/tagsplugin.js
+++ b/apps/files/js/tagsplugin.js
@@ -75,7 +75,11 @@
allowedLists: [
'files',
- 'favorites'
+ 'favorites',
+ 'systemtags',
+ 'shares.self',
+ 'shares.others',
+ 'shares.link'
],
_extendFileActions: function(fileActions) {
@@ -241,4 +245,3 @@
})(OCA);
OC.Plugins.register('OCA.Files.FileList', OCA.Files.TagsPlugin);
-
diff --git a/apps/files/lib/Helper.php b/apps/files/lib/Helper.php
index b6b209dea70..c3d80957913 100644
--- a/apps/files/lib/Helper.php
+++ b/apps/files/lib/Helper.php
@@ -208,19 +208,40 @@ class Helper {
* Populate the result set with file tags
*
* @param array $fileList
+ * @param string $fileIdentifier identifier attribute name for values in $fileList
* @return array file list populated with tags
*/
- public static function populateTags(array $fileList) {
- $filesById = array();
+ public static function populateTags(array $fileList, $fileIdentifier = 'fileid') {
+ $filesById = [];
foreach ($fileList as $fileData) {
- $filesById[$fileData['fileid']] = $fileData;
+ $filesById[$fileData[$fileIdentifier]] = $fileData;
}
$tagger = \OC::$server->getTagManager()->load('files');
$tags = $tagger->getTagsForObjects(array_keys($filesById));
- if ($tags) {
+
+ if (!is_array($tags)) {
+ throw new \UnexpectedValueException('$tags must be an array');
+ }
+
+ if (!empty($tags)) {
foreach ($tags as $fileId => $fileTags) {
$filesById[$fileId]['tags'] = $fileTags;
}
+
+ foreach ($filesById as $key => $fileWithTags) {
+ foreach($fileList as $key2 => $file){
+ if( $file[$fileIdentifier] == $key){
+ $fileList[$key2] = $fileWithTags;
+ }
+ }
+ }
+
+ foreach ($fileList as $key => $file) {
+ if (!array_key_exists('tags', $file)) {
+ $fileList[$key]['tags'] = [];
+ }
+ }
+
}
return $fileList;
}