/** * Assign form data to user-submitted data. * @see Form::readInputData() */ function readInputData() { parent::readInputData(); $this->readUserVars(array('authId', 'password', 'password2', 'salutation', 'firstName', 'middleName', 'lastName', 'suffix', 'gender', 'initials', 'signature', 'affiliation', 'email', 'userUrl', 'phone', 'fax', 'mailingAddress', 'country', 'biography', 'keywords', 'interestsTextOnly', 'userLocales', 'generatePassword', 'sendNotify', 'mustChangePassword')); if ($this->userId == null) { $this->readUserVars(array('username')); } if ($this->getData('userLocales') == null || !is_array($this->getData('userLocales'))) { $this->setData('userLocales', array()); } if ($this->getData('username') != null) { // Usernames must be lowercase $this->setData('username', strtolower($this->getData('username'))); } $keywords = $this->getData('keywords'); if ($keywords != null && is_array($keywords['interests'])) { // The interests are coming in encoded -- Decode them for DB storage $this->setData('interestsKeywords', array_map('urldecode', $keywords['interests'])); } }
/** * Assign form data to user-submitted data. * @see Form::readInputData() */ function readInputData() { parent::readInputData(); $this->readUserVars(array('authId', 'password', 'password2', 'salutation', 'firstName', 'middleName', 'lastName', 'suffix', 'gender', 'initials', 'signature', 'affiliation', 'email', 'userUrl', 'phone', 'orcid', 'mailingAddress', 'country', 'biography', 'interests', 'userLocales', 'generatePassword', 'sendNotify', 'mustChangePassword')); if ($this->userId == null) { $this->readUserVars(array('username')); } if ($this->getData('userLocales') == null || !is_array($this->getData('userLocales'))) { $this->setData('userLocales', array()); } if ($this->getData('username') != null) { // Usernames must be lowercase $this->setData('username', strtolower($this->getData('username'))); } }
/** * 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(); }