Ejemplo n.º 1
0
 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;
     }
     $this->items = $this->get('Items');
     $this->state = $this->get('State');
     $this->pagination = $this->get('Pagination');
     // Get params
     /** @var  $params Joomla\Registry\Registry */
     $params = $this->state->get("params");
     $this->params = $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->userId = JFactory::getUser()->get("id");
     $this->redirectUrl = CrowdfundingHelperRoute::getTransactionsRoute();
     $this->prepareDocument();
     parent::display($tpl);
 }
Ejemplo n.º 2
0
 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);
 }
Ejemplo n.º 3
0
 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);
 }
Ejemplo n.º 4
0
 public function send()
 {
     // Check for request forgeries.
     JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     // Get the data from the form POST
     $data = $this->input->post->get('cfreport', array(), 'array');
     $itemId = Joomla\Utilities\ArrayHelper::getValue($data, 'id');
     if (!$itemId) {
         $redirectOptions = array('force_direction' => CrowdfundingHelperRoute::getReportRoute());
         $this->displayNotice(JText::_('COM_CROWDFUNDING_ERROR_INVALID_PROJECT'), $redirectOptions);
         return;
     }
     // Get project
     $item = Crowdfunding\Project::getInstance(JFactory::getDbo(), $itemId);
     $redirectOptions = array('force_direction' => CrowdfundingHelperRoute::getReportRoute($item->getId()));
     $model = $this->getModel();
     /** @var $model CrowdfundingModelReport */
     $form = $model->getForm($data, false);
     /** @var $form JForm */
     if (!$form) {
         throw new Exception(JText::_('COM_CROWDFUNDING_ERROR_FORM_CANNOT_BE_LOADED'));
     }
     // Test if the data is valid.
     $validData = $model->validate($form, $data);
     // Check for validation errors.
     if ($validData === false) {
         $errors = $form->getErrors();
         $error = array_shift($errors);
         $msg = $error->getMessage();
         $this->displayNotice($msg, $redirectOptions);
         return;
     }
     try {
         $userId = (int) JFactory::getUser()->get('id');
         if ($userId > 0) {
             $validData['user_id'] = $userId;
         }
         $model->save($validData);
     } catch (RuntimeException $e) {
         $this->displayNotice($e->getMessage(), $redirectOptions);
         return;
     } catch (Exception $e) {
         JLog::add($e->getMessage(), JLog::ERROR, 'com_crowdfunding');
         throw new Exception(JText::_('COM_CROWDFUNDING_ERROR_SYSTEM'));
     }
     // Redirect to next page
     $this->displayMessage(JText::_('COM_CROWDFUNDING_REPORT_SENT_SUCCESSFULLY'), $redirectOptions);
 }
Ejemplo n.º 5
0
 public function save($key = null, $urlVar = null)
 {
     // Check for request forgeries.
     JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     $userId = (int) JFactory::getUser()->get('id');
     if (!$userId) {
         $redirectOptions = array('force_direction' => 'index.php?option=com_users&view=login');
         $this->displayNotice(JText::_('COM_CROWDFUNDING_ERROR_NOT_LOG_IN'), $redirectOptions);
         return;
     }
     // Get the data from the form POST
     $data = $this->input->post->get('jform', array(), 'array');
     $itemId = Joomla\Utilities\ArrayHelper::getValue($data, 'project_id', 0, 'int');
     // Get project
     $item = Crowdfunding\Project::getInstance(JFactory::getDbo(), $itemId);
     $redirectOptions = array('force_direction' => CrowdfundingHelperRoute::getDetailsRoute($item->getSlug(), $item->getCatSlug(), 'updates'));
     // Check for valid owner.
     if ($userId !== $item->getUserId()) {
         $this->displayWarning(JText::_('COM_CROWDFUNDING_ERROR_INVALID_PROJECT'), $redirectOptions);
         return;
     }
     $model = $this->getModel();
     /** @var $model CrowdfundingModelUpdate */
     $form = $model->getForm($data, false);
     /** @var $form JForm */
     if (!$form) {
         throw new Exception(JText::_('COM_CROWDFUNDING_ERROR_FORM_CANNOT_BE_LOADED'));
     }
     // Test if the data is valid.
     $validData = $model->validate($form, $data);
     // Check for validation errors.
     if ($validData === false) {
         $errors = $form->getErrors();
         $error = array_shift($errors);
         $msg = $error->getMessage();
         $this->displayNotice($msg, $redirectOptions);
         return;
     }
     try {
         $model->save($validData);
     } catch (Exception $e) {
         JLog::add($e->getMessage(), JLog::ERROR, 'com_crowdfunding');
         throw new Exception(JText::_('COM_CROWDFUNDING_ERROR_SYSTEM'));
     }
     // Redirect to next page
     $this->displayMessage(JText::_('COM_CROWDFUNDING_UPDATE_SUCCESSFULLY_SAVED'), $redirectOptions);
 }
Ejemplo n.º 6
0
 public function display($tpl = null)
 {
     $app = JFactory::getApplication();
     /** @var $app JApplicationSite */
     $this->option = JFactory::getApplication()->input->get('option');
     // Get user ID.
     $this->userId = JFactory::getUser()->get('id');
     // Get reward ID.
     $rewardId = $app->input->getInt('id');
     // Validate reward owner
     $validator = new Crowdfunding\Validator\Reward\Owner(JFactory::getDbo(), $rewardId, $this->userId);
     if (!$validator->isValid()) {
         $app->enqueueMessage(JText::_('COM_CROWDFUNDING_ERROR_INVALID_REWARD'), 'notice');
         $app->redirect(JRoute::_(CrowdfundingHelperRoute::getDiscoverRoute()));
         return;
     }
     $this->items = $this->get('Items');
     $this->state = $this->get('State');
     $this->pagination = $this->get('Pagination');
     // Get params
     /** @var  $params Joomla\Registry\Registry */
     $params = $this->state->get('params');
     $this->params = $params;
     // Prepare an URL where user will be redirected when change the state of a reward.
     $this->redirectUrl = 'index.php?option=com_crowdfunding&view=reward&id=' . $rewardId;
     // 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;
     // Load reward data.
     $this->reward = new Crowdfunding\Reward(JFactory::getDbo());
     $this->reward->load($rewardId);
     // Prepare reward delivery date.
     $dateValidator = new Prism\Validator\Date($this->reward->getDeliveryDate());
     $this->deliveryDate = $dateValidator->isValid() ? JHtml::_('date', $this->reward->getDeliveryDate(), JText::_('DATE_FORMAT_LC3')) : '--';
     // Get images folder.
     $this->imagesFolder = CrowdfundingHelper::getImagesFolderUri($this->userId);
     // Get social profile
     $socialPlatform = $this->params->get('integration_social_platform');
     if (JString::strlen($socialPlatform) > 0) {
         $this->prepareSocialIntegration($socialPlatform);
     }
     $this->prepareDocument();
     parent::display($tpl);
 }
