/**
  * @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);
 }
Exemplo n.º 2
0
 /**
  * @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);
 }
 /**
  * @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()));
 }
 /**
  * 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);
 }
 /**
  * @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)));
 }
Exemplo n.º 6
0
 /**
  * @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);
 }
 /**
  * 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>')));
 }
Exemplo n.º 8
0
 /**
  * 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;
 }
 /**
  * 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());
         }
     }
 }
 /**
  * @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);
 }
 /**
  * @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);
 }
 /**
  * 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));
 }
Exemplo n.º 13
0
 /**
  * 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);
     }
 }
 /**
  * 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;
 }
Exemplo n.º 15
0
 /**
  * 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');
     }
 }
 /**
  * @copydoc NotificationManagerDelegate::getNotificationUrl()
  */
 public function getNotificationUrl($request, $notification)
 {
     $router = $request->getRouter();
     $dispatcher = $router->getDispatcher();
     assert($notification->getAssocType() == ASSOC_TYPE_SUBMISSION && is_numeric($notification->getAssocId()));
     switch ($notification->getType()) {
         case NOTIFICATION_TYPE_SUBMISSION_SUBMITTED:
         case NOTIFICATION_TYPE_METADATA_MODIFIED:
         case NOTIFICATION_TYPE_EDITOR_ASSIGNMENT_REQUIRED:
             $contextDao = Application::getContextDAO();
             $context = $contextDao->getById($notification->getContextId());
             return $dispatcher->url($request, ROUTE_PAGE, $context->getPath(), 'workflow', 'submission', $notification->getAssocId());
         default:
             assert(false);
     }
 }
 /**
  * @copydoc NotificationManagerDelegate::getNotificationUrl()
  */
 public function getNotificationUrl($request, $notification)
 {
     $submissionDao = Application::getSubmissionDAO();
     $submission = $submissionDao->getById($notification->getAssocId());
     import('lib.pkp.controllers.grid.submissions.SubmissionsListGridCellProvider');
     list($page, $operation) = SubmissionsListGridCellProvider::getPageAndOperationByUserRoles($request, $submission);
     if ($page == 'workflow') {
         $stageData = $this->_getStageDataByType();
         $operation = $stageData['path'];
     }
     $router = $request->getRouter();
     $dispatcher = $router->getDispatcher();
     $contextDao = Application::getContextDAO();
     $context = $contextDao->getById($submission->getContextId());
     return $dispatcher->url($request, ROUTE_PAGE, $context->getPath(), $page, $operation, $submission->getId());
 }
