public function __construct(AM_Controller_Action $oActionController, $sName, $iIssueId, $iApplicationId) { $this->applicationId = $iApplicationId; $aControls = array(); $aUser = $oActionController->getUser(); if (!$iIssueId) { $aControls[] = new Volcano_Component_Control_Database_Static($oActionController, 'user', $aUser['id']); } return parent::__construct($oActionController, $sName, $aControls, $oActionController->oDb, 'issue', 'id', $iIssueId); }
public function show() { $oQuery = $this->db->select()->from('user', null)->joinLeft('client', 'client.id = user.client', null)->where('user.deleted = "no"')->order(array('user.first_name', 'user.last_name'))->columns(array('id' => 'user.id', 'name' => 'CONCAT(user.first_name, " ", user.last_name, IF(client.title IS NOT NULL, CONCAT(" (", client.title, ")"), ""), IF(user.is_admin, " - admin", ""))')); $aUsers = array('' => $this->actionController->__('Select user')) + $this->db->fetchPairs($oQuery); $aRecord = array('users' => $aUsers); if (isset($this->view->{$this->getName()})) { $aRecord = array_merge($aRecord, $this->view->{$this->getName()}); } $this->view->{$this->getName()} = $aRecord; parent::show(); }
/** * @return boolean */ public function validate() { if (!parent::validate()) { return false; } if (!$this->primaryKeyValue) { $oQuery = $this->db->select()->from('client', 'id')->where('title = ?', $this->controls['title']->getValue())->where('deleted != ?', 'yes'); if ($this->db->fetchOne($oQuery)) { $this->errors[] = $this->actionController->localizer->translate('Client with such name already exists'); return false; } } return true; }
public function show() { $aTypes = array(); foreach (self::$_aValidTypes as $sType) { $aTypes[$sType] = AM_Model_Db_ApplicationType::typeToText($sType); } $aRecord = array('types' => $aTypes); if (isset($this->view->{$this->getName()})) { $aRecord = array_merge($aRecord, $this->view->{$this->getName()}); } $this->view->{$this->getName()} = $aRecord; parent::show(); }
/** * @return boolean */ protected function update() { if ($this->controls['state']->getValue() == AM_Model_Db_State::STATE_PUBLISHED) { $aBind = array('state' => AM_Model_Db_State::STATE_ARCHIVED, 'updated' => new Zend_Db_Expr('NOW()')); $aWhere = array($this->db->quoteInto('issue = ?', $this->controls['issue']->getValue()), $this->db->quoteInto('state = ?', AM_Model_Db_State::STATE_PUBLISHED)); $this->db->update('revision', $aBind, $aWhere); } if (!parent::update()) { return false; } // Update issue $this->db->update('issue', array('updated' => new Zend_Db_Expr('NOW()')), $this->db->quoteInto('id = ?', $this->controls['issue']->getValue())); return true; }
/** * @return string */ public function operation() { if ($sResult = parent::operation()) { $aVariables = array(); $aVariables['subject'] = "[PadCMS] Your account has been " . ($sResult == 'update' ? 'updated' : 'created') . "."; $aVariables['emails'] = $this->controls['email']->getValue(); $aVariables['firstname'] = $this->controls['first_name']->getValue(); $aVariables['service_url'] = $this->config->common->base_domain_protocol . $this->config->common->base_domain; $aVariables['login'] = $this->controls['login']->getValue(); $aVariables['password'] = $this->controls['password']->getValue(); $this->actionController->getHelper('mailer')->send('notifications', $aVariables); } return $sResult; }
/** * @return boolean */ protected function update() { return parent::update(); }