Skip to content

Commit

Permalink
Merge pull request #2 from cernbox/cernbox-develop-8.2.2-pull-requests
Browse files Browse the repository at this point in the history
Cernbox develop 8.2.2 pull requests
  • Loading branch information
NadirRoGue committed Mar 30, 2016
2 parents d60d903 + 8251444 commit cdd1613
Show file tree
Hide file tree
Showing 93 changed files with 9,994 additions and 3,214 deletions.
13 changes: 13 additions & 0 deletions apps/files/js/fileactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,19 @@
* @param {OCA.Files.FileActionContext} context rendering context
*/
_renderInlineAction: function(actionSpec, isDefault, context) {
/** CERNBOX SHARE PLUGIN PATCH */
// HUGO here we control which actions to show or not
var mountType = context.$file.attr('data-mounttype');
if(mountType === "shared-root" && actionSpec.name === 'Delete') {
return; // HUGO hide Unshare button on Shared with me
}
if(mountType === "shared-root" && actionSpec.name === "Rename") {
return; // HUGO hide rename button on Shared with me
}
if(mountType === "shared" && actionSpec.name === "Versions") {
return; // HUGO hide versions button in files under Shared with me
}

var renderFunc = actionSpec.render || _.bind(this._defaultRenderAction, this);
var $actionEl = renderFunc(actionSpec, isDefault, context);
if (!$actionEl || !$actionEl.length) {
Expand Down
11 changes: 7 additions & 4 deletions apps/files/js/filelist.js
Original file line number Diff line number Diff line change
Expand Up @@ -764,14 +764,15 @@
elementToFile: function($el){
$el = $($el);
var data = {
id: parseInt($el.attr('data-id'), 10),
id: /*parseInt(*/$el.attr('data-id'),/* 10),*/ // CERNBOX FIX BIG FILE IDs THAT WONT FIT ON JAVASCRIPT INT
name: $el.attr('data-file'),
mimetype: $el.attr('data-mime'),
mtime: parseInt($el.attr('data-mtime'), 10),
type: $el.attr('data-type'),
size: parseInt($el.attr('data-size'), 10),
etag: $el.attr('data-etag'),
permissions: parseInt($el.attr('data-permissions'), 10)
permissions: parseInt($el.attr('data-permissions'), 10),
eospath: $el.attr('data-eospath')
};
var icon = $el.attr('data-icon');
if (icon) {
Expand Down Expand Up @@ -864,7 +865,7 @@
*/
setFiles: function(filesArray) {
var self = this;

// detach to make adding multiple rows faster
this.files = filesArray;

Expand Down Expand Up @@ -905,6 +906,7 @@
mime = fileData.mimetype,
path = fileData.path,
dataIcon = null,
eospath = fileData.eospath,
linkUrl;
options = options || {};

Expand All @@ -930,7 +932,8 @@
"data-mime": mime,
"data-mtime": mtime,
"data-etag": fileData.etag,
"data-permissions": fileData.permissions || this.getDirectoryPermissions()
"data-permissions": fileData.permissions || this.getDirectoryPermissions(),
"data-eospath": eospath
});

if (dataIcon) {
Expand Down
21 changes: 20 additions & 1 deletion apps/files/lib/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,16 @@ public static function formatFileInfo(FileInfo $i) {
if (isset($i['extraData'])) {
$entry['extraData'] = $i['extraData'];
}

/** CERNBOX FAVORITES PATCH */
// HUGO allow eos attrs to be passed to the web frontend
if(isset($i['cboxid']))
{
$entry['cboxid'] = $i['cboxid'];
}

$entry['eospath'] = $i['eospath'];

return $entry;
}

Expand Down Expand Up @@ -216,7 +226,16 @@ public static function getFiles($dir, $sortAttribute = 'name', $sortDescending =
public static function populateTags(array $fileList) {
$filesById = array();
foreach ($fileList as $fileData) {
$filesById[$fileData['fileid']] = $fileData;
/** CERNBOX FAVORITES PATCH */
//$filesById[$fileData['fileid']] = $fileData;
if(isset($fileData['cboxid']))
{
$filesById[$fileData['cboxid']] = $fileData;
}
else
{
$filesById[$fileData['fileid']] = $fileData;
}
}
$tagger = \OC::$server->getTagManager()->load('files');
$tags = $tagger->getTagsForObjects(array_keys($filesById));
Expand Down
48 changes: 45 additions & 3 deletions apps/files/service/tagservice.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,24 @@ public function __construct(
* @throws \OCP\Files\NotFoundException if the file does not exist
*/
public function updateFileTags($path, $tags) {
$fileId = $this->homeFolder->get($path)->getId();

/** CERNBOX FAVORITES PATCH */
//$fileId = $this->homeFolder->get($path)->getId();
$fileInfo = $this->homeFolder->get($path)->getFileInfo();
$versionFolderInfo = null;

if($fileInfo['type'] === 'file') {
$versionFolder = dirname($path) . "/" . ".sys.v#." . basename($path);
try {
$versionFolderInfo = $this->homeFolder->get($versionFolder)->getFileInfo();
} catch (\OCP\Files\NotFoundException $e) {
EosUtil::createVersion($fileInfo['eospath']);
$versionFolderInfo = $this->homeFolder->get($versionFolder)->getFileInfo();
}
}

$fileId = $fileInfo['type'] === 'file' ? $versionFolderInfo['fileid'] : $fileInfo['fileid'];
/** END OF CERNBOX FAVORITES PATCH */

$currentTags = $this->tagger->getTagsForObjects(array($fileId));

if (!empty($currentTags)) {
Expand Down Expand Up @@ -110,7 +126,33 @@ public function getFilesByTag($tagName) {
$fileInfos[] = $node->getFileInfo();
}
}
return $fileInfos;
/** CERNBOX FAVORITES PATCH */
//return $fileInfos;
// HUGO do here the trick of pointing to versions folder for files tagge
$fileInfosConverted = array();
foreach($fileInfos as $info) {
if($info['type'] === 'file') {
\OCP\Util::writeLog('TAG', $info['eospath'] . " must point to its sys folder. This should have been done is creating the FAV", \OCP\Util::ERROR);
} else {
$basename = basename($info['path']);
$dirname = dirname($info['path']);
if(strpos($basename, '.sys.v#.') !== false) {
\OCP\Util::writeLog('TAG', $info['eospath'] . " is a versions folder, we need to gave the user the real file", \OCP\Util::ERROR);
$filename = $basename;
$filepath = substr($dirname, 6) . "/" . substr($filename, 8);
\OCP\Util::writeLog('TAG', $filepath, \OCP\Util::ERROR);

$newInfo = $node = $this->homeFolder->get($filepath)->getFileInfo();
\OCP\Util::writeLog('TAG', $newInfo['eospath'], \OCP\Util::ERROR);
$fileInfosConverted[] = $newInfo;

} else {
$fileInfosConverted[] = $info;
}

}
}
return $fileInfosConverted;
}
}

Loading

0 comments on commit cdd1613

Please sign in to comment.