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));
}
}