Permalink
Browse files

New AJXP_PARENT_OPTION:PAREMETER_NAME: variable in options.

  • Loading branch information...
1 parent 4db6214 commit fe73a1a660bcb9b7f4d306499f18dde2aa3c681f @cdujeu cdujeu committed Jun 24, 2016
@@ -22,6 +22,7 @@
use Pydio\Core\Controller\Controller;
use Pydio\Core\Exception\PydioException;
+use Pydio\Core\Model\Context;
use Pydio\Core\Model\ContextInterface;
use Pydio\Core\Services;
@@ -53,7 +54,7 @@ public static function filter($value, ContextInterface $ctx)
if (is_string($value) && strpos($value, "AJXP_USER")!==false) {
if (UsersService::usersEnabled()) {
if(!$ctx->hasUser()){
- throw new PydioException("Cannot resolve path AJXP_USER without user passed in context");
+ throw new PydioException("Cannot resolve AJXP_USER without user passed in context");
}
$value = str_replace("AJXP_USER", $ctx->getUser()->getId(), $value);
} else {
@@ -84,6 +85,18 @@ public static function filter($value, ContextInterface $ctx)
if (is_string($value) && strstr($value, "AJXP_WORKSPACE_SLUG") !== false) {
$value = rtrim(str_replace("AJXP_WORKSPACE_SLUG", $ctx->getRepository()->getSlug(), $value), "/");
}
+ if(is_string($value) && preg_match("/AJXP_PARENT_OPTION:([\w_-]*):/", $value, $matches)){
+ $repoObject = $ctx->getRepository();
+ $parentRepository = $repoObject->getParentRepository();
+ if(empty($parentRepository)){
+ throw new PydioException("Cannot resolve ".$matches[0]." without parent workspace");
+ }
+ $parentOwner = $ctx->getRepository()->getOwner();
+ $parentContext = Context::contextWithObjects(null, $parentRepository);
+ $parentContext->setUserId($parentOwner);
+ $parentPath = rtrim($parentRepository->getContextOption($parentContext, $matches[1]), "/");
+ $value = str_replace($matches[0], $parentPath, $value);
+ }
$tab = array(&$value, $ctx);
Controller::applyIncludeHook("vars.filter", $tab);
@@ -2320,7 +2320,7 @@ public function makeSharedRepositoryOptions(ContextInterface $ctx, $httpVars)
{
$repository = $ctx->getRepository();
$newOptions = [
- "PATH" => TextEncoder::toStorageEncoding($repository->getContextOption($ctx, "PATH")).Utils::decodeSecureMagic($httpVars["file"]),
+ "PATH" => "AJXP_PARENT_OPTION:PATH:".Utils::decodeSecureMagic($httpVars["file"]),
"CREATE" => $repository->getContextOption($ctx, "CREATE"),
"RECYCLE_BIN" => isSet($httpVars["inherit_recycle"])? $repository->getContextOption($ctx, "RECYCLE_BIN") : "",
"DEFAULT_RIGHTS" => "",
@@ -201,7 +201,7 @@ public function loadNodeInfo(&$node, $parentNode = false, $details = false)
public function makeSharedRepositoryOptions(ContextInterface $ctx, $httpVars)
{
$newOptions = parent::makeSharedRepositoryOptions($ctx, $httpVars);
- $newOptions["CONTAINER"] = $ctx->getRepository()->getContextOption($ctx, "CONTAINER");
+ $newOptions["CONTAINER"] = "AJXP_PARENT_OPTION:CONTAINER"; //$ctx->getRepository()->getContextOption($ctx, "CONTAINER");
return $newOptions;
}
@@ -1883,6 +1883,7 @@ public function listSharesAsNodes(ContextInterface $ctx, $rootPath, $currentUser
}else{
$meta["ajxp_shared_minisite"] = "public";
$meta["icon"] = "folder.png";
+ $ctx = $ctx->withRepositoryId($repoObject->getId());
$meta["original_path"] = $repoObject->getContextOption($ctx, "PATH");
}
if(!empty($parentPath) && strpos($meta["original_path"], $parentPath) === 0){

0 comments on commit fe73a1a

Please sign in to comment.