/** * This method remove a notification. */ public function remove() { $itemId = $this->input->getUint("id"); $userId = JFactory::getUser()->get("id"); $response = new Prism\Response\Json(); $validatorOwner = new Gamification\Validator\Notification\Owner(JFactory::getDbo(), $itemId, $userId); if (!$validatorOwner->isValid()) { $response->setTitle(JText::_('COM_GAMIFICATION_FAIL'))->setText(JText::_('COM_GAMIFICATION_INVALID_NOTIFICATION'))->failure(); echo $response; JFactory::getApplication()->close(); } try { $notification = new Gamification\Notification\Notification(JFactory::getDbo()); $notification->load($itemId); $notification->remove(); } catch (Exception $e) { JLog::add($e->getMessage()); throw new Exception(JText::_('COM_GAMIFICATION_ERROR_SYSTEM')); } $response->setTitle(JText::_('COM_GAMIFICATION_SUCCESS'))->setText(JText::_('COM_GAMIFICATION_NOTIFICATION_REMOVED_SUCCESSFULLY'))->success(); echo $response; JFactory::getApplication()->close(); }