Exemplo n.º 1
0
 /**
  * Show the message reading page
  */
 public function read($data)
 {
     $mainframe = JFactory::getApplication();
     $my = JFactory::getUser();
     $doc = JFactory::getDocument();
     // Add file attachment library
     $doc->addScript(JURI::root() . 'media/uploader/fileuploader.js');
     $doc->addStyleSheet(JURI::root() . 'media/uploader/fileuploader.css');
     $this->addPathway(JText::_('COM_COMMUNITY_INBOX'), JRoute::_('index.php?option=com_messaging&view=inbox'));
     //JXModule::addBuffer('right', '<br /><h4>Side bar stuff goes here</h4>');
     $inboxModel = MessagingFactory::getModel('inbox');
     $msgid = JRequest::getVar('msgid', 0, 'REQUEST');
     $parentData = '';
     $html = $htmlContent = '';
     $messageHeading = '';
     $recipient = array();
     $parentData = $inboxModel->getMessage($msgid);
     if (!empty($data->messages)) {
         $document = JFactory::getDocument();
         $document->setTitle($this->escape($parentData->subject));
         $this->addPathway($this->escape($parentData->subject));
         foreach ($data->messages as $row) {
             // onMessageDisplay Event trigger
             $args = array();
             $args[] =& $row;
             $user = JXFactory::getUser($row->from);
             //construct the delete link
             $deleteLink = JRoute::_('index.php?option=com_community&task=remove&msgid=' . $row->id);
             $authorLink = JRoute::_('index.php?option=com_profile&view=display&user='******'user', $user)->set('msg', $row)->set('isMine', 0)->set('removeLink', $deleteLink)->set('authorLink', $authorLink)->set('attachments', $attachments)->set('readBy', $readBy)->fetch('inbox.message');
         }
         $myLink = JRoute::_('index.php?option=com_profile&view=display');
         $recipient = array();
         // Put the sender in the participant list
         $from = new stdClass();
         $from->to = $parentData->from;
         $recipient[] = $from;
         $recipient = array_merge($recipient, $inboxModel->getRecepientMessage($msgid));
         $recepientCount = count($recipient) - 1;
         // exclude the sender
         $textOther = $recepientCount > 1 ? 'COM_COMMUNITY_MSG_OTHER' : 'COM_COMMUNITY_MSG_OTHER_SINGULAR';
         $messageHeading = JText::sprintf('COM_COMMUNITY_MSG_BETWEEN_YOU_AND_USER', $myLink, '#', JText::sprintf($textOther, $recepientCount));
     } else {
         $html = '<div class="text">' . JText::_('COM_COMMUNITY_INBOX_MESSAGE_EMPTY') . '</div>';
     }
     $tmplMain = new MessagingTemplate();
     $html .= $tmplMain->set('messageHeading', $messageHeading)->set('msgid', $msgid)->set('recipient', $recipient)->set('messages', $data->messages)->set('parentData', $parentData)->set('htmlContent', $htmlContent)->set('my', $my)->fetch('inbox.read');
     return $html;
 }
Exemplo n.º 2
0
 /**
  * Mark message as Unread
  */
 public function markAsUnread()
 {
     $msgId = JRequest::getVar('msgid', '', 'POST');
     $my = JXFactory::getUser();
     $messagingModel = MessagingFactory::getModel('inbox');
     if ($my->id == 0) {
         exit;
     }
     $filter = array('parent' => $msgId, 'user_id' => $my->id);
     if ($messagingModel->markAsUnread($filter)) {
         $data['id'] = $msgId;
         header('Content-Type: text/json');
         echo json_encode($data);
     }
     exit;
 }
Exemplo n.º 3
0
 public static function getUserNotification($userid)
 {
     $messagingModel = MessagingFactory::getModel('inbox');
     return $messagingModel->getTotalNotifications($userid);
 }