public function save(Default_Model_Messages $value) { $data = array('idUserFrom' => $value->getIdUserFrom(), 'idUserTo' => $value->getIdUserTo(), 'subject' => $value->getSubject(), 'message' => $value->getMessage(), 'deletedTo' => $value->getDeletedTo() != null ? $value->getDeletedTo() : 0, 'deletedFrom' => $value->getDeletedFrom() != null ? $value->getDeletedFrom() : 0, 'read' => $value->getRead() != null ? $value->getRead() : 0); if (null === ($id = $value->getId())) { $data['created'] = new Zend_Db_Expr('NOW()'); $id = $this->getDbTable()->insert($data); } return $id; }
public function detailsAction() { $id = $this->getRequest()->getParam('id'); $type = $this->getRequest()->getParam('type'); $this->view->type = $type; $loggedInUserId = Zend_Registry::get('user')->getId(); $modelMesaj = new Default_Model_Messages(); if ($modelMesaj->find($id) && ($modelMesaj->getIdUserFrom() == $loggedInUserId || $modelMesaj->getIdUserTo() == $loggedInUserId)) { //BEGIN:mark as read if ($modelMesaj->getRead() == 0) { $model = new Default_Model_Messages(); $model->find($id); $model->makeRead(); } //END:mark as read $this->view->result = $modelMesaj; } }