Permalink
Browse files

Context propagation again

  • Loading branch information...
1 parent 7c63857 commit 2a77d7bddf2dd0ed78c1deea000c1a1d06c5d05d @cdujeu cdujeu committed Jun 5, 2016
Showing with 370 additions and 244 deletions.
  1. +2 −1 core/src/core/src/pydio/Core/Model/RepositoryInterface.php
  2. +2 −2 core/src/core/src/pydio/Core/Services/ConfService.php
  3. +2 −2 core/src/plugins/access.dropbox/class.dropboxAccessDriver.php
  4. +20 −24 core/src/plugins/access.fs/class.fsAccessDriver.php
  5. +1 −1 core/src/plugins/access.imap/class.imapAccessDriver.php
  6. +8 −2 core/src/plugins/access.s3/class.s3AccessDriver.php
  7. +8 −2 core/src/plugins/access.swift/class.swiftAccessDriver.php
  8. +3 −2 core/src/plugins/action.antivirus/class.AntivirusScanner.php
  9. +3 −2 core/src/plugins/action.avatar/class.AvatarProvider.php
  10. +3 −1 core/src/plugins/action.share/src/Legacy/LegacyPubliclet.php
  11. +57 −45 core/src/plugins/action.share/src/ShareCenter.php
  12. +1 −1 core/src/plugins/action.share/src/Store/ShareRightsManager.php
  13. +4 −3 core/src/plugins/action.timestamp/class.TimestampCreator.php
  14. +14 −9 core/src/plugins/authfront.duosecurity/class.DuoSecurityFrontend.php
  15. +1 −1 core/src/plugins/cache.doctrine/class.DoctrineCacheDriver.php
  16. +36 −16 core/src/plugins/core.access/src/AbstractAccessDriver.php
  17. +3 −1 core/src/plugins/core.access/src/IAjxpWrapperProvider.php
  18. +17 −1 core/src/plugins/core.access/src/Model/AJXP_Node.php
  19. +1 −1 core/src/plugins/core.access/src/Model/Repository.php
  20. +2 −1 core/src/plugins/core.conf/class.AJXP_Role.php
  21. +8 −8 core/src/plugins/core.conf/class.AbstractConfDriver.php
  22. +3 −3 core/src/plugins/core.index/class.AbstractSearchEngineIndexer.php
  23. +21 −14 core/src/plugins/core.mq/class.MqManager.php
  24. +16 −10 core/src/plugins/core.notifications/interface.AJXP_MessageExchanger.php
  25. +8 −5 core/src/plugins/cypher.encfs/class.EncfsMounter.php
  26. +7 −5 core/src/plugins/editor.diaporama/class.ImagePreviewer.php
  27. +2 −2 core/src/plugins/editor.etherpad/class.EtherpadClient.php
  28. +6 −5 core/src/plugins/editor.imagick/class.IMagickPreviewer.php
  29. +2 −2 core/src/plugins/editor.pixlr/class.PixlrEditor.php
  30. +16 −13 core/src/plugins/editor.zoho/class.ZohoEditor.php
  31. +13 −13 core/src/plugins/gui.ajax/class.AJXP_ClientDriver.php
  32. +4 −4 core/src/plugins/index.elasticsearch/class.AjxpElasticSearch.php
  33. +21 −10 core/src/plugins/index.lucene/class.AjxpLuceneIndexer.php
  34. +2 −1 core/src/plugins/meta.comments/class.CommentsMetaManager.php
  35. +2 −1 core/src/plugins/meta.syncable/class.ChangesTracker.php
  36. +29 −15 core/src/plugins/mq.serial/class.AJXP_SerialMessageExchanger.php
  37. +22 −15 core/src/plugins/mq.sql/class.AJXP_SqlMessageExchanger.php
