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

Commit 2d67e8c

Browse files
committed
Add an order parameter when registering the metaWrappers to allow a simple sorting.
1 parent 9dda916 commit 2d67e8c

File tree

3 files changed

+29
-4
lines changed

3 files changed

+29
-4
lines changed

core/src/plugins/access.fs/FsAccessDriver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ protected function initRepository(ContextInterface $contextInterface)
113113
$chmod = $repository->getContextOption($contextInterface, "CHMOD_VALUE");
114114
$this->urlBase = $contextInterface->getUrlBase();
115115

116-
MetaStreamWrapper::appendMetaWrapper("pydio.encoding", "Pydio\\Access\\Core\\EncodingWrapper");
116+
MetaStreamWrapper::appendMetaWrapper("pydio.encoding", "Pydio\\Access\\Core\\EncodingWrapper", 100);
117117

118118
if ($create == true) {
119119
if(!is_dir($storagePath)) @mkdir($storagePath, 0755, true);

core/src/plugins/core.access/src/MetaStreamWrapper.php

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
use Normalizer;
2525
use Pydio\Access\Core\Filter\ContentFilter;
2626
use Pydio\Access\Core\Model\AJXP_Node;
27+
use Pydio\Core\Exception\PydioException;
2728
use Pydio\Core\Model\ContextInterface;
2829

2930
use Pydio\Core\PluginFramework\PluginsService;
@@ -55,7 +56,13 @@ class MetaStreamWrapper implements IAjxpWrapper
5556
protected static $metaWrappers = [
5657
'core' => [
5758
'pydio' => 'Pydio\Access\Core\MetaStreamWrapper'
58-
]
59+
],
60+
];
61+
62+
protected static $metaWrappersOrders = [
63+
'core' => [
64+
'pydio' => 0
65+
],
5966
];
6067

6168
protected static $cachedRepositoriesWrappers = array();
@@ -110,9 +117,23 @@ public static function detectWrapperForNode(AJXP_Node $node, $register = false,
110117
* Register an addition protocol/wrapper in the stack
111118
* @param $name string
112119
* @param $className string
120+
* @param int $order
121+
* @param string $parent
122+
* @throws PydioException
113123
*/
114-
public static function appendMetaWrapper($name, $className, $parent = "core"){
124+
public static function appendMetaWrapper($name, $className, $order = 50, $parent = "core"){
125+
if($order === 0){
126+
throw new PydioException("Invalid argument: cannot use order 0 for registering a meta-wrapper.");
127+
}
115128
self::$metaWrappers[$parent][$name] = $className;
129+
self::$metaWrappersOrders[$parent][$name] = $order;
130+
$orders = self::$metaWrappersOrders[$parent];
131+
uksort(self::$metaWrappers[$parent], function($a, $b) use ($orders){
132+
$oA = $orders[$a];
133+
$oB = $orders[$b];
134+
if($oA === $oB) return 0;
135+
return $oA > $oB ? 1 : -1;
136+
});
116137
self::register();
117138
}
118139

core/src/plugins/core.mq/src/MqManager.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ public function sendInstantMessage(ContextInterface $ctx, $xmlContent, $targetUs
216216

217217
if (!$ctx->hasRepository()) {
218218
$userId = $targetUserId;
219+
$gPath = $targetGroupPath;
219220
} else {
220221
$scope = RepositoryService::getRepositoryById($repositoryId)->securityScope();
221222
if ($scope == "USER") {
@@ -243,6 +244,9 @@ public function sendInstantMessage(ContextInterface $ctx, $xmlContent, $targetUs
243244
$message->nodePaths = $nodePaths;
244245
}
245246

247+
if($repositoryId === null && (isset($userId) || isSet($gPath))){
248+
$repositoryId = "*";
249+
}
246250
if ($this->msgExchanger) {
247251
$this->msgExchanger->publishInstantMessage($ctx, "nodes:$repositoryId", $message);
248252
}
@@ -489,7 +493,7 @@ public function revokeAdminKey($params, $ctx){
489493
if(!$u->isAdmin()){
490494
return "ERROR: You are not administrator";
491495
}
492-
$c = ApiKeysService::revokePairForAdminTask(PYDIO_BOOSTER_TASK_IDENTIFIER, $u->getId());
496+
$c = ApiKeysService::revokePairForAdminTask(PYDIO_BOOSTER_TASK_IDENTIFIER);
493497
if($c > 0){
494498
return "SUCCESS: Successfully revoked $c pair of keys. You may have to generate new ones and reload PydioBooster.";
495499
}else{

0 commit comments

Comments
 (0)