Ejemplo n.º 1
0
 /**
  * Pre-installation.
  * @return boolean
  */
 function preInstall()
 {
     $this->currentVersion = Version::fromString('');
     $this->locale = $this->getParam('locale');
     $this->installedLocales = $this->getParam('additionalLocales');
     if (!isset($this->installedLocales) || !is_array($this->installedLocales)) {
         $this->installedLocales = array();
     }
     if (!in_array($this->locale, $this->installedLocales) && Locale::isLocaleValid($this->locale)) {
         array_push($this->installedLocales, $this->locale);
     }
     if ($this->getParam('manualInstall')) {
         // Do not perform database installation for manual install
         // Create connection object with the appropriate database driver for adodb-xmlschema
         $conn =& new DBConnection($this->getParam('databaseDriver'), null, null, null, null);
         $this->dbconn =& $conn->getDBConn();
     } else {
         // Connect to database
         $conn =& new DBConnection($this->getParam('databaseDriver'), $this->getParam('databaseHost'), $this->getParam('databaseUsername'), $this->getParam('databasePassword'), $this->getParam('createDatabase') ? null : $this->getParam('databaseName'), true, $this->getParam('connectionCharset') == '' ? false : $this->getParam('connectionCharset'));
         $this->dbconn =& $conn->getDBConn();
         if (!$conn->isConnected()) {
             $this->setError(INSTALLER_ERROR_DB, $this->dbconn->errorMsg());
             return false;
         }
     }
     DBConnection::getInstance($conn);
     return parent::preInstall();
 }
 /**
  * Save modified settings.
  */
 function execute()
 {
     $journal =& Request::getJournal();
     $settingsDao =& DAORegistry::getDAO('JournalSettingsDAO');
     // Verify additional locales
     $supportedLocales = array();
     foreach ($this->getData('supportedLocales') as $locale) {
         if (Locale::isLocaleValid($locale) && in_array($locale, $this->availableLocales)) {
             array_push($supportedLocales, $locale);
         }
     }
     $primaryLocale = $this->getData('primaryLocale');
     if ($primaryLocale != null && !empty($primaryLocale) && !in_array($primaryLocale, $supportedLocales)) {
         array_push($supportedLocales, $primaryLocale);
     }
     $this->setData('supportedLocales', $supportedLocales);
     foreach ($this->_data as $name => $value) {
         if (!in_array($name, array_keys($this->settings))) {
             continue;
         }
         $settingsDao->updateSetting($journal->getJournalId(), $name, $value, $this->settings[$name]);
     }
     $journalDao =& DAORegistry::getDAO('JournalDAO');
     $journal->setPrimaryLocale($this->getData('primaryLocale'));
     $journalDao->updateJournal($journal);
 }
Ejemplo n.º 3
0
 /**
  * Display upgrade form.
  */
 function upgrade()
 {
     InstallHandler::validate();
     if (($setLocale = Request::getUserVar('setLocale')) != null && Locale::isLocaleValid($setLocale)) {
         Request::setCookieVar('currentLocale', $setLocale);
     }
     $installForm =& new UpgradeForm();
     $installForm->initData();
     $installForm->display();
 }
 /**
  * Display upgrade form.
  */
 function upgrade()
 {
     $this->validate();
     $this->setupTemplate();
     if (($setLocale = PKPRequest::getUserVar('setLocale')) != null && Locale::isLocaleValid($setLocale)) {
         PKPRequest::setCookieVar('currentLocale', $setLocale);
     }
     $installForm = new UpgradeForm();
     $installForm->initData();
     $installForm->display();
 }
 function reloadLocalizedDefaultSettings()
 {
     // make sure the locale is valid
     $locale = Request::getUserVar('localeToLoad');
     if (!Locale::isLocaleValid($locale)) {
         Request::redirect(null, null, null, 'languages');
     }
     $this->validate();
     $this->setupTemplate(true);
     $conference =& Request::getConference();
     $conferenceSettingsDao =& DAORegistry::getDAO('ConferenceSettingsDAO');
     $conferenceSettingsDao->reloadLocalizedDefaultSettings($conference->getId(), 'registry/conferenceSettings.xml', array('indexUrl' => Request::getIndexUrl(), 'conferencePath' => $conference->getData('path'), 'primaryLocale' => $conference->getPrimaryLocale(), 'conferenceName' => $conference->getTitle($conference->getPrimaryLocale())), $locale);
     $templateMgr =& TemplateManager::getManager();
     $templateMgr->assign(array('currentUrl' => Request::url(null, null, null, 'languages'), 'pageTitle' => 'common.languages', 'message' => 'common.changesSaved', 'backLink' => Request::url(null, null, Request::getRequestedPage()), 'backLinkLabel' => 'manager.conferenceSiteManagement'));
     $templateMgr->display('common/message.tpl');
 }
