Example #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);
 }