Exemplo n.º 1
0
 public function deleteAction()
 {
     $id = $this->getRequest()->getParam('id');
     $type = $this->getRequest()->getParam('type');
     $loggedInUserId = Zend_Registry::get('user')->getId();
     $modelMesaj = new Default_Model_Messages();
     if ($modelMesaj->find($id)) {
         $deleted = false;
         $trash = false;
         if ($modelMesaj->getIdUserFrom() == $loggedInUserId) {
             if ($modelMesaj->getTrashedFrom() == 1) {
                 $deleted = $modelMesaj->deleteFrom();
             } else {
                 $deleted = $modelMesaj->trashFrom();
                 $trash = true;
             }
         } elseif ($modelMesaj->getIdUserTo() == $loggedInUserId) {
             if ($modelMesaj->getTrashedTo() == 1) {
                 $deleted = $modelMesaj->deleteTo();
             } else {
                 $deleted = $modelMesaj->trashTo();
                 $trash = true;
             }
         }
         if ($deleted && $trash) {
             $this->_flashMessenger->addMessage('<span class="mess-true">The massage was successfully moved to trash.</span>');
         } elseif ($deleted) {
             $this->_flashMessenger->addMessage('<span class="mess-true">Your message was successfully deleted.</span>');
         } else {
             $this->_flashMessenger->addMessage('<span class="mess-false">Error deleting message!</span>');
         }
     }
     $this->_redirect(WEBROOT . '/messages/index/type/' . $type);
 }
Exemplo n.º 2
0
 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;
 }
Exemplo n.º 3
0
 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;
     }
 }