Permalink
Browse files

Add an order parameter when registering the metaWrappers to allow a s…

…imple sorting.
  • Loading branch information...
1 parent 9dda916 commit 2d67e8c9e26c4b0fa1c35214a28542a0fc9332ad @cdujeu cdujeu committed Sep 29, 2016
@@ -113,7 +113,7 @@ protected function initRepository(ContextInterface $contextInterface)
$chmod = $repository->getContextOption($contextInterface, "CHMOD_VALUE");
$this->urlBase = $contextInterface->getUrlBase();
- MetaStreamWrapper::appendMetaWrapper("pydio.encoding", "Pydio\\Access\\Core\\EncodingWrapper");
+ MetaStreamWrapper::appendMetaWrapper("pydio.encoding", "Pydio\\Access\\Core\\EncodingWrapper", 100);
if ($create == true) {
if(!is_dir($storagePath)) @mkdir($storagePath, 0755, true);
@@ -24,6 +24,7 @@
use Normalizer;
use Pydio\Access\Core\Filter\ContentFilter;
use Pydio\Access\Core\Model\AJXP_Node;
+use Pydio\Core\Exception\PydioException;
use Pydio\Core\Model\ContextInterface;
use Pydio\Core\PluginFramework\PluginsService;
@@ -55,7 +56,13 @@ class MetaStreamWrapper implements IAjxpWrapper
protected static $metaWrappers = [
'core' => [
'pydio' => 'Pydio\Access\Core\MetaStreamWrapper'
- ]
+ ],
+ ];
+
+ protected static $metaWrappersOrders = [
+ 'core' => [
+ 'pydio' => 0
+ ],
];
protected static $cachedRepositoriesWrappers = array();
@@ -110,9 +117,23 @@ public static function detectWrapperForNode(AJXP_Node $node, $register = false,
* Register an addition protocol/wrapper in the stack
* @param $name string
* @param $className string
+ * @param int $order
+ * @param string $parent
+ * @throws PydioException
*/
- public static function appendMetaWrapper($name, $className, $parent = "core"){
+ public static function appendMetaWrapper($name, $className, $order = 50, $parent = "core"){
+ if($order === 0){
+ throw new PydioException("Invalid argument: cannot use order 0 for registering a meta-wrapper.");
+ }
self::$metaWrappers[$parent][$name] = $className;
+ self::$metaWrappersOrders[$parent][$name] = $order;
+ $orders = self::$metaWrappersOrders[$parent];
+ uksort(self::$metaWrappers[$parent], function($a, $b) use ($orders){
+ $oA = $orders[$a];
+ $oB = $orders[$b];
+ if($oA === $oB) return 0;
+ return $oA > $oB ? 1 : -1;
+ });
self::register();
}
@@ -216,6 +216,7 @@ public function sendInstantMessage(ContextInterface $ctx, $xmlContent, $targetUs
if (!$ctx->hasRepository()) {
$userId = $targetUserId;
+ $gPath = $targetGroupPath;
} else {
$scope = RepositoryService::getRepositoryById($repositoryId)->securityScope();
if ($scope == "USER") {
@@ -243,6 +244,9 @@ public function sendInstantMessage(ContextInterface $ctx, $xmlContent, $targetUs
$message->nodePaths = $nodePaths;
}
+ if($repositoryId === null && (isset($userId) || isSet($gPath))){
+ $repositoryId = "*";
+ }
if ($this->msgExchanger) {
$this->msgExchanger->publishInstantMessage($ctx, "nodes:$repositoryId", $message);
}
@@ -489,7 +493,7 @@ public function revokeAdminKey($params, $ctx){
if(!$u->isAdmin()){
return "ERROR: You are not administrator";
}
- $c = ApiKeysService::revokePairForAdminTask(PYDIO_BOOSTER_TASK_IDENTIFIER, $u->getId());
+ $c = ApiKeysService::revokePairForAdminTask(PYDIO_BOOSTER_TASK_IDENTIFIER);
if($c > 0){
return "SUCCESS: Successfully revoked $c pair of keys. You may have to generate new ones and reload PydioBooster.";
}else{

0 comments on commit 2d67e8c

Please sign in to comment.