Exemple #1
0
 public function save($updateOnly = false)
 {
     // Allow an exception to be thrown.
     try {
         // If user is made a Super Admin group and user is NOT a Super Admin
         //
         // @todo ACL - this needs to be acl checked
         //
         $my = MFactory::getUser();
         //are we creating a new user
         $isNew = empty($this->id);
         // If we aren't allowed to create new users return
         if ($isNew && $updateOnly) {
             return true;
         }
         // Get the old user
         $oldUser = new MUser($this->id);
         // Fire the onUserBeforeSave event.
         MPluginHelper::importPlugin('user');
         $dispatcher = MDispatcher::getInstance();
         $result = $dispatcher->trigger('onUserBeforeSave', array($oldUser->getProperties(), $isNew, $this->getProperties()));
         if (in_array(false, $result, true)) {
             // Plugin will have to raise its own error or throw an exception.
             return false;
         }
         //////////////////////////////////////
         //todo:: update old user
         //////////////////////////////////////
         register_new_user($this->username, $this->email);
         // Fire the onUserAfterSave event
         $dispatcher->trigger('onUserAfterSave', array($this->getProperties(), $isNew, $result, $this->getError()));
     } catch (Exception $e) {
         $this->setError($e->getMessage());
         return false;
     }
     return $result;
 }