Skip to content
This repository was archived by the owner on Nov 25, 2020. It is now read-only.

Commit 1c7e947

Browse files
committed
Fix various issues with shares lists, especially in My Account & Admin panels.
1 parent 372cf7e commit 1c7e947

File tree

3 files changed

+38
-31
lines changed

3 files changed

+38
-31
lines changed

core/src/plugins/action.share/class.ShareCenter.php

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,12 @@ public function switchAction($action, $httpVars, $fileVars)
656656

657657
$file = AJXP_Utils::decodeSecureMagic($httpVars["file"]);
658658
$node = new AJXP_Node($this->urlBase.$file);
659+
$loggedUser = AuthService::getLoggedUser();
660+
if(isSet($httpVars["owner"]) && $loggedUser->isAdmin()
661+
&& $loggedUser->getGroupPath() == "/" && $loggedUser->getId() != AJXP_Utils::sanitize($httpVars["owner"], AJXP_SANITIZE_EMAILCHARS)){
662+
// Impersonate the current user
663+
$node->setUser(AJXP_Utils::sanitize($httpVars["owner"], AJXP_SANITIZE_EMAILCHARS));
664+
}
659665
if(!file_exists($node->getUrl())){
660666
$mess = ConfService::getMessages();
661667
throw new Exception(str_replace('%s', "Cannot find file ".$file, $mess["share_center.219"]));
@@ -1634,7 +1640,7 @@ public function listSharesAsNodes($rootPath, $currentUser = true, $parentReposit
16341640

16351641
foreach($shares as $hash => $shareData){
16361642

1637-
$icon = "hdd_external_mount.png";
1643+
$icon = "folder";
16381644
$meta = array(
16391645
"icon" => $icon,
16401646
"openicon" => $icon,
@@ -1654,16 +1660,28 @@ public function listSharesAsNodes($rootPath, $currentUser = true, $parentReposit
16541660
continue;
16551661
}
16561662
$meta["text"] = $repoObject->getDisplay();
1657-
$meta["share_type_readable"] = $repoObject->hasContentFilter() ? "Publiclet" : ($shareType == "repository"? "Workspace": "Minisite");
1658-
if(isSet($shareData["LEGACY_REPO_OR_MINI"])){
1659-
$meta["share_type_readable"] = "Repository or Minisite (legacy)";
1663+
$permissions = $this->getRightsManager()->computeSharedRepositoryAccessRights($repoId, true, null);
1664+
$regularUsers = count(array_filter($permissions, function($a){
1665+
return (!isSet($a["HIDDEN"]) || $a["HIDDEN"] == false);
1666+
})) > 0;
1667+
$hiddenUsers = count(array_filter($permissions, function($a){
1668+
return (isSet($a["HIDDEN"]) && $a["HIDDEN"] == true);
1669+
})) > 0;
1670+
if($regularUsers && $hiddenUsers){
1671+
$meta["share_type_readable"] = "Public Link & Internal Users";
1672+
}elseif($regularUsers){
1673+
$meta["share_type_readable"] = "Internal Users";
1674+
}else if($hiddenUsers){
1675+
$meta["share_type_readable"] = "Public Link";
1676+
}else{
1677+
$meta["share_type_readable"] = $repoObject->hasContentFilter() ? "Public Link" : ($shareType == "repository"? "Internal Users": "Public Link");
1678+
if(isSet($shareData["LEGACY_REPO_OR_MINI"])){
1679+
$meta["share_type_readable"] = "Internal Only";
1680+
}
16601681
}
16611682
$meta["share_data"] = ($shareType == "repository" ? 'Shared as workspace: '.$repoObject->getDisplay() : $this->getPublicAccessManager()->buildPublicLink($hash));
16621683
$meta["shared_element_hash"] = $hash;
16631684
$meta["owner"] = $repoObject->getOwner();
1664-
if($shareType != "repository") {
1665-
$meta["copy_url"] = $this->getPublicAccessManager()->buildPublicLink($hash);
1666-
}
16671685
$meta["shared_element_parent_repository"] = $repoObject->getParentId();
16681686
if(!empty($parent)) {
16691687
$parentPath = $parent->getOption("PATH", false, $meta["owner"]);
@@ -1677,18 +1695,13 @@ public function listSharesAsNodes($rootPath, $currentUser = true, $parentReposit
16771695
$meta["shared_element_parent_repository_label"] = $repoObject->getParentId();
16781696
}
16791697
}
1680-
if($shareType != "repository"){
1681-
if($repoObject->hasContentFilter()){
1682-
$meta["ajxp_shared_minisite"] = "file";
1683-
$meta["icon"] = "mime_empty.png";
1684-
$meta["original_path"] = array_pop(array_keys($repoObject->getContentFilter()->filters));
1685-
}else{
1686-
$meta["ajxp_shared_minisite"] = "public";
1687-
$meta["icon"] = "folder.png";
1688-
$meta["original_path"] = $repoObject->getOption("PATH");
1689-
}
1690-
$meta["icon"] = $repoObject->hasContentFilter() ? "mime_empty.png" : "folder.png";
1698+
if($repoObject->hasContentFilter()){
1699+
$meta["ajxp_shared_minisite"] = "file";
1700+
$meta["icon"] = "mime_empty.png";
1701+
$meta["original_path"] = array_pop(array_keys($repoObject->getContentFilter()->filters));
16911702
}else{
1703+
$meta["ajxp_shared_minisite"] = "public";
1704+
$meta["icon"] = "folder.png";
16921705
$meta["original_path"] = $repoObject->getOption("PATH");
16931706
}
16941707
if(!empty($parentPath) && strpos($meta["original_path"], $parentPath) === 0){

core/src/plugins/action.share/class.ShareStore.php

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -348,16 +348,12 @@ public function listShares($limitToUser = '', $parentRepository = '', $cursor =
348348
}
349349
$oldRepos = ConfService::listRepositoriesWithCriteria($criteria, $count);
350350
foreach($oldRepos as $sharedWorkspace){
351-
if(!$sharedWorkspace->hasContentFilter()){
352-
$dbLets['repo-'.$sharedWorkspace->getId()] = array(
353-
"SHARE_TYPE" => "repository",
354-
"OWNER_ID" => $sharedWorkspace->getOwner(),
355-
"REPOSITORY" => $sharedWorkspace->getUniqueId(),
356-
"LEGACY_REPO_OR_MINI" => true
357-
);
358-
//Auto Migrate? boaf.
359-
//$this->storeShare($sharedWorkspace->getParentId(), $data, "repository");
360-
}
351+
$dbLets['repo-'.$sharedWorkspace->getId()] = array(
352+
"SHARE_TYPE" => "repository",
353+
"OWNER_ID" => $sharedWorkspace->getOwner(),
354+
"REPOSITORY" => $sharedWorkspace->getUniqueId(),
355+
"LEGACY_REPO_OR_MINI" => true
356+
);
361357
}
362358
}
363359

core/src/plugins/action.share/res/react/model/ShareModel.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -758,13 +758,11 @@
758758
merged : 'true'
759759
};
760760
if(meta.get('shared_element_hash')){
761-
//options["hash"] = meta.get('shared_element_hash');
762-
//options["element_type"] = meta.get('share_type');
763761
options["tmp_repository_id"] = meta.get('shared_element_parent_repository');
764762
options["file"] = meta.get("original_path");
763+
options["owner"] = meta.get("owner");
765764
}else{
766765
options["file"] = node.getPath();
767-
//options["element_type"] = node.isLeaf() ? "file" : meta.get("ajxp_shared_minisite")? "minisite" : "repository";
768766
}
769767
PydioApi.getClient().request(options, completeCallback, errorCallback, settings);
770768
}

0 commit comments

Comments
 (0)