Ejemplo n.º 6
0
 /**
  * Reload the default localized settings for the journal.
  * @param $args array
  * @param $request object
  */
 function reloadLocalizedDefaultSettings($args, &$request)
 {
     // make sure the locale is valid
     $locale = $request->getUserVar('localeToLoad');
     if (!Locale::isLocaleValid($locale)) {
         $request->redirect(null, null, 'languages');
     }
     $this->validate();
     $this->setupTemplate(true);
     $journal =& $request->getJournal();
     $journalSettingsDao =& DAORegistry::getDAO('JournalSettingsDAO');
     $journalSettingsDao->reloadLocalizedDefaultSettings($journal->getId(), 'registry/journalSettings.xml', array('indexUrl' => $request->getIndexUrl(), 'journalPath' => $journal->getData('path'), 'primaryLocale' => $journal->getPrimaryLocale(), 'journalName' => $journal->getTitle($journal->getPrimaryLocale())), $locale);
     $templateMgr =& TemplateManager::getManager();
     $templateMgr->assign(array('currentUrl' => $request->url(null, null, 'languages'), 'pageTitle' => 'common.languages', 'message' => 'common.changesSaved', 'backLink' => $request->url(null, $request->getRequestedPage()), 'backLinkLabel' => 'manager.journalManagement'));
     $templateMgr->display('common/message.tpl');
 }
Ejemplo n.º 7
0
 /**
  * Change the locale for the current user.
  * @param $args array first parameter is the new locale
  */
 function setLocale($args)
 {
     $setLocale = isset($args[0]) ? $args[0] : null;
     $site =& Request::getSite();
     if (Locale::isLocaleValid($setLocale) && in_array($setLocale, $site->getSupportedLocales())) {
         $session =& Request::getSession();
         $session->setSessionVar('currentLocale', $setLocale);
     }
     if (isset($_SERVER['HTTP_REFERER'])) {
         Request::redirectUrl($_SERVER['HTTP_REFERER']);
     }
     $source = Request::getUserVar('source');
     if (isset($source) && !empty($source)) {
         Request::redirectUrl(Request::getProtocol() . '://' . Request::getServerHost() . $source, false);
     }
     Request::redirect(null, 'index');
 }
 function getLocaleFiles($locale)
 {
     if (!Locale::isLocaleValid($locale)) {
         return null;
     }
     $localeFiles = array(Locale::getMainLocaleFilename($locale));
     $plugins =& PluginRegistry::loadAllPlugins();
     foreach (array_keys($plugins) as $key) {
         $plugin =& $plugins[$key];
         $localeFile = $plugin->getLocaleFilename($locale);
         if (!empty($localeFile)) {
             $localeFiles[] = $localeFile;
         }
         unset($plugin);
     }
     return $localeFiles;
 }
 /**
  * Reload the default localized settings for the journal.
  * @param $args array
  * @param $request object
  */
 function reloadLocalizedDefaultSettings($args, &$request)
 {
     // make sure the locale is valid
     $locale = $request->getUserVar('localeToLoad');
     if (!Locale::isLocaleValid($locale)) {
         $request->redirect(null, null, 'languages');
     }
     $this->validate();
     $this->setupTemplate(true);
     $journal =& $request->getJournal();
     $journalSettingsDao =& DAORegistry::getDAO('JournalSettingsDAO');
     $journalSettingsDao->reloadLocalizedDefaultSettings($journal->getId(), 'registry/journalSettings.xml', array('indexUrl' => $request->getIndexUrl(), 'journalPath' => $journal->getData('path'), 'primaryLocale' => $journal->getPrimaryLocale(), 'journalName' => $journal->getTitle($journal->getPrimaryLocale())), $locale);
     // Display a notification
     import('lib.pkp.classes.notification.NotificationManager');
     $notificationManager = new NotificationManager();
     $notificationManager->createTrivialNotification('notification.notification', 'common.changesSaved');
     $request->redirect(null, null, 'languages');
 }
 /**
  * Install a new locale.
  */
 function installLocale()
 {
     $this->validate();
     $site =& Request::getSite();
     $installLocale = Request::getUserVar('installLocale');
     if (isset($installLocale) && is_array($installLocale)) {
         $installedLocales = $site->getInstalledLocales();
         foreach ($installLocale as $locale) {
             if (Locale::isLocaleValid($locale) && !in_array($locale, $installedLocales)) {
                 array_push($installedLocales, $locale);
                 Locale::installLocale($locale);
             }
         }
         $site->setInstalledLocales($installedLocales);
         $siteDao =& DAORegistry::getDAO('SiteDAO');
         $siteDao->updateObject($site);
     }
     Request::redirect('admin', 'languages');
 }