Ejemplo n.º 7
0
 public function send()
 {
     // Check for request forgeries.
     JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     $redirectOptions = array("view" => "discover");
     $params = JComponentHelper::getParams("com_crowdfunding");
     /** @var  $params Joomla\Registry\Registry */
     if (!$params->get("security_display_friend_form", 0)) {
         $this->displayNotice(JText::_('COM_CROWDFUNDING_ERROR_CANT_SEND_MAIL'), $redirectOptions);
         return;
     }
     // Get the data from the form POST
     $data = $this->input->post->get('jform', array(), 'array');
     $itemId = Joomla\Utilities\ArrayHelper::getValue($data, "id", 0, "uint");
     // Get project
     $item = Crowdfunding\Project::getInstance(JFactory::getDbo(), $itemId);
     // Prepare redirect link
     $link = CrowdfundingHelperRoute::getEmbedRoute($item->getSlug(), $item->getCatSlug(), "email");
     $redirectOptions = array("force_direction" => $link);
     $model = $this->getModel();
     /** @var $model CrowdfundingModelFriendMail */
     $form = $model->getForm($data, false);
     /** @var $form JForm */
     if (!$form) {
         throw new Exception(JText::_("COM_CROWDFUNDING_ERROR_FORM_CANNOT_BE_LOADED"));
     }
     // Test if the data is valid.
     $validData = $model->validate($form, $data);
     // Check for validation errors.
     if ($validData === false) {
         $this->displayNotice($form->getErrors(), $redirectOptions);
         return;
     }
     try {
         $model->send($validData);
     } catch (Exception $e) {
         JLog::add($e->getMessage());
         throw new Exception(JText::_('COM_CROWDFUNDING_ERROR_SYSTEM'));
     }
     // Redirect to next page
     $this->displayMessage(JText::_("COM_CROWDFUNDING_FRIEND_MAIL_SUCCESSFULLY_SEND"), $redirectOptions);
 }
 /**
  * Method to get the data that should be injected in the form.
  *
  * @throws \Exception
  * @return    mixed    The data for the form.
  * @since    1.6
  */
 protected function loadFormData()
 {
     $app = JFactory::getApplication();
     /** @var $app JApplicationSite */
     $data = $app->getUserState($this->option . '.edit.friendmail.data', array());
     if (!$data) {
         $item = $this->getItem();
         // Prepare default content of the form
         if ((int) $item->id > 0) {
             $link = JRoute::_(CrowdfundingHelperRoute::getDetailsRoute($item->slug, $item->catslug));
             $data = array('id' => $item->id, 'subject' => JText::sprintf('COM_CROWDFUNDING_SEND_FRIEND_DEFAULT_SUBJECT', $item->title), 'message' => JText::sprintf('COM_CROWDFUNDING_SEND_FRIEND_DEFAULT_MESSAGE', $link));
             // Set user data
             $user = JFactory::getUser();
             if ((int) $user->get('id') > 0) {
                 $data['sender_name'] = $user->name;
                 $data['sender'] = $user->email;
             }
         }
     }
     return $data;
 }
Ejemplo n.º 9
0
 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);
 }
 /**
  * Catch a request from payment plugin via AJAX and process a transaction.
  */
 public function notifyAjax()
 {
     $response = new Prism\Response\Json();
     // Check for disabled payment functionality
     if ($this->params->get('debug_payment_disabled', 0)) {
         $errorData = JText::sprintf('COM_CROWDFUNDING_TRANSACTION_DATA', var_export($_REQUEST, true));
         $this->log->add(JText::_('COM_CROWDFUNDING_ERROR_PAYMENT_HAS_BEEN_DISABLED'), 'ERROR_CONTROLLER_NOTIFIER_AJAX', $errorData);
         // Send response to the browser
         $response->setTitle(JText::_('COM_CROWDFUNDING_FAIL'))->setText(JText::_('COM_CROWDFUNDING_ERROR_PAYMENT_HAS_BEEN_DISABLED_MESSAGE'))->failure();
         echo $response;
         $this->app->close();
     }
     // Get model object.
     $model = $this->getModel();
     $paymentResult = null;
     $redirectUrl = null;
     $message = null;
     $project = null;
     /** @var Crowdfunding\Project $project */
     // Trigger the event
     try {
         // Import Crowdfunding Payment Plugins
         JPluginHelper::importPlugin('crowdfundingpayment');
         // Trigger onPaymentNotify event.
         $dispatcher = JEventDispatcher::getInstance();
         $results = $dispatcher->trigger('onPaymentNotify', array($this->context, &$this->params));
         if (is_array($results) and count($results) > 0) {
             foreach ($results as $result) {
                 if (is_object($result) and isset($result->transaction)) {
                     $paymentResult = $result;
                     $project = isset($result->project) ? $result->project : null;
                     $redirectUrl = isset($result->redirectUrl) ? $result->redirectUrl : null;
                     $message = isset($result->message) ? $result->message : null;
                     break;
                 }
             }
         }
         // If there is no transaction data, the status might be pending or another one.
         // So, we have to stop the script execution.
         if (!$paymentResult) {
             // Send response to the browser
             $response->setTitle(JText::_('COM_CROWDFUNDING_FAIL'))->setText(JText::_('COM_CROWDFUNDING_TRANSACTION_NOT_PROCESSED_SUCCESSFULLY'))->failure();
             echo $response;
             $this->app->close();
         }
         // Trigger the event onAfterPaymentNotify
         $dispatcher->trigger('onAfterPaymentNotify', array($this->context, &$paymentResult, &$this->params));
         // Trigger the event onAfterPayment
         $dispatcher->trigger('onAfterPayment', array($this->context, &$paymentResult, &$this->params));
     } catch (Exception $e) {
         // Store log data to the database.
         $error = 'AJAX NOTIFIER ERROR: ' . $e->getMessage() . "\n";
         $errorData = 'INPUT:' . var_export($this->app->input, true) . "\n";
         $this->log->add($error, 'ERROR_CONTROLLER_NOTIFIER_AJAX', $errorData);
         // Send response to the browser
         $response->failure()->setTitle(JText::_('COM_CROWDFUNDING_FAIL'))->setText(JText::_('COM_CROWDFUNDING_ERROR_SYSTEM'));
         // Send notification about the error to the administrator.
         $model->sendMailToAdministrator();
         echo $response;
         $this->app->close();
     }
     // Generate redirect URL
     if (!$redirectUrl and is_object($project)) {
         $uri = JUri::getInstance();
         $redirectUrl = $uri->toString(array('scheme', 'host')) . JRoute::_(CrowdfundingHelperRoute::getBackingRoute($project->getSlug(), $project->getCatSlug(), 'share'));
     }
     if (!$message) {
         $message = JText::_('COM_CROWDFUNDING_TRANSACTION_PROCESSED_SUCCESSFULLY');
     }
     // Send response to the browser
     $response->success()->setTitle(JText::_('COM_CROWDFUNDING_SUCCESS'))->setText($message)->setRedirectUrl($redirectUrl);
     echo $response;
     $this->app->close();
 }
