/** * Method to load data via AJAX */ public function getData() { // Create response object. $response = new Prism\Response\Json(); // Get the input $itemId = $this->input->get->get('id', 0, 'int'); $userId = JFactory::getUser()->id; // Get the model $model = $this->getModel(); /** @var $model CrowdfundingModelUpdateItem */ try { $item = $model->getItem($itemId); if ($item->user_id != $userId) { $response->setTitle(JText::_("COM_CROWDFUNDING_FAIL"))->setText(JText::_("COM_CROWDFUNDING_RECORD_CANNOT_EDIT"))->failure(); echo $response; JFactory::getApplication()->close(); } } catch (Exception $e) { JLog::add($e->getMessage()); $response->setTitle(JText::_("COM_CROWDFUNDING_FAIL"))->setText(JText::_("COM_CROWDFUNDING_ERROR_SYSTEM"))->failure(); echo $response; JFactory::getApplication()->close(); } if (isset($item) and is_object($item)) { $response->setData(Joomla\Utilities\ArrayHelper::fromObject($item))->success(); } else { $response->failure(); } echo $response; JFactory::getApplication()->close(); }