/**
  * Making new User to register.
  * @param RegisterFO $fo
  * @return User
  */
 private function makeUser(RegisterFO $fo)
 {
     $user = new User();
     $user->setLogin($fo->getLogin());
     $user->setFirstname($fo->getFirstname());
     $user->setLastname($fo->getLastname());
     $user->setEmail($fo->getEmail());
     $user->setPassword($fo->getPassword());
     $user->setGender($fo->getGender());
     $user->setBirthdate($fo->getBirthdate());
     $user->setLatestIP(null);
     $user->setLastActive(null);
     $user->setActivation($this->makeActivationHash($user));
     return $user;
 }
Example #2
0
 public static function map(User $user, array $properties)
 {
     if (array_key_exists('userId', $properties)) {
         $user->setUserId($properties['userId']);
     }
     if (array_key_exists('password', $properties)) {
         $user->setPassword($properties['password']);
     }
     if (array_key_exists('name', $properties)) {
         $user->setName($properties['name']);
     }
     if (array_key_exists('gender', $properties)) {
         $user->setGender($properties['gender']);
     }
     if (array_key_exists('telephone', $properties)) {
         $user->setTelephone($properties['telephone']);
     }
     if (array_key_exists('email', $properties)) {
         $user->setEmail($properties['email']);
     }
     if (array_key_exists('avatar', $properties)) {
         $user->setAvatar($properties['avatar']);
     }
     if (array_key_exists('slogan', $properties)) {
         $user->setSlogan($properties['slogan']);
     }
     if (array_key_exists('birthday', $properties)) {
         $user->setBirthday($properties['birthday']);
     }
     if (array_key_exists('createdAt', $properties)) {
         $tempCreatedAt = DateTransform::createDate($properties['createdAt']);
         if ($tempCreatedAt) {
             $user->setCreatedAt($tempCreatedAt);
         }
     }
     if (array_key_exists('character', $properties)) {
         $user->setCharacter($properties['character']);
     }
 }
Example #3
0
 public function setUp()
 {
     $order_detail = new OrderDetail();
     $order_detail->setBarcode(171804847258);
     $order_detail->setDe(111);
     $order_detail->setInfo(1111);
     $user = new User();
     $user->setBirthday('1981-06-13');
     $user->setEmail('*****@*****.**');
     $user->setFirstName('FirstName');
     $user->setLastName('LastName');
     $user->setGender(-1);
     $user->setIndentityNumber('asv');
     $user->setJob('Job');
     $user->setMartialStatus(-1);
     $user->setPhone('5335514040');
     $this->order_info = new OrderInfo();
     $this->order_info->setClientPassword("ANRGGCLBU2V55LKKSY3E");
     $this->order_info->setInvoiceNumber("150909-47786");
     $this->order_info->setOrderDetail($order_detail);
     $this->order_info->setPointCode("TDR-4327");
     $this->order_info->setUser($user);
 }