Exemplo n.º 18
0
 /**
  * Constructor.
  * @param $argv array task arguments
  */
 function PKPUsageStatsLoader($args)
 {
     $plugin = PluginRegistry::getPlugin('generic', 'usagestatsplugin');
     /* @var $plugin UsageStatsPlugin */
     $this->_plugin = $plugin;
     if ($plugin->getSetting(CONTEXT_ID_NONE, 'compressArchives')) {
         $this->setCompressArchives(true);
     }
     $arg = current($args);
     switch ($arg) {
         case 'autoStage':
             if ($plugin->getSetting(0, 'createLogFiles')) {
                 $this->_autoStage = true;
             }
             break;
         case 'externalLogFiles':
             $this->_externalLogFiles = true;
             break;
     }
     // Define the base filesystem path.
     $args[0] = $plugin->getFilesPath();
     parent::FileLoader($args);
     if ($plugin->getEnabled()) {
         // Load the metric type constant.
         PluginRegistry::loadCategory('reports');
         import('classes.statistics.StatisticsHelper');
         $statsHelper = new StatisticsHelper();
         $geoLocationTool = $statsHelper->getGeoLocationTool();
         $this->_geoLocationTool = $geoLocationTool;
         $plugin->import('UsageStatsTemporaryRecordDAO');
         $statsDao = new UsageStatsTemporaryRecordDAO();
         DAORegistry::registerDAO('UsageStatsTemporaryRecordDAO', $statsDao);
         $this->_counterRobotsListFile = $this->_getCounterRobotListFile();
         $contextDao = Application::getContextDAO();
         /* @var $contextDao ContextDAO */
         $contextFactory = $contextDao->getAll();
         /* @var $contextFactory DAOResultFactory */
         $contextsByPath = array();
         while ($context = $contextFactory->next()) {
             /* @var $context Context */
             $contextsByPath[$context->getPath()] = $context;
         }
         $this->_contextsByPath = $contextsByPath;
         $this->checkFolderStructure(true);
     }
 }
 /**
  * @copydoc PKPNotificationOperationManager::getNotificationUrl()
  */
 public function getNotificationUrl($request, $notification)
 {
     $url = parent::getNotificationUrl($request, $notification);
     $dispatcher = Application::getDispatcher();
     $contextDao = Application::getContextDAO();
     $context = $contextDao->getById($notification->getContextId());
     switch ($notification->getType()) {
         case NOTIFICATION_TYPE_ASSIGN_COPYEDITOR:
         case NOTIFICATION_TYPE_AWAITING_COPYEDITS:
         case NOTIFICATION_TYPE_ASSIGN_PRODUCTIONUSER:
         case NOTIFICATION_TYPE_AWAITING_REPRESENTATIONS:
             assert($notification->getAssocType() == ASSOC_TYPE_SUBMISSION && is_numeric($notification->getAssocId()));
             return $dispatcher->url($request, ROUTE_PAGE, $context->getPath(), 'workflow', 'access', $notification->getAssocId());
         default:
             assert(false);
     }
 }
 /**
  * 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');
     $templateMgr = TemplateManager::getManager($request);
     $notification = $row->getData();
     $contextDao = Application::getContextDAO();
     $context = $contextDao->getById($notification->getContextId());
     $notificationMgr = new NotificationManager();
     $router = $request->getRouter();
     $templateMgr->assign(array('notificationMgr' => $notificationMgr, 'notification' => $notification, 'context' => $context, 'notificationObjectTitle' => $this->_getTitle($notification), 'message' => PKPString::stripUnsafeHtml($notificationMgr->getNotificationMessage($request, $notification))));
     // See if we're working in a multi-context environment
     $user = $request->getUser();
     $contextDao = Application::getContextDAO();
     $contexts = $contextDao->getAvailable($user ? $user->getId() : null)->toArray();
     $templateMgr->assign('isMultiContext', count($contexts) > 1);
     return array(new LinkAction('details', new AjaxAction($router->url($request, null, null, 'markRead', null, array('redirect' => 1, 'selectedElements' => array($notification->getId())))), $templateMgr->fetch('controllers/grid/tasks/task.tpl')));
 }
Exemplo n.º 21
0
 /**
  * @see ScheduledTask::executeActions()
  */
 protected function executeActions()
 {
     $submission = null;
     $context = null;
     $reviewAssignmentDao = DAORegistry::getDAO('ReviewAssignmentDAO');
     $submissionDao = Application::getSubmissionDAO();
     $contextDao = Application::getContextDAO();
     $incompleteAssignments = $reviewAssignmentDao->getIncompleteReviewAssignments();
     foreach ($incompleteAssignments as $reviewAssignment) {
         // Fetch the submission and the context if necessary.
         if ($submission == null || $submission->getId() != $reviewAssignment->getSubmissionId()) {
             $submission = $submissionDao->getById($reviewAssignment->getSubmissionId());
             if ($context == null || $context->getId() != $submission->getContextId()) {
                 $context = $contextDao->getById($submission->getContextId());
                 $inviteReminderDays = $context->getSetting('numDaysBeforeInviteReminder');
                 $submitReminderDays = $context->getSetting('numDaysBeforeSubmitReminder');
             }
         }
         if ($submission->getStatus() != STATUS_QUEUED) {
             continue;
         }
         // $submission, $context, $...ReminderDays, and $reviewAssignment
         // are initialized by this point.
         $shouldRemind = false;
         if ($inviteReminderDays && $reviewAssignment->getDateConfirmed() == null) {
             $checkDate = strtotime($reviewAssignment->getDateNotified());
             if (time() - $checkDate > 60 * 60 * 24 * $inviteReminderDays) {
                 $shouldRemind = true;
             }
         }
         if ($submitReminderDays && $reviewAssignment->getDateDue() != null) {
             $checkDate = strtotime($reviewAssignment->getDateDue());
             if (time() - $checkDate > 60 * 60 * 24 * $submitReminderDays) {
                 $shouldRemind = true;
             }
         }
         if ($reviewAssignment->getDateReminded() !== null) {
             $shouldRemind = false;
         }
         if ($shouldRemind) {
             $this->sendReminder($reviewAssignment, $submission, $context);
         }
     }
 }
 /**
  * Construct a URL for the notification based on its type and associated object
  * @copydoc PKPNotificationOperationManager::getNotificationContents()
  */
 public function getNotificationUrl($request, $notification)
 {
     $url = parent::getNotificationUrl($request, $notification);
     $dispatcher = Application::getDispatcher();
     $contextDao = Application::getContextDAO();
     $context = $contextDao->getById($notification->getContextId());
     switch ($notification->getType()) {
         case NOTIFICATION_TYPE_COPYEDIT_ASSIGNMENT:
         case NOTIFICATION_TYPE_LAYOUT_ASSIGNMENT:
         case NOTIFICATION_TYPE_INDEX_ASSIGNMENT:
             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');
         default:
             $delegateResult = $this->getByDelegate($notification->getType(), $notification->getAssocType(), $notification->getAssocId(), __FUNCTION__, array($request, $notification));
             if ($delegateResult) {
                 $url = $delegateResult;
             }
             return $url;
     }
 }
