コード例 #1
0
ファイル: currency.php プロジェクト: phpsource/CrowdFunding
 /**
  * Create an object or return existing one.
  *
  * <code>
  * $currencyId = 1;
  *
  * $options    = new JRegistry();
  * $options->set("intl", true);
  * $options->set("format", "2/./,");
  *
  * $currency   = CrowdFundingCurrency::getInstance(JFactory::getDbo(), $currencyId, $options);
  * </code>
  *
  * @param JDatabaseDriver $db
  * @param int             $id
  * @param Joomla\Registry\Registry             $options
  *
  * @return null|CrowdFundingCurrency
  */
 public static function getInstance(JDatabaseDriver $db, $id, $options = null)
 {
     if (!isset(self::$instances[$id])) {
         $item = new CrowdFundingCurrency($db);
         $item->load($id);
         if (!is_null($options) and $options instanceof JRegistry) {
             $item->setOption("intl", $options->get("locale_intl", false));
             $item->setOption("format", $options->get("amount_format", false));
         }
         self::$instances[$id] = $item;
     }
     return self::$instances[$id];
 }
コード例 #2
0
ファイル: view.html.php プロジェクト: phpsource/CrowdFunding
 public function display($tpl = null)
 {
     // Initialise variables
     $this->state = $this->get("State");
     $this->items = $this->get('Items');
     $this->pagination = $this->get('Pagination');
     // Get params
     /** @var  $params Joomla\Registry\Registry */
     $params = $this->state->get("params");
     $this->params = $params;
     $this->imageWidth = $this->params->get("image_width", 200);
     $this->imageHeight = $this->params->get("image_height", 200);
     $this->titleLength = $this->params->get("discover_title_length", 0);
     $this->descriptionLength = $this->params->get("discover_description_length", 0);
     $model = $this->getModel();
     /** @var @model CrowdFundingModelFeatured * */
     $this->numberInRow = $this->params->get("featured_items_row", 3);
     $this->items = $model->prepareItems($this->items, $this->numberInRow);
     // Get the folder with images
     $this->imageFolder = $params->get("images_directory", "images/crowdfunding");
     // Get currency
     jimport("crowdfunding.currency");
     $currencyId = $this->params->get("project_currency");
     $this->currency = CrowdFundingCurrency::getInstance(JFactory::getDbo(), $currencyId, $this->params);
     $this->displayCreator = $this->params->get("integration_display_creator", true);
     // Prepare integration. Load avatars and profiles.
     if (!empty($this->displayCreator)) {
         $this->prepareIntegration($this->items, $this->params);
     }
     $this->prepareDocument();
     $this->version = new CrowdFundingVersion();
     parent::display($tpl);
 }
コード例 #3
0
ファイル: view.html.php プロジェクト: phpsource/CrowdFunding
 public function display($tpl = null)
 {
     $this->state = $this->get('State');
     $this->items = $this->get('Items');
     $this->pagination = $this->get('Pagination');
     $this->params = $this->state->get("params");
     jimport("crowdfunding.currency");
     $currencyId = $this->state->params->get("project_currency");
     $this->currency = CrowdFundingCurrency::getInstance(JFactory::getDbo(), $currencyId, $this->params);
     // Get projects IDs
     $projectsIds = array();
     foreach ($this->items as $item) {
         $projectsIds[] = $item->id;
     }
     // Get number of rewards.
     jimport("crowdfunding.projects");
     $projects = new CrowdFundingProjects(JFactory::getDbo());
     $this->rewards = $projects->getRewardsNumber($projectsIds);
     // Add submenu
     CrowdFundingHelper::addSubmenu($this->getName());
     // Prepare sorting data
     $this->prepareSorting();
     // Prepare actions
     $this->addToolbar();
     $this->addSidebar();
     $this->setDocument();
     parent::display($tpl);
 }