Ejemplo n.º 11
0
 /**
  * Reload the default localized settings for the press
  * @param $args array
  * @param $request object
  */
 function reloadLocalizedDefaultSettings($args, &$request)
 {
     // make sure the locale is valid
     $locale = $request->getUserVar('localeToLoad');
     if (!Locale::isLocaleValid($locale)) {
         $request->redirect(null, null, 'languages');
     }
     $this->setupTemplate(true);
     $press =& $request->getPress();
     $pressSettingsDao =& DAORegistry::getDAO('PressSettingsDAO');
     $pressSettingsDao->reloadLocalizedDefaultSettings($press->getId(), 'registry/pressSettings.xml', array('indexUrl' => $request->getIndexUrl(), 'pressPath' => $press->getData('path'), 'primaryLocale' => $press->getPrimaryLocale(), 'pressName' => $press->getName($press->getPrimaryLocale())), $locale);
     // also reload the user group localizable data
     $userGroupDao =& DAORegistry::getDAO('UserGroupDAO');
     $userGroupDao->installLocale($locale, $press->getId());
     // Display a notification
     import('lib.pkp.classes.notification.NotificationManager');
     $notificationManager = new NotificationManager();
     $notificationManager->createTrivialNotification('notification.notification', 'common.changesSaved');
     $request->redirect(null, null, 'languages');
 }
Ejemplo n.º 12
0
 function getLocaleFiles($locale)
 {
     if (!Locale::isLocaleValid($locale)) {
         return null;
     }
     $localeFiles =& Locale::makeComponentMap($locale);
     $plugins =& PluginRegistry::loadAllPlugins();
     foreach (array_keys($plugins) as $key) {
         $plugin =& $plugins[$key];
         $localeFile = $plugin->getLocaleFilename($locale);
         if (!empty($localeFile)) {
             if (is_scalar($localeFile)) {
                 $localeFiles[] = $localeFile;
             }
             if (is_array($localeFile)) {
                 $localeFiles = array_merge($localeFiles, $localeFile);
             }
         }
         unset($plugin);
     }
     return $localeFiles;
 }
Ejemplo n.º 13
0
 /**
  * Save modified settings.
  */
 function execute()
 {
     $press =& Request::getPress();
     $settingsDao =& DAORegistry::getDAO('PressSettingsDAO');
     // Verify additional locales
     foreach (array('supportedLocales', 'supportedSubmissionLocales', 'supportedFormLocales') as $name) {
         ${$name} = array();
         foreach ($this->getData($name) as $locale) {
             if (Locale::isLocaleValid($locale) && in_array($locale, $this->availableLocales)) {
                 array_push(${$name}, $locale);
             }
         }
     }
     $primaryLocale = $this->getData('primaryLocale');
     // Make sure at least the primary locale is chosen as available
     if ($primaryLocale != null && !empty($primaryLocale)) {
         foreach (array('supportedLocales', 'supportedSubmissionLocales', 'supportedFormLocales') as $name) {
             if (!in_array($primaryLocale, ${$name})) {
                 array_push(${$name}, $primaryLocale);
             }
         }
     }
     $this->setData('supportedLocales', $supportedLocales);
     $this->setData('supportedSubmissionLocales', $supportedSubmissionLocales);
     $this->setData('supportedFormLocales', $supportedFormLocales);
     foreach ($this->_data as $name => $value) {
         if (!in_array($name, array_keys($this->settings))) {
             continue;
         }
         $settingsDao->updateSetting($press->getId(), $name, $value, $this->settings[$name]);
     }
     $pressDao =& DAORegistry::getDAO('PressDAO');
     $press->setPrimaryLocale($this->getData('primaryLocale'));
     $pressDao->updatePress($press);
 }