Example #4
0
 /**
  * Register a new user.
  */
 function execute()
 {
     $requireValidation = Config::getVar('email', 'require_validation');
     if ($this->existingUser) {
         // If using implicit auth - we hardwire that we are working on an existing user
         // Existing user in the system
         $userDao =& DAORegistry::getDAO('UserDAO');
         if ($this->implicitAuth) {
             // If we are using implicit auth - then use the session username variable - rather than data from the form
             $sessionManager =& SessionManager::getManager();
             $session =& $sessionManager->getUserSession();
             $user =& $userDao->getUserByUsername($session->getSessionVar('username'));
         } else {
             $user =& $userDao->getUserByUsername($this->getData('username'));
         }
         if ($user == null) {
             return false;
         }
         $userId = $user->getId();
     } else {
         // New user
         $user = new User();
         $user->setUsername($this->getData('username'));
         $user->setSalutation($this->getData('salutation'));
         $user->setFirstName($this->getData('firstName'));
         $user->setMiddleName($this->getData('middleName'));
         $user->setInitials($this->getData('initials'));
         $user->setLastName($this->getData('lastName'));
         $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->setBiography($this->getData('biography'), null);
         // Localized
         $user->setDateRegistered(Core::getCurrentDate());
         $user->setCountry($this->getData('country'));
         $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 (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(Locale::translate('user.login.accountNotValidated'));
         }
         $userDao =& DAORegistry::getDAO('UserDAO');
         $userDao->insertUser($user);
         $userId = $user->getId();
         if (!$userId) {
             return false;
         }
         // Add reviewing interests to interests table
         import('lib.pkp.classes.user.InterestManager');
         $interestManager = new InterestManager();
         $interestManager->insertInterests($userId, $this->getData('interestsKeywords'), $this->getData('interests'));
         $sessionManager =& SessionManager::getManager();
         $session =& $sessionManager->getUserSession();
         $session->setSessionVar('username', $user->getUsername());
     }
     $press =& Request::getPress();
     $roleDao =& DAORegistry::getDAO('RoleDAO');
     // Roles users are allowed to register themselves in
     $allowedRoles = array('reader' => 'registerAsReader', 'author' => 'registerAsAuthor', 'reviewer' => 'registerAsReviewer');
     $pressSettingsDao =& DAORegistry::getDAO('PressSettingsDAO');
     if (!$pressSettingsDao->getSetting($press->getId(), 'allowRegReader')) {
         unset($allowedRoles['reader']);
     }
     if (!$pressSettingsDao->getSetting($press->getId(), 'allowRegAuthor')) {
         unset($allowedRoles['author']);
     }
     if (!$pressSettingsDao->getSetting($press->getId(), 'allowRegReviewer')) {
         unset($allowedRoles['reviewer']);
     }
     foreach ($allowedRoles as $k => $v) {
         $roleId = $roleDao->getRoleIdFromPath($k);
         if ($this->getData($v) && !$roleDao->userHasRole($press->getId(), $userId, $roleId)) {
             $role = new Role();
             $role->setPressId($press->getId());
             $role->setUserId($userId);
             $role->setRoleId($roleId);
             $roleDao->insertRole($role);
         }
     }
     if (!$this->existingUser) {
         import('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');
             $mail->setFrom($press->getSetting('contactEmail'), $press->getSetting('contactName'));
             $mail->assignParams(array('userFullName' => $user->getFullName(), 'activateUrl' => Request::url($press->getPath(), 'user', 'activateUser', array($this->getData('username'), $accessKey))));
             $mail->addRecipient($user->getEmail(), $user->getFullName());
             $mail->send();
             unset($mail);
         }
         if ($this->getData('sendPassword')) {
             // Send welcome email to user
             $mail = new MailTemplate('USER_REGISTER');
             $mail->setFrom($press->getSetting('contactEmail'), $press->getSetting('contactName'));
             $mail->assignParams(array('username' => $this->getData('username'), 'password' => String::substr($this->getData('password'), 0, 30), 'userFullName' => $user->getFullName()));
             $mail->addRecipient($user->getEmail(), $user->getFullName());
             $mail->send();
             unset($mail);
         }
     }
     // By default, self-registering readers will receive
     // press updates. (The double set is here to prevent a
     // duplicate insert error msg if there was a notification entry
     // left over from a previous role.)
     if (isset($allowedRoles['reader']) && $this->getData($allowedRoles['reader'])) {
         $notificationStatusDao =& DAORegistry::getDAO('NotificationStatusDAO');
         $notificationStatusDao->setPressNotifications($press->getId(), $userId, false);
         $notificationStatusDao->setPressNotifications($press->getId(), $userId, true);
     }
 }
