/**
* Save section.
*/
function execute()
{
$journal =& Request::getJournal();
$journalId = $journal->getId();
// We get the section DAO early on so that
// the section class will be imported.
$sectionDao =& DAORegistry::getDAO('SectionDAO');
$section =& $this->section;
if (!is_a($section, 'Section')) {
$section = new Section();
$section->setJournalId($journalId);
$section->setSequence(REALLY_BIG_NUMBER);
}
$section->setTitle($this->getData('title'), null);
// Localized
$section->setAbbrev($this->getData('abbrev'), null);
// Localized
$reviewFormId = $this->getData('reviewFormId');
if ($reviewFormId === '') {
$reviewFormId = null;
}
$section->setReviewFormId($reviewFormId);
$section->setMetaIndexed($this->getData('metaIndexed') ? 0 : 1);
// #2066: Inverted
$section->setMetaReviewed($this->getData('metaReviewed') ? 0 : 1);
// #2066: Inverted
$section->setAbstractsNotRequired($this->getData('abstractsNotRequired') ? 1 : 0);
$section->setIdentifyType($this->getData('identifyType'), null);
// Localized
$section->setEditorRestricted($this->getData('editorRestriction') ? 1 : 0);
$section->setHideTitle($this->getData('hideTitle') ? 1 : 0);
$section->setHideAuthor($this->getData('hideAuthor') ? 1 : 0);
$section->setHideAbout($this->getData('hideAbout') ? 1 : 0);
$section->setDisableComments($this->getData('disableComments') ? 1 : 0);
$section->setPolicy($this->getData('policy'), null);
// Localized
$section->setAbstractWordCount($this->getData('wordCount'));
$section =& parent::execute($section);
if ($section->getId() != null) {
$sectionDao->updateSection($section);
$sectionId = $section->getId();
} else {
$sectionId = $sectionDao->insertSection($section);
$sectionDao->resequenceSections($journalId);
}
// Save assigned editors
$assignedEditorIds = Request::getUserVar('assignedEditorIds');
if (empty($assignedEditorIds)) {
$assignedEditorIds = array();
} elseif (!is_array($assignedEditorIds)) {
$assignedEditorIds = array($assignedEditorIds);
}
$sectionEditorsDao =& DAORegistry::getDAO('SectionEditorsDAO');
$sectionEditorsDao->deleteEditorsBySectionId($sectionId, $journalId);
foreach ($this->sectionEditors as $key => $junk) {
$sectionEditor =& $this->sectionEditors[$key];
$userId = $sectionEditor->getId();
// We don't have to worry about omit- and include-
// section editors because this function is only called
// when the Save button is pressed and those are only
// used in other cases.
if (in_array($userId, $assignedEditorIds)) {
$sectionEditorsDao->insertEditor($journalId, $sectionId, $userId, Request::getUserVar('canReview' . $userId), Request::getUserVar('canEdit' . $userId));
}
unset($sectionEditor);
}
}