本文整理汇总了PHP中Validation::encryptCredentials方法的典型用法代码示例。如果您正苦于以下问题:PHP Validation::encryptCredentials方法的具体用法?PHP Validation::encryptCredentials怎么用?PHP Validation::encryptCredentials使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Validation
的用法示例。
在下文中一共展示了Validation::encryptCredentials方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* Save new password.
* @return boolean success
*/
function execute()
{
$userDao =& DAORegistry::getDAO('UserDAO');
$user =& $userDao->getUserByUsername($this->getData('username'), false);
echo $user->getUsername();
echo $this->getData('password');
if ($user != null) {
if ($user->getAuthId()) {
$authDao =& DAORegistry::getDAO('AuthSourceDAO');
$auth =& $authDao->getPlugin($user->getAuthId());
}
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 {
echo $user->getUsername();
echo $this->getData('password');
$user->setPassword(Validation::encryptCredentials($user->getUsername(), $this->getData('password')));
}
$user->setMustChangePassword(0);
$userDao->updateUser($user);
return true;
} else {
return false;
}
}
示例2: execute
/**
* Save review assignment
* @param $args array
* @param $request PKPRequest
*/
function execute($args, $request)
{
$userDao = DAORegistry::getDAO('UserDAO');
$user = $userDao->newDataObject();
$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->setInlineHelp(1);
// default new reviewers to having inline help visible
$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->setMustChangePassword(true);
// Emailed P/W not safe
$user->setDateRegistered(Core::getCurrentDate());
$reviewerId = $userDao->insertObject($user);
// Set the reviewerId in the Form for the parent class to use
$this->setData('reviewerId', $reviewerId);
// Insert the user interests
import('lib.pkp.classes.user.InterestManager');
$interestManager = new InterestManager();
$interestManager->setInterestsForUser($user, $this->getData('interests'));
// 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('skipEmail')) {
// Send welcome email to user
import('lib.pkp.classes.mail.MailTemplate');
$mail = new MailTemplate('REVIEWER_REGISTER');
if ($mail->isEnabled()) {
$context = $request->getContext();
$mail->setReplyTo($context->getSetting('contactEmail'), $context->getSetting('contactName'));
$mail->assignParams(array('username' => $this->getData('username'), 'password' => $password, 'userFullName' => $user->getFullName()));
$mail->addRecipient($user->getEmail(), $user->getFullName());
$mail->send($request);
}
}
return parent::execute($args, $request);
}
示例3: createData
/**
* 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 (user_id, username, first_name, last_name, password, email, date_registered, date_last_login) VALUES (%d, \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\')', 1, $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 (journal_id, user_id, role_id) VALUES (%d, %d, %d)', 0, 1, ROLE_ID_SITE_ADMIN));
} 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->setJournalId(0);
$role->setUserId($user->getUserId());
$role->setRoleId(ROLE_ID_SITE_ADMIN);
if (!$roleDao->insertRole($role)) {
$this->setError(INSTALLER_ERROR_DB, $this->dbconn->errorMsg());
return false;
}
}
return true;
}
示例4: verifyPassword
/**
* Verify if the input password is correct
*
* @param string $username the string username
* @param string $password the plaintext password
* @param string $hash the password hash from the database
* @param string &$rehash if password needs rehash, this variable is used
* @return boolean
*/
function verifyPassword($username, $password, $hash, &$rehash)
{
if (password_needs_rehash($hash, PASSWORD_BCRYPT)) {
// update to new hashing algorithm
$oldHash = Validation::encryptCredentials($username, $password, false, true);
if ($oldHash === $hash) {
// update hash
$rehash = Validation::encryptCredentials($username, $password);
return true;
}
}
return password_verify($password, $hash);
}
示例5: createData
/**
* 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;
}
示例6: execute
/**
* Save new password.
*/
function execute()
{
$user = $this->getUser();
if ($user->getAuthId()) {
$authDao = DAORegistry::getDAO('AuthSourceDAO');
$auth = $authDao->getPlugin($user->getAuthId());
}
if (isset($auth)) {
$auth->doSetUserPassword($user->getUsername(), $this->getData('password'));
$user->setPassword(Validation::encryptCredentials($user->getId(), Validation::generatePassword()));
// Used for PW reset hash only
} else {
$user->setPassword(Validation::encryptCredentials($user->getUsername(), $this->getData('password')));
}
$userDao = DAORegistry::getDAO('UserDAO');
$userDao->updateObject($user);
}
示例7: resetPassword
/**
* Reset a user's password
* @param $args array first param contains the username of the user whose password is to be reset
*/
function resetPassword($args)
{
$this->validate();
$this->setupTemplate();
$username = isset($args[0]) ? $args[0] : null;
$userDao =& DAORegistry::getDAO('UserDAO');
$confirmHash = Request::getUserVar('confirm');
if ($username == null || ($user =& $userDao->getUserByUsername($username)) == null) {
PKPRequest::redirect(null, null, 'lostPassword');
return;
}
$templateMgr =& TemplateManager::getManager();
$hash = Validation::generatePasswordResetHash($user->getId());
if ($hash == false || $confirmHash != $hash) {
$templateMgr->assign('errorMsg', 'user.login.lostPassword.invalidHash');
$templateMgr->assign('backLink', PKPRequest::url(null, null, 'lostPassword'));
$templateMgr->assign('backLinkLabel', 'user.login.resetPassword');
$templateMgr->display('common/error.tpl');
} else {
// Reset password
$newPassword = Validation::generatePassword();
if ($user->getAuthId()) {
$authDao =& DAORegistry::getDAO('AuthSourceDAO');
$auth =& $authDao->getPlugin($user->getAuthId());
}
if (isset($auth)) {
$auth->doSetUserPassword($user->getUsername(), $newPassword);
$user->setPassword(Validation::encryptCredentials($user->getId(), Validation::generatePassword()));
// Used for PW reset hash only
} else {
$user->setPassword(Validation::encryptCredentials($user->getUsername(), $newPassword));
}
$user->setMustChangePassword(1);
$userDao->updateObject($user);
// Send email with new password
$site =& Request::getSite();
import('classes.mail.MailTemplate');
$mail = new MailTemplate('PASSWORD_RESET');
$this->_setMailFrom($mail);
$mail->assignParams(array('username' => $user->getUsername(), 'password' => $newPassword, 'siteTitle' => $site->getLocalizedTitle()));
$mail->addRecipient($user->getEmail(), $user->getFullName());
$mail->send();
$templateMgr->assign('pageTitle', 'user.login.resetPassword');
$templateMgr->assign('message', 'user.login.lostPassword.passwordSent');
$templateMgr->assign('backLink', PKPRequest::url(null, Request::getRequestedPage()));
$templateMgr->assign('backLinkLabel', 'user.login');
$templateMgr->display('common/message.tpl');
}
}
示例8: execute
/**
* 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());
//.........这里部分代码省略.........
示例9: execute
/**
* 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);
}
}
//.........这里部分代码省略.........
示例10: generatePassword
/**
* Generate a random password for a user.
* @param $user ImportedUser the user to be modified by this function
*/
function generatePassword(&$user)
{
$password = Validation::generatePassword();
$user->setUnencryptedPassword($password);
$user->setPassword(Validation::encryptCredentials($user->getUsername(), $password));
}
示例11: createData
/**
* 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 (user_id, username, first_name, last_name, password, email, date_registered, date_last_login) VALUES (%d, \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\')', 1, $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 (press_id, user_id, role_id) VALUES (%d, %d, %d)', 0, 1, 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;
}
// 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));
}
$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;
}
// Create an admin user group
Locale::requireComponents(array(LOCALE_COMPONENT_OMP_DEFAULT_SETTINGS));
$userGroupDao =& DAORegistry::getDao('UserGroupDAO', $this->dbconn);
$adminUserGroup = new UserGroup();
$adminUserGroup->setRoleId(ROLE_ID_SITE_ADMIN);
$adminUserGroup->setContextId(0);
$adminUserGroup->setPath(ROLE_PATH_SITE_ADMIN);
$adminUserGroup->setDefault(true);
foreach ($this->installedLocales as $locale) {
$name = Locale::translate('default.groups.name.siteAdmin', array(), $locale);
$namePlural = Locale::translate('default.groups.plural.siteAdmin', array(), $locale);
$adminUserGroup->setData('name', $name, $locale);
$adminUserGroup->setData('namePlural', $namePlural, $locale);
}
if (!$userGroupDao->insertUserGroup($adminUserGroup)) {
$this->setError(INSTALLER_ERROR_DB, $this->dbconn->errorMsg());
return false;
}
// put the installer into this user group
if (!$userGroupDao->assignUserToGroup($user->getId(), $adminUserGroup->getId())) {
$this->setError(INSTALLER_ERROR_DB, $this->dbconn->errorMsg());
return false;
}
}
return true;
}
示例12: createData
/**
* Create initial required data.
* @return boolean
*/
function createData()
{
// Add initial site administrator user
$userDao = DAORegistry::getDAO('UserDAO', $this->dbconn);
$user = $userDao->newDataObject();
$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'));
$user->setInlineHelp(1);
if (!$userDao->insertObject($user)) {
$this->setError(INSTALLER_ERROR_DB, $this->dbconn->errorMsg());
return false;
}
// Create an admin user group
AppLocale::requireComponents(LOCALE_COMPONENT_PKP_DEFAULT);
$userGroupDao = DAORegistry::getDao('UserGroupDAO', $this->dbconn);
$adminUserGroup = $userGroupDao->newDataObject();
$adminUserGroup->setRoleId(ROLE_ID_SITE_ADMIN);
$adminUserGroup->setContextId(CONTEXT_ID_NONE);
$adminUserGroup->setDefault(true);
foreach ($this->installedLocales as $locale) {
$name = __('default.groups.name.siteAdmin', array(), $locale);
$namePlural = __('default.groups.plural.siteAdmin', array(), $locale);
$adminUserGroup->setData('name', $name, $locale);
$adminUserGroup->setData('namePlural', $namePlural, $locale);
}
if (!$userGroupDao->insertObject($adminUserGroup)) {
$this->setError(INSTALLER_ERROR_DB, $this->dbconn->errorMsg());
return false;
}
// Put the installer into this user group
$userGroupDao->assignUserToGroup($user->getId(), $adminUserGroup->getId());
// Add initial site data
$locale = $this->getParam('locale');
$siteDao = DAORegistry::getDAO('SiteDAO', $this->dbconn);
$site = $siteDao->newDataObject();
$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;
}
// 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 default site settings
$siteSettingsDao = DAORegistry::getDAO('SiteSettingsDAO');
$siteSettingsDao->installSettings('registry/siteSettings.xml', array('contactEmail' => $this->getParam('adminEmail')));
return true;
}
示例13: execute
/**
* Register a new user.
* @param $request PKPRequest
* @return int|null User ID, or false on failure
*/
function execute($request)
{
$requireValidation = Config::getVar('email', 'require_validation');
$userDao = DAORegistry::getDAO('UserDAO');
// New user
$user = $userDao->newDataObject();
$user->setUsername($this->getData('username'));
// Set the base user fields (name, etc.)
$user->setFirstName($this->getData('firstName'));
$user->setMiddleName($this->getData('middleName'));
$user->setLastName($this->getData('lastName'));
$user->setInitials($this->getData('initials'));
$user->setEmail($this->getData('email'));
$user->setCountry($this->getData('country'));
$user->setAffiliation($this->getData('affiliation'), null);
// Localized
$user->setDateRegistered(Core::getCurrentDate());
$user->setInlineHelp(1);
// default new users to having inline help visible.
if (isset($this->defaultAuth)) {
$user->setPassword($this->getData('password'));
// FIXME Check result and handle failures
$this->defaultAuth->doCreateUser($user);
$user->setAuthId($this->defaultAuth->authId);
}
$user->setPassword(Validation::encryptCredentials($this->getData('username'), $this->getData('password')));
if ($requireValidation) {
// The account should be created in a disabled
// state.
$user->setDisabled(true);
$user->setDisabledReason(__('user.login.accountNotValidated'));
}
parent::execute($user);
$userDao->insertObject($user);
$userId = $user->getId();
if (!$userId) {
return false;
}
// Associate the new user with the existing session
$sessionManager = SessionManager::getManager();
$session = $sessionManager->getUserSession();
$session->setSessionVar('username', $user->getUsername());
// Save the roles
import('lib.pkp.classes.user.form.UserFormHelper');
$userFormHelper = new UserFormHelper();
$userFormHelper->saveRoleContent($this, $user);
// Insert the user interests
import('lib.pkp.classes.user.InterestManager');
$interestManager = new InterestManager();
$interestManager->setInterestsForUser($user, $this->getData('interests'));
import('lib.pkp.classes.mail.MailTemplate');
if ($requireValidation) {
// Create an access key
import('lib.pkp.classes.security.AccessKeyManager');
$accessKeyManager = new AccessKeyManager();
$accessKey = $accessKeyManager->createKey('RegisterContext', $user->getId(), null, Config::getVar('email', 'validation_timeout'));
// Send email validation request to user
$mail = new MailTemplate('USER_VALIDATE');
$this->_setMailFrom($request, $mail);
$context = $request->getContext();
$mail->assignParams(array('userFullName' => $user->getFullName(), 'activateUrl' => $request->url($context->getPath(), 'user', 'activateUser', array($this->getData('username'), $accessKey))));
$mail->addRecipient($user->getEmail(), $user->getFullName());
$mail->send();
unset($mail);
}
return $userId;
}
示例14: createData
/**
* 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;
//.........这里部分代码省略.........
示例15: execute
/**
* 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;
}