コード例 #4
0
ファイル: cfamount.php プロジェクト: phpsource/CrowdFunding
 /**
  * Method to get the field input markup.
  *
  * @return  string  The field input markup.
  *
  * @since   11.1
  */
 protected function getInput()
 {
     // Initialize some field attributes.
     $size = $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : '';
     $maxLength = $this->element['maxlength'] ? ' maxlength="' . (int) $this->element['maxlength'] . '"' : '';
     $readonly = (string) $this->element['readonly'] == 'true' ? ' readonly="readonly"' : '';
     $disabled = (string) $this->element['disabled'] == 'true' ? ' disabled="disabled"' : '';
     $class = !empty($this->element['class']) ? ' class="' . (string) $this->element['class'] . '"' : "";
     // Initialize JavaScript field attributes.
     $onchange = $this->element['onchange'] ? ' onchange="' . (string) $this->element['onchange'] . '"' : '';
     $params = JComponentHelper::getParams("com_crowdfunding");
     /** @var  $params Joomla\Registry\Registry */
     $currencyId = $params->get("project_currency");
     jimport("crowdfunding.currency");
     $currency = CrowdFundingCurrency::getInstance(JFactory::getDbo(), $currencyId, $params);
     if ($currency->getSymbol()) {
         // Prepended
         $html = '<div class="input-prepend input-append"><span class="add-on">' . $currency->getSymbol() . '</span>';
     } else {
         // Append
         $html = '<div class="input-append">';
     }
     $html .= '<input type="text" name="' . $this->name . '" id="' . $this->id . '"' . ' value="' . htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8') . '"' . $class . $size . $disabled . $readonly . $onchange . $maxLength . '/>';
     // Appended
     $html .= '<span class="add-on">' . $currency->getAbbr() . '</span></div>';
     return $html;
 }
コード例 #5
0
ファイル: view.html.php プロジェクト: phpsource/CrowdFunding
 public function display($tpl = null)
 {
     $app = JFactory::getApplication();
     /** @var $app JApplicationSite * */
     // Get model state.
     $this->state = $this->get('State');
     $this->item = $this->get("Item");
     // Get params
     /** @var  $params Joomla\Registry\Registry */
     $params = $this->state->get("params");
     $this->params = $params;
     $this->imageFolder = $this->params->get("images_directory", "images/crowdfunding");
     if (!$this->item) {
         $app->enqueueMessage(JText::_("COM_CROWDFUNDING_ERROR_INVALID_PROJECT"), "notice");
         $app->redirect(JRoute::_('index.php?option=com_crowdfunding&view=discover', false));
         return;
     }
     // Get currency
     jimport("crowdfunding.currency");
     $currencyId = $this->params->get("project_currency");
     $this->currency = CrowdFundingCurrency::getInstance(JFactory::getDbo(), $currencyId, $this->params);
     // Get a social platform for integration.
     $this->socialPlatform = $this->params->get("integration_social_platform");
     // 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;
     $layout = $this->getLayout();
     switch ($layout) {
         case "email":
             if (!$this->params->get("security_display_friend_form", 0)) {
                 $app->enqueueMessage(JText::_("COM_CROWDFUNDING_ERROR_CANT_SEND_MAIL"), "notice");
                 $app->redirect(JRoute::_($this->item->link, false));
                 return;
             }
             $this->prepareEmailForm($this->item);
             break;
         default:
             // Embed HTML code
             $this->embedCode = $this->prepareEmbedCode($this->item, $host);
             break;
     }
     $this->prepareDocument();
     $this->version = new CrowdFundingVersion();
     parent::display($tpl);
 }
