Permalink
Browse files

Fixes, again

  • Loading branch information...
1 parent d044c0c commit 38371318a3f010732f1472f81112c82ce7674cbe @cdujeu cdujeu committed Jun 9, 2016
@@ -186,7 +186,7 @@ public static function findPluginById($id)
public static function getInstance($ctx = null)
{
if(empty($ctx)){
- $ctx = Context::fromGlobalServices();
+ $ctx = Context::emptyContext();
}
$identifier = $ctx->getStringIdentifier();
if (!isSet(self::$instances[$identifier])) {
@@ -1133,8 +1133,7 @@ public function switchAction($action, $httpVars, $fileVars, ContextInterface $ct
case "user_update_group":
- $userSelection = new UserSelection();
- $userSelection->initFromHttpVars($httpVars);
+ $userSelection = UserSelection::fromContext($ctx, $httpVars);
$dir = $httpVars["dir"];
$dest = $httpVars["dest"];
if (isSet($httpVars["group_path"])) {
@@ -1268,8 +1267,7 @@ public function switchAction($action, $httpVars, $fileVars, ContextInterface $ct
case "user_update_role" :
$confStorage = ConfService::getConfStorageImpl();
- $selection = new UserSelection();
- $selection->initFromHttpVars($httpVars);
+ $selection = UserSelection::fromContext($ctx, $httpVars);
$files = $selection->getFiles();
$detectedRoles = array();
$roleId = null;
@@ -140,11 +140,11 @@ public function switchAction(ServerRequestInterface $requestInterface, ResponseI
case "delete" :
- $mime = $httpVars["ajxp_mime"];
- $selection = new UserSelection();
- $selection->initFromHttpVars($httpVars);
- $files = $selection->getFiles();
- $minisites = $this->listMinisites($ctx);
+ $mime = $httpVars["ajxp_mime"];
+ $selection = UserSelection::fromContext($ctx, $httpVars);
+ $files = $selection->getFiles();
+ $minisites = $this->listMinisites($ctx);
+
/**
* @var ShareCenter $shareCenter
*/
@@ -312,8 +312,7 @@ public function createResourceAction(ServerRequestInterface &$request, ResponseI
/** @var ContextInterface $ctx */
$ctx = $request->getAttribute("ctx");
- $selection = new UserSelection($ctx->getRepository());
- $selection->initFromHttpVars($request->getParsedBody());
+ $selection = UserSelection::fromContext($ctx, $request->getParsedBody());
if($selection->isEmpty()){
throw new PydioException("Empty resource");
}
@@ -85,8 +85,7 @@ public function switchAction($action, $httpVars, $fileVars, ContextInterface $ct
foreach ($httpVars as $getName=>$getValue) {
$$getName = Utils::securePath($getValue);
}
- $selection = new UserSelection();
- $selection->initFromHttpVars($httpVars);
+ $selection = UserSelection::fromContext($ctx, $httpVars);
if (isSet($dir) && $action != "upload") {
$safeDir = $dir;
$dir = TextEncoder::fromUTF8($dir);
@@ -53,16 +53,17 @@ class PluginCompression extends Plugin
*/
public function receiveAction(\Psr\Http\Message\ServerRequestInterface &$requestInterface, \Psr\Http\Message\ResponseInterface &$responseInterface)
{
- $httpVars = $requestInterface->getParsedBody();
- $messages = LocaleService::getMessages();
/** @var \Pydio\Core\Model\ContextInterface $ctx */
$ctx = $requestInterface->getAttribute("ctx");
- $repository = $ctx->getRepository();
- $userSelection = new UserSelection($repository, $httpVars);
- $nodes = $userSelection->buildNodes();
+
+ $httpVars = $requestInterface->getParsedBody();
+ $messages = LocaleService::getMessages();
+
+ $userSelection = UserSelection::fromContext($ctx, $httpVars);
+ $nodes = $userSelection->buildNodes();
$currentDirPath = Utils::safeDirname($userSelection->getUniqueNode()->getPath());
$currentDirPath = rtrim($currentDirPath, "/") . "/";
- $currentDirUrl = $userSelection->currentBaseUrl().$currentDirPath;
+ $currentDirUrl = $userSelection->currentBaseUrl().$currentDirPath;
$serializableStream = new \Pydio\Core\Http\Response\SerializableResponseStream();
$responseInterface = $responseInterface->withBody($serializableStream);
@@ -50,17 +50,16 @@ public function performChecks(){
public function switchAction(ServerRequestInterface &$request, ResponseInterface &$response)
{
-
- $selection = new UserSelection();
- $httpVars = $request->getParsedBody();
/** @var \Pydio\Core\Model\ContextInterface $ctx */
$ctx = $request->getAttribute("ctx");
+
+ $httpVars = $request->getParsedBody();
$repository = $ctx->getRepository();
$dir = $httpVars["dir"] OR "";
$dir = Utils::decodeSecureMagic($dir);
if($dir == "/") $dir = "";
- $selection->initFromHttpVars($httpVars);
+ $selection = UserSelection::fromContext($ctx, $httpVars);
if (!$selection->isEmpty()) {
//$this->filterUserSelectionToHidden($selection->getFiles());
}
@@ -321,7 +321,7 @@ public function switchAction($action, $httpVars, $postProcessData, \Pydio\Core\M
}
- public function placeConfigNode(&$configTree)
+ public function placeConfigNode(ContextInterface $ctx, &$configTree)
{
$mess = LocaleService::getMessages();
if (isSet($configTree["parameters"])){
@@ -84,13 +84,14 @@ public function init(ContextInterface $ctx, $options = array())
public function accessPreprocess(ServerRequestInterface &$request)
{
$actionName = $request->getAttribute("action");
- $httpVars = $request->getParsedBody();
+ $ctx = $request->getAttribute("ctx");
+ $httpVars = $request->getParsedBody();
if ($actionName == "apply_check_hook") {
if (!in_array($httpVars["hook_name"], array("before_create", "before_path_change", "before_change"))) {
return;
}
- $selection = new UserSelection($this->repository, $httpVars);
+ $selection = UserSelection::fromContext($ctx, $httpVars);
Controller::applyHook("node.".$httpVars["hook_name"], array($selection->getUniqueNode(), $httpVars["hook_arg"]));
}
if ($actionName == "ls") {
@@ -55,13 +55,12 @@ public function cypherAllMounted($actionName, &$httpVars, &$fileVars, ContextInt
}
}
- public function preProcessMove($actionName, &$httpVars, &$fileVars)
+ public function preProcessMove($actionName, &$httpVars, &$fileVars, ContextInterface $ctx)
{
$destO = Utils::decodeSecureMagic($httpVars["dest"]);
$dest = substr($destO, 1, strpos(ltrim($destO, "/"), "/"));
if(empty($dest)) $dest = ltrim($destO, "/");
- $userSelection = new UserSelection();
- $userSelection->initFromHttpVars($httpVars);
+ $userSelection = UserSelection::fromContext($ctx, $httpVars);
if (!$userSelection->isEmpty()) {
$testFileO = $userSelection->getUniqueFile();
$testFile = substr($testFileO, 1, strpos(ltrim($testFileO, "/"), "/"));
@@ -49,7 +49,7 @@ public function switchAction($action, $httpVars, $filesVars, \Pydio\Core\Model\C
}
}
- $selection = new UserSelection($repository, $httpVars);
+ $selection = UserSelection::fromContext($ctx, $httpVars);
if ($action == "open_file") {
$selectedNode = $selection->getUniqueNode();
@@ -128,12 +128,12 @@ public function switchAction(ServerRequestInterface &$request, ResponseInterface
$loggedUser = $ctx->getUser();
if($loggedUser != null){
- $repoWriteable = $loggedUser->canWrite($repository->getId());
+ $repoWriteable = $loggedUser->canWrite($ctx->getRepositoryId());
}else{
$repoWriteable = false;
}
- $selection = new UserSelection($repository, $httpVars);
+ $selection = UserSelection::fromContext($ctx, $httpVars);
$destStreamURL = $selection->currentBaseUrl();
if ($action == "post_to_zohoserver") {
@@ -120,10 +120,11 @@ protected function getMetaDefinition()
public function extractExif(\Psr\Http\Message\ServerRequestInterface $requestInterface, \Psr\Http\Message\ResponseInterface &$responseInterface)
{
- $httpVars = $requestInterface->getParsedBody();
- $userSelection = new UserSelection($this->accessDriver->repository, $httpVars);
- $selectedNode = $userSelection->getUniqueNode();
- $realFile = AJXP_MetaStreamWrapper::getRealFSReference($selectedNode->getUrl());
+ $httpVars = $requestInterface->getParsedBody();
+ $ctx = $requestInterface->getAttribute("ctx");
+ $userSelection = UserSelection::fromContext($ctx, $httpVars);
+ $selectedNode = $userSelection->getUniqueNode();
+ $realFile = AJXP_MetaStreamWrapper::getRealFSReference($selectedNode->getUrl());
Utils::safeIniSet('exif.encode_unicode', 'UTF-8');
$exifData = @exif_read_data($realFile, 0, TRUE);
@@ -110,10 +110,10 @@ public function initMeta(ContextInterface $ctx, AbstractAccessDriver $accessDriv
$this->metaStore->initMeta($ctx, $accessDriver);
}
- public function switchActions($actionName, $httpVars, $fileVars)
+ public function switchActions($actionName, $httpVars, $fileVars, ContextInterface $ctx)
{
- $repository = $this->accessDriver->repository;
- $selection = new UserSelection($repository, $httpVars);
+ $selection = UserSelection::fromContext($ctx, $httpVars);
+
switch ($actionName) {
case "filehasher_signature":
$file = $selection->getUniqueNode();
@@ -81,7 +81,7 @@ public function applyChangeLock(\Psr\Http\Message\ServerRequestInterface $reques
if (!UsersService::usersEnabled() && $user!=null && !$user->canWrite($repo->getId())) {
throw new Exception("You have no right on this action.");
}
- $selection = new UserSelection($repo, $httpVars);
+ $selection = UserSelection::fromContext($ctx, $httpVars);
$unlock = (isSet($httpVars["unlock"])?true:false);
if ($unlock) {
@@ -72,8 +72,8 @@ public function initMeta(ContextInterface $ctx, AbstractAccessDriver $accessDriv
protected function initDirAndSelection(ContextInterface $ctx, $httpVars, $additionnalPathes = array(), $testRecycle = false)
{
- $repo = $this->accessDriver->repository;
- $userSelection = new UserSelection($repo, $httpVars);
+ $userSelection = UserSelection::fromContext($ctx, $httpVars);
+ $repo = $userSelection->getContext()->getRepository();
$urlBase = $userSelection->currentBaseUrl();
$result = array();
@@ -250,12 +250,11 @@ public function editMeta(\Psr\Http\Message\ServerRequestInterface &$requestInter
/** @var ContextInterface $ctx */
$ctx = $requestInterface->getAttribute("ctx");
$user = $ctx->getUser();
- $repo = $this->accessDriver->repository;
-
- if (!UsersService::usersEnabled() && $user!=null && !$user->canWrite($repo->getId())) {
+
+ if (!UsersService::usersEnabled() && $user!=null && !$user->canWrite($ctx->getRepositoryId())) {
throw new Exception("You have no right on this action.");
}
- $selection = new UserSelection($repo, $httpVars);
+ $selection = UserSelection::fromContext($ctx, $httpVars);
$nodes = $selection->buildNodes();
$nodesDiffs = new \Pydio\Access\Core\Model\NodesDiff();
@@ -382,7 +382,7 @@ public function switchActions(\Psr\Http\Message\ServerRequestInterface $requestI
/** @var ContextInterface $ctx */
$ctx = $requestInterface->getAttribute("ctx");
- $us = new UserSelection($this->accessDriver->repository, $httpVars);
+ $us = UserSelection::fromContext($ctx, $httpVars);
$node = $us->getUniqueNode();
$node->loadNodeInfo();
$cmd = $httpVars["watch_action"];
@@ -87,7 +87,7 @@ public function preProcess(\Psr\Http\Message\ServerRequestInterface &$request, \
$this->logDebug("Trying Cross-Session Resume request");
$dir = Utils::decodeSecureMagic($httpVars["dir"]);
- $context = new UserSelection($repository);
+ $context = UserSelection::fromContext($ctx, $httpVars);
$destStreamURL = $context->currentBaseUrl().$dir;
$fileHash = md5($httpVars["fileName"]);
@@ -241,7 +241,7 @@ public function postProcess(\Psr\Http\Message\ServerRequestInterface &$request,
if ($httpVars["lastPartition"]) {
$dir = Utils::decodeSecureMagic($httpVars["dir"]);
- $context = new UserSelection($repository);
+ $context = UserSelection::fromContext($ctx, $httpVars);
$destStreamURL = $context->currentBaseUrl().$dir."/";
/* we check if the current file has a relative path (aka we want to upload an entire directory) */

0 comments on commit 3837131

Please sign in to comment.