Ejemplo n.º 14
0
 /**
  * Parse an XML users file into a set of users to import.
  * @param $file string path to the XML file to parse
  * @return array ImportedUsers the collection of users read from the file
  */
 function &parseData($file)
 {
     $roleDao =& DAORegistry::getDAO('RoleDAO');
     $success = true;
     $this->usersToImport = array();
     $tree = $this->parser->parse($file);
     $schedConfDao =& DAORegistry::getDAO('SchedConfDAO');
     $schedConf =& $schedConfDao->getSchedConf($this->schedConfId);
     $schedConfPrimaryLocale = Locale::getPrimaryLocale();
     $site =& Request::getSite();
     $siteSupportedLocales = $site->getSupportedLocales();
     if ($tree !== false) {
         foreach ($tree->getChildren() as $user) {
             if ($user->getName() == 'user') {
                 // Match user element
                 $newUser = new ImportedUser();
                 foreach ($user->getChildren() as $attrib) {
                     switch ($attrib->getName()) {
                         case 'username':
                             // Usernames must be lowercase
                             $newUser->setUsername(strtolower($attrib->getValue()));
                             break;
                         case 'password':
                             $newUser->setMustChangePassword($attrib->getAttribute('change') == 'true' ? 1 : 0);
                             $encrypted = $attrib->getAttribute('encrypted');
                             if (isset($encrypted) && $encrypted !== 'plaintext') {
                                 $ocsEncryptionScheme = Config::getVar('security', 'encryption');
                                 if ($encrypted != $ocsEncryptionScheme) {
                                     $this->errors[] = Locale::translate('plugins.importexport.users.import.encryptionMismatch', array('importHash' => $encrypted, 'ocsHash' => $ocsEncryptionScheme));
                                 }
                                 $newUser->setPassword($attrib->getValue());
                             } else {
                                 $newUser->setUnencryptedPassword($attrib->getValue());
                             }
                             break;
                         case 'salutation':
                             $newUser->setSalutation($attrib->getValue());
                             break;
                         case 'first_name':
                             $newUser->setFirstName($attrib->getValue());
                             break;
                         case 'middle_name':
                             $newUser->setMiddleName($attrib->getValue());
                             break;
                         case 'last_name':
                             $newUser->setLastName($attrib->getValue());
                             break;
                         case 'initials':
                             $newUser->setInitials($attrib->getValue());
                             break;
                         case 'gender':
                             $newUser->setGender($attrib->getValue());
                             break;
                         case 'affiliation':
                             $locale = $attrib->getAttribute('locale');
                             if (empty($locale)) {
                                 $locale = $schedConfPrimaryLocale;
                             }
                             $newUser->setAffiliation($attrib->getValue(), $locale);
                             break;
                         case 'email':
                             $newUser->setEmail($attrib->getValue());
                             break;
                         case 'url':
                             $newUser->setUrl($attrib->getValue());
                             break;
                         case 'phone':
                             $newUser->setPhone($attrib->getValue());
                             break;
                         case 'fax':
                             $newUser->setFax($attrib->getValue());
                             break;
                         case 'mailing_address':
                             $newUser->setMailingAddress($attrib->getValue());
                             break;
                         case 'country':
                             $newUser->setCountry($attrib->getValue());
                             break;
                         case 'signature':
                             $locale = $attrib->getAttribute('locale');
                             if (empty($locale)) {
                                 $locale = $schedConfPrimaryLocale;
                             }
                             $newUser->setSignature($attrib->getValue(), $locale);
                             break;
                         case 'interests':
                             $locale = $attrib->getAttribute('locale');
                             if (empty($locale)) {
                                 $locale = $schedConfPrimaryLocale;
                             }
                             $newUser->setInterests($attrib->getValue(), $locale);
                             break;
                         case 'gossip':
                             $locale = $attrib->getAttribute('locale');
                             if (empty($locale)) {
                                 $locale = $schedConfPrimaryLocale;
                             }
                             $newUser->setGossip($attrib->getValue(), $locale);
                             break;
                         case 'biography':
                             $locale = $attrib->getAttribute('locale');
                             if (empty($locale)) {
                                 $locale = $schedConfPrimaryLocale;
                             }
                             $newUser->setBiography($attrib->getValue(), $locale);
                             break;
                         case 'locales':
                             $locales = array();
                             foreach (explode(':', $attrib->getValue()) as $locale) {
                                 if (Locale::isLocaleValid($locale) && in_array($locale, $siteSupportedLocales)) {
                                     array_push($locales, $locale);
                                 }
                             }
                             $newUser->setLocales($locales);
                             break;
                         case 'role':
                             $roleType = $attrib->getAttribute('type');
                             if ($this->validRole($roleType)) {
                                 $role = new Role();
                                 $role->setRoleId($roleDao->getRoleIdFromPath($roleType));
                                 $newUser->addRole($role);
                             }
                             break;
                     }
                 }
                 array_push($this->usersToImport, $newUser);
             }
         }
     }
     return $this->usersToImport;
 }