Ejemplo n.º 11
0
 protected static function findItem($needles = null)
 {
     $app = JFactory::getApplication();
     $menus = $app->getMenu('site');
     // Prepare the reverse lookup array.
     // Collect all menu items and creat an array that contains
     // the ID from the query string of the menu item as a key,
     // and the menu item id (Itemid) as a value
     // Example:
     // array( "category" =>
     //     1(id) => 100 (Itemid),
     //     2(id) => 101 (Itemid)
     // );
     if (self::$lookup === null) {
         self::$lookup = array();
         $component = JComponentHelper::getComponent('com_crowdfunding');
         $items = $menus->getItems('component_id', $component->id);
         if ($items) {
             foreach ($items as $item) {
                 if (isset($item->query) && isset($item->query['view'])) {
                     $view = $item->query['view'];
                     if (!isset(self::$lookup[$view])) {
                         self::$lookup[$view] = array();
                     }
                     if (isset($item->query['id'])) {
                         self::$lookup[$view][$item->query['id']] = $item->id;
                     } else {
                         // If it is a root element that have no a request parameter ID ( categories, authors ), we set 0 for an key
                         self::$lookup[$view][0] = $item->id;
                     }
                 }
             }
         }
     }
     if ($needles) {
         foreach ($needles as $view => $ids) {
             if (isset(self::$lookup[$view])) {
                 foreach ($ids as $id) {
                     if (isset(self::$lookup[$view][(int) $id])) {
                         return self::$lookup[$view][(int) $id];
                     }
                 }
             }
         }
     } else {
         $active = $menus->getActive();
         if ($active) {
             return $active->id;
         }
     }
     return null;
 }
Ejemplo n.º 12
0
    echo $imageFolder . "/" . $project->getImage();
    ?>
" alt="<?php 
    echo htmlspecialchars($project->getTitle(), ENT_QUOTES, "UTF-8");
    ?>
" width="<?php 
    echo $imageWidth;
    ?>
" height="<?php 
    echo $imageHeight;
    ?>
" />
            <div class="caption">
                <h3>
                    <a href="<?php 
    echo JRoute::_(CrowdfundingHelperRoute::getDetailsRoute($project->getSlug(), $project->getCatSlug()));
    ?>
">
                        <?php 
    echo htmlspecialchars($project->getTitle(), ENT_QUOTES, "UTF-8");
    ?>
                    </a>
                </h3>
                <span class="font-xxsmall">
                    <?php 
    echo JText::_("MOD_CROWDFUNDINGDETAILS_BY");
    if (!empty($socialProfileLink)) {
        ?>
                        <a href="<?php 
        echo $socialProfileLink;
        ?>
Ejemplo n.º 13
0
    echo JHtml::_('crowdfunding.approved', $item->approved);
    ?>
                    </td>
                    <td class="text-center hidden-phone">
                        <a href="<?php 
    echo JRoute::_(CrowdfundingHelperRoute::getFormRoute($item->id));
    ?>
"
                           class="btn btn-primary btn-sm">
                            <span class="fa fa-edit"></span>
                            <?php 
    echo JText::_('COM_CROWDFUNDING_EDIT');
    ?>
                        </a>
                        <a href="<?php 
    echo JRoute::_(CrowdfundingHelperRoute::getFormRoute($item->id, 'manager'));
    ?>
"
                           class="btn btn-default btn-sm">
                            <span class="fa fa-wrench"></span>
                            <?php 
    echo JText::_('COM_CROWDFUNDING_MANAGER');
    ?>
                        </a>
                    </td>
                </tr>
            <?php 
}
?>
            </tbody>
