Skip to content

Commit

Permalink
[Patch] Fixing share placeholder info
Browse files Browse the repository at this point in the history
- Fix for All files
- Fix for Shared with others
  • Loading branch information
NadirRoGue committed Apr 18, 2016
1 parent 624ea1e commit 6c9900f
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 4 deletions.
41 changes: 40 additions & 1 deletion apps/files/ajax/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,47 @@
}

$files = \OCA\Files\Helper::populateTags($files);
$formattedFiles = \OCA\Files\Helper::formatFileInfos($files);

$userId = \OC::$server->getUserSession()->getUser()->getUID();
if($userId && $userId != '')
{
$shared = \OC_DB::prepare('SELECT item_type, share_type, file_target FROM oc_share WHERE uid_owner = ?')
->execute([$userId])
->fetchAll();

$finalShared = [];
foreach($shared as $share)
{
$name = ltrim($share['file_target'], '/');
if($share['item_type'] === 'folder' && $share['share_type'] !== 3)
{
$pos = strrpos($name, ' ');
$name = substr($name, 0, $pos);
}
else if($share['item_type'] === 'file')
{
$name = ltrim($name, '.sys.v#.');
}

if(!isset($finalShared[$name]) || (isset($finalShared[$name]) && $finalShared[$name] !== 3))
{
$finalShared[$name] = $share['share_type'];
}
}

foreach($formattedFiles as $key => $file)
{
if(isset($finalShared[$file['name']]))
{
$file['share_type'] = $finalShared[$file['name']];
$formattedFiles[$key] = $file; // faster than foreach($formattedFiles as &$file)
}
}
}

$data['directory'] = $dir;
$data['files'] = \OCA\Files\Helper::formatFileInfos($files);
$data['files'] = $formattedFiles;
$data['permissions'] = $permissions;

OCP\JSON::success(array('data' => $data));
Expand Down
27 changes: 27 additions & 0 deletions apps/files/js/filelist.js
Original file line number Diff line number Diff line change
Expand Up @@ -1217,6 +1217,33 @@
iconDiv.css('background-image', 'url("' + previewUrl + '")');
}
}

var share_type = fileData.share_type || -1;
share_type = parseInt(share_type);

if(share_type != -1)
{
var icon = '';
var aLink = tr.find('a.action-share');
aLink.addClass('shared-style');
var img = aLink.find('img').first();
var span = $('<span></span>');
span.text(' Shared');

switch(share_type)
{
case 0:
case 1:
icon = 'shared';
break;
case 3:
icon = 'public';
break;
}
img.attr('src', OC.imagePath('core', 'actions/' + icon));
aLink.append(span);
}

return tr;
},
/**
Expand Down
2 changes: 1 addition & 1 deletion apps/files_sharing/js/share.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
if (fileData.shareOwner) {
tr.attr('data-share-owner', fileData.shareOwner);
/** CERNBOX SHOW DISPLAYNAME PULL REQUEST PATCH */
//tr.attr('data-share-owner-displayname', fileData.ownerDisplayName);
tr.attr('data-share-owner-displayname', fileData.displayname_owner);
// user should always be able to rename a mount point
if (fileData.isShareMountPoint) {
tr.attr('data-permissions', fileData.permissions | OC.PERMISSION_UPDATE);
Expand Down
17 changes: 15 additions & 2 deletions apps/files_sharing/js/sharedfilelist.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
OC.Plugins.attach('OCA.Sharing.FileList', this);
},

_renderRow: function() {
_renderRow: function(fileData) {
// HACK: needed to call the overridden _renderRow
// this is because at the time this class is created
// the overriding hasn't been done yet...
Expand Down Expand Up @@ -128,7 +128,7 @@
// no op because it doesn't have
// storage info like free space / used space
},

reload: function() {
this.showMask();
if (this._reloadCall) {
Expand Down Expand Up @@ -196,6 +196,19 @@
}

this.setFiles(files);

this.$fileList.children().each(function(i)
{
var sharees = $(this).attr('data-share-recipients');
if(typeof sharees == 'undefined')
{
OC.Share.markFileAsShared($(this), true, true);
}
else
{
OC.Share.markFileAsShared($(this), true, false);
}
});
},

_makeFilesFromRemoteShares: function(data) {
Expand Down
5 changes: 5 additions & 0 deletions core/js/cernboxtabview.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
(function()
{
if(!OCA.Files)
{
return;
}

if(!OC.Cernbox)
{
OC.Cernbox = {};
Expand Down

0 comments on commit 6c9900f

Please sign in to comment.