Exemplo n.º 1
0
 /**
  * Processes input of widget updating its internal state.
  *
  * @return widget current instance
  */
 public function processInput()
 {
     if (user::current()->isAuthenticated()) {
         user::dropCurrent();
     }
     view::flash(\de\toxa\txf\_L('You logged out successfully.'));
     $referrer = input::vget('referrer');
     $referrer = url::isRelative($referrer) ? $referrer : null;
     txf::redirectTo(\de\toxa\txf\_1($referrer, 'home'));
 }
Exemplo n.º 2
0
 /**
  * Processes input of widget updating its internal state.
  *
  * @throws http_exception on unauthorized access for page editor
  * @return $this current instance
  */
 public function processInput()
 {
     if ($this->mayEdit && $this->wantEdit) {
         $editor = $this->getEditor();
         if ($editor->processInput()) {
             // editor has been closed ...
             if ($this->viewerUrl) {
                 txf::redirectTo(sprintf($this->viewerUrl, $this->pageName));
             } else {
                 $this->wantEdit = false;
                 $this->getPage(true);
             }
         }
     } else {
         if (!$this->mayEdit && $this->wantEdit) {
             throw new http_exception(403);
         }
     }
     return $this;
 }
Exemplo n.º 3
0
 /**
  * Processes input of widget updating its internal state.
  *
  * @throws http_exception on trying to use widget without authorization
  * @return $this current instance
  */
 public function processInput()
 {
     if (!$this->isUserAuthorized()) {
         throw new http_exception(403, \de\toxa\txf\_L('You must not manage users!'));
     }
     $provider = user::getProvider();
     if (!$provider instanceof sql_user) {
         throw new http_exception(400, \de\toxa\txf\_L('This manager is suitable for managing SQL-based users, only!'));
     }
     list($action, $userId) = $this->detectMode();
     if ($this->isListing()) {
         $this->getBrowser()->processInput();
     } else {
         switch ($action) {
             case 'edit':
             case 'add':
                 $this->processInputOnEditing($provider, $userId);
                 break;
             case 'delete':
                 if ($userId === user::current()->getID()) {
                     throw new http_exception(403, \de\toxa\txf\_L('Deleting current user account rejected.'));
                 }
                 user::load($userId)->delete();
                 txf::redirectTo($this->getUrls()->list);
                 break;
             default:
                 // TODO implement all else actions (lock, unlock, ...)
                 txf::redirectTo($this->getUrls()->list);
         }
     }
     return $this;
 }
Exemplo n.º 4
0
 public function performDelete()
 {
     if (!user::current()->isAuthenticated()) {
         throw new http_exception(403);
     }
     $this->prepareControl();
     try {
         $this->getSelectedItem()->delete();
     } catch (datasource_exception $e) {
         view::flash(\de\toxa\txf\_L('Failed deleting selected item.'), 'error');
     } catch (\RuntimeException $e) {
         view::flash(\de\toxa\txf\_L('Selected item does not exist (anymore).'), 'error');
     }
     txf::redirectTo($this->getUrls()->list);
 }
Exemplo n.º 5
0
 /**
  * Renders previously registered flash messages.
  */
 protected static function renderFlashes()
 {
     $session =& txf::session(\de\toxa\txf\session::SCOPE_GLOBAL);
     if (is_array(@$session['view']) && is_array(@$session['view']['flashes'])) {
         foreach ($session['view']['flashes'] as $context => $messages) {
             if (is_array($messages) && count($messages)) {
                 self::viewport('flash', \de\toxa\txf\markup::flash($context, $messages));
             }
         }
         unset($session['view']['flashes']);
     }
 }
Exemplo n.º 6
0
 protected function redirect()
 {
     $session =& txf::session();
     $target = \de\toxa\txf\_1(@$session['referrer'], 'home');
     unset($session['referrer']);
     txf::redirectTo($target);
 }