Permalink
Browse files

Move all actions inside managers

  • Loading branch information...
1 parent 06dccba commit df96831843830f8a11d20fc55c3903f08c1d1874 @cdujeu cdujeu committed Jul 13, 2016
Oops, something went wrong.
Oops, something went wrong.
@@ -21,8 +21,12 @@
namespace Pydio\Access\Driver\DataProvider\Provisioning;
use Pydio\Access\Core\Model\NodesList;
+use Pydio\Core\Controller\XMLWriter;
use Pydio\Core\Model\ContextInterface;
+use Pydio\Core\PluginFramework\PluginsService;
+use Pydio\Core\Services\ConfService;
use Pydio\Core\Services\UsersService;
+use Pydio\Core\Utils\Vars\OptionsHelper;
defined('AJXP_EXEC') or die('Access not allowed');
@@ -42,6 +46,9 @@
/** @var string */
protected $pluginName;
+ /** @var bool */
+ protected $listSpecialRoles = AJXP_SERVER_DEBUG;
+
/**
* Manager constructor.
* @param ContextInterface $ctx
@@ -56,6 +63,9 @@ public function __construct(ContextInterface $ctx, $pluginName){
* @return bool
*/
protected function currentUserIsGroupAdmin(){
+ if(ConfService::getAuthDriverImpl()->isAjxpAdmin($this->context->getUser()->getId())){
+ return false;
+ }
return (UsersService::usersEnabled() && $this->context->getUser()->getGroupPath() !== "/");
}
@@ -88,6 +98,96 @@ protected function appendBookmarkMeta($nodePath, &$meta){
}
}
+
+ /**
+ * @param ContextInterface $ctx
+ * @param $repDef
+ * @param $options
+ * @param bool $globalBinaries
+ * @param array $existingValues
+ */
+ protected function parseParameters(ContextInterface $ctx, &$repDef, &$options, $globalBinaries = false, $existingValues = array())
+ {
+ OptionsHelper::parseStandardFormParameters($ctx, $repDef, $options, "DRIVER_OPTION_", ($globalBinaries ? array() : null));
+ if(!count($existingValues)){
+ return;
+ }
+ $this->mergeExistingParameters($options, $existingValues);
+ }
+
+ /**
+ * @param array $parsed
+ * @param array $existing
+ */
+ protected function mergeExistingParameters(&$parsed, $existing){
+ foreach($parsed as $k => &$v){
+ if($v === "__AJXP_VALUE_SET__" && isSet($existing[$k])){
+ $parsed[$k] = $existing[$k];
+ }else if(is_array($v) && is_array($existing[$k])){
+ $this->mergeExistingParameters($v, $existing[$k]);
+ }
+ }
+ }
+
+
+ /**
+ * @param ContextInterface $ctx
+ * @param $currentUserIsGroupAdmin
+ * @param bool $withLabel
+ * @return array
+ */
+ protected function getEditableParameters($ctx, $currentUserIsGroupAdmin, $withLabel = false){
+
+ $query = "//param|//global_param";
+ if($currentUserIsGroupAdmin){
+ $query = "//param[@scope]|//global_param[@scope]";
+ }
+
+ $nodes = PluginsService::getInstance($ctx)->searchAllManifests($query, "node", false, true, true);
+ $actions = array();
+ foreach ($nodes as $node) {
+ if($node->parentNode->nodeName != "server_settings") continue;
+ $parentPlugin = $node->parentNode->parentNode;
+ $pId = $parentPlugin->attributes->getNamedItem("id")->nodeValue;
+ if (empty($pId)) {
+ $pId = $parentPlugin->nodeName .".";
+ if($pId == "ajxpdriver.") $pId = "access.";
+ $pId .= $parentPlugin->attributes->getNamedItem("name")->nodeValue;
+ }
+ if(!is_array($actions[$pId])) $actions[$pId] = array();
+ $actionName = $node->attributes->getNamedItem("name")->nodeValue;
+ $attributes = array();
+ for( $i = 0; $i < $node->attributes->length; $i ++){
+ $att = $node->attributes->item($i);
+ $value = $att->nodeValue;
+ if(in_array($att->nodeName, array("choices", "description", "group", "label"))) {
+ $value = XMLWriter::replaceAjxpXmlKeywords($value);
+ }
+ $attributes[$att->nodeName] = $value;
+ }
+ if($withLabel){
+ $actions[$pId][$actionName] = array(
+ "parameter" => $actionName ,
+ "label" => $attributes["label"],
+ "attributes" => $attributes
+ );
+ }else{
+ $actions[$pId][] = $actionName;
+ }
+
+ }
+ foreach ($actions as $actPid => $actionGroup) {
+ ksort($actionGroup, SORT_STRING);
+ $actions[$actPid] = array();
+ foreach ($actionGroup as $v) {
+ $actions[$actPid][] = $v;
+ }
+ }
+ return $actions;
+ }
+
+
+
/**
* @param array $httpVars Full set of query parameters
* @param string $rootPath Path to prepend to the resulting nodes
@@ -20,9 +20,13 @@
*/
namespace Pydio\Access\Driver\DataProvider\Provisioning;
+use Psr\Http\Message\ResponseInterface;
+use Psr\Http\Message\ServerRequestInterface;
use Pydio\Access\Core\Model\AJXP_Node;
use Pydio\Access\Core\Model\NodesList;
use Pydio\Core\Utils\Reflection\DocsParser;
+use Pydio\Core\Utils\Reflection\PydioSdkGenerator;
+use Zend\Diactoros\Response\JsonResponse;
defined('AJXP_EXEC') or die('Access not allowed');
@@ -31,10 +35,22 @@
* Class HooksManager
* @package Pydio\Access\Driver\DataProvider\Provisioning
*/
-class HooksManager extends AbstractManager
+class DocumentationManager extends AbstractManager
{
/**
+ * @param ServerRequestInterface $requestInterface
+ * @param ResponseInterface $responseInterface
+ * @return ResponseInterface
+ */
+ public function docActions(ServerRequestInterface $requestInterface, ResponseInterface $responseInterface){
+
+ PydioSdkGenerator::analyzeRegistry(isSet($httpVars["version"])?$httpVars["version"]:AJXP_VERSION);
+
+ return new JsonResponse(["result"=>"ok"]);
+ }
+
+ /**
* @param array $httpVars Full set of query parameters
* @param string $rootPath Path to prepend to the resulting nodes
* @param string $relativePath Specific path part for this function
Oops, something went wrong.

0 comments on commit df96831

Please sign in to comment.