UserRoleForm::execute PHP Method

execute() public method

Update user's roles.
public execute ( $args, $request )
$args array
$request PKPRequest
    function execute($args, $request)
    {
        parent::execute($request);
        // Role management handled by parent form, just return user.
        $userDao = DAORegistry::getDAO('UserDAO');
        return $userDao->getById($this->userId);
    }

Usage Example

Example #1
0
 /**
  * Update a newly created user's roles
  * @param $args array
  * @param $request PKPRequest
  * @return string Serialized JSON object
  */
 function updateUserRoles($args, &$request)
 {
     // Identify the press
     $press =& $request->getPress();
     // Identify the user Id
     $userId = $request->getUserVar('userId');
     if ($userId !== null && !Validation::canAdminister($press->getId(), $userId)) {
         // We don't have administrative rights over this user.
         $json = new JSON('false', Locale::translate('grid.user.cannotAdminister'));
     } else {
         // Form handling
         import('controllers.grid.users.user.form.UserRoleForm');
         $userRoleForm = new UserRoleForm($userId);
         $userRoleForm->readInputData();
         if ($userRoleForm->validate()) {
             $user =& $userRoleForm->execute($args, $request);
             // Successfully managed newly created user's roles
             // Prepare the grid row data
             $row =& $this->getRowInstance();
             $row->setGridId($this->getId());
             $row->setId($user->getId());
             $row->setData($user);
             $row->initialize($request);
             $json = new JSON('true', $this->_renderRowInternally($request, $row));
         } else {
             $json = new JSON('false', $userForm->display($args, $request));
         }
     }
     return $json->getString();
 }
All Usage Examples Of UserRoleForm::execute