Example #5
0
 /**
  * Internal function to return a User object from a row.
  * @param $row array
  * @param $callHook boolean
  * @return User
  */
 function &_returnUserFromRow(&$row, $callHook = true)
 {
     $user = new User();
     $user->setId($row['user_id']);
     $user->setUsername($row['username']);
     $user->setPassword($row['password']);
     $user->setSalutation($row['salutation']);
     $user->setFirstName($row['first_name']);
     $user->setMiddleName($row['middle_name']);
     $user->setInitials($row['initials']);
     $user->setLastName($row['last_name']);
     $user->setGender($row['gender']);
     $user->setEmail($row['email']);
     $user->setUrl($row['url']);
     $user->setPhone($row['phone']);
     $user->setFax($row['fax']);
     $user->setMailingAddress($row['mailing_address']);
     $user->setCountry($row['country']);
     $user->setLocales(isset($row['locales']) && !empty($row['locales']) ? explode(':', $row['locales']) : array());
     $user->setDateLastEmail($this->datetimeFromDB($row['date_last_email']));
     $user->setDateRegistered($this->datetimeFromDB($row['date_registered']));
     $user->setDateValidated($this->datetimeFromDB($row['date_validated']));
     $user->setDateLastLogin($this->datetimeFromDB($row['date_last_login']));
     $user->setMustChangePassword($row['must_change_password']);
     $user->setDisabled($row['disabled']);
     $user->setDisabledReason($row['disabled_reason']);
     $user->setAuthId($row['auth_id']);
     $user->setAuthStr($row['auth_str']);
     if ($callHook) {
         HookRegistry::call('UserDAO::_returnUserFromRow', array(&$user, &$row));
     }
     return $user;
 }
 /**
  * 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);
 }
Example #7
0
     $ERRORS[] = 'Invalid e-mail address specified.';
 }
 if (sizeof($ERRORS) > 0) {
     draw_errors($ERRORS);
 } else {
     // Create an user and set some base attrs.
     $new_user = new User($db);
     $new_user->setUserName($USER['user_name']);
     $new_user->setRegisteredIpAddr($_SERVER['REMOTE_ADDR']);
     $new_user->setPassword($USER['password']);
     $new_user->setCurrentSaltExpiration($new_user->sysdate());
     $new_user->setLastActivity($new_user->sysdate());
     $new_user->setAccessLevel('user');
     $new_user->setEmail($USER['email']);
     $new_user->setAge($USER['age']);
     $new_user->setGender($USER['gender']);
     $new_user->setProfile($USER['profile']);
     $new_user->setCurrency($APP_CONFIG['starting_funds']);
     $new_user->setUserTitle('User');
     $new_user->setTextareaPreference('tinymce');
     $new_user->setDatetimeCreated($new_user->sysdate());
     $new_user->setDatetimeLastPost($new_user->sysdate());
     $new_user->setPasswordResetRequested($new_user->sysdate());
     $new_user->setTimezoneId(54);
     // 54 = UTC
     $new_user->setDatetimeFormatId(1);
     // Y-m-d H:i:s
     $new_user->setShowOnlineStatus('Y');
     $new_user->save();
     // Log the user in and send him back home.
     $new_user->login();
 /**
  * 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);
     }
 }
 function importUsers()
 {
     assert($this->xml->name == 'users');
     import('lib.pkp.classes.user.InterestManager');
     $interestManager = new InterestManager();
     $roleDao =& DAORegistry::getDAO('RoleDAO');
     $userDAO =& DAORegistry::getDAO('UserDAO');
     $publicFileManager =& new PublicFileManager();
     $site =& Request::getSite();
     $siteSupportedLocales = $site->getSupportedLocales();
     $this->nextElement();
     while ($this->xml->name == 'user') {
         $userXML = $this->getCurrentElementAsDom();
         $username = (string) $userXML->username;
         $email = (string) $userXML->email;
         $userByEmail = $userDAO->getUserByEmail($email);
         $user = null;
         if (!empty($userByEmail)) {
             $user = $userByEmail;
         } else {
             $user = new User();
             $user->setUsername((string) $userXML->username);
             $user->setPassword((string) $userXML->password);
             $user->setSalutation((string) $userXML->salutation);
             $user->setFirstName((string) $userXML->firstName);
             $user->setMiddleName((string) $userXML->middleName);
             $user->setInitials((string) $userXML->initials);
             $user->setLastName((string) $userXML->lastName);
             $user->setSuffix((string) $userXML->suffix);
             $user->setGender((string) $userXML->gender);
             $user->setEmail((string) $userXML->email);
             $user->setUrl((string) $userXML->url);
             $user->setPhone((string) $userXML->phone);
             $user->setFax((string) $userXML->fax);
             $user->setMailingAddress((string) $userXML->mailingAddress);
             $user->setBillingAddress((string) $userXML->billingAddress);
             $user->setCountry((string) $userXML->country);
             $locales = array();
             foreach (explode(':', (string) $userXML->locales) as $locale) {
                 if (AppLocale::isLocaleValid($locale) && in_array($locale, $siteSupportedLocales)) {
                     array_push($locales, $locale);
                 }
             }
             $user->setLocales($locales);
             $user->setDateLastEmail((string) $userXML->dateLastEmail);
             $user->setDateRegistered((string) $userXML->dateRegistered);
             $user->setDateValidated((string) $userXML->dateValidated);
             $user->setDateLastLogin((string) $userXML->dateLastLogin);
             $user->setMustChangePassword((int) $userXML->mustChangePassword);
             $user->setDisabled((int) $userXML->disabled);
             $user->setDisabledReason((string) $userXML->disabledReason);
             $user->setAuthId((int) $userXML->authId);
             $user->setAuthStr((string) $userXML->authStr);
             $user->setInlineHelp((int) $userXML->inlineHelp);
             $this->generateUsername($user);
             $userDAO->insertUser($user);
             $this->restoreDataObjectSettings($userDAO, $userXML->settings, 'user_settings', 'user_id', $user->getId());
             $user = $userDAO->getById($user->getId());
             $profileImage =& $user->getSetting('profileImage');
             if ($profileImage) {
                 $oldProfileImage = $profileImage['uploadName'];
                 $extension = $publicFileManager->getExtension($oldProfileImage);
                 $newProfileImage = 'profileImage-' . $user->getId() . "." . $extension;
                 $sourceFile = $this->siteFolderPath . '/' . $oldProfileImage;
                 $publicFileManager->copyFile($sourceFile, $publicFileManager->getSiteFilesPath() . "/" . $newProfileImage);
                 unlink($sourceFile);
                 $profileImage['uploadName'] = $newProfileImage;
                 $user->updateSetting('profileImage', $profileImage);
             }
             $interests = array();
             foreach ($userXML->interest as $interest) {
                 $interests[] = (string) $interest;
             }
             $interestManager->setInterestsForUser($user, $interests);
         }
         $this->idTranslationTable->register(INTERNAL_TRANSFER_OBJECT_USER, (int) $userXML->oldId, $user->getId());
         foreach ($userXML->role as $roleXML) {
             $role = new Role();
             $role->setRoleId((int) $roleXML);
             $role->setUserId($user->getId());
             $role->setJournalId($this->journal->getId());
             $roleDao->insertRole($role);
         }
         $this->nextElement();
     }
 }
Example #10
0
 $page->addJavascript("assets/js/jquery.inputmask.bundle.min.js");
 $page->startBody();
 $update = null;
 //update PassWord
 $updatePW = true;
 date_default_timezone_set('Asia/Bangkok');
 $User = new User();
 if (isset($_POST["btnUpdate"])) {
     $User->setUserID($_POST["txtUserID"]);
     $User->setUserName($_POST["txtUserName"]);
     $User->setEmail($_POST["txtEmail"]);
     $dateOfBirth = new DateTime(str_replace('/', '-', $_POST["txtBirthDay"]));
     //d-m-Y
     $User->setDateOfBirth($dateOfBirth);
     $User->setFullName($_POST["txtFullName"]);
     $User->setGender($_POST["cboGender"]);
     $User->setUserPermission(0);
     $userLastModified = new DateTime();
     $User->setUserLastModified($userLastModified);
     $User->setUserPassWord(Context::getCurrentUser()["userPassWord"]);
     $User->update();
     $_SESSION["CurrentUser"] = (array) $User;
     $update = true;
     unset($_SESSION['captcha']);
 } else {
     if (isset($_POST["btnSave"]) && isset($_POST["txtPassWordOld"])) {
         $messagePW = "";
         $User->setUserID(Context::getCurrentUser()["userID"]);
         $passWordOld = $_POST["txtPassWordOld"];
         if (Context::getCurrentUser()["userPassWord"] == $passWordOld) {
             $User->setUserPassWord($_POST["txtPassWordNew"]);
Example #11
0
 /**
  * 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;
 }
 /**
  * Used to register new User.
  * 
  * @param array $request Register form Credentials to be used to register new User.
  * @return integer Number of successfully affected rows in User table.
  */
 public function register($request)
 {
     $login = $request[RegisterEnum::LOGIN];
     $password = md5($request[RegisterEnum::PASSWORD]);
     $firstname = $request[RegisterEnum::FIRSTNAME];
     $lastname = $request[RegisterEnum::LASTNAME];
     $email = $request[RegisterEnum::EMAIL];
     $gender = $request[RegisterEnum::GENDER];
     $year = $request[RegisterEnum::YEAR];
     $month = $request[RegisterEnum::MONTH];
     $day = $request[RegisterEnum::DAY];
     $birthdate = $year . '-' . $month . '-' . $day;
     $vo = new User();
     $vo->setLogin($this->db->escape($login));
     $vo->setPassword($this->db->escape($password));
     $vo->setFirstname($this->db->escape($firstname));
     $vo->setLastname($this->db->escape($lastname));
     $vo->setEmail($this->db->escape($email));
     $vo->setOnline(0);
     $vo->setGender($gender);
     $vo->setBirthdate($birthdate);
     $vo->setAvatar(0);
     $vo->setActive(0);
     $vo->setVisitNumber(0);
     $vo->setLastActive(' ');
     $dao = $this->dao->getDAO("User");
     return $dao->save($vo);
 }
 /**
  * Register a new user.
  */
 function execute()
 {
     $requireValidation = Config::getVar('email', 'require_validation');
     // New user
     $user = new User();
     $user->setUsername($this->getData('username'));
     $user->setSalutation($this->getData('salutation'));
     $user->setFirstName($this->getData('firstName'));
     $user->setMiddleName($this->getData('middleName'));
     $user->setInitials($this->getData('initials'));
     $user->setLastName($this->getData('lastName'));
     $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->setBiography($this->getData('biography'), null);
     // Localized
     $user->setInterests($this->getData('interests'), null);
     // Localized
     $user->setDateRegistered(Core::getCurrentDate());
     $user->setCountry($this->getData('country'));
     $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 (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(Locale::translate('user.login.accountNotValidated'));
     }
     $userDao =& DAORegistry::getDAO('UserDAO');
     $userDao->insertUser($user);
     $userId = $user->getId();
     if (!$userId) {
         return false;
     }
     $sessionManager =& SessionManager::getManager();
     $session =& $sessionManager->getUserSession();
     $session->setSessionVar('username', $user->getUsername());
     $roleDao =& DAORegistry::getDAO('RoleDAO');
     // Roles users are allowed to register themselves in
     $allowedRoles = array('submitter' => 'registerAsSubmitter');
     if (!$site->getSetting('enableSubmit')) {
         unset($allowedRoles['submitter']);
     }
     foreach ($allowedRoles as $k => $v) {
         $roleId = $roleDao->getRoleIdFromPath($k);
         if ($this->getData($v) && !$roleDao->roleExists($userId, $roleId)) {
             $role = new Role();
             $role->setUserId($userId);
             $role->setRoleId($roleId);
             $roleDao->insertRole($role);
         }
     }
     import('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');
         $mail->setFrom($site->getLocalizedSetting('contactEmail'), $site->getLocalizedSetting('contactName'));
         $mail->assignParams(array('userFullName' => $user->getFullName(), 'activateUrl' => Request::url('user', 'activateUser', array($this->getData('username'), $accessKey))));
         $mail->addRecipient($user->getEmail(), $user->getFullName());
         $mail->send();
         unset($mail);
     }
     if ($this->getData('sendPassword')) {
         // Send welcome email to user
         $mail = new MailTemplate('USER_REGISTER');
         $mail->setFrom($site->getLocalizedSetting('contactEmail'), $site->getLocalizedSetting('contactName'));
         $mail->assignParams(array('username' => $this->getData('username'), 'password' => String::substr($this->getData('password'), 0, 30), 'userFullName' => $user->getFullName()));
         $mail->addRecipient($user->getEmail(), $user->getFullName());
         $mail->send();
         unset($mail);
     }
 }
 /**
  * Save registration.
  */
 function execute()
 {
     $schedConf =& Request::getSchedConf();
     $user =& Request::getUser();
     $registrationOptionIds = (array) $this->getData('registrationOptionId');
     if (!$user) {
         // New user
         $user = new User();
         $user->setUsername($this->getData('username'));
         $user->setFirstName($this->getData('firstName'));
         $user->setMiddleName($this->getData('middleName'));
         $user->setInitials($this->getData('initials'));
         $user->setLastName($this->getData('lastName'));
         $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->setBillingAddress($this->getData('billingAddress'));
         $user->setBiography($this->getData('biography'), null);
         // Localized
         $user->setDateRegistered(Core::getCurrentDate());
         $user->setCountry($this->getData('country'));
         $user->setPassword(Validation::encryptCredentials($this->getData('username'), $this->getData('password')));
         $userDao =& DAORegistry::getDAO('UserDAO');
         $userId = $userDao->insertUser($user);
         if (!$userId) {
             return REGISTRATION_FAILED;
         }
         $conference =& Request::getConference();
         $roleDao =& DAORegistry::getDAO('RoleDAO');
         $role = new Role();
         $role->setRoleId(ROLE_ID_READER);
         $role->setSchedConfId($schedConf->getId());
         $role->setConferenceId($conference->getId());
         $role->setUserId($user->getId());
         $roleDao->insertRole($role);
         $sessionManager =& SessionManager::getManager();
         $session =& $sessionManager->getUserSession();
         $session->setSessionVar('username', $user->getUsername());
         // Make sure subsequent requests to Request::getUser work
         Validation::login($this->getData('username'), $this->getData('password'), $reason);
         import('classes.user.form.CreateAccountForm');
         CreateAccountForm::sendConfirmationEmail($user, $this->getData('password'), true);
     }
     // Get the registration type
     $registrationDao =& DAORegistry::getDAO('RegistrationDAO');
     $registrationTypeDao =& DAORegistry::getDAO('RegistrationTypeDAO');
     $registrationType =& $registrationTypeDao->getRegistrationType($this->getData('registrationTypeId'));
     if (!$registrationType || $registrationType->getSchedConfId() != $schedConf->getId()) {
         Request::redirect('index');
     }
     import('classes.payment.ocs.OCSPaymentManager');
     $paymentManager =& OCSPaymentManager::getManager();
     if (!$paymentManager->isConfigured()) {
         return REGISTRATION_NO_PAYMENT;
     }
     if ($this->_registration) {
         // An existing registration was already in place. Compare and notify someone.
         $oldRegistration =& $this->_registration;
         $oldRegistrationType =& $registrationTypeDao->getRegistrationType($oldRegistration->getTypeId());
         unset($this->_registration);
         import('mail.MailTemplate');
         $mail = new MailTemplate('USER_REGISTRATION_CHANGE');
         $mail->setFrom($schedConf->getSetting('registrationEmail'), $schedConf->getSetting('registrationName'));
         $mail->addRecipient($schedConf->getSetting('registrationEmail'), $schedConf->getSetting('registrationName'));
         $optionsDiffer = '';
         $registrationOptionDao =& DAORegistry::getDAO('RegistrationOptionDAO');
         $registrationOptionIterator =& $registrationOptionDao->getRegistrationOptionsBySchedConfId($schedConf->getId());
         $oldRegistrationOptionIds = $registrationOptionDao->getRegistrationOptions($oldRegistration->getRegistrationId());
         while ($registrationOption =& $registrationOptionIterator->next()) {
             $optionId = $registrationOption->getOptionId();
             $previouslyChosen = in_array($optionId, $oldRegistrationOptionIds);
             $newlyChosen = in_array($optionId, $registrationOptionIds);
             if ($previouslyChosen && !$newlyChosen) {
                 $optionsDiffer .= Locale::translate('schedConf.registrationOptions.removed', array('option' => $registrationOption->getRegistrationOptionName())) . "\n";
             } elseif (!$previouslyChosen && $newlyChosen) {
                 $optionsDiffer .= Locale::translate('schedConf.registrationOptions.added', array('option' => $registrationOption->getRegistrationOptionName())) . "\n";
             }
             unset($registrationOption);
         }
         $mail->assignParams(array('managerName' => $schedConf->getSetting('registrationName'), 'registrationId' => $oldRegistration->getRegistrationId(), 'registrantName' => $user->getFullName(), 'oldRegistrationType' => $oldRegistrationType->getSummaryString(), 'newRegistrationType' => $registrationType->getSummaryString(), 'differingOptions' => $optionsDiffer, 'username' => $user->getUsername(), 'registrationContactSignature' => $schedConf->getSetting('registrationName')));
         $mail->send();
         $registrationDao->deleteRegistrationById($oldRegistration->getRegistrationId());
     }
     import('classes.registration.Registration');
     $registration = new Registration();
     $registration->setSchedConfId($schedConf->getId());
     $registration->setUserId($user->getId());
     $registration->setTypeId($this->getData('registrationTypeId'));
     $registration->setSpecialRequests($this->getData('specialRequests') ? $this->getData('specialRequests') : null);
     $registration->setDateRegistered(time());
     $registrationId = $registrationDao->insertRegistration($registration);
     $registrationOptionDao =& DAORegistry::getDAO('RegistrationOptionDAO');
     $registrationOptions =& $registrationOptionDao->getRegistrationOptionsBySchedConfId($schedConf->getId());
     $cost = $registrationType->getCost();
     $registrationOptionCosts = $registrationTypeDao->getRegistrationOptionCosts($this->getData('registrationTypeId'));
     while ($registrationOption =& $registrationOptions->next()) {
         if (in_array($registrationOption->getOptionId(), $registrationOptionIds) && strtotime($registrationOption->getOpeningDate()) < time() && strtotime($registrationOption->getClosingDate()) > time() && $registrationOption->getPublic()) {
             $registrationOptionDao->insertRegistrationOptionAssoc($registrationId, $registrationOption->getOptionId());
             $cost += $registrationOptionCosts[$registrationOption->getOptionId()];
         }
         unset($registrationOption);
     }
     $queuedPayment =& $paymentManager->createQueuedPayment($schedConf->getConferenceId(), $schedConf->getId(), QUEUED_PAYMENT_TYPE_REGISTRATION, $user->getId(), $registrationId, $cost, $registrationType->getCurrencyCodeAlpha());
     $queuedPaymentId = $paymentManager->queuePayment($queuedPayment, time() + 60 * 60 * 24 * 30);
     // 30 days to complete
     if ($cost == 0) {
         $paymentManager->fulfillQueuedPayment($queuedPaymentId, $queuedPayment);
         return REGISTRATION_FREE;
     } else {
         $paymentManager->displayPaymentForm($queuedPaymentId, $queuedPayment);
     }
     $this->_registration =& $registration;
     $this->_queuedPayment =& $queuedPayment;
     // Add reviewing interests to interests table
     $interestDao =& DAORegistry::getDAO('InterestDAO');
     $interests = Request::getUserVar('interestsKeywords');
     $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);
     return REGISTRATION_SUCCESSFUL;
 }