Ejemplo n.º 15
0
 function saveLocaleFile($args)
 {
     $this->validate();
     $plugin =& PluginRegistry::getPlugin('generic', 'CustomLocalePlugin');
     $this->setupTemplate($plugin, true);
     $locale = array_shift($args);
     if (!Locale::isLocaleValid($locale)) {
         $path = array($plugin->getCategory(), $plugin->getName(), 'index');
         Request::redirect(null, null, null, $path);
     }
     $filename = urldecode(urldecode(array_shift($args)));
     if (!CustomLocaleAction::isLocaleFile($locale, $filename)) {
         $path = array($plugin->getCategory(), $plugin->getName(), 'edit', $locale);
         Request::redirect(null, null, null, $path);
     }
     $journal =& Request::getJournal();
     $journalId = $journal->getId();
     $changes = Request::getUserVar('changes');
     $customFilesDir = Config::getVar('files', 'public_files_dir') . DIRECTORY_SEPARATOR . 'journals' . DIRECTORY_SEPARATOR . $journalId . DIRECTORY_SEPARATOR . CUSTOM_LOCALE_DIR . DIRECTORY_SEPARATOR . $locale;
     $customFilePath = $customFilesDir . DIRECTORY_SEPARATOR . $filename;
     // Create empty custom locale file if it doesn't exist
     import('file.FileManager');
     import('file.EditableLocaleFile');
     if (!FileManager::fileExists($customFilePath)) {
         $numParentDirs = substr_count($customFilePath, DIRECTORY_SEPARATOR);
         $parentDirs = '';
         for ($i = 0; $i < $numParentDirs; $i++) {
             $parentDirs .= '..' . DIRECTORY_SEPARATOR;
         }
         $newFileContents = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
         $newFileContents .= '<!DOCTYPE locale SYSTEM "' . $parentDirs . 'lib' . DIRECTORY_SEPARATOR . 'pkp' . DIRECTORY_SEPARATOR . 'dtd' . DIRECTORY_SEPARATOR . 'locale.dtd' . '">' . "\n";
         $newFileContents .= '<locale name="' . $locale . '">' . "\n";
         $newFileContents .= '</locale>';
         FileManager::writeFile($customFilePath, $newFileContents);
     }
     $file = new EditableLocaleFile($locale, $customFilePath);
     while (!empty($changes)) {
         $key = array_shift($changes);
         $value = $this->correctCr(array_shift($changes));
         if (!empty($value)) {
             if (!$file->update($key, $value)) {
                 $file->insert($key, $value);
             }
         } else {
             $file->delete($key);
         }
     }
     $file->write();
     Request::redirectUrl(Request::getUserVar('redirectUrl'));
 }
Ejemplo n.º 16
0
    function saveEmail($args)
    {
        $this->validate();
        $plugin =& $this->plugin;
        $this->setupTemplate();
        $locale = array_shift($args);
        if (!Locale::isLocaleValid($locale)) {
            Request::redirect(null, null, 'index');
        }
        $emails = TranslatorAction::getEmailTemplates($locale);
        $referenceEmails = TranslatorAction::getEmailTemplates(MASTER_LOCALE);
        $emailKey = array_shift($args);
        $targetFilename = str_replace(MASTER_LOCALE, $locale, $referenceEmails[$emailKey]['templateDataFile']);
        // FIXME: Ugly.
        if (!in_array($emailKey, array_keys($emails))) {
            // If it's not a reference or translation email, bail.
            if (!in_array($emailKey, array_keys($referenceEmails))) {
                Request::redirect(null, null, 'index');
            }
            // If it's a reference email but not a translated one,
            // create a blank file. FIXME: This is ugly.
            if (!file_exists($targetFilename)) {
                $dir = dirname($targetFilename);
                if (!file_exists($dir)) {
                    mkdir($dir);
                }
                file_put_contents($targetFilename, '<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE email_texts SYSTEM "../../../../../lib/pkp/dtd/emailTemplateData.dtd">
<!--
  * emailTemplateData.xml
  *
  * Copyright (c) 2003-2011 John Willinsky
  * Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
  *
  * Localized email templates XML file.
  *
  * $Id$
  -->
<email_texts locale="' . $locale . '">
</email_texts>');
            }
        }
        import('lib.pkp.classes.file.EditableEmailFile');
        $file = new EditableEmailFile($locale, $targetFilename);
        $subject = $this->correctCr(Request::getUserVar('subject'));
        $body = $this->correctCr(Request::getUserVar('body'));
        $description = $this->correctCr(Request::getUserVar('description'));
        if (!$file->update($emailKey, $subject, $body, $description)) {
            $file->insert($emailKey, $subject, $body, $description);
        }
        $file->write();
        if (Request::getUserVar('returnToCheck') == 1) {
            Request::redirect(null, null, 'check', $locale);
        } else {
            Request::redirect(null, null, 'edit', $locale);
        }
    }
 /**
  * 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'));
     $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->setInterests($this->getData('interests'), 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->getUserId() != null) {
         if ($this->getData('password') !== '') {
             if (isset($auth)) {
                 $auth->doSetUserPassword($user->getUsername(), $this->getData('password'));
                 $user->setPassword(Validation::encryptCredentials($user->getUserId(), 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->updateUser($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->getUserId(), 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->getJournalId());
                     $role->setUserId($userId);
                     $role->setRoleId($roleId);
                     $roleDao->insertRole($role);
                 }
             }
         }
         if ($sendNotify) {
             // Send welcome email to user
             import('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();
         }
     }
 }
Ejemplo n.º 18
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);
     }
 }
Ejemplo n.º 19
0
 /**
  * Retrieve the primary locale of the current context.
  * @return string
  */
 function getPrimaryLocale()
 {
     static $locale;
     if ($locale) {
         return $locale;
     }
     if (defined('SESSION_DISABLE_INIT') || !Config::getVar('general', 'installed')) {
         return $locale = LOCALE_DEFAULT;
     }
     $press =& Request::getPress();
     if (isset($press)) {
         $locale = $press->getPrimaryLocale();
     }
     if (!isset($locale)) {
         $site =& Request::getSite();
         $locale = $site->getPrimaryLocale();
     }
     if (!isset($locale) || !Locale::isLocaleValid($locale)) {
         $locale = LOCALE_DEFAULT;
     }
     return $locale;
 }
Ejemplo n.º 20
0
 /**
  * Save profile settings.
  */
 function execute()
 {
     $user =& Request::getUser();
     $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->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->setInterests($this->getData('interests'), null);
     // Localized
     $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);
     $userDao =& DAORegistry::getDAO('UserDAO');
     $userDao->updateObject($user);
     $roleDao =& DAORegistry::getDAO('RoleDAO');
     $userSettingsDao =& DAORegistry::getDAO('UserSettingsDAO');
     if ($user->getAuthId()) {
         $authDao =& DAORegistry::getDAO('AuthSourceDAO');
         $auth =& $authDao->getPlugin($user->getAuthId());
     }
     if (isset($auth)) {
         $auth->doSetUserInfo($user);
     }
 }
 /**
  * Remove cover page from article
  */
 function removeArticleCoverPage($args, &$request)
 {
     $articleId = isset($args[0]) ? (int) $args[0] : 0;
     $this->validate($articleId);
     $formLocale = $args[1];
     if (!Locale::isLocaleValid($formLocale)) {
         $request->redirect(null, null, 'viewMetadata', $articleId);
     }
     $submission =& $this->submission;
     $journal =& $request->getJournal();
     import('classes.file.PublicFileManager');
     $publicFileManager = new PublicFileManager();
     $publicFileManager->removeJournalFile($journal->getId(), $submission->getFileName($formLocale));
     $submission->setFileName('', $formLocale);
     $submission->setOriginalFileName('', $formLocale);
     $submission->setWidth('', $formLocale);
     $submission->setHeight('', $formLocale);
     $articleDao =& DAORegistry::getDAO('ArticleDAO');
     $articleDao->updateArticle($submission);
     $request->redirect(null, null, 'viewMetadata', $articleId);
 }
