Beispiel #1
0
 /**
  * Method to load data via AJAX
  */
 public function getData()
 {
     // Create response object.
     jimport('itprism.response.json');
     $response = new ITPrismResponseJson();
     // 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"))->setTitle(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"))->setTitle(JText::_("COM_CROWDFUNDING_ERROR_SYSTEM"))->failure();
         echo $response;
         JFactory::getApplication()->close();
     }
     $response->setData($item)->success();
     echo $response;
     JFactory::getApplication()->close();
 }
Beispiel #2
0
 /**
  * Method to save the submitted ordering values for records via AJAX.
  *
  * @throws Exception
  * @return  void
  */
 public function loadLocation()
 {
     // Get the input
     $query = $this->input->get->get('query', "", 'string');
     jimport('itprism.response.json');
     $response = new ITPrismResponseJson();
     try {
         jimport("crowdfunding.locations");
         $locations = new CrowdFundingLocations(JFactory::getDbo());
         $locations->loadByString($query);
         $locationData = $locations->toOptions();
     } catch (Exception $e) {
         JLog::add($e->getMessage());
         throw new Exception(JText::_('COM_CROWDFUNDING_ERROR_SYSTEM'));
     }
     $response->setData($locationData)->success();
     echo $response;
     JFactory::getApplication()->close();
 }