public function bind(\Nethgui\Controller\RequestInterface $request) { $keyValue = \Nethgui\array_head($request->getPath()); $this->getAdapter()->setKeyValue($keyValue); parent::bind($request); $this->parameters['active'] = $this->getIdentifier() === 'enable' ? 'YES' : 'NO'; }
public function bind(\Nethgui\Controller\RequestInterface $request) { $user = $request->getUser(); $isAdmin = $user->hasCredential('username') && in_array($user->getCredential('username'), array('admin', 'root')) || $user->hasCredential('groups') && in_array('adm', $user->getCredential('groups')); $this->loadChildrenDirectory($this, $isAdmin ? 'Dashboard' : 'UserDashboard'); $this->sortChildren(array($this, "sortPlugin")); parent::bind($request); }
public function bind(\Nethgui\Controller\RequestInterface $request) { if (!$request->getUser()->getCredential('username') === 'root') { throw new \Nethgui\Exception\HttpException('Not found', 404, 1417136236); } $this->setUserName('root'); parent::bind($request); }
public function bind(\Nethgui\Controller\RequestInterface $request) { if (!$request->isMutation() && $this->getPlatform()->getDatabase('SESSION')->getKey($this->sessionKey)) { // Clear the session key when starting a new wizard $this->getPlatform()->getDatabase('SESSION')->deleteKey($this->sessionKey); } parent::bind($request); }
/** * Pass the request object and path segments to all of its children * * @param \Nethgui\Controller\RequestInterface $request */ public function bind(\Nethgui\Controller\RequestInterface $request) { foreach ($this->getChildren() as $module) { if ($module instanceof \Nethgui\Controller\RequestHandlerInterface) { $module->bind($request->spawnRequest($module->getIdentifier())); } } }
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, 1399992974); } parent::bind($request); $this->parameters['ruleId'] = $ruleId; }
protected function bindPosition(\Nethgui\Controller\RequestInterface $request) { $A = $this->getAdapter(); $position = \Nethgui\array_head($request->getPath()); $id = $request->spawnRequest($position)->getParameter('id'); if (isset($id, $A[$id])) { $this->copyDefaults = \iterator_to_array($A[$id]); } return $position; }
public function bind(\Nethgui\Controller\RequestInterface $request) { $keyValue = \Nethgui\array_head($request->getPath()); $A = $this->getParent()->getAdapter(); if (!isset($A[$keyValue])) { throw new \Nethgui\Exception\HttpException('Not found', 404, 1399033549); } if (isset($A[$keyValue]['role']) && in_array($A[$keyValue]['role'], array('bridged', 'slave', 'alias'))) { throw new \Nethgui\Exception\HttpException('Not found', 404, 1399033550); } $this->getAdapter()->setKeyValue($keyValue); parent::bind($request); }
private function authorize(\Nethgui\Controller\RequestInterface $request) { foreach ($this->getChildren() as $child) { if ($request->isMutation()) { $auth = $this->getPolicyDecisionPoint()->authorize($request->getUser(), $child, self::ACTION_MUTATE); } else { $auth = $this->getPolicyDecisionPoint()->authorize($request->getUser(), $child, self::ACTION_QUERY); } if ($auth->isDenied()) { throw $auth->asException(1327499272); } } }
public function bind(\Nethgui\Controller\RequestInterface $request) { $keyValue = \Nethgui\array_head($request->getPath()); $adapter = $this->getParent()->getAdapter(); if (!isset($adapter[$keyValue])) { throw new \Nethgui\Exception\HttpException('Not found', 404, 1399456905); } if (!in_array($adapter[$keyValue]['type'], array('bridge', 'bond', 'alias', 'vlan', 'xdsl'))) { throw new \Nethgui\Exception\HttpException('Not found', 404, 1399456906); } parent::bind($request); $this->parameters['type'] = $adapter[$keyValue]['type']; $this->parameters['device'] = $keyValue; }
public function bind(\Nethgui\Controller\RequestInterface $request) { $keyValue = \Nethgui\array_head($request->getPath()); $adapter = $this->getParent()->getAdapter(); if (!isset($adapter[$keyValue])) { throw new \Nethgui\Exception\HttpException('Not found', 404, 1399456808); } $props = $adapter[$keyValue]; if ($props['type'] !== 'ethernet') { throw new \Nethgui\Exception\HttpException('Not found', 404, 1399456809); } parent::bind($request); $this->parameters['device'] = $keyValue; }
/** * Overrides Composite bind() method, defining what is the current action * and forwarding the call to it. * * @param \Nethgui\Controller\RequestInterface $request */ public function bind(\Nethgui\Controller\RequestInterface $request) { $this->request = $request; $actionId = $this->establishCurrentActionId(); if ($actionId === FALSE) { return; // don't bind the request to any action. Render action index. } $this->currentAction = $this->getAction($actionId); if (is_null($this->currentAction)) { throw new \Nethgui\Exception\HttpException('Not Found', 404, 1322148401); } if ($this->currentAction instanceof \Nethgui\Controller\RequestHandlerInterface) { $this->currentAction->bind($request->spawnRequest($actionId)); } }
public function bind(\Nethgui\Controller\RequestInterface $request) { $userName = $request->getUser()->getCredential('username'); if ($userName === 'admin' && $this->getPlatform()->getDatabase('accounts')->getType('admin') !== 'user') { # Fake admin user, fallback to root. $userName = '******'; } // The root user needs a different data source: if ($userName === 'root') { $this->adapter = $this->getPlatform()->getTableAdapter('configuration', 'configuration'); } else { $this->adapter = $this->getPlatform()->getTableAdapter('accounts', 'user'); } // Inject username-dependent datasource into the record adapter $this->recordAdapter->setTableData($this->adapter)->setKeyValue($userName); parent::bind($request); }
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); } }
protected function bindPosition(\Nethgui\Controller\RequestInterface $request) { return \Nethgui\array_head($request->getPath()); }
public function bind(\Nethgui\Controller\RequestInterface $request) { $keyValue = '/' . implode('/', $request->getPath()); $this->getAdapter()->setKeyValue($keyValue); parent::bind($request); }
/** * * @param \Nethgui\Controller\RequestInterface $originalRequest * @return \Nethgui\Module\Menu */ public function setCurrentModuleIdentifier(\Nethgui\Controller\RequestInterface $originalRequest) { $this->currentItem = \Nethgui\array_head($originalRequest->getPath()); return $this; }
/** * Forwards control to Modules and creates output views. * * This is the framework "main()" function / entry point. * * @api * @param \Nethgui\Controller\RequestInterface $request * @param array $output DEPRECATED since 1.6 * @return integer DEPRECATED since 1.6 */ public function dispatch(\Nethgui\Controller\RequestInterface $request, &$output = NULL) { /* @var $log \Nethgui\Log\LogInterface */ $log = $this->dc['Log']; $this->dc['OriginalRequest'] = $request; if ($request instanceof \Nethgui\Utility\SessionConsumerInterface) { $request->setSession($this->dc['Session']); } try { $response = $this->handle($request); } catch (\Nethgui\Exception\HttpException $ex) { // no processing is required, rethrow: throw $ex; } catch (\Nethgui\Exception\AuthorizationException $ex) { if ($request->getExtension() === 'xhtml' && !$request->isMutation() && !$request->getUser()->isAuthenticated()) { $response = $this->handle($this->createLoginRequest($request)); } else { $log->error(sprintf('%s: [%d] %s', __CLASS__, $ex->getCode(), $ex->getMessage())); throw new \Nethgui\Exception\HttpException('Forbidden', 403, 1327681977, $ex); } } catch (\Exception $ex) { $log->exception($ex, NETHGUI_DEBUG); throw new \Nethgui\Exception\HttpException('Internal server error', 500, 1366796122, $ex); } $response->send(); }
/** * Calculate the key value for a new record from the given $request * object. * * Override this function whenever the key value requires some kind of * processing to be calculated. * * @api * @param \Nethgui\Controller\RequestInterface $request * @return string */ protected function calculateKeyFromRequest(\Nethgui\Controller\RequestInterface $request) { return $request->getParameter($this->getKey()); }
public function bind(\Nethgui\Controller\RequestInterface $request) { $this->request = $request; foreach ($this->parameters->getKeys() as $parameterName) { if ($request->hasParameter($parameterName)) { $this->parameters[$parameterName] = $request->getParameter($parameterName); } } }
protected function calculateKeyFromRequest(\Nethgui\Controller\RequestInterface $request) { return trim($request->getParameter('localAddress')) . '@' . $request->getParameter('domainAddress'); }
public function bind(\Nethgui\Controller\RequestInterface $request) { $this->setUserName(\Nethgui\array_end($request->getPath())); parent::bind($request); }