本文整理汇总了PHP中SessionManager::getManager方法的典型用法代码示例。如果您正苦于以下问题:PHP SessionManager::getManager方法的具体用法?PHP SessionManager::getManager怎么用?PHP SessionManager::getManager使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SessionManager
的用法示例。
在下文中一共展示了SessionManager::getManager方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: logEvent
/**
* Add a new event log entry with the specified parameters
* @param $request object
* @param $submission object
* @param $eventType int
* @param $messageKey string
* @param $params array optional
* @return object SubmissionLogEntry iff the event was logged
*/
static function logEvent($request, $submission, $eventType, $messageKey, $params = array())
{
// Create a new entry object
$submissionEventLogDao = DAORegistry::getDAO('SubmissionEventLogDAO');
$entry = $submissionEventLogDao->newDataObject();
// Set implicit parts of the log entry
$entry->setDateLogged(Core::getCurrentDate());
$entry->setIPAddress($request->getRemoteAddr());
if (Validation::isLoggedInAs()) {
// If user is logged in as another user log with real userid
$sessionManager = SessionManager::getManager();
$session = $sessionManager->getUserSession();
$userId = $session->getSessionVar('signedInAs');
if ($userId) {
$entry->setUserId($userId);
}
} else {
$user = $request->getUser();
if ($user) {
$entry->setUserId($user->getId());
}
}
$entry->setSubmissionId($submission->getId());
// Set explicit parts of the log entry
$entry->setEventType($eventType);
$entry->setMessage($messageKey);
$entry->setParams($params);
$entry->setIsTranslated(0);
// Legacy for old entries. All messages now use locale keys.
// Insert the resulting object
$submissionEventLogDao->insertObject($entry);
return $entry;
}
示例2: handleRequest
/**
* Handle a new request.
*/
function handleRequest()
{
if (!Config::getVar('general', 'installed') && pageRequiresInstall()) {
// Redirect to installer if application has not been installed
Request::redirect(null, 'install');
}
// Determine the handler for this request
$page = Request::getRequestedPage();
$op = Request::getRequestedOp();
$sourceFile = sprintf('pages/%s/index.php', $page);
// If a hook has been registered to handle this page, give it the
// opportunity to load required resources and set HANDLER_CLASS.
if (!HookRegistry::call('LoadHandler', array(&$page, &$op, &$sourceFile))) {
if (file_exists($sourceFile)) {
require $sourceFile;
} else {
require 'pages/index/index.php';
}
}
if (!defined('SESSION_DISABLE_INIT')) {
// Initialize session
$sessionManager =& SessionManager::getManager();
$session =& $sessionManager->getUserSession();
}
$methods = array_map('strtolower', get_class_methods(HANDLER_CLASS));
if (in_array(strtolower($op), $methods)) {
// Call a specific operation
call_user_func(array(HANDLER_CLASS, $op), Request::getRequestedArgs());
} else {
// Call the selected handler's index operation
call_user_func(array(HANDLER_CLASS, 'index'), Request::getRequestedArgs());
}
}
示例3: getCellState
/**
* Gathers the state of a given cell given a $row/$column combination
* @param $row GridRow
* @param $column GridColumn
* @return string
*/
function getCellState(&$row, &$column)
{
$element =& $row->getData();
$columnId = $column->getId();
assert(is_a($element, 'DataObject') && !empty($columnId));
switch ($columnId) {
case 'name':
return $element->getDateCompleted() ? 'linkReview' : '';
case is_numeric($columnId):
// numeric implies a role column.
if ($element->getDateCompleted()) {
$viewsDao =& DAORegistry::getDAO('ViewsDAO');
$sessionManager =& SessionManager::getManager();
$session =& $sessionManager->getUserSession();
$user =& $session->getUser();
$lastViewed = $viewsDao->getLastViewDate(ASSOC_TYPE_REVIEW_RESPONSE, $element->getId(), $user->getId());
if ($lastViewed) {
return 'completed';
} else {
return 'new';
}
} else {
return '';
}
case 'reviewer':
if ($element->getDateCompleted()) {
return 'completed';
} elseif ($element->getDateDue() < Core::getCurrentDate()) {
return 'overdue';
} elseif ($element->getDateConfirmed()) {
return $element->getDeclined() ? 'declined' : 'accepted';
}
return 'new';
}
}
示例4: execute
/**
* Save conference settings.
* @param $request PKPRequest
*/
function execute($request)
{
$conferenceDao = DAORegistry::getDAO('ConferenceDAO');
if (isset($this->contextId)) {
$conference =& $conferenceDao->getById($this->contextId);
}
if (!isset($conference)) {
$conference = $conferenceDao->newDataObject();
}
$conference->setPath($this->getData('path'));
$conference->setEnabled($this->getData('enabled'));
if ($conference->getId() != null) {
$isNewConference = false;
$conferenceDao->updateObject($conference);
$section = null;
} else {
$isNewConference = true;
$site = $request->getSite();
// Give it a default primary locale
$conference->setPrimaryLocale($site->getPrimaryLocale());
$conferenceId = $conferenceDao->insertObject($conference);
$conferenceDao->resequence();
// Make the site administrator the conference manager of newly created conferences
$sessionManager =& SessionManager::getManager();
$userSession =& $sessionManager->getUserSession();
if ($userSession->getUserId() != null && $userSession->getUserId() != 0 && !empty($conferenceId)) {
$role = new Role();
$role->setConferenceId($conferenceId);
$role->setUserId($userSession->getUserId());
$role->setRoleId(ROLE_ID_MANAGER);
$roleDao = DAORegistry::getDAO('RoleDAO');
$roleDao->insertRole($role);
}
// Make the file directories for the conference
import('lib.pkp.classes.file.FileManager');
$fileManager = new FileManager();
$fileManager->mkdir(Config::getVar('files', 'files_dir') . '/conferences/' . $conferenceId);
$fileManager->mkdir(Config::getVar('files', 'files_dir') . '/conferences/' . $conferenceId . '/schedConfs');
$fileManager->mkdir(Config::getVar('files', 'public_files_dir') . '/conferences/' . $conferenceId);
$fileManager->mkdir(Config::getVar('files', 'public_files_dir') . '/conferences/' . $conferenceId . '/schedConfs');
// Install default conference settings
$conferenceSettingsDao = DAORegistry::getDAO('ConferenceSettingsDAO');
$names = $this->getData('name');
AppLocale::requireComponents(LOCALE_COMPONENT_APP_DEFAULT, LOCALE_COMPONENT_APP_COMMON);
$dispatcher = $request->getDispatcher();
$conferenceSettingsDao->installSettings($conferenceId, 'registry/conferenceSettings.xml', array('privacyStatementUrl' => $dispatcher->url($request, ROUTE_PAGE, array($this->getData('path'), 'index'), 'about', 'submissions', null, null, 'privacyStatement'), 'loginUrl' => $dispatcher->url($request, ROUTE_PAGE, array('index', 'index'), 'login'), 'conferenceUrl' => $dispatcher->url($request, ROUTE_PAGE, array($this->getData('path'), 'index')), 'conferencePath' => $this->getData('path'), 'primaryLocale' => $site->getPrimaryLocale(), 'aboutUrl' => $dispatcher->url($request, ROUTE_PAGE, array($this->getData('path'), 'index'), 'about'), 'accountUrl' => $dispatcher->url($request, ROUTE_PAGE, array($this->getData('path'), 'index'), 'user', 'register'), 'conferenceName' => $names[$site->getPrimaryLocale()]));
// Install the default RT versions.
import('classes.rt.ocs.ConferenceRTAdmin');
$conferenceRtAdmin = new ConferenceRTAdmin($conferenceId);
$conferenceRtAdmin->restoreVersions(false);
}
$conference->updateSetting('name', $this->getData('name'), 'string', true);
$conference->updateSetting('description', $this->getData('description'), 'string', true);
// Make sure all plugins are loaded for settings preload
PluginRegistry::loadAllPlugins();
HookRegistry::call('ConferenceSiteSettingsForm::execute', array(&$this, &$conference));
}
示例5: __construct
public function __construct()
{
// Get paths to system base directories
$this->baseDir = dirname(dirname(dirname(dirname(dirname(dirname(dirname(dirname(dirname(dirname($_SERVER['SCRIPT_FILENAME']))))))))));
// Load and execute initialization code
chdir($this->baseDir);
define('INDEX_FILE_LOCATION', $this->baseDir . '/index.php');
require $this->baseDir . '/lib/pkp/includes/bootstrap.inc.php';
$publicDir = Config::getVar('files', 'public_files_dir');
$this->baseUrl = Config::getVar('general', 'base_url');
// Load user variables
$sessionManager =& SessionManager::getManager();
$userSession =& $sessionManager->getUserSession();
$user =& $userSession->getUser();
if (isset($user)) {
// User is logged in
$siteDir = $this->baseDir . '/' . $publicDir . '/site/';
if (!file_exists($siteDir . '/images/')) {
import('classes.file.FileManager');
// Check that the public/site/ directory exists and is writeable
if (!file_exists($siteDir) || !is_writeable($siteDir)) {
die(__('installer.installFilesDirError'));
}
// Create the images directory
if (!FileManager::mkdir($siteDir . '/images/')) {
die(__('installer.installFilesDirError'));
}
}
//Check if user's image directory exists, else create it
if (Validation::isLoggedIn() && !file_exists($siteDir . '/images/' . $user->getUsername())) {
import('classes.file.FileManager');
// Check that the public/site/images/ directory exists and is writeable
if (!file_exists($siteDir . '/images/') || !is_writeable($siteDir . '/images/')) {
die(__('installer.installFilesDirError'));
}
// Create the directory to store the user's images
if (!FileManager::mkdir($siteDir . '/images/' . $user->getUsername())) {
die(__('installer.installFilesDirError'));
}
$this->imageDir = $publicDir . '/site/images/' . $user->getUsername();
} else {
if (Validation::isLoggedIn()) {
// User's image directory already exists
$this->imageDir = $publicDir . '/site/images/' . $user->getUsername();
}
}
} else {
// Not logged in; Do not allow images to be uploaded
$this->imageDir = null;
}
// Set the base directory back to its original location
chdir(dirname($_SERVER['SCRIPT_FILENAME']));
}
示例6: getLocale
/**
* Return the key name of the user's currently selected locale (default
* is "en_US" for U.S. English).
* @return string
*/
static function getLocale()
{
static $currentLocale;
if (!isset($currentLocale)) {
if (defined('SESSION_DISABLE_INIT') || !Config::getVar('general', 'installed')) {
// If the locale is specified in the URL, allow
// it to override. (Necessary when locale is
// being set, as cookie will not yet be re-set)
$locale = self::$request->getUserVar('setLocale');
if (empty($locale) || !in_array($locale, array_keys(AppLocale::getSupportedLocales()))) {
$locale = self::$request->getCookieVar('currentLocale');
}
} else {
$sessionManager = SessionManager::getManager();
$session = $sessionManager->getUserSession();
$locale = self::$request->getUserVar('uiLocale');
$press = self::$request->getPress();
$site = self::$request->getSite();
if (!isset($locale)) {
$locale = $session->getSessionVar('currentLocale');
}
if (!isset($locale)) {
$locale = self::$request->getCookieVar('currentLocale');
}
if (isset($locale)) {
// Check if user-specified locale is supported
if ($press != null) {
$locales = $press->getSupportedLocaleNames();
} else {
$locales = $site->getSupportedLocaleNames();
}
if (!in_array($locale, array_keys($locales))) {
unset($locale);
}
}
if (!isset($locale)) {
// Use press/site default
if ($press != null) {
$locale = $press->getPrimaryLocale();
}
if (!isset($locale)) {
$locale = $site->getPrimaryLocale();
}
}
}
if (!AppLocale::isLocaleValid($locale)) {
$locale = LOCALE_DEFAULT;
}
$currentLocale = $locale;
}
return $currentLocale;
}
示例7: initialize
/**
* @copydoc GridRow::initialize()
*/
function initialize($request, $template = null)
{
parent::initialize($request, $template);
// Is this a new row or an existing row?
$element =& $this->getData();
assert(is_a($element, 'User'));
$rowId = $this->getId();
if (!empty($rowId) && is_numeric($rowId)) {
// Only add row actions if this is an existing row
$router = $request->getRouter();
$actionArgs = array('gridId' => $this->getGridId(), 'rowId' => $rowId);
$actionArgs = array_merge($actionArgs, $this->getRequestArgs());
$this->addAction(new LinkAction('email', new AjaxModal($router->url($request, null, null, 'editEmail', null, $actionArgs), __('grid.user.email'), 'modal_email', true), __('grid.user.email'), 'notify'));
$this->addAction(new LinkAction('edit', new AjaxModal($router->url($request, null, null, 'editUser', null, $actionArgs), __('grid.user.edit'), 'modal_edit', true), __('grid.user.edit'), 'edit'));
if ($element->getDisabled()) {
$actionArgs['enable'] = true;
$this->addAction(new LinkAction('enable', new AjaxModal($router->url($request, null, null, 'editDisableUser', null, $actionArgs), __('common.enable'), 'enable', true), __('common.enable'), 'enable'));
} else {
$actionArgs['enable'] = false;
$this->addAction(new LinkAction('disable', new AjaxModal($router->url($request, null, null, 'editDisableUser', null, $actionArgs), __('grid.user.disable'), 'disable', true), __('grid.user.disable'), 'disable'));
}
$this->addAction(new LinkAction('remove', new RemoteActionConfirmationModal(__('manager.people.confirmRemove'), __('common.remove'), $router->url($request, null, null, 'removeUser', null, $actionArgs), 'modal_delete'), __('grid.action.remove'), 'delete'));
$sessionManager = SessionManager::getManager();
$session = $sessionManager->getUserSession();
$canAdminister = Validation::canAdminister($this->getId(), $session->user->getId());
if (!Validation::isLoggedInAs() and $session->user->getId() != $this->getId() and $canAdminister) {
$dispatcher = $router->getDispatcher();
$this->addAction(new LinkAction('logInAs', new RedirectConfirmationModal(__('grid.user.confirmLogInAs'), __('grid.action.logInAs'), $dispatcher->url($request, ROUTE_PAGE, null, 'login', 'signInAsUser', $this->getId())), __('grid.action.logInAs'), 'enroll_user'));
}
$oldUserId = $this->getOldUserId();
$userDao = DAORegistry::getDAO('UserDAO');
$oldUser = $userDao->getById($this->getOldUserId());
if ($oldUser) {
$actionArgs['oldUserId'] = $this->getOldUserId();
$actionArgs['newUserId'] = $rowId;
// Don't merge a user in itself
if ($actionArgs['oldUserId'] != $actionArgs['newUserId']) {
$userDao = DAORegistry::getDAO('UserDAO');
$oldUser = $userDao->getById($this->getOldUserId());
$this->addAction(new LinkAction('mergeUser', new RemoteActionConfirmationModal(__('grid.user.mergeUsers.confirm', array('oldUsername' => $oldUser->getUsername(), 'newUsername' => $element->getUsername())), null, $router->url($request, null, null, 'mergeUsers', null, $actionArgs), 'modal_merge_users'), __('grid.user.mergeUsers.mergeIntoUser'), 'merge_users'));
}
} else {
// do not allow the deletion of the admin account.
if ($rowId > 1 && $canAdminister) {
$this->addAction(new LinkAction('mergeUser', new JsEventConfirmationModal(__('grid.user.mergeUsers.mergeUserSelect.confirm'), 'confirmationModalConfirmed', array('oldUserId' => $rowId), null, 'modal_merge_users'), __('grid.user.mergeUsers.mergeUser'), 'merge_users'));
}
}
}
}
示例8: signIn
/**
* Validate a user's credentials and log the user in.
*/
function signIn()
{
parent::validate();
if (Validation::isLoggedIn()) {
Request::redirect(null, 'user');
}
if (Config::getVar('security', 'force_login_ssl') && Request::getProtocol() != 'https') {
// Force SSL connections for login
Request::redirectSSL();
}
$user = Validation::login(Request::getUserVar('username'), Request::getUserVar('password'), $reason, Request::getUserVar('remember') == null ? false : true);
if ($user !== false) {
if (Config::getVar('security', 'force_login_ssl') && !Config::getVar('security', 'force_ssl')) {
// Redirect back to HTTP if forcing SSL for login only
Request::redirectNonSSL();
} else {
if ($user->getMustChangePassword()) {
// User must change their password in order to log in
Validation::logout();
Request::redirect(null, null, 'changePassword', $user->getUsername());
} else {
$source = Request::getUserVar('source');
if (isset($source) && !empty($source)) {
Request::redirectUrl(Request::getProtocol() . '://' . Request::getServerHost() . $source, false);
} else {
Request::redirect(null, 'user');
}
}
}
} else {
$sessionManager =& SessionManager::getManager();
$session =& $sessionManager->getUserSession();
$templateMgr =& TemplateManager::getManager();
$templateMgr->assign('username', Request::getUserVar('username'));
$templateMgr->assign('remember', Request::getUserVar('remember'));
$templateMgr->assign('source', Request::getUserVar('source'));
$templateMgr->assign('showRemember', Config::getVar('general', 'session_lifetime') > 0);
$templateMgr->assign('error', $reason === null ? 'user.login.loginError' : ($reason === '' ? 'user.login.accountDisabled' : 'user.login.accountDisabledWithReason'));
$templateMgr->assign('reason', $reason);
$templateMgr->display('user/login.tpl');
}
}
示例9: changeActingAsUserGroup
/**
* Change the user's current user group.
* @param $args array
* @param $request PKPRequest
* @return string the serialized grid JSON message
*/
function changeActingAsUserGroup($args, &$request)
{
// Check that the user group parameter is in the request
if (!isset($args['changedActingAsUserGroupId'])) {
fatalError('No acting-as user-group has been found in the request!');
}
// Retrieve the user from the session.
$user =& $request->getUser();
assert(is_a($user, 'User'));
// Check that the target user group exists and
// that the currently logged in user has been
// assigned to it.
$changedActingAsUserGroupId = $args['changedActingAsUserGroupId'];
$userGroupDao = DAORegistry::getDAO('UserGroupDAO');
$router =& $request->getRouter();
$context =& $router->getContext($request);
if ($context) {
// Handle context-specific user groups.
$userInGroup = $userGroupDao->userInGroup($context->getId(), $user->getId(), $changedActingAsUserGroupId);
} else {
$application =& PKPApplication::getApplication();
if ($application->getContextDepth() > 0) {
// Handle site-wide user groups.
$userInGroup = $userGroupDao->userInGroup(0, $user->getId(), $changedActingAsUserGroupId);
} else {
// Handle apps that don't have a context.
$userInGroup = $userGroupDao->userInGroup($user->getId(), $changedActingAsUserGroupId);
}
}
if ($userInGroup) {
$sessionManager =& SessionManager::getManager();
$session =& $sessionManager->getUserSession();
$session->setActingAsUserGroupId($changedActingAsUserGroupId);
$json = new JSON('true');
} else {
$json = new JSON('false', Locale::translate('common.actingAsUserGroup.userIsNotInTargetUserGroup'));
}
return $json->getString();
}
示例10: _validateAccessKey
/**
* Tests if the request contains a valid access token. If this is the case
* the regular login process will be skipped
*
* @param $request PKPRequest
* @return void
*/
function _validateAccessKey($request)
{
$accessKeyCode = $request->getUserVar('key');
$reviewId = $request->getUserVar('reviewId');
if (!($accessKeyCode && $reviewId)) {
return false;
}
// Check if the user is already logged in
$sessionManager = SessionManager::getManager();
$session = $sessionManager->getUserSession();
if ($session->getUserId()) {
return false;
}
import('lib.pkp.classes.security.AccessKeyManager');
$reviewerSubmissionDao = DAORegistry::getDAO('ReviewerSubmissionDAO');
$reviewerSubmission = $reviewerSubmissionDao->getReviewerSubmission($reviewId);
// Validate the access key
$context = $request->getContext();
$accessKeyManager = new AccessKeyManager();
$accessKeyHash = AccessKeyManager::generateKeyHash($accessKeyCode);
$accessKey = $accessKeyManager->validateKey($context->getId(), $reviewerSubmission->getReviewerId(), $accessKeyHash);
if (!$accessKey) {
return false;
}
// Get the reviewer user object
$userDao = DAORegistry::getDAO('UserDAO');
$user = $userDao->getById($accessKey->getUserId());
if (!$user) {
return false;
}
// Register the user object in the session
import('lib.pkp.classes.security.PKPValidation');
$reason = null;
if (PKPValidation::registerUserSession($user, $reason)) {
$this->submission = $reviewerSubmission;
$this->user = $user;
}
}
示例11: isValid
/**
* Check if field value is valid.
* Value is valid if it is empty and optional or validated by user-supplied function.
* @return boolean
*/
function isValid()
{
$user = Request::getUser();
if (!$user) {
return false;
}
$roleDao =& DAORegistry::getDAO('RoleDAO');
$returner = true;
foreach ($this->roles as $roleId) {
$sessionManager =& SessionManager::getManager();
$session =& $sessionManager->getUserSession();
$user =& $session->getUser();
if (!$user) {
return false;
}
$roleDao =& DAORegistry::getDAO('RoleDAO');
$exists = $roleDao->roleExists($user->getId(), $roleId);
if (!$this->all && $exists) {
return true;
}
$returner = $returner && $exists;
}
return $returner;
}
示例12: 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());
//.........这里部分代码省略.........
示例13: recordView
/**
* Record a file view in database.
* @param $submissionFile SubmissionFile
*/
function recordView($submissionFile)
{
// Mark the file as viewed by this user.
$sessionManager = SessionManager::getManager();
$session = $sessionManager->getUserSession();
$user = $session->getUser();
if (is_a($user, 'User')) {
$viewsDao = DAORegistry::getDAO('ViewsDAO');
$viewsDao->recordView(ASSOC_TYPE_SUBMISSION_FILE, $submissionFile->getFileIdAndRevision(), $user->getId());
}
}
示例14: downloadFile
/**
* Download the monograph file
* @param $args array
* @param $request PKPRequest
* @return string Serialized JSON object
*/
function downloadFile($args, &$request)
{
$monograph =& $this->getAuthorizedContextObject(ASSOC_TYPE_MONOGRAPH);
$fileId = (int) $request->getUserVar('fileId');
assert(!empty($fileId));
$sessionManager =& SessionManager::getManager();
$session =& $sessionManager->getUserSession();
$user =& $session->getUser();
$viewsDao =& DAORegistry::getDAO('ViewsDAO');
$viewsDao->recordView(ASSOC_TYPE_MONOGRAPH_FILE, $fileId, $user->getId());
import('classes.file.MonographFileManager');
MonographFileManager::downloadFile($monograph->getId(), $fileId);
}
示例15: insertFooter
/**
* Hook callback function to insert footer note
*/
function insertFooter($hookName, $params)
{
$smarty =& $params[1];
$output =& $params[2];
/** Initial objects **/
$sessionManager =& SessionManager::getManager();
$session =& $sessionManager->getUserSession();
$templateMgr =& TemplateManager::getManager();
$journal =& Request::getJournal();
$journalId = $journal->getId();
$currentLocale = AppLocale::getLocale();
/** variable assignations to template block.tpl **/
$templateMgr->assign('cookiesAlertText', $this->getSetting($journalId, 'cookiesAlertText' . $currentLocale));
$templateMgr->assign('cookiesAlertButton', $this->getSetting($journalId, 'cookiesAlertButton' . $currentLocale));
$templateMgr->assign('cookiesAlertStyleBd', $this->getSetting($journalId, 'cookiesAlertStyleBd'));
$templateMgr->assign('cookiesAlertStyleBgwrapper', $this->getSetting($journalId, 'cookiesAlertStyleBgwrapper'));
$templateMgr->assign('cookiesAlertStyleBgbutton', $this->getSetting($journalId, 'cookiesAlertStyleBgbutton'));
/** register value if button is clicked **/
$url_params = $templateMgr->request->getQueryArray();
if (array_key_exists('acceptCookies', $url_params)) {
//$url_params['acceptCookies'] == 1) {
$session->setSessionVar('cookiesAlertAccepted', $url_params['acceptCookies']);
}
/** if not accepted display the block template **/
if ($session->getSessionVar('cookiesAlertAccepted') != 1) {
$templateMgr->display($this->getTemplatePath() . 'block.tpl');
}
return false;
}