Exemple #1
0
 public function getTrashMessagesNumber()
 {
     $model = new Default_Model_Messages();
     $select = $model->getMapper()->getDbTable()->select()->from(array('u' => 'messages'), array('id' => 'COUNT(u.id)'))->where("" . "(u.idUserTo = '" . Zend_Registry::get('user')->getId() . "' AND u.trashedTo = 1 AND NOT u.deletedTo)  " . "OR " . "(u.idUserFrom = '" . Zend_Registry::get('user')->getId() . "'  AND u.trashedFrom = 1 AND NOT u.deletedFrom)")->order('u.created  DESC')->setIntegrityCheck(false);
     $model->fetchRow($select);
     return $model->getId();
 }
Exemple #2
0
 public function getInbox()
 {
     if ($this->_inbox === null) {
         $inbox = new Default_Model_Messages();
         $inbox->filter->orderBy('senton DESC');
         $inbox->filter->receiverid->equals($this->id);
         $this->_inbox = $inbox->refresh();
     }
     return $this->_inbox;
 }
 public function newmessageAction()
 {
     // Interdiction d'écrire des messages pour le moment
     return;
     $table = new Default_Model_Messages();
     if ($this->_request->isPost()) {
         // on vire l'html
         $escape = new My_Escape();
         $auteur = $escape->escapeHTML($this->getRequest()->getPost("auteur"));
         $commentaire = $escape->escapeHTML($this->getRequest()->getPost("commentaire"));
         date_default_timezone_set('Europe/Paris');
         $table->ajouter($auteur, date("Y/m/d G:i:s"), str_replace("\n", "<br />", $commentaire));
         $this->_redirect("/livreor/index");
     }
 }
 public function delmsgAction()
 {
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender();
     $ms = new Default_Model_Messages();
     $ms->filter->id->equals($_POST['msgid']);
     $ms->refresh()->remove(0);
 }
Exemple #5
0
 public function deleteFrom(Default_Model_Messages $value)
 {
     $id = $value->getId();
     $data = array('deletedFrom' => '1');
     $this->getDbTable()->update($data, array('id = ?' => $id));
     return $id;
 }
Exemple #6
0
function sendUserInboxNotification($receiverid = null, $sendername = "")
{
    if ($receiverid == null || is_numeric($receiverid) == false) {
        return;
    }
    $receivers = new Default_Model_Researchers();
    $receivers->filter->id->equals($receiverid);
    if (count($receivers->items) == 0) {
        return;
    }
    $receiver = $receivers->items[0];
    $mails = new Default_Model_MailSubscriptions();
    $mails->filter->researcherid->equals($receiverid)->and($mails->filter->subjecttype->equals('inbox'));
    if (count($mails->items) == 0) {
        return;
    }
    $email = getPrimaryContact($receiverid);
    if ($email == null) {
        return;
    }
    $recipients = array($email);
    $ms = new Default_Model_Messages();
    $ms->filter->receiverid->equals($receiverid);
    $all = count($ms->items);
    $unread = $ms->unreadCount();
    $subject = "EGI AppDB: New message from user";
    $text = "Dear " . $receiver->name . ",\n";
    $text .= "\n";
    $text .= "you have a new message in your inbox";
    if (trim($sendername) !== "") {
        $text .= " by " . $sendername;
    }
    $text .= ".\n\n";
    $text .= "You have " . $unread . " unread message" . ($unread == 1 ? "" : "s") . " out of a total of " . $all . " message" . ($all == 1 ? "" : "s") . " in your inbox.\n";
    $text .= "To view your inbox, login to [1] and click on \n";
    $text .= "the inbox icon, on the top of the page.\n";
    $text .= "\n";
    $text .= "Best regards,\n";
    $text .= "The AppDB team\n";
    $body = preg_replace("/\\[1\\]/", "<a href='http://" . $_SERVER["APPLICATION_UI_HOSTNAME"] . "' target='_blank'>EGI Applications Database</a>", $text);
    $body = "<html><head></head><body><pre>" . $body . "</pre></body></html>";
    $text = preg_replace("/\\[1\\]/", "EGI Applications Database [1]", $text);
    $text .= "\n\n________________________________________________________________________________________________________\n";
    $text .= "[1]. http://" . $_SERVER["APPLICATION_UI_HOSTNAME"];
    //sendMultipartMail($subject,$recipients,$text,$body,'*****@*****.**','enadyskolopassword');
    EmailService::sendReport($subject, $recipients, $text, $body);
}
Exemple #7
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);
 }
 public function leavemessageAction()
 {
     trackPage('/people/leavemessage', $this->_getParam("format"));
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender();
     //validations
     if ($this->session->userid == null) {
         echo "";
         return;
     }
     if (!(isset($_POST['msg']) && isset($_POST['receiverID']))) {
         echo "";
         return;
     }
     $data = $_POST['msg'];
     $receiverID = $_POST['receiverID'];
     if (trim($data) == "" || is_numeric($receiverID) === false) {
         echo "";
         return;
     }
     //Send message to user
     $ms = new Default_Model_Messages();
     $m = new Default_Model_Message();
     $m->receiverID = $receiverID;
     $m->senderID = $this->session->userid;
     $m->msg = $data;
     $m->isRead = "0";
     $ms->add($m);
     //Notify user for inbox message
     sendUserInboxNotification($receiverID, $this->session->fullName);
     echo "ok";
 }
Exemple #9
0
 public function reply(Default_Model_Messages $model)
 {
     $this->subject->setValue('Re: ' . $model->getSubject());
     $this->idUserTo->setValue($model->getIdUserFrom());
 }
Exemple #10
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;
     }
 }