Inheritance: extends Form
Esempio n. 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();
 }
Esempio n. 2
0
 /**
  * Update a newly created user's roles
  * @param $args array
  * @param $request PKPRequest
  * @return string Serialized JSON object
  */
 function updateUserRoles($args, $request)
 {
     $user = $request->getUser();
     // Identify the user Id.
     $userId = $request->getUserVar('userId');
     if ($userId !== null && !Validation::canAdminister($userId, $user->getId())) {
         // We don't have administrative rights over this user.
         $json = new JSONMessage(false, __('grid.user.cannotAdminister'));
     } else {
         // Form handling.
         import('lib.pkp.controllers.grid.settings.user.form.UserRoleForm');
         $userRoleForm = new UserRoleForm($userId, $user->getFullName());
         $userRoleForm->readInputData();
         if ($userRoleForm->validate()) {
             $userRoleForm->execute($args, $request);
             // Successfully managed newly created user's roles.
             return DAO::getDataChangedEvent($userId);
         } else {
             $json = new JSONMessage(false);
         }
     }
     return $json->getString();
 }