/**
  * @see GridDataProvider::loadData()
  */
 function loadData()
 {
     $submission = $this->getAuthorizedContextObject(ASSOC_TYPE_SUBMISSION);
     $representationDao = Application::getRepresentationDAO();
     $representationFactory = $representationDao->getBySubmissionId($submission->getId());
     return $representationFactory->toAssociativeArray();
 }
 /**
  * Handle a submission element
  * @param $node DOMElement
  * @return array Array of PublicationFormat objects
  */
 function handleElement($node)
 {
     $deployment = $this->getDeployment();
     $context = $deployment->getContext();
     $submission = $deployment->getSubmission();
     assert(is_a($submission, 'Submission'));
     $representation = parent::handleElement($node);
     if ($node->getAttribute('approved') == 'true') {
         $representation->setIsApproved(true);
     }
     if ($node->getAttribute('physical_format') == 'true') {
         $representation->setPhysicalFormat(true);
     }
     $representationDao = Application::getRepresentationDAO();
     $representationDao->insertObject($representation);
     // Handle metadata in subelements.  Do this after the insertObject() call because it
     // creates other DataObjects which depend on a representation id.
     for ($n = $node->firstChild; $n !== null; $n = $n->nextSibling) {
         if (is_a($n, 'DOMElement')) {
             switch ($n->tagName) {
                 case 'Product':
                     $this->_processProductNode($n, $this->getDeployment(), $representation);
                     break;
                 default:
             }
         }
     }
     // Update the object.
     $representationDao->updateObject($representation);
     return $representation;
 }
 /**
  * @see GridHandler::loadData
  */
 function loadData($request, $filter = null)
 {
     $submission = $this->getSubmission();
     $representationDao = Application::getRepresentationDAO();
     $representations = $representationDao->getBySubmissionId($submission->getId());
     return $representations->toAssociativeArray();
 }
 /**
  * Handle a submission element
  * @param $node DOMElement
  * @return array Array of Representation objects
  */
 function handleElement($node)
 {
     $deployment = $this->getDeployment();
     $context = $deployment->getContext();
     $submission = $deployment->getSubmission();
     assert(is_a($submission, 'Submission'));
     // Create the data object
     $representationDao = Application::getRepresentationDAO();
     $representation = $representationDao->newDataObject();
     $representation->setSubmissionId($submission->getId());
     // Handle metadata in subelements.  Look for the 'name' and 'seq' elements.
     // All other elements are handled by subclasses.
     for ($n = $node->firstChild; $n !== null; $n = $n->nextSibling) {
         if (is_a($n, 'DOMElement')) {
             switch ($n->tagName) {
                 case 'name':
                     $representation->setName($n->textContent, $n->getAttribute('locale'));
                     break;
                 case 'seq':
                     $representation->setSeq($n->textContent);
                     break;
             }
         }
     }
     return $representation;
     // database insert is handled by sub class.
 }
 /**
  * Get the submission for a query.
  * @param $query Query
  * @return Submission
  */
 protected function getQuerySubmission($query)
 {
     $submissionDao = Application::getSubmissionDAO();
     switch ($query->getAssocType()) {
         case ASSOC_TYPE_SUBMISSION:
             return $submissionDao->getById($query->getAssocId());
         case ASSOC_TYPE_REPRESENTATION:
             $representationDao = Application::getRepresentationDAO();
             $representation = $representationDao->getById($query->getAssocId());
             return $submissionDao->getById($representation->getSubmissionId());
     }
     assert(false);
 }
 /**
  * Handle a submission element
  * @param $node DOMElement
  * @return array Array of ArticleGalley objects
  */
 function handleElement($node)
 {
     $deployment = $this->getDeployment();
     $context = $deployment->getContext();
     $submission = $deployment->getSubmission();
     assert(is_a($submission, 'Submission'));
     $representation = parent::handleElement($node);
     $representationDao = Application::getRepresentationDAO();
     $representationDao->insertObject($representation);
     // Update the object.
     $representationDao->updateObject($representation);
     return $representation;
 }
 /**
  * @copydoc ManageSubmissionFilesForm::importFile()
  */
 protected function importFile($context, $submissionFile, $fileStage)
 {
     $newSubmissionFile = parent::importFile($context, $submissionFile, $fileStage);
     $representationDao = Application::getRepresentationDAO();
     $representation = $representationDao->getById($this->_representationId, $this->getSubmissionId(), $context->getId());
     $newSubmissionFile->setAssocType(ASSOC_TYPE_REPRESENTATION);
     $newSubmissionFile->setAssocId($representation->getId());
     $newSubmissionFile->setFileStage(SUBMISSION_FILE_PROOF);
     $newSubmissionFile->setViewable(false);
     // Not approved by default
     $submissionFileDao = DAORegistry::getDAO('SubmissionFileDAO');
     $submissionFileDao->updateObject($newSubmissionFile);
     return $newSubmissionFile;
 }
 /**
  * @see DataObjectRequiredPolicy::dataObjectEffect()
  */
 function dataObjectEffect()
 {
     $representationId = (int) $this->getDataObjectId();
     if (!$representationId) {
         return AUTHORIZATION_DENY;
     }
     // Need a valid submission in request.
     $submission = $this->getAuthorizedContextObject(ASSOC_TYPE_SUBMISSION);
     if (!is_a($submission, 'Submission')) {
         return AUTHORIZATION_DENY;
     }
     // Make sure the representation belongs to the submission.
     $representationDao = Application::getRepresentationDAO();
     $representation = $representationDao->getById($representationId, $submission->getId());
     if (!is_a($representation, 'Representation')) {
         return AUTHORIZATION_DENY;
     }
     // Save the representation to the authorization context.
     $this->addAuthorizedContextObject(ASSOC_TYPE_REPRESENTATION, $representation);
     return AUTHORIZATION_PERMIT;
 }
 /**
  * Handle a submission element
  * @param $node DOMElement
  * @return array Array of ArticleGalley objects
  */
 function handleElement($node)
 {
     $deployment = $this->getDeployment();
     $context = $deployment->getContext();
     $submission = $deployment->getSubmission();
     assert(is_a($submission, 'Submission'));
     $submissionFileRefNodes = $node->getElementsByTagName('submission_file_ref');
     assert($submissionFileRefNodes->length == 1);
     $fileNode = $submissionFileRefNodes->item(0);
     $fileId = $fileNode->getAttribute('id');
     $revisionId = $fileNode->getAttribute('revision');
     $dbFileId = $deployment->getFileDBId($fileId, $revisionId);
     assert($dbFileId);
     $representation = parent::handleElement($node);
     for ($n = $node->firstChild; $n !== null; $n = $n->nextSibling) {
         if (is_a($n, 'DOMElement')) {
             switch ($n->tagName) {
                 case 'name':
                     // Labels are not localized in OJS ArticleGalleys, but we use the <name locale="....">...</name> structure.
                     $representation->setLabel($n->textContent);
                     $representation->setLocale($n->getAttribute('locale'));
                     break;
             }
         }
     }
     $representationDao = Application::getRepresentationDAO();
     $representation->setFileId($dbFileId);
     $representationDao->insertObject($representation);
     // Update the submission file.
     $submissionFileDao = DAORegistry::getDAO('SubmissionFileDAO');
     $submissionFile = $submissionFileDao->getRevision($dbFileId, $revisionId);
     $submissionFile->setAssocType(ASSOC_TYPE_REPRESENTATION);
     $submissionFile->setAssocId($representation->getId());
     $submissionFileDao->updateObject($submissionFile);
     // representation proof files
     return $representation;
 }
 /**
  * Add the representations of a submission to its DOM element.
  * @param $doc DOMDocument
  * @param $submissionNode DOMElement
  * @param $submission Submission
  */
 function addRepresentations($doc, $submissionNode, $submission)
 {
     $filterDao = DAORegistry::getDAO('FilterDAO');
     $nativeExportFilters = $filterDao->getObjectsByGroup($this->getRepresentationExportFilterGroupName());
     assert(count($nativeExportFilters) == 1);
     // Assert only a single serialization filter
     $exportFilter = array_shift($nativeExportFilters);
     $exportFilter->setDeployment($this->getDeployment());
     $representationDao = Application::getRepresentationDAO();
     $representations = $representationDao->getBySubmissionId($submission->getId());
     while ($representation = $representations->next()) {
         $representationDoc = $exportFilter->execute($representation);
         $clone = $doc->importNode($representationDoc->documentElement, true);
         $submissionNode->appendChild($clone);
     }
 }