コード例 #6
0
ファイル: view.html.php プロジェクト: phpsource/CrowdFunding
 /**
  * Display the view
  */
 public function display($tpl = null)
 {
     $app = JFactory::getApplication();
     /** @var $app JApplicationAdministrator */
     // Get user ID
     $userId = $app->input->getInt("id");
     $model = $this->getModel();
     $this->state = $model->getState();
     $this->item = $model->getItem($userId);
     $this->params = JComponentHelper::getParams($this->option);
     // Get currency
     jimport("crowdfunding.currency");
     $currencyId = $this->params->get("project_currency");
     $this->currency = CrowdFundingCurrency::getInstance(JFactory::getDbo(), $currencyId, $this->params);
     // Get number of rewards.
     jimport("crowdfunding.statistics.user");
     $statistics = new CrowdFundingStatisticsUser(JFactory::getDbo(), $this->item->id);
     $this->projects = $statistics->getProjectsNumber();
     $amounts = $statistics->getAmounts();
     if (!empty($amounts["invested"])) {
         $this->investedAmount = (double) $amounts["invested"]->amount;
         $this->investedTransactions = (int) $amounts["invested"]->number;
     }
     if (!empty($amounts["received"])) {
         $this->receivedAmount = (double) $amounts["received"]->amount;
         $this->receivedTransactions = (int) $amounts["received"]->number;
     }
     // Get social profile
     $socialPlatform = $this->params->get("integration_social_platform");
     if (!empty($socialPlatform)) {
         $options = array("social_platform" => $socialPlatform, "user_id" => $this->item->id);
         jimport("itprism.integrate.profile.builder");
         $profileBuilder = new ITPrismIntegrateProfileBuilder($options);
         $profileBuilder->build();
         $this->socialProfile = $profileBuilder->getProfile();
         $this->profileLink = $this->socialProfile->getLink();
     }
     jimport("crowdfunding.user.rewards");
     $this->rewards = new CrowdFundingUserRewards(JFactory::getDbo());
     $this->rewards->load($this->item->id);
     $this->returnUrl = base64_encode("index.php?option=com_crowdfunding&view=user&id=" . $this->item->id);
     // Prepare actions, behaviors, scripts and document
     $this->addToolbar();
     $this->setDocument();
     parent::display($tpl);
 }
コード例 #7
0
ファイル: view.html.php プロジェクト: phpsource/CrowdFunding
 public function display($tpl = null)
 {
     // Initialise variables
     $this->items = $this->get('Items');
     $this->state = $this->get('State');
     $this->params = $this->state->get('params');
     if (!empty($this->items)) {
         jimport("crowdfunding.currency");
         $currencyId = $this->params->get("project_currency");
         $this->currency = CrowdFundingCurrency::getInstance(JFactory::getDbo(), $currencyId, $this->params);
     }
     // 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();
     $this->version = new CrowdFundingVersion();
     parent::display($tpl);
 }
コード例 #8
0
ファイル: view.html.php プロジェクト: phpsource/CrowdFunding
 public function display($tpl = null)
 {
     $this->state = $this->get('State');
     $this->items = $this->get('Items');
     $this->pagination = $this->get('Pagination');
     $this->params = $this->state->get("params");
     jimport("crowdfunding.currency");
     $currencyId = $this->state->params->get("project_currency");
     $this->currency = CrowdFundingCurrency::getInstance(JFactory::getDbo(), $currencyId, $this->params);
     // Add submenu
     CrowdFundingHelper::addSubmenu("projects");
     $projectId = $this->state->get("project_id");
     $this->projectTitle = CrowdFundingHelper::getProjectTitle($projectId);
     // Prepare sorting data
     $this->prepareSorting();
     // Prepare actions
     $this->addToolbar();
     $this->addSidebar();
     $this->setDocument();
     parent::display($tpl);
 }
