public function display($tpl = null) { $this->app = JFactory::getApplication(); /** @var $this->app JApplicationSite */ $this->option = JFactory::getApplication()->input->get('option'); $this->state = $this->get('State'); $this->item = $this->get('Item'); // Get params $this->params = $this->state->get('params'); /** @var $this->params Joomla\Registry\Registry */ $this->imageFolder = $this->params->get('images_directory', 'images/crowdfunding'); if (!$this->item) { $this->app->enqueueMessage(JText::_('COM_CROWDFUNDING_ERROR_INVALID_PROJECT'), 'notice'); $this->app->redirect(JRoute::_(CrowdfundingHelperRoute::getDiscoverRoute(), false)); return; } $container = Prism\Container::getContainer(); $this->money = $this->getMoneyFormatter($container, $this->params); // Integrate with social profile. $this->displayCreator = $this->params->get('integration_display_creator', true); // Prepare integration. Load avatars and profiles. if ($this->displayCreator and (is_object($this->item) and $this->item->user_id > 0)) { $socialProfile = CrowdfundingHelper::prepareIntegration($this->params->get('integration_social_platform'), $this->item->user_id); $this->socialProfileLink = !$socialProfile ? null : $socialProfile->getLink(); } // Set a link to project page $uri = JUri::getInstance(); $host = $uri->toString(array('scheme', 'host')); $this->item->link = $host . JRoute::_(CrowdfundingHelperRoute::getDetailsRoute($this->item->slug, $this->item->catslug), false); // Set a link to image $this->item->link_image = $host . '/' . $this->imageFolder . '/' . $this->item->image; $this->embedCode = $this->prepareEmbedCode($this->item, $host); $this->prepareDocument(); parent::display($tpl); }
public function display($tpl = null) { $this->app = JFactory::getApplication(); $this->option = JFactory::getApplication()->input->get('option'); // Get model state. $this->state = $this->get('State'); $this->item = $this->get('Item'); // Get params $this->params = $this->state->get('params'); /** @var $this->params Joomla\Registry\Registry */ $model = $this->getModel(); $userId = JFactory::getUser()->get('id'); if (!$this->item or $model->isRestricted($this->item, $userId)) { $this->app->enqueueMessage(JText::_('COM_CROWDFUNDING_ERROR_INVALID_PROJECT'), 'notice'); $this->app->redirect(JRoute::_('index.php?option=com_crowdfunding&view=discover', false)); return; } $this->container = Prism\Container::getContainer(); $this->prepareMoneyFormatter($this->container, $this->params); // Get the path to the images. $this->imageFolder = $this->params->get('images_directory', 'images/crowdfunding'); $this->defaultAvatar = JUri::base() . $this->params->get('integration_avatars_default'); $this->avatarsSize = $this->params->get('integration_avatars_size', 'small'); // Prepare the link that points to project page. $host = JUri::getInstance()->toString(array('scheme', 'host')); $this->item->link = $host . JRoute::_(CrowdfundingHelperRoute::getDetailsRoute($this->item->slug, $this->item->catslug)); // Prepare the link that points to project image. $this->item->link_image = $host . '/' . $this->imageFolder . '/' . $this->item->image; // Get the current screen. $this->screen = $this->app->input->getCmd('screen', 'home'); $this->prepareDocument(); // Import content plugins JPluginHelper::importPlugin('content'); switch ($this->screen) { case 'updates': $this->prepareUpdatesScreen(); break; case 'comments': $this->prepareCommentsScreen(); break; case 'funders': $this->prepareFundersScreen(); break; default: // Home break; } // Events $dispatcher = JEventDispatcher::getInstance(); $this->item->event = new stdClass(); $results = $dispatcher->trigger('onContentBeforeDisplay', array('com_crowdfunding.details', &$this->item, &$this->params)); $this->item->event->beforeDisplayContent = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentAfterDisplayMedia', array('com_crowdfunding.details', &$this->item, &$this->params)); $this->item->event->onContentAfterDisplayMedia = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentAfterDisplay', array('com_crowdfunding.details', &$this->item, &$this->params)); $this->item->event->onContentAfterDisplay = trim(implode("\n", $results)); // Count hits $model->hit($this->item->id); parent::display($tpl); }
public function display($tpl = null) { $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::_(CrowdfundingHelperRoute::getDiscoverRoute(), false)); return; } // Get currency // Get currency $currency = Crowdfunding\Currency::getInstance(JFactory::getDbo(), $this->params->get("project_currency")); $this->amount = new Crowdfunding\Amount($this->params); $this->amount->setCurrency($currency); // Integrate with social profile. $this->displayCreator = $this->params->get("integration_display_creator", true); // Prepare integration. Load avatars and profiles. if ($this->displayCreator and !empty($this->item->user_id)) { $socialProfilesBuilder = new Prism\Integration\Profile\Builder(array("social_platform" => $this->params->get("integration_social_platform"), "user_id" => $this->item->user_id)); $socialProfilesBuilder->build(); $socialProfile = $socialProfilesBuilder->getProfile(); $this->socialProfileLink = !$socialProfile ? null : $socialProfile->getLink(); } // Set a link to project page $uri = JUri::getInstance(); $host = $uri->toString(array("scheme", "host")); $this->item->link = $host . JRoute::_(CrowdfundingHelperRoute::getDetailsRoute($this->item->slug, $this->item->catslug), false); // Set a link to image $this->item->link_image = $host . "/" . $this->imageFolder . "/" . $this->item->image; $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(); parent::display($tpl); }
public function display($tpl = null) { $app = JFactory::getApplication(); /** @var $app JApplicationSite */ $this->option = JFactory::getApplication()->input->get('option'); $this->state = $this->get('State'); $this->item = $this->get('Item'); // Get params $this->params = $this->state->get('params'); /** @var $this->params Joomla\Registry\Registry */ $this->imageFolder = $this->params->get('images_directory', 'images/crowdfunding'); if (!$this->item) { $app->enqueueMessage(JText::_('COM_CROWDFUNDING_ERROR_INVALID_PROJECT'), 'notice'); $app->redirect(JRoute::_(CrowdfundingHelperRoute::getDiscoverRoute(), false)); return; } // Get currency // Get currency $currency = Crowdfunding\Currency::getInstance(JFactory::getDbo(), $this->params->get('project_currency')); $this->amount = new Crowdfunding\Amount($this->params); $this->amount->setCurrency($currency); // Integrate with social profile. $this->displayCreator = $this->params->get('integration_display_creator', true); // Prepare integration. Load avatars and profiles. if ($this->displayCreator and (is_object($this->item) and $this->item->user_id > 0)) { $socialProfilesBuilder = new Prism\Integration\Profile\Builder(array('social_platform' => $this->params->get('integration_social_platform'), 'user_id' => $this->item->user_id)); $socialProfilesBuilder->build(); $socialProfile = $socialProfilesBuilder->getProfile(); $this->socialProfileLink = !$socialProfile ? null : $socialProfile->getLink(); } // Set a link to project page $uri = JUri::getInstance(); $host = $uri->toString(array('scheme', 'host')); $this->item->link = $host . JRoute::_(CrowdfundingHelperRoute::getDetailsRoute($this->item->slug, $this->item->catslug), false); // Set a link to image $this->item->link_image = $host . '/' . $this->imageFolder . '/' . $this->item->image; $layout = $this->getLayout(); if ($this->getLayout() === '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); } else { $this->embedCode = $this->prepareEmbedCode($this->item, $host); } $this->prepareDocument(); parent::display($tpl); }
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); }
/** * 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; }
/** * @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"> </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; }
/** * Send emails to the administrator, project owner and the user who have made a donation. * * @param object $project * @param object $transaction * @param 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"); $componentParams = \JComponentHelper::getParams("com_crowdfunding"); $currency = Crowdfunding\Currency::getInstance(\JFactory::getDbo(), $componentParams->get("project_currency")); $amount = new Crowdfunding\Amount($componentParams); $amount->setCurrency($currency); // 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" => $amount->setValue($transaction->txn_amount)->formatCurrency(), "transaction_id" => $transaction->txn_id); // Prepare data about payer if he is NOT anonymous ( is registered user with profile ). if (!empty($transaction->investor_id)) { $investor = \JFactory::getUser($transaction->investor_id); $data["payer_email"] = $investor->get("email"); $data["payer_name"] = $investor->get("name"); } // Send mail to the administrator $emailId = $this->params->get("admin_mail_id", 0); if (!empty($emailId)) { $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 Registry */ $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, Prism\Constants::MAIL_MODE_HTML); } else { // Send as plain text. $return = $mailer->sendMail($email->getSenderEmail(), $email->getSenderName(), $recipientMail, $subject, $body, Prism\Constants::MAIL_MODE_PLAIN); } // Check for an error. if ($return !== true) { $this->log->add(\JText::_($this->textPrefix . "_ERROR_MAIL_SENDING_ADMIN"), $this->debugType, $mailer->ErrorInfo); } } // Send mail to project owner. $emailId = $this->params->get("creator_mail_id", 0); if (!empty($emailId)) { $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")); } $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, Prism\Constants::MAIL_MODE_HTML); } else { // Send as plain text. $return = $mailer->sendMail($email->getSenderEmail(), $email->getSenderName(), $recipientMail, $subject, $body, Prism\Constants::MAIL_MODE_PLAIN); } // Check for an error. if ($return !== true) { $this->log->add(\JText::_($this->textPrefix . "_ERROR_MAIL_SENDING_PROJECT_OWNER"), $this->debugType, $mailer->ErrorInfo); } } // Send mail to backer. $emailId = $this->params->get("user_mail_id", 0); if (!empty($emailId) and !empty($transaction->investor_id)) { $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")); } $user = \JFactory::getUser($transaction->investor_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, Prism\Constants::MAIL_MODE_HTML); } else { // Send as plain text. $return = $mailer->sendMail($email->getSenderEmail(), $email->getSenderName(), $recipientMail, $subject, $body, Prism\Constants::MAIL_MODE_PLAIN); } // Check for an error. if ($return !== true) { $this->log->add(\JText::_($this->textPrefix . "_ERROR_MAIL_SENDING_PROJECT_OWNER"), $this->debugType, $mailer->ErrorInfo); } } }
?> " 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>
/** * 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; }
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; }
/** * @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; }
public function display($tpl = null) { // Get model state. $this->state = $this->get('State'); $this->item = $this->get("Item"); // Get params $this->params = $this->state->get("params"); if (!$this->item) { $this->app->enqueueMessage(JText::_("COM_CROWDFUNDING_ERROR_INVALID_PROJECT"), "notice"); $this->app->redirect(JRoute::_(CrowdfundingHelperRoute::getDiscoverRoute(), false)); return; } // Create an object that will contain the data during the payment process. $this->paymentSessionContext = Crowdfunding\Constants::PAYMENT_SESSION_CONTEXT . $this->item->id; $paymentSession = $this->app->getUserState($this->paymentSessionContext); // Create payment session object. if (!$paymentSession or !isset($paymentSession->step1)) { $paymentSession = new JData(); $paymentSession->step1 = false; } // Images $this->imageFolder = $this->params->get("images_directory", "images/crowdfunding"); // Get currency $this->currency = Crowdfunding\Currency::getInstance(JFactory::getDbo(), $this->params->get("project_currency")); $this->amount = new Crowdfunding\Amount($this->params); $this->amount->setCurrency($this->currency); // Set a link that points to project page $filter = JFilterInput::getInstance(); $host = JUri::getInstance()->toString(array('scheme', 'host')); $host = $filter->clean($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; // Get wizard type $this->wizardType = $this->params->get("backing_wizard_type", "three_steps"); $this->fourSteps = strcmp("four_steps", $this->wizardType) != 0 ? false : true; // Import "crowdfundingpayment" plugins. JPluginHelper::importPlugin('crowdfundingpayment'); $this->layout = $this->getLayout(); switch ($this->layout) { case "step2": $this->prepareStep2(); break; case "payment": $this->preparePayment($paymentSession); break; case "share": $this->prepareShare($paymentSession); break; default: // Pledge and Rewards $this->prepareRewards($paymentSession); break; } // Get project type and check for enabled rewards. $this->rewardsEnabled = true; if (!empty($this->item->type_id)) { $type = new Crowdfunding\Type(JFactory::getDbo()); $type->load($this->item->type_id); if ($type->getId() and !$type->isRewardsEnabled()) { $this->rewardsEnabled = false; } } // Check days left. If there is no days, disable the button. $this->disabledButton = ""; if (!$this->item->days_left) { $this->disabledButton = 'disabled="disabled"'; } $this->paymentSession = $paymentSession; // Prepare the data of the layout $this->layoutData = new JData(array("layout" => $this->layout, "item" => $this->item, "paymentSession" => $paymentSession)); $this->prepareDebugMode($paymentSession); $this->prepareDocument(); parent::display($tpl); }
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; }
public static function projectTitle($title, $categoryState, $slug, $catSlug) { $html = array(); if (!$categoryState) { $html[] = htmlspecialchars($title, ENT_QUOTES, "utf-8"); $html[] = '<button type="button" class="hasTooltip" title="' . htmlspecialchars(JText::_("COM_CROWDFUNDING_SELECT_OTHER_CATEGORY_TOOLTIP"), ENT_QUOTES, "utf-8") . '">'; $html[] = '<span class="glyphicon glyphicon-info-sign"></span>'; $html[] = '</button>'; } else { $html[] = '<a href="' . JRoute::_(CrowdfundingHelperRoute::getDetailsRoute($slug, $catSlug)) . '">'; $html[] = htmlspecialchars($title, ENT_QUOTES, "utf-8"); $html[] = '</a>'; } return implode("\n", $html); }
public function display($tpl = null) { $this->app = JFactory::getApplication(); $this->option = $this->app->input->get('option'); $this->state = $this->get('State'); $this->item = $this->get('Item'); // Get params $this->params = $this->state->get('params'); if (!$this->item) { $this->app->enqueueMessage(JText::_('COM_CROWDFUNDING_ERROR_INVALID_PROJECT'), 'notice'); $this->app->redirect(JRoute::_(CrowdfundingHelperRoute::getDiscoverRoute(), false)); return; } // Create an object that will contain the data during the payment process. $this->paymentSessionContext = Crowdfunding\Constants::PAYMENT_SESSION_CONTEXT . $this->item->id; $paymentSession = $this->app->getUserState($this->paymentSessionContext); // Create payment session object. if (!$paymentSession or !isset($paymentSession->step1)) { $paymentSession = $this->createPaymentSession(); } // Images $this->imageFolder = $this->params->get('images_directory', 'images/crowdfunding'); // Get currency $this->currency = Crowdfunding\Currency::getInstance(JFactory::getDbo(), $this->params->get('project_currency')); $this->amount = new Crowdfunding\Amount($this->params); $this->amount->setCurrency($this->currency); // Set a link that points to project page $filter = JFilterInput::getInstance(); $host = JUri::getInstance()->toString(array('scheme', 'host')); $host = $filter->clean($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; // Get wizard type $this->wizardType = $this->params->get('backing_wizard_type', 'three_steps'); $this->fourSteps = strcmp('four_steps', $this->wizardType) === 0; // Import 'crowdfundingpayment' plugins. JPluginHelper::importPlugin('crowdfundingpayment'); $this->layout = $this->getLayout(); switch ($this->layout) { case 'step2': // Step 2 on wizard in four steps. $this->prepareStep2(); break; case 'payment': // Step 2 $paymentSession = $this->preparePayment($paymentSession); break; case 'share': // Step 3 $paymentSession = $this->prepareShare($paymentSession); break; default: // Step 1 ( Rewards ) $paymentSession = $this->prepareRewards($paymentSession); break; } // Get project type and check for enabled rewards. $this->rewardsEnabled = CrowdfundingHelper::isRewardsEnabled($this->item->id); // Check days left. If there is no days, disable the button. $this->disabledButton = ''; if (!$this->item->days_left) { $this->disabledButton = 'disabled="disabled"'; } // Prepare the data of the layout $this->layoutData = new JData(array('layout' => $this->layout, 'item' => $this->item, 'paymentSession' => $paymentSession, 'rewards_enabled' => $this->rewardsEnabled)); $this->prepareDebugMode($paymentSession); $this->prepareDocument(); $this->paymentSession = $paymentSession; // Store the new values of the payment process to the user session. $this->app->setUserState($this->paymentSessionContext, $paymentSession); parent::display($tpl); }
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; ?>
/** * Send emails to the administrator, project owner and the user who have made a donation. * * @param \stdClass $project * @param \stdClass $transaction * @param Registry $params * @param \stdClass $reward */ protected function sendMails(&$project, &$transaction, &$params, &$reward) { $app = \JFactory::getApplication(); /** @var $app \JApplicationSite */ // Get website $uri = \JUri::getInstance(); $website = $uri->toString(array('scheme', 'host')); $emailMode = $this->params->get('email_mode', 'plain'); $componentParams = \JComponentHelper::getParams('com_crowdfunding'); $currency = Crowdfunding\Currency::getInstance(\JFactory::getDbo(), $componentParams->get('project_currency')); $amount = new Crowdfunding\Amount($componentParams); $amount->setCurrency($currency); // 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' => $amount->setValue($transaction->txn_amount)->formatCurrency(), 'transaction_id' => $transaction->txn_id, 'reward_title' => '', 'delivery_date' => '', 'payer_name' => '', 'payer_email' => ''); // Set reward data. if (is_object($reward)) { $data['reward_title'] = $reward->title; if ($reward->delivery !== '0000-00-00') { $date = new \JDate($reward->delivery); $data['delivery_date'] = $date->format('d F Y'); } } // Prepare data about payer if he is NOT anonymous ( is registered user with profile ). if ((int) $transaction->investor_id > 0) { $investor = \JFactory::getUser($transaction->investor_id); $data['payer_email'] = $investor->get('email'); $data['payer_name'] = $investor->get('name'); } // Send mail to the administrator $emailId = (int) $this->params->get('admin_mail_id', 0); if ($emailId > 0) { $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 Registry */ $recipientId = (int) $componentParams->get('administrator_id', 0); 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 $return = $mailer->sendMail($email->getSenderEmail(), $email->getSenderName(), $recipientMail, $subject, $body, Prism\Constants::MAIL_MODE_HTML); } else { // Send as plain text. $return = $mailer->sendMail($email->getSenderEmail(), $email->getSenderName(), $recipientMail, $subject, $body, Prism\Constants::MAIL_MODE_PLAIN); } // Check for an error. if ($return !== true) { $this->log->add(\JText::_($this->textPrefix . '_ERROR_MAIL_SENDING_ADMIN'), $this->debugType, $mailer->ErrorInfo); } } // Send mail to project owner. $emailId = (int) $this->params->get('creator_mail_id', 0); if ($emailId > 0) { $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')); } $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, Prism\Constants::MAIL_MODE_HTML); } else { // Send as plain text. $return = $mailer->sendMail($email->getSenderEmail(), $email->getSenderName(), $recipientMail, $subject, $body, Prism\Constants::MAIL_MODE_PLAIN); } // Check for an error. if ($return !== true) { $this->log->add(\JText::_($this->textPrefix . '_ERROR_MAIL_SENDING_PROJECT_OWNER'), $this->debugType, $mailer->ErrorInfo); } } // Send mail to backer. $emailId = (int) $this->params->get('user_mail_id', 0); if ($emailId > 0 and (int) $transaction->investor_id > 0) { $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')); } $user = \JFactory::getUser($transaction->investor_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, Prism\Constants::MAIL_MODE_HTML); } else { // Send as plain text. $return = $mailer->sendMail($email->getSenderEmail(), $email->getSenderName(), $recipientMail, $subject, $body, Prism\Constants::MAIL_MODE_PLAIN); } // Check for an error. if ($return !== true) { $this->log->add(\JText::_($this->textPrefix . '_ERROR_MAIL_SENDING_PROJECT_OWNER'), $this->debugType, $mailer->ErrorInfo); } } }
public static function projectTitle($title, $categoryState, $slug, $catSlug) { $html = array(); $categoryState = (int) $categoryState; if ($categoryState <= 0) { $html[] = htmlspecialchars($title, ENT_QUOTES, 'UTF-8'); $html[] = '<button type="button" class="hasTooltip" title="' . htmlspecialchars(JText::_('COM_CROWDFUNDING_SELECT_OTHER_CATEGORY_TOOLTIP'), ENT_QUOTES, 'UTF-8') . '">'; $html[] = '<span class="fa fa-info-circle"></span>'; $html[] = '</button>'; } else { $html[] = '<a href="' . JRoute::_(CrowdfundingHelperRoute::getDetailsRoute($slug, $catSlug)) . '">'; $html[] = htmlspecialchars($title, ENT_QUOTES, 'UTF-8'); $html[] = '</a>'; } return implode("\n", $html); }
/** * Send emails to the administrator, project owner and the user who have made a donation. * * @param \stdClass $paymentResult * @param Registry $params * * @throws \InvalidArgumentException * @return void */ protected function sendMails($paymentResult, $params) { if (!\JComponentHelper::isInstalled('com_emailtemplates')) { \JLog::add(\JText::_('LIB_CROWDFUNDING_EMAIL_TEMPLATES_INSTALLATION'), \JLog::WARNING, 'com_crowdfunding'); return; } $transaction = $paymentResult->transaction; /** @var Crowdfunding\Transaction\Transaction $transaction */ $project = $paymentResult->project; /** @var Crowdfunding\Project $project */ $reward = $paymentResult->reward; /** @var Crowdfunding\Reward $reward */ // Get website $uri = \JUri::getInstance(); $website = $uri->toString(array('scheme', 'host')); $emailMode = $this->params->get('email_mode', 'plain'); $moneyHash = Prism\Utilities\StringHelper::generateMd5Hash(Crowdfunding\Constants::CONTAINER_FORMATTER_MONEY, $params->get('project_currency')); $money = $this->container->get($moneyHash); /** @var Prism\Money\Money $money */ // Prepare data for parsing. $data = array('site_name' => $this->app->get('sitename'), 'site_url' => \JUri::root(), 'item_title' => $project->getTitle(), 'item_url' => $website . \JRoute::_(\CrowdfundingHelperRoute::getDetailsRoute($project->getSlug(), $project->getCatSlug())), 'amount' => $money->setAmount($transaction->getAmount())->formatCurrency(), 'transaction_id' => $transaction->getTransactionId(), 'reward_title' => '', 'delivery_date' => '', 'payer_name' => '', 'payer_email' => ''); // Prepare data about payer if he is NOT anonymous ( is registered user with profile ). if ((int) $transaction->getInvestorId() > 0) { $investor = \JFactory::getUser($transaction->getInvestorId()); $data['payer_email'] = $investor->get('email'); $data['payer_name'] = $investor->get('name'); } // Set reward data. if (is_object($reward)) { $data['reward_title'] = $reward->getTitle(); $dateValidator = new Prism\Validator\Date($reward->getDeliveryDate()); if ($dateValidator->isValid()) { $date = new \JDate($reward->getDeliveryDate()); $data['delivery_date'] = $date->format($this->params->get('date_format_views', \JText::_('DATE_FORMAT_LC3'))); } } // Send mail to the administrator $emailId = (int) $this->params->get('admin_mail_id', 0); if ($emailId > 0) { $email = new Emailtemplates\Email(); $email->setDb(\JFactory::getDbo()); $email->load($emailId); if (!$email->getSenderName()) { $email->setSenderName($this->app->get('fromname')); } if (!$email->getSenderEmail()) { $email->setSenderEmail($this->app->get('mailfrom')); } $recipientId = (int) $params->get('administrator_id', 0); if ($recipientId > 0) { $recipient = \JFactory::getUser($recipientId); $recipientName = $recipient->get('name'); $recipientMail = $recipient->get('email'); } else { $recipientName = $this->app->get('fromname'); $recipientMail = $this->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; // DEBUG JDEBUG ? $this->log->add(\JText::_($this->textPrefix . '_DEBUG_SEND_MAIL_ADMINISTRATOR'), $this->debugType, $data) : null; $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, Prism\Constants::MAIL_MODE_HTML); } else { // Send as plain text. $return = $mailer->sendMail($email->getSenderEmail(), $email->getSenderName(), $recipientMail, $subject, $body, Prism\Constants::MAIL_MODE_PLAIN); } // Check for an error. if ($return !== true) { $this->log->add(\JText::_($this->textPrefix . '_ERROR_MAIL_SENDING_ADMIN'), $this->errorType, $mailer->ErrorInfo); } } // Send mail to project owner. $emailId = (int) $this->params->get('creator_mail_id', 0); if ($emailId > 0) { $email = new Emailtemplates\Email(); $email->setDb(\JFactory::getDbo()); $email->load($emailId); if (!$email->getSenderName()) { $email->setSenderName($this->app->get('fromname')); } if (!$email->getSenderEmail()) { $email->setSenderEmail($this->app->get('mailfrom')); } $user = \JFactory::getUser($transaction->getReceiverId()); $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; // DEBUG JDEBUG ? $this->log->add(\JText::_($this->textPrefix . '_DEBUG_SEND_MAIL_PROJECT_OWNER'), $this->debugType, $data) : null; $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, Prism\Constants::MAIL_MODE_HTML); } else { // Send as plain text. $return = $mailer->sendMail($email->getSenderEmail(), $email->getSenderName(), $recipientMail, $subject, $body, Prism\Constants::MAIL_MODE_PLAIN); } // Check for an error. if ($return !== true) { $this->log->add(\JText::_($this->textPrefix . '_ERROR_MAIL_SENDING_PROJECT_OWNER'), $this->errorType, $mailer->ErrorInfo); } } // Send mail to backer. $emailId = (int) $this->params->get('user_mail_id', 0); if ($emailId > 0 and (int) $transaction->getInvestorId() > 0) { $email = new Emailtemplates\Email(); $email->setDb(\JFactory::getDbo()); $email->load($emailId); if (!$email->getSenderName()) { $email->setSenderName($this->app->get('fromname')); } if (!$email->getSenderEmail()) { $email->setSenderEmail($this->app->get('mailfrom')); } $user = \JFactory::getUser($transaction->getInvestorId()); $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; // DEBUG JDEBUG ? $this->log->add(\JText::_($this->textPrefix . '_DEBUG_SEND_MAIL_BACKER'), $this->debugType, $data) : null; $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, Prism\Constants::MAIL_MODE_HTML); } else { // Send as plain text. $return = $mailer->sendMail($email->getSenderEmail(), $email->getSenderName(), $recipientMail, $subject, $body, Prism\Constants::MAIL_MODE_PLAIN); } // Check for an error. if ($return !== true) { $this->log->add(\JText::_($this->textPrefix . '_ERROR_MAIL_SENDING_PROJECT_OWNER'), $this->errorType, $mailer->ErrorInfo); } } }