Exemple #1
0
 public function display($tpl = null)
 {
     $app = JFactory::getApplication();
     /** @var $app JApplicationSite */
     $itemId = $app->input->getUint("id");
     $userId = JFactory::getUser()->get("id");
     $model = $this->getModel();
     // Initialise variables
     $this->item = $model->getItem($itemId, $userId);
     $this->state = $this->get('State');
     $this->params = $this->state->get('params');
     $notification = new SocialCommunity\Notification(JFactory::getDbo());
     $notification->load(array("id" => $itemId, "user_id" => $userId));
     if ($notification->getId() and !$notification->isRead()) {
         $notification->updateStatus(Prism\Constants::READ);
     }
     $this->prepareDocument();
     parent::display($tpl);
 }
Exemple #2
0
 /**
  * This method removes a notification.
  */
 public function remove()
 {
     $itemId = $this->input->getUint("id");
     $userId = JFactory::getUser()->get("id");
     $response = new Prism\Response\Json();
     $validatorOwner = new SocialCommunity\Validator\Notification\Owner(JFactory::getDbo(), $itemId, $userId);
     if (!$validatorOwner->isValid()) {
         $response->setTitle(JText::_('COM_SOCIALCOMMUNITY_FAILURE'))->setText(JText::_('COM_SOCIALCOMMUNITY_ERROR_INVALID_NOTIFICATION'))->failure();
         echo $response;
         JFactory::getApplication()->close();
     }
     try {
         $notification = new SocialCommunity\Notification(JFactory::getDbo());
         $notification->load($itemId);
         $notification->remove();
     } catch (Exception $e) {
         JLog::add($e->getMessage());
         throw new Exception(JText::_('COM_SOCIALCOMMUNITY_ERROR_SYSTEM'));
     }
     $response->setTitle(JText::_('COM_SOCIALCOMMUNITY_SUCCESS'))->setText(JText::_('COM_SOCIALCOMMUNITY_NOTIFICATION_REMOVED_SUCCESSFULLY'))->success();
     echo $response;
     JFactory::getApplication()->close();
 }