コード例 #9
0
ファイル: view.html.php プロジェクト: phpsource/CrowdFunding
 public function display($tpl = null)
 {
     $this->state = $this->get("State");
     $this->params = $this->state->get("params");
     $this->version = new CrowdFundingVersion();
     // Load ITPrism library version
     jimport("itprism.version");
     if (!class_exists("ITPrismVersion")) {
         $this->itprismVersion = JText::_("COM_CROWDFUNDING_ITPRISM_LIBRARY_DOWNLOAD");
     } else {
         $itprismVersion = new ITPrismVersion();
         $this->itprismVersion = $itprismVersion->getShortVersion();
     }
     // Get popular projects.
     jimport("crowdfunding.statistics.projects.popular");
     $this->popular = new CrowdFundingStatisticsProjectsPopular(JFactory::getDbo());
     $this->popular->load(5);
     // Get popular most funded.
     jimport("crowdfunding.statistics.projects.mostfunded");
     $this->mostFunded = new CrowdFundingStatisticsProjectsMostFunded(JFactory::getDbo());
     $this->mostFunded->load(5);
     // Get latest started.
     jimport("crowdfunding.statistics.projects.latest");
     $this->latestStarted = new CrowdFundingStatisticsProjectsLatest(JFactory::getDbo());
     $this->latestStarted->load(5);
     // Get latest created.
     $this->latestCreated = new CrowdFundingStatisticsProjectsLatest(JFactory::getDbo());
     $this->latestCreated->loadByCreated(5);
     // Get currency.
     jimport("crowdfunding.currency");
     $currencyId = $this->params->get("project_currency");
     $this->currency = CrowdFundingCurrency::getInstance(JFactory::getDbo(), $currencyId, $this->params);
     // Add submenu
     CrowdFundingHelper::addSubmenu($this->getName());
     $this->addToolbar();
     $this->addSidebar();
     $this->setDocument();
     parent::display($tpl);
 }
コード例 #10
0
ファイル: view.html.php プロジェクト: phpsource/CrowdFunding
 public function display($tpl = null)
 {
     $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)) {
         jimport("crowdfunding.currency");
         $currencyId = $this->params->get("project_currency");
         $this->currency = CrowdFundingCurrency::getInstance(JFactory::getDbo(), $currencyId, $this->params);
     }
     // 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();
     $this->version = new CrowdFundingVersion();
     parent::display($tpl);
 }
コード例 #11
0
ファイル: payments.php プロジェクト: phpsource/CrowdFunding
 /**
  * @param int $projectId
  * @param Joomla\Registry\Registry $params
  *
  * @return stdClass
  * @throws UnexpectedValueException
  */
 protected function prepareItem($projectId, $params)
 {
     jimport("crowdfunding.project");
     $project = new CrowdFundingProject(JFactory::getDbo());
     $project->load($projectId);
     if (!$project->getId()) {
         throw new UnexpectedValueException(JText::_("COM_CROWDFUNDING_ERROR_INVALID_PROJECT"));
     }
     if ($project->isCompleted()) {
         throw new UnexpectedValueException(JText::_("COM_CROWDFUNDING_ERROR_COMPLETED_PROJECT"));
     }
     // Get currency
     jimport("crowdfunding.currency");
     $currencyId = $params->get("project_currency");
     $this->currency = CrowdFundingCurrency::getInstance(JFactory::getDbo(), $currencyId, $params);
     $item = new stdClass();
     $item->id = $project->getId();
     $item->title = $project->getTitle();
     $item->slug = $project->getSlug();
     $item->catslug = $project->getCatSlug();
     $item->rewardId = $this->paymentProcess->rewardId;
     $item->amount = $this->paymentProcess->amount;
     $item->currency = $this->currency->getAbbr();
     return $item;
 }
