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 resumeView(\Nethgui\View\ViewInterface $view)
 {
     $session = $this->getParent()->getSession();
     $vs = new \ArrayObject();
     $this->state->resume($session)->copyTo($vs, iterator_to_array($session->retrieve(__CLASS__)));
     call_user_func($this->resumeCallback, $view, $vs);
 }
 public function process()
 {
     parent::process();
     if ($this->getRequest()->isMutation()) {
         $this->getPlatform()->getDatabase('hosts')->setKey($this->parameters['name'], 'host-group', array('Description' => $this->parameters['Description'], 'Members' => implode(',', is_array($this->parameters['Members']) ? $this->parameters['Members'] : array())));
         $this->state->resume($this->getParent()->getSession())->assign(sprintf("host-group;%s", $this->parameters['name']));
     }
 }
 public function process()
 {
     parent::process();
     if ($this->getRequest()->isMutation()) {
         $this->getPlatform()->getDatabase('hosts')->setKey($this->parameters['name'], 'iprange', array('Description' => $this->parameters['Description'], 'Start' => $this->parameters['Start'], 'End' => $this->parameters['End']));
         $this->state->resume($this->getParent()->getSession())->assign(sprintf("iprange;%s", $this->parameters['name']));
     }
 }
 public function process()
 {
     parent::process();
     if ($this->getRequest()->isMutation()) {
         $this->getPlatform()->getDatabase('fwservices')->setKey($this->parameters['name'], 'fwservice', array('Description' => $this->parameters['Description'], 'Protocol' => $this->parameters['Protocol'], 'Ports' => $this->parameters['Ports']));
         $this->state->resume($this->getParent()->getSession())->assign(sprintf("fwservice;%s", $this->parameters['name']));
     }
 }
 public function process()
 {
     parent::process();
     if ($this->getRequest()->isMutation()) {
         $this->getPlatform()->getDatabase('networks')->setKey($this->parameters['name'], 'zone', array('Description' => $this->parameters['Description'], 'Interface' => $this->parameters['Interface'], 'Network' => $this->parameters['Network']));
         $this->state->resume($this->getParent()->getSession())->assign(sprintf("zone;%s", $this->parameters['name']));
     }
 }
Example #7
0
 public function bind(\Nethgui\Controller\RequestInterface $request)
 {
     $ruleId = \Nethgui\array_head($request->getPath());
     if (!$this->getAdapter()->offsetExists($ruleId)) {
         throw new \Nethgui\Exception\HttpException('Not found', 404, 1399992975);
     }
     $this->worker->ruleId = $ruleId;
     $this->worker->bind($request);
     $subrequest = $request->spawnRequest($ruleId);
     if ($subrequest->hasParameter('f') || $subrequest->hasParameter('Submit')) {
         // resume values from
         $this->workflow->resume($this->getParent()->getSession())->copyTo($this->worker->parameters, array('SrcRaw', 'DstRaw', 'ServiceRaw', 'status', 'Description', 'LogType', 'Action'));
     } else {
         // start new workflow
         $defaults = array();
         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(), 'Edit/' . $ruleId, $ruleId, $defaults);
     }
 }