public function bind(\Nethgui\Controller\RequestInterface $request) { parent::bind($request); $this->position = $this->bindPosition($request); if (intval($this->position) <= 0) { throw new \Nethgui\Exception\HttpException('Not found', 404, 1399992980); } $subrequest = $request->spawnRequest($this->position); if ($subrequest->hasParameter('f') || $subrequest->hasParameter('Submit')) { $this->workflow->resume($this->getParent()->getSession()); } else { // start a new workflow generating a random rule key $defaults = $this->getRuleDefaults(); foreach (array('SrcRaw', 'DstRaw', 'ServiceRaw', 'status', 'Description', 'LogType', 'Action') as $f) { if ($request->hasParameter($f)) { $defaults[$f] = $request->getParameter($f); } } $this->workflow->start($this->getParent()->getSession(), $this->getIdentifier(), $this->getIdentifier() . '/' . $this->position, $this->generateNextRuleId(), $defaults); } $this->worker->ruleId = $this->workflow->getRuleId(); $this->worker->bind($request); $this->workflow->copyTo($this->worker->parameters, array('SrcRaw', 'DstRaw', 'ServiceRaw', 'status', 'Description', 'LogType', 'Action')); if ($request->isMutation()) { $this->worker->parameters['Position'] = $this->position; } }
public function initialize() { parent::initialize(); /* @var $worker \Nethgui\Controller\AbstractController */ $this->worker = new RuleGenericController($this->getIdentifier()); $this->worker->initializeFromAction($this); $this->workflow = new \NethServer\Module\FirewallRules\RuleWorkflow(); }
public function prepareView(\Nethgui\View\ViewInterface $view) { parent::prepareView($view); $view->setTemplate('NethServer/Template/FirewallObjects/HostGroups/Modify'); if (!$this->getRequest()->isValidated()) { return; } if ($this->getRequest()->isMutation()) { $view->getCommandList()->sendQuery($view->getModuleUrl('../' . $this->state->getReturnPath())); } else { $view->getCommandList()->show(); } }
public function prepareView(\Nethgui\View\ViewInterface $view) { parent::prepareView($view); $r = array(); $actionLabels = array('accept' => $view->translate('ActionAccept_label'), 'reject' => $view->translate('ActionReject_label'), 'drop' => $view->translate('ActionDrop_label')); $actionIcons = array('accept' => 'fa-check-circle', 'drop' => 'fa-minus-circle', 'reject' => 'fa-shield'); foreach ($this->getAdapter() as $key => $values) { $values['id'] = (string) $key; $values['Position'] = isset($values['Position']) ? intval($values['Position']) : 0; $values['rawAction'] = $values['Action']; $values['ActionIcon'] = $actionIcons[$values['Action']]; $values['SrcIcon'] = $this->getObjectIcon($values['Src']); $values['DstIcon'] = $this->getObjectIcon($values['Dst']); if ($values['Service'] == 'any') { $values['ServiceIcon'] = ''; } else { $values['ServiceIcon'] = $this->getObjectIcon($values['Service']); } $values['Action'] = $actionLabels[$values['Action']]; $values['Edit'] = $view->getModuleUrl('../Edit/' . $key); $values['Copy'] = $view->getModuleUrl('../Copy/' . ($values['Position'] + 1) . '?id=' . $key); $values['RuleText'] = $view->translate('RuleText_label', array('Src' => $this->resolveEndpoint($values['Src'], $view), 'Dst' => $this->resolveEndpoint($values['Dst'], $view), 'Service' => $this->resolveService($values['Service'], $view))); $values['Src'] = $this->resolveName($values['Src'], $view); $values['Dst'] = $this->resolveName($values['Dst'], $view); $values['Service'] = $this->resolveService($values['Service']); $values['Delete'] = $view->getModuleUrl('../Delete/' . $key); $values['LogIcon'] = $values['Log'] != 'none' ? 'fa-book' : ''; $r[] = $values; } usort($r, function ($a, $b) { return $a['Position'] > $b['Position']; }); $positions = array_map(function ($v) { return $v['Position']; }, $r); $first = isset($positions[0]) ? $positions[0] / 2 : \NethServer\Module\FirewallRules::RULESTEP; $last = (end($positions) ? end($positions) : 0) + \NethServer\Module\FirewallRules::RULESTEP; $view['hasChanges'] = $this->hasChanges(); $view['Rules'] = $r; $view['Create_last'] = $view->getModuleUrl('../Create/' . intval($last)); $view['Create_first'] = $view->getModuleUrl('../Create/' . intval($first)); if ($this->getRequest()->isValidated()) { $view->getCommandList()->show(); } }
public function prepareView(\Nethgui\View\ViewInterface $view) { parent::prepareView($view); $view->setTemplate('NethServer/Template/FirewallObjects/Services/Modify'); $view['ProtocolDatasource'] = array_map(function ($fmt) use($view) { return array($fmt, $view->translate($fmt . '_label')); }, $this->protocols); if (!$this->getRequest()->isValidated()) { return; } if ($this->getRequest()->isMutation()) { $view->getCommandList()->sendQuery($view->getModuleUrl('../' . $this->state->getReturnPath())); } else { $view->getCommandList()->show(); } }
public function nextPath() { if ($this->getRequest()->isMutation()) { return '../Review'; } return parent::nextPath(); }
public function nextPath() { return $this->getRequest()->isMutation() ? 'Index' : parent::nextPath(); }
public function initializeFromAction(\Nethgui\Controller\Collection\AbstractAction $action) { $this->setParent($action->getParent())->setPlatform($action->getPlatform())->setPolicyDecisionPoint($action->getPolicyDecisionPoint())->setLog($action->getLog())->initialize(); return $this; }