コード例 #12
0
ファイル: plugin.php プロジェクト: phpsource/CrowdFunding
 /**
  * Send emails to the administrator, project owner and the user who have made a donation.
  *
  * @param object $project
  * @param object $transaction
  * @param Joomla\Registry\Registry $params
  */
 protected function sendMails($project, $transaction, $params)
 {
     $app = JFactory::getApplication();
     /** @var $app JApplicationSite */
     // Get website
     $uri = JUri::getInstance();
     $website = $uri->toString(array("scheme", "host"));
     $emailMode = $this->params->get("email_mode", "plain");
     jimport("crowdfunding.currency");
     $currencyId = $params->get("project_currency");
     $currency = CrowdFundingCurrency::getInstance(JFactory::getDbo(), $currencyId, $params);
     // Prepare data for parsing
     $data = array("site_name" => $app->get("sitename"), "site_url" => JUri::root(), "item_title" => $project->title, "item_url" => $website . JRoute::_(CrowdFundingHelperRoute::getDetailsRoute($project->slug, $project->catslug)), "amount" => $currency->getAmountString($transaction->txn_amount), "transaction_id" => $transaction->txn_id);
     // Send mail to the administrator
     $emailId = $this->params->get("admin_mail_id", 0);
     if (!empty($emailId)) {
         jimport("crowdfunding.email");
         $email = new CrowdFundingEmail();
         $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");
         $recipientId = $componentParams->get("administrator_id");
         if (!empty($recipientId)) {
             $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
             $return = $mailer->sendMail($email->getSenderEmail(), $email->getSenderName(), $recipientMail, $subject, $body, CrowdFundingConstants::MAIL_MODE_HTML);
         } else {
             // Send as plain text.
             $return = $mailer->sendMail($email->getSenderEmail(), $email->getSenderName(), $recipientMail, $subject, $body, CrowdFundingConstants::MAIL_MODE_PLAIN);
         }
         // Check for an error.
         if ($return !== true) {
             $this->log->add(JText::_($this->textPrefix . "_ERROR_MAIL_SENDING_ADMIN"), $this->debugType);
         }
     }
     // Send mail to project owner
     $emailId = $this->params->get("creator_mail_id", 0);
     if (!empty($emailId)) {
         $email = new CrowdFundingEmail();
         $email->setDb(JFactory::getDbo());
         $email->load($emailId);
         if (!$email->getSenderName()) {
             $email->setSenderName($app->get("fromname"));
         }
         if (!$email->getSenderEmail()) {
             $email->setSenderEmail($app->get("mailfrom"));
         }
         $user = JFactory::getUser($transaction->receiver_id);
         $recipientName = $user->get("name");
         $recipientMail = $user->get("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
             $return = $mailer->sendMail($email->getSenderEmail(), $email->getSenderName(), $recipientMail, $subject, $body, CrowdFundingConstants::MAIL_MODE_HTML);
         } else {
             // Send as plain text.
             $return = $mailer->sendMail($email->getSenderEmail(), $email->getSenderName(), $recipientMail, $subject, $body, CrowdFundingConstants::MAIL_MODE_PLAIN);
         }
         // Check for an error.
         if ($return !== true) {
             // Log error
             $this->log->add(JText::_($this->textPrefix . "_ERROR_MAIL_SENDING_PROJECT_OWNER"), $this->debugType);
         }
     }
     // Send mail to backer
     $emailId = $this->params->get("user_mail_id", 0);
     $investorId = $transaction->investor_id;
     if (!empty($emailId) and !empty($investorId)) {
         $email = new CrowdFundingEmail();
         $email->setDb(JFactory::getDbo());
         $email->load($emailId);
         if (!$email->getSenderName()) {
             $email->setSenderName($app->get("fromname"));
         }
         if (!$email->getSenderEmail()) {
             $email->setSenderEmail($app->get("mailfrom"));
         }
         $user = JFactory::getUser($investorId);
         $recipientName = $user->get("name");
         $recipientMail = $user->get("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
             $return = $mailer->sendMail($email->getSenderEmail(), $email->getSenderName(), $recipientMail, $subject, $body, CrowdFundingConstants::MAIL_MODE_HTML);
         } else {
             // Send as plain text.
             $return = $mailer->sendMail($email->getSenderEmail(), $email->getSenderName(), $recipientMail, $subject, $body, CrowdFundingConstants::MAIL_MODE_PLAIN);
         }
         // Check for an error.
         if ($return !== true) {
             // Log error
             $this->log->add(JText::_($this->textPrefix . "_ERROR_MAIL_SENDING_USER"), $this->debugType);
         }
     }
 }