Ejemplo n.º 14
0
 protected function sendMail($project, $emailId)
 {
     $app = JFactory::getApplication();
     /** @var $app JApplicationSite */
     // Get website
     $uri = JUri::getInstance();
     $website = $uri->toString(array("scheme", "host"));
     $emailMode = $this->params->get("email_mode", "plain");
     // Route project URI
     $appSite = JApplicationCms::getInstance('site');
     $router = $appSite->getRouter('site');
     $routedUri = $router->build(CrowdfundingHelperRoute::getDetailsRoute($project->slug, $project->catslug));
     if ($routedUri instanceof JUri) {
         $routedUri = $routedUri->toString();
     }
     if (0 === strpos($routedUri, "/administrator")) {
         $routedUri = str_replace("/administrator", "", $routedUri);
     }
     // Prepare data for parsing
     $data = array("site_name" => $app->get("sitename"), "site_url" => JUri::root(), "item_title" => $project->title, "item_url" => $website . $routedUri);
     // Send mail to the administrator
     if (!$emailId) {
         return false;
     }
     $email = new EmailTemplates\Email();
     $email->setDb(JFactory::getDbo());
     $email->load($emailId);
     if (!$email->getSenderName()) {
         $email->setSenderName($app->get("fromname"));
     }
     if (!$email->getSenderEmail()) {
         $email->setSenderEmail($app->get("mailfrom"));
     }
     $recipientName = $project->name;
     $recipientMail = $project->email;
     // Prepare data for parsing
     $data["sender_name"] = $email->getSenderName();
     $data["sender_email"] = $email->getSenderEmail();
     $data["recipient_name"] = $recipientName;
     $data["recipient_email"] = $recipientMail;
     $email->parse($data);
     $subject = $email->getSubject();
     $body = $email->getBody($emailMode);
     $mailer = JFactory::getMailer();
     if (strcmp("html", $emailMode) == 0) {
         // Send as HTML message
         $result = $mailer->sendMail($email->getSenderEmail(), $email->getSenderName(), $recipientMail, $subject, $body, Prism\Constants::MAIL_MODE_HTML);
     } else {
         // Send as plain text.
         $result = $mailer->sendMail($email->getSenderEmail(), $email->getSenderName(), $recipientMail, $subject, $body, Prism\Constants::MAIL_MODE_PLAIN);
     }
     // Log the error.
     if ($result !== true) {
         $this->log->add(JText::sprintf("PLG_CONTENT_CROWDFUNDINGUSERMAIL_ERROR_SEND_MAIL", $this->name), "PLG_CONTENT_USERE_MAIL_ERROR", JText::sprintf("PLG_CONTENT_CROWDFUNDINGUSERMAIL_ERROR_SEND_MAIL_NOTE", $mailer->ErrorInfo));
         return false;
     }
     return true;
 }
Ejemplo n.º 15
0
    ?>
</div>
		<div class="cf-frss pull-center"><?php 
    echo JHtml::_('crowdfunding.resultStateText', $project->getFundedPercent(), $project->getFundingType());
    ?>
</div>
	</div>
	<?php 
} else {
    ?>
	<div class="cfinfo-funding-action">
		<a class="btn btn-default btn-large btn-block <?php 
    echo !$isValidEndDate ? 'disabled' : '';
    ?>
" href="<?php 
    echo JRoute::_(CrowdfundingHelperRoute::getBackingRoute($project->getSlug(), $project->getCatSlug()));
    ?>
">
			<?php 
    if (!$params->get('button_title_custom')) {
        echo JText::_($params->get('button_title', 'MOD_CROWDFUNDINGINFO_BUTTON_CONTRIBUTE'));
    } else {
        echo htmlspecialchars($params->get('button_title_custom'), ENT_COMPAT, 'UTF-8');
    }
    ?>
        </a>
	</div>
	<?php 
}
?>
 /**
  * Disconnect user from payment gateway.
  *
  * @param string                   $context
  * @param Joomla\Registry\Registry $params
  *
  * @return null|array
  */
 public function onPayoutsDeauthorize($context, $params)
 {
     if (strcmp('com_crowdfundingfinance.payouts.deauthorize.stripeconnect', $context) !== 0) {
         return null;
     }
     if ($this->app->isAdmin()) {
         return null;
     }
     $doc = JFactory::getDocument();
     /**  @var $doc JDocumentHtml */
     // Check document type
     $docType = $doc->getType();
     if (strcmp('html', $docType) !== 0) {
         return null;
     }
     // Prepare output data.
     $output = array('redirect_url' => '', 'message' => '');
     $errorOutput = array('redirect_url' => JRoute::_(CrowdfundingHelperRoute::getDiscoverRoute()), 'message' => '');
     // DEBUG DATA
     JDEBUG ? $this->log->add(JText::_($this->textPrefix . '_DEBUG_GET_RESPONSE_AUTHORIZE'), $this->debugType, $_GET) : null;
     $userId = JFactory::getUser()->get('id');
     if (!$userId) {
         $errorOutput['message'] = JText::_($this->textPrefix . '_ERROR_NOT_REGISTERED_USER');
         return $errorOutput;
     }
     // Get token
     $state = $this->app->input->get('state');
     if (!$state) {
         $errorOutput['message'] = JText::_($this->textPrefix . '_ERROR_INVALID_AUTHORIZATION_DATA');
         return $errorOutput;
     }
     // Get project ID and redirect URL from the session.
     $stateData = $this->app->getUserState($state);
     if (count($stateData) === 0 or (!$stateData['redirect_url'] or !$stateData['project_id'])) {
         $errorOutput['message'] = JText::_($this->textPrefix . '_ERROR_INVALID_AUTHORIZATION_DATA');
         return $errorOutput;
     }
     $cfFinanceParams = JComponentHelper::getParams('com_crowdfundingfinance');
     $apiKeys = Crowdfundingfinance\Stripe\Helper::getKeys($cfFinanceParams);
     if (!$apiKeys['client_id'] or !$apiKeys['secret_key']) {
         $errorOutput['message'] = JText::_($this->textPrefix . '_ERROR_CONFIGURATION');
         return $errorOutput;
     }
     $payout = new Crowdfundingfinance\Payout(JFactory::getDbo());
     $payout->setSecretKey($this->app->get('secret'));
     $payout->load(array('project_id' => (int) $stateData['project_id']));
     if (!$payout->getId()) {
         $errorOutput['message'] = JText::_($this->textPrefix . '_ERROR_INVALID_PAYOUT');
         return $errorOutput;
     }
     $alias = !$apiKeys['test'] ? 'production' : 'test';
     $stripeData = $payout->getStripe();
     if (!$stripeData->get('stripeconnect.' . $alias . '.account_id')) {
         $errorOutput['message'] = JText::_($this->textPrefix . '_ERROR_NOT_CONNECTED');
         return $errorOutput;
     }
     Crowdfundingfinance\Stripe\Helper::deauthorize($apiKeys, $stripeData->get('stripeconnect.' . $alias . '.account_id'));
     $stripeData->set('stripeconnect.' . $alias . '.access_token', '');
     $stripeData->set('stripeconnect.' . $alias . '.refresh_token', '');
     $stripeData->set('stripeconnect.' . $alias . '.account_id', '');
     $stripeData->set('stripeconnect.' . $alias . '.expires', 0);
     $payout->setStripe($stripeData);
     $payout->storeStripe();
     // Get next URL.
     $output['redirect_url'] = base64_decode($stateData['redirect_url']);
     return $output;
 }
