saveRoleContent() публичный Метод

Save role elements of an executed user form.
public saveRoleContent ( $form, $user )
$form Form The form from which to fetch elements
$user User The current user
 /**
  * Save roles settings.
  * @param $request PKPRequest
  */
 function execute($request)
 {
     $user = $request->getUser();
     // Save the roles
     import('lib.pkp.classes.user.form.UserFormHelper');
     $userFormHelper = new UserFormHelper();
     $userFormHelper->saveRoleContent($this, $user);
     // Insert the user interests
     import('lib.pkp.classes.user.InterestManager');
     $interestManager = new InterestManager();
     $interestManager->setInterestsForUser($user, $this->getData('interests'));
     parent::execute($request, $user);
 }
 /**
  * Register a new user.
  * @param $request PKPRequest
  * @return int|null User ID, or false on failure
  */
 function execute($request)
 {
     $requireValidation = Config::getVar('email', 'require_validation');
     $userDao = DAORegistry::getDAO('UserDAO');
     // New user
     $user = $userDao->newDataObject();
     $user->setUsername($this->getData('username'));
     // Set the base user fields (name, etc.)
     $user->setFirstName($this->getData('firstName'));
     $user->setMiddleName($this->getData('middleName'));
     $user->setLastName($this->getData('lastName'));
     $user->setInitials($this->getData('initials'));
     $user->setEmail($this->getData('email'));
     $user->setCountry($this->getData('country'));
     $user->setAffiliation($this->getData('affiliation'), null);
     // Localized
     $user->setDateRegistered(Core::getCurrentDate());
     $user->setInlineHelp(1);
     // default new users to having inline help visible.
     if (isset($this->defaultAuth)) {
         $user->setPassword($this->getData('password'));
         // FIXME Check result and handle failures
         $this->defaultAuth->doCreateUser($user);
         $user->setAuthId($this->defaultAuth->authId);
     }
     $user->setPassword(Validation::encryptCredentials($this->getData('username'), $this->getData('password')));
     if ($requireValidation) {
         // The account should be created in a disabled
         // state.
         $user->setDisabled(true);
         $user->setDisabledReason(__('user.login.accountNotValidated'));
     }
     parent::execute($user);
     $userDao->insertObject($user);
     $userId = $user->getId();
     if (!$userId) {
         return false;
     }
     // Associate the new user with the existing session
     $sessionManager = SessionManager::getManager();
     $session = $sessionManager->getUserSession();
     $session->setSessionVar('username', $user->getUsername());
     // Save the roles
     import('lib.pkp.classes.user.form.UserFormHelper');
     $userFormHelper = new UserFormHelper();
     $userFormHelper->saveRoleContent($this, $user);
     // Insert the user interests
     import('lib.pkp.classes.user.InterestManager');
     $interestManager = new InterestManager();
     $interestManager->setInterestsForUser($user, $this->getData('interests'));
     import('lib.pkp.classes.mail.MailTemplate');
     if ($requireValidation) {
         // Create an access key
         import('lib.pkp.classes.security.AccessKeyManager');
         $accessKeyManager = new AccessKeyManager();
         $accessKey = $accessKeyManager->createKey('RegisterContext', $user->getId(), null, Config::getVar('email', 'validation_timeout'));
         // Send email validation request to user
         $mail = new MailTemplate('USER_VALIDATE');
         $this->_setMailFrom($request, $mail);
         $context = $request->getContext();
         $mail->assignParams(array('userFullName' => $user->getFullName(), 'activateUrl' => $request->url($context->getPath(), 'user', 'activateUser', array($this->getData('username'), $accessKey))));
         $mail->addRecipient($user->getEmail(), $user->getFullName());
         $mail->send();
         unset($mail);
     }
     return $userId;
 }