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

Commit

Permalink
Fixes, again
Browse files Browse the repository at this point in the history
  • Loading branch information
cdujeu committed Jun 9, 2016
1 parent d044c0c commit 3837131
Show file tree
Hide file tree
Showing 19 changed files with 46 additions and 50 deletions.
Expand Up @@ -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])) {
Expand Down
Expand Up @@ -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"])) {
Expand Down Expand Up @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions core/src/plugins/access.ajxp_user/class.UserDashboardDriver.php
Expand Up @@ -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
*/
Expand Down
3 changes: 1 addition & 2 deletions core/src/plugins/access.fs/class.fsAccessDriver.php
Expand Up @@ -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");
}
Expand Down
3 changes: 1 addition & 2 deletions core/src/plugins/access.mysql/class.mysqlAccessDriver.php
Expand Up @@ -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);
Expand Down
13 changes: 7 additions & 6 deletions core/src/plugins/action.compression/class.PluginCompression.php
Expand Up @@ -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);
Expand Down
7 changes: 3 additions & 4 deletions core/src/plugins/action.powerfs/class.PowerFSController.php
Expand Up @@ -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());
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/plugins/action.scheduler/class.AjxpScheduler.php
Expand Up @@ -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"])){
Expand Down
5 changes: 3 additions & 2 deletions core/src/plugins/core.access/src/AbstractAccessDriver.php
Expand Up @@ -84,13 +84,14 @@ abstract protected function initRepository(ContextInterface $ctx);
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") {
Expand Down
5 changes: 2 additions & 3 deletions core/src/plugins/cypher.encfs/class.EncfsMounter.php
Expand Up @@ -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, "/"), "/"));
Expand Down
2 changes: 1 addition & 1 deletion core/src/plugins/editor.browser/class.FileMimeSender.php
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions core/src/plugins/editor.zoho/class.ZohoEditor.php
Expand Up @@ -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") {
Expand Down
9 changes: 5 additions & 4 deletions core/src/plugins/meta.exif/class.ExifMetaManager.php
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions core/src/plugins/meta.filehasher/class.FileHasher.php
Expand Up @@ -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();
Expand Down
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions core/src/plugins/meta.svn/class.SvnManager.php
Expand Up @@ -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();

Expand Down
7 changes: 3 additions & 4 deletions core/src/plugins/meta.user/class.UserMetaManager.php
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion core/src/plugins/meta.watch/class.MetaWatchRegister.php
Expand Up @@ -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"];
Expand Down
Expand Up @@ -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"]);

Expand Down Expand Up @@ -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) */
Expand Down

0 comments on commit 3837131

Please sign in to comment.