コード例 #13
0
ファイル: paypal.php プロジェクト: phpsource/CrowdFunding
 /**
  * This method processes transaction data that comes from PayPal instant notifier.
  *
  * @param string    $context This string gives information about that where it has been executed the trigger.
  * @param Joomla\Registry\Registry $params  The parameters of the component
  *
  * @return null|array
  */
 public function onPaymenNotify($context, &$params)
 {
     if (strcmp("com_crowdfunding.notify.paypal", $context) != 0) {
         return null;
     }
     $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("raw", $docType) != 0) {
         return null;
     }
     // Validate request method
     $requestMethod = $app->input->getMethod();
     if (strcmp("POST", $requestMethod) != 0) {
         $this->log->add(JText::_($this->textPrefix . "_ERROR_INVALID_REQUEST_METHOD"), $this->debugType, JText::sprintf($this->textPrefix . "_ERROR_INVALID_TRANSACTION_REQUEST_METHOD", $requestMethod));
         return null;
     }
     // DEBUG DATA
     JDEBUG ? $this->log->add(JText::_($this->textPrefix . "_DEBUG_RESPONSE"), $this->debugType, $_POST) : null;
     // Decode custom data
     $custom = JArrayHelper::getValue($_POST, "custom");
     $custom = json_decode(base64_decode($custom), true);
     // DEBUG DATA
     JDEBUG ? $this->log->add(JText::_($this->textPrefix . "_DEBUG_CUSTOM"), $this->debugType, $custom) : null;
     // Verify gateway. Is it PayPal?
     if (!$this->isPayPalGateway($custom)) {
         $this->log->add(JText::_($this->textPrefix . "_ERROR_INVALID_PAYMENT_GATEWAY"), $this->debugType, array("custom" => $custom, "_POST" => $_POST));
         return null;
     }
     // Get PayPal URL
     $sandbox = $this->params->get('paypal_sandbox', 0);
     if (!$sandbox) {
         $url = JString::trim($this->params->get('paypal_url', "https://www.paypal.com/cgi-bin/webscr"));
     } else {
         $url = JString::trim($this->params->get('paypal_sandbox_url', "https://www.sandbox.paypal.com/cgi-bin/webscr"));
     }
     jimport("itprism.payment.paypal.ipn");
     $paypalIpn = new ITPrismPayPalIpn($url, $_POST);
     $loadCertificate = (bool) $this->params->get("paypal_load_certificate", 0);
     $paypalIpn->verify($loadCertificate);
     // DEBUG DATA
     JDEBUG ? $this->log->add(JText::_($this->textPrefix . "_DEBUG_VERIFY_OBJECT"), $this->debugType, $paypalIpn) : null;
     // Prepare the array that will be returned by this method
     $result = array("project" => null, "reward" => null, "transaction" => null, "payment_service" => "PayPal");
     if ($paypalIpn->isVerified()) {
         // Get currency
         jimport("crowdfunding.currency");
         $currencyId = $params->get("project_currency");
         $currency = CrowdFundingCurrency::getInstance(JFactory::getDbo(), $currencyId);
         // Get intention data
         $intentionId = JArrayHelper::getValue($custom, "intention_id", 0, "int");
         jimport("crowdfunding.intention");
         $intention = new CrowdFundingIntention(JFactory::getDbo());
         $intention->load($intentionId);
         // Get payment session as intention.
         if (!$intention->getId()) {
             jimport("crowdfunding.payment.session");
             $keys = array("intention_id" => $intentionId);
             $intention = new CrowdFundingPaymentSession(JFactory::getDbo());
             $intention->load($keys);
         }
         // DEBUG DATA
         JDEBUG ? $this->log->add(JText::_($this->textPrefix . "_DEBUG_INTENTION"), $this->debugType, $intention->getProperties()) : null;
         // Validate transaction data
         $validData = $this->validateData($_POST, $currency->getAbbr(), $intention);
         if (is_null($validData)) {
             return $result;
         }
         // DEBUG DATA
         JDEBUG ? $this->log->add(JText::_($this->textPrefix . "_DEBUG_VALID_DATA"), $this->debugType, $validData) : null;
         // Get project.
         jimport("crowdfunding.project");
         $projectId = JArrayHelper::getValue($validData, "project_id");
         $project = CrowdFundingProject::getInstance(JFactory::getDbo(), $projectId);
         // DEBUG DATA
         JDEBUG ? $this->log->add(JText::_($this->textPrefix . "_DEBUG_PROJECT_OBJECT"), $this->debugType, $project->getProperties()) : null;
         // Check for valid project
         if (!$project->getId()) {
             // Log data in the database
             $this->log->add(JText::_($this->textPrefix . "_ERROR_INVALID_PROJECT"), $this->debugType, $validData);
             return $result;
         }
         // Set the receiver of funds
         $validData["receiver_id"] = $project->getUserId();
         // Save transaction data.
         // If it is not completed, return empty results.
         // If it is complete, continue with process transaction data
         $transactionData = $this->storeTransaction($validData, $project);
         if (is_null($transactionData)) {
             return $result;
         }
         // Update the number of distributed reward.
         $rewardId = JArrayHelper::getValue($transactionData, "reward_id");
         $reward = null;
         if (!empty($rewardId)) {
             $reward = $this->updateReward($transactionData);
             // Validate the reward.
             if (!$reward) {
                 $transactionData["reward_id"] = 0;
             }
         }
         // Generate object of data, based on the transaction properties.
         $result["transaction"] = JArrayHelper::toObject($transactionData);
         // Generate object of data based on the project properties
         $properties = $project->getProperties();
         $result["project"] = JArrayHelper::toObject($properties);
         // Generate object of data based on the reward properties
         if (!empty($reward)) {
             $properties = $reward->getProperties();
             $result["reward"] = JArrayHelper::toObject($properties);
         }
         // DEBUG DATA
         JDEBUG ? $this->log->add(JText::_($this->textPrefix . "_DEBUG_RESULT_DATA"), $this->debugType, $result) : null;
         // Remove intention
         $txnStatus = isset($result["transaction"]->txn_status) ? $result["transaction"]->txn_status : null;
         $this->removeIntention($intention, $txnStatus);
         unset($intention);
     } else {
         // Log error
         $this->log->add(JText::_($this->textPrefix . "_ERROR_INVALID_TRANSACTION_DATA"), $this->debugType, array("error message" => $paypalIpn->getError(), "paypalVerify" => $paypalIpn, "_POST" => $_POST));
     }
     return $result;
 }