Example #11
0
 /**
  * Get prepared download statistics from the DB
  * @param $pubObjectId integer
  * @return array
  */
 function _getDownloadStats($pubObjectId)
 {
     $cache = CacheManager::getManager()->getCache('downloadStats', $pubObjectId, array($this, '_downloadStatsCacheMiss'));
     if (time() - $cache->getCacheTime() > 60 * 60 * 24) {
         // Cache is older than one day, erase it.
         $cache->flush();
     }
     $statsReports = $cache->get($pubObjectId);
     $currentYear = date("Y");
     $months = range(1, 12);
     $statsByFormat = $statsByMonth = $years = array();
     $totalDownloads = 0;
     foreach ($statsReports as $statsReport) {
         $month = (int) substr($statsReport[STATISTICS_DIMENSION_MONTH], -2);
         $year = (int) substr($statsReport[STATISTICS_DIMENSION_MONTH], 0, 4);
         $metric = $statsReport[STATISTICS_METRIC];
         // Keep track of the years, avoiding duplicates.
         $years[$year] = null;
         $representationId = $statsReport[STATISTICS_DIMENSION_REPRESENTATION_ID];
         // Prepare the stats aggregating by Representation.
         // Create entries for all months, so all representations will have the same entries count.
         if (!array_key_exists($representationId, $statsByFormat)) {
             $representationDao = Application::getRepresentationDAO();
             $representation = $representationDao->getById($representationId);
             if (empty($representation)) {
                 continue;
             }
             $statsByFormat[$representationId] = array('data' => array(), 'label' => $representation->getLocalizedName(), 'color' => $this->_getColor($representationId), 'total' => 0);
         }
         // Make sure we have entries for all years with stats.
         if (!array_key_exists($year, $statsByFormat[$representationId]['data'])) {
             $statsByFormat[$representationId]['data'][$year] = array_fill_keys($months, 0);
         }
         $statsByFormat[$representationId]['data'][$year][$month] = $metric;
         $statsByFormat[$representationId]['total'] += $metric;
         // Prepare the stats aggregating only by Month.
         if (!array_key_exists($year, $statsByMonth)) {
             $statsByMonth[$year] = array_fill_keys($months, 0);
         }
         $statsByMonth[$year][$month] += $metric;
         $totalDownloads += $metric;
     }
     if ($statsByMonth) {
         $datasetId = 'allDownloads';
         // GraphJS works with datasets.
         $statsByMonth = array($datasetId => array('data' => $statsByMonth, 'label' => __('common.allDownloads'), 'color' => $this->_getColor(REALLY_BIG_NUMBER), 'total' => $totalDownloads));
     }
     return array($statsByFormat, $statsByMonth, array_keys($years));
 }
 /**
  * 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);
 }
 /**
  * Fetch the specified authorDashboard tab.
  * @param $args array
  * @param $request Request
  * @return JSONMessage JSON object
  */
 function fetchTab($args, $request)
 {
     $this->setupTemplate($request);
     $templateMgr = TemplateManager::getManager($request);
     $stageId = $request->getUserVar('stageId');
     $templateMgr->assign('stageId', $stageId);
     $submission = $this->getAuthorizedContextObject(ASSOC_TYPE_SUBMISSION);
     $templateMgr->assign('submission', $submission);
     // Import submission file to define file stages.
     import('lib.pkp.classes.submission.SubmissionFile');
     // Workflow-stage specific "upload file" action.
     $currentStage = $submission->getStageId();
     $fileStage = $this->_fileStageFromWorkflowStage($currentStage);
     $templateMgr->assign('lastReviewRoundNumber', $this->_getLastReviewRoundNumbers($submission));
     $reviewRoundDao = DAORegistry::getDAO('ReviewRoundDAO');
     $templateMgr->assign('externalReviewRounds', $reviewRoundDao->getBySubmissionId($submission->getId(), WORKFLOW_STAGE_ID_EXTERNAL_REVIEW));
     // Get the last review round.
     $lastReviewRound = $reviewRoundDao->getLastReviewRoundBySubmissionId($submission->getId(), $currentStage);
     // Create and assign add file link action.
     if ($fileStage && is_a($lastReviewRound, 'ReviewRound')) {
         import('lib.pkp.controllers.api.file.linkAction.AddFileLinkAction');
         $templateMgr->assign('uploadFileAction', new AddFileLinkAction($request, $submission->getId(), $currentStage, array(ROLE_ID_AUTHOR), null, $fileStage, null, null, $lastReviewRound->getId()));
     }
     // If the submission is in or past the editorial stage,
     // assign the editor's copyediting emails to the template
     $submissionEmailLogDao = DAORegistry::getDAO('SubmissionEmailLogDAO');
     $user = $request->getUser();
     // Define the notification options.
     $templateMgr->assign('authorDashboardNotificationRequestOptions', $this->_getNotificationRequestOptions($submission));
     switch ($stageId) {
         case WORKFLOW_STAGE_ID_SUBMISSION:
             return $templateMgr->fetchJson('controllers/tab/authorDashboard/submission.tpl');
         case WORKFLOW_STAGE_ID_INTERNAL_REVIEW:
             return $templateMgr->fetchJson('controllers/tab/authorDashboard/internalReview.tpl');
         case WORKFLOW_STAGE_ID_EXTERNAL_REVIEW:
             return $templateMgr->fetchJson('controllers/tab/authorDashboard/externalReview.tpl');
         case WORKFLOW_STAGE_ID_EDITING:
             $templateMgr->assign('copyeditingEmails', $submissionEmailLogDao->getByEventType($submission->getId(), SUBMISSION_EMAIL_COPYEDIT_NOTIFY_AUTHOR, $user->getId()));
             return $templateMgr->fetchJson('controllers/tab/authorDashboard/editorial.tpl');
         case WORKFLOW_STAGE_ID_PRODUCTION:
             $representationDao = Application::getRepresentationDAO();
             $templateMgr->assign(array('productionEmails' => $submissionEmailLogDao->getByEventType($submission->getId(), SUBMISSION_EMAIL_PROOFREAD_NOTIFY_AUTHOR, $user->getId()), 'representations' => $representationDao->getBySubmissionId($submission->getId())->toArray()));
             return $templateMgr->fetchJson('controllers/tab/authorDashboard/production.tpl');
     }
 }
 /**
  * Handle a submission element
  * @param $node DOMElement
  * @return array Array of ArticleGalley objects
  */
 function handleElement($node)
 {
     $deployment = $this->getDeployment();
     $context = $deployment->getContext();
     $submission = $deployment->getSubmission();
     assert(is_a($submission, 'Submission'));
     $representation = parent::handleElement($node);
     if ($node->getAttribute('available') == 'true') {
         $representation->setIsAvailable(true);
     }
     $galleyType = $node->getAttribute('galley_type');
     $representation->setGalleyType($galleyType);
     for ($n = $node->firstChild; $n !== null; $n = $n->nextSibling) {
         if (is_a($n, 'DOMElement')) {
             switch ($n->tagName) {
                 case 'remote_url':
                     $representation->setRemoteURL($n->textContent);
                     break;
                 case 'name':
                     // Labels are not localized in OJS ArticleGalleys, but we use the <name locale="....">...</name> structure.
                     $representation->setLabel($n->textContent);
                     $representation->setLocale($n->getAttribute('locale'));
                     break;
             }
         }
     }
     $representationDao = Application::getRepresentationDAO();
     $representationDao->insertObject($representation);
     // representation proof files
     return $representation;
 }
 /**
  * Clear pub id
  * @param $args array
  * @param $request PKPRequest
  * @return JSONMessage JSON object
  */
 function clearPubId($args, $request)
 {
     if (!$request->checkCSRF()) {
         return new JSONMessage(false);
     }
     $submission = $this->getSubmission();
     $representationDao = Application::getRepresentationDAO();
     $representation = $representationDao->getById($request->getUserVar('representationId'), $submission->getId());
     import('lib.pkp.controllers.tab.pubIds.form.PKPPublicIdentifiersForm');
     $form = new PKPPublicIdentifiersForm($representation);
     $form->clearPubId($request->getUserVar('pubIdPlugIn'));
     return new JSONMessage(true);
 }