Ejemplo n.º 17
0
 /**
  * @param string  $context
  * @param object $article
  * @param Joomla\Registry\Registry $params
  * @param int $page
  *
  * @return null|string
  * @throws Exception
  */
 public function onContentBeforeDisplay($context, &$article, &$params, $page = 0)
 {
     $app = JFactory::getApplication();
     /** @var $app JApplicationSite */
     if ($app->isAdmin()) {
         return null;
     }
     $doc = JFactory::getDocument();
     /**  @var $doc JDocumentHtml */
     // Check document type
     $docType = $doc->getType();
     if (strcmp("html", $docType) != 0) {
         return null;
     }
     if (strcmp("com_crowdfunding.details", $context) != 0) {
         return null;
     }
     // Load language
     $this->loadLanguage();
     $itemId = $app->input->getInt("id");
     $stats = CrowdfundingHelper::getProjectData($itemId);
     $screen = $app->input->getCmd("screen", "home");
     $html = '<ul class="nav nav-pills cf-plg-navigation">';
     if ($this->params->get("display_home")) {
         $class = 'class="cf-plg-nav-home';
         if (strcmp($screen, "home") == 0) {
             $class .= ' active';
         }
         $class .= '"';
         $html .= '<li ' . $class . '><a href="' . JRoute::_(CrowdfundingHelperRoute::getDetailsRoute($article->slug, $article->catslug)) . '">' . JText::_("PLG_CONTENT_CROWDFUNDINGNAV_HOME") . "</a></li>";
     }
     if ($this->params->get("display_updates")) {
         $class = 'class="cf-plg-nav-updates';
         if (strcmp($screen, "updates") == 0) {
             $class .= ' active';
         }
         $class .= '"';
         $stat = '<span class="badge">' . Joomla\Utilities\ArrayHelper::getValue($stats, "updates", 0) . '</span>';
         $html .= '<li ' . $class . '><a href="' . JRoute::_(CrowdfundingHelperRoute::getDetailsRoute($article->slug, $article->catslug, "updates")) . '">' . JText::_("PLG_CONTENT_CROWDFUNDINGNAV_UPDATES") . ' ' . $stat . '</a></li>';
     }
     if ($this->params->get("display_comments")) {
         $class = 'class="cf-plg-nav-comments';
         if (strcmp($screen, "comments") == 0) {
             $class .= ' active';
         }
         $class .= '"';
         if (!$params->get("comments_enabled", 1)) {
             $stat = '<span class="cf-dclabel">&nbsp;</span>';
         } else {
             $stat = '<span class="badge">' . Joomla\Utilities\ArrayHelper::getValue($stats, "comments", 0) . '</span>';
         }
         $html .= '<li ' . $class . '><a href="' . JRoute::_(CrowdfundingHelperRoute::getDetailsRoute($article->slug, $article->catslug, "comments")) . '">' . JText::_("PLG_CONTENT_CROWDFUNDINGNAV_COMMENTS") . ' ' . $stat . '</a></li>';
     }
     if ($this->params->get("display_funders")) {
         $class = 'class="cf-plg-nav-funders';
         if (strcmp($screen, "funders") == 0) {
             $class .= ' active';
         }
         $class .= '"';
         $stat = '<span class="badge">' . Joomla\Utilities\ArrayHelper::getValue($stats, "funders", 0) . '</span>';
         $html .= '<li ' . $class . '><a href="' . JRoute::_(CrowdfundingHelperRoute::getDetailsRoute($article->slug, $article->catslug, "funders")) . '">' . JText::_("PLG_CONTENT_CROWDFUNDINGNAV_FUNDERS") . ' ' . $stat . '</a></li>';
     }
     $html .= '</ul>';
     return $html;
 }
Ejemplo n.º 18
0
    ?>
    <div class="cfrewards<?php 
    echo $moduleclassSfx;
    ?>
">

        <div class="reward_title center"><?php 
    echo JText::_("MOD_CROWDFUNDINGREWARDS_PLEDGE_REWARDS");
    ?>
