Example #1
0
 /**
  * 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();
 }
Example #2
0
 public function getProjectFunds()
 {
     // Create response object
     $response = new Prism\Response\Json();
     $app = JFactory::getApplication();
     /** @var $app JApplicationAdministrator */
     $itemId = $app->input->getInt('id');
     // Check for errors.
     if (!$itemId) {
         $response->setTitle(JText::_('COM_CROWDFUNDINGFINANCE_FAIL'))->setText(JText::_('COM_CROWDFUNDINGFINANCE_ERROR_INVALID_PROJECT'))->failure();
         echo $response;
         JFactory::getApplication()->close();
     }
     try {
         // Get statistics
         $project = new Crowdfunding\Statistics\Project(JFactory::getDbo(), $itemId);
         $data = $project->getFundedAmount();
     } catch (Exception $e) {
         JLog::add($e->getMessage());
         $response->setTitle(JText::_('COM_CROWDFUNDINGFINANCE_FAIL'))->setText(JText::_('COM_CROWDFUNDINGFINANCE_ERROR_SYSTEM'))->failure();
         echo $response;
         JFactory::getApplication()->close();
         throw new Exception(JText::_('COM_CROWDFUNDINGFINANCE_ERROR_SYSTEM'));
     }
     $response->setData($data)->success();
     echo $response;
     JFactory::getApplication()->close();
 }
Example #3
0
 /**
  * Method to load data via AJAX
  */
 public function getData()
 {
     // Get the input
     $app = JFactory::getApplication();
     $itemId = $app->input->get('id', 0, 'int');
     $userId = JFactory::getUser()->id;
     $response = new Prism\Response\Json();
     // Get the model
     $model = $this->getModel();
     /** @var $model CrowdfundingModelCommentItem * */
     try {
         $item = $model->getItem($itemId);
         if ($item->user_id != $userId) {
             $response->setTitle(JText::_('COM_CROWDFUNDING_FAIL'))->setText(JText::_('COM_CROWDFUNDING_INVALID_PROJECT'))->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();
     }
     $data = array();
     if (isset($item) and is_object($item)) {
         $data = array("id" => $item->id, "comment" => $item->comment);
     }
     $response->setData($data)->success();
     echo $response;
     JFactory::getApplication()->close();
 }
Example #4
0
 /**
  * Method to load data via AJAX
  */
 public function getNumber()
 {
     $response = new Prism\Response\Json();
     try {
         $notifications = new SocialCommunity\Notifications(JFactory::getDbo());
         $options = array("user_id" => JFactory::getUser()->get("id"), "status" => Prism\Constants::NOT_READ);
         $notRead = $notifications->getNumber($options);
     } catch (Exception $e) {
         JLog::add($e->getMessage());
         throw new Exception(JText::_('COM_CROWDFUNDING_ERROR_SYSTEM'));
     }
     $data = array("results" => $notRead);
     $response->setData($data)->success();
     echo $response;
     JFactory::getApplication()->close();
 }
 /**
  * Method to load data via AJAX
  */
 public function getNumber()
 {
     $response = new Prism\Response\Json();
     try {
         $notifications = new Gamification\Notification\Notifications(JFactory::getDbo());
         $options = array('user_id' => JFactory::getUser()->get('id'), 'status' => Prism\Constants::NOT_READ);
         $notRead = $notifications->getNumber($options);
     } catch (Exception $e) {
         JLog::add($e->getMessage(), JLog::ERROR, 'com_gamification');
         throw new Exception(JText::_('COM_CROWDFUNDING_ERROR_SYSTEM'));
     }
     $data = array('results' => $notRead);
     $response->setData($data)->success();
     echo $response;
     JFactory::getApplication()->close();
 }
 /**
  * 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->getString('query');
     $response = new Prism\Response\Json();
     try {
         $locations = new Crowdfunding\Locations(JFactory::getDbo());
         $locations->loadByString($query);
         $locationData = $locations->toOptions('id', 'name');
     } catch (Exception $e) {
         JLog::add($e->getMessage(), JLog::ERROR, 'com_crowdfunding');
         throw new Exception(JText::_('COM_CROWDFUNDING_ERROR_SYSTEM'));
     }
     $response->setData($locationData)->success();
     echo $response;
     JFactory::getApplication()->close();
 }
Example #7
0
 /**
  * Method to save the submitted ordering values for records via AJAX.
  *
  * @throws Exception
  *
  * @return  void
  *
  * @since   3.0
  */
 public function loadLocation()
 {
     // Get the input
     $query = $this->input->get->get('query', "", 'string');
     $response = new Prism\Response\Json();
     try {
         $locations = new SocialCommunity\Locations(JFactory::getDbo());
         $locations->load(array("search" => $query));
         $locationData = $locations->toOptions();
     } catch (Exception $e) {
         JLog::add($e->getMessage());
         throw new Exception(JText::_('COM_SOCIALCOMMUNITY_ERROR_SYSTEM'));
     }
     $response->setData($locationData)->success();
     echo $response;
     JFactory::getApplication()->close();
 }
Example #8
0
 /**
  * Method to save the submitted ordering values for records via AJAX.
  *
  * @throws Exception
  * @return  void
  */
 public function loadProject()
 {
     // Get the input
     $query = $this->input->get->get('query', "", 'string');
     $response = new Prism\Response\Json();
     try {
         $options = array("published" => Prism\Constants::PUBLISHED, "approved" => Prism\Constants::APPROVED);
         $projects = new Crowdfunding\Projects(JFactory::getDbo());
         $projects->loadByString($query, $options);
         $projectData = $projects->toOptions();
     } catch (Exception $e) {
         JLog::add($e->getMessage());
         throw new Exception(JText::_('COM_CROWDFUNDING_ERROR_SYSTEM'));
     }
     $response->setData($projectData)->success();
     echo $response;
     JFactory::getApplication()->close();
 }
 /**
  * Method to save the submitted ordering values for records via AJAX.
  *
  * @throws Exception
  *
  * @return  void
  *
  * @since   3.0
  */
 public function loadLocation()
 {
     // Get the input
     $query = $this->input->get->getCmd('query');
     $countryId = $this->input->get->getInt('country_id');
     $response = new Prism\Response\Json();
     try {
         $locations = new Socialcommunity\Location\Locations(JFactory::getDbo());
         $locations->load(array('search' => $query, 'country_id' => $countryId));
         $locationData = $locations->toOptions('id', 'name', 'country_code');
     } catch (Exception $e) {
         JLog::add($e->getMessage());
         throw new Exception(JText::_('COM_SOCIALCOMMUNITY_ERROR_SYSTEM'));
     }
     $response->setData($locationData)->success();
     echo $response;
     JFactory::getApplication()->close();
 }
Example #10
0
 public function getAcyStats()
 {
     // Check for request forgeries.
     JSession::checkToken('get') or jexit(JText::_('JINVALID_TOKEN'));
     $app = JFactory::getApplication();
     /** @var $app JApplicationAdministrator */
     $response = new Prism\Response\Json();
     $projectId = $this->input->get->getInt('acy_pid');
     $listId = $this->input->get->getInt('acy_lid');
     $model = $this->getModel();
     try {
         $model->addSubscribers();
         $data = $model->getAcyStats($projectId, $listId);
     } catch (Exception $e) {
         JLog::add($e->getMessage());
         $response->setTitle(JText::_('COM_CROWDFUNDING_FAIL'))->setText(JText::_('COM_CROWDFUNDING_ERROR_SYSTEM'))->success();
         echo $response;
         $app->close();
     }
     $response->setData($data)->success();
     echo $response;
     $app->close();
 }