function getUserForID($userId)
 {
     $user = new User();
     ini_set('display_errors', 'On');
     $db = "w4111c.cs.columbia.edu:1521/adb";
     $conn = oci_connect("kpg2108", "test123", $db);
     $stmt = oci_parse($conn, "select * from users where user_Id='" . $userId . "'");
     $rows = oci_execute($stmt);
     oci_close($conn);
     while ($row = oci_fetch_assoc($stmt)) {
         echo $row['LOGIN_ID'];
         $user->setUserId($row['USER_ID']);
         $user->setPassword($row['PASSWORD']);
         $user->setFirstName($row['FNAME']);
         $user->setLastName($row['LNAME']);
         $user->setLoginId($row['LOGIN_ID']);
         $user->setEmailId($row['EMAIL_ID']);
         $user->setAddress($row['ADDRESS']);
         $user->setPhoneNumber($row['PHONE_NO']);
         $user->setSecurityAnswer($row['ANSWER']);
         $user->setSecurityQuestion($row['QUESTION']);
         $user->setMiles($row['MILES']);
     }
     return $user;
 }
 /**
  * Connects to the DB, gets the data from DB
  * and creates an array of users which were stored in DB
  * @param nothing
  * @return  true, if the array containing users was created, false if an error appeared
  */
 public function generateArray()
 {
     try {
         $userArr = DB::getInstance()->getUsersList();
         // Connect to DB and get users
         foreach ($userArr as $oneUser) {
             // For each row that represents one user
             $user = new User();
             $x = 0;
             // Counter
             foreach ($oneUser as $userData) {
                 // Set user data. Each cell in the row represents user's data
                 if ($x == 1) {
                     $user->setUsername($userData);
                 } elseif ($x == 2) {
                     $user->setPassword($userData);
                 } elseif ($x == 3) {
                     $user->setFirstName($userData);
                 } elseif ($x == 4) {
                     $user->setLastName($userData);
                 } elseif ($x == 5) {
                     $user->setEmailAddress($userData);
                 } elseif ($x == 6) {
                     $user->setDescription($userData);
                 }
                 $x++;
             }
             $this->addUserToArray($user);
         }
         return true;
     } catch (\Exception $e) {
         // Catch exception
         return false;
     }
 }
Example #3
0
 private function doUpdate(User $user, $firstName, $lastName, $default)
 {
     $this->validate($firstName, $lastName);
     $user->setFirstName($firstName);
     $user->setLastName($lastName);
     $user->setDefault($default);
     return $this->updateUser($user);
 }
 protected function createUser()
 {
     $user = new User();
     $user->setFirstName('John');
     $user->setLastName('Smith Jr.');
     $user->setEmailAddress('*****@*****.**');
     $user->setDateCreated(new fTimestamp());
     $user->setHashedPassword('8njsbck');
     return $user;
 }
Example #5
0
 /**
  * @param string $data
  * @return UserInterface $user
  */
 private function mapRestRepresentationToUser($data)
 {
     $user = new User();
     $user->setFirstName($data['first-name']);
     $user->setLastName($data['last-name']);
     $user->setDisplayName($data['display-name']);
     $user->setEmail($data['email']);
     $user->setActive($data['active']);
     $user->setUsername($data['name']);
     return $user;
 }
