/**
  * This method removes a notification.
  */
 public function remove()
 {
     $app = JFactory::getApplication();
     /** @var $app JApplicationSite */
     $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;
         $app->close();
     }
     try {
         $notification = new Socialcommunity\Notification\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;
     $app->close();
 }
 public function display($tpl = null)
 {
     $this->app = JFactory::getApplication();
     $this->option = $this->app->input->get('option');
     $itemId = $this->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\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);
 }