本文整理匯總了PHP中InterestManager類的典型用法代碼示例。如果您正苦於以下問題:PHP InterestManager類的具體用法?PHP InterestManager怎麽用?PHP InterestManager使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了InterestManager類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getInterests
/**
* Get interests for reviewer interests autocomplete.
* @param $args array
* @param $request PKPRequest
* @return JSONMessage JSON object
*/
function getInterests($args, $request)
{
// Get the input text used to filter on
$filter = $request->getUserVar('term');
import('lib.pkp.classes.user.InterestManager');
$interestManager = new InterestManager();
$interests = $interestManager->getAllInterests($filter);
import('lib.pkp.classes.core.JSONMessage');
return new JSONMessage(true, $interests);
}
示例2: execute
/**
* Save roles settings.
* @param $request PKPRequest
*/
function execute($request)
{
$user = $request->getUser();
// 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'));
parent::execute($request, $user);
}
示例3: 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->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);
}
示例4: 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();
// FIXME: Bug #6199
$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 reviewing interests to interests table
import('lib.pkp.classes.user.InterestManager');
$interestManager = new InterestManager();
$interestManager->insertInterests($userId, $this->getData('interestsKeywords'), $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('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 = new SeriesEditorAction();
$seriesEditorAction->addReviewer($submission, $reviewerId, $reviewType, $round, $reviewDueDate, $responseDueDate);
// Get the reviewAssignment object now that it has been added
$reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
/* @var $reviewAssignmentDao 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;
}
示例5: 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;
}
示例6: array
/**
* Create or update a user.
* @param $args array
* @param $request PKPRequest
*/
function &execute($args, $request)
{
parent::execute($request);
$userDao = DAORegistry::getDAO('UserDAO');
$context = $request->getContext();
if (isset($this->userId)) {
$userId = $this->userId;
$user = $userDao->getById($userId);
}
if (!isset($user)) {
$user = $userDao->newDataObject();
$user->setInlineHelp(1);
// default new users to having inline help visible
}
$user->setSalutation($this->getData('salutation'));
$user->setFirstName($this->getData('firstName'));
$user->setMiddleName($this->getData('middleName'));
$user->setLastName($this->getData('lastName'));
$user->setSuffix($this->getData('suffix'));
$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->setOrcid($this->getData('orcid'));
$user->setMailingAddress($this->getData('mailingAddress'));
$user->setCountry($this->getData('country'));
$user->setBiography($this->getData('biography'), null);
// Localized
$user->setMustChangePassword($this->getData('mustChangePassword') ? 1 : 0);
$user->setAuthId((int) $this->getData('authId'));
$site = $request->getSite();
$availableLocales = $site->getSupportedLocales();
$locales = array();
foreach ($this->getData('userLocales') as $locale) {
if (AppLocale::isLocaleValid($locale) && in_array($locale, $availableLocales)) {
array_push($locales, $locale);
}
}
$user->setLocales($locales);
if ($user->getAuthId()) {
$authDao = DAORegistry::getDAO('AuthSourceDAO');
$auth =& $authDao->getPlugin($user->getAuthId());
}
if ($user->getId() != null) {
if ($this->getData('password') !== '') {
if (isset($auth)) {
$auth->doSetUserPassword($user->getUsername(), $this->getData('password'));
$user->setPassword(Validation::encryptCredentials($user->getId(), Validation::generatePassword()));
// Used for PW reset hash only
} else {
$user->setPassword(Validation::encryptCredentials($user->getUsername(), $this->getData('password')));
}
}
if (isset($auth)) {
// FIXME Should try to create user here too?
$auth->doSetUserInfo($user);
}
$userDao->updateObject($user);
} else {
$user->setUsername($this->getData('username'));
if ($this->getData('generatePassword')) {
$password = Validation::generatePassword();
$sendNotify = true;
} else {
$password = $this->getData('password');
$sendNotify = $this->getData('sendNotify');
}
if (isset($auth)) {
$user->setPassword($password);
// FIXME Check result and handle failures
$auth->doCreateUser($user);
$user->setAuthId($auth->authId);
$user->setPassword(Validation::encryptCredentials($user->getId(), Validation::generatePassword()));
// Used for PW reset hash only
} else {
$user->setPassword(Validation::encryptCredentials($this->getData('username'), $password));
}
$user->setDateRegistered(Core::getCurrentDate());
$userId = $userDao->insertObject($user);
if ($sendNotify) {
// Send welcome email to user
import('lib.pkp.classes.mail.MailTemplate');
$mail = new MailTemplate('USER_REGISTER');
$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();
}
}
import('lib.pkp.classes.user.InterestManager');
//.........這裏部分代碼省略.........
示例7: header
<?php
require_once "functions.php";
require_once "InterestManager.class.php";
if (!isset($_SESSION['user_id'])) {
header("Location: login.php");
//Ära enne suunamist midagi rohkem tee
exit;
}
if (isset($_GET["logout"])) {
session_destroy();
header("Location: login.php");
exit;
}
##HALDUS##
$InterestManager = new InterestManager($mysqli, $_SESSION['user_id']);
if (isset($_GET["insert"])) {
$int_name = $_GET["insert"];
$InterestManager->addInterest($int_name);
$interest_response = $InterestManager->addInterest($int_name);
}
if (isset($_GET["dropdown_interest"])) {
$InterestManager->addUserInterests($_SESSION['user_id'], $_GET["dropdown_interest"]);
$user_int_response = $InterestManager->addUserInterests($_SESSION['user_id'], $_GET["dropdown_interest"]);
var_dump($user_int_response);
}
?>
Tere, <?php
echo $_SESSION['user_email'];
?>
示例8: execute
//.........這裏部分代碼省略.........
// Localized
$user->setSignature($this->getData('signature'), null);
// Localized
$user->setEmail($this->getData('email'));
$user->setData('orcid', $this->getData('orcid'));
$user->setUrl($this->getData('userUrl'));
$user->setPhone($this->getData('phone'));
$user->setFax($this->getData('fax'));
$user->setMailingAddress($this->getData('mailingAddress'));
$user->setCountry($this->getData('country'));
$user->setBiography($this->getData('biography'), null);
// Localized
$user->setGossip($this->getData('gossip'), null);
// Localized
$user->setMustChangePassword($this->getData('mustChangePassword') ? 1 : 0);
$user->setAuthId((int) $this->getData('authId'));
$site =& Request::getSite();
$availableLocales = $site->getSupportedLocales();
$locales = array();
foreach ($this->getData('userLocales') as $locale) {
if (AppLocale::isLocaleValid($locale) && in_array($locale, $availableLocales)) {
array_push($locales, $locale);
}
}
$user->setLocales($locales);
if ($user->getAuthId()) {
$authDao =& DAORegistry::getDAO('AuthSourceDAO');
$auth =& $authDao->getPlugin($user->getAuthId());
}
if ($user->getId() != null) {
$userId = $user->getId();
if ($this->getData('password') !== '') {
if (isset($auth)) {
$auth->doSetUserPassword($user->getUsername(), $this->getData('password'));
$user->setPassword(Validation::encryptCredentials($userId, Validation::generatePassword()));
// Used for PW reset hash only
} else {
$user->setPassword(Validation::encryptCredentials($user->getUsername(), $this->getData('password')));
}
}
if (isset($auth)) {
// FIXME Should try to create user here too?
$auth->doSetUserInfo($user);
}
$userDao->updateObject($user);
} else {
$user->setUsername($this->getData('username'));
if ($this->getData('generatePassword')) {
$password = Validation::generatePassword();
$sendNotify = true;
} else {
$password = $this->getData('password');
$sendNotify = $this->getData('sendNotify');
}
if (isset($auth)) {
$user->setPassword($password);
// FIXME Check result and handle failures
$auth->doCreateUser($user);
$user->setAuthId($auth->authId);
$user->setPassword(Validation::encryptCredentials($user->getId(), Validation::generatePassword()));
// Used for PW reset hash only
} else {
$user->setPassword(Validation::encryptCredentials($this->getData('username'), $password));
}
$user->setDateRegistered(Core::getCurrentDate());
$userId = $userDao->insertUser($user);
$isManager = Validation::isJournalManager();
if (!empty($this->_data['enrollAs'])) {
foreach ($this->getData('enrollAs') as $roleName) {
// Enroll new user into an initial role
$roleDao =& DAORegistry::getDAO('RoleDAO');
$roleId = $roleDao->getRoleIdFromPath($roleName);
if (!$isManager && $roleId != ROLE_ID_READER) {
continue;
}
if ($roleId != null) {
$role = new Role();
$role->setJournalId($journal->getId());
$role->setUserId($userId);
$role->setRoleId($roleId);
$roleDao->insertRole($role);
}
}
}
if ($sendNotify) {
// Send welcome email to user
import('classes.mail.MailTemplate');
$mail = new MailTemplate('USER_REGISTER');
$mail->setFrom($journal->getSetting('contactEmail'), $journal->getSetting('contactName'));
$mail->assignParams(array('username' => $this->getData('username'), 'password' => $password, 'userFullName' => $user->getFullName()));
$mail->addRecipient($user->getEmail(), $user->getFullName());
$mail->send();
}
}
// Insert the user interests
$interests = $this->getData('interestsKeywords') ? $this->getData('interestsKeywords') : $this->getData('interestsTextOnly');
import('lib.pkp.classes.user.InterestManager');
$interestManager = new InterestManager();
$interestManager->setInterestsForUser($user, $interests);
}
示例9: header
//kontrollin kas sessiooni muutuja olemas
if (!isset($_SESSION['user_id'])) {
header("Location: login.php");
//ära enne suunamist midagi tee
exit;
}
// aadressireale tekkis ?logout=1
if (isset($_GET["logout"])) {
//kustutame sessiooni muutujad
session_destroy();
header("Location: login.php");
}
//****************
//****HALDUS******
//****************
$InterestManager = new InterestManager($mysqli, $_SESSION['user_id']);
if (isset($_GET["new_interest"])) {
$add_interest_response = $InterestManager->addInterest($_GET["new_interest"]);
}
if (isset($_GET["dropdown_interest"])) {
$add_user_interest_response = $InterestManager->addUserInterest($_GET["dropdown_interest"]);
}
?>
<p>
Tere, <?php
echo $_SESSION['user_email'];
?>
<a href="?logout=1">Logi välja</a>
示例10: _updateUserInterests
/**
* Update user interests
* @param $user
*/
function _updateUserInterests($user)
{
// Insert the user interests
$interests = $this->getData('interestsKeywords') ? $this->getData('interestsKeywords') : $this->getData('interestsTextOnly');
import('lib.pkp.classes.user.InterestManager');
$interestManager = new InterestManager();
$interestManager->setInterestsForUser($user, $interests);
}
示例11: header
require_once "functions.php";
require_once "InterestManager.class.php";
//kontrollin, kas kasutaja ei ole sisseloginud
if (!isset($_SESSION["id_from_db"])) {
// suunan login lehele
header("Location: login.php");
exit;
}
//login välja, aadressireal on ?logout=1
if (isset($_GET["logout"])) {
//kustutab kõik sessiooni muutujad
session_destroy();
header("Location: login.php");
exit;
}
$InterestManager = new InterestManager($mysqli);
if (isset($_GET["new_interest"])) {
$interests_response = $InterestManager->addInterest($_GET["new_interest"]);
}
if (isset($_GET["dropdownselect"])) {
$added_user_interests = $InterestManager->addUserInterest($_GET["dropdownselect"], $_SESSION["id_from_db"]);
}
?>
<p>
Tere, <?php
echo $_SESSION["user_email"];
?>
<a href="?logout=1"> Logi välja</a>
</p>
示例12: _doUserRequest
//.........這裏部分代碼省略.........
curl_setopt($curlCh, CURLOPT_HTTPHEADER, $extraHeaders);
curl_setopt($curlCh, CURLOPT_POSTFIELDS, $soapMessage);
$result = true;
$response = curl_exec($curlCh);
// We do not localize our error messages as they are all
// fatal errors anyway and must be analyzed by technical staff.
if ($response === false) {
$result = 'OJS-OFR: Expected string response.';
}
if ($result === true && ($status = curl_getinfo($curlCh, CURLINFO_HTTP_CODE)) != OFR_WS_RESPONSE_OK) {
$result = 'OJS-OFR: Expected ' . OFR_WS_RESPONSE_OK . ' response code, got ' . $status . ' instead.';
}
curl_close($curlCh);
// Check SOAP response by simple string manipulation rather
// than instantiating a DOM.
if (is_string($response)) {
$request = Application::getRequest();
/**
* The XML returned looks something like this:
*
* <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
* <soap:Header><AuthorizationToken xmlns="http://www.avectra.com/2005/"><Token>2a51ca85-d490-4444-802c-d247259d674a</Token></AuthorizationToken></soap:Header>
* <soap:Body>
* <BNEGetIndividualInformationResponse xmlns="http://www.avectra.com/2005/">
* <BNEGetIndividualInformationResult>
* <Individual xmlns="">
* <ind_cst_key>2a51ca85-d490-9999-802c-d24XX59d674a</ind_cst_key>
* <cst_recno>000001</cst_recno>
* <ind_first_name>John</ind_first_name>
* <ind_last_name>Public</ind_last_name>
* <cst_eml_address_dn>user@email.com</cst_eml_address_dn>
* <InterestCodes><InterestCode>Art and Material Culture</InterestCode></InterestCodes>
* </Individual>
* </BNEGetIndividualInformationResult>
* </BNEGetIndividualInformationResponse>
* </soap:Body>
* </soap:Envelope>
*/
$matches = array();
if (!preg_match('#<faultstring>([^<]*)</faultstring>#', $response)) {
// Ensure that the user is logged into the AnthroNet portal.
if (preg_match('#<ind_cst_key>00000000\\-0000\\-0000\\-0000\\-000000000000</ind_cst_key>#', $response)) {
$request->redirect(null, 'user');
} else {
$email = $firstName = $lastName = $interestCodes = null;
$interestCodesArray = array();
if (preg_match('#<cst_eml_address_dn>(.*?)</cst_eml_address_dn>#', $response, $matches)) {
$email = $matches[1];
}
if (preg_match('#<ind_first_name>(.*?)</ind_first_name>#', $response, $matches)) {
$firstName = $matches[1];
}
if (preg_match('#<ind_last_name>(.*?)</ind_last_name>#', $response, $matches)) {
$lastName = $matches[1];
}
if (preg_match('#<InterestCodes>(.*?)</InterestCodes>#', $response, $matches)) {
$interestCodes = $matches[1];
preg_match_all('#<InterestCode>(.*?)</InterestCode>#', $interestCodes, $matches, PREG_PATTERN_ORDER);
if (is_array($matches[1])) {
$interestCodesArray = $matches[1];
}
}
$userDao =& DAORegistry::getDAO('UserDAO');
// see if this user exists already.
$user = $userDao->getUserByEmail($email);
if (!$user) {
$user = new User();
$userName = Validation::suggestUsername($firstName, $lastName);
$user->setUsername($userName);
$user->setFirstName($firstName);
$user->setLastName($lastName);
$user->setEmail($email);
$user->setDateRegistered(Core::getCurrentDate());
$locales = array('en_US');
$user->setLocales($locales);
$user->setPassword(Validation::encryptCredentials($userName, Validation::generatePassword()));
$userDao->insertUser($user);
}
import('lib.pkp.classes.user.InterestManager');
$interestManager = new InterestManager();
$interestManager->setInterestsForUser($user, $interestCodesArray);
// enroll as Author, if not already.
$roleDao =& DAORegistry::getDAO('RoleDAO');
if (!$roleDao->userHasRole($journal->getId(), $user->getId(), ROLE_ID_AUTHOR)) {
$role = new Role();
$role->setJournalId($journal->getId());
$role->setUserId($user->getId());
$role->setRoleId(ROLE_ID_AUTHOR);
$roleDao->insertRole($role);
}
return $user;
}
} else {
$result = 'OFR: ' . $status . ' - ' . $matches[1];
}
} else {
$result = 'OJS-OFR: Expected string response.';
}
return false;
}
示例13: header
<?php
require_once "functions.php";
require_once "../classes/Confirm.class.php";
require_once "../classes/InterestManager.class.php";
if (!isset($_SESSION['logged_in_user_id'])) {
header("Location: login.php");
}
if (isset($_GET["logout"])) {
//kustutame sessiooni muutujad
session_destroy();
header("Location: login.php");
}
$InterestManager = new InterestManager($mysqli, $_GET["id"]);
$Confirm = new Confirm($mysqli);
$contest_array = $Confirm->getAllData();
?>
<?php
// lehe nimi
$page_title = "Kasutaja info";
?>
<?php
require_once "../header.php";
?>
<br><br>
<div class="container">
<div class="row">
示例14: importUsers
/**
* Import the parsed users into the system.
* @param $sendNotify boolean send an email notification to each imported user containing their username and password
* @param $continueOnError boolean continue to import remaining users if a failure occurs
* @return boolean success
*/
function importUsers($sendNotify = false, $continueOnError = false)
{
$success = true;
$this->importedUsers = array();
$this->errors = array();
$userDao =& DAORegistry::getDAO('UserDAO');
$roleDao =& DAORegistry::getDAO('RoleDAO');
if ($sendNotify) {
// Set up mail template to send to added users
import('classes.mail.MailTemplate');
$mail = new MailTemplate('USER_REGISTER');
$journalDao =& DAORegistry::getDAO('JournalDAO');
$journal =& $journalDao->getJournal($this->journalId);
$mail->setFrom($journal->getSetting('contactEmail'), $journal->getSetting('contactName'));
}
for ($i = 0, $count = count($this->usersToImport); $i < $count; $i++) {
$user =& $this->usersToImport[$i];
// If the email address already exists in the system,
// then assign the user the username associated with that email address.
if ($user->getEmail() != null) {
$emailExists = $userDao->getUserByEmail($user->getEmail(), true);
if ($emailExists != null) {
$user->setUsername($emailExists->getUsername());
}
}
if ($user->getUsername() == null) {
$newUsername = true;
$this->generateUsername($user);
} else {
$newUsername = false;
}
if ($user->getUnencryptedPassword() != null) {
$user->setPassword(Validation::encryptCredentials($user->getUsername(), $user->getUnencryptedPassword()));
} else {
if ($user->getPassword() == null) {
$this->generatePassword($user);
}
}
if (!$newUsername) {
// Check if user already exists
$userExists = $userDao->getUserByUsername($user->getUsername(), true);
if ($userExists != null) {
$user->setId($userExists->getId());
}
} else {
$userExists = false;
}
if ($newUsername || !$userExists) {
// Create new user account
// If the user's username was specified in the data file and
// the username already exists, only the new roles are added for that user
if (!$userDao->insertUser($user)) {
// Failed to add user!
$this->errors[] = sprintf('%s: %s (%s)', __('manager.people.importUsers.failedToImportUser'), $user->getFullName(), $user->getUsername());
if ($continueOnError) {
// Skip to next user
$success = false;
continue;
} else {
return false;
}
}
}
// Add reviewing interests to interests table
$interests = $user->getTemporaryInterests();
$interests = explode(',', $interests);
$interests = array_map('trim', $interests);
// Trim leading whitespace
import('lib.pkp.classes.user.InterestManager');
$interestManager = new InterestManager();
$interestManager->setInterestsForUser($user, $interests);
// Enroll user in specified roles
// If the user is already enrolled in a role, that role is skipped
foreach ($user->getRoles() as $role) {
$role->setUserId($user->getId());
$role->setJournalId($this->journalId);
if (!$roleDao->roleExists($role->getJournalId(), $role->getUserId(), $role->getRoleId())) {
if (!$roleDao->insertRole($role)) {
// Failed to add role!
$this->errors[] = sprintf('%s: %s - %s (%s)', __('manager.people.importUsers.failedToImportRole'), $role->getRoleName(), $user->getFullName(), $user->getUsername());
if ($continueOnError) {
// Continue to insert other roles for this user
$success = false;
continue;
} else {
return false;
}
}
}
}
if ($sendNotify && !$userExists) {
// Send email notification to user as if user just registered themselves
$mail->addRecipient($user->getEmail(), $user->getFullName());
$mail->sendWithParams(array('journalName' => $journal->getTitle($journal->getPrimaryLocale()), 'username' => $user->getUsername(), 'password' => $user->getUnencryptedPassword() == null ? '-' : $user->getUnencryptedPassword(), 'userFullName' => $user->getFullName()));
//.........這裏部分代碼省略.........
示例15: foreach
function &exportUsers(&$journal, &$users, $allowedRoles = null)
{
$roleDao =& DAORegistry::getDAO('RoleDAO');
$doc =& XMLCustomWriter::createDocument('users', USERS_DTD_ID, USERS_DTD_URL);
$root =& XMLCustomWriter::createElement($doc, 'users');
foreach ($users as $user) {
$userNode =& XMLCustomWriter::createElement($doc, 'user');
XMLCustomWriter::createChildWithText($doc, $userNode, 'username', $user->getUserName(), false);
$passwordNode =& XMLCustomWriter::createChildWithText($doc, $userNode, 'password', $user->getPassword());
XMLCustomWriter::setAttribute($passwordNode, 'encrypted', Config::getVar('security', 'encryption'));
XMLCustomWriter::createChildWithText($doc, $userNode, 'salutation', $user->getSalutation(), false);
XMLCustomWriter::createChildWithText($doc, $userNode, 'first_name', $user->getFirstName());
XMLCustomWriter::createChildWithText($doc, $userNode, 'middle_name', $user->getMiddleName(), false);
XMLCustomWriter::createChildWithText($doc, $userNode, 'last_name', $user->getLastName());
XMLCustomWriter::createChildWithText($doc, $userNode, 'initials', $user->getInitials(), false);
XMLCustomWriter::createChildWithText($doc, $userNode, 'gender', $user->getGender(), false);
XMLCustomWriter::createChildWithText($doc, $userNode, 'email', $user->getEmail());
XMLCustomWriter::createChildWithText($doc, $userNode, 'url', $user->getUrl(), false);
XMLCustomWriter::createChildWithText($doc, $userNode, 'phone', $user->getPhone(), false);
XMLCustomWriter::createChildWithText($doc, $userNode, 'fax', $user->getFax(), false);
XMLCustomWriter::createChildWithText($doc, $userNode, 'mailing_address', $user->getMailingAddress(), false);
XMLCustomWriter::createChildWithText($doc, $userNode, 'country', $user->getCountry(), false);
if (is_array($user->getAffiliation(null))) {
foreach ($user->getAffiliation(null) as $locale => $value) {
$affiliationNode =& XMLCustomWriter::createChildWithText($doc, $userNode, 'affiliation', $value, false);
if ($affiliationNode) {
XMLCustomWriter::setAttribute($affiliationNode, 'locale', $locale);
}
unset($affiliationNode);
}
}
if (is_array($user->getSignature(null))) {
foreach ($user->getSignature(null) as $locale => $value) {
$signatureNode =& XMLCustomWriter::createChildWithText($doc, $userNode, 'signature', $value, false);
if ($signatureNode) {
XMLCustomWriter::setAttribute($signatureNode, 'locale', $locale);
}
unset($signatureNode);
}
}
import('lib.pkp.classes.user.InterestManager');
$interestManager = new InterestManager();
$interests = $interestManager->getInterestsForUser($user);
if (is_array($interests)) {
foreach ($interests as $interest) {
XMLCustomWriter::createChildWithText($doc, $userNode, 'interests', $interest, false);
}
}
if (is_array($user->getGossip(null))) {
foreach ($user->getGossip(null) as $locale => $value) {
$gossipNode =& XMLCustomWriter::createChildWithText($doc, $userNode, 'gossip', $value, false);
if ($gossipNode) {
XMLCustomWriter::setAttribute($gossipNode, 'locale', $locale);
}
unset($gossipNode);
}
}
if (is_array($user->getBiography(null))) {
foreach ($user->getBiography(null) as $locale => $value) {
$biographyNode =& XMLCustomWriter::createChildWithText($doc, $userNode, 'biography', $value, false);
if ($biographyNode) {
XMLCustomWriter::setAttribute($biographyNode, 'locale', $locale);
}
unset($biographyNode);
}
}
XMLCustomWriter::createChildWithText($doc, $userNode, 'locales', join(':', $user->getLocales()), false);
$roles =& $roleDao->getRolesByUserId($user->getId(), $journal->getId());
foreach ($roles as $role) {
$rolePath = $role->getRolePath();
if ($allowedRoles !== null && !in_array($rolePath, $allowedRoles)) {
continue;
}
$roleNode =& XMLCustomWriter::createElement($doc, 'role');
XMLCustomWriter::setAttribute($roleNode, 'type', $rolePath);
XMLCustomWriter::appendChild($userNode, $roleNode);
unset($roleNode);
}
XMLCustomWriter::appendChild($root, $userNode);
}
XMLCustomWriter::appendChild($doc, $root);
return $doc;
}