Example #6
0
 protected function getAsObject($row)
 {
     $result = new User();
     $result->setNew(false);
     $result->setId(Singleton::create("NullConverter")->fromDBtoDOM($row["id"]));
     $result->setFirstName(Singleton::create("NullConverter")->fromDBtoDOM($row["firstName"]));
     $result->setLastName(Singleton::create("NullConverter")->fromDBtoDOM($row["lastName"]));
     $result->setCreateDate(Singleton::create("DateConverter")->fromDBtoDOM($row["createDate"]));
     $result->setDefault(Singleton::create("BooleanConverter")->fromDBtoDOM($row["default"]));
     return $result;
 }
 public static function map(User $user, array $properties)
 {
     if (array_key_exists('id', $properties)) {
         $user->setId($properties['id']);
     }
     if (array_key_exists('first_name', $properties)) {
         $user->setFirstName($properties['first_name']);
     }
     if (array_key_exists('user_password', $properties)) {
         $user->setUserPassword($properties['user_password']);
     }
 }
 /**
  * @param int $id
  * @param $email
  * @param string $firstName
  * @param string $lastName
  * @param string $password
  * @param string $picture
  * @param string $file
  * @param int $role
  * @param int $displayed
  * @return User
  * @internal param string $userName
  */
 public static function createUser($id, $email, $firstName = "", $lastName = "", $password = null, $picture = null, $file = null, $role = 0, $displayed = 0)
 {
     $user = new User();
     $user->setId($id);
     $user->setEmail($email);
     $user->setFirstName($firstName);
     $user->setLastName($lastName);
     $user->setPassword($password);
     $user->setPicture($picture);
     $user->setFile($file);
     $user->setDisplay($displayed);
     $user->setRole($role);
     return $user;
 }
 /**
  * Create initial required data.
  * @return boolean
  */
 function createData()
 {
     // Add initial site data
     $locale = $this->getParam('locale');
     $siteDao =& DAORegistry::getDAO('SiteDAO', $this->dbconn);
     $site = new Site();
     $site->setRedirect(0);
     $site->setMinPasswordLength(INSTALLER_DEFAULT_MIN_PASSWORD_LENGTH);
     $site->setPrimaryLocale($locale);
     $site->setInstalledLocales($this->installedLocales);
     $site->setSupportedLocales($this->installedLocales);
     if (!$siteDao->insertSite($site)) {
         $this->setError(INSTALLER_ERROR_DB, $this->dbconn->errorMsg());
         return false;
     }
     $siteSettingsDao =& DAORegistry::getDAO('SiteSettingsDAO');
     $siteSettingsDao->updateSetting('title', array($locale => __(INSTALLER_DEFAULT_SITE_TITLE)), null, true);
     $siteSettingsDao->updateSetting('contactName', array($locale => __(INSTALLER_DEFAULT_SITE_TITLE)), null, true);
     $siteSettingsDao->updateSetting('contactEmail', array($locale => $this->getParam('adminEmail')), null, true);
     // Add initial site administrator user
     $userDao =& DAORegistry::getDAO('UserDAO', $this->dbconn);
     $user = new User();
     $user->setUsername($this->getParam('adminUsername'));
     $user->setPassword(Validation::encryptCredentials($this->getParam('adminUsername'), $this->getParam('adminPassword'), $this->getParam('encryption')));
     $user->setFirstName($user->getUsername());
     $user->setLastName('');
     $user->setEmail($this->getParam('adminEmail'));
     if (!$userDao->insertUser($user)) {
         $this->setError(INSTALLER_ERROR_DB, $this->dbconn->errorMsg());
         return false;
     }
     $roleDao =& DAORegistry::getDao('RoleDAO', $this->dbconn);
     $role = new Role();
     $role->setJournalId(0);
     $role->setUserId($user->getId());
     $role->setRoleId(ROLE_ID_SITE_ADMIN);
     if (!$roleDao->insertRole($role)) {
         $this->setError(INSTALLER_ERROR_DB, $this->dbconn->errorMsg());
         return false;
     }
     // Install email template list and data for each locale
     $emailTemplateDao =& DAORegistry::getDAO('EmailTemplateDAO');
     $emailTemplateDao->installEmailTemplates($emailTemplateDao->getMainEmailTemplatesFilename());
     foreach ($this->installedLocales as $locale) {
         $emailTemplateDao->installEmailTemplateData($emailTemplateDao->getMainEmailTemplateDataFilename($locale));
     }
     // Install filters and filter templates.
     $this->installFilterTemplates();
     return true;
 }
Example #10
0
 public function mapUserDtoToUser(UserDto $userDto)
 {
     $user = new User();
     $user->setId($userDto->getId());
     $user->setEmail($userDto->getEmail());
     $user->setFirstName($userDto->getFirstName());
     $user->setLastName($userDto->getLastName());
     $user->setUsername($userDto->getUserName());
     $user->setPicture($userDto->getPicture());
     $user->setFile($userDto->getFile());
     $user->setDisplay($userDto->getDisplay());
     $user->setRole($userDto->getRole());
     return $user;
 }
 function testCreate_ManyToMany()
 {
     $this->_createModelAndIncludeThem('user', 'User');
     $this->_createModelAndIncludeThem('group', 'Group');
     $user = new User();
     $user->setFirstName($user_first_name = 'Vasya');
     $user->save();
     $group = new Group();
     $group->setTitle($group_title = 'Moderasti');
     $group->getUsers()->add($user);
     $group->save();
     $loaded_user = lmbActiveRecord::findById('User', $user->getId());
     $this->assertEqual($loaded_user->getFirstName(), $user_first_name);
     $this->assertEqual($loaded_user->getGroups()->at(0)->getId(), $group->getId());
     $loaded_group = lmbActiveRecord::findById('Group', $group->getId());
     $this->assertEqual($loaded_group->getUsers()->at(0)->getId(), $user->getId());
 }
Example #12
0
 public function configureUser()
 {
     $_response = User::login(request_var('cmbCompany'), request_var('userId'));
     if (is_array($_response) && count($_response)) {
         session_init();
         $objUser = new User();
         $objUser->setId($_response["ParticipanteId"]);
         $objUser->setIdentification($_response["Identificacion"]);
         $objUser->setFirstName($_response["Nombre"]);
         $objUser->setLastName($_response["Apellido"]);
         $objUser->setFullName($_response["Nombre"] . " " . $_response["Apellido"]);
         $objUser->setUsername($_response["UsuarioId"]);
         $objUser->setCompany(request_var('cmbCompany'));
         $objUser->setOffice(request_var("cmbOffice"));
         set_session_var(VAR_USER, $objUser);
         send_redirect("../view/main/master.php");
     }
 }
 public function getAbonentByID($user_id)
 {
     try {
         $sql = "select * from users t1, phonenumbers t2 where t1.user_id=t2.user_id and t1.user_id=?";
         $query = $this->db->query($sql, array($user_id));
         $UserObj = new User();
         if ($query->num_rows() > 0) {
             $row = $query->row_array();
             $UserObj->setID($row['user_id']);
             $UserObj->setFirstName($row['first_name']);
             $UserObj->setLastName($row['last_name']);
             $UserObj->setAddress($row['address']);
             $UserObj->setPhoneNumber($row['phonenumber']);
         }
         return $UserObj;
     } catch (Exception $e) {
         throw new Exception($e->getMessage());
     }
 }
 public static function map(User $user, array $properties)
 {
     if (array_key_exists('id', $properties)) {
         $user->setId($properties['id']);
     }
     if (array_key_exists('first_name', $properties)) {
         $user->setFirstName($properties['first_name']);
     }
     if (array_key_exists('last_name', $properties)) {
         $user->setLastName($properties['last_name']);
     }
     if (array_key_exists('user_password', $properties)) {
         $user->setPassword($properties['user_password']);
     }
     if (array_key_exists('email', $properties)) {
         $user->setEmail($properties['email']);
     }
     if (array_key_exists('address_id', $properties)) {
         $user->setAddressId($properties['address_id']);
     }
 }