Ejemplo n.º 22
0
 /**
  * Retrieve the primary locale of the current context.
  * @return string
  */
 function getPrimaryLocale()
 {
     $journal =& Request::getJournal();
     if (isset($journal)) {
         $locale = $journal->getPrimaryLocale();
     }
     if (!isset($locale)) {
         $site =& Request::getSite();
         $locale = $site->getPrimaryLocale();
     }
     if (!isset($locale) || !Locale::isLocaleValid($locale)) {
         $locale = LOCALE_DEFAULT;
     }
     return $locale;
 }
Ejemplo n.º 23
0
 /**
  * Save profile settings.
  */
 function execute()
 {
     $user =& Request::getUser();
     $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->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
     // Add reviewing interests to interests table
     import('lib.pkp.classes.user.InterestManager');
     $interestManager = new InterestManager();
     $interestManager->insertInterests($userId, $this->getData('interestsKeywords'), $this->getData('interests'));
     $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);
     $userDao =& DAORegistry::getDAO('UserDAO');
     $userDao->updateObject($user);
     $userGroupDao =& DAORegistry::getDAO('UserGroupDAO');
     $pressDao =& DAORegistry::getDAO('PressDAO');
     $notificationStatusDao =& DAORegistry::getDAO('NotificationStatusDAO');
     // Roles
     $press =& Request::getPress();
     if ($press) {
         if ($press->getSetting('allowRegReviewer')) {
             foreach ($this->getData('reviewerGroup') as $groupId => $wantsGroup) {
                 $inGroup = $userGroupDao->userInGroup($user->getId(), $groupId);
                 if ($inGroup && !$wantsGroup) {
                     $userGroupDao->removeUserFromGroup($user->getId(), $groupId);
                 }
                 if (!$hasRole && $wantsRole) {
                     $userGroupDao->assignUserToGroup($user->getId(), $groupId);
                 }
             }
         }
         if ($press->getSetting('allowRegAuthor')) {
             foreach ($this->getData('authorGroup') as $groupId => $wantsGroup) {
                 $inGroup = $userGroupDao->userInGroup($user->getId(), $groupId);
                 if ($inGroup && !$wantsGroup) {
                     $userGroupDao->removeUserFromGroup($user->getId(), $groupId);
                 }
                 if (!$hasRole && $wantsRole) {
                     $userGroupDao->assignUserToGroup($user->getId(), $groupId);
                 }
             }
         }
         if ($press->getSetting('allowRegReader')) {
             foreach ($this->getData('readerGroup') as $groupId => $wantsGroup) {
                 $inGroup = $userGroupDao->userInGroup($user->getId(), $groupId);
                 if ($inGroup && !$wantsGroup) {
                     $userGroupDao->removeUserFromGroup($user->getId(), $groupId);
                 }
                 if (!$hasRole && $wantsRole) {
                     $userGroupDao->assignUserToGroup($user->getId(), $groupId);
                 }
             }
         }
     }
     $presses =& $pressDao->getPresses();
     $presses =& $presses->toArray();
     $pressNotifications = $notificationStatusDao->getPressNotifications($user->getId());
     $readerNotify = Request::getUserVar('pressNotify');
     foreach ($presses as $thisPress) {
         $thisPressId = $thisPress->getId();
         $currentlyReceives = !empty($pressNotifications[$thisPressId]);
         $shouldReceive = !empty($readerNotify) && in_array($thisPress->getId(), $readerNotify);
         if ($currentlyReceives != $shouldReceive) {
             $notificationStatusDao->setPressNotifications($thisPressId, $user->getId(), $shouldReceive);
         }
     }
     $userSettingsDao =& DAORegistry::getDAO('UserSettingsDAO');
     if ($user->getAuthId()) {
         $authDao =& DAORegistry::getDAO('AuthSourceDAO');
         $auth =& $authDao->getPlugin($user->getAuthId());
     }
     if (isset($auth)) {
         $auth->doSetUserInfo($user);
     }
 }
 /**
  * Remove cover page from article
  */
 function removeArticleCoverPage($args, &$request)
 {
     $articleId = isset($args[0]) ? (int) $args[0] : 0;
     $this->validate($articleId);
     $formLocale = $args[1];
     if (!Locale::isLocaleValid($formLocale)) {
         $request->redirect(null, null, 'viewMetadata', $articleId);
     }
     $submission =& $this->submission;
     if (SectionEditorAction::removeArticleCoverPage($submission, $formLocale)) {
         $request->redirect(null, null, 'viewMetadata', $articleId);
     }
 }
