本文整理汇总了PHP中Application::getContextDAO方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::getContextDAO方法的具体用法?PHP Application::getContextDAO怎么用?PHP Application::getContextDAO使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Application
的用法示例。
在下文中一共展示了Application::getContextDAO方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadData
/**
* @copydoc GridHandler::loadData()
*/
protected function loadData($request, $filter)
{
$submissionDao = Application::getSubmissionDAO();
/* @var $submissionDao SubmissionDAO */
// Determine whether this is a Sub Editor or Manager.
// Managers can access all submissions, Sub Editors
// only assigned submissions.
$user = $request->getUser();
$userId = $user->getId();
// Get all submissions for all contexts that user is
// enrolled in as manager or series editor.
$roleDao = DAORegistry::getDAO('RoleDAO');
$contextDao = Application::getContextDAO();
$contexts = $contextDao->getAll();
$accessibleContexts = array();
while ($context = $contexts->next()) {
$isManager = $roleDao->userHasRole($context->getId(), $userId, ROLE_ID_MANAGER);
$isSubEditor = $roleDao->userHasRole($context->getId(), $userId, ROLE_ID_SUB_EDITOR);
if (!$isManager && !$isSubEditor) {
continue;
}
$accessibleContexts[] = $context->getId();
}
list($search, $column, $stageId) = $this->getFilterValues($filter);
$title = $author = null;
if ($column == 'title') {
$title = $search;
} else {
$author = $search;
}
$rangeInfo = $this->getGridRangeInfo($request, $this->getId());
return $submissionDao->getBySubEditorId($accessibleContexts, null, false, false, $title, $author, $stageId, $rangeInfo);
}
示例2: fetch
/**
* @see Form::fetch()
* @param $request PKPRequest
* @param $params array
*/
function fetch($request, $params = null)
{
$site = $request->getSite();
$publicFileManager = new PublicFileManager();
$contextDao = Application::getContextDAO();
$contexts = $contextDao->getNames();
$siteStyleFilename = $publicFileManager->getSiteFilesPath() . '/' . $site->getSiteStyleFilename();
$cssSettingName = 'siteStyleSheet';
$imageSettingName = 'pageHeaderTitleImage';
// Get link actions.
$uploadCssLinkAction = $this->_getFileUploadLinkAction($cssSettingName, 'css', $request);
$uploadImageLinkAction = $this->_getFileUploadLinkAction($imageSettingName, 'image', $request);
// Get the files view.
$cssView = $this->renderFileView($cssSettingName, $request);
$imageView = $this->renderFileView($imageSettingName, $request);
$templateMgr = TemplateManager::getManager($request);
$templateMgr->assign('locale', AppLocale::getLocale());
$templateMgr->assign('siteStyleFileExists', file_exists($siteStyleFilename));
$templateMgr->assign('uploadCssLinkAction', $uploadCssLinkAction);
$templateMgr->assign('uploadImageLinkAction', $uploadImageLinkAction);
$templateMgr->assign('cssView', $cssView);
$templateMgr->assign('imageView', $imageView);
$templateMgr->assign('redirectOptions', $contexts);
$templateMgr->assign('pageHeaderTitleImage', $site->getSetting($imageSettingName));
$application = Application::getApplication();
$templateMgr->assign('availableMetricTypes', $application->getMetricTypes(true));
$themePlugins = PluginRegistry::loadCategory('themes');
$themePluginOptions = array();
foreach ($themePlugins as $themePlugin) {
$themePluginOptions[basename($themePlugin->getPluginPath())] = $themePlugin->getDisplayName();
}
$templateMgr->assign('themePluginOptions', $themePluginOptions);
return parent::fetch($request);
}
示例3: getSubmissions
/**
* @copydoc SubmissionListGridHandler::getSubmissions()
*/
function getSubmissions($request)
{
// Get all contexts that user is enrolled in as manager, series editor
// reviewer or assistant
$user = $request->getUser();
$roleDao = DAORegistry::getDAO('RoleDAO');
$contextDao = Application::getContextDAO();
$contexts = $contextDao->getAll()->toArray();
$accessibleRoles = array(ROLE_ID_MANAGER, ROLE_ID_SUB_EDITOR, ROLE_ID_REVIEWER, ROLE_ID_ASSISTANT);
$accessibleContexts = array();
$stageUserId = null;
$reviewUserId = null;
foreach ($accessibleRoles as $role) {
foreach ($contexts as $context) {
if ($roleDao->userHasRole($context->getId(), $user->getId(), $role)) {
$accessibleContexts[] = $context->getId();
if ($role == ROLE_ID_ASSISTANT) {
$stageUserId = $user->getId();
} elseif ($role == ROLE_ID_REVIEWER) {
$reviewUserId = $user->getId();
}
}
}
}
$accessibleContexts = array_unique($accessibleContexts);
if (count($accessibleContexts) == 1) {
$accessibleContexts = array_pop($accessibleContexts);
}
// Fetch all submissions for contexts the user can access. If the user
// is a reviewer or assistant only show submissions that have been
// assigned to the user
$submissionDao = Application::getSubmissionDAO();
return $submissionDao->getByStatus(array(STATUS_DECLINED, STATUS_PUBLISHED), $stageUserId, $reviewUserId, $accessibleContexts, $this->getGridRangeInfo($request, $this->getId()));
}
示例4: getCellActions
/**
* Get cell actions associated with this row/column combination
* @param $row GridRow
* @param $column GridColumn
* @return array an array of LinkAction instances
*/
function getCellActions($request, $row, $column, $position = GRID_ACTION_POSITION_DEFAULT)
{
if ($column->getId() == 'title') {
$submission = $row->getData();
$router = $request->getRouter();
$dispatcher = $router->getDispatcher();
$title = $submission->getLocalizedTitle();
if (empty($title)) {
$title = __('common.untitled');
}
$contextId = $submission->getContextId();
$contextDao = Application::getContextDAO();
$context = $contextDao->getById($contextId);
if ($submission->getSubmissionProgress() > 0) {
$url = $dispatcher->url($request, ROUTE_PAGE, $context->getPath(), 'submission', 'wizard', $submission->getSubmissionProgress(), array('submissionId' => $submission->getId()));
} else {
list($page, $operation) = SubmissionsListGridCellProvider::getPageAndOperationByUserRoles($request, $submission);
$url = $dispatcher->url($request, ROUTE_PAGE, $context->getPath(), $page, $operation, $submission->getId());
}
import('lib.pkp.classes.linkAction.request.RedirectAction');
$action = new LinkAction('itemWorkflow', new RedirectAction($url), $title);
return array($action);
}
return parent::getCellActions($request, $row, $column, $position);
}
示例5: initialize
/**
* @copydoc PKPHandler::initialize()
*/
function initialize($request)
{
parent::initialize($request);
// Load submission-specific translations.
AppLocale::requireComponents(LOCALE_COMPONENT_APP_COMMON, LOCALE_COMPONENT_APP_SUBMISSION, LOCALE_COMPONENT_PKP_SUBMISSION);
// Fetch the authorized roles and determine if the user is a manager.
$authorizedRoles = $this->getAuthorizedContextObject(ASSOC_TYPE_USER_ROLES);
$this->_isManager = in_array(ROLE_ID_MANAGER, $authorizedRoles);
// If there is more than one context in the system, add a context column
$contextDao = Application::getContextDAO();
$contexts = $contextDao->getAll();
$cellProvider = new SubmissionsListGridCellProvider($authorizedRoles);
if ($contexts->getCount() > 1) {
$hasRoleCount = 0;
$userGroupDao = DAORegistry::getDAO('UserGroupDAO');
$user = $request->getUser();
while ($context = $contexts->next()) {
$userGroups = $userGroupDao->getByUserId($user->getId(), $context->getId());
if ($userGroups->getCount() > 0) {
$hasRoleCount++;
}
}
if ($hasRoleCount > 1 || $request->getContext() == null) {
$this->addColumn(new GridColumn('context', 'context.context', null, null, $cellProvider));
}
}
$this->addColumn(new GridColumn('id', null, __('common.id'), 'controllers/grid/gridCell.tpl', $cellProvider, array('alignment' => COLUMN_ALIGNMENT_LEFT, 'width' => 10)));
$this->addColumn(new GridColumn('title', 'submission.title', null, null, $cellProvider, array('html' => true, 'alignment' => COLUMN_ALIGNMENT_LEFT)));
$this->addColumn(new GridColumn('stage', 'workflow.stage', null, null, $cellProvider, array('alignment' => COLUMN_ALIGNMENT_LEFT, 'width' => 15)));
}
示例6: fetch
/**
* @see Form::fetch()
* @param $request PKPRequest
* @param $params array
*/
function fetch($request, $params = null)
{
$site = $request->getSite();
$publicFileManager = new PublicFileManager();
$contextDao = Application::getContextDAO();
$contexts = $contextDao->getNames();
$siteStyleFilename = $publicFileManager->getSiteFilesPath() . '/' . $site->getSiteStyleFilename();
$cssSettingName = 'siteStyleSheet';
$imageSettingName = 'pageHeaderTitleImage';
// Get link actions.
$uploadCssLinkAction = $this->_getFileUploadLinkAction($cssSettingName, 'css', $request);
$uploadImageLinkAction = $this->_getFileUploadLinkAction($imageSettingName, 'image', $request);
// Get the files view.
$cssView = $this->renderFileView($cssSettingName, $request);
$imageView = $this->renderFileView($imageSettingName, $request);
$application = Application::getApplication();
$templateMgr = TemplateManager::getManager($request);
$templateMgr->assign(array('locale' => AppLocale::getLocale(), 'siteStyleFileExists' => file_exists($siteStyleFilename), 'uploadCssLinkAction' => $uploadCssLinkAction, 'uploadImageLinkAction' => $uploadImageLinkAction, 'cssView' => $cssView, 'imageView' => $imageView, 'redirectOptions' => $contexts, 'pageHeaderTitleImage' => $site->getSetting($imageSettingName), 'availableMetricTypes' => $application->getMetricTypes(true)));
$themePlugins = PluginRegistry::getPlugins('themes');
$enabledThemes = array();
$activeThemeOptions = array();
foreach ($themePlugins as $themePlugin) {
$enabledThemes[basename($themePlugin->getPluginPath())] = $themePlugin->getDisplayName();
if ($themePlugin->isActive()) {
$activeThemeOptions = $themePlugin->getOptionsConfig();
$activeThemeOptionsValues = $themePlugin->getOptionValues();
foreach ($activeThemeOptions as $name => $option) {
$activeThemeOptions[$name]['value'] = isset($activeThemeOptionsValues[$name]) ? $activeThemeOptionsValues[$name] : '';
}
}
}
$templateMgr->assign(array('enabledThemes' => $enabledThemes, 'activeThemeOptions' => $activeThemeOptions));
return parent::fetch($request);
}
示例7: getCellActions
/**
* Get cell actions associated with this row/column combination
* @param $row GridRow
* @param $column GridColumn
* @return array an array of LinkAction instances
*/
function getCellActions($request, $row, $column, $position = GRID_ACTION_POSITION_DEFAULT)
{
assert($column->getId() == 'task');
$notification = $row->getData();
$contextDao = Application::getContextDAO();
$context = $contextDao->getById($notification->getContextId());
$notificationMgr = new NotificationManager();
$router = $request->getRouter();
return array(new LinkAction('details', new AjaxAction($router->url($request, null, null, 'markRead', null, array('redirect' => 1, 'selectedElements' => array($notification->getId())))), ($notification->getDateRead() ? '' : '<strong>') . __('common.tasks.titleAndTask', array('acronym' => $context->getLocalizedAcronym(), 'title' => $this->_getTitle($notification), 'task' => $notificationMgr->getNotificationMessage($request, $notification))) . ($notification->getDateRead() ? '' : '</strong>')));
}
示例8: CopyAccessLogFileTool
/**
* Constructor.
* @param $argv array command-line arguments
*/
function CopyAccessLogFileTool($argv = array())
{
parent::CommandLineTool($argv);
if (sizeof($this->argv) !== 1) {
$this->usage();
exit(1);
}
$plugin =& PluginRegistry::getPlugin('generic', 'usagestatsplugin');
/* @var $plugin UsageStatsPlugin */
$this->_usageStatsDir = $plugin->getFilesPath();
$this->_tmpDir = $this->_usageStatsDir . DIRECTORY_SEPARATOR . 'tmp';
AppLocale::requireComponents(LOCALE_COMPONENT_PKP_ADMIN);
// This tool needs egrep and gunzip path configured.
$this->_egrepPath = escapeshellarg(Config::getVar('cli', 'egrep'));
if ($this->_egrepPath == "''") {
printf(__('admin.copyAccessLogFileTool.error.noEgrep') . "\n");
exit(1);
}
$this->_gunzipPath = escapeshellarg(Config::getVar('cli', 'gunzip'));
if ($this->_gunzipPath == "''") {
printf(__('admin.copyAccessLogFileTool.error.noGunzip') . "\n");
exit(1);
}
// Get a list of files currently inside the usage stats dir.
$fileLoaderDirs = array(FILE_LOADER_PATH_STAGING, FILE_LOADER_PATH_PROCESSING, FILE_LOADER_PATH_ARCHIVE, FILE_LOADER_PATH_REJECT);
$usageStatsFiles = array();
foreach ($fileLoaderDirs as $dir) {
$dirFiles = glob($this->_usageStatsDir . DIRECTORY_SEPARATOR . $dir . DIRECTORY_SEPARATOR . '*');
if (is_array($dirFiles) && count($dirFiles) > 0) {
foreach ($dirFiles as $file) {
if (!is_file($file)) {
continue;
}
$fileBasename = pathinfo($file, PATHINFO_BASENAME);
if (pathinfo($file, PATHINFO_EXTENSION) == 'gz') {
// Always save the filename without compression extension.
$fileBasename = substr($fileBasename, 0, -3);
}
$usageStatsFiles[] = $fileBasename;
}
}
}
$this->_usageStatsFiles = $usageStatsFiles;
// Get a list of context paths.
$contextDao =& Application::getContextDAO();
/* @var $contextDao ContextDAO */
$contextFactory = $contextDao->getAll();
$contextPaths = array();
while ($context =& $contextFactory->next()) {
/* @var $context Context */
$contextPaths[] = escapeshellarg($context->getPath());
}
$contextPaths = implode('/|/', $contextPaths);
$this->_contextPaths = $contextPaths;
}
示例9: readInputData
/**
* Assign form data to user-submitted data.
*/
function readInputData()
{
$this->readUserVars(array('name', 'description', 'path', 'enabled'));
if ($this->contextId) {
$contextDao = Application::getContextDAO();
$context = $contextDao->getById($this->contextId);
if ($context) {
$this->setData('oldPath', $context->getPath());
}
}
}
示例10: getNotificationUrl
/**
* @copydoc PKPNotificationOperationManager::getNotificationUrl()
*/
function getNotificationUrl($request, $notification)
{
$dispatcher = Application::getDispatcher();
$contextDao = Application::getContextDAO();
$context = $contextDao->getById($notification->getContextId());
$reviewRound = $this->getReviewRound($notification->getAssocId());
$submissionDao = Application::getSubmissionDAO();
$submission = $submissionDao->getById($reviewRound->getSubmissionId());
import('lib.pkp.controllers.grid.submissions.SubmissionsListGridCellProvider');
return SubmissionsListGridCellProvider::getUrlByUserRoles($request, $submission);
}
示例11: getNotificationUrl
/**
* @copydoc PKPNotificationOperationManager::getNotificationUrl()
*/
public function getNotificationUrl($request, $notification)
{
$router = $request->getRouter();
$dispatcher = $router->getDispatcher();
$contextDao = Application::getContextDAO();
$context = $contextDao->getById($notification->getContextId());
switch ($notification->getType()) {
case NOTIFICATION_TYPE_VISIT_CATALOG:
return $dispatcher->url($request, ROUTE_PAGE, $context->getPath(), 'manageCatalog');
}
return parent::getNotificationUrl($request, $notification);
}
示例12: getNotificationUrl
/**
* Construct a URL for the notification based on its type and associated object
* @copydoc INotificationInfoProvider::getNotificationContents()
*/
public function getNotificationUrl($request, $notification)
{
$dispatcher = Application::getDispatcher();
$contextDao = Application::getContextDAO();
$context = $contextDao->getById($notification->getContextId());
switch ($notification->getType()) {
case NOTIFICATION_TYPE_ALL_REVIEWS_IN:
case NOTIFICATION_TYPE_ALL_REVISIONS_IN:
assert($notification->getAssocType() == ASSOC_TYPE_REVIEW_ROUND && is_numeric($notification->getAssocId()));
$reviewRoundDao = DAORegistry::getDAO('ReviewRoundDAO');
$reviewRound = $reviewRoundDao->getById($notification->getAssocId());
assert(is_a($reviewRound, 'ReviewRound'));
$submissionDao = Application::getSubmissionDAO();
$submission = $submissionDao->getById($reviewRound->getSubmissionId());
import('lib.pkp.controllers.grid.submissions.SubmissionsListGridCellProvider');
list($page, $operation) = SubmissionsListGridCellProvider::getPageAndOperationByUserRoles($request, $submission);
if ($page == 'workflow') {
$stageId = $reviewRound->getStageId();
$operation = WorkflowStageDAO::getPathFromId($stageId);
}
return $dispatcher->url($request, ROUTE_PAGE, $context->getPath(), $page, $operation, $submission->getId());
case NOTIFICATION_TYPE_LAYOUT_ASSIGNMENT:
case NOTIFICATION_TYPE_INDEX_ASSIGNMENT:
case NOTIFICATION_TYPE_APPROVE_SUBMISSION:
assert($notification->getAssocType() == ASSOC_TYPE_SUBMISSION && is_numeric($notification->getAssocId()));
return $dispatcher->url($request, ROUTE_PAGE, $context->getPath(), 'workflow', 'access', $notification->getAssocId());
case NOTIFICATION_TYPE_REVIEWER_COMMENT:
assert($notification->getAssocType() == ASSOC_TYPE_REVIEW_ASSIGNMENT && is_numeric($notification->getAssocId()));
$reviewAssignmentDao = DAORegistry::getDAO('ReviewAssignmentDAO');
/* @var $reviewAssignmentDao ReviewAssignmentDAO */
$reviewAssignment = $reviewAssignmentDao->getById($notification->getAssocId());
$userGroupDao = DAORegistry::getDAO('UserGroupDAO');
$operation = $reviewAssignment->getStageId() == WORKFLOW_STAGE_ID_INTERNAL_REVIEW ? WORKFLOW_STAGE_PATH_INTERNAL_REVIEW : WORKFLOW_STAGE_PATH_EXTERNAL_REVIEW;
return $dispatcher->url($request, ROUTE_PAGE, $context->getPath(), 'workflow', $operation, $reviewAssignment->getSubmissionId());
case NOTIFICATION_TYPE_REVIEW_ASSIGNMENT:
$reviewAssignmentDao = DAORegistry::getDAO('ReviewAssignmentDAO');
/* @var $reviewAssignmentDao ReviewAssignmentDAO */
$reviewAssignment = $reviewAssignmentDao->getById($notification->getAssocId());
return $dispatcher->url($request, ROUTE_PAGE, $context->getPath(), 'reviewer', 'submission', $reviewAssignment->getSubmissionId());
case NOTIFICATION_TYPE_NEW_ANNOUNCEMENT:
assert($notification->getAssocType() == ASSOC_TYPE_ANNOUNCEMENT);
$announcementDao = DAORegistry::getDAO('AnnouncementDAO');
/* @var $announcementDao AnnouncementDAO */
$announcement = $announcementDao->getById($notification->getAssocId());
/* @var $announcement Announcement */
$context = $contextDao->getById($announcement->getAssocId());
return $dispatcher->url($request, ROUTE_PAGE, $context->getPath(), 'announcement', 'view', array($notification->getAssocId()));
case NOTIFICATION_TYPE_CONFIGURE_PAYMENT_METHOD:
return __('notification.type.configurePaymentMethod');
}
return $this->getByDelegate($notification->getType(), $notification->getAssocType(), $notification->getAssocId(), __FUNCTION__, array($request, $notification));
}
示例13: getNotificationUrl
/**
* Construct a URL for the notification based on its type and associated object
* @param $request PKPRequest
* @param $notification Notification
* @return string
*/
function getNotificationUrl($request, $notification)
{
$router = $request->getRouter();
$dispatcher = $router->getDispatcher();
$contextDao = Application::getContextDAO();
$context = $contextDao->getById($notification->getContextId());
switch ($notification->getType()) {
case NOTIFICATION_TYPE_PUBLISHED_ISSUE:
return $dispatcher->url($request, ROUTE_PAGE, $context->getPath(), 'issue', 'current');
default:
return parent::getNotificationUrl($request, $notification);
}
}
示例14:
/**
* Check whether the filter filters on a context
* and if so: retrieve it.
*
* NB: We do not check filters below the context level as this would
* be unnecessarily complex. We'd have to check whether the given
* publication objects are actually from the same context. This again
* would require us to retrieve all context objects for the filtered
* objects, etc.
*
* @param $filter array
* @return null|Context
*/
function &getContext($filter)
{
// Check whether the report is on context level.
$context = null;
if (isset($filter[STATISTICS_DIMENSION_CONTEXT_ID])) {
$contextFilter = $filter[STATISTICS_DIMENSION_CONTEXT_ID];
if (is_scalar($contextFilter)) {
// Retrieve the context object.
$contextDao = Application::getContextDAO();
/* @var $contextDao ContextDAO */
$context = $contextDao->getById($contextFilter);
}
}
return $context;
}
示例15: register
/**
* Display registration form for new users.
* @param $args array
* @param $request PKPRequest
*/
function register($args, $request)
{
$this->validate($request);
$this->setupTemplate($request);
if ($request->getContext()) {
import('lib.pkp.classes.user.form.RegistrationForm');
$regForm = new RegistrationForm($request->getSite());
$regForm->initData($request->getContext());
$regForm->display($request);
} else {
$templateMgr = TemplateManager::getManager($request);
$contextDao = Application::getContextDAO();
$templateMgr->assign(array('source' => $request->getUserVar('source'), 'contexts' => $contextDao->getAll(true)));
$templateMgr->display('frontend/pages/userRegisterSite.tpl');
}
}