Example #15
0
 public function testCreate()
 {
     $user = new User();
     $user->setId(1);
     $user->setEmail('*****@*****.**');
     $user->setPassword('xxxx');
     $user->setFirstName('John');
     $user->setLastName('Doe');
     $user->addRole(new UserRole());
     $user->addVehicle(new Vehicle());
     $this->assertSame(null, $user->getUpdated());
     $user->setUpdated();
     $user->preUpdate();
     $this->assertSame(1, $user->getId());
     $this->assertTrue($user->getCreated() instanceof \DateTime);
     $this->assertTrue($user->getUpdated() instanceof \DateTime);
     $this->assertSame('*****@*****.**', $user->getEmail());
     $this->assertSame('John', $user->getFirstName());
     $this->assertSame('Doe', $user->getLastName());
     $this->assertTrue($user->getRoles()[0] instanceof UserRole);
     $this->assertTrue($user->getVehicles()[0] instanceof Vehicle);
 }
 public function executeNewuser(sfWebRequest $request)
 {
     $this->form = new UserForm();
     // check if the data is coming from POST method
     if ($request->isMethod('post')) {
         // bind the form
         $this->form->bind($request->getParameter($this->form->getName()));
         $captcha = new reCaptcha();
         $responsecaptcha = $captcha->recaptcha_check_answer($_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
         //check capcha
         if (!$responsecaptcha->is_valid) {
             $this->getUser()->setFlash('message', 'Invalid Sequrity Code,Please enter again');
         } else {
             $formData = $this->form->getValues();
             $checkUsernameAndEmail = Doctrine::getTable('User')->func_checkUsernameAndEmail($formData['email_address'], $formData['username']);
             if (count($checkUsernameAndEmail)) {
                 $this->getUser()->setFlash('message', 'UserName or Email is already taken');
             } else {
                 $user = new User();
                 $user->setUsername($formData['username']);
                 $getSalt = Doctrine::getTable('User')->func_generateSalt();
                 $getPassword = Doctrine::getTable('User')->func_generatePassword($getSalt, $formData['pass']);
                 $user->setSalt($getSalt);
                 $user->setPass($getPassword);
                 $user->setIsActive(0);
                 $user->setFirstName($formData['first_name']);
                 $user->setLastName($formData['last_name']);
                 $user->setEmailAddress($formData['email_address']);
                 $user->save();
                 Doctrine::getTable('User')->func_sendVerificationEmail($formData['first_name'], $formData['email_address'], $getSalt);
                 $this->getUser()->setFlash('message', 'Thanks for registration. Account activation link has been sent into your email address.');
                 $this->redirect('@login');
             }
             // if the username and email does not exist
         }
     }
     // check if the method is POST
 }
Example #17
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 #18
0
 public function addUserAction()
 {
     $request = $this->getRequest();
     $baseUrl = $request->getBaseUrl();
     $this->view->headScript()->appendFile($baseUrl . '/js/datatables/js/jquery.dataTables.js', 'text/javascript');
     $this->view->headScript()->appendFile($baseUrl . '/js/datatables/plugin/dataTables.pluginAPI.js', 'text/javascript');
     $this->view->headScript()->appendFile($baseUrl . '/js/airtime/user/user.js', 'text/javascript');
     $form = new Application_Form_AddUser();
     $this->view->successMessage = "";
     if ($request->isPost()) {
         if ($form->isValid($request->getPost())) {
             $formdata = $form->getValues();
             if ($form->validateLogin($formdata)) {
                 $user = new User($formdata['user_id']);
                 $user->setFirstName($formdata['first_name']);
                 $user->setLastName($formdata['last_name']);
                 $user->setLogin($formdata['login']);
                 if ($formdata['password'] != "xxxxxx") {
                     $user->setPassword($formdata['password']);
                 }
                 $user->setType($formdata['type']);
                 $user->setEmail($formdata['email']);
                 $user->setSkype($formdata['skype']);
                 $user->setJabber($formdata['jabber']);
                 $user->save();
                 $form->reset();
                 if (strlen($formdata['user_id']) == 0) {
                     $this->view->successMessage = "<div class='success'>User added successfully!</div>";
                 } else {
                     $this->view->successMessage = "<div class='success'>User updated successfully!</div>";
                 }
             }
         }
     }
     $this->view->form = $form;
 }
<?php

$autoloader = (require '/vendor/autoload.php');
require './generated-conf/config.php';
$user = new User();
$user->setFirstName('Steven');
$user->setLastName('Chin');
$user->setNetID('sachin');
$user->setEmail('*****@*****.**');
$user->save();
Example #20
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;
 }
