/** * @return boolean */ protected function update() { $bIsPublished = false; $oIssue = AM_Model_Db_Table_Abstract::factory('issue')->findOneBy('id', $this->primaryKeyValue); /* @var $oIssue AM_Model_Db_Issue */ $sOldState = $oIssue->state; $sOldOrientation = $oIssue->orientation; $sOldPdfMode = $oIssue->static_pdf_mode; $sOldType = $oIssue->type; if ($this->controls['state']->getValue() == AM_Model_Db_State::STATE_PUBLISHED) { // Check for published revision $oQuery = $this->db->select()->from('revision', 'COUNT(*)')->where('issue = ?', $this->primaryKeyValue)->where('state = ?', AM_Model_Db_State::STATE_PUBLISHED); $iPubRevisions = $this->db->fetchOne($oQuery); if (!$iPubRevisions) { $this->errors[] = $this->localizer->translate('Issue has no published revision'); return false; } if ($sOldState != AM_Model_Db_State::STATE_PUBLISHED) { $bIsPublished = true; $this->databaseControls[] = new Volcano_Component_Control_Database_Static($this->actionController, 'release_date', new Zend_Db_Expr('NOW()')); } } if ($this->controls['orientation']->getValue() != $sOldOrientation) { $this->controls['orientation']->setDbValue($sOldOrientation); } $bResult = parent::update(); if (!$bResult) { return false; } if ($bIsPublished) { $sMessage = $this->actionController->__('New issue is available'); AM_Task_Worker_Notification_Planner_Abstract::createTask(array('issue_id' => $this->primaryKeyValue, 'message' => $sMessage, 'badge' => 1)); } if ($this->controls['pdf_type']->getValue() != $sOldPdfMode) { $oIssue->static_pdf_mode = $this->controls['pdf_type']->getValue(); $oIssue->compileHorizontalPdfs(); } if ($this->controls['type']->getValue() != $sOldType) { AM_Model_Db_Table_Abstract::factory('issue_simple_pdf')->deleteBy(array('id_issue' => $this->primaryKeyValue)); } return $bResult; }