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

Commit

Permalink
Move all actions inside managers
Browse files Browse the repository at this point in the history
  • Loading branch information
cdujeu committed Jul 13, 2016
1 parent 06dccba commit df96831
Show file tree
Hide file tree
Showing 9 changed files with 2,725 additions and 2,469 deletions.
2,234 changes: 153 additions & 2,081 deletions core/src/plugins/access.ajxp_conf/ConfAccessDriver.php

Large diffs are not rendered by default.

773 changes: 389 additions & 384 deletions core/src/plugins/access.ajxp_conf/ajxp_confActions.xml

Large diffs are not rendered by default.

100 changes: 100 additions & 0 deletions core/src/plugins/access.ajxp_conf/src/AbstractManager.php
Expand Up @@ -21,8 +21,12 @@
namespace Pydio\Access\Driver\DataProvider\Provisioning; namespace Pydio\Access\Driver\DataProvider\Provisioning;


use Pydio\Access\Core\Model\NodesList; use Pydio\Access\Core\Model\NodesList;
use Pydio\Core\Controller\XMLWriter;
use Pydio\Core\Model\ContextInterface; use Pydio\Core\Model\ContextInterface;
use Pydio\Core\PluginFramework\PluginsService;
use Pydio\Core\Services\ConfService;
use Pydio\Core\Services\UsersService; use Pydio\Core\Services\UsersService;
use Pydio\Core\Utils\Vars\OptionsHelper;


defined('AJXP_EXEC') or die('Access not allowed'); defined('AJXP_EXEC') or die('Access not allowed');


Expand All @@ -42,6 +46,9 @@ abstract class AbstractManager
/** @var string */ /** @var string */
protected $pluginName; protected $pluginName;


/** @var bool */
protected $listSpecialRoles = AJXP_SERVER_DEBUG;

/** /**
* Manager constructor. * Manager constructor.
* @param ContextInterface $ctx * @param ContextInterface $ctx
Expand All @@ -56,6 +63,9 @@ public function __construct(ContextInterface $ctx, $pluginName){
* @return bool * @return bool
*/ */
protected function currentUserIsGroupAdmin(){ protected function currentUserIsGroupAdmin(){
if(ConfService::getAuthDriverImpl()->isAjxpAdmin($this->context->getUser()->getId())){
return false;
}
return (UsersService::usersEnabled() && $this->context->getUser()->getGroupPath() !== "/"); return (UsersService::usersEnabled() && $this->context->getUser()->getGroupPath() !== "/");
} }


Expand Down Expand Up @@ -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 array $httpVars Full set of query parameters
* @param string $rootPath Path to prepend to the resulting nodes * @param string $rootPath Path to prepend to the resulting nodes
Expand Down
Expand Up @@ -20,9 +20,13 @@
*/ */
namespace Pydio\Access\Driver\DataProvider\Provisioning; 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\AJXP_Node;
use Pydio\Access\Core\Model\NodesList; use Pydio\Access\Core\Model\NodesList;
use Pydio\Core\Utils\Reflection\DocsParser; 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'); defined('AJXP_EXEC') or die('Access not allowed');


Expand All @@ -31,9 +35,21 @@
* Class HooksManager * Class HooksManager
* @package Pydio\Access\Driver\DataProvider\Provisioning * @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 array $httpVars Full set of query parameters
* @param string $rootPath Path to prepend to the resulting nodes * @param string $rootPath Path to prepend to the resulting nodes
Expand Down

0 comments on commit df96831

Please sign in to comment.