コード例 #14
0
ファイル: currencies.php プロジェクト: phpsource/CrowdFunding
 /**
  * Create a currency object and return it.
  *
  * <code>
  * $ids = array(1,2,3,4,5);
  * $currencies   = new CrowdFundingCurrencies(JFactory::getDbo());
  * $currencies->load($ids);
  *
  * $currency = $currencies->getCurrency(1);
  * </code>
  *
  * @param int $id
  *
  * @throws UnexpectedValueException
  *
  * @return null|CrowdFundingCurrency
  */
 public function getCurrency($id)
 {
     if (!$id) {
         throw new UnexpectedValueException(JText::_("LIB_CROWDFUNDING_INVALID_CURRENCY_ID"));
     }
     $currency = null;
     foreach ($this->items as $item) {
         if ($id == $item["id"]) {
             $currency = new CrowdFundingCurrency();
             $currency->bind($item);
             break;
         }
     }
     return $currency;
 }
コード例 #15
0
ファイル: view.html.php プロジェクト: phpsource/CrowdFunding
 protected function prepareFundersScreen()
 {
     $model = JModelLegacy::getInstance("Funders", "CrowdFundingModel", $config = array('ignore_request' => false));
     $this->items = $model->getItems();
     // Get users IDs
     $usersIds = array();
     foreach ($this->items as $item) {
         $usersIds[] = $item->id;
     }
     // Create a currency object if I have to display funders amounts.
     $this->displayAmounts = $this->params->get("funders_display_amounts", 0);
     if ($this->displayAmounts) {
         jimport("crowdfunding.currency");
         $currencyId = $this->params->get("project_currency");
         $this->currency = CrowdFundingCurrency::getInstance(JFactory::getDbo(), $currencyId);
     }
     // Prepare integration. Load avatars and profiles.
     $this->prepareIntegration($usersIds, $this->params);
 }
