/** * Log the upload event. * Must be overridden in subclasses. * @param PKPRequest $request * @param PKPUser $user * @param SubmissionFile $submissionFile * @param int $assocType * @param int $revisedFileId * @param int $fileStage */ function _logEvent($request, $user, $submissionFile, $assocType, $revisedFileId, $fileStage) { // log the upload event. import('lib.pkp.classes.log.SubmissionFileLog'); import('lib.pkp.classes.log.SubmissionFileEventLogEntry'); // constants $localeKey = $revisedFileId ? 'submission.event.revisionUploaded' : 'submission.event.fileUploaded'; $assocType = $revisedFileId ? SUBMISSION_LOG_FILE_REVISION_UPLOAD : SUBMISSION_LOG_FILE_UPLOAD; SubmissionFileLog::logEvent($request, $submissionFile, $assocType, $localeKey, array('fileStage' => $fileStage, 'revisedFileId' => $revisedFileId, 'fileId' => $submissionFile->getFileId(), 'fileRevision' => $submissionFile->getRevision(), 'originalFileName' => $submissionFile->getOriginalFileName(), 'submissionId' => $this->getData('submissionId'), 'username' => $user->getUsername())); }
/** * logs the deletion event using app-specific logging classes. * @param $request PKPRequest * @param $submission Submission * @param $submissionFile SubmissionFile * @param $user PKPUser */ function logDeletionEvent($request, $submission, $submissionFile, $user) { // log the deletion event. import('lib.pkp.classes.log.SubmissionFileLog'); import('lib.pkp.classes.log.SubmissionFileEventLogEntry'); // constants if ($submissionFile->getRevision() > 1) { SubmissionFileLog::logEvent($request, $submissionFile, SUBMISSION_LOG_FILE_REVISION_DELETE, 'submission.event.revisionDeleted', array('fileStage' => $submissionFile->getFileStage(), 'sourceFileId' => $submissionFile->getSourceFileId(), 'fileId' => $submissionFile->getFileId(), 'fileRevision' => $submissionFile->getRevision(), 'originalFileName' => $submissionFile->getOriginalFileName(), 'submissionId' => $submissionFile->getSubmissionId(), 'username' => $user->getUsername())); } else { SubmissionFileLog::logEvent($request, $submissionFile, SUBMISSION_LOG_FILE_DELETE, 'submission.event.fileDeleted', array('fileStage' => $submissionFile->getFileStage(), 'sourceFileId' => $submissionFile->getSourceFileId(), 'fileId' => $submissionFile->getFileId(), 'fileRevision' => $submissionFile->getRevision(), 'originalFileName' => $submissionFile->getOriginalFileName(), 'submissionId' => $submissionFile->getSubmissionId(), 'username' => $user->getUsername())); } if ($submissionFile->getRevision() == 1 && $submissionFile->getSourceFileId() == null) { import('lib.pkp.classes.log.SubmissionLog'); import('classes.log.SubmissionEventLogEntry'); // constants SubmissionLog::logEvent($request, $submission, SUBMISSION_LOG_LAST_REVISION_DELETED, 'submission.event.lastRevisionDeleted', array('title' => $submissionFile->getOriginalFileName(), 'submissionId' => $submissionFile->getSubmissionId(), 'username' => $user->getUsername())); } }
/** * Save the submission file upload form. * @see Form::execute() * @param $request Request * @return SubmissionFile if successful, otherwise null */ function execute($request) { // Identify the file genre and category. $revisedFileId = $this->getRevisedFileId(); if ($revisedFileId) { // The file genre and category will be copied over from the revised file. $fileGenre = null; } else { // This is a new file so we need the file genre and category from the form. $fileGenre = $this->getData('genreId') ? (int) $this->getData('genreId') : null; } // Retrieve the uploader's user group. $uploaderUserGroupId = $this->getData('uploaderUserGroupId'); if (!$uploaderUserGroupId) { fatalError('Invalid uploader user group!'); } // Identify the uploading user. $user = $request->getUser(); assert(is_a($user, 'User')); $assocType = $this->getData('assocType') ? (int) $this->getData('assocType') : null; $assocId = $this->getData('assocId') ? (int) $this->getData('assocId') : null; $fileStage = $this->getData('fileStage'); // Upload the file. import('lib.pkp.classes.file.SubmissionFileManager'); $submissionFileManager = new SubmissionFileManager($request->getContext()->getId(), $this->getData('submissionId')); $submissionFile = $submissionFileManager->uploadSubmissionFile('uploadedFile', $fileStage, $user->getId(), $uploaderUserGroupId, $revisedFileId, $fileGenre, $assocType, $assocId); if (!$submissionFile) { return null; } // Log the event. import('lib.pkp.classes.log.SubmissionFileLog'); import('lib.pkp.classes.log.SubmissionFileEventLogEntry'); // constants SubmissionFileLog::logEvent($request, $submissionFile, $revisedFileId ? SUBMISSION_LOG_FILE_REVISION_UPLOAD : SUBMISSION_LOG_FILE_UPLOAD, $revisedFileId ? 'submission.event.revisionUploaded' : 'submission.event.fileUploaded', array('fileStage' => $fileStage, 'revisedFileId' => $revisedFileId, 'fileId' => $submissionFile->getFileId(), 'fileRevision' => $submissionFile->getRevision(), 'originalFileName' => $submissionFile->getOriginalFileName(), 'submissionId' => $this->getData('submissionId'), 'username' => $user->getUsername())); return $submissionFile; }
/** * Log an event for this file * @param $request PKPRequest * @param $eventType int SUBMISSION_LOG_... */ function _logEvent($request, $eventType) { // Get the log event message switch ($eventType) { case SUBMISSION_LOG_NOTE_POSTED: $logMessage = 'informationCenter.history.notePosted'; break; case SUBMISSION_LOG_MESSAGE_SENT: $logMessage = 'informationCenter.history.messageSent'; break; default: assert(false); } import('lib.pkp.classes.log.SubmissionFileLog'); SubmissionFileLog::logEvent($request, $this->submissionFile, $eventType, $logMessage); }
/** * Set the approval status for a file. * @param $args array * @param $request PKPRequest */ function setProofFileCompletion($args, $request) { $submission = $this->getSubmission(); $submissionFileDao = DAORegistry::getDAO('SubmissionFileDAO'); import('lib.pkp.classes.submission.SubmissionFile'); // Constants $submissionFile = $submissionFileDao->getRevision($request->getUserVar('fileId'), $request->getUserVar('revision'), SUBMISSION_FILE_PROOF, $submission->getId()); $confirmationText = __('editor.submission.proofreading.confirmRemoveCompletion'); if ($request->getUserVar('approval')) { $confirmationText = __('editor.submission.proofreading.confirmCompletion'); } if ($submissionFile && $submissionFile->getAssocType() == ASSOC_TYPE_REPRESENTATION) { import('lib.pkp.controllers.grid.pubIds.form.PKPAssignPublicIdentifiersForm'); $formTemplate = $this->getAssignPublicIdentifiersFormTemplate(); $assignPublicIdentifiersForm = new PKPAssignPublicIdentifiersForm($formTemplate, $submissionFile, $request->getUserVar('approval'), $confirmationText); if (!$request->getUserVar('confirmed')) { // Display assign pub ids modal $assignPublicIdentifiersForm->initData($args, $request); return new JSONMessage(true, $assignPublicIdentifiersForm->fetch($request)); } if ($request->getUserVar('approval')) { // Asign pub ids $assignPublicIdentifiersForm->readInputData(); $assignPublicIdentifiersForm->execute($request); } // Update the approval flag $submissionFile->setViewable($request->getUserVar('approval') ? 1 : 0); $submissionFileDao->updateObject($submissionFile); // Log the event import('lib.pkp.classes.log.SubmissionFileLog'); import('lib.pkp.classes.log.SubmissionFileEventLogEntry'); // constants $user = $request->getUser(); SubmissionFileLog::logEvent($request, $submissionFile, SUBMISSION_LOG_FILE_SIGNOFF_SIGNOFF, 'submission.event.signoffSignoff', array('file' => $submissionFile->getOriginalFileName(), 'name' => $user->getFullName(), 'username' => $user->getUsername())); return DAO::getDataChangedEvent(); } 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()); }
/** * @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(); } }
/** * Set the approval status for a file. * @param $args array * @param $request PKPRequest */ function setProofFileCompletion($args, $request) { $submission = $this->getSubmission(); $submissionFileDao = DAORegistry::getDAO('SubmissionFileDAO'); import('lib.pkp.classes.submission.SubmissionFile'); // Constants $submissionFile = $submissionFileDao->getRevision($request->getUserVar('fileId'), $request->getUserVar('revision'), SUBMISSION_FILE_PROOF, $submission->getId()); if ($submissionFile && $submissionFile->getAssocType() == ASSOC_TYPE_REPRESENTATION) { // Update the approval flag $submissionFile->setViewable($request->getUserVar('approval') ? 1 : 0); $submissionFileDao->updateObject($submissionFile); // Log the event import('lib.pkp.classes.log.SubmissionFileLog'); import('lib.pkp.classes.log.SubmissionFileEventLogEntry'); // constants $user = $request->getUser(); SubmissionFileLog::logEvent($request, $submissionFile, SUBMISSION_LOG_FILE_SIGNOFF_SIGNOFF, 'submission.event.signoffSignoff', array('file' => $submissionFile->getOriginalFileName(), 'name' => $user->getFullName(), 'username' => $user->getUsername())); return DAO::getDataChangedEvent(); } return new JSONMessage(false); }
/** * 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()); }