Example #21
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);
     }
 }
 /**
  * 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 #23
0
 /**
  * Import papers (including metadata and files).
  */
 function importPapers()
 {
     if ($this->hasOption('verbose')) {
         printf("Importing papers\n");
     }
     import('classes.file.PaperFileManager');
     import('classes.search.PaperSearchIndex');
     $userDao =& DAORegistry::getDAO('UserDAO');
     $roleDao =& DAORegistry::getDAO('RoleDAO');
     $trackDao =& DAORegistry::getDAO('TrackDAO');
     $paperDao =& DAORegistry::getDAO('PaperDAO');
     $publishedPaperDao =& DAORegistry::getDAO('PublishedPaperDAO');
     $galleyDao =& DAORegistry::getDAO('PaperGalleyDAO');
     $unassignedTrackId = null;
     $result =& $this->importDao->retrieve('SELECT * FROM papers ORDER by id');
     while (!$result->EOF) {
         $row =& $result->fields;
         $schedConf =& $this->schedConfMap[$row['cf']];
         $schedConfId = $schedConf->getId();
         // Bring in the primary user for this paper.
         $user = $userDao->getUserByUsername(Core::cleanVar($row['login']));
         if (!$user) {
             unset($user);
             $user = new User();
             $user->setUsername(Core::cleanVar($row['login']));
             $user->setFirstName(Core::cleanVar($row['first_name']));
             $user->setLastName(Core::cleanVar($row['surname']));
             $user->setAffiliation(Core::cleanVar($row['affiliation']), Locale::getLocale());
             $user->setEmail(Core::cleanVar($row['email']));
             $user->setUrl(Core::cleanVar($row['url']));
             $user->setBiography(Core::cleanVar($row['bio']), Locale::getLocale());
             $user->setLocales(array());
             $user->setDateRegistered($row['created']);
             $user->setDateLastLogin($row['created']);
             $user->setMustChangePassword(1);
             $password = Validation::generatePassword();
             $user->setPassword(Validation::encryptCredentials($user->getUsername(), $password));
             if ($this->hasOption('emailUsers')) {
                 import('classes.mail.MailTemplate');
                 $mail = new MailTemplate('USER_REGISTER');
                 $mail->setFrom($schedConf->getSetting('contactEmail'), $schedConf->getSetting('contactName'));
                 $mail->assignParams(array('username' => $user->getUsername(), 'password' => $password, 'conferenceName' => $schedConf->getFullTitle()));
                 $mail->addRecipient($user->getEmail(), $user->getFullName());
                 $mail->send();
             }
             $user->setDisabled(0);
             $otherUser =& $userDao->getUserByEmail(Core::cleanVar($row['email']));
             if ($otherUser !== null) {
                 // User exists with this email -- munge it to make unique
                 $user->setEmail('ocs-' . Core::cleanVar($row['login']) . '+' . Core::cleanVar($row['email']));
                 $this->conflicts[] = array(&$otherUser, &$user);
             }
             unset($otherUser);
             $userDao->insertUser($user);
             // Make this user a author
             $role = new Role();
             $role->setSchedConfId($schedConf->getId());
             $role->setConferenceId($schedConf->getConferenceId());
             $role->setUserId($user->getId());
             $role->setRoleId(ROLE_ID_AUTHOR);
             $roleDao->insertRole($role);
             unset($role);
         }
         $userId = $user->getId();
         // Bring in the basic entry for the paper
         $paper = new Paper();
         $paper->setUserId($userId);
         $paper->setLocale(Locale::getPrimaryLocale());
         $paper->setSchedConfId($schedConfId);
         $oldTrackId = $row['primary_track_id'];
         if (!$oldTrackId || !isset($this->trackMap[$oldTrackId])) {
             $oldTrackId = $row['secondary_track_id'];
         }
         if (!$oldTrackId || !isset($this->trackMap[$oldTrackId])) {
             if (!$unassignedTrackId) {
                 // Create an "Unassigned" track to use for submissions
                 // that didn't have a track in OCS 1.x.
                 $track = new Track();
                 $track->setSchedConfId($schedConf->getId());
                 $track->setTitle('UNASSIGNED', Locale::getLocale());
                 $track->setSequence(REALLY_BIG_NUMBER);
                 $track->setDirectorRestricted(1);
                 $track->setMetaReviewed(1);
                 $unassignedTrackId = $trackDao->insertTrack($track);
             }
             $newTrackId = $unassignedTrackId;
         } else {
             $newTrackId = $this->trackMap[$oldTrackId];
         }
         $paper->setTrackId($newTrackId);
         $paper->setTitle(Core::cleanVar($row['title']), Locale::getLocale());
         $paper->setAbstract(Core::cleanVar($row['abstract']), Locale::getLocale());
         $paper->setDiscipline(Core::cleanVar($row['discipline']), Locale::getLocale());
         $paper->setSponsor(Core::cleanVar($row['sponsor']), Locale::getLocale());
         $paper->setSubject(Core::cleanVar($row['topic']), Locale::getLocale());
         $paper->setLanguage(Core::cleanVar($row['language']));
         $paper->setDateSubmitted($row['created']);
         $paper->setDateStatusModified($row['timestamp']);
         // $paper->setTypeConst($row['present_format'] == 'multiple' ? SUBMISSION_TYPE_PANEL : SUBMISSION_TYPE_SINGLE); FIXME
         $paper->setCurrentRound(REVIEW_ROUND_ABSTRACT);
         $paper->setSubmissionProgress(0);
         $paper->setPages('');
         // Bring in authors
         $firstNames = split("\n", Core::cleanVar($row['first_name'] . "\n" . $row['add_first_names']));
         $lastNames = split("\n", Core::cleanVar($row['surname'] . "\n" . $row['add_surnames']));
         $emails = split("\n", Core::cleanVar($row['email'] . "\n" . $row['add_emails']));
         $affiliations = split("\n", Core::cleanVar($row['affiliation'] . "\n" . $row['add_affiliations']));
         $urls = split("\n", Core::cleanVar($row['url'] . "\n" . $row['add_urls']));
         foreach ($emails as $key => $email) {
             if (empty($email)) {
                 continue;
             }
             $author = new Author();
             $author->setEmail($email);
             $author->setFirstName($firstNames[$key]);
             $author->setLastName($lastNames[$key]);
             $author->setAffiliation($affiliations[$key], Locale::getLocale());
             @$author->setUrl($urls[$key]);
             // Suppress warnings from inconsistent OCS 1.x data
             $author->setPrimaryContact($key == 0 ? 1 : 0);
             $paper->addAuthor($author);
             unset($author);
         }
         switch ($row['accepted']) {
             case 'true':
                 $paper->setStatus(STATUS_PUBLISHED);
                 $paperId = $paperDao->insertPaper($paper);
                 $publishedPaper = new PublishedPaper();
                 $publishedPaper->setPaperId($paperId);
                 $publishedPaper->setSchedConfId($schedConfId);
                 $publishedPaper->setDatePublished(Core::getCurrentDate());
                 $publishedPaper->setSeq(REALLY_BIG_NUMBER);
                 $publishedPaper->setViews(0);
                 $publishedPaperDao->insertPublishedPaper($publishedPaper);
                 $publishedPaperDao->resequencePublishedPapers($paper->getTrackId(), $schedConfId);
                 break;
             case 'reject':
                 $paper->setStatus(STATUS_DECLINED);
                 $paperId = $paperDao->insertPaper($paper);
                 break;
             default:
                 $paper->setStatus(STATUS_QUEUED);
                 $paperId = $paperDao->insertPaper($paper);
         }
         $this->paperMap[$row['id']] =& $paper;
         $paperFileManager = new PaperFileManager($paperId);
         if (!empty($row['paper']) && $row['paper'] != 'PDF') {
             $format = 'text/html';
             $extension = $paperFileManager->getDocumentExtension($format);
             $fileId = $paperFileManager->writeSubmissionFile('migratedFile' . $extension, $row['paper'], $format);
             $paper->setSubmissionFileId($fileId);
             $paperDao->updatePaper($paper);
             $fileId = $paperFileManager->writePublicFile('migratedGalley' . $extension, $row['paper'], $format);
             PaperSearchIndex::updateFileIndex($paperId, PAPER_SEARCH_GALLEY_FILE, $fileId);
             if (strstr($format, 'html')) {
                 $galley = new PaperHTMLGalley();
                 $galley->setLabel('HTML');
             } else {
                 $galley = new PaperGalley();
                 switch ($format) {
                     case 'application/pdf':
                         $galley->setLabel('PDF');
                         break;
                     case 'application/postscript':
                         $galley->setLabel('PostScript');
                         break;
                     case 'application/msword':
                         $galley->setLabel('Word');
                         break;
                     case 'text/xml':
                         $galley->setLabel('XML');
                         break;
                     case 'application/powerpoint':
                         $galley->setLabel('Slideshow');
                         break;
                     default:
                         $galley->setLabel('Untitled');
                         break;
                 }
             }
             $galley->setLocale(Locale::getLocale());
             $galley->setPaperId($paperId);
             $galley->setFileId($fileId);
             $galleyDao->insertGalley($galley);
             unset($galley);
         } elseif ($row['paper'] == 'PDF') {
             $fileId = $paperFileManager->copySubmissionFile($this->importPath . '/papers/' . $row['pdf'], 'application/pdf');
             $paper->setSubmissionFileId($fileId);
             $paperDao->updatePaper($paper);
             $fileId = $paperFileManager->copyPublicFile($this->importPath . '/papers/' . $row['pdf'], 'application/pdf');
             PaperSearchIndex::updateFileIndex($paperId, PAPER_SEARCH_GALLEY_FILE, $fileId);
             $galley = new PaperGalley();
             $galley->setLabel('PDF');
             $galley->setLocale(Locale::getLocale());
             $galley->setPaperId($paperId);
             $galley->setFileId($fileId);
             $galleyDao->insertGalley($galley);
             unset($galley);
         }
         // FIXME: The following fields from OCS 1.x are UNUSED:
         // program_insert approach coverage format relation appendix_names appendix_dates
         // appendix appendix_pdf secondary_track_id multiple_* restrict_access paper_email
         // delete_paper comment_email
         unset($user);
         unset($paper);
         unset($schedConf);
         unset($paperFileManager);
         $result->MoveNext();
     }
     $result->Close();
 }