</div>
        <?php 
    foreach ($rewards as $reward) {
        ?>
            <div class="reward">
                <a href="<?php 
        echo JRoute::_(CrowdfundingHelperRoute::getBackingRoute($project->getSlug(), $project->getCatSlug(), "default", $reward["id"]));
        ?>
">
    			<span class="ramount">
    			<?php 
        $amount = $currency->getAmountString($reward["amount"]);
        echo JText::sprintf("MOD_CROWDFUNDINGREWARDS_INVEST_MORE", $amount);
        ?>
    			</span>
                    <span class="rtitle"><?php 
        echo htmlspecialchars($reward["title"], ENT_QUOTES, "UTF-8");
        ?>
</span>
                    <span class="rdesc"><?php 
        echo htmlspecialchars($reward["description"], ENT_QUOTES, "UTF-8");
        ?>
Ejemplo n.º 19
0
 public function saveState()
 {
     JSession::checkToken('get') or jexit(JText::_('JINVALID_TOKEN'));
     $userId = JFactory::getUser()->get('id');
     if (!$userId) {
         $redirectOptions = array('force_direction' => 'index.php?option=com_users&view=login');
         $this->displayNotice(JText::_('COM_CROWDFUNDING_ERROR_NOT_LOG_IN'), $redirectOptions);
         return;
     }
     // Get component parameters
     $params = JComponentHelper::getParams($this->option);
     /** @var  $params Joomla\Registry\Registry */
     // Get the data from the form
     $itemId = $this->input->get->get('id', 0, 'int');
     $state = $this->input->get->get('state', 0, 'int');
     $state = !$state ? 0 : 1;
     $return = $this->input->get->get('return', '', 'base64');
     $returnLink = JRoute::_(CrowdfundingHelperRoute::getProjectsRoute(), false);
     // Get return link from parameters.
     if (strlen($return) > 0) {
         $returnLink = base64_decode($return);
     }
     $redirectOptions = array('force_direction' => $returnLink);
     $model = $this->getModel();
     /** @var $model CrowdfundingModelProjectItem */
     $item = $model->getItem($itemId, $userId);
     if (!$item->id) {
         $this->displayNotice(JText::_('COM_CROWDFUNDING_ERROR_INVALID_PROJECT'), $redirectOptions);
         return;
     }
     // Include plugins to validate content.
     $dispatcher = JEventDispatcher::getInstance();
     JPluginHelper::importPlugin('content');
     // Trigger onContentValidate event.
     $context = $this->option . '.projects.changestate';
     $results = $dispatcher->trigger('onContentValidateChangeState', array($context, &$item, &$params, $state));
     // If there is an error, redirect to another page.
     foreach ($results as $result) {
         if ((bool) $result['success'] === false) {
             $this->displayNotice(Joomla\Utilities\ArrayHelper::getValue($result, 'message'), $redirectOptions);
             return;
         }
     }
     try {
         $model->saveState($itemId, $userId, $state);
     } catch (RuntimeException $e) {
         $this->setMessage($e->getMessage(), 'warning');
         $this->setRedirect($returnLink);
         return;
     } catch (Exception $e) {
         JLog::add($e->getMessage(), JLog::ERROR, 'com_crowdfunding');
         throw new Exception(JText::_('COM_CROWDFUNDING_ERROR_SYSTEM'));
     }
     // Redirect to next page
     if (!$state) {
         $msg = JText::_('COM_CROWDFUNDING_PROJECT_STOPPED_SUCCESSFULLY');
     } else {
         $msg = JText::_('COM_CROWDFUNDING_PROJECT_LAUNCHED_SUCCESSFULLY_INFO');
     }
     $this->displayMessage($msg, $redirectOptions);
 }
 /**
  * @param stdClass $project
  * @param int $emailId
  *
  * @return bool
  */
 protected function sendMail($project, $emailId)
 {
     $app = JFactory::getApplication();
     /** @var $app JApplicationSite */
     // Get website
     $uri = JUri::getInstance();
     $website = $uri->toString(array('scheme', 'host'));
     $emailMode = $this->params->get('email_mode', 'plain');
     // Route project URI
     $appSite = JApplicationCms::getInstance('site');
     $router = $appSite->getRouter('site');
     $routedUri = $router->build(CrowdfundingHelperRoute::getDetailsRoute($project->slug, $project->catslug));
     if ($routedUri instanceof JUri) {
         $routedUri = $routedUri->toString();
     }
     if (0 === strpos($routedUri, '/administrator')) {
         $routedUri = str_replace('/administrator', '', $routedUri);
     }
     // Prepare data for parsing
     $data = array('site_name' => $app->get('sitename'), 'site_url' => JUri::root(), 'item_title' => $project->title, 'item_url' => $website . $routedUri);
     $email = new Emailtemplates\Email();
     $email->setDb(JFactory::getDbo());
     $email->load($emailId);
     if (!$email->getSenderName()) {
         $email->setSenderName($app->get('fromname'));
     }
     if (!$email->getSenderEmail()) {
         $email->setSenderEmail($app->get('mailfrom'));
     }
     $recipientName = $project->name;
     $recipientMail = $project->email;
     // Prepare data for parsing
     $data['sender_name'] = $email->getSenderName();
     $data['sender_email'] = $email->getSenderEmail();
     $data['recipient_name'] = $recipientName;
     $data['recipient_email'] = $recipientMail;
     $email->parse($data);
     $subject = $email->getSubject();
     $body = $email->getBody($emailMode);
     $mailer = JFactory::getMailer();
     if (strcmp('html', $emailMode) === 0) {
         // Send as HTML message
         $result = $mailer->sendMail($email->getSenderEmail(), $email->getSenderName(), $recipientMail, $subject, $body, Prism\Constants::MAIL_MODE_HTML);
     } else {
         // Send as plain text.
         $result = $mailer->sendMail($email->getSenderEmail(), $email->getSenderName(), $recipientMail, $subject, $body, Prism\Constants::MAIL_MODE_PLAIN);
     }
     // Log the error.
     if ($result !== true) {
         JLog::add($this->errorPrefix . $mailer->ErrorInfo, JLog::WARNING, 'com_crowdfunding');
         return false;
     }
     return true;
 }
 protected function sendReportMail($report, $emailId)
 {
     $app = JFactory::getApplication();
     /** @var $app JApplicationSite */
     // Send mail to the administrator
     if (!$emailId) {
         return false;
     }
     // Get website
     $uri = JUri::getInstance();
     $website = $uri->toString(array('scheme', 'host'));
     $emailMode = $this->params->get('email_mode', 'plain');
     // Get project
     $project = Crowdfunding\Project::getInstance(JFactory::getDbo(), $report->project_id);
     // Prepare data for parsing
     $data = array('site_name' => $app->get('sitename'), 'site_url' => JUri::root(), 'item_title' => $project->getTitle(), 'item_url' => $website . JRoute::_(CrowdfundingHelperRoute::getDetailsRoute($project->getSlug(), $project->getCatSlug())), 'report_subject' => $report->subject, 'report_description' => $report->description);
     $email = new Emailtemplates\Email();
     $email->setDb(JFactory::getDbo());
     $email->load($emailId);
     if (!$email->getSenderName()) {
         $email->setSenderName($app->get('fromname'));
     }
     if (!$email->getSenderEmail()) {
         $email->setSenderEmail($app->get('mailfrom'));
     }
     // Prepare recipient data.
     $componentParams = JComponentHelper::getParams('com_crowdfunding');
     /** @var  $componentParams Joomla\Registry\Registry */
     $recipientId = (int) $componentParams->get('administrator_id');
     if ($recipientId > 0) {
         $recipient = JFactory::getUser($recipientId);
         $recipientName = $recipient->get('name');
         $recipientMail = $recipient->get('email');
     } else {
         $recipientName = $app->get('fromname');
         $recipientMail = $app->get('mailfrom');
     }
     // Prepare data for parsing
     $data['sender_name'] = $email->getSenderName();
     $data['sender_email'] = $email->getSenderEmail();
     $data['recipient_name'] = $recipientName;
     $data['recipient_email'] = $recipientMail;
     $email->parse($data);
     $subject = $email->getSubject();
     $body = $email->getBody($emailMode);
     $mailer = JFactory::getMailer();
     if (strcmp('html', $emailMode) === 0) {
         // Send as HTML message
         $result = $mailer->sendMail($email->getSenderEmail(), $email->getSenderName(), $recipientMail, $subject, $body, Prism\Constants::MAIL_MODE_HTML);
     } else {
         // Send as plain text.
         $result = $mailer->sendMail($email->getSenderEmail(), $email->getSenderName(), $recipientMail, $subject, $body, Prism\Constants::MAIL_MODE_PLAIN);
     }
     // Log the error.
     if ($result !== true) {
         $this->log->add(JText::sprintf('PLG_CONTENT_CROWDFUNDINGADMINMAIL_ERROR_SEND_MAIL', $this->name), 'PLG_CONTENT_ADMIN_EMAIL_ERROR', JText::sprintf('PLG_CONTENT_CROWDFUNDINGADMINMAIL_ERROR_SEND_MAIL_NOTE', $mailer->ErrorInfo));
         return false;
     }
     return true;
 }
Ejemplo n.º 22
0
            ?>
"
                             alt="<?php 
            echo $this->escape($item->title);
            ?>
" width="200"
                             height="200" />
                    <?php 
        }
        ?>
                </a>

                <div class="caption height-150px absolute-bottom">
                    <h3>
                        <a href="<?php 
        echo JRoute::_(CrowdfundingHelperRoute::getCategoryRoute($item->slug));
        ?>
