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(); $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(); /** @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); }
/** * Check the system for debug mode */ protected function prepareDebugMode(&$paymentSession) { // Check for maintenance (debug) state $params = $this->state->get("params"); if ($params->get("debug_payment_disabled", 0)) { $msg = JString::trim($params->get("debug_disabled_functionality_msg")); if (!$msg) { $msg = JText::_("COM_CROWDFUNDING_DEBUG_MODE_DEFAULT_MSG"); } $this->app->enqueueMessage($msg, "notice"); $this->disabledButton = 'disabled="disabled"'; // Store the new values of the payment process to the user sesstion. $paymentSession->step1 = false; $this->app->setUserState($this->paymentSessionContext, $paymentSession); } }
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)); }
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 * @param array $paymentProcessData */ protected function prepareCurrency($app, $paymentProcessData) { // Load currencies $options = array("state" => 1); jimport("virtualcurrency.currencies"); $this->currencies = new VirtualCurrencyCurrencies(JFactory::getDbo()); $this->currencies->load($options); // Get amount from session $this->currencyAmount = $paymentProcessData["amount"]; // Get item if there is one $itemId = $paymentProcessData["item_id"]; if (!empty($itemId)) { $item = new VirtualCurrencyCurrency(JFactory::getDbo()); $item->load($itemId); // Compare amount with the minimum allowed amount. if ($this->currencyAmount < $item->getParam("minimum")) { // Reset payment data. $paymentProcessData = $this->paymentData; $app->setUserState("payment.data", $paymentProcessData); $this->layoutData->flagStep1 = false; } } // Check days left. If there is no days, disable the button. $this->disabledButton = ""; // Check for debug mode if ($this->params->get("debug_payment_disabled", 0)) { $msg = JString::trim($this->params->get("debug_disabled_functionality_msg")); if (!$msg) { $msg = JText::_("COM_VIRTUALCURRENCY_DEBUG_MODE_DEFAULT_MSG"); } $app->enqueueMessage($msg, "notice"); $this->disabledButton = 'disabled="disabled"'; } }