@@ -24,6 +24,7 @@
use Pydio\Access\Core\AbstractAccessDriver;
use Pydio\Access\Core\Filter\ContentFilter;
+use Pydio\Conf\Core\AjxpGroupPathProvider;
/**
@@ -32,7 +33,7 @@
* @package Pydio
* @subpackage Core
*/
-interface RepositoryInterface
+interface RepositoryInterface extends AjxpGroupPathProvider
{
/**
@@ -906,15 +906,15 @@ public function createRepositoryFromArrayInst($index, $repository)
/**
* Add dynamically created repository
*
- * @param \Pydio\Access\Core\Model\Repository $oRepository
+ * @param \Pydio\Core\Model\RepositoryInterface $oRepository
* @return -1|null if error
*/
public static function addRepository($oRepository)
{
return self::getInstance()->addRepositoryInst($oRepository);
}
/**
- * @param \Pydio\Access\Core\Model\Repository $oRepository
+ * @param Repository|\Pydio\Core\Model\RepositoryInterface $oRepository
* @return -1|null on error
*/
public function addRepositoryInst($oRepository)
@@ -154,9 +154,9 @@ public function setTokens($oauth_tokens)
Utils::saveSerialFile(AJXP_DATA_PATH."/plugins/access.dropbox/".$repositoryId."_".$userId."_tokens", $oauth_tokens, true);
}
- public function makeSharedRepositoryOptions($httpVars, $repository)
+ public function makeSharedRepositoryOptions(ContextInterface $ctx, $httpVars)
{
- $newOptions = parent::makeSharedRepositoryOptions($httpVars, $repository);
+ $newOptions = parent::makeSharedRepositoryOptions($ctx, $httpVars);
$newOptions["DROPBOX_OAUTH_TOKENS"] = $this->getTokens();
return $newOptions;
}
@@ -43,7 +43,6 @@
use Pydio\Core\Http\Response\SerializableResponseStream;
use Pydio\Core\Http\Message\UserMessage;
use Pydio\Core\Model\ContextInterface;
-use Pydio\Core\Services\AuthService;
use Pydio\Core\Services\ConfService;
use Pydio\Core\Controller\Controller;
use Pydio\Core\Exception\PydioException;
@@ -55,7 +54,6 @@
use Pydio\Tasks\Task;
use Pydio\Tasks\TaskService;
use Zend\Diactoros\Response;
-use Zend\Diactoros\ServerRequestFactory;
defined('AJXP_EXEC') or die( 'Access not allowed');
@@ -361,16 +359,15 @@ public function createResourceAction(ServerRequestInterface &$request, ResponseI
*/
public function uploadAction(ServerRequestInterface &$request, ResponseInterface &$response){
- $selection = new UserSelection($this->repository);
$httpVars = $request->getParsedBody();
$dir = Utils::sanitize($httpVars["dir"], AJXP_SANITIZE_DIRNAME) OR "";
if (AJXP_MetaStreamWrapper::actualRepositoryWrapperClass($this->repository->getId()) == "fsAccessWrapper") {
$dir = fsAccessWrapper::patchPathForBaseDir($dir);
}
$dir = Utils::securePath($dir);
- $selection->initFromHttpVars($httpVars);
+ $selection = UserSelection::fromContext($request->getAttribute("ctx"), $httpVars);
if (!$selection->isEmpty()) {
- $this->filterUserSelectionToHidden($selection->getFiles());
+ $this->filterUserSelectionToHidden($selection->getContext(), $selection->getFiles());
if(empty($dir) && $selection->isUnique()){
$dir = Utils::safeDirname($selection->getUniqueFile());
}
@@ -423,7 +420,7 @@ public function uploadAction(ServerRequestInterface &$request, ResponseInterface
}
// CHECK IF THIS IS A FORBIDDEN FILENAME
- $this->filterUserSelectionToHidden(array($userfile_name));
+ $this->filterUserSelectionToHidden($selection->getContext(), array($userfile_name));
// APPLY PRE-UPLOAD HOOKS
$already_existed = false;
@@ -527,11 +524,10 @@ public function downloadAction(ServerRequestInterface &$request, ResponseInterfa
/** @var ContextInterface $ctx */
$ctx = $request->getAttribute("ctx");
- $selection = new UserSelection($this->repository);
$httpVars = $request->getParsedBody();
- $selection->initFromHttpVars($httpVars);
+ $selection = UserSelection::fromContext($ctx, $httpVars);
if (!$selection->isEmpty()) {
- $this->filterUserSelectionToHidden($selection->getFiles());
+ $this->filterUserSelectionToHidden($ctx, $selection->getFiles());
}
$action = $request->getAttribute("action");
@@ -688,10 +684,9 @@ public function switchAction(ServerRequestInterface &$request, ResponseInterface
$action = $request->getAttribute("action");
$httpVars = $request->getParsedBody();
- $selection = new UserSelection($this->repository);
- $selection->initFromHttpVars($httpVars);
+ $selection = UserSelection::fromContext($ctx, $httpVars);
if (!$selection->isEmpty()) {
- $this->filterUserSelectionToHidden($selection->getFiles());
+ $this->filterUserSelectionToHidden($ctx, $selection->getFiles());
RecycleBinManager::filterActions($action, $selection, $httpVars);
}
$mess = ConfService::getMessages();
@@ -717,7 +712,7 @@ public function switchAction(ServerRequestInterface &$request, ResponseInterface
$loggedUser = $ctx->getUser();
if (isSet($httpVars["archive_name"])) {
$localName = Utils::decodeSecureMagic($httpVars["archive_name"]);
- $this->filterUserSelectionToHidden(array($localName));
+ $this->filterUserSelectionToHidden($ctx, array($localName));
} else {
$localName = (basename($dir)==""?"Files":basename($dir)).".zip";
}
@@ -883,7 +878,7 @@ public function switchAction(ServerRequestInterface &$request, ResponseInterface
if($selection->isUnique() && isSet($httpVars["targetBaseName"])){
$targetBaseName = $httpVars["targetBaseName"];
}
- $this->filterUserSelectionToHidden(array($httpVars["dest"]));
+ $this->filterUserSelectionToHidden($ctx, array($httpVars["dest"]));
if ($selection->inZip()) {
// Set action to copy anycase (cannot move from the zip).
$action = "copy";
@@ -961,7 +956,7 @@ public function switchAction(ServerRequestInterface &$request, ResponseInterface
$dest = Utils::decodeSecureMagic($httpVars["dest"]);
$filename_new = "";
}
- $this->filterUserSelectionToHidden(array($filename_new));
+ $this->filterUserSelectionToHidden($ctx, array($filename_new));
$this->rename($file, $filename_new, $dest);
$logMessage= new UserMessage(TextEncoder::toUTF8($file)." $mess[41] ".TextEncoder::toUTF8($filename_new));
if($dest == null) $dest = Utils::safeDirname($file);
@@ -990,7 +985,7 @@ public function switchAction(ServerRequestInterface &$request, ResponseInterface
$parentDir = Utils::safeDirname($newDirPath);
$basename = Utils::safeBasename($newDirPath);
$basename = substr($basename, 0, $max_length);
- $this->filterUserSelectionToHidden(array($basename));
+ $this->filterUserSelectionToHidden($ctx, array($basename));
try{
Controller::applyHook("node.before_create", array(new AJXP_Node($parentDir."/".$basename), -2));
}catch (PydioException $e){
@@ -1033,7 +1028,7 @@ public function switchAction(ServerRequestInterface &$request, ResponseInterface
$filename = $parent ."/" . Utils::decodeSecureMagic($httpVars["filename"], AJXP_SANITIZE_FILENAME);
}
$filename = substr($filename, 0, ConfService::getCoreConf("NODENAME_MAX_LENGTH"));
- $this->filterUserSelectionToHidden(array($filename));
+ $this->filterUserSelectionToHidden($ctx, array($filename));
$node = new AJXP_Node($this->urlBase."/".$filename);
$content = "";
if (isSet($httpVars["content"])) {
@@ -1170,7 +1165,7 @@ public function switchAction(ServerRequestInterface &$request, ResponseInterface
foreach($uniqueNodes as $node){
if(!file_exists($node->getUrl()) || (!is_readable($node->getUrl()) && !is_writable($node->getUrl()))) continue;
$nodeName = $node->getLabel();
- if (!$this->filterNodeName($node->getPath(), $nodeName, $isLeaf, $lsOptions)) {
+ if (!$this->filterNodeName($ctx, $node->getPath(), $nodeName, $isLeaf, $lsOptions)) {
continue;
}
if (RecycleBinManager::recycleEnabled() && $node->getPath() == RecycleBinManager::getRecyclePath()) {
@@ -1191,8 +1186,8 @@ public function switchAction(ServerRequestInterface &$request, ResponseInterface
$parentPath = Utils::safeDirname($node->getPath());
$siblings = scandir($this->urlBase.$parentPath);
foreach($siblings as $i => $s){
- if($this->filterFile($s, true)) unset($siblings[$i]);
- if($this->filterFolder($s)) unset($siblings[$i]);
+ if($this->filterFile($ctx, $s, true)) unset($siblings[$i]);
+ if($this->filterFolder($ctx, $s)) unset($siblings[$i]);
}
if(count($siblings) > $threshold){
//usort($siblings, "strcasecmp");
@@ -1240,7 +1235,7 @@ public function switchAction(ServerRequestInterface &$request, ResponseInterface
$nodesList->setParentNode($parentAjxpNode);
if (isSet($totalPages) && isSet($crtPage) && ($totalPages > 1 || ! Utils::userAgentIsNativePydioApp())) {
$remoteOptions = null;
- if ($this->getFilteredOption("REMOTE_SORTING")) {
+ if ($this->getContextualOption($ctx, "REMOTE_SORTING")) {
$remoteOptions = array(
"remote_order" => "true",
"currentOrderCol" => isSet($orderField)?$orderField:$defaultOrder,
@@ -1284,7 +1279,7 @@ public function switchAction(ServerRequestInterface &$request, ResponseInterface
continue;
}
$isLeaf = "";
- if (!$this->filterNodeName($path, $nodeName, $isLeaf, $lsOptions)) {
+ if (!$this->filterNodeName($ctx, $path, $nodeName, $isLeaf, $lsOptions)) {
continue;
}
if (RecycleBinManager::recycleEnabled() && $dir == "" && "/".$nodeName == RecycleBinManager::getRecyclePath()) {
@@ -1870,7 +1865,7 @@ public function date_modif($file)
return $tmp;// date("d,m L Y H:i:s",$tmp);
}
- public function extractArchiveItemPreCallback($status, $data){
+ public function extractArchiveItemPreCallback($status, $data, $taskId = null){
$fullname = $data['filename'];
$size = $data['size'];
$realBase = AJXP_MetaStreamWrapper::getRealFSReference($this->urlBase);
@@ -2362,8 +2357,9 @@ public function makePublicletOptions($filePath, $password, $expire, $downloadlim
return $data;
}
- public function makeSharedRepositoryOptions($httpVars, $repository)
+ public function makeSharedRepositoryOptions(ContextInterface $ctx, $httpVars)
{
+ $repository = $ctx->getRepository();
$newOptions = array(
"PATH" => TextEncoder::toStorageEncoding($repository->getOption("PATH")).Utils::decodeSecureMagic($httpVars["file"]),
"CREATE" => $repository->getOption("CREATE"),
@@ -174,7 +174,7 @@ protected function parseSpecificContributions(ContextInterface $ctx, \DOMNode &$
$this->disableArchiveBrowsingContributions($contribNode);
}
- public function filterNodeName($nodePath, $nodeName, &$isLeaf, $lsOptions)
+ public function filterNodeName(ContextInterface $contextInterface, $nodePath, $nodeName, &$isLeaf, $lsOptions)
{
return true;
}
@@ -237,9 +237,15 @@ public function loadNodeInfo(&$node, $parentNode = false, $details = false)
}
}
- public function makeSharedRepositoryOptions($httpVars, $repository)
+ /**
+ * @param ContextInterface $ctx
+ * @param array $httpVars
+ * @return array
+ * @throws \Exception
+ */
+ public function makeSharedRepositoryOptions(ContextInterface $ctx, $httpVars)
{
- $newOptions = parent::makeSharedRepositoryOptions($httpVars, $repository);
+ $newOptions = parent::makeSharedRepositoryOptions($ctx, $httpVars);
$newOptions["CONTAINER"] = $this->repository->getOption("CONTAINER");
return $newOptions;
}
@@ -127,9 +127,15 @@ public function isRemote()
return true;
}
- public function makeSharedRepositoryOptions($httpVars, $repository)
+ /**
+ * @param ContextInterface $ctx
+ * @param array $httpVars
+ * @return array
+ * @throws \Exception
+ */
+ public function makeSharedRepositoryOptions(ContextInterface $ctx, $httpVars)
{
- $newOptions = parent::makeSharedRepositoryOptions($httpVars, $repository);
+ $newOptions = parent::makeSharedRepositoryOptions($ctx, $httpVars);
$newOptions["CONTAINER"] = $this->repository->getOption("CONTAINER");
return $newOptions;
}
@@ -34,10 +34,11 @@ public function scanFile ($oldNode = null, $newNode = null)
// This block scans or doesn't scan the file. This is based on plugin parameters
+ $trace = $this->getContextualOption($newNode->getContext(), "TRACE");
if ($this->file_size < $this->scan_max_size) {
if ($this->scan_all == true) {
if ($this->inList()==true) {
- if ($this->getFilteredOption("TRACE") == false) {return;}
+ if ($trace === false) {return;}
$this->scanLater();
return ;
} else {
@@ -49,7 +50,7 @@ public function scanFile ($oldNode = null, $newNode = null)
$this->scanNow();
return ;
} else {
- if ($this->getFilteredOption("TRACE") == false) {return;}
+ if ($trace === false) {return;}
$this->scanLater();
return ;
}
@@ -34,8 +34,9 @@ class AvatarProvider extends Plugin
{
public function receiveAction(\Psr\Http\Message\ServerRequestInterface &$requestInterface, \Psr\Http\Message\ResponseInterface &$responseInterface)
{
- $provider = $this->getFilteredOption("AVATAR_PROVIDER");
- $type = $this->getFilteredOption("GRAVATAR_TYPE");
+ $ctx = $requestInterface->getAttribute("ctx");
+ $provider = $this->getContextualOption($ctx, "AVATAR_PROVIDER");
+ $type = $this->getContextualOption($ctx, "GRAVATAR_TYPE");
$httpVars = $requestInterface->getParsedBody();
if ($requestInterface->getAttribute("action") == "get_avatar_url") {
$suffix = "";
@@ -27,6 +27,7 @@
use Pydio\Access\Core\Model\AJXP_Node;
use Pydio\Access\Core\Model\Repository;
use Pydio\Access\Core\Model\UserSelection;
+use Pydio\Core\Model\ContextInterface;
use Pydio\Core\Services\AuthService;
use Pydio\Core\Services\ConfService;
use Pydio\Core\Controller\Controller;
@@ -326,11 +327,12 @@ public static function publicletToJson($shareId, $shareMeta, $shareStore, $publi
}
/**
+ * @param ContextInterface $ctx
* @param ShareCenter $shareCenter
* @param ShareStore $shareStore
* @param ShareRightsManager $shareRightManager
*/
- public static function migrateLegacyMeta($shareCenter, $shareStore, $shareRightManager, $dryRun = true){
+ public static function migrateLegacyMeta(ContextInterface $ctx, $shareCenter, $shareStore, $shareRightManager, $dryRun = true){
$metaStoreDir = AJXP_DATA_PATH."/plugins/metastore.serial";
$publicFolder = ConfService::getCoreConf("PUBLIC_DOWNLOAD_FOLDER");
// TODO 1: Check all metastores of all repositories?
Oops, something went wrong.

0 comments on commit 2a77d7b

Please sign in to comment.