Exemplo n.º 1
0
 public function addAction()
 {
     $iIssueId = intval($this->_getParam('iid'));
     if ($iIssueId && !AM_Model_Db_Table_Abstract::factory('issue')->checkAccess($iIssueId, $this->_aUserInfo)) {
         throw new AM_Controller_Exception_Forbidden('Access denied');
     }
     $oApplication = AM_Model_Db_Table_Abstract::factory('application')->findOneBy('id', $this->iApplicationId);
     /* @var $oApplication AM_Model_Db_Application */
     $sClass = AM_Component_Record_Database_Issue_Abstract::getClassByApplicationType($oApplication->type);
     /* @var string */
     $oComponentRecord = new $sClass($this, 'issue', $iIssueId, $this->iApplicationId);
     $sResult = $oComponentRecord->operation();
     if ($sResult) {
         $oIssue = AM_Model_Db_Table_Abstract::factory('issue')->findOneBy('id', $oComponentRecord->getPrimaryKeyValue());
         //Init export processes
         $oIssue->exportRevisions();
     }
     if ($sResult) {
         $this->_redirect('/issue/edit/iid/' . $oComponentRecord->getPrimaryKeyValue() . '/aid/' . $this->iApplicationId);
     }
     $oComponentRecord->show();
     $oBreadCrumbHelper = new AM_View_Helper_Breadcrumbs($this->view, $this->oDb, $this->getUser(), AM_View_Helper_Breadcrumbs::ISSUE, $this->_getAllParams());
     $oBreadCrumbHelper->show();
 }
Exemplo n.º 2
0
 /**
  * @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;
 }