/** * Save approval notice. */ function execute() { $approvalNoticeDao =& DAORegistry::getDAO('ApprovalNoticeDAO'); // Create or edit approval notice if (isset($this->approvalNoticeId)) { $approvalNotice =& $approvalNoticeDao->getApprovalNotice($this->approvalNoticeId); } if (!isset($approvalNotice)) { $approvalNotice = new ApprovalNotice(); } // Clean the committees and review types array before saving them $committees = array_unique($this->getData('committees')); $reviewTypes = array_unique($this->getData('reviewTypes')); $allComFound = false; $allTypeFound = false; foreach ($committees as $committeeId) { if ($committeeId == APPROVAL_NOTICE_COMMITTEE_ALL) { $approvalNotice->setCommitteesFromArray(array(0 => APPROVAL_NOTICE_COMMITTEE_ALL)); $allComFound = true; } } if (!$allComFound) { $approvalNotice->setCommitteesFromArray($committees); } foreach ($reviewTypes as $reviewTypeId) { if ($reviewTypeId == APPROVAL_NOTICE_TYPE_ALL) { $approvalNotice->setReviewTypesFromArray(array(0 => APPROVAL_NOTICE_TYPE_ALL)); $allTypeFound = true; } } if (!$allTypeFound) { $approvalNotice->setReviewTypesFromArray($reviewTypes); } $approvalNotice->setApprovalNoticeTitle($this->getData('title')); $approvalNotice->setActive($this->getData('active')); $approvalNotice->setApprovalNoticeHeader($this->getData('APHeader')); $approvalNotice->setApprovalNoticeBody($this->getData('APBody')); $approvalNotice->setApprovalNoticeFooter($this->getData('APFooter')); // Update or insert announcement if ($approvalNotice->getId() != null) { $approvalNoticeDao->updateObject($approvalNotice); } else { $approvalNoticeDao->insertApprovalNotice($approvalNotice); } return $approvalNotice; }