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

Commit

Permalink
Start removing AuthService::getLoggedUser() and ConfService::getRepos…
Browse files Browse the repository at this point in the history
…itory() in favor of contexts.
  • Loading branch information
cdujeu committed Jun 4, 2016
1 parent c702baf commit c4ff2e6
Show file tree
Hide file tree
Showing 59 changed files with 651 additions and 561 deletions.
29 changes: 24 additions & 5 deletions core/src/core/src/pydio/Core/Controller/Controller.php
Expand Up @@ -27,6 +27,7 @@
use Pydio\Core\Exception\PydioException;
use Pydio\Auth\Core\AJXP_Safe;
use Pydio\Core\Model\Context;
use Pydio\Core\Model\ContextInterface;
use Pydio\Core\Services;
use Pydio\Core\Services\AuthService;
use Pydio\Core\Services\ConfService;
Expand All @@ -36,6 +37,7 @@
use Pydio\Tasks\Task;
use Pydio\Tasks\TaskService;
use Zend\Diactoros\Response;
use Zend\Diactoros\ServerRequestFactory;

defined('AJXP_EXEC') or die( 'Access not allowed');
/**
Expand Down Expand Up @@ -247,11 +249,31 @@ public static function run(ServerRequestInterface $request, &$actionNode = null)
return $response;
}

/**
* @param Task $task
*/
public static function applyTaskInBackground(Task $task){

$parameters = $task->getParameters();
$task->setStatus(Task::STATUS_RUNNING);
TaskService::getInstance()->updateTask($task);
self::applyActionInBackground($task->getWsId(), $task->getAction(), $parameters, $task->getUserId(), "", $task->getId());

}

/**
* @param ContextInterface $context
* @param string $action
* @param array $parameters
* @return ServerRequestInterface
*/
public static function executableRequest(ContextInterface $context, $action, $parameters = []){
$request = ServerRequestFactory::fromGlobals();
$request = $request
->withAttribute("ctx", $context)
->withAttribute("action", $action)
->withParsedBody($parameters);
return $request;
}

/**
Expand Down Expand Up @@ -345,10 +367,7 @@ public static function applyActionInBackground($currentRepositoryId, $actionName
}
}

$repoObject = ConfService::getRepository();
if(empty($repoObject)){
$repoObject = ConfService::getRepositoryById($currentRepositoryId);
}
$repoObject = ConfService::getRepositoryById($currentRepositoryId);
$clearEnv = false;
if($repoObject->getOption("USE_SESSION_CREDENTIALS")){
$encodedCreds = AJXP_Safe::getEncodedCredentialString();
Expand Down Expand Up @@ -506,7 +525,7 @@ private static function handleRequest($callback, ServerRequestInterface &$reques
}else{

$httpVars = $request->getParsedBody();
$result = $plugInstance->$methodName($request->getAttribute("action"), $httpVars, $_FILES);
$result = $plugInstance->$methodName($request->getAttribute("action"), $httpVars, $_FILES, $request->getAttribute("ctx"));
// May have been modified
$request = $request->withParsedBody($httpVars);

Expand Down
Expand Up @@ -185,7 +185,7 @@ protected function bodyHandler($callback, ServerRequestInterface &$request, Resp
*
* @param string|object $destination
* @param object $sourceObject
* @return object
* @return mixed
*/
public static function cast($destination, $sourceObject)
{
Expand Down
6 changes: 3 additions & 3 deletions core/src/core/src/pydio/Core/Model/RepositoryInterface.php
Expand Up @@ -70,17 +70,17 @@ public function getContentFilter();
* @param string $uniqueUser
* @return RepositoryInterface
*/
public function createSharedChild($newLabel, $newOptions, $parentId = null, $owner = null, $uniqueUser = null);
public function createSharedChild($newLabel, $newOptions, $parentId, $owner, $uniqueUser = null);

/**
* Create a child from this repository if it's a template
* @param string $newLabel
* @param array $newOptions
* @param string $owner
* @param string $creator
* @param string $uniqueUser
* @return RepositoryInterface
*/
public function createTemplateChild($newLabel, $newOptions, $owner = null, $uniqueUser = null);
public function createTemplateChild($newLabel, $newOptions, $creator = null, $uniqueUser = null);

/**
* Recompute uuid
Expand Down
8 changes: 7 additions & 1 deletion core/src/core/src/pydio/Core/Model/UserInterface.php
Expand Up @@ -23,13 +23,14 @@
defined('AJXP_EXEC') or die('Access not allowed');

use Pydio\Conf\Core\AJXP_Role;
use Pydio\Conf\Core\AjxpGroupPathProvider;

/**
* @class AbstractAjxpUser
* @abstract
* User abstraction, the "conf" driver must provides its own implementation
*/
interface UserInterface
interface UserInterface extends AjxpGroupPathProvider
{
/**
* @param bool $hidden
Expand Down Expand Up @@ -234,6 +235,11 @@ public function recomputeMergedRole();
*/
public function getMergedRole();

/**
* @return AJXP_Role
*/
public function getPersonalRole();

/**
* @param bool $resolveAsParent
*/
Expand Down
5 changes: 2 additions & 3 deletions core/src/core/src/pydio/Core/Services/ConfService.php
Expand Up @@ -29,11 +29,10 @@
use Pydio\Conf\Core\AbstractAjxpUser;
use Pydio\Conf\Core\AbstractConfDriver;
use Pydio\Core\Controller\Controller;
use Pydio\Core\Exception\NoActiveWorkspaceException;
use Pydio\Core\Exception\PydioException;
use Pydio\Core\Exception\PydioUserAlertException;
use Pydio\Core\Model\Context;
use Pydio\Core\Model\RepositoryInterface;
use Pydio\Core\Model\UserInterface;
use Pydio\Core\PluginFramework\CoreInstanceProvider;
use Pydio\Core\Utils\Utils;
use Pydio\Core\Utils\VarsFilter;
Expand Down Expand Up @@ -350,7 +349,7 @@ public static function reloadServicesAndActivePlugins(){


/**
* @param AbstractAjxpUser $loggedUser
* @param UserInterface $loggedUser
* @param String|int $parameterId
* @return bool
*/
Expand Down

0 comments on commit c4ff2e6

Please sign in to comment.