/** * Initializes the review system. * * @return void */ protected function initializeReview() { $pageTS = $this->getPageTS(); if (empty($pageTS['review'])) { return; } $this->reviewConfiguration = is_array($pageTS['review']) ? $pageTS['review'] : array(); if (!isset($this->reviewConfiguration['required'])) { $this->reviewConfiguration['required'] = 2; } $this->reviewConfiguration['required'] = max(1, intval($this->reviewConfiguration['required'])); $this->review = $this->reviewRepository->findActive($this->page); if ($this->review === null) { $this->review = $this->objectManager->create('Tx_Contentstage_Domain_Model_Review'); $this->review->setPage($this->page); $this->review->setLevels($this->localRepository->getDepth()); $this->review->setRequired($this->reviewConfiguration['required']); $this->review->setAutoPush(!empty($this->reviewConfiguration['defaultAutoPush'])); } }
/** * action create * * @param Tx_Contentstage_Domain_Model_Review $newReview * @param array $reviewers Array of be_user ids * @return void */ public function createAction(Tx_Contentstage_Domain_Model_Review $review, array $reviewers = array()) { $this->checkPermission(); if (!is_array($reviewers) || count($reviewers) != $this->review->getRequired()) { $this->flashMessageContainer->add($this->translate('review.create.error.badReviewers', array($this->review->getRequired(), count($reviewers))), '', t3lib_FlashMessage::ERROR); $this->redirect('compare', 'Content'); } $reviewed = array(); try { $this->mapReviewers($reviewers, $reviewed); } catch (Exception $e) { $this->log->log($this->translate('error.' . $e->getCode(), array($e->getMessage())) ?: $e->getMessage(), Tx_CabagExtbase_Utility_Logging::ERROR, $e->getTraceAsString()); $this->redirect('compare', 'Content'); } $review->setRequired($this->review->getRequired()); $review->setCreated(new DateTime()); $review->setCreator($this->activeBackendUser); $this->reviewRepository->add($review); $review->addChangeString($this->activeBackendUser); foreach ($reviewed as $reviewedObject) { $review->addReviewed($reviewedObject); } $this->persistenceManager->persistAll(); // at the moment, it is not possible to inject a storage object at creation, so we have to cheat a bit $tempData = t3lib_div::_GP('tx_contentstage_web_contentstagestage_temp'); if (!empty($tempData['review']['dbrecord']) && count($tempData['review']['dbrecord']) > 0) { $converter = $this->objectManager->get('Tx_Contentstage_Property_TypeConverter_DbrecordConverter'); $review->setDbrecord($converter->convertFrom($tempData['review']['dbrecord'], 'Tx_Extbase_Persistence_ObjectStorage<Tx_Contentstage_Domain_Model_Dbrecord>')); } $this->reviewRepository->update($review); $this->persistenceManager->persistAll(); $this->log->log($this->translate('review.create.success'), Tx_CabagExtbase_Utility_Logging::OK); if ($this->reviewConfiguration['autoReviewIfSelf']) { $found = $review->getActiveReviewed($this->activeBackendUser); if ($found !== null) { // the action will redirect to compare action and thus prevent the initial mail sent and only sends a "changed" mail $this->reviewedAction($review, $this->translate('review.submit.ok'), true); } } $this->sendReviewMailAndLog('created', $review); $this->redirect('compare', 'Content'); }