本文整理汇总了PHP中Role::setRoleId方法的典型用法代码示例。如果您正苦于以下问题:PHP Role::setRoleId方法的具体用法?PHP Role::setRoleId怎么用?PHP Role::setRoleId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Role
的用法示例。
在下文中一共展示了Role::setRoleId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: become
/**
* Become a given role.
*/
function become($args)
{
parent::validate(true, true);
$user =& Request::getUser();
if (!$user) {
Request::redirect(null, null, 'index');
}
switch (array_shift($args)) {
case 'submitter':
$roleId = ROLE_ID_SUBMITTER;
$setting = 'enableSubmit';
$deniedKey = 'user.noRoles.enableSubmitClosed';
break;
default:
Request::redirect('index');
}
$site =& Request::getSite();
if ($site->getSetting($setting)) {
$role = new Role();
$role->setRoleId($roleId);
$role->setUserId($user->getId());
$roleDao =& DAORegistry::getDAO('RoleDAO');
$roleDao->insertRole($role);
Request::redirectUrl(Request::getUserVar('source'));
} else {
$templateMgr =& TemplateManager::getManager();
$templateMgr->assign('message', $deniedKey);
return $templateMgr->display('common/message.tpl');
}
}
示例2: Role
/**
* Internal function to return a Role object from a row.
* @param $row array
* @return Role
*/
function &_returnRoleFromRow(&$row)
{
$role = new Role();
$role->setUserId($row['user_id']);
$role->setRoleId($row['role_id']);
HookRegistry::call('RoleDAO::_returnRoleFromRow', array(&$role, &$row));
return $role;
}
示例3: Role
/**
* Internal function to return a Role object from a row.
* @param $row array
* @return Role
*/
function _returnRoleFromRow($row)
{
$role = new Role($row['role_id']);
$role->setConferenceId($row['conference_id']);
$role->setSchedConfId($row['sched_conf_id']);
$role->setUserId($row['user_id']);
$role->setRoleId($row['role_id']);
HookRegistry::call('RoleDAO::_returnRoleFromRow', array(&$role, &$row));
return $role;
}
示例4: BuildPostedDataObject
/**
* @return void
* @desc Re-build from data posted by this control the data object this control
* is editing
*/
function BuildPostedDataObject()
{
$role = new Role();
if (isset($_POST['item'])) {
$role->setRoleId($_POST['item']);
}
$role->setRoleName($_POST['name']);
$permissions = $this->permissions_editor->DataObjects()->GetItems();
foreach ($permissions as $permission) {
$role->Permissions()->AddPermission($permission->GetId(), $permission->GetValue());
}
$this->SetDataObject($role);
}
示例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 = $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;
}
$siteSettingsDao =& DAORegistry::getDAO('SiteSettingsDAO');
$siteSettingsDao->installSettings('registry/siteSettings.xml', array('contactEmail' => $this->getParam('adminEmail')));
// 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));
}
return true;
}
示例6: execute
/**
* Register a new user.
*/
function execute()
{
$userDao =& DAORegistry::getDAO('UserDAO');
$journal =& Request::getJournal();
if (isset($this->userId)) {
$user =& $userDao->getById($this->userId);
}
if (!isset($user)) {
$user = new User();
}
$user->setSalutation($this->getData('salutation'));
$user->setFirstName($this->getData('firstName'));
$user->setMiddleName($this->getData('middleName'));
$user->setLastName($this->getData('lastName'));
$user->setInitials($this->getData('initials'));
$user->setGender($this->getData('gender'));
$user->setAffiliation($this->getData('affiliation'), null);
// Localized
$user->setSignature($this->getData('signature'), null);
// Localized
$user->setEmail($this->getData('email'));
$user->setData('orcid', $this->getData('orcid'));
$user->setUrl($this->getData('userUrl'));
$user->setPhone($this->getData('phone'));
$user->setFax($this->getData('fax'));
$user->setMailingAddress($this->getData('mailingAddress'));
$user->setCountry($this->getData('country'));
$user->setBiography($this->getData('biography'), null);
// Localized
$user->setGossip($this->getData('gossip'), null);
// Localized
$user->setMustChangePassword($this->getData('mustChangePassword') ? 1 : 0);
$user->setAuthId((int) $this->getData('authId'));
$site =& Request::getSite();
$availableLocales = $site->getSupportedLocales();
$locales = array();
foreach ($this->getData('userLocales') as $locale) {
if (AppLocale::isLocaleValid($locale) && in_array($locale, $availableLocales)) {
array_push($locales, $locale);
}
}
$user->setLocales($locales);
if ($user->getAuthId()) {
$authDao =& DAORegistry::getDAO('AuthSourceDAO');
$auth =& $authDao->getPlugin($user->getAuthId());
}
if ($user->getId() != null) {
$userId = $user->getId();
if ($this->getData('password') !== '') {
if (isset($auth)) {
$auth->doSetUserPassword($user->getUsername(), $this->getData('password'));
$user->setPassword(Validation::encryptCredentials($userId, Validation::generatePassword()));
// Used for PW reset hash only
} else {
$user->setPassword(Validation::encryptCredentials($user->getUsername(), $this->getData('password')));
}
}
if (isset($auth)) {
// FIXME Should try to create user here too?
$auth->doSetUserInfo($user);
}
$userDao->updateObject($user);
} else {
$user->setUsername($this->getData('username'));
if ($this->getData('generatePassword')) {
$password = Validation::generatePassword();
$sendNotify = true;
} else {
$password = $this->getData('password');
$sendNotify = $this->getData('sendNotify');
}
if (isset($auth)) {
$user->setPassword($password);
// FIXME Check result and handle failures
$auth->doCreateUser($user);
$user->setAuthId($auth->authId);
$user->setPassword(Validation::encryptCredentials($user->getId(), Validation::generatePassword()));
// Used for PW reset hash only
} else {
$user->setPassword(Validation::encryptCredentials($this->getData('username'), $password));
}
$user->setDateRegistered(Core::getCurrentDate());
$userId = $userDao->insertUser($user);
$isManager = Validation::isJournalManager();
if (!empty($this->_data['enrollAs'])) {
foreach ($this->getData('enrollAs') as $roleName) {
// Enroll new user into an initial role
$roleDao =& DAORegistry::getDAO('RoleDAO');
$roleId = $roleDao->getRoleIdFromPath($roleName);
if (!$isManager && $roleId != ROLE_ID_READER) {
continue;
}
if ($roleId != null) {
$role = new Role();
$role->setJournalId($journal->getId());
$role->setUserId($userId);
$role->setRoleId($roleId);
//.........这里部分代码省略.........
示例7: enroll
/**
* Enroll a user in a role.
*/
function enroll($args)
{
$this->validate();
$roleId = (int) (isset($args[0]) ? $args[0] : Request::getUserVar('roleId'));
// Get a list of users to enroll -- either from the
// submitted array 'users', or the single user ID in
// 'userId'
$users = Request::getUserVar('users');
if (!isset($users) && Request::getUserVar('userId') != null) {
$users = array(Request::getUserVar('userId'));
}
$journalDao =& DAORegistry::getDAO('JournalDAO');
$journal =& $journalDao->getJournalByPath(Request::getRequestedJournalPath());
$roleDao =& DAORegistry::getDAO('RoleDAO');
$rolePath = $roleDao->getRolePath($roleId);
if ($users != null && is_array($users) && $rolePath != '' && $rolePath != 'admin') {
for ($i = 0; $i < count($users); $i++) {
if (!$roleDao->userHasRole($journal->getId(), $users[$i], $roleId)) {
$role = new Role();
$role->setJournalId($journal->getId());
$role->setUserId($users[$i]);
$role->setRoleId($roleId);
$roleDao->insertRole($role);
}
}
}
Request::redirect(null, null, 'people', empty($rolePath) ? null : $rolePath . 's');
}
示例8: display
function display(&$args, $request)
{
$templateMgr = TemplateManager::getManager($request);
parent::display($args, $request);
$templateMgr->assign('roleOptions', array('' => 'manager.people.doNotEnroll', 'manager' => 'user.role.manager', 'editor' => 'user.role.editor', 'sectionEditor' => 'user.role.sectionEditor', 'layoutEditor' => 'user.role.layoutEditor', 'reviewer' => 'user.role.reviewer', 'copyeditor' => 'user.role.copyeditor', 'proofreader' => 'user.role.proofreader', 'author' => 'user.role.author', 'reader' => 'user.role.reader', 'subscriptionManager' => 'user.role.subscriptionManager'));
$roleDao = DAORegistry::getDAO('RoleDAO');
$journal = $request->getJournal();
set_time_limit(0);
switch (array_shift($args)) {
case 'confirm':
$this->import('UserXMLParser');
$sendNotify = (bool) $request->getUserVar('sendNotify');
$continueOnError = (bool) $request->getUserVar('continueOnError');
import('lib.pkp.classes.file.FileManager');
$fileManager = new FileManager();
if (($userFile = $fileManager->getUploadedFilePath('userFile')) !== false) {
// Import the uploaded file
$parser = new UserXMLParser($journal->getId());
$users =& $parser->parseData($userFile);
$i = 0;
$usersRoles = array();
foreach ($users as $user) {
$usersRoles[$i] = array();
foreach ($user->getRoles() as $role) {
array_push($usersRoles[$i], $role->getRoleName());
}
$i++;
}
$templateMgr->assign('users', $users);
$templateMgr->assign('usersRoles', $usersRoles);
$templateMgr->assign('sendNotify', $sendNotify);
$templateMgr->assign('continueOnError', $continueOnError);
$templateMgr->assign('errors', $parser->errors);
// Show confirmation form
$templateMgr->display($this->getTemplatePath() . 'importUsersConfirm.tpl');
}
break;
case 'import':
$this->import('UserXMLParser');
$roleDao = DAORegistry::getDAO('RoleDAO');
$userKeys = $request->getUserVar('userKeys');
if (!is_array($userKeys)) {
$userKeys = array();
}
$sendNotify = (bool) $request->getUserVar('sendNotify');
$continueOnError = (bool) $request->getUserVar('continueOnError');
$users = array();
foreach ($userKeys as $i) {
$newUser = new ImportedUser();
$newUser->setFirstName($request->getUserVar($i . '_firstName'));
$newUser->setMiddleName($request->getUserVar($i . '_middleName'));
$newUser->setLastName($request->getUserVar($i . '_lastName'));
$newUser->setUsername($request->getUserVar($i . '_username'));
$newUser->setEmail($request->getUserVar($i . '_email'));
$locales = array();
if ($request->getUserVar($i . '_locales') != null || is_array($request->getUserVar($i . '_locales'))) {
foreach ($request->getUserVar($i . '_locales') as $locale) {
array_push($locales, $locale);
}
}
$newUser->setLocales($locales);
$newUser->setSignature($request->getUserVar($i . '_signature'), null);
$newUser->setBiography($request->getUserVar($i . '_biography'), null);
$newUser->setTemporaryInterests($request->getUserVar($i . '_interests'));
$newUser->setGossip($request->getUserVar($i . '_gossip'), null);
$newUser->setCountry($request->getUserVar($i . '_country'));
$newUser->setMailingAddress($request->getUserVar($i . '_mailingAddress'));
$newUser->setFax($request->getUserVar($i . '_fax'));
$newUser->setPhone($request->getUserVar($i . '_phone'));
$newUser->setUrl($request->getUserVar($i . '_url'));
$newUser->setAffiliation($request->getUserVar($i . '_affiliation'), null);
$newUser->setGender($request->getUserVar($i . '_gender'));
$newUser->setInitials($request->getUserVar($i . '_initials'));
$newUser->setSalutation($request->getUserVar($i . '_salutation'));
$newUser->setPassword($request->getUserVar($i . '_password'));
$newUser->setMustChangePassword($request->getUserVar($i . '_mustChangePassword'));
$newUser->setUnencryptedPassword($request->getUserVar($i . '_unencryptedPassword'));
$newUserRoles = $request->getUserVar($i . '_roles');
if (is_array($newUserRoles) && count($newUserRoles) > 0) {
foreach ($newUserRoles as $newUserRole) {
if ($newUserRole != '') {
$role = new Role();
$role->setRoleId($roleDao->getRoleIdFromPath($newUserRole));
$newUser->addRole($role);
}
}
}
array_push($users, $newUser);
}
$parser = new UserXMLParser($journal->getId());
$parser->setUsersToImport($users);
if (!$parser->importUsers($sendNotify, $continueOnError)) {
// Failures occurred
$templateMgr->assign('isError', true);
$templateMgr->assign('errors', $parser->getErrors());
}
$templateMgr->assign('importedUsers', $parser->getImportedUsers());
$templateMgr->display($this->getTemplatePath() . 'importUsersResults.tpl');
break;
case 'exportAll':
//.........这里部分代码省略.........
示例9: importPapers
/**
* Import papers (including metadata and files).
*/
function importPapers()
{
if ($this->hasOption('verbose')) {
printf("Importing papers\n");
}
import('classes.file.PaperFileManager');
import('classes.search.PaperSearchIndex');
$userDao =& DAORegistry::getDAO('UserDAO');
$roleDao =& DAORegistry::getDAO('RoleDAO');
$trackDao =& DAORegistry::getDAO('TrackDAO');
$paperDao =& DAORegistry::getDAO('PaperDAO');
$publishedPaperDao =& DAORegistry::getDAO('PublishedPaperDAO');
$galleyDao =& DAORegistry::getDAO('PaperGalleyDAO');
$unassignedTrackId = null;
$result =& $this->importDao->retrieve('SELECT * FROM papers ORDER by id');
while (!$result->EOF) {
$row =& $result->fields;
$schedConf =& $this->schedConfMap[$row['cf']];
$schedConfId = $schedConf->getId();
// Bring in the primary user for this paper.
$user = $userDao->getUserByUsername(Core::cleanVar($row['login']));
if (!$user) {
unset($user);
$user = new User();
$user->setUsername(Core::cleanVar($row['login']));
$user->setFirstName(Core::cleanVar($row['first_name']));
$user->setLastName(Core::cleanVar($row['surname']));
$user->setAffiliation(Core::cleanVar($row['affiliation']), Locale::getLocale());
$user->setEmail(Core::cleanVar($row['email']));
$user->setUrl(Core::cleanVar($row['url']));
$user->setBiography(Core::cleanVar($row['bio']), Locale::getLocale());
$user->setLocales(array());
$user->setDateRegistered($row['created']);
$user->setDateLastLogin($row['created']);
$user->setMustChangePassword(1);
$password = Validation::generatePassword();
$user->setPassword(Validation::encryptCredentials($user->getUsername(), $password));
if ($this->hasOption('emailUsers')) {
import('classes.mail.MailTemplate');
$mail = new MailTemplate('USER_REGISTER');
$mail->setFrom($schedConf->getSetting('contactEmail'), $schedConf->getSetting('contactName'));
$mail->assignParams(array('username' => $user->getUsername(), 'password' => $password, 'conferenceName' => $schedConf->getFullTitle()));
$mail->addRecipient($user->getEmail(), $user->getFullName());
$mail->send();
}
$user->setDisabled(0);
$otherUser =& $userDao->getUserByEmail(Core::cleanVar($row['email']));
if ($otherUser !== null) {
// User exists with this email -- munge it to make unique
$user->setEmail('ocs-' . Core::cleanVar($row['login']) . '+' . Core::cleanVar($row['email']));
$this->conflicts[] = array(&$otherUser, &$user);
}
unset($otherUser);
$userDao->insertUser($user);
// Make this user a author
$role = new Role();
$role->setSchedConfId($schedConf->getId());
$role->setConferenceId($schedConf->getConferenceId());
$role->setUserId($user->getId());
$role->setRoleId(ROLE_ID_AUTHOR);
$roleDao->insertRole($role);
unset($role);
}
$userId = $user->getId();
// Bring in the basic entry for the paper
$paper = new Paper();
$paper->setUserId($userId);
$paper->setLocale(Locale::getPrimaryLocale());
$paper->setSchedConfId($schedConfId);
$oldTrackId = $row['primary_track_id'];
if (!$oldTrackId || !isset($this->trackMap[$oldTrackId])) {
$oldTrackId = $row['secondary_track_id'];
}
if (!$oldTrackId || !isset($this->trackMap[$oldTrackId])) {
if (!$unassignedTrackId) {
// Create an "Unassigned" track to use for submissions
// that didn't have a track in OCS 1.x.
$track = new Track();
$track->setSchedConfId($schedConf->getId());
$track->setTitle('UNASSIGNED', Locale::getLocale());
$track->setSequence(REALLY_BIG_NUMBER);
$track->setDirectorRestricted(1);
$track->setMetaReviewed(1);
$unassignedTrackId = $trackDao->insertTrack($track);
}
$newTrackId = $unassignedTrackId;
} else {
$newTrackId = $this->trackMap[$oldTrackId];
}
$paper->setTrackId($newTrackId);
$paper->setTitle(Core::cleanVar($row['title']), Locale::getLocale());
$paper->setAbstract(Core::cleanVar($row['abstract']), Locale::getLocale());
$paper->setDiscipline(Core::cleanVar($row['discipline']), Locale::getLocale());
$paper->setSponsor(Core::cleanVar($row['sponsor']), Locale::getLocale());
$paper->setSubject(Core::cleanVar($row['topic']), Locale::getLocale());
$paper->setLanguage(Core::cleanVar($row['language']));
$paper->setDateSubmitted($row['created']);
//.........这里部分代码省略.........
示例10: execute
/**
* Register a new user.
*/
function execute()
{
$requireValidation = Config::getVar('email', 'require_validation');
if ($this->existingUser) {
// Existing user in the system
$userDao =& DAORegistry::getDAO('UserDAO');
$user =& $userDao->getUserByUsername($this->getData('username'));
if ($user == null) {
return false;
}
$userId = $user->getId();
} else {
// New user
$user = new User();
$user->setUsername($this->getData('username'));
$user->setSalutation($this->getData('salutation'));
$user->setFirstName($this->getData('firstName'));
$user->setMiddleName($this->getData('middleName'));
$user->setInitials($this->getData('initials'));
$user->setLastName($this->getData('lastName'));
$user->setGender($this->getData('gender'));
$user->setAffiliation($this->getData('affiliation'));
$user->setSignature($this->getData('signature'), null);
// Localized
$user->setEmail($this->getData('email'));
$user->setUrl($this->getData('userUrl'));
$user->setPhone($this->getData('phone'));
$user->setFax($this->getData('fax'));
$user->setMailingAddress($this->getData('mailingAddress'));
$user->setBiography($this->getData('biography'), null);
// Localized
$user->setInterests($this->getData('interests'), null);
// Localized
$user->setDateRegistered(Core::getCurrentDate());
$user->setCountry($this->getData('country'));
$site =& Request::getSite();
$availableLocales = $site->getSupportedLocales();
$locales = array();
foreach ($this->getData('userLocales') as $locale) {
if (AppLocale::isLocaleValid($locale) && in_array($locale, $availableLocales)) {
array_push($locales, $locale);
}
}
$user->setLocales($locales);
if (isset($this->defaultAuth)) {
$user->setPassword($this->getData('password'));
// FIXME Check result and handle failures
$this->defaultAuth->doCreateUser($user);
$user->setAuthId($this->defaultAuth->authId);
}
$user->setPassword(Validation::encryptCredentials($this->getData('username'), $this->getData('password')));
if ($requireValidation) {
// The account should be created in a disabled
// state.
$user->setDisabled(true);
$user->setDisabledReason(__('user.login.accountNotValidated'));
}
$userDao =& DAORegistry::getDAO('UserDAO');
$userDao->insertUser($user);
$userId = $user->getId();
if (!$userId) {
return false;
}
$sessionManager =& SessionManager::getManager();
$session =& $sessionManager->getUserSession();
$session->setSessionVar('username', $user->getUsername());
}
$conference =& Request::getConference();
$schedConf =& Request::getSchedConf();
$roleDao =& DAORegistry::getDAO('RoleDAO');
// Roles users are allowed to register themselves in
$allowedRoles = array('reader' => 'createAsReader', 'author' => 'createAsAuthor', 'reviewer' => 'createAsReviewer');
import('schedConf.SchedConfAction');
if (!SchedConfAction::allowRegReader($schedConf)) {
unset($allowedRoles['reader']);
}
if (!SchedConfAction::allowRegAuthor($schedConf)) {
unset($allowedRoles['author']);
}
if (!SchedConfAction::allowRegReviewer($schedConf)) {
unset($allowedRoles['reviewer']);
}
foreach ($allowedRoles as $k => $v) {
$roleId = $roleDao->getRoleIdFromPath($k);
if ($this->getData($v) && !$roleDao->roleExists($conference->getId(), $schedConf->getId(), $userId, $roleId)) {
$role = new Role();
$role->setConferenceId($conference->getId());
$role->setSchedConfId($schedConf->getId());
$role->setUserId($userId);
$role->setRoleId($roleId);
$roleDao->insertRole($role);
}
}
if (!$this->existingUser) {
$this->sendConfirmationEmail($user, $this->getData('password'), $this->getData('sendPassword'));
}
if (isset($allowedRoles['reader']) && $this->getData('openAccessNotification')) {
//.........这里部分代码省略.........
示例11: execute
/**
* 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);
//.........这里部分代码省略.........
示例12: execute
/**
* 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)) {
//.........这里部分代码省略.........
示例13: become
/**
* Become a given role.
* @param $args array
* @param $request PKPRequest
*/
function become($args, $request)
{
parent::validate(true);
$journal = $request->getJournal();
$user = $request->getUser();
switch (array_shift($args)) {
case 'author':
$roleId = ROLE_ID_AUTHOR;
$setting = 'allowRegAuthor';
$deniedKey = 'user.noRoles.submitArticleRegClosed';
break;
case 'reviewer':
$roleId = ROLE_ID_REVIEWER;
$setting = 'allowRegReviewer';
$deniedKey = 'user.noRoles.regReviewerClosed';
break;
default:
$request->redirect(null, null, 'index');
}
if ($journal->getSetting($setting)) {
$role = new Role();
$role->setJournalId($journal->getId());
$role->setRoleId($roleId);
$role->setUserId($user->getId());
$roleDao = DAORegistry::getDAO('RoleDAO');
$roleDao->insertRole($role);
$request->redirectUrl($request->getUserVar('source'));
} else {
$templateMgr = TemplateManager::getManager($request);
$templateMgr->assign('message', $deniedKey);
return $templateMgr->display('common/message.tpl');
}
}
示例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: enroll
function enroll($args, $request)
{
$paperId = (int) array_shift($args);
$this->validate($request, $paperId, TRACK_DIRECTOR_ACCESS_REVIEW);
$conference =& $request->getConference();
$schedConf =& $request->getSchedConf();
$submission =& $this->submission;
$roleDao =& DAORegistry::getDAO('RoleDAO');
$roleId = $roleDao->getRoleIdFromPath('reviewer');
$users = $request->getUserVar('users');
if (!is_array($users) && $request->getUserVar('userId') != null) {
$users = array($request->getUserVar('userId'));
}
// Enroll reviewer
for ($i = 0; $i < count($users); $i++) {
if (!$roleDao->userHasRole($schedConf->getConferenceId(), $schedConf->getId(), $users[$i], $roleId)) {
$role = new Role();
$role->setConferenceId($schedConf->getConferenceId());
$role->setSchedConfId($schedConf->getId());
$role->setUserId($users[$i]);
$role->setRoleId($roleId);
$roleDao->insertRole($role);
}
}
$request->redirect(null, null, null, 'selectReviewer', $paperId);
}