コード例 #16
0
ファイル: view.html.php プロジェクト: phpsource/CrowdFunding
 protected function prepareManager()
 {
     $model = JModelLegacy::getInstance("Manager", "CrowdFundingModel", $config = array('ignore_request' => false));
     /** @var $model CrowdFundingModelManager */
     // Get state
     /** @var  $state Joomla\Registry\Registry */
     $this->state = $model->getState();
     // Get params
     /** @var  $params Joomla\Registry\Registry */
     $params = $this->state->get("params");
     $this->params = $params;
     $this->imageWidth = $this->params->get("image_width", 200);
     $this->imageHeight = $this->params->get("image_height", 200);
     $this->titleLength = $this->params->get("discover_title_length", 0);
     $this->descriptionLength = $this->params->get("discover_description_length", 0);
     // Get the folder with images
     $this->imageFolder = $params->get("images_directory", "images/crowdfunding");
     // Filter the URL.
     $uri = JUri::getInstance();
     $filter = JFilterInput::getInstance();
     $this->returnUrl = $filter->clean($uri->toString());
     // Get item
     $itemId = $this->state->get('manager.id');
     // Create a currency object.
     jimport("crowdfunding.currency");
     $currencyId = $this->params->get("project_currency");
     $this->currency = CrowdFundingCurrency::getInstance(JFactory::getDbo(), $currencyId, $this->params);
     $this->item = $model->getItem($itemId, $this->userId);
     if (empty($this->item->id)) {
         $app = JFactory::getApplication();
         /** $app JApplicationSite */
         $app->enqueueMessage(JText::_("COM_CROWDFUNDING_ERROR_SOMETHING_WRONG"), "notice");
         $app->redirect(JRoute::_(CrowdFundingHelperRoute::getDiscoverRoute()));
         return;
     }
     jimport("crowdfunding.statistics.project");
     $statistics = new CrowdFundingStatisticsProject(JFactory::getDbo(), $this->item->id);
     $this->statistics = array("updates" => $statistics->getUpdatesNumber(), "comments" => $statistics->getCommentsNumber(), "funders" => $statistics->getTransactionsNumber());
     // Get rewards
     jimport("crowdfunding.rewards");
     $this->rewards = new CrowdFundingRewards(JFactory::getDbo());
     $this->rewards->load($this->item->id);
     $this->pathwayName = JText::_("COM_CROWDFUNDING_STEP_MANAGER");
 }
コード例 #17
0
ファイル: view.html.php プロジェクト: phpsource/CrowdFunding
 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));
 }
コード例 #18
0
if (!$projectId) {
    echo JText::_("MOD_CROWDFUNDINGDETAILS_ERROR_INVALID_PROJECT");
    return;
}
// Get project
jimport("crowdfunding.project");
$project = CrowdFundingProject::getInstance(JFactory::getDbo(), $projectId);
if (!$project->getId()) {
    echo JText::_("MOD_CROWDFUNDINGDETAILS_ERROR_INVALID_PROJECT");
    return;
}
// Get component params
$componentParams = JComponentHelper::getParams("com_crowdfunding");
/** @var  $componentParams Joomla\Registry\Registry */
$socialPlatform = $componentParams->get("integration_social_platform");
$imageFolder = $componentParams->get("images_directory", "images/crowdfunding");
// Get currency
jimport("crowdfunding.currency");
$currencyId = $componentParams->get("project_currency");
$currency = CrowdFundingCurrency::getInstance(JFactory::getDbo(), $currencyId, $componentParams);
// Get social platform and a link to the profile
jimport("itprism.integrate.profile." . JString::strtolower($socialPlatform));
$socialProfile = CrowdFundingHelper::getSocialProfile($project->getUserId(), $socialPlatform);
$socialProfileLink = !$socialProfile ? null : $socialProfile->getLink();
// Get amounts
$fundedAmount = $currency->getAmountString($project->getGoal());
$raised = $currency->getAmountString($project->getFunded());
// Prepare the value that I am going to display
$fundedPercents = JHtml::_("crowdfunding.funded", $project->getFundedPercent());
$user = JFactory::getUser($project->getUserId());
require JModuleHelper::getLayoutPath('mod_crowdfundingdetails', $params->get('layout', 'default'));