Example #15
0
 /**
  * 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()
 {
     $requireValidation = Config::getVar('email', 'require_validation');
     if ($this->existingUser) {
         // Existing user in the system
         $userDao =& DAORegistry::getDAO('UserDAO');
         $user =& $userDao->getUserByUsername($this->getData('username'));
         if ($user == null) {
             return false;
         }
         $userId = $user->getId();
     } else {
         // New user
         $user = new User();
         $user->setUsername($this->getData('username'));
         $user->setSalutation($this->getData('salutation'));
         $user->setFirstName($this->getData('firstName'));
         $user->setMiddleName($this->getData('middleName'));
         $user->setInitials($this->getData('initials'));
         $user->setLastName($this->getData('lastName'));
         $user->setGender($this->getData('gender'));
         $user->setAffiliation($this->getData('affiliation'));
         $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->setBiography($this->getData('biography'), null);
         // Localized
         $user->setInterests($this->getData('interests'), null);
         // Localized
         $user->setDateRegistered(Core::getCurrentDate());
         $user->setCountry($this->getData('country'));
         $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 (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'));
         }
         $userDao =& DAORegistry::getDAO('UserDAO');
         $userDao->insertUser($user);
         $userId = $user->getId();
         if (!$userId) {
             return false;
         }
         $sessionManager =& SessionManager::getManager();
         $session =& $sessionManager->getUserSession();
         $session->setSessionVar('username', $user->getUsername());
     }
     $conference =& Request::getConference();
     $schedConf =& Request::getSchedConf();
     $roleDao =& DAORegistry::getDAO('RoleDAO');
     // Roles users are allowed to register themselves in
     $allowedRoles = array('reader' => 'createAsReader', 'author' => 'createAsAuthor', 'reviewer' => 'createAsReviewer');
     import('schedConf.SchedConfAction');
     if (!SchedConfAction::allowRegReader($schedConf)) {
         unset($allowedRoles['reader']);
     }
     if (!SchedConfAction::allowRegAuthor($schedConf)) {
         unset($allowedRoles['author']);
     }
     if (!SchedConfAction::allowRegReviewer($schedConf)) {
         unset($allowedRoles['reviewer']);
     }
     foreach ($allowedRoles as $k => $v) {
         $roleId = $roleDao->getRoleIdFromPath($k);
         if ($this->getData($v) && !$roleDao->roleExists($conference->getId(), $schedConf->getId(), $userId, $roleId)) {
             $role = new Role();
             $role->setConferenceId($conference->getId());
             $role->setSchedConfId($schedConf->getId());
             $role->setUserId($userId);
             $role->setRoleId($roleId);
             $roleDao->insertRole($role);
         }
     }
     if (!$this->existingUser) {
         $this->sendConfirmationEmail($user, $this->getData('password'), $this->getData('sendPassword'));
     }
     if (isset($allowedRoles['reader']) && $this->getData('openAccessNotification')) {
         $userSettingsDao =& DAORegistry::getDAO('UserSettingsDAO');
         $userSettingsDao->updateSetting($userId, 'openAccessNotification', true, 'bool', $conference->getId());
     }
 }
Example #17
0
 /**
  * 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;
 }
Example #18
0
 $User->setLanguage(Utils::NullIfEmpty($_POST['selectLanguage']));
 $User->setDateDisplayOptions($_POST['selectDateformat']);
 $User->setImageview(Utils::NullIfEmpty($_POST['selectImageview']));
 if ($CurrentUser->hasPermission(RIGHT_USER_RIGHTS)) {
     $getrights = array();
     foreach (Rights::getDefinedRights() as $k => $v) {
         if (array_key_exists('chk' . $k, $_POST)) {
             $getrights[] = $v;
         }
     }
     $User->setRights($getrights);
 }
 if (array_key_exists('radGender', $_POST)) {
     switch (intval($_POST['radGender'])) {
         case GENDER_FEMALE:
             $User->setGender(GENDER_FEMALE);
             break;
         case GENDER_MALE:
             $User->setGender(GENDER_MALE);
             break;
         default:
         case GENDER_UNKNOWN:
             $User->setGender(GENDER_UNKNOWN);
             break;
     }
 } else {
     $User->setGender(GENDER_UNKNOWN);
 }
 if (array_key_exists('txtPassword', $_POST) && $_POST['txtPassword']) {
     if ($_POST['txtRepeatPassword'] && $_POST['txtRepeatPassword'] == $_POST['txtPassword']) {
         $NewSalt = Utils::GenerateGarbage(20);