/** * Delete a file or revision * @param $args array * @param $request Request * @return string a serialized JSON object */ function deleteFile($args, $request) { $submissionFile = $this->getAuthorizedContextObject(ASSOC_TYPE_SUBMISSION_FILE); $submission = $this->getAuthorizedContextObject(ASSOC_TYPE_SUBMISSION); $stageId = $request->getUserVar('stageId'); if ($stageId) { // validate the stage id. $stageAssignmentDao = DAORegistry::getDAO('StageAssignmentDAO'); $user = $request->getUser(); $stageAssignments = $stageAssignmentDao->getBySubmissionAndStageId($submission->getId(), $stageId, null, $user->getId()); } assert($submissionFile && $submission); // Should have been validated already $noteDao = DAORegistry::getDAO('NoteDAO'); $noteDao->deleteByAssoc(ASSOC_TYPE_SUBMISSION_FILE, $submissionFile->getFileId()); // Delete all signoffs related with this file. $signoffDao = DAORegistry::getDAO('SignoffDAO'); /* @var $signoffDao SignoffDAO */ $signoffFactory = $signoffDao->getAllByAssocType(ASSOC_TYPE_SUBMISSION_FILE, $submissionFile->getFileId()); $signoffs = $signoffFactory->toArray(); $notificationMgr = new NotificationManager(); foreach ($signoffs as $signoff) { $signoffDao->deleteObject($signoff); // Delete for all users. $notificationMgr->updateNotification($request, array(NOTIFICATION_TYPE_AUDITOR_REQUEST, NOTIFICATION_TYPE_COPYEDIT_ASSIGNMENT), null, ASSOC_TYPE_SIGNOFF, $signoff->getId()); $notificationMgr->updateNotification($request, array(NOTIFICATION_TYPE_SIGNOFF_COPYEDIT, NOTIFICATION_TYPE_SIGNOFF_PROOF), array($signoff->getUserId()), ASSOC_TYPE_SUBMISSION, $submission->getId()); } // Delete the submission file. $submissionFileDao = DAORegistry::getDAO('SubmissionFileDAO'); /* @var $submissionFileDao SubmissionFileDAO */ // check to see if we need to remove review_round_file associations if (!$stageAssignments->wasEmpty()) { $submissionFileDao->deleteReviewRoundAssignment($submission->getId(), $stageId, $submissionFile->getFileId(), $submissionFile->getRevision()); } $success = (bool) $submissionFileDao->deleteRevisionById($submissionFile->getFileId(), $submissionFile->getRevision(), $submissionFile->getFileStage(), $submission->getId()); if ($success) { if ($submissionFile->getFileStage() == SUBMISSION_FILE_REVIEW_REVISION) { $notificationMgr->updateNotification($request, array(NOTIFICATION_TYPE_PENDING_INTERNAL_REVISIONS, NOTIFICATION_TYPE_PENDING_EXTERNAL_REVISIONS), array($submission->getUserId()), ASSOC_TYPE_SUBMISSION, $submission->getId()); $reviewRoundDao = DAORegistry::getDAO('ReviewRoundDAO'); $lastReviewRound = $reviewRoundDao->getLastReviewRoundBySubmissionId($submission->getId(), $stageId); $notificationMgr->updateNotification($request, array(NOTIFICATION_TYPE_ALL_REVISIONS_IN), null, ASSOC_TYPE_REVIEW_ROUND, $lastReviewRound->getId()); } $this->indexSubmissionFiles($submission, $submissionFile); $fileManager = $this->getFileManager($submission->getContextId(), $submission->getId()); $fileManager->deleteFile($submissionFile->getFileId(), $submissionFile->getRevision()); $this->setupTemplate($request); $user = $request->getUser(); if (!$request->getUserVar('suppressNotification')) { NotificationManager::createTrivialNotification($user->getId(), NOTIFICATION_TYPE_SUCCESS, array('contents' => __('notification.removedFile'))); } $this->logDeletionEvent($request, $submission, $submissionFile, $user); return DAO::getDataChangedEvent(); } else { $json = new JSONMessage(false); return $json->getString(); } }
/** * Save 'manage copyedited files' form * @param $args array * @param $request PKPRequest * @return JSONMessage JSON object */ function updateCopyeditFiles($args, $request) { $submission = $this->getSubmission(); import('lib.pkp.controllers.grid.files.copyedit.form.ManageCopyeditFilesForm'); $manageCopyeditFilesForm = new ManageCopyeditFilesForm($submission->getId()); $manageCopyeditFilesForm->readInputData(); if ($manageCopyeditFilesForm->validate()) { $manageCopyeditFilesForm->execute($args, $request, $this->getGridCategoryDataElements($request, $this->getStageId())); $notificationMgr = new NotificationManager(); $notificationMgr->updateNotification($request, array(NOTIFICATION_TYPE_ASSIGN_COPYEDITOR, NOTIFICATION_TYPE_AWAITING_COPYEDITS), null, ASSOC_TYPE_SUBMISSION, $submission->getId()); // Let the calling grid reload itself return DAO::getDataChangedEvent(); } else { return new JSONMessage(false); } }
function execute($request, $userRoles) { $user = $request->getUser(); // Retrieve the signoff we're working with. $signoffDao = DAORegistry::getDAO('SubmissionFileSignoffDAO'); $signoff = $signoffDao->getById($this->getData('signoffId')); assert(is_a($signoff, 'Signoff')); // Insert the note, if existing content and/or file. $temporaryFileId = $this->getData('temporaryFileId'); if ($temporaryFileId || $this->getData('newNote')) { $noteDao = DAORegistry::getDAO('NoteDAO'); $note = $noteDao->newDataObject(); $note->setUserId($user->getId()); $note->setContents($this->getData('newNote')); $note->setAssocType(ASSOC_TYPE_SIGNOFF); $note->setAssocId($signoff->getId()); $noteId = $noteDao->insertObject($note); $note->setId($noteId); // Upload the file, if any, and associate it with the note. if ($temporaryFileId) { // Fetch the temporary file storing the uploaded library file $temporaryFileDao = DAORegistry::getDAO('TemporaryFileDAO'); $temporaryFile =& $temporaryFileDao->getTemporaryFile($temporaryFileId, $user->getId()); // Upload the file. // Bring in the SUBMISSION_FILE_* constants import('lib.pkp.classes.submission.SubmissionFile'); $context = $request->getContext(); import('lib.pkp.classes.file.SubmissionFileManager'); $submissionFileManager = new SubmissionFileManager($context->getId(), $this->_submissionId); // Get the submission file that is associated with the signoff. $submissionFileDao = DAORegistry::getDAO('SubmissionFileDAO'); /** @var $submissionFileDao SubmissionFileDAO */ $signoffFile =& $submissionFileDao->getLatestRevision($signoff->getAssocId()); assert(is_a($signoffFile, 'SubmissionFile')); $noteFileId = $submissionFileManager->temporaryFileToSubmissionFile($temporaryFile, SUBMISSION_FILE_NOTE, $signoff->getUserId(), $signoff->getUserGroupId(), null, $signoffFile->getGenreId(), ASSOC_TYPE_NOTE, $noteId); } if ($user->getId() == $signoff->getUserId() && !$signoff->getDateCompleted()) { // Considered as a signoff response. // Mark the signoff as completed (we have a note with content // or a file or both). $signoff->setDateCompleted(Core::getCurrentDate()); $signoffDao->updateObject($signoff); $notificationMgr = new NotificationManager(); $notificationMgr->updateNotification($request, array(NOTIFICATION_TYPE_AUDITOR_REQUEST), array($signoff->getUserId()), ASSOC_TYPE_SIGNOFF, $signoff->getId()); $notificationMgr->updateNotification($request, array(NOTIFICATION_TYPE_SIGNOFF_COPYEDIT, NOTIFICATION_TYPE_SIGNOFF_PROOF), array($signoff->getUserId()), ASSOC_TYPE_SUBMISSION, $this->_submissionId); // Define the success trivial notification locale key. $successLocaleKey = 'notification.uploadedResponse'; // log the event. import('lib.pkp.classes.log.SubmissionFileLog'); import('lib.pkp.classes.log.SubmissionFileEventLogEntry'); // constants $submissionDao = Application::getSubmissionDAO(); $submission = $submissionDao->getById($this->_submissionId); $submissionFileDao = DAORegistry::getDAO('SubmissionFileDAO'); $submissionFile = $submissionFileDao->getLatestRevision($signoff->getFileId()); if (isset($submissionFile)) { SubmissionFileLog::logEvent($request, $submissionFile, SUBMISSION_LOG_FILE_AUDIT_UPLOAD, 'submission.event.fileAuditUploaded', array('file' => $submissionFile->getOriginalFileName(), 'name' => $user->getFullName(), 'username' => $user->getUsername())); } } else { // Common note addition. if ($user->getId() !== $signoff->getUserId() && array_intersect($userRoles, array(ROLE_ID_MANAGER, ROLE_ID_ASSISTANT, ROLE_ID_SUB_EDITOR))) { // If the current user is a context/series/sub editor or assistant, open the signoff again. if ($signoff->getDateCompleted()) { $signoff->setDateCompleted(null); $signoffDao->updateObject($signoff); $notificationMgr = new NotificationManager(); $notificationMgr->updateNotification($request, array(NOTIFICATION_TYPE_AUDITOR_REQUEST), array($signoff->getUserId()), ASSOC_TYPE_SIGNOFF, $signoff->getId()); $notificationMgr->updateNotification($request, array(NOTIFICATION_TYPE_SIGNOFF_COPYEDIT, NOTIFICATION_TYPE_SIGNOFF_PROOF), array($signoff->getUserId()), ASSOC_TYPE_SUBMISSION, $this->_submissionId); } } $successLocaleKey = 'notification.addedNote'; } NotificationManager::createTrivialNotification($user->getId(), NOTIFICATION_TYPE_SUCCESS, array('contents' => __($successLocaleKey))); return $signoff->getId(); } }
/** * Let the user signoff on the signoff * @param $args array * @param $request Request * @return JSONMessage JSON object */ function signOffsignOff($args, $request) { $rowSignoff = $this->getAuthorizedContextObject(ASSOC_TYPE_SIGNOFF); if (!$rowSignoff) { fatalError('Invalid Signoff given'); } $user = $request->getUser(); $signoffDao = DAORegistry::getDAO('SignoffDAO'); $signoff = $signoffDao->build('SIGNOFF_SIGNOFF', ASSOC_TYPE_SIGNOFF, $rowSignoff->getId(), $user->getId()); $signoff->setDateCompleted(Core::getCurrentDate()); $signoffDao->updateObject($signoff); // Delete for all users. $notificationMgr = new NotificationManager(); $notificationMgr->updateNotification($request, array(NOTIFICATION_TYPE_COPYEDIT_ASSIGNMENT), null, ASSOC_TYPE_SIGNOFF, $signoff->getAssocId()); // log the sign off sign off import('lib.pkp.classes.log.SubmissionFileLog'); import('lib.pkp.classes.log.SubmissionFileEventLogEntry'); // constants $submissionFileDao = DAORegistry::getDAO('SubmissionFileDAO'); $submissionFile = $submissionFileDao->getLatestRevision($rowSignoff->getAssocId()); if (isset($submissionFile)) { SubmissionFileLog::logEvent($request, $submissionFile, SUBMISSION_LOG_FILE_SIGNOFF_SIGNOFF, 'submission.event.signoffSignoff', array('file' => $submissionFile->getOriginalFileName(), 'name' => $user->getFullName(), 'username' => $user->getUsername())); } // Redraw the row. return DAO::getDataChangedEvent($rowSignoff->getId(), $rowSignoff->getAssocId()); }
/** * Delete the participant from the user groups * @param $args * @param $request * @return JSONMessage JSON object */ function deleteParticipant($args, $request) { $submission = $this->getSubmission(); $stageId = $this->getStageId(); $assignmentId = (int) $request->getUserVar('assignmentId'); $stageAssignmentDao = DAORegistry::getDAO('StageAssignmentDAO'); /* @var $stageAssignmentDao StageAssignmentDAO */ $stageAssignment = $stageAssignmentDao->getById($assignmentId); if (!$stageAssignment || $stageAssignment->getSubmissionId() != $submission->getId()) { fatalError('Invalid Assignment'); } // Delete the assignment $stageAssignmentDao->deleteObject($stageAssignment); // FIXME: perhaps we can just insert the notification on page load // instead of having it there all the time? $stages = Application::getApplicationStages(); foreach ($stages as $workingStageId) { // remove user's assignment from this user group from all the stages // (no need to check if user group is assigned, since nothing will be deleted if there isn't) $stageAssignmentDao->deleteByAll($submission->getId(), $workingStageId, $stageAssignment->getUserGroupId(), $stageAssignment->getUserId()); } $notificationMgr = new NotificationManager(); import('classes.workflow.EditorDecisionActionsManager'); $notificationMgr->updateNotification($request, EditorDecisionActionsManager::getStageNotifications(), null, ASSOC_TYPE_SUBMISSION, $submission->getId()); // Log removal. $userDao = DAORegistry::getDAO('UserDAO'); $assignedUser = $userDao->getById($userId); $userGroupDao = DAORegistry::getDAO('UserGroupDAO'); $userGroup = $userGroupDao->getById($stageAssignment->getUserGroupId()); import('lib.pkp.classes.log.SubmissionLog'); SubmissionLog::logEvent($request, $submission, SUBMISSION_LOG_REMOVE_PARTICIPANT, 'submission.event.participantRemoved', array('name' => $assignedUser->getFullName(), 'username' => $assignedUser->getUsername(), 'userGroupName' => $userGroup->getLocalizedName())); // Redraw the category return DAO::getDataChangedEvent($stageAssignment->getUserGroupId()); }
/** * Mark the review as read and trigger a rewrite of the row. * @param $args array * @param $request PKPRequest * @return JSONMessage JSON object */ function reviewRead($args, $request) { // Retrieve review assignment. $reviewAssignment = $this->getAuthorizedContextObject(ASSOC_TYPE_REVIEW_ASSIGNMENT); /* @var $reviewAssignment ReviewAssignment */ // Mark the latest read date of the review by the editor. $user = $request->getUser(); $viewsDao = DAORegistry::getDAO('ViewsDAO'); $viewsDao->recordView(ASSOC_TYPE_REVIEW_RESPONSE, $reviewAssignment->getId(), $user->getId()); // if the review assignment had been unconsidered, update the flag. if ($reviewAssignment->getUnconsidered() == REVIEW_ASSIGNMENT_UNCONSIDERED) { $reviewAssignmentDao = DAORegistry::getDAO('ReviewAssignmentDAO'); $reviewAssignment->setUnconsidered(REVIEW_ASSIGNMENT_UNCONSIDERED_READ); $reviewAssignmentDao->updateObject($reviewAssignment); } if (!$reviewAssignment->getDateCompleted()) { // Editor completes the review. $reviewAssignment->setDateConfirmed(Core::getCurrentDate()); $reviewAssignment->setDateCompleted(Core::getCurrentDate()); } $this->_updateReviewRoundStatus($reviewAssignment); // Remove the reviewer task. $notificationDao = DAORegistry::getDAO('NotificationDAO'); $notificationDao->deleteByAssoc(ASSOC_TYPE_REVIEW_ASSIGNMENT, $reviewAssignment->getId(), $reviewAssignment->getReviewerId(), NOTIFICATION_TYPE_REVIEW_ASSIGNMENT); $notificationMgr = new NotificationManager(); $reviewRound = $this->getReviewRound(); $notificationMgr->updateNotification($request, array(NOTIFICATION_TYPE_ALL_REVIEWS_IN), null, ASSOC_TYPE_REVIEW_ROUND, $reviewRound->getId()); return DAO::getDataChangedEvent($reviewAssignment->getId()); }
/** * Save an editor decision. * @param $args array * @param $request PKPRequest * @param $formName string Name of form to call * @param $redirectOp string A workflow stage operation to * redirect to if successful (if any). * @return string Serialized JSON object */ protected function _saveEditorDecision($args, $request, $formName, $redirectOp = null, $decision = null) { // Retrieve the authorized submission. $submission = $this->getAuthorizedContextObject(ASSOC_TYPE_SUBMISSION); // Retrieve the decision if (is_null($decision)) { $decision = (int) $request->getUserVar('decision'); } $editorDecisionForm = $this->_getEditorDecisionForm($formName, $decision); $editorDecisionForm->readInputData(); if ($editorDecisionForm->validate()) { $editorDecisionForm->execute($args, $request); // Update editor decision and pending revisions notifications. $notificationMgr = new NotificationManager(); $editorDecisionNotificationType = $this->_getNotificationTypeByEditorDecision($decision); $notificationTypes = $this->_getReviewNotificationTypes(); $notificationTypes[] = $editorDecisionNotificationType; $notificationMgr->updateNotification($request, $notificationTypes, array($submission->getUserId()), ASSOC_TYPE_SUBMISSION, $submission->getId()); $reviewRound = $this->getAuthorizedContextObject(ASSOC_TYPE_REVIEW_ROUND); if ($reviewRound) { $notificationMgr->updateNotification($request, array(NOTIFICATION_TYPE_ALL_REVIEWS_IN), null, ASSOC_TYPE_REVIEW_ROUND, $reviewRound->getId()); $notificationMgr->updateNotification($request, array(NOTIFICATION_TYPE_ALL_REVISIONS_IN), null, ASSOC_TYPE_REVIEW_ROUND, $reviewRound->getId()); } if ($redirectOp) { $dispatcher = $this->getDispatcher(); $redirectUrl = $dispatcher->url($request, ROUTE_PAGE, null, 'workflow', $redirectOp, array($submission->getId())); return $request->redirectUrlJson($redirectUrl); } else { // Needed to update review round status notifications. return DAO::getDataChangedEvent(); } } else { $json = new JSONMessage(false); } return $json->getString(); }
/** * Attach any dependent entities to a new file upload. * @param $submissionFile SubmissionFile */ protected function _attachEntities($submissionFile) { switch ($submissionFile->getFileStage()) { case SUBMISSION_FILE_REVIEW_FILE: case SUBMISSION_FILE_REVIEW_ATTACHMENT: case SUBMISSION_FILE_REVIEW_REVISION: // Add the uploaded review file to the review round. $reviewRound = $this->getReviewRound(); $submissionFileDao = DAORegistry::getDAO('SubmissionFileDAO'); $submissionFileDao->assignRevisionToReviewRound($submissionFile->getFileId(), $submissionFile->getRevision(), $reviewRound); if ($submissionFile->getFileStage() == SUBMISSION_FILE_REVIEW_REVISION) { // Get a list of author user IDs $authorUserIds = array(); $stageAssignmentDao = DAORegistry::getDAO('StageAssignmentDAO'); $submitterAssignments = $stageAssignmentDao->getBySubmissionAndRoleId($reviewRound->getSubmissionId(), ROLE_ID_AUTHOR); while ($assignment = $submitterAssignments->next()) { $authorUserIds[] = $assignment->getUserId(); } // Update the notifications $notificationMgr = new NotificationManager(); $notificationMgr->updateNotification(PKPApplication::getRequest(), array(NOTIFICATION_TYPE_PENDING_INTERNAL_REVISIONS, NOTIFICATION_TYPE_PENDING_EXTERNAL_REVISIONS), $authorUserIds, ASSOC_TYPE_SUBMISSION, $reviewRound->getSubmissionId()); $notificationMgr->updateNotification(PKPApplication::getRequest(), array(NOTIFICATION_TYPE_ALL_REVISIONS_IN), null, ASSOC_TYPE_REVIEW_ROUND, $reviewRound->getId()); } break; } }
/** * Save the metadata and store the catalog data for this published * monograph. */ function execute($request) { parent::execute(); $monograph = $this->getMonograph(); $monographDao = DAORegistry::getDAO('MonographDAO'); $publishedMonographDao = DAORegistry::getDAO('PublishedMonographDAO'); $publishedMonograph = $publishedMonographDao->getById($monograph->getId(), null, false); /* @var $publishedMonograph PublishedMonograph */ $isExistingEntry = $publishedMonograph ? true : false; if (!$publishedMonograph) { $publishedMonograph = $publishedMonographDao->newDataObject(); $publishedMonograph->setId($monograph->getId()); } // Populate the published monograph with the cataloging metadata $publishedMonograph->setAudience($this->getData('audience')); $publishedMonograph->setAudienceRangeQualifier($this->getData('audienceRangeQualifier')); $publishedMonograph->setAudienceRangeFrom($this->getData('audienceRangeFrom')); $publishedMonograph->setAudienceRangeTo($this->getData('audienceRangeTo')); $publishedMonograph->setAudienceRangeExact($this->getData('audienceRangeExact')); // If a cover image was uploaded, deal with it. if ($temporaryFileId = $this->getData('temporaryFileId')) { // Fetch the temporary file storing the uploaded library file $temporaryFileDao = DAORegistry::getDAO('TemporaryFileDAO'); $temporaryFile = $temporaryFileDao->getTemporaryFile($temporaryFileId, $this->_userId); $temporaryFilePath = $temporaryFile->getFilePath(); import('classes.file.SimpleMonographFileManager'); $simpleMonographFileManager = new SimpleMonographFileManager($monograph->getPressId(), $publishedMonograph->getId()); $basePath = $simpleMonographFileManager->getBasePath(); // Delete the old file if it exists $oldSetting = $publishedMonograph->getCoverImage(); if ($oldSetting) { $simpleMonographFileManager->deleteFile($basePath . $oldSetting['thumbnailName']); $simpleMonographFileManager->deleteFile($basePath . $oldSetting['catalogName']); $simpleMonographFileManager->deleteFile($basePath . $oldSetting['name']); } // The following variables were fetched in validation assert($this->_sizeArray && $this->_imageExtension); // Load the cover image for surrogate production $cover = null; // Scrutinizer switch ($this->_imageExtension) { case '.jpg': $cover = imagecreatefromjpeg($temporaryFilePath); break; case '.png': $cover = imagecreatefrompng($temporaryFilePath); break; case '.gif': $cover = imagecreatefromgif($temporaryFilePath); break; } assert(isset($cover)); // Copy the new file over (involves creating the appropriate subdirectory too) $filename = 'cover' . $this->_imageExtension; $simpleMonographFileManager->copyFile($temporaryFile->getFilePath(), $basePath . $filename); // Generate surrogate images (thumbnail and catalog image) $press = $request->getPress(); $coverThumbnailsMaxWidth = $press->getSetting('coverThumbnailsMaxWidth'); $coverThumbnailsMaxHeight = $press->getSetting('coverThumbnailsMaxHeight'); $thumbnailImageInfo = $this->_buildSurrogateImage($cover, $basePath, SUBMISSION_IMAGE_TYPE_THUMBNAIL, $coverThumbnailsMaxWidth, $coverThumbnailsMaxHeight); $catalogImageInfo = $this->_buildSurrogateImage($cover, $basePath, SUBMISSION_IMAGE_TYPE_CATALOG); // Clean up imagedestroy($cover); $publishedMonograph->setCoverImage(array('name' => $filename, 'width' => $this->_sizeArray[0], 'height' => $this->_sizeArray[1], 'thumbnailName' => $thumbnailImageInfo['filename'], 'thumbnailWidth' => $thumbnailImageInfo['width'], 'thumbnailHeight' => $thumbnailImageInfo['height'], 'catalogName' => $catalogImageInfo['filename'], 'catalogWidth' => $catalogImageInfo['width'], 'catalogHeight' => $catalogImageInfo['height'], 'uploadName' => $temporaryFile->getOriginalFileName(), 'dateUploaded' => Core::getCurrentDate())); // Clean up the temporary file import('lib.pkp.classes.file.TemporaryFileManager'); $temporaryFileManager = new TemporaryFileManager(); $temporaryFileManager->deleteFile($temporaryFileId, $this->_userId); } if ($this->getData('attachPermissions')) { $monograph->setCopyrightYear($this->getData('copyrightYear')); $monograph->setCopyrightHolder($this->getData('copyrightHolder'), null); // Localized $monograph->setLicenseURL($this->getData('licenseURL')); } else { $monograph->setCopyrightYear(null); $monograph->setCopyrightHolder(null, null); $monograph->setLicenseURL(null); } $monographDao->updateObject($monograph); // Update the modified fields or insert new. if ($isExistingEntry) { $publishedMonographDao->updateObject($publishedMonograph); } else { $publishedMonographDao->insertObject($publishedMonograph); } import('classes.publicationFormat.PublicationFormatTombstoneManager'); $publicationFormatTombstoneMgr = new PublicationFormatTombstoneManager(); $publicationFormatDao = DAORegistry::getDAO('PublicationFormatDAO'); $publicationFormatFactory = $publicationFormatDao->getBySubmissionId($monograph->getId()); $publicationFormats = $publicationFormatFactory->toAssociativeArray(); $notificationMgr = new NotificationManager(); if ($this->getData('confirm')) { // Update the monograph status. $monograph->setStatus(STATUS_PUBLISHED); $monographDao->updateObject($monograph); $publishedMonograph->setDatePublished(Core::getCurrentDate()); $publishedMonographDao->updateObject($publishedMonograph); $notificationMgr->updateNotification($request, array(NOTIFICATION_TYPE_APPROVE_SUBMISSION), null, ASSOC_TYPE_MONOGRAPH, $publishedMonograph->getId()); // Remove publication format tombstones. $publicationFormatTombstoneMgr->deleteTombstonesByPublicationFormats($publicationFormats); // Update the search index for this published monograph. import('classes.search.MonographSearchIndex'); MonographSearchIndex::indexMonographMetadata($monograph); // Log the publication event. import('lib.pkp.classes.log.SubmissionLog'); SubmissionLog::logEvent($request, $monograph, SUBMISSION_LOG_METADATA_PUBLISH, 'submission.event.metadataPublished'); } else { if ($isExistingEntry) { // Update the monograph status. $monograph->setStatus(STATUS_QUEUED); $monographDao->updateObject($monograph); // Unpublish monograph. $publishedMonograph->setDatePublished(null); $publishedMonographDao->updateObject($publishedMonograph); $notificationMgr->updateNotification($request, array(NOTIFICATION_TYPE_APPROVE_SUBMISSION), null, ASSOC_TYPE_MONOGRAPH, $publishedMonograph->getId()); // Create tombstones for each publication format. $publicationFormatTombstoneMgr->insertTombstonesByPublicationFormats($publicationFormats, $request->getContext()); // Log the unpublication event. import('lib.pkp.classes.log.SubmissionLog'); SubmissionLog::logEvent($request, $monograph, SUBMISSION_LOG_METADATA_UNPUBLISH, 'submission.event.metadataUnpublished'); } } }
/** * Send a notification from the notify tab. * @param $args array * @param $request PKPRequest * @return JSONMessage JSON object */ function sendNotification($args, $request) { $this->setupTemplate($request); import('controllers.grid.users.stageParticipant.form.StageParticipantNotifyForm'); // exists in each app. $notifyForm = new StageParticipantNotifyForm($this->getSubmission()->getId(), ASSOC_TYPE_SUBMISSION, $this->getAuthorizedContextObject(ASSOC_TYPE_WORKFLOW_STAGE)); $notifyForm->readInputData($request); if ($notifyForm->validate()) { $noteId = $notifyForm->execute($request); // Return a JSON string indicating success // (will clear the form on return) $this->_logEventAndCreateNotification($request); // Update submission notifications $notificationMgr = new NotificationManager(); $notificationMgr->updateNotification($request, array(NOTIFICATION_TYPE_ASSIGN_COPYEDITOR, NOTIFICATION_TYPE_AWAITING_COPYEDITS, NOTIFICATION_TYPE_ASSIGN_PRODUCTIONUSER, NOTIFICATION_TYPE_AWAITING_REPRESENTATIONS), null, ASSOC_TYPE_SUBMISSION, $this->getSubmission()->getId()); return new JSONMessage(true); } else { // Return a JSON string indicating failure return new JSONMessage(false); } }
/** * Save changes to submission. * @param $args array * @param $request PKPRequest * @return int the submission ID */ function execute($args, $request) { $submissionDao = Application::getSubmissionDAO(); // Set other submission data. if ($this->submission->getSubmissionProgress() <= $this->step) { $this->submission->setDateSubmitted(Core::getCurrentDate()); $this->submission->stampStatusModified(); $this->submission->setSubmissionProgress(0); } parent::execute($this->submission); // Save the submission. $submissionDao->updateObject($this->submission); // Assign the default stage participants. $userGroupDao = DAORegistry::getDAO('UserGroupDAO'); // Assistant roles -- For each assistant role user group assigned to this // stage in setup, iff there is only one user for the group, // automatically assign the user to the stage // But skip authors and reviewers, since these are very submission specific $stageAssignmentDao = DAORegistry::getDAO('StageAssignmentDAO'); $submissionStageGroups = $userGroupDao->getUserGroupsByStage($this->submission->getContextId(), WORKFLOW_STAGE_ID_SUBMISSION, true, true); $managerFound = false; while ($userGroup = $submissionStageGroups->next()) { $users = $userGroupDao->getUsersById($userGroup->getId(), $this->submission->getContextId()); if ($users->getCount() == 1) { $user = $users->next(); $stageAssignmentDao->build($this->submission->getId(), $userGroup->getId(), $user->getId()); if ($userGroup->getRoleId() == ROLE_ID_MANAGER) { $managerFound = true; } } } // Author roles // Assign only the submitter in whatever ROLE_ID_AUTHOR capacity they were assigned previously $user = $request->getUser(); $submitterAssignments = $stageAssignmentDao->getBySubmissionAndStageId($this->submission->getId(), null, null, $user->getId()); while ($assignment = $submitterAssignments->next()) { $userGroup = $userGroupDao->getById($assignment->getUserGroupId()); if ($userGroup->getRoleId() == ROLE_ID_AUTHOR) { $stageAssignmentDao->build($this->submission->getId(), $userGroup->getId(), $assignment->getUserId()); // Only assign them once, since otherwise we'll one assignment for each previous stage. // And as long as they are assigned once, they will get access to their submission. break; } } $notificationManager = new NotificationManager(); // Assign sub editors for that section $submissionSubEditorFound = false; $subEditorsDao = DAORegistry::getDAO('SubEditorsDAO'); $subEditors = $subEditorsDao->getBySectionId($this->submission->getSectionId(), $this->submission->getContextId()); foreach ($subEditors as $subEditor) { $userGroups = $userGroupDao->getByUserId($subEditor->getId(), $this->submission->getContextId()); while ($userGroup = $userGroups->next()) { if ($userGroup->getRoleId() != ROLE_ID_SUB_EDITOR) { continue; } $stageAssignmentDao->build($this->submission->getId(), $userGroup->getId(), $subEditor->getId()); // If we assign a stage assignment in the Submission stage to a sub editor, make note. if ($userGroupDao->userGroupAssignedToStage($userGroup->getId(), WORKFLOW_STAGE_ID_SUBMISSION)) { $submissionSubEditorFound = true; } } } // Update assignment notifications import('classes.workflow.EditorDecisionActionsManager'); $notificationManager->updateNotification($request, EditorDecisionActionsManager::getStageNotifications(), null, ASSOC_TYPE_SUBMISSION, $this->submission->getId()); // Send a notification to associated users if an editor needs assigning if (!$managerFound && !$submissionSubEditorFound) { $roleDao = DAORegistry::getDAO('RoleDAO'); /* @var $roleDao RoleDAO */ // Get the managers. $managers = $roleDao->getUsersByRoleId(ROLE_ID_MANAGER, $this->submission->getContextId()); $managersArray = $managers->toAssociativeArray(); $allUserIds = array_keys($managersArray); foreach ($allUserIds as $userId) { $notificationManager->createNotification($request, $userId, NOTIFICATION_TYPE_SUBMISSION_SUBMITTED, $this->submission->getContextId(), ASSOC_TYPE_SUBMISSION, $this->submission->getId()); // Add TASK notification indicating that a submission is unassigned $notificationManager->createNotification($request, $userId, NOTIFICATION_TYPE_EDITOR_ASSIGNMENT_REQUIRED, $this->submission->getContextId(), ASSOC_TYPE_SUBMISSION, $this->submission->getId(), NOTIFICATION_LEVEL_TASK); } } $notificationManager->updateNotification($request, array(NOTIFICATION_TYPE_APPROVE_SUBMISSION), null, ASSOC_TYPE_SUBMISSION, $this->submission->getId()); return $this->submissionId; }
/** * @see Form::execute() * @param $request Request * @return MonographFile if successful, otherwise null */ function execute($request) { // Retrieve the signoff we're working with. $signoffDao = DAORegistry::getDAO('SubmissionFileSignoffDAO'); $signoff = $signoffDao->getById($this->getData('signoffId')); assert(is_a($signoff, 'Signoff')); // Insert the note, if existing content and/or file. $temporaryFileId = $this->getData('temporaryFileId'); if ($temporaryFileId || $this->getData('newNote')) { $user = $request->getUser(); $noteDao = DAORegistry::getDAO('NoteDAO'); $note = $noteDao->newDataObject(); $note->setUserId($user->getId()); $note->setContents($this->getData('newNote')); $note->setAssocType(ASSOC_TYPE_SIGNOFF); $note->setAssocId($signoff->getId()); $noteId = $noteDao->insertObject($note); $note->setId($noteId); // Upload the file, if any, and associate it with the note. if ($temporaryFileId) { // Fetch the temporary file storing the uploaded library file $temporaryFileDao = DAORegistry::getDAO('TemporaryFileDAO'); $temporaryFile = $temporaryFileDao->getTemporaryFile($temporaryFileId, $user->getId()); // Upload the file. // Bring in the SUBMISSION_FILE_* constants import('classes.monograph.MonographFile'); $press = $request->getPress(); import('lib.pkp.classes.file.SubmissionFileManager'); $monographFileManager = new SubmissionFileManager($press->getId(), $this->getMonographId()); $signoffFileId = $monographFileManager->temporaryFileToSubmissionFile($temporaryFile, SUBMISSION_FILE_NOTE, $signoff->getUserId(), $signoff->getUserGroupId(), $signoff->getAssocId(), null, ASSOC_TYPE_NOTE, $noteId); // FIXME: Currently the code allows for a signoff to be // added many times (if the option is presented in the // form). Need to delete previous files uploaded to this // signoff. Partially due to #6799. // Mark ALL the signoffs for this user as completed with this file upload. if ($signoffFileId) { $signoff->setFileId($signoffFileId); $signoff->setFileRevision(1); } } // Now mark the signoff as completed (we have a note with content // or a file or both). $signoff->setDateCompleted(Core::getCurrentDate()); $signoffDao->updateObject($signoff); $notificationMgr = new NotificationManager(); $notificationMgr->updateNotification($request, array(NOTIFICATION_TYPE_AUDITOR_REQUEST), array($signoff->getUserId()), ASSOC_TYPE_SIGNOFF, $signoff->getId()); $notificationMgr->updateNotification($request, array(NOTIFICATION_TYPE_SIGNOFF_COPYEDIT, NOTIFICATION_TYPE_SIGNOFF_PROOF), array($signoff->getUserId()), ASSOC_TYPE_SUBMISSION, $this->getMonographId()); // log the event. import('lib.pkp.classes.log.SubmissionFileLog'); import('lib.pkp.classes.log.SubmissionFileEventLogEntry'); // constants $submissionFileDao = DAORegistry::getDAO('SubmissionFileDAO'); $monographFile = $submissionFileDao->getLatestRevision($signoff->getFileId()); if (isset($monographFile)) { SubmissionFileLog::logEvent($request, $monographFile, SUBMISSION_LOG_FILE_AUDIT_UPLOAD, 'submission.event.fileAuditUploaded', array('file' => $monographFile->getOriginalFileName(), 'name' => $user->getFullName(), 'username' => $user->getUsername())); } return $signoff->getId(); } }
/** * Save the metadata of the latest revision of * the requested submission file * @param $args array * @param $request Request * @return string a serialized JSON object */ function saveMetadata($args, $request) { $submission = $this->getSubmission(); $metadataForm = $this->_getMetadataForm($request); $metadataForm->readInputData(); if ($metadataForm->validate()) { $metadataForm->execute($args, $request); $submissionFile = $metadataForm->getSubmissionFile(); $notificationMgr = new NotificationManager(); /* @var $notificationMgr NotificationManager */ $submission = $this->getSubmission(); $notificationMgr->updateNotification($request, $this->_getUpdateNotifications(), array($submission->getUserId()), ASSOC_TYPE_SUBMISSION, $submission->getId()); $reviewRound = $this->getReviewRound(); if ($reviewRound) { $notificationMgr->updateNotification($request, array(NOTIFICATION_TYPE_ALL_REVISIONS_IN), null, ASSOC_TYPE_REVIEW_ROUND, $reviewRound->getId()); // Delete any 'revision requested' notifications since all revisions are now in. $context = $request->getContext(); $notificationDao = DAORegistry::getDAO('NotificationDAO'); $notificationDao->deleteByAssoc(ASSOC_TYPE_SUBMISSION, $submission->getId(), $submission->getUserId(), NOTIFICATION_TYPE_EDITOR_DECISION_PENDING_REVISIONS, $context->getId()); } // Log the upload event import('lib.pkp.classes.log.SubmissionLog'); import('classes.log.SubmissionEventLogEntry'); import('lib.pkp.classes.log.SubmissionFileEventLogEntry'); // constants $user = $request->getUser(); SubmissionLog::logEvent($request, $submission, $submissionFile->getRevision() > 1 ? SUBMISSION_LOG_FILE_REVISION_UPLOAD : SUBMISSION_LOG_FILE_UPLOAD, $submissionFile->getRevision() > 1 ? 'submission.event.fileRevised' : 'submission.event.fileUploaded', array('fileStage' => $submissionFile->getFileStage(), 'fileId' => $submissionFile->getFileId(), 'fileRevision' => $submissionFile->getRevision(), 'originalFileName' => $submissionFile->getOriginalFileName(), 'submissionId' => $submissionFile->getSubmissionId(), 'username' => $user->getUsername())); return DAO::getDataChangedEvent(); } else { $json = new JSONMessage(false, $metadataForm->fetch($request)); } return $json->getString(); }
/** * Persist a signoff insertion * @see ListbuilderHandler::insertEntry */ function insertEntry($request, $newRowId) { // Fetch and validate the file ID $fileId = (int) $newRowId['name']; $submission = $this->getSubmission(); $submissionFileDao = DAORegistry::getDAO('SubmissionFileDAO'); $submissionFile = $submissionFileDao->getLatestRevision($fileId, null, $submission->getId()); assert($submissionFile); // FIXME: How to validate user IDs? $userId = (int) $this->getData('userId'); // Fetch and validate user group ID $userGroupId = (int) $this->getData('userGroupId'); $context = $request->getContext(); $userGroupDao = DAORegistry::getDAO('UserGroupDAO'); $userGroup = $userGroupDao->getById($userGroupId, $context->getId()); // Build the signoff. $submissionFileSignoffDao = DAORegistry::getDAO('SubmissionFileSignoffDAO'); $signoff = $submissionFileSignoffDao->build($this->getSymbolic(), $submissionFile->getFileId(), $userId, $userGroup->getId()); /* @var $signoff Signoff */ // Set the date notified $signoff->setDateNotified(Core::getCurrentDate()); // Set the date response due (stored as date underway in signoffs table) $dueDateParts = explode('-', $this->getData('responseDueDate')); $signoff->setDateUnderway(date('Y-m-d H:i:s', mktime(0, 0, 0, $dueDateParts[0], $dueDateParts[1], $dueDateParts[2]))); $submissionFileSignoffDao->updateObject($signoff); $this->_signoffId = $signoff->getId(); $this->_fileId = $signoff->getAssocId(); $notificationMgr = new NotificationManager(); $notificationMgr->updateNotification($request, array(NOTIFICATION_TYPE_AUDITOR_REQUEST), array($signoff->getUserId()), ASSOC_TYPE_SIGNOFF, $signoff->getId()); // log the add auditor event. import('lib.pkp.classes.log.SubmissionFileLog'); import('lib.pkp.classes.log.SubmissionFileEventLogEntry'); // constants $userDao = DAORegistry::getDAO('UserDAO'); $user = $userDao->getById($userId); if (isset($user)) { SubmissionFileLog::logEvent($request, $submissionFile, SUBMISSION_LOG_FILE_AUDITOR_ASSIGN, 'submission.event.fileAuditorAdded', array('file' => $submissionFile->getOriginalFileName(), 'name' => $user->getFullName(), 'username' => $user->getUsername())); } $notificationMgr->updateNotification($request, array(NOTIFICATION_TYPE_SIGNOFF_COPYEDIT, NOTIFICATION_TYPE_SIGNOFF_PROOF), array($signoff->getUserId()), ASSOC_TYPE_SUBMISSION, $submission->getId()); }
/** * Assigns a reviewer to a submission. * @param $request PKPRequest * @param $submission object * @param $reviewerId int * @param $reviewRound ReviewRound * @param $reviewDueDate datetime optional * @param $responseDueDate datetime optional */ function addReviewer($request, $submission, $reviewerId, &$reviewRound, $reviewDueDate = null, $responseDueDate = null, $reviewMethod = null) { $reviewAssignmentDao = DAORegistry::getDAO('ReviewAssignmentDAO'); $userDao = DAORegistry::getDAO('UserDAO'); $reviewer = $userDao->getById($reviewerId); // Check to see if the requested reviewer is not already // assigned to review this submission. $assigned = $reviewAssignmentDao->reviewerExists($reviewRound->getId(), $reviewerId); // Only add the reviewer if he has not already // been assigned to review this submission. $stageId = $reviewRound->getStageId(); $round = $reviewRound->getRound(); if (!$assigned && isset($reviewer) && !HookRegistry::call('EditorAction::addReviewer', array(&$submission, $reviewerId))) { $reviewAssignment = new ReviewAssignment(); $reviewAssignment->setSubmissionId($submission->getId()); $reviewAssignment->setReviewerId($reviewerId); $reviewAssignment->setDateAssigned(Core::getCurrentDate()); $reviewAssignment->setStageId($stageId); $reviewAssignment->setRound($round); $reviewAssignment->setReviewRoundId($reviewRound->getId()); if (isset($reviewMethod)) { $reviewAssignment->setReviewMethod($reviewMethod); } $reviewAssignmentDao->insertObject($reviewAssignment); // Stamp modification date $submission->stampStatusModified(); $submissionDao = Application::getSubmissionDAO(); $submissionDao->updateObject($submission); $this->setDueDates($request, $submission, $reviewAssignment, $reviewDueDate, $responseDueDate); // Add notification $notificationMgr = new NotificationManager(); $notificationMgr->createNotification($request, $reviewerId, NOTIFICATION_TYPE_REVIEW_ASSIGNMENT, $submission->getContextId(), ASSOC_TYPE_REVIEW_ASSIGNMENT, $reviewAssignment->getId(), NOTIFICATION_LEVEL_TASK); // Insert a trivial notification to indicate the reviewer was added successfully. $currentUser = $request->getUser(); $notificationMgr = new NotificationManager(); $notificationMgr->createTrivialNotification($currentUser->getId(), NOTIFICATION_TYPE_SUCCESS, array('contents' => __('notification.addedReviewer'))); // Update the review round status. $reviewRoundDao = DAORegistry::getDAO('ReviewRoundDAO'); /* @var $reviewRoundDao ReviewRoundDAO */ $reviewAssignments = $reviewAssignmentDao->getBySubmissionId($submission->getId(), $reviewRound->getId(), $stageId); $reviewRoundDao->updateStatus($reviewRound, $reviewAssignments); $notificationMgr->updateNotification($request, array(NOTIFICATION_TYPE_ALL_REVIEWS_IN), null, ASSOC_TYPE_REVIEW_ROUND, $reviewRound->getId()); // Add log import('lib.pkp.classes.log.SubmissionLog'); import('lib.pkp.classes.log.PKPSubmissionEventLogEntry'); SubmissionLog::logEvent($request, $submission, SUBMISSION_LOG_REVIEW_ASSIGN, 'log.review.reviewerAssigned', array('reviewerName' => $reviewer->getFullName(), 'submissionId' => $submission->getId(), 'stageId' => $stageId, 'round' => $round)); } }
/** * Save an editor decision. * @param $args array * @param $request PKPRequest * @param $formName string Name of form to call * @param $redirectOp string A workflow stage operation to * redirect to if successful (if any). * @return JSONMessage JSON object */ protected function _saveEditorDecision($args, $request, $formName, $redirectOp = null, $decision = null) { // Retrieve the authorized submission. $submission = $this->getAuthorizedContextObject(ASSOC_TYPE_SUBMISSION); // Retrieve the decision if (is_null($decision)) { $decision = (int) $request->getUserVar('decision'); } $editorDecisionForm = $this->_getEditorDecisionForm($formName, $decision); $editorDecisionForm->readInputData(); if ($editorDecisionForm->validate()) { $editorDecisionForm->execute($args, $request); // Get a list of author user IDs $authorUserIds = array(); $stageAssignmentDao = DAORegistry::getDAO('StageAssignmentDAO'); $submitterAssignments = $stageAssignmentDao->getBySubmissionAndRoleId($submission->getId(), ROLE_ID_AUTHOR); while ($assignment = $submitterAssignments->next()) { $authorUserIds[] = $assignment->getUserId(); } // De-duplicate assignments $authorUserIds = array_unique($authorUserIds); // Update editor decision and pending revisions notifications. $notificationMgr = new NotificationManager(); $editorDecisionNotificationType = $this->_getNotificationTypeByEditorDecision($decision); $notificationTypes = array_merge(array($editorDecisionNotificationType), $this->_getReviewNotificationTypes()); $notificationMgr->updateNotification($request, $notificationTypes, $authorUserIds, ASSOC_TYPE_SUBMISSION, $submission->getId()); // Update review round notifications $reviewRound = $this->getAuthorizedContextObject(ASSOC_TYPE_REVIEW_ROUND); if ($reviewRound) { $notificationMgr->updateNotification($request, array(NOTIFICATION_TYPE_ALL_REVIEWS_IN, NOTIFICATION_TYPE_ALL_REVISIONS_IN), null, ASSOC_TYPE_REVIEW_ROUND, $reviewRound->getId()); } // Update submission notifications $submissionNotificationsToUpdate = array(SUBMISSION_EDITOR_DECISION_ACCEPT => array(NOTIFICATION_TYPE_ASSIGN_COPYEDITOR, NOTIFICATION_TYPE_AWAITING_COPYEDITS), SUBMISSION_EDITOR_DECISION_SEND_TO_PRODUCTION => array(NOTIFICATION_TYPE_ASSIGN_COPYEDITOR, NOTIFICATION_TYPE_AWAITING_COPYEDITS, NOTIFICATION_TYPE_ASSIGN_PRODUCTIONUSER, NOTIFICATION_TYPE_AWAITING_REPRESENTATIONS)); $notificationMgr = new NotificationManager(); if (array_key_exists($decision, $submissionNotificationsToUpdate)) { $notificationMgr->updateNotification($request, $submissionNotificationsToUpdate[$decision], null, ASSOC_TYPE_SUBMISSION, $submission->getId()); } if ($redirectOp) { $dispatcher = $this->getDispatcher(); $redirectUrl = $dispatcher->url($request, ROUTE_PAGE, null, 'workflow', $redirectOp, array($submission->getId())); return $request->redirectUrlJson($redirectUrl); } else { // Needed to update review round status notifications. return DAO::getDataChangedEvent(); } } else { return new JSONMessage(false); } }
/** * Save a query * @param $args array * @param $request PKPRequest * @return JSONMessage JSON object */ function updateQuery($args, $request) { $query = $this->getQuery(); if (!$this->getAccessHelper()->getCanEdit($query->getId())) { return new JSONMessage(false); } import('lib.pkp.controllers.grid.queries.form.QueryForm'); $queryForm = new QueryForm($request, $this->getAssocType(), $this->getAssocId(), $this->getStageId(), $query->getId()); $queryForm->readInputData(); if ($queryForm->validate()) { $queryForm->execute($request); // Update submission notifications $notificationMgr = new NotificationManager(); $notificationMgr->updateNotification($request, array(NOTIFICATION_TYPE_ASSIGN_COPYEDITOR, NOTIFICATION_TYPE_AWAITING_COPYEDITS, NOTIFICATION_TYPE_ASSIGN_PRODUCTIONUSER, NOTIFICATION_TYPE_AWAITING_REPRESENTATIONS), null, ASSOC_TYPE_SUBMISSION, $this->getAssocId()); return DAO::getDataChangedEvent($query->getId()); } return new JSONMessage(true, $queryForm->fetch($request, array_merge($this->getRequestArgs(), array('queryId' => $query->getId())))); }
/** * Internal method to create the necessary notifications, with user validation. * @param PKPRquest $request * @param Submission $submission * @param PKPUser $user * @param string $template */ function _createNotifications($request, $submission, $user, $template) { $stageAssignmentDao = DAORegistry::getDAO('StageAssignmentDAO'); $userGroupDao = DAORegistry::getDAO('UserGroupDAO'); $stageAssignments = $stageAssignmentDao->getBySubmissionAndStageId($submission->getId(), $this->getStageId(), null, $user->getId()); $notificationMgr = new NotificationManager(); switch ($template) { case 'COPYEDIT_REQUEST': while ($stageAssignment = $stageAssignments->next()) { $userGroup = $userGroupDao->getById($stageAssignment->getUserGroupId()); if (in_array($userGroup->getRoleId(), array(ROLE_ID_MANAGER, ROLE_ID_SUB_EDITOR, ROLE_ID_ASSISTANT))) { import('lib.pkp.classes.submission.SubmissionFile'); $submissionFileDao = DAORegistry::getDAO('SubmissionFileDAO'); $submissionFileSignoffDao = DAORegistry::getDAO('SubmissionFileSignoffDAO'); $submissionFiles = $submissionFileDao->getLatestRevisions($submission->getId(), SUBMISSION_FILE_COPYEDIT); foreach ($submissionFiles as $submissionFile) { $signoffFactory = $submissionFileSignoffDao->getAllBySymbolic('SIGNOFF_COPYEDITING', $submissionFile->getFileId()); while ($signoff = $signoffFactory->next()) { $notificationMgr->updateNotification($request, array(NOTIFICATION_TYPE_COPYEDIT_ASSIGNMENT), array($user->getId()), ASSOC_TYPE_SIGNOFF, $signoff->getId()); } } return; } } // User not in valid role for this task/notification. break; case 'LAYOUT_REQUEST': while ($stageAssignment = $stageAssignments->next()) { $userGroup = $userGroupDao->getById($stageAssignment->getUserGroupId()); if (in_array($userGroup->getRoleId(), array(ROLE_ID_MANAGER, ROLE_ID_SUB_EDITOR, ROLE_ID_ASSISTANT))) { $this->_addUploadTaskNotification($request, NOTIFICATION_TYPE_LAYOUT_ASSIGNMENT, $user->getId(), $submission->getId()); return; } } // User not in valid role for this task/notification. break; case 'INDEX_REQUEST': while ($stageAssignment = $stageAssignments->next()) { $userGroup = $userGroupDao->getById($stageAssignment->getUserGroupId()); if (in_array($userGroup->getRoleId(), array(ROLE_ID_MANAGER, ROLE_ID_SUB_EDITOR, ROLE_ID_ASSISTANT))) { $this->_addUploadTaskNotification($request, NOTIFICATION_TYPE_INDEX_ASSIGNMENT, $user->getId(), $submission->getId()); return; } } // User not in valid role for this task/notification. break; } }
/** * Send a message to a user. * @param $userId int the user id to send email to. * @param $submission Submission * @param $request PKPRequest */ function sendMessage($userId, $submission, $request) { $template = $this->getData('template'); $fromUser = $request->getUser(); $email = $this->_getMailTemplate($submission, $template, false); $email->setReplyTo($fromUser->getEmail(), $fromUser->getFullName()); import('lib.pkp.controllers.grid.submissions.SubmissionsListGridCellProvider'); $dispatcher = $request->getDispatcher(); $userDao = DAORegistry::getDAO('UserDAO'); $user = $userDao->getById($userId); if (isset($user)) { $email->addRecipient($user->getEmail(), $user->getFullName()); $email->setBody($this->getData('message')); $submissionUrl = SubmissionsListGridCellProvider::getUrlByUserRoles($request, $submission, $user->getId()); // Parameters for various emails $email->assignParams(array('participantName' => $user->getFullName(), 'participantUsername' => $user->getUsername(), 'submissionUrl' => $submissionUrl, 'editorialContactName' => $user->getFullname(), 'editorUsername' => $user->getUsername())); $email->send($request); // remove the INDEX_ and LAYOUT_ tasks if a user has sent the appropriate _COMPLETE email switch ($template) { case 'COPYEDIT_REQUEST': $this->_addAssignmentTaskNotification($request, NOTIFICATION_TYPE_COPYEDIT_ASSIGNMENT, $user->getId(), $submission->getId()); break; case 'LAYOUT_REQUEST': $this->_addAssignmentTaskNotification($request, NOTIFICATION_TYPE_LAYOUT_ASSIGNMENT, $user->getId(), $submission->getId()); break; case 'INDEX_REQUEST': $this->_addAssignmentTaskNotification($request, NOTIFICATION_TYPE_INDEX_ASSIGNMENT, $user->getId(), $submission->getId()); break; } // Create a query $queryDao = DAORegistry::getDAO('QueryDAO'); $query = $queryDao->newDataObject(); $query->setAssocType(ASSOC_TYPE_SUBMISSION); $query->setAssocId($submission->getId()); $query->setStageId($this->_stageId); $query->setSequence(REALLY_BIG_NUMBER); $queryDao->insertObject($query); $queryDao->resequence(ASSOC_TYPE_SUBMISSION, $submission->getId()); // Add the current user and message recipient as participants. $queryDao->insertParticipant($query->getId(), $user->getId()); if ($user->getId() != $request->getUser()->getId()) { $queryDao->insertParticipant($query->getId(), $request->getUser()->getId()); } // Create a head note $noteDao = DAORegistry::getDAO('NoteDAO'); $headNote = $noteDao->newDataObject(); $headNote->setUserId($request->getUser()->getId()); $headNote->setAssocType(ASSOC_TYPE_QUERY); $headNote->setAssocId($query->getId()); $headNote->setDateCreated(Core::getCurrentDate()); $headNote->setTitle($email->getSubject()); $headNote->setContents($email->getBody()); $noteDao->insertObject($headNote); $notificationMgr = new NotificationManager(); $notificationMgr->updateNotification($request, array(NOTIFICATION_TYPE_ASSIGN_COPYEDITOR, NOTIFICATION_TYPE_AWAITING_COPYEDITS, NOTIFICATION_TYPE_ASSIGN_PRODUCTIONUSER, NOTIFICATION_TYPE_AWAITING_REPRESENTATIONS), null, ASSOC_TYPE_SUBMISSION, $submission->getId()); } }
/** * @see Form::execute() * @param $request PKPRequest */ function execute($request) { $reviewAssignment =& $this->getReviewAssignment(); $notificationMgr = new NotificationManager(); if ($reviewAssignment->getReviewFormId()) { $reviewFormResponseDao = DAORegistry::getDAO('ReviewFormResponseDAO'); $reviewFormResponses = $this->getData('reviewFormResponses'); if (is_array($reviewFormResponses)) { foreach ($reviewFormResponses as $reviewFormElementId => $reviewFormResponseValue) { $reviewFormResponse = $reviewFormResponseDao->getReviewFormResponse($reviewAssignment->getId(), $reviewFormElementId); if (!isset($reviewFormResponse)) { $reviewFormResponse = new ReviewFormResponse(); } $reviewFormElementDao = DAORegistry::getDAO('ReviewFormElementDAO'); $reviewFormElement = $reviewFormElementDao->getById($reviewFormElementId); $elementType = $reviewFormElement->getElementType(); switch ($elementType) { case REVIEW_FORM_ELEMENT_TYPE_SMALL_TEXT_FIELD: case REVIEW_FORM_ELEMENT_TYPE_TEXT_FIELD: case REVIEW_FORM_ELEMENT_TYPE_TEXTAREA: $reviewFormResponse->setResponseType('string'); $reviewFormResponse->setValue($reviewFormResponseValue); break; case REVIEW_FORM_ELEMENT_TYPE_RADIO_BUTTONS: case REVIEW_FORM_ELEMENT_TYPE_DROP_DOWN_BOX: $reviewFormResponse->setResponseType('int'); $reviewFormResponse->setValue($reviewFormResponseValue); break; case REVIEW_FORM_ELEMENT_TYPE_CHECKBOXES: $reviewFormResponse->setResponseType('object'); $reviewFormResponse->setValue($reviewFormResponseValue); break; } if ($reviewFormResponse->getReviewFormElementId() != null && $reviewFormResponse->getReviewId() != null) { $reviewFormResponseDao->updateObject($reviewFormResponse); } else { $reviewFormResponse->setReviewFormElementId($reviewFormElementId); $reviewFormResponse->setReviewId($reviewAssignment->getId()); $reviewFormResponseDao->insertObject($reviewFormResponse); } } } } else { // Create a comment with the review. $submissionCommentDao = DAORegistry::getDAO('SubmissionCommentDAO'); $comment = $submissionCommentDao->newDataObject(); $comment->setCommentType(COMMENT_TYPE_PEER_REVIEW); $comment->setRoleId(ROLE_ID_REVIEWER); $comment->setAssocId($reviewAssignment->getId()); $comment->setSubmissionId($reviewAssignment->getSubmissionId()); $comment->setAuthorId($reviewAssignment->getReviewerId()); $comment->setComments($this->getData('comments')); $comment->setCommentTitle(''); $comment->setViewable(true); $comment->setDatePosted(Core::getCurrentDate()); // Persist the comment. $submissionCommentDao->insertObject($comment); $submissionDao = Application::getSubmissionDAO(); $submission = $submissionDao->getById($reviewAssignment->getSubmissionId()); $stageAssignmentDao = DAORegistry::getDAO('StageAssignmentDAO'); $stageAssignments = $stageAssignmentDao->getBySubmissionAndStageId($submission->getId(), $submission->getStageId()); $userGroupDao = DAORegistry::getDAO('UserGroupDAO'); $router = $request->getRouter(); $context = $router->getContext($request); $receivedList = array(); // Avoid sending twice to the same user. while ($stageAssignment = $stageAssignments->next()) { $userId = $stageAssignment->getUserId(); $userGroup = $userGroupDao->getById($stageAssignment->getUserGroupId(), $submission->getContextId()); // Never send reviewer comment notification to authors. if ($userGroup->getRoleId() == ROLE_ID_AUTHOR || in_array($userId, $receivedList)) { continue; } $notificationMgr->createNotification($request, $userId, NOTIFICATION_TYPE_REVIEWER_COMMENT, $submission->getContextId(), ASSOC_TYPE_REVIEW_ASSIGNMENT, $reviewAssignment->getId()); $receivedList[] = $userId; } } // Set review to next step. $this->updateReviewStepAndSaveSubmission($this->getReviewerSubmission()); // Mark the review assignment as completed. $reviewAssignment->setDateCompleted(Core::getCurrentDate()); $reviewAssignment->stampModified(); // assign the recommendation to the review assignment, if there was one. $reviewAssignment->setRecommendation((int) $this->getData('recommendation')); // Persist the updated review assignment. $reviewAssignmentDao = DAORegistry::getDAO('ReviewAssignmentDAO'); /* @var $reviewAssignmentDao ReviewAssignmentDAO */ $reviewAssignmentDao->updateObject($reviewAssignment); // Update the review round status. $reviewRoundDao = DAORegistry::getDAO('ReviewRoundDAO'); /* @var $reviewRoundDao ReviewRoundDAO */ $reviewRound = $reviewRoundDao->getById($reviewAssignment->getReviewRoundId()); $reviewAssignments = $reviewAssignmentDao->getByReviewRoundId($reviewRound->getId(), true); $reviewRoundDao->updateStatus($reviewRound, $reviewAssignments); // Update "all reviews in" notification. $notificationMgr->updateNotification($request, array(NOTIFICATION_TYPE_ALL_REVIEWS_IN), null, ASSOC_TYPE_REVIEW_ROUND, $reviewRound->getId()); // Remove the task $notificationDao = DAORegistry::getDAO('NotificationDAO'); $notificationDao->deleteByAssoc(ASSOC_TYPE_REVIEW_ASSIGNMENT, $reviewAssignment->getId(), $reviewAssignment->getReviewerId(), NOTIFICATION_TYPE_REVIEW_ASSIGNMENT); }
/** * Save the metadata of the latest revision of * the requested submission file. * @param $args array * @param $request Request * @return JSONMessage JSON object */ function saveMetadata($args, $request) { $submission = $this->getAuthorizedContextObject(ASSOC_TYPE_SUBMISSION); $submissionFile = $this->getAuthorizedContextObject(ASSOC_TYPE_SUBMISSION_FILE); $reviewRound = $this->getAuthorizedContextObject(ASSOC_TYPE_REVIEW_ROUND); $stageId = $request->getUserVar('stageId'); $metadataForm = $submissionFile->getMetadataForm($stageId, $reviewRound); $metadataForm->readInputData(); if ($metadataForm->validate()) { $metadataForm->execute($args, $request); $submissionFile = $metadataForm->getSubmissionFile(); // Get a list of author user IDs $authorUserIds = array(); $stageAssignmentDao = DAORegistry::getDAO('StageAssignmentDAO'); $submitterAssignments = $stageAssignmentDao->getBySubmissionAndRoleId($submission->getId(), ROLE_ID_AUTHOR); while ($assignment = $submitterAssignments->next()) { $authorUserIds[] = $assignment->getUserId(); } // Update the notifications $notificationMgr = new NotificationManager(); /* @var $notificationMgr NotificationManager */ $notificationMgr->updateNotification($request, $this->getUpdateNotifications(), $authorUserIds, ASSOC_TYPE_SUBMISSION, $submission->getId()); if ($reviewRound) { $notificationMgr->updateNotification($request, array(NOTIFICATION_TYPE_ALL_REVISIONS_IN), null, ASSOC_TYPE_REVIEW_ROUND, $reviewRound->getId()); // Delete any 'revision requested' notifications since all revisions are now in. $context = $request->getContext(); $notificationDao = DAORegistry::getDAO('NotificationDAO'); $stageAssignmentDao = DAORegistry::getDAO('StageAssignmentDAO'); $submitterAssignments = $stageAssignmentDao->getBySubmissionAndRoleId($submission->getId(), ROLE_ID_AUTHOR); while ($assignment = $submitterAssignments->next()) { $notificationDao->deleteByAssoc(ASSOC_TYPE_SUBMISSION, $submission->getId(), $assignment->getUserId(), NOTIFICATION_TYPE_EDITOR_DECISION_PENDING_REVISIONS, $context->getId()); } } // Log the upload event import('lib.pkp.classes.log.SubmissionLog'); import('classes.log.SubmissionEventLogEntry'); import('lib.pkp.classes.log.SubmissionFileEventLogEntry'); // constants $user = $request->getUser(); SubmissionLog::logEvent($request, $submission, $submissionFile->getRevision() > 1 ? SUBMISSION_LOG_FILE_REVISION_UPLOAD : SUBMISSION_LOG_FILE_UPLOAD, $submissionFile->getRevision() > 1 ? 'submission.event.fileRevised' : 'submission.event.fileUploaded', array('fileStage' => $submissionFile->getFileStage(), 'fileId' => $submissionFile->getFileId(), 'fileRevision' => $submissionFile->getRevision(), 'originalFileName' => $submissionFile->getOriginalFileName(), 'submissionId' => $submissionFile->getSubmissionId(), 'username' => $user->getUsername())); return DAO::getDataChangedEvent(); } else { return new JSONMessage(true, $metadataForm->fetch($request)); } }
/** * Save a galley * @param $args array * @param $request PKPRequest * @return JSONMessage JSON object */ function updateGalley($args, $request) { $galley = $this->getGalley(); import('controllers.grid.articleGalleys.form.ArticleGalleyForm'); $galleyForm = new ArticleGalleyForm($request, $this->getSubmission(), $galley); $galleyForm->readInputData(); if ($galleyForm->validate($request)) { $galley = $galleyForm->execute($request); $notificationMgr = new NotificationManager(); $notificationMgr->updateNotification($request, array(NOTIFICATION_TYPE_ASSIGN_PRODUCTIONUSER, NOTIFICATION_TYPE_AWAITING_REPRESENTATIONS), null, ASSOC_TYPE_SUBMISSION, $galley->getSubmissionId()); return DAO::getDataChangedEvent($galley->getId()); } return new JSONMessage(true, $galleyForm->fetch()); }