示例#1
0
文件: manager.php 项目: cepharum/txf
 /**
  * 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;
 }