/** * Register a new user. * @return userId int * Last modified: EL on February 22th 2013 */ function execute() { $userDao =& DAORegistry::getDAO('UserDAO'); $user = new User(); $user->setSalutation($this->getData('salutation')); $user->setFirstName($this->getData('firstName')); $user->setMiddleName($this->getData('middleName')); $user->setLastName($this->getData('lastName')); $user->setGender($this->getData('gender')); $user->setInitials($this->getData('initials')); $user->setAffiliation($this->getData('affiliation'), null); // Localized $user->setEmail($this->getData('email')); $user->setUrl($this->getData('userUrl')); $user->setPhone($this->getData('phone')); $user->setFax($this->getData('fax')); $user->setMailingAddress($this->getData('mailingAddress')); $user->setCountry($this->getData('country')); $user->setBiography($this->getData('biography'), null); // Localized $user->setGossip($this->getData('gossip'), null); // Localized $user->setMustChangePassword($this->getData('mustChangePassword') ? 1 : 0); $authDao =& DAORegistry::getDAO('AuthSourceDAO'); $auth =& $authDao->getDefaultPlugin(); $user->setAuthId($auth ? $auth->getAuthId() : 0); $site =& Request::getSite(); $availableLocales = $site->getSupportedLocales(); $locales = array(); foreach ($this->getData('userLocales') as $locale) { if (Locale::isLocaleValid($locale) && in_array($locale, $availableLocales)) { array_push($locales, $locale); } } $user->setLocales($locales); $user->setUsername($this->getData('username')); $password = Validation::generatePassword(); $sendNotify = $this->getData('sendNotify'); if (isset($auth)) { $user->setPassword($password); // FIXME Check result and handle failures $auth->doCreateUser($user); $user->setAuthId($auth->authId); $user->setPassword(Validation::encryptCredentials($user->getId(), Validation::generatePassword())); // Used for PW reset hash only } else { $user->setPassword(Validation::encryptCredentials($this->getData('username'), $password)); } $user->setDateRegistered(Core::getCurrentDate()); $userId = $userDao->insertUser($user); // Add reviewing interests to interests table $interestDao =& DAORegistry::getDAO('InterestDAO'); $interests = is_array(Request::getUserVar('interestsKeywords')) ? Request::getUserVar('interestsKeywords') : array(); if (is_array($interests)) { $interests = array_map('urldecode', $interests); // The interests are coming in encoded -- Decode them for DB storage $interestTextOnly = Request::getUserVar('interests'); if (!empty($interestsTextOnly)) { // If JS is disabled, this will be the input to read $interestsTextOnly = explode(",", $interestTextOnly); } else { $interestsTextOnly = null; } if ($interestsTextOnly && !isset($interests)) { $interests = $interestsTextOnly; } elseif (isset($interests) && !is_array($interests)) { $interests = array($interests); } $interestDao->insertInterests($interests, $user->getId(), true); } $interestDao->insertInterests($interests, $user->getId(), true); $roleDao =& DAORegistry::getDAO('RoleDAO'); $journal =& Request::getJournal(); $ercStatus = $this->getData('ercStatus'); if ($ercStatus == "Secretary") { $role = new Role(); $role->setJournalId($journal->getId()); $role->setUserId($userId); $role->setRoleId(ROLE_ID_SECTION_EDITOR); $roleDao->insertRole($role); $sectionEditorsDao =& DAORegistry::getDAO('SectionEditorsDAO'); $sectionEditorsDao->insertEditor($journal->getId(), $this->sectionId, $userId, 1, 1); } elseif ($ercStatus == "Chair" || $ercStatus == "Vice-Chair" || $ercStatus == "Member") { $role = new Role(); $role->setJournalId($journal->getId()); $role->setUserId($userId); $role->setRoleId(ROLE_ID_REVIEWER); $roleDao->insertRole($role); $ercReviewersDao =& DAORegistry::getDAO('ErcReviewersDAO'); if ($ercStatus == "Chair") { $ercReviewersDao->insertReviewer($journal->getId(), $this->sectionId, $userId, 1); } elseif ($ercStatus == "Vice-Chair") { $ercReviewersDao->insertReviewer($journal->getId(), $this->sectionId, $userId, 2); } if ($ercStatus == "Member") { $ercReviewersDao->insertReviewer($journal->getId(), $this->sectionId, $userId, 3); } } if ($sendNotify) { $sectionDao =& DAORegistry::getDAO('SectionDAO'); $erc =& $sectionDao->getSection($this->sectionId); $thisUser =& Request::getUser(); // Send welcome email to user import('classes.mail.MailTemplate'); $mail = new MailTemplate('COMMITTEE_REGISTER'); $mail->setFrom($journal->getSetting('contactEmail'), $journal->getSetting('contactName')); $mail->assignParams(array('username' => $this->getData('username'), 'password' => $password, 'userFullName' => $user->getFullName(), 'ercStatus' => $ercStatus, 'ercTitle' => $erc->getLocalizedTitle(), 'editProfile' => Request::url(null, 'user', 'profile'), 'secretaryFullName' => $thisUser->getFullName(), 'secretaryFunctions' => $thisUser->getErcFunction($this->sectionId))); $mail->addRecipient($user->getEmail(), $user->getFullName()); $mail->send(); } return $userId; }
/** * Register a new user. * @return $userId int */ function execute() { $userDao =& DAORegistry::getDAO('UserDAO'); $user = new User(); $user->setSalutation($this->getData('salutation')); $user->setFirstName($this->getData('firstName')); $user->setMiddleName($this->getData('middleName')); $user->setLastName($this->getData('lastName')); $user->setGender($this->getData('gender')); $user->setInitials($this->getData('initials')); $user->setAffiliation($this->getData('affiliation')); $user->setEmail($this->getData('email')); $user->setUrl($this->getData('userUrl')); $user->setPhone($this->getData('phone')); $user->setFax($this->getData('fax')); $user->setMailingAddress($this->getData('mailingAddress')); $user->setCountry($this->getData('country')); $user->setBiography($this->getData('biography'), null); // Localized $user->setInterests($this->getData('interests'), null); // Localized $user->setGossip($this->getData('gossip'), null); // Localized $user->setMustChangePassword($this->getData('mustChangePassword') ? 1 : 0); $authDao =& DAORegistry::getDAO('AuthSourceDAO'); $auth =& $authDao->getDefaultPlugin(); $user->setAuthId($auth ? $auth->getAuthId() : 0); $site =& Request::getSite(); $availableLocales = $site->getSupportedLocales(); $locales = array(); foreach ($this->getData('userLocales') as $locale) { if (AppLocale::isLocaleValid($locale) && in_array($locale, $availableLocales)) { array_push($locales, $locale); } } $user->setLocales($locales); $user->setUsername($this->getData('username')); $password = Validation::generatePassword(); $sendNotify = $this->getData('sendNotify'); if (isset($auth)) { $user->setPassword($password); // FIXME Check result and handle failures $auth->doCreateUser($user); $user->setAuthId($auth->authId); $user->setPassword(Validation::encryptCredentials($user->getId(), Validation::generatePassword())); // Used for PW reset hash only } else { $user->setPassword(Validation::encryptCredentials($this->getData('username'), $password)); } $user->setDateRegistered(Core::getCurrentDate()); $userId = $userDao->insertUser($user); $roleDao =& DAORegistry::getDAO('RoleDAO'); $schedConf =& Request::getSchedConf(); $role = new Role(); $role->setConferenceId($schedConf->getConferenceId()); $role->setSchedConfId($schedConf->getId()); $role->setUserId($userId); $role->setRoleId(ROLE_ID_REVIEWER); $roleDao->insertRole($role); if ($sendNotify) { // Send welcome email to user import('mail.MailTemplate'); $mail = new MailTemplate('USER_REGISTER'); $mail->setFrom($schedConf->getSetting('contactEmail'), $schedConf->getSetting('contactName')); $mail->assignParams(array('username' => $this->getData('username'), 'password' => $password)); $mail->addRecipient($user->getEmail(), $user->getFullName()); $mail->send(); } return $userId; }
/** * Register a new user. */ function execute() { $userDao =& DAORegistry::getDAO('UserDAO'); $journal =& Request::getJournal(); if (isset($this->userId)) { $user =& $userDao->getUser($this->userId); } if (!isset($user)) { $user = new User(); } $user->setSalutation($this->getData('salutation')); $user->setFirstName($this->getData('firstName')); $user->setMiddleName($this->getData('middleName')); $user->setLastName($this->getData('lastName')); $user->setInitials($this->getData('initials')); $user->setGender($this->getData('gender')); $user->setAffiliation($this->getData('affiliation'), null); // Localized $user->setSignature($this->getData('signature'), null); // Localized $user->setEmail($this->getData('email')); $user->setUrl($this->getData('userUrl')); $user->setPhone($this->getData('phone')); $user->setFax($this->getData('fax')); $user->setMailingAddress($this->getData('mailingAddress')); $user->setCountry($this->getData('country')); $user->setBiography($this->getData('biography'), null); // Localized $user->setGossip($this->getData('gossip'), null); // Localized $user->setMustChangePassword($this->getData('mustChangePassword') ? 1 : 0); $user->setAuthId((int) $this->getData('authId')); $site =& Request::getSite(); $availableLocales = $site->getSupportedLocales(); $locales = array(); foreach ($this->getData('userLocales') as $locale) { if (Locale::isLocaleValid($locale) && in_array($locale, $availableLocales)) { array_push($locales, $locale); } } $user->setLocales($locales); if ($user->getAuthId()) { $authDao =& DAORegistry::getDAO('AuthSourceDAO'); $auth =& $authDao->getPlugin($user->getAuthId()); } if ($user->getId() != null) { $userId = $user->getId(); if ($this->getData('password') !== '') { if (isset($auth)) { $auth->doSetUserPassword($user->getUsername(), $this->getData('password')); $user->setPassword(Validation::encryptCredentials($userId, Validation::generatePassword())); // Used for PW reset hash only } else { $user->setPassword(Validation::encryptCredentials($user->getUsername(), $this->getData('password'))); } } if (isset($auth)) { // FIXME Should try to create user here too? $auth->doSetUserInfo($user); } $userDao->updateObject($user); } else { $user->setUsername($this->getData('username')); if ($this->getData('generatePassword')) { $password = Validation::generatePassword(); $sendNotify = true; } else { $password = $this->getData('password'); $sendNotify = $this->getData('sendNotify'); } if (isset($auth)) { $user->setPassword($password); // FIXME Check result and handle failures $auth->doCreateUser($user); $user->setAuthId($auth->authId); $user->setPassword(Validation::encryptCredentials($user->getId(), Validation::generatePassword())); // Used for PW reset hash only } else { $user->setPassword(Validation::encryptCredentials($this->getData('username'), $password)); } $user->setDateRegistered(Core::getCurrentDate()); $userId = $userDao->insertUser($user); $isManager = Validation::isJournalManager(); // EL on March 13th 2013 // If this is used, it should be totally modified if (!empty($this->_data['enrollAs'])) { foreach ($this->getData('enrollAs') as $roleName) { // Enroll new user into an initial role $roleDao =& DAORegistry::getDAO('RoleDAO'); $roleId = $roleDao->getRoleIdFromPath($roleName); if (!$isManager && $roleId != ROLE_ID_READER) { continue; } if ($roleId != null) { $role = new Role(); $role->setJournalId($journal->getId()); $role->setUserId($userId); $role->setRoleId($roleId); $roleDao->insertRole($role); } } } if ($sendNotify) { // Send welcome email to user import('classes.mail.MailTemplate'); $mail = new MailTemplate('USER_REGISTER'); $mail->setFrom($journal->getSetting('supportEmail'), $journal->getSetting('supportName')); $mail->assignParams(array('username' => $this->getData('username'), 'password' => String::substr($this->getData('password'), 0, 30), 'supportName' => $journal->getSetting('supportName'), 'userFullName' => $user->getFullName())); $mail->addRecipient($user->getEmail(), $user->getFullName()); $mail->send(); } } // Add reviewing interests to interests table $interestDao =& DAORegistry::getDAO('InterestDAO'); $interests = is_array(Request::getUserVar('interestsKeywords')) ? Request::getUserVar('interestsKeywords') : array(); if (is_array($interests)) { $interests = array_map('urldecode', $interests); // The interests are coming in encoded -- Decode them for DB storage $interestTextOnly = Request::getUserVar('interests'); if (!empty($interestsTextOnly)) { // If JS is disabled, this will be the input to read $interestsTextOnly = explode(",", $interestTextOnly); } else { $interestsTextOnly = null; } if ($interestsTextOnly && !isset($interests)) { $interests = $interestsTextOnly; } elseif (isset($interests) && !is_array($interests)) { $interests = array($interests); } $interestDao->insertInterests($interests, $userId, true); } }
/** * Register a new user. */ function execute() { $userDao =& DAORegistry::getDAO('UserDAO'); $journal =& Request::getJournal(); if (isset($this->userId)) { $user =& $userDao->getById($this->userId); } if (!isset($user)) { $user = new User(); } $user->setSalutation($this->getData('salutation')); $user->setFirstName($this->getData('firstName')); $user->setMiddleName($this->getData('middleName')); $user->setLastName($this->getData('lastName')); $user->setInitials($this->getData('initials')); $user->setGender($this->getData('gender')); $user->setAffiliation($this->getData('affiliation'), null); // Localized $user->setSignature($this->getData('signature'), null); // Localized $user->setEmail($this->getData('email')); $user->setData('orcid', $this->getData('orcid')); $user->setUrl($this->getData('userUrl')); $user->setPhone($this->getData('phone')); $user->setFax($this->getData('fax')); $user->setMailingAddress($this->getData('mailingAddress')); $user->setCountry($this->getData('country')); $user->setBiography($this->getData('biography'), null); // Localized $user->setGossip($this->getData('gossip'), null); // Localized $user->setMustChangePassword($this->getData('mustChangePassword') ? 1 : 0); $user->setAuthId((int) $this->getData('authId')); $site =& Request::getSite(); $availableLocales = $site->getSupportedLocales(); $locales = array(); foreach ($this->getData('userLocales') as $locale) { if (AppLocale::isLocaleValid($locale) && in_array($locale, $availableLocales)) { array_push($locales, $locale); } } $user->setLocales($locales); if ($user->getAuthId()) { $authDao =& DAORegistry::getDAO('AuthSourceDAO'); $auth =& $authDao->getPlugin($user->getAuthId()); } if ($user->getId() != null) { $userId = $user->getId(); if ($this->getData('password') !== '') { if (isset($auth)) { $auth->doSetUserPassword($user->getUsername(), $this->getData('password')); $user->setPassword(Validation::encryptCredentials($userId, Validation::generatePassword())); // Used for PW reset hash only } else { $user->setPassword(Validation::encryptCredentials($user->getUsername(), $this->getData('password'))); } } if (isset($auth)) { // FIXME Should try to create user here too? $auth->doSetUserInfo($user); } $userDao->updateObject($user); } else { $user->setUsername($this->getData('username')); if ($this->getData('generatePassword')) { $password = Validation::generatePassword(); $sendNotify = true; } else { $password = $this->getData('password'); $sendNotify = $this->getData('sendNotify'); } if (isset($auth)) { $user->setPassword($password); // FIXME Check result and handle failures $auth->doCreateUser($user); $user->setAuthId($auth->authId); $user->setPassword(Validation::encryptCredentials($user->getId(), Validation::generatePassword())); // Used for PW reset hash only } else { $user->setPassword(Validation::encryptCredentials($this->getData('username'), $password)); } $user->setDateRegistered(Core::getCurrentDate()); $userId = $userDao->insertUser($user); $isManager = Validation::isJournalManager(); if (!empty($this->_data['enrollAs'])) { foreach ($this->getData('enrollAs') as $roleName) { // Enroll new user into an initial role $roleDao =& DAORegistry::getDAO('RoleDAO'); $roleId = $roleDao->getRoleIdFromPath($roleName); if (!$isManager && $roleId != ROLE_ID_READER) { continue; } if ($roleId != null) { $role = new Role(); $role->setJournalId($journal->getId()); $role->setUserId($userId); $role->setRoleId($roleId); $roleDao->insertRole($role); } } } if ($sendNotify) { // Send welcome email to user import('classes.mail.MailTemplate'); $mail = new MailTemplate('USER_REGISTER'); $mail->setFrom($journal->getSetting('contactEmail'), $journal->getSetting('contactName')); $mail->assignParams(array('username' => $this->getData('username'), 'password' => $password, 'userFullName' => $user->getFullName())); $mail->addRecipient($user->getEmail(), $user->getFullName()); $mail->send(); } } // Insert the user interests $interests = $this->getData('interestsKeywords') ? $this->getData('interestsKeywords') : $this->getData('interestsTextOnly'); import('lib.pkp.classes.user.InterestManager'); $interestManager = new InterestManager(); $interestManager->setInterestsForUser($user, $interests); }
/** * Create or update a user. * @param $args array * @param $request PKPRequest */ function &execute($args, &$request) { $userDao =& DAORegistry::getDAO('UserDAO'); $press =& $request->getPress(); if (isset($this->userId)) { $userId = $this->userId; $user =& $userDao->getUser($userId); } if (!isset($user)) { $user = new User(); } $user->setSalutation($this->getData('salutation')); $user->setFirstName($this->getData('firstName')); $user->setMiddleName($this->getData('middleName')); $user->setLastName($this->getData('lastName')); $user->setInitials($this->getData('initials')); $user->setGender($this->getData('gender')); $user->setAffiliation($this->getData('affiliation'), null); // Localized $user->setSignature($this->getData('signature'), null); // Localized $user->setEmail($this->getData('email')); $user->setUrl($this->getData('userUrl')); $user->setPhone($this->getData('phone')); $user->setFax($this->getData('fax')); $user->setMailingAddress($this->getData('mailingAddress')); $user->setCountry($this->getData('country')); $user->setBiography($this->getData('biography'), null); // Localized $user->setGossip($this->getData('gossip'), null); // Localized $user->setMustChangePassword($this->getData('mustChangePassword') ? 1 : 0); $user->setAuthId((int) $this->getData('authId')); $site =& $request->getSite(); $availableLocales = $site->getSupportedLocales(); $locales = array(); foreach ($this->getData('userLocales') as $locale) { if (Locale::isLocaleValid($locale) && in_array($locale, $availableLocales)) { array_push($locales, $locale); } } $user->setLocales($locales); if ($user->getAuthId()) { $authDao =& DAORegistry::getDAO('AuthSourceDAO'); $auth =& $authDao->getPlugin($user->getAuthId()); } if ($user->getId() != null) { if ($this->getData('password') !== '') { if (isset($auth)) { $auth->doSetUserPassword($user->getUsername(), $this->getData('password')); $user->setPassword(Validation::encryptCredentials($user->getId(), Validation::generatePassword())); // Used for PW reset hash only } else { $user->setPassword(Validation::encryptCredentials($user->getUsername(), $this->getData('password'))); } } if (isset($auth)) { // FIXME Should try to create user here too? $auth->doSetUserInfo($user); } $userDao->updateObject($user); } else { $user->setUsername($this->getData('username')); if ($this->getData('generatePassword')) { $password = Validation::generatePassword(); $sendNotify = true; } else { $password = $this->getData('password'); $sendNotify = $this->getData('sendNotify'); } if (isset($auth)) { $user->setPassword($password); // FIXME Check result and handle failures $auth->doCreateUser($user); $user->setAuthId($auth->authId); $user->setPassword(Validation::encryptCredentials($user->getId(), Validation::generatePassword())); // Used for PW reset hash only } else { $user->setPassword(Validation::encryptCredentials($this->getData('username'), $password)); } $user->setDateRegistered(Core::getCurrentDate()); $userId = $userDao->insertUser($user); if ($sendNotify) { // Send welcome email to user import('classes.mail.MailTemplate'); $mail = new MailTemplate('USER_REGISTER'); $mail->setFrom($press->getSetting('contactEmail'), $press->getSetting('contactName')); $mail->assignParams(array('username' => $this->getData('username'), 'password' => $password, 'userFullName' => $user->getFullName())); $mail->addRecipient($user->getEmail(), $user->getFullName()); $mail->send(); } } // Add reviewing interests to interests table import('lib.pkp.classes.user.InterestManager'); $interestManager = new InterestManager(); $interestManager->insertInterests($userId, $this->getData('interestsKeywords'), $this->getData('interests')); return $user; }