Ejemplo n.º 25
0
 /**
  * Save profile settings.
  */
 function execute()
 {
     $user =& Request::getUser();
     $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->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->setTimeZone($this->getData('timeZone'));
     $user->setBiography($this->getData('biography'), null);
     // Localized
     $user->setInterests($this->getData('interests'), null);
     // Localized
     $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);
     $userDao =& DAORegistry::getDAO('UserDAO');
     $userDao->updateObject($user);
     $roleDao =& DAORegistry::getDAO('RoleDAO');
     $schedConfDao =& DAORegistry::getDAO('SchedConfDAO');
     // Roles
     $schedConf =& Request::getSchedConf();
     if ($schedConf) {
         import('schedConf.SchedConfAction');
         $role = new Role();
         $role->setUserId($user->getId());
         $role->setConferenceId($schedConf->getConferenceId());
         $role->setSchedConfId($schedConf->getId());
         if (SchedConfAction::allowRegReviewer($schedConf)) {
             $role->setRoleId(ROLE_ID_REVIEWER);
             $hasRole = Validation::isReviewer();
             $wantsRole = Request::getUserVar('reviewerRole');
             if ($hasRole && !$wantsRole) {
                 $roleDao->deleteRole($role);
             }
             if (!$hasRole && $wantsRole) {
                 $roleDao->insertRole($role);
             }
         }
         if (SchedConfAction::allowRegAuthor($schedConf)) {
             $role->setRoleId(ROLE_ID_AUTHOR);
             $hasRole = Validation::isAuthor();
             $wantsRole = Request::getUserVar('authorRole');
             if ($hasRole && !$wantsRole) {
                 $roleDao->deleteRole($role);
             }
             if (!$hasRole && $wantsRole) {
                 $roleDao->insertRole($role);
             }
         }
         if (SchedConfAction::allowRegReader($schedConf)) {
             $role->setRoleId(ROLE_ID_READER);
             $hasRole = Validation::isReader();
             $wantsRole = Request::getUserVar('readerRole');
             if ($hasRole && !$wantsRole) {
                 $roleDao->deleteRole($role);
             }
             if (!$hasRole && $wantsRole) {
                 $roleDao->insertRole($role);
             }
         }
     }
     $openAccessNotify = Request::getUserVar('openAccessNotify');
     $userSettingsDao =& DAORegistry::getDAO('UserSettingsDAO');
     $schedConfs =& $schedConfDao->getSchedConfs();
     $schedConfs =& $schedConfs->toArray();
     foreach ($schedConfs as $thisSchedConf) {
         if ($thisSchedConf->getSetting('enableOpenAccessNotification') == true) {
             $currentlyReceives = $user->getSetting('openAccessNotification', $thisSchedConf->getId());
             $shouldReceive = !empty($openAccessNotify) && in_array($thisSchedConf->getId(), $openAccessNotify);
             if ($currentlyReceives != $shouldReceive) {
                 $userSettingsDao->updateSetting($user->getId(), 'openAccessNotification', $shouldReceive, 'bool', $thisSchedConf->getId());
             }
         }
     }
     if ($user->getAuthId()) {
         $authDao =& DAORegistry::getDAO('AuthSourceDAO');
         $auth =& $authDao->getPlugin($user->getAuthId());
     }
     if (isset($auth)) {
         $auth->doSetUserInfo($user);
     }
 }
 /**
  * Remove book for review cover page image.
  */
 function removeBookForReviewCoverPage($args = array(), &$request)
 {
     $this->setupTemplate();
     if (empty($args) || count($args) < 2) {
         $request->redirect(null, 'editor');
     }
     $bookId = (int) $args[0];
     $formLocale = $args[1];
     if (!Locale::isLocaleValid($formLocale)) {
         $request->redirect(null, 'editor');
     }
     $bfrPlugin =& PluginRegistry::getPlugin('generic', BOOKS_FOR_REVIEW_PLUGIN_NAME);
     $returnPage = $request->getUserVar('returnPage');
     if ($returnPage != null) {
         $validPages =& $this->getValidReturnPages();
         if (!in_array($returnPage, $validPages)) {
             $returnPage = null;
         }
     }
     $journal =& $request->getJournal();
     $journalId = $journal->getId();
     $bfrDao =& DAORegistry::getDAO('BookForReviewDAO');
     // Ensure book for review is for this journal
     if ($bfrDao->getBookForReviewJournalId($bookId) == $journalId) {
         $bfrDao->removeCoverPage($bookId, $formLocale);
         $request->redirect(null, 'editor', 'editBookForReview', $bookId, array('returnPage' => $returnPage));
     }
     $request->redirect(null, 'editor', 'booksForReview', $returnPage);
 }
