Permalink
Browse files

Docs and unused codes

  • Loading branch information...
1 parent b049072 commit 6cd0506818993ea9071f7f2247545e1165843711 @cdujeu cdujeu committed Jun 5, 2016
@@ -40,7 +40,7 @@ public function __construct($repository, $errors)
{
$message = "Error while loading workspace ".$repository->getDisplay()." : ".implode("\n-", $errors);
$this->repository = $repository;
- parent::__construct($message, null, 5000);
+ parent::__construct($message, false, 5000);
}
public function getRepository(){
@@ -21,11 +21,10 @@
namespace Pydio\Core\PluginFramework;
use Pydio\Access\Core\AJXP_MetaStreamWrapper;
-use Pydio\Access\Core\Model\Repository;
use Pydio\Core\Model\Context;
use Pydio\Core\Model\ContextInterface;
+use Pydio\Core\Model\RepositoryInterface;
use Pydio\Core\Services\AuthService;
-use Pydio\Core\PluginFramework\PluginsService;
use Pydio\Core\Services\ConfService;
use Pydio\Core\Controller\XMLWriter;
use Pydio\Log\Core\AJXP_Logger;
@@ -170,7 +169,7 @@ protected function getContextualOption(ContextInterface $ctx, $optionName){
/**
* @param string $optionName
- * @param string|\Pydio\Access\Core\Model\Repository $repositoryScope
+ * @param string|RepositoryInterface $repositoryScope
* @param null|\Pydio\Conf\Core\AbstractAjxpUser $userObject
* @return mixed|null
*/
@@ -187,7 +186,7 @@ protected function getFilteredOption($optionName, $repositoryScope = AJXP_REPO_S
if ($repositoryScope === AJXP_REPO_SCOPE_ALL) {
$repo = ConfService::getRepository();
if($repo != null) $repositoryScope = $repo->getId();
- }else if(is_object($repositoryScope) && $repositoryScope instanceof Repository){
+ }else if(is_object($repositoryScope) && $repositoryScope instanceof RepositoryInterface){
$repo = $repositoryScope;
$repositoryScope = $repo->getId();
}
@@ -862,7 +862,7 @@ public function patchPluginWithMixin(&$plugin, &$manifestDoc, $mixinName)
/*********************************/
/**
* Save plugin registry to cache
- * @param AbstractCacheDriver $cacheStorage
+ * @param AbstractCacheDriver|null $cacheStorage
*/
private function savePluginsRegistryToCache($cacheStorage) {
if (!empty ($cacheStorage)) {
@@ -957,8 +957,9 @@ private function _loadDetectedPluginsFromCache($cacheStorage){
// Retrieving Registry from Server Cache
if (!empty($cacheStorage)) {
$res = $cacheStorage->fetch(AJXP_CACHE_SERVICE_NS_SHARED, 'plugins_registry');
-
- $this->detectedPlugins=$res;
+ if(is_array($res)){
+ $this->detectedPlugins=$res;
+ }
}
// Retrieving Registry from files cache
@@ -1100,7 +1101,7 @@ private function filterRegistryFromRole(&$registry, ContextInterface $ctx)
if ($crtRepo != null && $crtRepo instanceof Repository) {
$crtRepoId = $crtRepo->getId();
}
- $actionRights = $loggedUser->mergedRole->listActionsStatesFor($crtRepo);
+ $actionRights = $loggedUser->getMergedRole()->listActionsStatesFor($crtRepo);
$changes = false;
$xPath = new DOMXPath($registry);
foreach ($actionRights as $pluginName => $actions) {
@@ -1115,7 +1116,7 @@ private function filterRegistryFromRole(&$registry, ContextInterface $ctx)
$changes = true;
}
}
- $parameters = $loggedUser->mergedRole->listParameters();
+ $parameters = $loggedUser->getMergedRole()->listParameters();
foreach ($parameters as $scope => $paramsPlugs) {
if ($scope === AJXP_REPO_SCOPE_ALL || $scope === $crtRepoId || ($crtRepo != null && $crtRepo->hasParent() && $scope === AJXP_REPO_SCOPE_SHARED)) {
foreach ($paramsPlugs as $plugId => $params) {
@@ -1548,7 +1548,7 @@ private function loadRepositoryDriverInst(&$repository)
}
/**
- * @param Repository $repository
+ * @param RepositoryInterface $repository
*/
public static function switchBackAfterRepositoryError($repository){
self::getInstance()->removeRepositoryFromCache($repository->getId());
@@ -675,7 +675,7 @@ public function switchAction($action, $httpVars, $fileVars, ContextInterface $ct
if(!AuthService::canAdministrate($userObject)){
throw new \Exception("Cant find user!");
}
- $role = $userObject->personalRole;
+ $role = $userObject->getPersonalRole();
} else {
$role = AuthService::getRole($roleId, $roleGroup);
}
@@ -858,7 +858,7 @@ public function switchAction($action, $httpVars, $fileVars, ContextInterface $ct
if(!AuthService::canAdministrate($userObject)){
throw new \Exception("Cannot post role for user ".$usrId);
}
- $originalRole = $userObject->personalRole;
+ $originalRole = $userObject->getPersonalRole();
} else {
// second param = create if not exists.
$originalRole = AuthService::getRole($roleId, $roleGroup);
@@ -1082,7 +1082,7 @@ public function switchAction($action, $httpVars, $fileVars, ContextInterface $ct
if(!AuthService::canAdministrate($user)){
throw new \Exception("Cannot update user with id ".$userId);
}
- $user->personalRole->setAcl(Utils::sanitize($httpVars["repository_id"], AJXP_SANITIZE_ALPHANUM), Utils::sanitize($httpVars["right"], AJXP_SANITIZE_ALPHANUM));
+ $user->getPersonalRole()->setAcl(Utils::sanitize($httpVars["repository_id"], AJXP_SANITIZE_ALPHANUM), Utils::sanitize($httpVars["right"], AJXP_SANITIZE_ALPHANUM));
$user->save();
$loggedUser = $ctx->getUser();
if ($loggedUser->getId() == $user->getId()) {
@@ -1536,7 +1536,7 @@ public function switchAction($action, $httpVars, $fileVars, ContextInterface $ct
$groupRole->setAcl($newRep->getId(), $defaultRights);
}
$loggedUser = $ctx->getUser();
- $loggedUser->personalRole->setAcl($newRep->getUniqueId(), "rw");
+ $loggedUser->getPersonalRole()->setAcl($newRep->getUniqueId(), "rw");
$loggedUser->recomputeMergedRole();
$loggedUser->save("superuser");
AuthService::updateUser($loggedUser);
@@ -356,8 +356,6 @@ public function createResourceAction(ServerRequestInterface &$request, ResponseI
*/
public function uploadAction(ServerRequestInterface &$request, ResponseInterface &$response){
- /** @var ContextInterface $ctx */
- $ctx = $request->getAttribute("ctx");
$selection = new UserSelection($this->repository);
$httpVars = $request->getParsedBody();
$dir = Utils::sanitize($httpVars["dir"], AJXP_SANITIZE_DIRNAME) OR "";
@@ -545,7 +545,7 @@ public function handleTasks($action, $httpVars, $fileVars)
public function fakeLongTask($action, $httpVars, $fileVars, \Pydio\Core\Model\ContextInterface $context)
{
$minutes = (isSet($httpVars["time_length"])?intval($httpVars["time_length"]):2);
- $this->logInfo(__FUNCTION__, "Running Fake task on ".$context->getId());
+ $this->logInfo(__FUNCTION__, "Running Fake task on ".$context->getRepositoryId());
print('STARTING FAKE TASK');
sleep($minutes * 30);
print('ENDIND FAKE TASK');
@@ -1662,7 +1662,7 @@ public function shareNode(ContextInterface $ctx, $ajxpNode, $httpVars, &$update)
return null;
}
- $newRepo = $this->createSharedRepository($httpVars, $repoUpdate, $users, $groups);
+ $newRepo = $this->createSharedRepository($httpVars, $update, $users, $groups);
foreach($shareObjects as $shareObject){
@@ -408,7 +408,7 @@ public function createUserObject($userId)
{
$test=CacheService::fetch("shared", "pydio:user:" . $userId);
if($test !== false && $test instanceof AbstractAjxpUser){
- if($test->personalRole == null){
+ if($test->getPersonalRole() === null){
$test->personalRole = $test->roles["AJXP_USR_/".$userId];
}
$test->recomputeMergedRole();
@@ -806,7 +806,6 @@ public function switchAction(ServerRequestInterface $requestInterface, ResponseI
} else {
$updating = false;
- $loggedUser = $loggedUser;
Utils::parseStandardFormParameters($httpVars, $data, null, "PREFERENCES_");
}
@@ -823,18 +822,22 @@ public function switchAction(ServerRequestInterface $requestInterface, ResponseI
$name = $xmlNode->getAttribute("name");
if (isSet($data[$name]) || $data[$name] === "") {
if($data[$name] == "__AJXP_VALUE_SET__") continue;
- if ($data[$name] === "" || $loggedUser->parentRole == null
- || $loggedUser->parentRole->filterParameterValue($pluginId, $name, AJXP_REPO_SCOPE_ALL, "") != $data[$name]
- || $loggedUser->personalRole->filterParameterValue($pluginId, $name, AJXP_REPO_SCOPE_ALL, "") != $data[$name]) {
- $loggedUser->personalRole->setParameterValue($pluginId, $name, $data[$name]);
+ $pRole = null;
+ $persRole = $loggedUser->getPersonalRole();
+ if($loggedUser instanceof AbstractAjxpUser) $pRole = $loggedUser->parentRole;
+ if ($data[$name] === ""
+ || $pRole === null || $pRole->filterParameterValue($pluginId, $name, AJXP_REPO_SCOPE_ALL, "") != $data[$name]
+ || $persRole->filterParameterValue($pluginId, $name, AJXP_REPO_SCOPE_ALL, "") != $data[$name])
+ {
+ $persRole->setParameterValue($pluginId, $name, $data[$name]);
$rChanges = true;
}
}
}
}
}
if ($rChanges) {
- AuthService::updateRole($loggedUser->personalRole, $loggedUser);
+ AuthService::updateRole($loggedUser->getPersonalRole(), $loggedUser);
$loggedUser->recomputeMergedRole();
if ($action == "custom_data_edit") {
AuthService::updateUser($loggedUser);
@@ -886,7 +889,7 @@ public function switchAction(ServerRequestInterface $requestInterface, ResponseI
$result = array();
$params = explode(",", $paramsString);
foreach($params as $p){
- $result[$p] = $loggedUser->personalRole->filterParameterValue("core.conf", $p, AJXP_REPO_SCOPE_ALL, "");
+ $result[$p] = $loggedUser->getPersonalRole()->filterParameterValue("core.conf", $p, AJXP_REPO_SCOPE_ALL, "");
}
$responseInterface = $responseInterface->withHeader("Content-type", "application/json");
@@ -1051,7 +1054,7 @@ public function switchAction(ServerRequestInterface $requestInterface, ResponseI
// Make sure we do not overwrite otherwise loaded rights.
$loggedUser->load();
- $loggedUser->personalRole->setAcl($newRep->getUniqueId(), "rw");
+ $loggedUser->getPersonalRole()->setAcl($newRep->getUniqueId(), "rw");
$loggedUser->save("superuser");
$loggedUser->recomputeMergedRole();
AuthService::updateUser($loggedUser);
@@ -1079,7 +1082,7 @@ public function switchAction(ServerRequestInterface $requestInterface, ResponseI
// Make sure we do not override remotely set rights
$loggedUser->load();
- $loggedUser->personalRole->setAcl($repoId, "");
+ $loggedUser->getPersonalRole()->setAcl($repoId, "");
$loggedUser->save("superuser");
AuthService::updateUser($loggedUser);
@@ -45,6 +45,9 @@ class AJXP_Logger extends Plugin
* @var AbstractLogDriver
*/
protected $pluginInstance;
+ /**
+ * @var AbstractLogDriver
+ */
protected static $loggerInstance;
protected static $globalOptions;
@@ -71,7 +74,6 @@ public function getLoggerInstance()
* @param string $source The source of the message (plugin id or classname)
* @param string $prefix A quick description
* @param array $messages An array of messages (string or array).
- * @param array $nodePathes Optional array of pathes
*/
public static function log2($level, $source, $prefix, $messages = array())
{
@@ -122,7 +124,6 @@ public static function log2($level, $source, $prefix, $messages = array())
* @static
* @param string $source The source of the message (plugin id or classname)
* @param string $prefix A quick description
- * @param string|array $messages Variable number of message args (string or array).
* @return void
*/
public static function debug($source, $prefix = "")
@@ -267,7 +268,7 @@ public static function getLoggedUser()
/**
* Format an array as a readable string
*
- * @param Array $params
+ * @param array $params
* @return String readable list of parameters.
*/
public static function arrayToString($params)
@@ -372,7 +372,6 @@ public function switchActions(\Psr\Http\Message\ServerRequestInterface $requestI
if($actionName !== "toggle_watch") return;
/** @var ContextInterface $ctx */
$ctx = $requestInterface->getAttribute("ctx");
- $ctxUser = $ctx->getUser();
$us = new UserSelection($this->accessDriver->repository, $httpVars);
$node = $us->getUniqueNode();

0 comments on commit 6cd0506

Please sign in to comment.