/**
  * Updates Submission Note
  * @param $articleId int
  */
 function updateSubmissionNote($articleId, $request)
 {
     import('classes.file.ArticleFileManager');
     $noteDao =& DAORegistry::getDAO('NoteDAO');
     $user =& $request->getUser();
     $journal =& $request->getJournal();
     $note = new Note();
     $note->setId($request->getUserVar('noteId'));
     $note->setAssocType(ASSOC_TYPE_ARTICLE);
     $note->setAssocId($articleId);
     $note->setUserId($user->getId());
     $note->setDateModified(Core::getCurrentDate());
     $note->setContextId($journal->getId());
     $note->setTitle($request->getUserVar('title'));
     $note->setContents($request->getUserVar('note'));
     $note->setFileId($request->getUserVar('fileId'));
     if (HookRegistry::call('SectionEditorAction::updateSubmissionNote', array(&$articleId, &$note))) {
         return;
     }
     $articleFileManager = new ArticleFileManager($articleId);
     // if there is a new file being uploaded
     if ($articleFileManager->uploadedFileExists('upload')) {
         // Attach the new file to the note, overwriting existing file if necessary
         $fileId = $articleFileManager->uploadSubmissionNoteFile('upload', $note->getFileId(), true);
         $note->setFileId($fileId);
     } else {
         if ($request->getUserVar('removeUploadedFile')) {
             $articleFileManager = new ArticleFileManager($articleId);
             $articleFileManager->deleteFile($note->getFileId());
             $note->setFileId(0);
         }
     }
     $noteDao->updateObject($note);
 }
 /**
  * Updates Submission Note
  * @param $articleId int
  */
 function updateSubmissionNote($articleId)
 {
     import('file.ArticleFileManager');
     $articleNoteDao =& DAORegistry::getDAO('ArticleNoteDAO');
     $user =& Request::getUser();
     $articleNote = new ArticleNote();
     $articleNote->setId(Request::getUserVar('noteId'));
     $articleNote->setArticleId($articleId);
     $articleNote->setUserId($user->getId());
     $articleNote->setDateModified(Core::getCurrentDate());
     $articleNote->setTitle(Request::getUserVar('title'));
     $articleNote->setNote(Request::getUserVar('note'));
     $articleNote->setFileId(Request::getUserVar('fileId'));
     if (HookRegistry::call('SectionEditorAction::updateSubmissionNote', array(&$articleId, &$articleNote))) {
         return;
     }
     $articleFileManager = new ArticleFileManager($articleId);
     // if there is a new file being uploaded
     if ($articleFileManager->uploadedFileExists('upload')) {
         // Attach the new file to the note, overwriting existing file if necessary
         $fileId = $articleFileManager->uploadSubmissionNoteFile('upload', $articleNote->getFileId(), true);
         $articleNote->setFileId($fileId);
     } else {
         if (Request::getUserVar('removeUploadedFile')) {
             $articleFileManager = new ArticleFileManager($articleId);
             $articleFileManager->deleteFile($articleNote->getFileId());
             $articleNote->setFileId(0);
         }
     }
     $articleNoteDao->updateArticleNote($articleNote);
 }