Example #24
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;
 }
Example #25
0
 /**
  * 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);
     }
 }
Example #26
0
 /**
  * Register a new user. See classes/user/form/RegistrationForm.inc.php - for how this is done for registering a user in a non-shib environment.
  */
 function registerUserFromShib()
 {
     // Grab the names of the header fields from the config file
     $uin = Config::getVar('security', 'implicit_auth_header_uin');
     // For TDL this is HTTP_TDL_TDLUID
     $first_name = Config::getVar('security', 'implicit_auth_header_first_name');
     $last_name = Config::getVar('security', 'implicit_auth_header_last_name');
     $email = Config::getVar('security', 'implicit_auth_header_email');
     $phone = Config::getVar('security', 'implicit_auth_header_phone');
     $initials = Config::getVar('security', 'implicit_auth_header_initials');
     $mailing_address = Config::getVar('security', 'implicit_auth_header_mailing_address');
     $uin = Config::getVar('security', 'implicit_auth_header_uin');
     // Create a new user object and set it's fields from the header variables
     $user = new User();
     $user->setAuthStr($_SERVER[$uin]);
     $user->setUsername($_SERVER[$email]);
     # Mail is userid
     $user->setFirstName($_SERVER[$first_name]);
     $user->setLastName($_SERVER[$last_name]);
     $user->setEmail($_SERVER[$email]);
     $user->setPhone($_SERVER[$phone]);
     $user->setMailingAddress($_SERVER[$mailing_address]);
     $user->setDateRegistered(Core::getCurrentDate());
     // Set the user's  password to their email address. This may or may not be necessary
     $email = Config::getVar('security', 'implicit_auth_header_email');
     $user->setPassword(Validation::encryptCredentials($email, $email . 'pass'));
     // Now go insert the user in the db
     $userDao =& DAORegistry::getDAO('UserDAO');
     $userDao->insertUser($user);
     $userId = $user->getId();
     if (!$userId) {
         return false;
     }
     // Go put the user into the session and return it.
     $sessionManager =& SessionManager::getManager();
     $session =& $sessionManager->getUserSession();
     $session->setSessionVar('username', $user->getUsername());
     return $user;
 }
 $validator->addValidation("lastName", "req", "Please fill in last name");
 $validator->addValidation("lastName", "alpha", "Please fill only alphabets for last name");
 $validator->addValidation("address", "req", "Please fill in address");
 $validator->addValidation("phoneNo", "req", "Please fill in phone number");
 $validator->addValidation("phoneNo", "numeric", "Please fill only numeric values for phone number");
 $validator->addValidation("passwordRecoveryQues", "req", "Please fill in password recovery question");
 $validator->addValidation("passwordRecoveryAns", "req", "Please fill in password recovery answer");
 $validator->addValidation("email", "email", "The input for email should be a valid email value");
 $validator->addValidation("email", "req", "Please fill in email");
 if ($validator->ValidateForm()) {
     $_SESSION['action'] = "updateUser";
     $user = new User();
     $user->setUserId($_SESSION['userId']);
     $user->setLoginId($user1->getLoginId());
     $user->setPassword($_REQUEST["password"]);
     $user->setFirstName($_REQUEST["firstName"]);
     $user->setLastName($_REQUEST["lastName"]);
     $user->setEmailId($_REQUEST["email"]);
     $user->setAddress($_REQUEST["address"]);
     $user->setPhoneNumber($_REQUEST["phoneNo"]);
     $user->setSecurityAnswer($_REQUEST["passwordRecoveryQues"]);
     $user->setSecurityQuestion($_REQUEST["passwordRecoveryAns"]);
     $_SESSION['userToBeUpdated'] = serialize($user);
     header("Location: ../controller/Controller.php");
 } else {
     echo "<B>Validation Errors:</B>";
     $error_hash = $validator->GetErrors();
     foreach ($error_hash as $inpname => $inp_err) {
         echo "<p>{$inpname} : {$inp_err}</p>\n";
     }
 }