Ejemplo n.º 27
0
 /**
  * Save profile settings.
  */
 function execute()
 {
     $user =& Request::getUser();
     $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->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
     $userId = $user->getId();
     // Insert the user interests
     import('lib.pkp.classes.user.InterestManager');
     $interestManager = new InterestManager();
     $interestManager->insertInterests($userId, $this->getData('interestsKeywords'), $this->getData('interests'));
     $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);
     $userDao =& DAORegistry::getDAO('UserDAO');
     $userDao->updateObject($user);
     $roleDao =& DAORegistry::getDAO('RoleDAO');
     $journalDao =& DAORegistry::getDAO('JournalDAO');
     // Roles
     $journal =& Request::getJournal();
     if ($journal) {
         $role = new Role();
         $role->setUserId($user->getId());
         $role->setJournalId($journal->getId());
         if ($journal->getSetting('allowRegReviewer')) {
             $role->setRoleId(ROLE_ID_REVIEWER);
             $hasRole = Validation::isReviewer();
             $wantsRole = Request::getUserVar('reviewerRole');
             if ($hasRole && !$wantsRole) {
                 $roleDao->deleteRole($role);
             }
             if (!$hasRole && $wantsRole) {
                 $roleDao->insertRole($role);
             }
         }
         if ($journal->getSetting('allowRegAuthor')) {
             $role->setRoleId(ROLE_ID_AUTHOR);
             $hasRole = Validation::isAuthor();
             $wantsRole = Request::getUserVar('authorRole');
             if ($hasRole && !$wantsRole) {
                 $roleDao->deleteRole($role);
             }
             if (!$hasRole && $wantsRole) {
                 $roleDao->insertRole($role);
             }
         }
         if ($journal->getSetting('allowRegReader')) {
             $role->setRoleId(ROLE_ID_READER);
             $hasRole = Validation::isReader();
             $wantsRole = Request::getUserVar('readerRole');
             if ($hasRole && !$wantsRole) {
                 $roleDao->deleteRole($role);
             }
             if (!$hasRole && $wantsRole) {
                 $roleDao->insertRole($role);
             }
         }
     }
     $openAccessNotify = Request::getUserVar('openAccessNotify');
     $userSettingsDao =& DAORegistry::getDAO('UserSettingsDAO');
     $journals =& $journalDao->getEnabledJournals();
     $journals =& $journals->toArray();
     foreach ($journals as $thisJournal) {
         if ($thisJournal->getSetting('publishingMode') == PUBLISHING_MODE_SUBSCRIPTION && $thisJournal->getSetting('enableOpenAccessNotification')) {
             $currentlyReceives = $user->getSetting('openAccessNotification', $thisJournal->getJournalId());
             $shouldReceive = !empty($openAccessNotify) && in_array($thisJournal->getJournalId(), $openAccessNotify);
             if ($currentlyReceives != $shouldReceive) {
                 $userSettingsDao->updateSetting($user->getId(), 'openAccessNotification', $shouldReceive, 'bool', $thisJournal->getJournalId());
             }
         }
     }
     if ($user->getAuthId()) {
         $authDao =& DAORegistry::getDAO('AuthSourceDAO');
         $auth =& $authDao->getPlugin($user->getAuthId());
     }
     if (isset($auth)) {
         $auth->doSetUserInfo($user);
     }
 }
Ejemplo n.º 28
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);
     }
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 30
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 (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);
     $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;
 }