/** * @see PKPUsageStatsLoader::getAssoc() */ protected function getAssoc($assocType, $contextPaths, $page, $op, $args) { list($assocTypeToReturn, $assocId) = parent::getAssoc($assocType, $contextPaths, $page, $op, $args); if (!$assocId && !$assocTypeToReturn) { switch ($assocType) { case ASSOC_TYPE_SUBMISSION_FILE: if (!isset($args[0])) { break; } $submissionId = $args[0]; $submissionDao = DAORegistry::getDAO('MonographDAO'); $monograph = $submissionDao->getById($submissionId); if (!$monograph) { break; } if (!isset($args[2])) { break; } $fileIdAndRevision = $args[2]; list($fileId, $revision) = array_map(create_function('$a', 'return (int) $a;'), preg_split('/-/', $fileIdAndRevision)); $monographFileDao = DAORegistry::getDAO('SubmissionFileDAO'); /* @var $monographFileDao SubmissionFileDAO */ $monographFile = $monographFileDao->getRevision($fileId, $revision); if ($monographFile) { $assocId = $monographFile->getFileId(); } $assocTypeToReturn = $assocType; break; case ASSOC_TYPE_SERIES: if (!isset($args[0])) { break; } $seriesPath = $args[0]; $seriesDao = Application::getSectionDAO(); /* @var $seriesDao SeriesDAO */ if (isset($this->_contextsByPath[current($contextPaths)])) { $context = $this->_contextsByPath[current($contextPaths)]; $series = $seriesDao->getByPath($seriesPath, $context->getId()); if ($series) { $assocId = $series->getId(); } } break; } } return array($assocId, $assocType); }
/** * Foreign key lookup for the published object dimension. * @param $assocType int * @param $assocId int * @return array Values must be foreign keys relative to the * context, pkp section, associated object (type and id), submission * and representation. */ protected function foreignKeyLookup($assocType, $assocId) { $contextId = $sectionId = $submissionId = $representationId = null; $isFile = false; $isRepresentation = false; switch ($assocType) { case ASSOC_TYPE_SUBMISSION_FILE: $submissionFileDao = DAORegistry::getDAO('SubmissionFileDAO'); /* @var $submissionFileDao SubmissionFileDAO */ $submissionFile = $submissionFileDao->getLatestRevision($assocId); if ($submissionFile) { $isFile = true; $submissionId = $submissionFile->getSubmissionId(); if ($submissionFile->getAssocType() == ASSOC_TYPE_REPRESENTATION) { $representationId = $submissionFile->getAssocId(); } else { throw new Exception('Cannot load record: submission file is not associated with a representation object.'); } } else { throw new Exception('Cannot load record: invalid submission file id.'); } // Don't break but go on to retrieve the representation. // Don't break but go on to retrieve the representation. case ASSOC_TYPE_REPRESENTATION: if (!$isFile) { $representationId = $assocId; } $representationDao = Application::getRepresentationDAO(); /* @var $representationDao RepresentationDAO */ $representation = $representationDao->getById($representationId); /* @var $representation Representation */ if ($representation) { if (!$isFile) { $isRepresentation = true; } $contextId = $representation->getContextId(); $submissionId = $representation->getSubmissionId(); } else { throw new Exception('Cannot load record: invalid representation id.'); } // Don't break but go on to retrieve the submission. // Don't break but go on to retrieve the submission. case ASSOC_TYPE_SUBMISSION: if (!$isFile && !$isRepresentation) { $submissionId = $assocId; } $submissionDao = Application::getSubmissionDAO(); /* @var $submissionDao SubmissionDAO */ $submission = $submissionDao->getById($submissionId); if ($submission) { $contextId = $submission->getContextId(); $submissionId = $submission->getId(); $sectionId = $submission->getSectionId(); } else { throw new Exception('Cannot load record: invalid submission id.'); } break; case ASSOC_TYPE_SECTION: $sectionDao = Application::getSectionDAO(); $section = $sectionDao->getById($assocId); /* @var $section PKPSection */ if ($section) { $sectionId = $section->getId(); $contextId = $section->getContextId(); } else { throw new Exception('Cannot load record: invalid section id.'); } break; case Application::getContextAssocType(): $contextDao = Application::getContextDAO(); /* @var $contextDao ContextDAO */ $context = $contextDao->getById($assocId); if (!$context) { throw new Exception('Cannot load record: invalid context id.'); } $contextId = $assocId; break; } return array($contextId, $sectionId, null, null, $submissionId, $representationId); }
/** * Get data object title based on passed * assoc type and id. * @param $assocId int * @param $assocType int * @return string */ protected function getObjectTitle($assocId, $assocType) { switch ($assocType) { case Application::getContextAssocType(): $contextDao = Application::getContextDAO(); /* @var $contextDao ContextDAO */ $context = $contextDao->getById($assocId); if (!$context) { break; } return $context->getLocalizedName(); case ASSOC_TYPE_SUBMISSION: $submissionDao = Application::getSubmissionDAO(); /* @var $submissionDao SubmissionDAO */ $submission = $submissionDao->getById($assocId, null, true); if (!$submission) { break; } return $submission->getLocalizedTitle(); case ASSOC_TYPE_SECTION: $sectionDao = Application::getSectionDAO(); $section = $sectionDao->getById($assocId); if (!$section) { break; } return $section->getLocalizedTitle(); case ASSOC_TYPE_SUBMISSION_FILE: $submissionFileDao = DAORegistry::getDAO('SubmissionFileDAO'); /* @var $submissionFileDao SubmissionFileDAO */ $submissionFile = $submissionFileDao->getLatestRevision($assocId); if (!$submissionFile) { break; } return $submissionFile->getFileLabel(); } return __('manager.statistics.reports.objectNotFound'); }
/** * Initialize form data from the associated author. * @param $args array * @param $request PKPRequest */ function initData($args, $request) { $reviewerId = (int) $request->getUserVar('reviewerId'); $context = $request->getContext(); $reviewRound = $this->getReviewRound(); $submission = $this->getSubmission(); // The reviewer id has been set if (!empty($reviewerId)) { if ($this->_isValidReviewer($context, $submission, $reviewRound, $reviewerId)) { $userDao = DAORegistry::getDAO('UserDAO'); /* @var $userDao UserDAO */ $reviewer = $userDao->getById($reviewerId); $this->setData('userNameString', sprintf('%s (%s)', $reviewer->getFullname(), $reviewer->getUsername())); } } // Get review assignment related data; $reviewAssignmentDao = DAORegistry::getDAO('ReviewAssignmentDAO'); $reviewAssignment = $reviewAssignmentDao->getReviewAssignment($reviewRound->getId(), $reviewerId, $reviewRound->getRound()); // Get the review method (open, blind, or double-blind) if (isset($reviewAssignment) && $reviewAssignment->getReviewMethod() != false) { $reviewMethod = $reviewAssignment->getReviewMethod(); $reviewFormId = $reviewAssignment->getReviewFormId(); } else { // Set default review method. $reviewMethod = $context->getSetting('defaultReviewMode'); if (!$reviewMethod) { $reviewMethod = SUBMISSION_REVIEW_METHOD_BLIND; } // If there is a section/series and it has a default // review form designated, use it. $sectionDao = Application::getSectionDAO(); $section = $sectionDao->getById($submission->getSectionId(), $context->getId()); if ($section) { $reviewFormId = $section->getReviewFormId(); } else { $reviewFormId = null; } } // Get the response/review due dates or else set defaults if (isset($reviewAssignment) && $reviewAssignment->getDueDate() != null) { $reviewDueDate = strftime(Config::getVar('general', 'date_format_short'), strtotime($reviewAssignment->getDueDate())); } else { $numWeeks = (int) $context->getSetting('numWeeksPerReview'); if ($numWeeks <= 0) { $numWeeks = 4; } $reviewDueDate = strftime(Config::getVar('general', 'date_format_short'), strtotime('+' . $numWeeks . ' week')); } if (isset($reviewAssignment) && $reviewAssignment->getResponseDueDate() != null) { $responseDueDate = strftime(Config::getVar('general', 'date_format_short'), strtotime($reviewAssignment->getResponseDueDate())); } else { $numWeeks = (int) $context->getSetting('numWeeksPerResponse'); if ($numWeeks <= 0) { $numWeeks = 3; } $responseDueDate = strftime(Config::getVar('general', 'date_format_short'), strtotime('+' . $numWeeks . ' week')); } // Get the currently selected reviewer selection type to show the correct tab if we're re-displaying the form $selectionType = (int) $request->getUserVar('selectionType'); $stageId = $reviewRound->getStageId(); $this->setData('submissionId', $this->getSubmissionId()); $this->setData('stageId', $stageId); $this->setData('reviewMethod', $reviewMethod); $this->setData('reviewFormId', $reviewFormId); $this->setData('reviewRoundId', $reviewRound->getId()); $this->setData('reviewerId', $reviewerId); $context = $request->getContext(); $templateKey = $this->_getMailTemplateKey($context); $template = new SubmissionMailTemplate($submission, $templateKey); if ($template) { $user = $request->getUser(); $dispatcher = $request->getDispatcher(); AppLocale::requireComponents(LOCALE_COMPONENT_PKP_REVIEWER); // reviewer.step1.requestBoilerplate $template->assignParams(array('contextUrl' => $dispatcher->url($request, ROUTE_PAGE, $context->getPath()), 'editorialContactSignature' => $user->getContactSignature(), 'signatureFullName' => $user->getFullname(), 'passwordResetUrl' => $dispatcher->url($request, ROUTE_PAGE, $context->getPath(), 'login', 'lostPassword'), 'messageToReviewer' => __('reviewer.step1.requestBoilerplate'), 'abstractTermIfEnabled' => $submission->getLocalizedAbstract() == '' ? '' : __('common.abstract'))); $template->replaceParams(); } $this->setData('personalMessage', $template->getBody()); $this->setData('responseDueDate', $responseDueDate); $this->setData('reviewDueDate', $reviewDueDate); $this->setData('selectionType', $selectionType); }