Example #16
0
 /**
  * Check whether the given public ID exists for any publishing
  * object in a press.
  * @param $pressId int
  * @param $pubIdType string One of the NLM pub-id-type values or
  * 'other::something' if not part of the official NLM list
  * (see <http://dtd.nlm.nih.gov/publishing/tag-library/n-4zh0.html>).
  * @param $pubId string
  * @param $assocType int The object type of an object to be excluded from
  *  the search. Identified by one of the ASSOC_TYPE_* constants.
  * @param $assocId int The id of an object to be excluded from the search.
  * @param $forSameType boolean Whether only the same objects should be considered.
  * @return boolean
  */
 function anyPubIdExists($pressId, $pubIdType, $pubId, $assocType = ASSOC_TYPE_ANY, $assocId = 0, $forSameType = false)
 {
     $pubObjectDaos = array(ASSOC_TYPE_SUBMISSION => Application::getSubmissionDAO(), ASSOC_TYPE_REPRESENTATION => Application::getRepresentationDAO(), ASSOC_TYPE_SUBMISSION_FILE => DAORegistry::getDAO('SubmissionFileDAO'));
     if ($forSameType) {
         $dao = $pubObjectDaos[$assocType];
         $excludedId = $assocId;
         if ($dao->pubIdExists($pubIdType, $pubId, $excludedId, $pressId)) {
             return true;
         }
         return false;
     }
     foreach ($pubObjectDaos as $daoAssocType => $dao) {
         if ($assocType == $daoAssocType) {
             $excludedId = $assocId;
         } else {
             $excludedId = 0;
         }
         if ($dao->pubIdExists($pubIdType, $pubId, $excludedId, $pressId)) {
             return true;
         }
     }
     return false;
 }
 /**
  * Fetch the specified workflow tab.
  * @param $args array
  * @param $request Request
  * @return JSONMessage JSON object
  */
 function fetchTab($args, $request)
 {
     $this->setupTemplate($request);
     $templateMgr = TemplateManager::getManager($request);
     $stageId = $this->getAuthorizedContextObject(ASSOC_TYPE_WORKFLOW_STAGE);
     $templateMgr->assign('stageId', $stageId);
     $submission = $this->getAuthorizedContextObject(ASSOC_TYPE_SUBMISSION);
     $templateMgr->assign('submission', $submission);
     switch ($stageId) {
         case WORKFLOW_STAGE_ID_SUBMISSION:
             return $templateMgr->fetchJson('controllers/tab/workflow/submission.tpl');
         case WORKFLOW_STAGE_ID_INTERNAL_REVIEW:
         case WORKFLOW_STAGE_ID_EXTERNAL_REVIEW:
             // Retrieve the authorized submission and stage id.
             $selectedStageId = $this->getAuthorizedContextObject(ASSOC_TYPE_WORKFLOW_STAGE);
             // Get all review rounds for this submission, on the current stage.
             $reviewRoundDao = DAORegistry::getDAO('ReviewRoundDAO');
             $reviewRoundsFactory = $reviewRoundDao->getBySubmissionId($submission->getId(), $selectedStageId);
             $reviewRoundsArray = $reviewRoundsFactory->toAssociativeArray();
             $lastReviewRound = $reviewRoundDao->getLastReviewRoundBySubmissionId($submission->getId(), $selectedStageId);
             // Get the review round number of the last review round to be used
             // as the current review round tab index, if we have review rounds.
             if ($lastReviewRound) {
                 $lastReviewRoundNumber = $lastReviewRound->getRound();
                 $lastReviewRoundId = $lastReviewRound->getId();
                 $templateMgr->assign('lastReviewRoundNumber', $lastReviewRoundNumber);
             }
             // Add the round information to the template.
             $templateMgr->assign('reviewRounds', $reviewRoundsArray);
             $templateMgr->assign('reviewRoundOp', $this->_identifyReviewRoundOp($stageId));
             if ($submission->getStageId() == $selectedStageId && count($reviewRoundsArray) > 0) {
                 $dispatcher = $request->getDispatcher();
                 import('lib.pkp.classes.linkAction.request.AjaxModal');
                 $newRoundAction = new LinkAction('newRound', new AjaxModal($dispatcher->url($request, ROUTE_COMPONENT, null, 'modals.editorDecision.EditorDecisionHandler', 'newReviewRound', null, array('submissionId' => $submission->getId(), 'decision' => SUBMISSION_EDITOR_DECISION_RESUBMIT, 'stageId' => $selectedStageId, 'reviewRoundId' => $lastReviewRoundId)), __('editor.submission.newRound'), 'modal_add_item'), __('editor.submission.newRound'), 'add_item_small');
                 $templateMgr->assign('newRoundAction', $newRoundAction);
             }
             // Render the view.
             return $templateMgr->fetchJson('controllers/tab/workflow/review.tpl');
         case WORKFLOW_STAGE_ID_EDITING:
             return $templateMgr->fetchJson('controllers/tab/workflow/editorial.tpl');
         case WORKFLOW_STAGE_ID_PRODUCTION:
             $templateMgr = TemplateManager::getManager($request);
             $notificationRequestOptions = array(NOTIFICATION_LEVEL_NORMAL => array(NOTIFICATION_TYPE_VISIT_CATALOG => array(ASSOC_TYPE_SUBMISSION, $submission->getId()), NOTIFICATION_TYPE_APPROVE_SUBMISSION => array(ASSOC_TYPE_SUBMISSION, $submission->getId())), NOTIFICATION_LEVEL_TRIVIAL => array());
             $representationDao = Application::getRepresentationDAO();
             $representations = $representationDao->getBySubmissionId($submission->getId());
             $templateMgr->assign('representations', $representations->toAssociativeArray());
             $templateMgr->assign('productionNotificationRequestOptions', $notificationRequestOptions);
             return $templateMgr->fetchJson('controllers/tab/workflow/production.tpl');
     }
 }
 /**
  * Show the form to allow the user to select files from previous stages
  * @param $args array
  * @param $request PKPRequest
  * @return JSONMessage JSON object
  */
 function selectFiles($args, $request)
 {
     $submission = $this->getSubmission();
     $representationDao = Application::getRepresentationDAO();
     $representation = $representationDao->getById($request->getUserVar('representationId'), $submission->getId());
     import('lib.pkp.controllers.grid.files.proof.form.ManageProofFilesForm');
     $manageProofFilesForm = new ManageProofFilesForm($submission->getId(), $representation->getId());
     $manageProofFilesForm->initData($args, $request);
     return new JSONMessage(true, $manageProofFilesForm->fetch($request));
 }
 /**
  * Set a format's "approved" state
  * @param $args array
  * @param $request PKPRequest
  * @return JSONMessage JSON object
  */
 function setApproved($args, $request)
 {
     $submission = $this->getSubmission();
     $representationDao = Application::getRepresentationDAO();
     $representation = $representationDao->getById($request->getUserVar('representationId'), $submission->getId());
     if (!$representation) {
         return new JSONMessage(false, __('manager.setup.errorDeletingItem'));
     }
     $newApprovedState = (int) $request->getUserVar('newApprovedState');
     $representation->setIsApproved($newApprovedState);
     $representationDao->updateObject($representation);
     return DAO::getDataChangedEvent($representation->getId());
 }
 /**
  * Store objects with pub ids.
  * @copydoc Form::execute()
  */
 function execute($request)
 {
     parent::execute($request);
     $pubObject = $this->getPubObject();
     $pubObject->setStoredPubId('publisher-id', $this->getData('publisherId'));
     $pubIdPluginHelper = new PKPPubIdPluginHelper();
     $pubIdPluginHelper->execute($this->getContextId(), $this, $pubObject);
     if (is_a($pubObject, 'Submission')) {
         $submissionDao = Application::getSubmissionDAO();
         $submissionDao->updateObject($pubObject);
     } elseif (is_a($pubObject, 'Representation')) {
         $representationDao = Application::getRepresentationDAO();
         $representationDao->updateObject($pubObject);
     } elseif (is_a($pubObject, 'SubmissionFile')) {
         $submissionFileDao = DAORegistry::getDAO('SubmissionFileDAO');
         $submissionFileDao->updateObject($pubObject);
     }
 }
 /**
  * Get the title for a notification.
  * @param $notification Notification
  * @return string
  */
 function _getTitle($notification)
 {
     switch ($notification->getAssocType()) {
         case ASSOC_TYPE_ANNOUNCEMENT:
             $announcementId = $notification->getAssocId();
             $announcement = DAORegistry::getDAO('AnnouncementDAO')->getById($announcementId);
             if ($announcement) {
                 return $announcement->getLocalizedTitle();
             }
             return null;
         case ASSOC_TYPE_SUBMISSION:
             $submissionId = $notification->getAssocId();
             break;
         case ASSOC_TYPE_SUBMISSION_FILE:
             $fileId = $notification->getAssocId();
             break;
         case ASSOC_TYPE_REVIEW_ASSIGNMENT:
             $reviewAssignmentDao = DAORegistry::getDAO('ReviewAssignmentDAO');
             /* @var $reviewAssignmentDao ReviewAssignmentDAO */
             $reviewAssignment = $reviewAssignmentDao->getById($notification->getAssocId());
             assert(is_a($reviewAssignment, 'ReviewAssignment'));
             $submissionId = $reviewAssignment->getSubmissionId();
             break;
         case ASSOC_TYPE_REVIEW_ROUND:
             $reviewRoundDao = DAORegistry::getDAO('ReviewRoundDAO');
             $reviewRound = $reviewRoundDao->getById($notification->getAssocId());
             assert(is_a($reviewRound, 'ReviewRound'));
             $submissionId = $reviewRound->getSubmissionId();
             break;
         case ASSOC_TYPE_QUERY:
             $queryDao = DAORegistry::getDAO('QueryDAO');
             $query = $queryDao->getById($notification->getAssocId());
             assert(is_a($query, 'Query'));
             switch ($query->getAssocType()) {
                 case ASSOC_TYPE_SUBMISSION:
                     $submissionId = $query->getAssocId();
                     break;
                 case ASSOC_TYPE_REPRESENTATION:
                     $representationDao = Application::getRepresentationDAO();
                     $representation = $representationDao->getById($query->getAssocId());
                     $submissionId = $representation->getSubmissionId();
                     break;
                 default:
                     assert(false);
             }
             break;
         default:
             // Don't know of other ASSOC_TYPEs for TASK notifications
             assert(false);
     }
     if (!isset($submissionId) && isset($fileId)) {
         assert(is_numeric($fileId));
         $submissionFileDao = DAORegistry::getDAO('SubmissionFileDAO');
         /* @var $submissionFileDao SubmissionFileDAO */
         $submissionFile = $submissionFileDao->getLatestRevision($fileId);
         assert(is_a($submissionFile, 'SubmissionFile'));
         $submissionId = $submissionFile->getSubmissionId();
     }
     assert(is_numeric($submissionId));
     $submissionDao = Application::getSubmissionDAO();
     $submission = $submissionDao->getById($submissionId);
     assert(is_a($submission, 'Submission'));
     return $submission->getLocalizedTitle();
 }
 /**
  * Return an array of publication object types and
  * the corresponding DAOs.
  * @return array
  */
 function getDAOs()
 {
     return array('Submission' => Application::getSubmissionDAO(), 'Representation' => Application::getRepresentationDAO(), 'SubmissionFile' => DAORegistry::getDAO('SubmissionFileDAO'));
 }
 /**
  * @copydoc DataObject::getDAO()
  */
 function getDAO()
 {
     return Application::getRepresentationDAO();
 }
 /**
  * @copydoc NotificationManagerDelegate::updateNotification()
  */
 public function updateNotification($request, $userIds, $assocType, $assocId)
 {
     $context = $request->getContext();
     $contextId = $context->getId();
     assert($assocType == ASSOC_TYPE_SUBMISSION);
     $submissionId = $assocId;
     $submissionDao = Application::getSubmissionDAO();
     $submission = $submissionDao->getById($submissionId);
     $stageAssignmentDao = DAORegistry::getDAO('StageAssignmentDAO');
     $editorStageAssignments = $stageAssignmentDao->getEditorsAssignedToStage($submissionId, $submission->getStageId());
     // Get the copyediting and production discussions
     $queryDao = DAORegistry::getDAO('QueryDAO');
     /* @var $queryDao QueryDAO */
     $editingQueries = $queryDao->getByAssoc(ASSOC_TYPE_SUBMISSION, $submissionId, WORKFLOW_STAGE_ID_EDITING);
     $productionQueries = $queryDao->getByAssoc(ASSOC_TYPE_SUBMISSION, $submissionId, WORKFLOW_STAGE_ID_PRODUCTION);
     // Get the copyedited files
     $submissionFileDao = DAORegistry::getDAO('SubmissionFileDAO');
     import('lib.pkp.classes.submission.SubmissionFile');
     $copyeditedFiles = $submissionFileDao->getLatestRevisions($submissionId, SUBMISSION_FILE_COPYEDIT);
     // Get representations
     $representationDao = Application::getRepresentationDAO();
     $representations = $representationDao->getBySubmissionId($submissionId, $contextId);
     $notificationType = $this->getNotificationType();
     foreach ($editorStageAssignments as $editorStageAssignment) {
         switch ($submission->getStageId()) {
             case WORKFLOW_STAGE_ID_PRODUCTION:
                 if ($notificationType == NOTIFICATION_TYPE_ASSIGN_COPYEDITOR || $notificationType == NOTIFICATION_TYPE_AWAITING_COPYEDITS) {
                     // Remove 'assign a copyeditor' and 'awaiting copyedits' notification
                     $this->_removeNotification($submissionId, $editorStageAssignment->getUserId(), $notificationType, $contextId);
                 } else {
                     // If there is a representation
                     if (!$representations->wasEmpty()) {
                         // Remove 'assign a production user' and 'awaiting representations' notification
                         $this->_removeNotification($submissionId, $editorStageAssignment->getUserId(), $notificationType, $contextId);
                     } else {
                         // If a production user is assigned i.e. there is a production discussion
                         if (!$productionQueries->wasEmpty()) {
                             if ($notificationType == NOTIFICATION_TYPE_AWAITING_REPRESENTATIONS) {
                                 // Add 'awaiting representations' notification
                                 $this->_createNotification($request, $submissionId, $editorStageAssignment->getUserId(), $notificationType, $contextId);
                             } elseif ($notificationType == NOTIFICATION_TYPE_ASSIGN_PRODUCTIONUSER) {
                                 // Remove 'assign a production user' notification
                                 $this->_removeNotification($submissionId, $editorStageAssignment->getUserId(), $notificationType, $contextId);
                             }
                         } else {
                             if ($notificationType == NOTIFICATION_TYPE_ASSIGN_PRODUCTIONUSER) {
                                 // Add 'assign a user' notification
                                 $this->_createNotification($request, $submissionId, $editorStageAssignment->getUserId(), $notificationType, $contextId);
                             } elseif ($notificationType == NOTIFICATION_TYPE_AWAITING_REPRESENTATIONS) {
                                 // Remove 'awaiting representations' notification
                                 $this->_removeNotification($submissionId, $editorStageAssignment->getUserId(), $notificationType, $contextId);
                             }
                         }
                     }
                 }
                 break;
             case WORKFLOW_STAGE_ID_EDITING:
                 if (!empty($copyeditedFiles)) {
                     // Remove 'assign a copyeditor' and 'awaiting copyedits' notification
                     $this->_removeNotification($submissionId, $editorStageAssignment->getUserId(), $notificationType, $contextId);
                 } else {
                     // If a copyeditor is assigned i.e. there is a copyediting discussion
                     if (!$editingQueries->wasEmpty()) {
                         if ($notificationType == NOTIFICATION_TYPE_AWAITING_COPYEDITS) {
                             // Add 'awaiting copyedits' notification
                             $this->_createNotification($request, $submissionId, $editorStageAssignment->getUserId(), $notificationType, $contextId);
                         } elseif ($notificationType == NOTIFICATION_TYPE_ASSIGN_COPYEDITOR) {
                             // Remove 'assign a copyeditor' notification
                             $this->_removeNotification($submissionId, $editorStageAssignment->getUserId(), $notificationType, $contextId);
                         }
                     } else {
                         if ($notificationType == NOTIFICATION_TYPE_ASSIGN_COPYEDITOR) {
                             // Add 'assign a copyeditor' notification
                             $this->_createNotification($request, $submissionId, $editorStageAssignment->getUserId(), $notificationType, $contextId);
                         } elseif ($notificationType == NOTIFICATION_TYPE_AWAITING_COPYEDITS) {
                             // Remove 'awaiting copyedits' notification
                             $this->_removeNotification($submissionId, $editorStageAssignment->getUserId(), $notificationType, $contextId);
                         }
                     }
                 }
                 break;
             default:
                 assert(false);
         }
     }
 }
