public function display($tpl = null) { $this->app = JFactory::getApplication(); $this->option = $this->app->input->get('option'); $userId = JFactory::getUser()->get('id'); if (!$userId) { $this->app->enqueueMessage(JText::_('COM_CROWDFUNDING_ERROR_NOT_LOG_IN'), 'notice'); $this->app->redirect(JRoute::_('index.php?option=com_users&view=login', false)); return; } $this->items = $this->get('Items'); $this->state = $this->get('State'); $this->pagination = $this->get('Pagination'); $this->params = $this->state->get('params'); /** @var $params Joomla\Registry\Registry */ if (is_array($this->items) and count($this->items) > 0) { $currency = Crowdfunding\Currency::getInstance(JFactory::getDbo(), $this->params->get('project_currency')); $this->amount = new Crowdfunding\Amount($this->params); $this->amount->setCurrency($currency); } // Prepare filters $this->listOrder = $this->escape($this->state->get('list.ordering')); $this->listDirn = $this->escape($this->state->get('list.direction')); $this->saveOrder = strcmp($this->listOrder, 'a.ordering') === 0; $this->userId = JFactory::getUser()->get('id'); $this->redirectUrl = CrowdfundingHelperRoute::getTransactionsRoute(); $this->prepareDocument(); parent::display($tpl); }
public function display($tpl = null) { $userId = JFactory::getUser()->get("id"); if (!$userId) { $this->app->enqueueMessage(JText::_("COM_CROWDFUNDING_ERROR_NOT_LOG_IN"), "notice"); $this->app->redirect(JRoute::_("index.php?option=com_users&view=login", false)); return; } // Initialise variables $this->items = $this->get('Items'); $this->state = $this->get('State'); $this->params = $this->state->get('params'); if (!empty($this->items)) { // Get currency $currency = Crowdfunding\Currency::getInstance(JFactory::getDbo(), $this->params->get("project_currency")); $this->amount = new Crowdfunding\Amount($this->params); $this->amount->setCurrency($currency); } // Prepare filters $this->listOrder = $this->escape($this->state->get('list.ordering')); $this->listDirn = $this->escape($this->state->get('list.direction')); $this->saveOrder = strcmp($this->listOrder, 'a.ordering') != 0 ? false : true; $this->prepareDocument(); parent::display($tpl); }
public function display($tpl = null) { $this->app = JFactory::getApplication(); $this->option = JFactory::getApplication()->input->get('option'); // Get model state. $this->state = $this->get('State'); $this->item = $this->get('Item'); // Get params $this->params = $this->state->get('params'); /** @var $this->params Joomla\Registry\Registry */ $model = $this->getModel(); $userId = JFactory::getUser()->get('id'); if (!$this->item or $model->isRestricted($this->item, $userId)) { $this->app->enqueueMessage(JText::_('COM_CROWDFUNDING_ERROR_INVALID_PROJECT'), 'notice'); $this->app->redirect(JRoute::_('index.php?option=com_crowdfunding&view=discover', false)); return; } $this->container = Prism\Container::getContainer(); $this->prepareMoneyFormatter($this->container, $this->params); // Get the path to the images. $this->imageFolder = $this->params->get('images_directory', 'images/crowdfunding'); $this->defaultAvatar = JUri::base() . $this->params->get('integration_avatars_default'); $this->avatarsSize = $this->params->get('integration_avatars_size', 'small'); // Prepare the link that points to project page. $host = JUri::getInstance()->toString(array('scheme', 'host')); $this->item->link = $host . JRoute::_(CrowdfundingHelperRoute::getDetailsRoute($this->item->slug, $this->item->catslug)); // Prepare the link that points to project image. $this->item->link_image = $host . '/' . $this->imageFolder . '/' . $this->item->image; // Get the current screen. $this->screen = $this->app->input->getCmd('screen', 'home'); $this->prepareDocument(); // Import content plugins JPluginHelper::importPlugin('content'); switch ($this->screen) { case 'updates': $this->prepareUpdatesScreen(); break; case 'comments': $this->prepareCommentsScreen(); break; case 'funders': $this->prepareFundersScreen(); break; default: // Home break; } // Events $dispatcher = JEventDispatcher::getInstance(); $this->item->event = new stdClass(); $results = $dispatcher->trigger('onContentBeforeDisplay', array('com_crowdfunding.details', &$this->item, &$this->params)); $this->item->event->beforeDisplayContent = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentAfterDisplayMedia', array('com_crowdfunding.details', &$this->item, &$this->params)); $this->item->event->onContentAfterDisplayMedia = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentAfterDisplay', array('com_crowdfunding.details', &$this->item, &$this->params)); $this->item->event->onContentAfterDisplay = trim(implode("\n", $results)); // Count hits $model->hit($this->item->id); parent::display($tpl); }
public function display($tpl = null) { $this->app = JFactory::getApplication(); $this->option = $this->app->input->get('option'); $userId = JFactory::getUser()->get('id'); if (!$userId) { $this->app->enqueueMessage(JText::_('COM_CROWDFUNDING_ERROR_NOT_LOG_IN'), 'notice'); $this->app->redirect(JRoute::_('index.php?option=com_users&view=login', false)); return; } // Initialise variables $this->items = $this->get('Items'); $this->state = $this->get('State'); $this->params = $this->state->get('params'); if (is_array($this->items) and count($this->items) > 0) { $container = Prism\Container::getContainer(); $this->money = $this->getMoneyFormatter($container, $this->params); } // Prepare filters $this->listOrder = $this->escape($this->state->get('list.ordering')); $this->listDirn = $this->escape($this->state->get('list.direction')); $this->saveOrder = (bool) (strcmp($this->listOrder, 'a.ordering') !== 0); $this->dateFormat = $this->params->get('date_format_views', JText::_('DATE_FORMAT_LC3')); $this->prepareDocument(); parent::display($tpl); }
public function display($tpl = null) { $this->app = JFactory::getApplication(); /** @var $this->app JApplicationSite */ $this->option = JFactory::getApplication()->input->get('option'); $this->state = $this->get('State'); $this->item = $this->get('Item'); // Get params $this->params = $this->state->get('params'); /** @var $this->params Joomla\Registry\Registry */ $this->imageFolder = $this->params->get('images_directory', 'images/crowdfunding'); if (!$this->item) { $this->app->enqueueMessage(JText::_('COM_CROWDFUNDING_ERROR_INVALID_PROJECT'), 'notice'); $this->app->redirect(JRoute::_(CrowdfundingHelperRoute::getDiscoverRoute(), false)); return; } $container = Prism\Container::getContainer(); $this->money = $this->getMoneyFormatter($container, $this->params); // Integrate with social profile. $this->displayCreator = $this->params->get('integration_display_creator', true); // Prepare integration. Load avatars and profiles. if ($this->displayCreator and (is_object($this->item) and $this->item->user_id > 0)) { $socialProfile = CrowdfundingHelper::prepareIntegration($this->params->get('integration_social_platform'), $this->item->user_id); $this->socialProfileLink = !$socialProfile ? null : $socialProfile->getLink(); } // Set a link to project page $uri = JUri::getInstance(); $host = $uri->toString(array('scheme', 'host')); $this->item->link = $host . JRoute::_(CrowdfundingHelperRoute::getDetailsRoute($this->item->slug, $this->item->catslug), false); // Set a link to image $this->item->link_image = $host . '/' . $this->imageFolder . '/' . $this->item->image; $this->embedCode = $this->prepareEmbedCode($this->item, $host); $this->prepareDocument(); parent::display($tpl); }
/** * Check if item exists. * * @return bool */ protected function isValid() { if (!$this->item->id or $this->item->user_id != $this->userId) { $this->app->enqueueMessage(JText::_("COM_CROWDFUNDING_ERROR_SOMETHING_WRONG"), "notice"); $this->app->redirect(JRoute::_(CrowdfundingHelperRoute::getDiscoverRoute())); return false; } return true; }
protected function returnToStep1(&$paymentSession, $message = "") { // Reset the flag for step 1 $paymentSession->step1 = false; $this->app->setUserState($this->paymentSessionContext, $paymentSession); if (!empty($message)) { $this->app->enqueueMessage($message, "notice"); } $this->app->redirect(JRoute::_(CrowdfundingHelperRoute::getBackingRoute($this->item->slug, $this->item->catslug), false)); }
public function display($tpl = null) { $this->app = JFactory::getApplication(); /** @var $this->app JApplicationSite */ $this->option = JFactory::getApplication()->input->get('option'); $this->state = $this->get('State'); $this->item = $this->get('Item'); $this->form = $this->get('Form'); // Get params $this->params = $this->state->get('params'); /** @var $this->params Joomla\Registry\Registry */ if (!$this->item) { $this->app->enqueueMessage(JText::_('COM_CROWDFUNDING_ERROR_INVALID_PROJECT'), 'notice'); $this->app->redirect(JRoute::_(CrowdfundingHelperRoute::getDiscoverRoute(), false)); return; } if (!$this->params->get('security_display_friend_form', 0)) { $this->app->enqueueMessage(JText::_('COM_CROWDFUNDING_ERROR_CANT_SEND_MAIL'), 'notice'); $this->app->redirect(JRoute::_($this->item->link, false)); return; } $this->prepareDocument(); parent::display($tpl); }
/** * Execute 301 redirect with cycle checking * @param $newUrl * @return null */ protected function _redirect($newUrl) { if (!$newUrl) { return null; } $juri = JUri::getInstance(); $fullCurUrl = urldecode($juri->toString()); $curUrl = urldecode($juri->toString(array('path', 'query', 'fragment'))); // checking for cycle redirect if ($newUrl !== $curUrl && $newUrl !== $fullCurUrl) { if ($this->app->jbversion->joomla(3)) { $this->_joomlaApp->redirect($newUrl, true); } else { $this->_joomlaApp->redirect($newUrl, '', 'message', true); } } }
protected function prepareExtras() { $model = JModelLegacy::getInstance('Extras', 'CrowdfundingModel', $config = array('ignore_request' => false)); /** @var $model CrowdfundingModelExtras */ // Get state /** @var $state Joomla\Registry\Registry */ $this->state = $model->getState(); // Get item $itemId = $this->state->get('extras.id'); $this->item = $model->getItem($itemId, $this->userId); // Check if the item exists. if (!CrowdfundingHelper::isAuthorized($this->userId, $this->item, 'extras')) { $this->app->enqueueMessage(JText::_('COM_CROWDFUNDING_ERROR_SOMETHING_WRONG'), 'notice'); $this->app->redirect(JRoute::_(CrowdfundingHelperRoute::getDiscoverRoute())); return; } $this->pathwayName = JText::_('COM_CROWDFUNDING_STEP_EXTRAS'); // Events JPluginHelper::importPlugin('crowdfunding'); $dispatcher = JEventDispatcher::getInstance(); $results = $dispatcher->trigger('onExtrasDisplay', array('com_crowdfunding.project.extras', &$this->item, &$this->params)); $this->item->event = new stdClass(); $this->item->event->onExtrasDisplay = trim(implode("\n", $results)); }
protected function preparePayment(&$paymentSession) { // If missing the flag "step1", redirect to first step. if (!$paymentSession->step1) { $this->app->enqueueMessage(JText::_("COM_CROWDFUNDING_ERROR_INVALID_AMOUNT"), "notice"); $this->app->redirect(JRoute::_(CrowdFundingHelperRoute::getBackingRoute($this->item->slug, $this->item->catslug), false)); } // Check for both user states. The user must have only one state, registered or anonymous. $userId = JFactory::getUser()->get("id"); $aUserId = $this->app->getUserState("auser_id"); if (!empty($userId) and !empty($aUserId) or empty($userId) and empty($aUserId)) { // Reset anonymous hash user ID and redirect to first step. $this->app->setUserState("auser_id", ""); // Reset the flag for step 1 $paymentSession->step1 = false; $this->app->setUserState($this->paymentSessionContext, $paymentSession); $this->app->redirect(JRoute::_(CrowdFundingHelperRoute::getBackingRoute($this->item->slug, $this->item->catslug), false)); } if (!$this->item->days_left) { // Reset the flag for step 1 $paymentSession->step1 = false; $this->app->setUserState($this->paymentSessionContext, $paymentSession); $this->app->enqueueMessage(JText::_("COM_CROWDFUNDING_ERROR_PROJECT_COMPLETED"), "notice"); $this->app->redirect(JRoute::_(CrowdFundingHelperRoute::getBackingRoute($this->item->slug, $this->item->catslug), false)); } // Validate reward $this->reward = null; $keys = array("id" => $paymentSession->rewardId, "project_id" => $this->item->id); jimport("crowdfunding.reward"); $this->reward = new CrowdFundingReward(JFactory::getDbo()); $this->reward->load($keys); if ($this->reward->getId()) { if ($this->reward->isLimited() and !$this->reward->getAvailable()) { // Reset the flag for step 1 $paymentSession->step1 = false; $this->app->setUserState($this->paymentSessionContext, $paymentSession); $this->app->enqueueMessage(JText::_("COM_CROWDFUNDING_ERROR_REWARD_NOT_AVAILABLE"), "notice"); $this->app->redirect(JRoute::_(CrowdFundingHelperRoute::getBackingRoute($this->item->slug, $this->item->catslug), false)); } } // Validate amount $this->amount = $paymentSession->amount; if (!$this->amount) { // Reset the flag for step 1 $paymentSession->step1 = false; $this->app->setUserState($this->paymentSessionContext, $paymentSession); $this->app->enqueueMessage(JText::_("COM_CROWDFUNDING_ERROR_INVALID_AMOUNT"), "notice"); $this->app->redirect(JRoute::_(CrowdFundingHelperRoute::getBackingRoute($this->item->slug, $this->item->catslug), false)); } $item = new stdClass(); $item->id = $this->item->id; $item->title = $this->item->title; $item->slug = $this->item->slug; $item->catslug = $this->item->catslug; $item->rewardId = $paymentSession->rewardId; $item->amount = $paymentSession->amount; $item->currencyCode = $this->currency->getAbbr(); // Events JPluginHelper::importPlugin('crowdfundingpayment'); $dispatcher = JEventDispatcher::getInstance(); $results = $dispatcher->trigger('onProjectPayment', array('com_crowdfunding.payment', &$item, &$this->params)); $this->item->event = new stdClass(); $this->item->event->onProjectPayment = trim(implode("\n", $results)); }
public function display($tpl = null) { $this->app = JFactory::getApplication(); $this->option = $this->app->input->get('option'); /** @var $model SocialCommunityModelProfile */ $model = $this->getModel(); $this->state = $model->getState(); $this->item = $model->getItem(); $this->params = $this->state->get('params'); $this->visitorId = $this->state->get($this->option . '.visitor.id'); $this->isOwner = $this->state->get($this->option . '.visitor.is_owner'); $this->targetId = $this->state->get($this->option . '.target.user_id'); // If I am not logged in, and I try to load profile page without user ID as a parameter, // I must load the layout of registration and login form. if (!$this->visitorId and !$this->item) { $this->setLayout('registration'); } // If there is target ID but there is no valid item, // go on the view "No Profile". The profile does not exists. if ($this->targetId and !$this->item) { $this->setLayout('noprofile'); } switch ($this->getLayout()) { case 'registration': $this->prepareRegistration(); break; case 'noprofile': $this->prepareNoProfile(); break; default: // default layout $filesystemHelper = new Prism\Filesystem\Helper($this->params); $this->mediaFolder = $filesystemHelper->getMediaFolderUri($this->item->user_id); // Display details layout if // - visitor is not registered and there is target ID. // - visitor is registered but he is not the owner of the profile. if (!$this->visitorId and $this->targetId or $this->visitorId and !$this->isOwner) { $this->setLayout('details'); // Details page. } else { $this->setLayout('default'); // Profile owner's wall. } // If the wall has been disabled, display profile details. if (!$this->params->get('profile_wall', Prism\Constants::ENABLED)) { $this->setLayout('details'); // Details page. } $pluginContext = 'com_socialcommunity.profile'; switch ($this->getLayout()) { case 'default': $pluginContext .= '.wall'; // If I am logged in and I try to load profile page, // but I do not provide valid profile ID, // I have to display error message. if (!$this->item and $this->visitor->id > 0) { $menu = $this->app->getMenu(); $menuItem = $menu->getDefault(); $this->app->enqueueMessage(JText::_('COM_SOCIALCOMMUNITY_ERROR_INVALID_PROFILE'), 'notice'); $this->app->redirect(JRoute::_('index.php?Itemid=' . $menuItem->id, false)); return; } $this->prepareWall(); break; default: // details $pluginContext .= '.details'; $this->prepareDetails(); break; } // Import content plugins JPluginHelper::importPlugin('content'); // Events $dispatcher = JEventDispatcher::getInstance(); $this->item->event = new stdClass(); $offset = 0; $results = $dispatcher->trigger('onContentBeforeDisplay', array($pluginContext, &$this->item, &$this->params, $offset)); $this->item->event->beforeDisplayContent = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentBeforeDisplayProfile', array($pluginContext, &$this->item, &$this->params)); $this->item->event->beforeDisplayProfileContent = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentAfterDisplayProfile', array($pluginContext, &$this->item, &$this->params)); $this->item->event->afterDisplayProfileContent = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentAfterDisplay', array($pluginContext, &$this->item, &$this->params, $offset)); $this->item->event->afterDisplayContent = trim(implode("\n", $results)); break; } $this->prepareDocument(); parent::display($tpl); }
/** * @param JApplicationSite $app */ protected function prepareInformation($app) { if ($this->params->get("debug_payment_disabled", 0)) { $app->redirect(JRoute::_('index.php?option=com_virtualcurrency&view=payment', false)); } $paymentSessionData = $app->getUserState("payment.data"); $itemId = $paymentSessionData["item_id"]; $this->amount = $paymentSessionData["amount"]; jimport("virtualcurrency.currency"); $this->item = new VirtualCurrencyCurrency(JFactory::getDbo()); $this->item->load($itemId); // Calculate total amount that should be paid. jimport("itprism.math"); $total = new ITPrismMath(); $total->calculateTotal(array($this->amount, $this->item->getParam("amount"))); $this->total = (string) $total; // Get real currency $realCurrencyId = $this->params->get("payments_currency_id"); jimport("virtualcurrency.realcurrency"); $this->realCurrency = VirtualCurrencyRealCurrency::getInstance(JFactory::getDbo(), $realCurrencyId, $this->params); }