예제 #1
0
파일: Mapper.php 프로젝트: rtsantos/mais
 protected function _afterSave()
 {
     parent::_afterSave();
     if ($this->_action == 'update') {
         $_where = new ZendT_Db_Where();
         $_where->addFilter($this->getModel()->getName() . '.hierarquia', $this->_oldHierarquia, '?%');
         $_where->addFilter($this->getModel()->getName() . '.id', $this->getId(), '!=');
         $_mapper = new Auth_DataView_Conta_MapperView();
         $_mapper->findAll($_where, '*');
         while ($_mapper->fetch()) {
             $_mapper->update();
         }
         $idPai = $this->getIdPapelPai(true)->toPhp();
         if ($this->_idPaiOld && $this->_idPaiOld != $idPai) {
             $_relation = new Auth_Model_ContaRel_Mapper();
             $_relation->setIdPapel($this->getId())->setIdPapelRel($this->_idPaiOld)->retrieve();
             if ($idPai) {
                 $_relation->setIdPapelRel($idPai)->update();
             } else {
                 $_relation->delete();
             }
         }
     } elseif ($this->_action == 'insert') {
         $_relation = new Auth_Model_ContaRel_Mapper();
         $_relation->setIdPapel($this->getId())->setIdPapelRel($this->getId())->setStatus('A')->insert();
         if ($this->getIdPapelPai(true)->toPhp()) {
             $_relation->newRow()->setIdPapel($this->getId())->setIdPapelRel($this->getIdPapelPai())->setStatus('A')->insert();
         }
     }
 }
예제 #2
0
파일: Mapper.php 프로젝트: rtsantos/mais
 /**
  * Retorna o valor antigo do registro antes de realizar a atualização
  *
  * @return Auth_Model_ContaRel_Mapper
  */
 public function getValueOld()
 {
     if (!$this->_dataOld instanceof Auth_Model_ContaRel_Mapper) {
         $this->_dataOld = new Auth_Model_ContaRel_Mapper();
         $this->_dataOld->setId($this->getId());
         $this->_dataOld->retrive();
     }
     return $this->_dataOld;
 }