Exemplo n.º 23
0
 /**
  * Update an existing journal.
  * @param $args array
  * @param $request PKPRequest
  * @return string Serialized JSON object
  */
 function updateContext($args, $request)
 {
     // Identify the context Id.
     $contextId = $request->getUserVar('contextId');
     // Form handling.
     $settingsForm = new JournalSiteSettingsForm($contextId);
     $settingsForm->readInputData();
     if (!$settingsForm->validate()) {
         $json = new JSONMessage(false);
         return $json->getString();
     }
     PluginRegistry::loadCategory('blocks');
     // The context settings form will return a context path in two cases:
     // 1 - if a new context was created;
     // 2 - if a press path of an existing context was edited.
     $newContextPath = $settingsForm->execute($request);
     // Create the notification.
     $notificationMgr = new NotificationManager();
     $user = $request->getUser();
     $notificationMgr->createTrivialNotification($user->getId());
     // Check for the two cases above.
     if ($newContextPath) {
         $context = $request->getContext();
         if (is_null($contextId)) {
             // CASE 1: new press created.
             // Create notification related to payment method configuration.
             $contextDao = Application::getContextDAO();
             $newContext = $contextDao->getByPath($newContextPath);
             $notificationMgr->createNotification($request, null, NOTIFICATION_TYPE_CONFIGURE_PAYMENT_METHOD, $newContext->getId(), ASSOC_TYPE_JOURNAL, $newContext->getId(), NOTIFICATION_LEVEL_NORMAL);
             // redirect and set the parameter to open the press
             // setting wizard modal after redirection.
             return $this->_getRedirectEvent($request, $newContextPath, true);
         } else {
             // CASE 2: check if user is in the context of
             // the press being edited.
             if ($context && $context->getId() == $contextId) {
                 return $this->_getRedirectEvent($request, $newContextPath, false);
             }
         }
     }
     return DAO::getDataChangedEvent($contextId);
 }
 /**
  * @copydoc PKPHandler::authorize()
  */
 function authorize($request, &$args, $roleAssignments, $enforceRestrictedSite = true)
 {
     import('lib.pkp.classes.security.authorization.PKPSiteAccessPolicy');
     $this->addPolicy(new PKPSiteAccessPolicy($request, null, $roleAssignments));
     $returner = parent::authorize($request, $args, $roleAssignments, $enforceRestrictedSite);
     // Make sure user is in a context. Otherwise, redirect.
     $context = $request->getContext();
     $router = $request->getRouter();
     $requestedOp = $router->getRequestedOp($request);
     if ($requestedOp == 'settings') {
         $contextDao = Application::getContextDAO();
         $contextFactory = $contextDao->getAll();
         if ($contextFactory->getCount() == 1) {
             // Don't let users access site settings in a single context installation.
             // In that case, those settings are available under management or are not
             // relevant (like site appearance).
             return false;
         }
     }
     return $returner;
 }
