display() public method

Display the form.
public display ( $args, $request )
$args array
$request PKPRequest
Ejemplo n.º 1
0
 /**
  * Update an existing user
  * @param $args array
  * @param $request PKPRequest
  * @return string Serialized JSON object
  */
 function updateUser($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.UserForm');
         $userForm = new UserForm($userId);
         $userForm->readInputData();
         if ($userForm->validate()) {
             $user =& $userForm->execute($args, $request);
             // If this is a newly created user, show role management form
             if (!$userId) {
                 import('controllers.grid.users.user.form.UserRoleForm');
                 $userRoleForm = new UserRoleForm($user->getId());
                 $userRoleForm->initData($args, $request);
                 $json = new JSON('false', $userRoleForm->display($args, $request));
             } else {
                 // Successful edit of an existing user
                 // 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();
 }
Ejemplo n.º 2
0
 /**
  * Update an existing user.
  * @param $args array
  * @param $request PKPRequest
  * @return string Serialized JSON object
  */
 function updateUser($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.
         $userForm = new UserDetailsForm($request, $userId);
         $userForm->readInputData();
         if ($userForm->validate()) {
             $user = $userForm->execute($args, $request);
             // If this is a newly created user, show role management form.
             if (!$userId) {
                 import('lib.pkp.controllers.grid.settings.user.form.UserRoleForm');
                 $userRoleForm = new UserRoleForm($user->getId(), $user->getFullName());
                 $userRoleForm->initData($args, $request);
                 $json = new JSONMessage(true, $userRoleForm->display($args, $request));
             } else {
                 // Successful edit of an existing user.
                 $notificationManager = new NotificationManager();
                 $user = $request->getUser();
                 $notificationManager->createTrivialNotification($user->getId(), NOTIFICATION_TYPE_SUCCESS, array('contents' => __('notification.editedUser')));
                 // Prepare the grid row data.
                 return DAO::getDataChangedEvent($userId);
             }
         } else {
             $json = new JSONMessage(false);
         }
     }
     return $json->getString();
 }