">
                            <?php 
        echo $this->escape($item->title);
        ?>
                        </a>
                        <?php 
        if ($this->displayProjectsNumber) {
            $number = !array_key_exists($item->id, $this->projectsNumber) ? 0 : $this->projectsNumber[$item->id]['number'];
            echo '( ' . $number . ' )';
        }
        ?>
                    </h3>
                    <?php 
        if ((bool) $this->params->get('categories_display_description', true)) {
Ejemplo n.º 23
0
 protected function getCancelUrl($slug, $catslug)
 {
     $page = String::trim($this->params->get('cancel_url'));
     if (!$page) {
         $uri = \JUri::getInstance();
         $page = $uri->toString(array("scheme", "host")) . \JRoute::_(\CrowdfundingHelperRoute::getBackingRoute($slug, $catslug, "default"), false);
     }
     return $page;
 }
Ejemplo n.º 24
0
 /**
  * Route URI to front-end.
  *
  * @param object  $item
  * @param string  $website
  * @param JRouter $routerSite
  *
  * @return string
  */
 public static function siteRoute($item, $website, $routerSite)
 {
     $routedUri = $routerSite->build(CrowdfundingHelperRoute::getDetailsRoute($item->slug, $item->catslug));
     if ($routedUri instanceof JUri) {
         $routedUri = $routedUri->toString();
     }
     if (false !== strpos($routedUri, "/administrator")) {
         $routedUri = str_replace("/administrator", "", $routedUri);
     }
     return $website . $routedUri;
 }
Ejemplo n.º 25
0
    ?>
"
                         width="<?php 
    echo $this->params->get('image_width');
    ?>
"
                         height="<?php 
    echo $this->params->get('image_height');
    ?>
">
                </a>

                <div class="caption">
                    <h3>
                        <a href="<?php 
    echo JRoute::_(CrowdfundingHelperRoute::getDetailsRoute($this->item->slug, $this->item->catslug));
    ?>
" target="_blank">
                            <?php 
    echo $this->escape($this->item->title);
    ?>
                        </a>
                    </h3>
                    <?php 
    if (!is_null($this->socialProfileLink)) {
        ?>
                        <div class="font-xxsmall">
                            <?php 
        echo JText::sprintf('COM_CROWDFUNDING_BY_S', JHtml::_('crowdfunding.socialProfileLink', $this->socialProfileLink, $this->item->user_name, array('target' => '_blank')));
        ?>
                        </div>
Ejemplo n.º 26
0
    ?>
    <div class="cfrewards<?php 
    echo $moduleclassSfx;
    ?>
">

        <div class="reward_title center"><?php 
    echo JText::_('MOD_CROWDFUNDINGREWARDS_PLEDGE_REWARDS');
    ?>
</div>
        <?php 
    foreach ($rewards as $reward) {
        ?>
            <div class="reward">
                <a href="<?php 
        echo JRoute::_(CrowdfundingHelperRoute::getBackingRoute($project->getSlug(), $project->getCatSlug(), 'default', $reward['id']));
        ?>
">
    			<span class="ramount">
    			<?php 
        echo JText::sprintf('MOD_CROWDFUNDINGREWARDS_INVEST_MORE', $amount->setValue($reward['amount'])->formatCurrency());
        ?>
    			</span>
                    <span class="rtitle"><?php 
        echo htmlspecialchars($reward['title'], ENT_QUOTES, 'UTF-8');
        ?>
</span>
                    <span class="rdesc"><?php 
        echo htmlspecialchars($reward['description'], ENT_QUOTES, 'UTF-8');
        ?>
</span>
Ejemplo n.º 27
0
    ?>
</a>
                    <?php 
}
?>
                </li>

                <li <?php 
echo $active["share"] ? 'class="active"' : '';
?>
>
                    <?php 
if (!empty($displayData->paymentSession->step2)) {
    ?>
                        <a href="<?php 
    echo JRoute::_(CrowdfundingHelperRoute::getBackingRoute($displayData->item->slug, $displayData->item->catslug, "share"));
    ?>
">
                            (3) <?php 
    echo JText::_("COM_CROWDFUNDING_STEP_SHARE");
    ?>
                        </a>
                    <?php 
} else {
    ?>
                        <a href="javascript: void(0);"
                           class="disabled">(3) <?php 
    echo JText::_("COM_CROWDFUNDING_STEP_SHARE");
    ?>
</a>
                    <?php 
Ejemplo n.º 28
0
 public function process()
 {
     $app = JFactory::getApplication();
     /** @var $app JApplicationSite */
     // Check for request forgeries.
     $requestMethod = $app->input->getMethod();
     if (strcmp("POST", $requestMethod) == 0) {
         JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     } else {
         JSession::checkToken("get") or jexit(JText::_('JINVALID_TOKEN'));
     }
     // Get params
     $params = JComponentHelper::getParams("com_crowdfunding");
     /** @var  $params Joomla\Registry\Registry */
     // Get the data from the form
     $itemId = $this->input->getInt('id', 0);
     $rewardId = $this->input->getInt('rid', 0);
     // Get amount
     $amount = CrowdfundingHelper::parseAmount($this->input->getString("amount"));
     // Get user ID
     $user = JFactory::getUser();
     $userId = (int) $user->get("id");
     // Anonymous user ID
     $aUserId = "";
     $model = $this->getModel();
     /** @var $model CrowdfundingModelBacking */
     // Get the item
     $item = $model->getItem($itemId);
     $returnUrl = CrowdfundingHelperRoute::getBackingRoute($item->slug, $item->catslug);
     // Authorise the user
     if (!$user->authorise("crowdfunding.donate", "com_crowdfunding")) {
         $this->setRedirect(JRoute::_($returnUrl, false), JText::_('COM_CROWDFUNDING_ERROR_NO_PERMISSIONS'), "notice");
         return;
     }
     // Check for valid project
     if (empty($item->id)) {
         $this->setRedirect(JRoute::_(CrowdfundingHelperRoute::getDiscoverRoute()), JText::_('COM_CROWDFUNDING_ERROR_INVALID_PROJECT'), "notice");
         return;
     }
     // Check for maintenance (debug) state.
     if ($params->get("debug_payment_disabled", 0)) {
         $msg = Joomla\String\String::trim($params->get("debug_disabled_functionality_msg"));
         if (!$msg) {
             $msg = JText::_("COM_CROWDFUNDING_DEBUG_MODE_DEFAULT_MSG");
         }
         $this->setRedirect(JRoute::_($returnUrl, false), $msg, "notice");
         return;
     }
     // Check for agreed conditions from the user.
     if ($params->get("backing_terms", 0)) {
         $terms = $this->input->get("terms", 0, "int");
         if (!$terms) {
             $this->setRedirect(JRoute::_($returnUrl, false), JText::_("COM_CROWDFUNDING_ERROR_TERMS_NOT_ACCEPTED"), "notice");
             return;
         }
     }
     // Check for valid amount.
     if (!$amount) {
         $this->setRedirect(JRoute::_($returnUrl, false), JText::_("COM_CROWDFUNDING_ERROR_INVALID_AMOUNT"), "notice");
         return;
     }
     // Store payment process data
     // Get the payment process object and
     // store the selected data from the user.
     $paymentSessionContext = Crowdfunding\Constants::PAYMENT_SESSION_CONTEXT . $item->id;
     $paymentSessionLocal = $app->getUserState($paymentSessionContext);
     $paymentSessionLocal->step1 = true;
     $paymentSessionLocal->amount = $amount;
     $paymentSessionLocal->rewardId = $rewardId;
     $app->setUserState($paymentSessionContext, $paymentSessionLocal);
     // Generate hash user ID used for anonymous payment.
     if (!$userId) {
         $aUserId = $app->getUserState("auser_id");
         if (!$aUserId) {
             // Generate a hash ID for anonymous user.
             $anonymousUserId = new Prism\String();
             $anonymousUserId->generateRandomString(32);
             $aUserId = (string) $anonymousUserId;
             $app->setUserState("auser_id", $aUserId);
         }
     }
     $date = new JDate();
     // Create an intention record.
     $intentionId = 0;
     if (!empty($userId)) {
         $intentionKeys = array("user_id" => $userId, "project_id" => $item->id);
         $intention = new Crowdfunding\Intention(JFactory::getDbo());
         $intention->load($intentionKeys);
         $intentionData = array("user_id" => $userId, "project_id" => $item->id, "reward_id" => $rewardId, "record_date" => $date->toSql());
         $intention->bind($intentionData);
         $intention->store();
         $intentionId = $intention->getId();
     }
     // Create a payment session.
     $paymentSessionDatabase = new Crowdfunding\Payment\Session(JFactory::getDbo());
     $paymentSessionData = array("user_id" => $userId, "auser_id" => $aUserId, "project_id" => $item->id, "reward_id" => $rewardId, "record_date" => $date->toSql(), "session_id" => $paymentSessionLocal->session_id, "intention_id" => $intentionId);
     $paymentSessionDatabase->bind($paymentSessionData);
     $paymentSessionDatabase->store();
     // Redirect to next page
     $link = CrowdfundingHelperRoute::getBackingRoute($item->slug, $item->catslug, "payment");
     $this->setRedirect(JRoute::_($link, false));
 }
Ejemplo n.º 29
0
        
        <?php 
if (!$this->rewardsEnabledViaType) {
    // Get next layout
    $nextLayout = strcmp($this->params->get("project_wizard_type", "five_steps"), "five_steps") == 0 ? "manager" : "extras";
    ?>
            <p class="alert alert-info mt-10">
                <span class="glyphicon glyphicon-info"></span>
                <?php 
    echo JText::_("COM_CROWDFUNDING_NOTE_REWARDS_CREATING_NOT_ALLOWED");
    ?>
            </p>

            <div class="cf-rewards-submit-btn">
                <a class="btn btn-primary" href="<?php 
    echo JRoute::_(CrowdfundingHelperRoute::getFormRoute($this->item->id, $nextLayout));
    ?>
">
                    <span class="glyphicon glyphicon-ok"></span>
                    <?php 
    echo JText::_("COM_CROWDFUNDING_CONTINUE");
    ?>
                </a>
            </div>

        <?php 
} else {
    ?>
        
            <div class="cf-rewards-submit-btn">
                <button class="btn btn-primary" <?php 
Ejemplo n.º 30
0
 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));
 }