Exemplo n.º 25
0
 /**
  * Display registration form for new users.
  * @param $args array
  * @param $request PKPRequest
  */
 function register($args, $request)
 {
     $this->validate($request);
     $this->setupTemplate($request, true);
     $context = $request->getContext();
     $site = $request->getSite();
     if ($context != null) {
         import('classes.user.form.RegistrationForm');
         $existingUser = $request->getUserVar('existingUser') ? 1 : 0;
         $regForm = new RegistrationForm($site, $existingUser);
         $regForm->initData();
         $regForm->display($request);
     } else {
         $contextDao = Application::getContextDAO();
         $contexts = $contextDao->getAll(true);
         $templateMgr = TemplateManager::getManager($request);
         $templateMgr->assign('source', $request->getUserVar('source'));
         $templateMgr->assign('contexts', $contexts);
         $templateMgr->display('user/registerSite.tpl');
     }
 }
 /**
  * @copydoc SubmissionListGridHandler::getSubmissions()
  */
 function getSubmissions($request, $userId)
 {
     $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();
     // 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();
     }
     $accessibleSubmissions = array();
     // Don't use range info to retrieve the object, because we do
     // some more filtering below, and that would end up breaking
     // the range info. FIXME: to speed up the process, do all
     // the filtering needed in SQL and use range info here.
     $submissionFactory = $submissionDao->getBySubEditorId($accessibleContexts, null, false, false);
     if (!$submissionFactory->wasEmpty()) {
         $stageAssignmentDao = DAORegistry::getDAO('StageAssignmentDAO');
         while ($submission = $submissionFactory->next()) {
             if (!$stageAssignmentDao->editorAssignedToStage($submission->getId())) {
                 $accessibleSubmissions[$submission->getId()] = $submission;
             }
         }
     }
     $rangeInfo = $this->getGridRangeInfo($request, $this->getId());
     import('lib.pkp.classes.core.VirtualArrayIterator');
     return VirtualArrayIterator::factory($accessibleSubmissions, $rangeInfo);
 }
Exemplo n.º 27
0
 /**
  * View submissions tab
  * @param $args array
  * @param $request PKPRequest
  * @return JSONMessage JSON object
  */
 function submissions($args, $request)
 {
     $templateMgr = TemplateManager::getManager($request);
     $this->setupTemplate($request);
     // Get all the contexts in the system, to determine which 'new submission' entry point we display
     $contextDao = Application::getContextDAO();
     /* @var $contextDao ContextDAO */
     $contexts = $contextDao->getAll();
     // Check each context to see if user has access to it.
     $user = $request->getUser();
     $roleDao = DAORegistry::getDAO('RoleDAO');
     $allContextsUserRoles = $roleDao->getByUserIdGroupedByContext($user->getId());
     $userRolesThatCanSubmit = array(ROLE_ID_AUTHOR, ROLE_ID_ASSISTANT, ROLE_ID_MANAGER, ROLE_ID_SUB_EDITOR);
     $accessibleContexts = array();
     while ($context = $contexts->next()) {
         if (array_key_exists($context->getId(), $allContextsUserRoles)) {
             $contextUserRoles = array_keys($allContextsUserRoles[$context->getId()]);
             if (array_intersect($userRolesThatCanSubmit, $contextUserRoles)) {
                 $accessibleContexts[] = $context;
             }
         }
     }
     // Assign contexts to template.
     $contextCount = count($accessibleContexts);
     $templateMgr->assign('contextCount', $contextCount);
     if ($contextCount == 1) {
         $templateMgr->assign('context', $accessibleContexts[0]);
     } elseif ($contextCount > 1) {
         $contexts = array();
         foreach ($accessibleContexts as $context) {
             $url = $request->url($context->getPath(), 'submission');
             $contexts[$url] = $context->getLocalizedName();
         }
         $templateMgr->assign('contexts', $contexts);
     }
     return $templateMgr->fetchJson('dashboard/submissions.tpl');
 }
