function execute($request)
{
$journal = $request->getJournal();
$issueDao = DAORegistry::getDAO('IssueDAO');
if ($this->issue) {
$isNewIssue = false;
$issue = $this->issue;
} else {
$issue = $issueDao->newDataObject();
$isNewIssue = true;
}
$volume = $this->getData('volume');
$number = $this->getData('number');
$year = $this->getData('year');
$issue->setJournalId($journal->getId());
$issue->setTitle($this->getData('title'), null);
// Localized
$issue->setVolume(empty($volume) ? 0 : $volume);
$issue->setNumber(empty($number) ? 0 : $number);
$issue->setYear(empty($year) ? 0 : $year);
if (!$isNewIssue) {
$issue->setDatePublished($this->getData('datePublished'));
}
$issue->setDescription($this->getData('description'), null);
// Localized
$issue->setShowVolume($this->getData('showVolume'));
$issue->setShowNumber($this->getData('showNumber'));
$issue->setShowYear($this->getData('showYear'));
$issue->setShowTitle($this->getData('showTitle'));
$issue->setAccessStatus($this->getData('accessStatus') ? $this->getData('accessStatus') : ISSUE_ACCESS_OPEN);
// See bug #6324
if ($this->getData('enableOpenAccessDate')) {
$issue->setOpenAccessDate($this->getData('openAccessDate'));
} else {
$issue->setOpenAccessDate(null);
}
// If it is a new issue, first insert it, then update the cover
// because the cover name needs an issue id.
if ($isNewIssue) {
$issue->setPublished(0);
$issue->setCurrent(0);
$issueDao->insertObject($issue);
}
$locale = AppLocale::getLocale();
// Copy an uploaded cover file for the issue, if there is one.
if ($temporaryFileId = $this->getData('temporaryFileId')) {
$user = $request->getUser();
$temporaryFileDao = DAORegistry::getDAO('TemporaryFileDAO');
$temporaryFile = $temporaryFileDao->getTemporaryFile($temporaryFileId, $user->getId());
import('classes.file.PublicFileManager');
$publicFileManager = new PublicFileManager();
$newFileName = 'cover_issue_' . $issue->getId() . '_' . $locale . $publicFileManager->getImageExtension($temporaryFile->getFileType());
$journal = $request->getJournal();
$publicFileManager->copyJournalFile($journal->getId(), $temporaryFile->getFilePath(), $newFileName);
$issue->setCoverImage($newFileName, $locale);
$issueDao->updateObject($issue);
}
$issue->setCoverImageAltText($this->getData('coverImageAltText'), $locale);
parent::execute();
$issueDao->updateObject($issue);
}