Example #1
0
 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;
     $model = $this->getModel();
     $userId = JFactory::getUser()->get("id");
     if (!$this->item or $model->isRestricted($this->item, $userId)) {
         $app->enqueueMessage(JText::_("COM_CROWDFUNDING_ERROR_INVALID_PROJECT"), "notice");
         $app->redirect(JRoute::_('index.php?option=com_crowdfunding&view=discover', false));
         return;
     }
     // Get rewards of the project
     $this->imageFolder = $this->params->get("images_directory", "images/crowdfunding");
     // 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 = $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();
     $offset = 0;
     $results = $dispatcher->trigger('onContentBeforeDisplay', array('com_crowdfunding.details', &$this->item, &$this->params, $offset));
     $this->item->event->beforeDisplayContent = trim(implode("\n", $results));
     $results = $dispatcher->trigger('onContentAfterDisplayMedia', array('com_crowdfunding.details', &$this->item, &$this->params, $offset));
     $this->item->event->onContentAfterDisplayMedia = trim(implode("\n", $results));
     $results = $dispatcher->trigger('onContentAfterDisplay', array('com_crowdfunding.details', &$this->item, &$this->params, $offset));
     $this->item->event->onContentAfterDisplay = trim(implode("\n", $results));
     // Count hits
     $model->hit($this->item->id);
     $this->version = new CrowdFundingVersion();
     parent::display($tpl);
 }
Example #2
0
 public function save($key = null, $urlVar = null)
 {
     // Check for request forgeries.
     JSession::checkToken() 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 the data from the form POST
     $data = $this->input->post->get('jform', array(), 'array');
     $itemId = JArrayHelper::getValue($data, "project_id");
     // Get project
     jimport("crowdfunding.project");
     $item = CrowdFundingProject::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());
         throw new Exception(JText::_('COM_CROWDFUNDING_ERROR_SYSTEM'));
     }
     // Redirect to next page
     $this->displayNotice(JText::_("COM_CROWDFUNDING_UPDATE_SUCCESSFULLY_SAVED"), $redirectOptions);
 }
Example #3
0
 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);
 }
Example #4
0
 public function display($tpl = null)
 {
     // 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;
     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 = CrowdFundingConstants::PAYMENT_SESSION_CONTEXT . $this->item->id;
     $paymentSession = $this->app->getUserState($this->paymentSessionContext);
     // Create payment session object.
     if (!$paymentSession) {
         $paymentSession = new JData();
         $paymentSession->step1 = false;
     }
     // Images
     $this->imageFolder = $this->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);
     // 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 params
     $params = JComponentHelper::getParams("com_crowdfunding");
     // Get wizard type
     $this->wizardType = $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)) {
         jimport("crowdfunding.type");
         $type = new CrowdFundingType(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();
     $this->version = new CrowdFundingVersion();
     parent::display($tpl);
 }
Example #5
0
    // Get social platform and a link to the profile
    $socialProfile = CrowdFundingHelper::getSocialProfile($this->item->user_id, $this->socialPlatform);
    $socialProfileLink = !$socialProfile ? null : $socialProfile->getLink();
    ?>
      <li class="span12">
        <div class="thumbnail">
          <img src="<?php 
    echo $this->item->link_image;
    ?>
" alt="<?php 
    echo $this->item->title;
    ?>
" width="200" height="200">
          <div class="caption">
            <h3><a href="<?php 
    echo JRoute::_(CrowdFundingHelperRoute::getDetailsRoute($this->item->slug, $this->item->catslug));
    ?>
" target="_blank"><?php 
    echo $this->item->title;
    ?>
</a></h3>
            <span class="cf-founder">
                by <?php 
    echo JHtml::_("crowdfunding.socialProfileLink", $socialProfileLink, $this->item->user_name, array("target" => "_blank"));
    ?>
 
            </span>
            <p><?php 
    echo $this->item->short_desc;
    ?>
</p>
Example #6
0
        <?php 
if ($project->getId()) {
    ?>
            <li>
                <div class="thumbnail cf-project">
                    <img src="<?php 
    echo $imageFolder . "/" . $project->getImage();
    ?>
" alt="<?php 
    echo htmlspecialchars($project->getTitle(), ENT_QUOTES, "UTF-8");
    ?>
" width="200" height="200">
                    <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;
        ?>
Example #7
0
 /**
  * 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);
         }
     }
 }
Example #8
0
 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[] = '<i class="icon-info-sign"></i>';
         $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 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="label">' . JArrayHelper::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="label">' . JArrayHelper::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="label">' . JArrayHelper::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;
 }
 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 CrowdFundingEmail();
     $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, CrowdFundingConstants::MAIL_MODE_HTML);
     } else {
         // Send as plain text.
         $result = $mailer->sendMail($email->getSenderEmail(), $email->getSenderName(), $recipientMail, $subject, $body, CrowdFundingConstants::MAIL_MODE_PLAIN);
     }
     // Log the error.
     if ($result !== true) {
         $this->log->add(JText::sprintf("PLG_CONTENT_CROWDFUNDINGUSERMAIL_ERROR_SEND_MAIL_USER", $mailer->ErrorInfo), "PLG_CONTENT_USERE_MAIL_ERROR");
         return false;
     }
     return true;
 }
 protected function sendMail($project, $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");
     // 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)));
     $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
         $result = $mailer->sendMail($email->getSenderEmail(), $email->getSenderName(), $recipientMail, $subject, $body, CrowdFundingConstants::MAIL_MODE_HTML);
     } else {
         // Send as plain text.
         $result = $mailer->sendMail($email->getSenderEmail(), $email->getSenderName(), $recipientMail, $subject, $body, CrowdFundingConstants::MAIL_MODE_PLAIN);
     }
     // Log the error.
     if ($result !== true) {
         $this->log->add(JText::sprintf("PLG_CONTENT_CROWDFUNDINGADMINMAIL_ERROR_SEND_MAIL_ADMIN", $mailer->ErrorInfo), "PLG_CONTENT_ADMIN_EMAIL_ERROR");
         return false;
     }
     return true;
 }