Inheritance: extends UserForm
コード例 #1
0
 /**
  * Add a user with data initialized from an existing author.
  * @param $args array
  * @param $request PKPRequest
  * @return JSONMessage JSON object
  */
 function addUser($args, $request)
 {
     // Identify the author Id.
     $authorId = $request->getUserVar('authorId');
     $authorDao = DAORegistry::getDAO('AuthorDAO');
     $userDao = DAORegistry::getDAO('UserDAO');
     $author = $authorDao->getById($authorId);
     if ($author !== null && $userDao->userExistsByEmail($author->getEmail())) {
         // We don't have administrative rights over this user.
         return new JSONMessage(false, __('grid.user.cannotAdminister'));
     } else {
         // Form handling.
         import('lib.pkp.controllers.grid.settings.user.form.UserDetailsForm');
         $userForm = new UserDetailsForm($request, null, $author);
         $userForm->initData($args, $request);
         return new JSONMessage(true, $userForm->display($args, $request));
     }
 }
コード例 #2
0
ファイル: UserGridHandler.inc.php プロジェクト: doana/pkp-lib
 /**
  * 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();
 }