Example #28
0
 /**
  * Save review assignment
  * @param $args array
  * @param $request PKPRequest
  */
 function execute($args, &$request)
 {
     $seriesEditorSubmissionDao =& DAORegistry::getDAO('SeriesEditorSubmissionDAO');
     $submission =& $seriesEditorSubmissionDao->getSeriesEditorSubmission($this->getMonographId());
     $press =& $request->getPress();
     $reviewType = $this->getData('reviewType');
     $round = $this->getData('round');
     $reviewDueDate = $this->getData('reviewDueDate');
     $responseDueDate = $this->getData('responseDueDate');
     $selectionType = (int) $this->getData('selectionType');
     if ($selectionType == REVIEWER_SELECT_CREATE) {
         $userDao =& DAORegistry::getDAO('UserDAO');
         $user = new User();
         $user->setFirstName($this->getData('firstname'));
         $user->setMiddleName($this->getData('middlename'));
         $user->setLastName($this->getData('lastname'));
         $user->setEmail($this->getData('email'));
         $authDao =& DAORegistry::getDAO('AuthSourceDAO');
         $auth =& $authDao->getDefaultPlugin();
         $user->setAuthId($auth ? $auth->getAuthId() : 0);
         $user->setUsername($this->getData('username'));
         $password = Validation::generatePassword();
         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());
         $reviewerId = $userDao->insertUser($user);
         // Add reviewer 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
         if (empty($interests)) {
             $interests = array();
         } elseif (!is_array($interests)) {
             $interests = array($interests);
         }
         $interestDao->insertInterests($interests, $reviewerId, true);
         // Assign the selected user group ID to the user
         $userGroupDao =& DAORegistry::getDAO('UserGroupDAO');
         /* @var $userGroupDao UserGroupDAO */
         $userGroupId = (int) $this->getData('userGroupId');
         $userGroupDao->assignUserToGroup($reviewerId, $userGroupId);
         if ($this->getData('sendNotify')) {
             // Send welcome email to user
             import('classes.mail.MailTemplate');
             $mail = new MailTemplate('REVIEWER_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();
         }
     } elseif ($selectionType == REVIEWER_SELECT_ENROLL) {
         // Assign a reviewer user group to an existing non-reviewer
         $userId = $this->getData('userId');
         $userGroupId = $this->getData('userGroupId');
         $userGroupId = $this->getData('userGroupId');
         $userGroupDao =& DAORegistry::getDAO('UserGroupDAO');
         /* @var $userGroupDao UserGroupDAO */
         $userGroupDao->assignUserToGroup($userId, $userGroupId);
         // Set the reviewerId to the userId to return to the grid
         $reviewerId = $userId;
     } else {
         $reviewerId = $this->getData('reviewerId');
     }
     import('classes.submission.seriesEditor.SeriesEditorAction');
     SeriesEditorAction::addReviewer($submission, $reviewerId, $reviewType, $round, $reviewDueDate, $responseDueDate);
     // Get the reviewAssignment object now that it has been added
     $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
     $reviewAssignment =& $reviewAssignmentDao->getReviewAssignment($submission->getId(), $reviewerId, $round, $reviewType);
     $reviewAssignment->setDateNotified(Core::getCurrentDate());
     $reviewAssignment->setCancelled(0);
     $reviewAssignment->stampModified();
     $reviewAssignmentDao->updateObject($reviewAssignment);
     // Update the review round status if this is the first reviewer added
     $reviewRoundDao =& DAORegistry::getDAO('ReviewRoundDAO');
     $currentReviewRound =& $reviewRoundDao->build($this->getMonographId(), $submission->getCurrentReviewType(), $submission->getCurrentRound());
     if ($currentReviewRound->getStatus() == REVIEW_ROUND_STATUS_PENDING_REVIEWERS) {
         $currentReviewRound->setStatus(REVIEW_ROUND_STATUS_PENDING_REVIEWS);
         $reviewRoundDao->updateObject($currentReviewRound);
     }
     return $reviewAssignment;
 }
