/** * @copydoc GridRow::initialize() */ function initialize($request, $template = null) { parent::initialize($request, $template); AppLocale::requireComponents(LOCALE_COMPONENT_APP_SUBMISSION, LOCALE_COMPONENT_PKP_SUBMISSION); $requestArgs = array_merge($this->getRequestArgs(), array('submissionId' => $this->getId(), 'rowId' => $this->getId())); $dispatcher = Application::getDispatcher(); import('lib.pkp.classes.linkAction.request.AjaxModal'); $this->addAction(new LinkAction('catalogEntry', new AjaxModal($dispatcher->url($request, ROUTE_COMPONENT, null, 'modals.submissionMetadata.CatalogEntryHandler', 'fetch', null, array_merge($requestArgs, array('stageId' => WORKFLOW_STAGE_ID_PRODUCTION))), __('submission.catalogEntry'), 'modal_more_info'), __('submission.editCatalogEntry'))); import('lib.pkp.classes.linkAction.request.RedirectAction'); $this->addAction(new LinkAction('itemWorkflow', new RedirectAction($dispatcher->url($request, ROUTE_PAGE, null, 'workflow', 'access', null, $requestArgs)), __('submission.submission'))); }
/** * @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); }
/** * 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)); }
/** * @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); } }
/** * 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; } }
/** * 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_AUDITOR_REQUEST: case NOTIFICATION_TYPE_COPYEDIT_ASSIGNMENT: assert($notification->getAssocType() == ASSOC_TYPE_SIGNOFF); $signoffDao = DAORegistry::getDAO('SignoffDAO'); /* @var $signoffDao SignoffDAO */ $signoff = $signoffDao->getById($notification->getAssocId()); assert(is_a($signoff, 'Signoff') && $signoff->getAssocType() == ASSOC_TYPE_SUBMISSION_FILE); $submissionFileDao = DAORegistry::getDAO('SubmissionFileDAO'); /* @var $submissionFileDao SubmissionFileDAO */ $submissionFile = $submissionFileDao->getLatestRevision($signoff->getAssocId()); assert(is_a($submissionFile, 'SubmissionFile')); $submissionDao = Application::getSubmissionDAO(); $submission = $submissionDao->getById($submissionFile->getSubmissionId()); // Get correct page (author dashboard or workflow), based // on user roles (if only author, go to author dashboard). import('lib.pkp.controllers.grid.submissions.SubmissionsListGridCellProvider'); list($page, $operation) = SubmissionsListGridCellProvider::getPageAndOperationByUserRoles($request, $submission); // If workflow, get the correct operation (stage). if ($page == 'workflow') { $stageId = $signoffDao->getStageIdBySymbolic($signoff->getSymbolic()); $operation = WorkflowStageDAO::getPathFromId($stageId); } return $dispatcher->url($request, ROUTE_PAGE, $context->getPath(), $page, $operation, $submissionFile->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)); }
/** * @copydoc PKPNotificationOperationManager::getNotificationUrl() */ function getNotificationUrl($request, $notification) { $dispatcher = Application::getDispatcher(); $context = $request->getContext(); return $dispatcher->url($request, ROUTE_PAGE, $context->getPath(), 'workflow', 'access', $notification->getAssocId()); }
/** * Spawn new processes via web requests up to the * given max. parallelism. * @param $request Request * @param $handler string a fully qualified handler class name * @param $op string the operation to be called on the handler * @param $processType integer one of the PROCESS_TYPE_* constants * @param $noOfProcesses integer the number of processes to be spawned. * The actual number of processes can be lower if the max parallelism * is exceeded or if there are already processes of the same type * running. * @param $additionalData optional Data to include with the processes * @return integer the actual number of spawned processes. */ function spawnProcesses($request, $handler, $op, $processType, $noOfProcesses, $data = null) { // Generate the web URL to be called. $dispatcher = Application::getDispatcher(); $processUrl = $dispatcher->url($request, ROUTE_COMPONENT, null, $handler, $op); // Parse the URL into parts to construct the fsockopen call. $urlParts = parse_url($processUrl); assert(isset($urlParts['scheme']) && isset($urlParts['host']) && isset($urlParts['path']) && !isset($urlParts['fragment'])); if ($urlParts['scheme'] == 'https') { $port = 443; $transport = 'ssl://'; } else { $port = 80; $transport = ''; } // Delete process zombies for correct process slot calculation. $this->deleteZombies(); // Calculate the number of max process slots for the given process type. $noOfProcesses = min($noOfProcesses, PROCESS_MAX_PARALLELISM); // Spawn new non-blocking (i.e. parallel) processes via // web requests until all process slots have been filled. $currentParallelism = $this->getNumberOfObjectsByProcessType($processType); $spawnedProcesses = 0; while ($currentParallelism < $noOfProcesses) { // Block a process slot. // NB: insertObject() re-checks the number of currently running // processes on each iteration to make sure that we don't exceed // the limit when there are concurrent requests. $process =& $this->insertObject($processType, $noOfProcesses, $data); if (!is_a($process, 'Process')) { break; } $oneTimeKey = $process->getId(); // Make the request including the generated one-time-key. $stream = fsockopen($transport . $urlParts['host'], $port); if (!$stream) { break; } $processRequest = 'GET ' . $urlParts['path'] . '?authToken=' . urlencode($oneTimeKey) . " HTTP/1.1\r\n" . 'Host: ' . $urlParts['host'] . "\r\n" . "User-Agent: OJS\r\n" . "Connection: Close\r\n\r\n"; stream_set_blocking($stream, 0); fwrite($stream, $processRequest); fclose($stream); unset($stream); $currentParallelism++; $spawnedProcesses++; } return $spawnedProcesses; }