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

Commit

Permalink
Fix various issues with shares lists, especially in My Account & Admi…
Browse files Browse the repository at this point in the history
…n panels.
  • Loading branch information
cdujeu committed Apr 7, 2016
1 parent 372cf7e commit 1c7e947
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 31 deletions.
49 changes: 31 additions & 18 deletions core/src/plugins/action.share/class.ShareCenter.php
Expand Up @@ -656,6 +656,12 @@ public function switchAction($action, $httpVars, $fileVars)

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

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

$icon = "hdd_external_mount.png";
$icon = "folder";
$meta = array(
"icon" => $icon,
"openicon" => $icon,
Expand All @@ -1654,16 +1660,28 @@ public function listSharesAsNodes($rootPath, $currentUser = true, $parentReposit
continue;
}
$meta["text"] = $repoObject->getDisplay();
$meta["share_type_readable"] = $repoObject->hasContentFilter() ? "Publiclet" : ($shareType == "repository"? "Workspace": "Minisite");
if(isSet($shareData["LEGACY_REPO_OR_MINI"])){
$meta["share_type_readable"] = "Repository or Minisite (legacy)";
$permissions = $this->getRightsManager()->computeSharedRepositoryAccessRights($repoId, true, null);
$regularUsers = count(array_filter($permissions, function($a){
return (!isSet($a["HIDDEN"]) || $a["HIDDEN"] == false);
})) > 0;
$hiddenUsers = count(array_filter($permissions, function($a){
return (isSet($a["HIDDEN"]) && $a["HIDDEN"] == true);
})) > 0;
if($regularUsers && $hiddenUsers){
$meta["share_type_readable"] = "Public Link & Internal Users";
}elseif($regularUsers){
$meta["share_type_readable"] = "Internal Users";
}else if($hiddenUsers){
$meta["share_type_readable"] = "Public Link";
}else{
$meta["share_type_readable"] = $repoObject->hasContentFilter() ? "Public Link" : ($shareType == "repository"? "Internal Users": "Public Link");
if(isSet($shareData["LEGACY_REPO_OR_MINI"])){
$meta["share_type_readable"] = "Internal Only";
}
}
$meta["share_data"] = ($shareType == "repository" ? 'Shared as workspace: '.$repoObject->getDisplay() : $this->getPublicAccessManager()->buildPublicLink($hash));
$meta["shared_element_hash"] = $hash;
$meta["owner"] = $repoObject->getOwner();
if($shareType != "repository") {
$meta["copy_url"] = $this->getPublicAccessManager()->buildPublicLink($hash);
}
$meta["shared_element_parent_repository"] = $repoObject->getParentId();
if(!empty($parent)) {
$parentPath = $parent->getOption("PATH", false, $meta["owner"]);
Expand All @@ -1677,18 +1695,13 @@ public function listSharesAsNodes($rootPath, $currentUser = true, $parentReposit
$meta["shared_element_parent_repository_label"] = $repoObject->getParentId();
}
}
if($shareType != "repository"){
if($repoObject->hasContentFilter()){
$meta["ajxp_shared_minisite"] = "file";
$meta["icon"] = "mime_empty.png";
$meta["original_path"] = array_pop(array_keys($repoObject->getContentFilter()->filters));
}else{
$meta["ajxp_shared_minisite"] = "public";
$meta["icon"] = "folder.png";
$meta["original_path"] = $repoObject->getOption("PATH");
}
$meta["icon"] = $repoObject->hasContentFilter() ? "mime_empty.png" : "folder.png";
if($repoObject->hasContentFilter()){
$meta["ajxp_shared_minisite"] = "file";
$meta["icon"] = "mime_empty.png";
$meta["original_path"] = array_pop(array_keys($repoObject->getContentFilter()->filters));
}else{
$meta["ajxp_shared_minisite"] = "public";
$meta["icon"] = "folder.png";
$meta["original_path"] = $repoObject->getOption("PATH");
}
if(!empty($parentPath) && strpos($meta["original_path"], $parentPath) === 0){
Expand Down
16 changes: 6 additions & 10 deletions core/src/plugins/action.share/class.ShareStore.php
Expand Up @@ -348,16 +348,12 @@ public function listShares($limitToUser = '', $parentRepository = '', $cursor =
}
$oldRepos = ConfService::listRepositoriesWithCriteria($criteria, $count);
foreach($oldRepos as $sharedWorkspace){
if(!$sharedWorkspace->hasContentFilter()){
$dbLets['repo-'.$sharedWorkspace->getId()] = array(
"SHARE_TYPE" => "repository",
"OWNER_ID" => $sharedWorkspace->getOwner(),
"REPOSITORY" => $sharedWorkspace->getUniqueId(),
"LEGACY_REPO_OR_MINI" => true
);
//Auto Migrate? boaf.
//$this->storeShare($sharedWorkspace->getParentId(), $data, "repository");
}
$dbLets['repo-'.$sharedWorkspace->getId()] = array(
"SHARE_TYPE" => "repository",
"OWNER_ID" => $sharedWorkspace->getOwner(),
"REPOSITORY" => $sharedWorkspace->getUniqueId(),
"LEGACY_REPO_OR_MINI" => true
);
}
}

Expand Down
4 changes: 1 addition & 3 deletions core/src/plugins/action.share/res/react/model/ShareModel.js
Expand Up @@ -758,13 +758,11 @@
merged : 'true'
};
if(meta.get('shared_element_hash')){
//options["hash"] = meta.get('shared_element_hash');
//options["element_type"] = meta.get('share_type');
options["tmp_repository_id"] = meta.get('shared_element_parent_repository');
options["file"] = meta.get("original_path");
options["owner"] = meta.get("owner");
}else{
options["file"] = node.getPath();
//options["element_type"] = node.isLeaf() ? "file" : meta.get("ajxp_shared_minisite")? "minisite" : "repository";
}
PydioApi.getClient().request(options, completeCallback, errorCallback, settings);
}
Expand Down

0 comments on commit 1c7e947

Please sign in to comment.