Example #29
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 #30
0
 /**
  * Create initial required data.
  * @return boolean
  */
 function createData()
 {
     if ($this->getParam('manualInstall')) {
         // Add insert statements for default data
         // FIXME use ADODB data dictionary?
         $this->executeSQL(sprintf('INSERT INTO site (primary_locale, installed_locales) VALUES (\'%s\', \'%s\')', $this->getParam('locale'), join(':', $this->installedLocales)));
         $this->executeSQL(sprintf('INSERT INTO site_settings (setting_name, setting_type, setting_value, locale) VALUES (\'%s\', \'%s\', \'%s\', \'%s\')', 'title', 'string', addslashes(Locale::translate(INSTALLER_DEFAULT_SITE_TITLE)), $this->getParam('locale')));
         $this->executeSQL(sprintf('INSERT INTO site_settings (setting_name, setting_type, setting_value, locale) VALUES (\'%s\', \'%s\', \'%s\', \'%s\')', 'contactName', 'string', addslashes(Locale::translate(INSTALLER_DEFAULT_SITE_TITLE)), $this->getParam('locale')));
         $this->executeSQL(sprintf('INSERT INTO site_settings (setting_name, setting_type, setting_value, locale) VALUES (\'%s\', \'%s\', \'%s\', \'%s\')', 'contactEmail', 'string', addslashes($this->getParam('adminEmail')), $this->getParam('locale')));
         $this->executeSQL(sprintf('INSERT INTO users (username, first_name, last_name, password, email, date_registered, date_last_login) VALUES (\'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\')', $this->getParam('adminUsername'), $this->getParam('adminUsername'), $this->getParam('adminUsername'), Validation::encryptCredentials($this->getParam('adminUsername'), $this->getParam('adminPassword'), $this->getParam('encryption')), $this->getParam('adminEmail'), Core::getCurrentDate(), Core::getCurrentDate()));
         $this->executeSQL(sprintf('INSERT INTO roles (conference_id, user_id, role_id) VALUES (%d, (SELECT user_id FROM users WHERE username = \'%s\'), %d)', 0, $this->getParam('adminUsername'), ROLE_ID_SITE_ADMIN));
         // Install email template list and data for each locale
         $emailTemplateDao =& DAORegistry::getDAO('EmailTemplateDAO');
         foreach ($emailTemplateDao->installEmailTemplates($emailTemplateDao->getMainEmailTemplatesFilename(), true) as $sql) {
             $this->executeSQL($sql);
         }
         foreach ($this->installedLocales as $locale) {
             foreach ($emailTemplateDao->installEmailTemplateData($emailTemplateDao->getMainEmailTemplateDataFilename($locale), true) as $sql) {
                 $this->executeSQL($sql);
             }
         }
     } else {
         // Add initial site data
         $locale = $this->getParam('locale');
         $siteDao =& DAORegistry::getDAO('SiteDAO', $this->dbconn);
         $site = new Site();
         $site->setRedirect(0);
         $site->setMinPasswordLength(INSTALLER_DEFAULT_MIN_PASSWORD_LENGTH);
         $site->setPrimaryLocale($locale);
         $site->setInstalledLocales($this->installedLocales);
         $site->setSupportedLocales($this->installedLocales);
         if (!$siteDao->insertSite($site)) {
             $this->setError(INSTALLER_ERROR_DB, $this->dbconn->errorMsg());
             return false;
         }
         $siteSettingsDao =& DAORegistry::getDAO('SiteSettingsDAO');
         $siteSettingsDao->updateSetting('title', array($locale => Locale::translate(INSTALLER_DEFAULT_SITE_TITLE)), null, true);
         $siteSettingsDao->updateSetting('contactName', array($locale => Locale::translate(INSTALLER_DEFAULT_SITE_TITLE)), null, true);
         $siteSettingsDao->updateSetting('contactEmail', array($locale => $this->getParam('adminEmail')), null, true);
         // Add initial site administrator user
         $userDao =& DAORegistry::getDAO('UserDAO', $this->dbconn);
         $user = new User();
         $user->setUsername($this->getParam('adminUsername'));
         $user->setPassword(Validation::encryptCredentials($this->getParam('adminUsername'), $this->getParam('adminPassword'), $this->getParam('encryption')));
         $user->setFirstName($user->getUsername());
         $user->setLastName('');
         $user->setEmail($this->getParam('adminEmail'));
         if (!$userDao->insertUser($user)) {
             $this->setError(INSTALLER_ERROR_DB, $this->dbconn->errorMsg());
             return false;
         }
         $roleDao =& DAORegistry::getDao('RoleDAO', $this->dbconn);
         $role = new Role();
         $role->setConferenceId(0);
         $role->setUserId($user->getId());
         $role->setRoleId(ROLE_ID_SITE_ADMIN);
         if (!$roleDao->insertRole($role)) {
             $this->setError(INSTALLER_ERROR_DB, $this->dbconn->errorMsg());
             return false;
         }
         // Install email template list and data for each locale
         $emailTemplateDao =& DAORegistry::getDAO('EmailTemplateDAO');
         $emailTemplateDao->installEmailTemplates($emailTemplateDao->getMainEmailTemplatesFilename());
         foreach ($this->installedLocales as $locale) {
             $emailTemplateDao->installEmailTemplateData($emailTemplateDao->getMainEmailTemplateDataFilename($locale));
         }
         // Add initial plugin data to versions table
         $versionDao =& DAORegistry::getDAO('VersionDAO');
         import('site.VersionCheck');
         $categories = PluginRegistry::getCategories();
         foreach ($categories as $category) {
             PluginRegistry::loadCategory($category, true);
             $plugins = PluginRegistry::getPlugins($category);
             foreach ($plugins as $plugin) {
                 $versionFile = $plugin->getPluginPath() . '/version.xml';
                 if (FileManager::fileExists($versionFile)) {
                     $versionInfo =& VersionCheck::parseVersionXML($versionFile);
                     $pluginVersion = $versionInfo['version'];
                     $pluginVersion->setCurrent(1);
                     $versionDao->insertVersion($pluginVersion);
                 } else {
                     $pluginVersion = new Version();
                     $pluginVersion->setMajor(1);
                     $pluginVersion->setMinor(0);
                     $pluginVersion->setRevision(0);
                     $pluginVersion->setBuild(0);
                     $pluginVersion->setDateInstalled(Core::getCurrentDate());
                     $pluginVersion->setCurrent(1);
                     $pluginVersion->setProductType('plugins.' . $category);
                     $pluginVersion->setProduct(basename($plugin->getPluginPath()));
                     $versionDao->insertVersion($pluginVersion);
                 }
             }
         }
     }
     return true;
 }