Exemplo n.º 28
0
 /**
  * Save role elements of an executed user form.
  * @param $form Form The form from which to fetch elements
  * @param $user User The current user
  */
 function saveRoleContent($form, $user)
 {
     $userGroupDao = DAORegistry::getDAO('UserGroupDAO');
     $contextDao = Application::getContextDAO();
     $contexts = $contextDao->getAll(true);
     while ($context = $contexts->next()) {
         foreach (array(array('roleId' => ROLE_ID_REVIEWER, 'formElement' => 'reviewerGroup'), array('roleId' => ROLE_ID_AUTHOR, 'formElement' => 'authorGroup'), array('roleId' => ROLE_ID_READER, 'formElement' => 'readerGroup')) as $groupData) {
             $groupFormData = (array) $form->getData($groupData['formElement']);
             $userGroups = $userGroupDao->getByRoleId($context->getId(), $groupData['roleId']);
             while ($userGroup = $userGroups->next()) {
                 if (!$userGroup->getPermitSelfRegistration()) {
                     continue;
                 }
                 $groupId = $userGroup->getId();
                 $inGroup = $userGroupDao->userInGroup($user->getId(), $groupId);
                 if (!$inGroup && array_key_exists($groupId, $groupFormData)) {
                     $userGroupDao->assignUserToGroup($user->getId(), $groupId, $context->getId());
                 } elseif ($inGroup && !array_key_exists($groupId, $groupFormData)) {
                     $userGroupDao->removeUserFromGroup($user->getId(), $groupId, $context->getId());
                 }
             }
         }
     }
 }
 /**
  * View myQueue tab
  * @param $args array
  * @param $request PKPRequest
  * @return JSONMessage JSON object
  */
 function myQueue($args, $request)
 {
     $templateMgr = TemplateManager::getManager($request);
     $this->setupTemplate($request);
     // Get all the contexts in the system, to determine which 'new submission' entry point we display
     $contextDao = Application::getContextDAO();
     /* @var $contextDao ContextDAO */
     $contexts = $contextDao->getAll();
     // Check each context to see if user has access to it.
     $user = $request->getUser();
     $roleDao = DAORegistry::getDAO('RoleDAO');
     $allContextsUserRoles = $roleDao->getByUserIdGroupedByContext($user->getId());
     $userRolesThatCanSubmit = array(ROLE_ID_AUTHOR, ROLE_ID_ASSISTANT, ROLE_ID_MANAGER, ROLE_ID_SUB_EDITOR);
     $accessibleContexts = array();
     while ($context = $contexts->next()) {
         if (array_key_exists($context->getId(), $allContextsUserRoles)) {
             $contextUserRoles = array_keys($allContextsUserRoles[$context->getId()]);
             if (array_intersect($userRolesThatCanSubmit, $contextUserRoles)) {
                 $accessibleContexts[] = $context;
             }
         }
     }
     return $templateMgr->fetchJson('dashboard/myQueue.tpl');
 }
Exemplo n.º 30
0
 /**
  * Redirect to user home page (or the user group home page if the user has one user group).
  * @param $request PKPRequest the request to be routed
  */
 function redirectHome($request)
 {
     $userGroupDao = DAORegistry::getDAO('UserGroupDAO');
     $user = $request->getUser();
     $userId = $user->getId();
     if ($context = $this->getContext($request, 1)) {
         // The user is in the context, see if they have zero or one roles only
         $userGroups = $userGroupDao->getByUserId($userId, $context->getId());
         if ($userGroups->getCount() <= 1) {
             $userGroup = $userGroups->next();
             if (!$userGroup || $userGroup->getRoleId() == ROLE_ID_READER) {
                 $request->redirect(null, 'index');
             }
         }
         $request->redirect(null, 'dashboard');
     } else {
         // The user is at the site context, check to see if they are
         // only registered in one place w/ one role
         $userGroups = $userGroupDao->getByUserId($userId, CONTEXT_ID_NONE);
         if ($userGroups->getCount() == 1) {
             $contextDao = Application::getContextDAO();
             $userGroup = $userGroups->next();
             $context = $contextDao->getById($userGroup->getContextId());
             if (!isset($context)) {
                 $request->redirect('index', 'index');
             }
             if ($userGroup->getRoleId() == ROLE_ID_READER) {
                 $request->redirect(null, 'index');
             }
         }
         $request->redirect('index', 'index');
     }
 }