Example #25
0
 /**
  * Clear pubIds of all issue objects.
  * @param $issue Issue
  */
 function clearIssueObjectsPubIds($issue)
 {
     $issueId = $issue->getId();
     $submissionPubIdEnabled = $this->isObjectTypeEnabled('Submission', $issue->getJournalId());
     $representationPubIdEnabled = $this->isObjectTypeEnabled('Representation', $issue->getJournalId());
     $filePubIdEnabled = $this->isObjectTypeEnabled('SubmissionFile', $issue->getJournalId());
     if (!$submissionPubIdEnabled && !$representationPubIdEnabled && !$filePubIdEnabled) {
         return false;
     }
     $pubIdType = $this->getPubIdType();
     $publishedArticleDao = DAORegistry::getDAO('PublishedArticleDAO');
     $representationDao = Application::getRepresentationDAO();
     $submissionFileDao = DAORegistry::getDAO('SubmissionFileDAO');
     import('lib.pkp.classes.submission.SubmissionFile');
     // SUBMISSION_FILE_... constants
     $publishedArticles = $publishedArticleDao->getPublishedArticles($issueId);
     foreach ($publishedArticles as $publishedArticle) {
         if ($submissionPubIdEnabled) {
             // Does this option have to be enabled here for?
             $publishedArticleDao->deletePubId($publishedArticle->getId(), $pubIdType);
         }
         if ($representationPubIdEnabled || $filePubIdEnabled) {
             // Does this option have to be enabled here for?
             $representations = $representationDao->getBySubmissionId($publishedArticle->getId());
             while ($representation = $representations->next()) {
                 if ($representationPubIdEnabled) {
                     // Does this option have to be enabled here for?
                     $representationDao->deletePubId($representation->getId(), $pubIdType);
                 }
                 if ($filePubIdEnabled) {
                     // Does this option have to be enabled here for?
                     $articleProofFiles = $submissionFileDao->getAllRevisionsByAssocId(ASSOC_TYPE_REPRESENTATION, $representation->getId(), SUBMISSION_FILE_PROOF);
                     foreach ($articleProofFiles as $articleProofFile) {
                         $submissionFileDao->deletePubId($articleProofFile->getFileId(), $pubIdType);
                     }
                 }
             }
             unset($representations);
         }
     }
 }