public function __construct(&$subject, $config) { parent::__construct($subject, $config); if (JComponentHelper::isInstalled('com_usernotify')) { $this->cparms = JComponentHelper::getParams('com_usernotify'); $this->targs = $this->cparms->get('target', array()); if (JDEBUG) { JLog::addLogger(array('text_file' => 'com_usernotify.log.php'), JLog::ALL, array('com_usernotify')); } } }
public function display($tpl = null) { $this->option = JFactory::getApplication()->input->get('option'); $this->params = JComponentHelper::getParams($this->option); JLoader::register('CrowdfundingInstallHelper', CROWDFUNDING_PATH_COMPONENT_ADMINISTRATOR . '/helpers/install.php'); // Load library language $lang = JFactory::getLanguage(); $lang->load('com_crowdfunding.sys', CROWDFUNDING_PATH_COMPONENT_ADMINISTRATOR); if (JComponentHelper::isInstalled('com_acymailing')) { $this->prepareAcymailing(); } // Prepare actions $this->addToolbar(); $this->addSidebar(); $this->setDocument(); parent::display($tpl); }
public function display($tpl = null) { $this->option = JFactory::getApplication()->input->get('option'); $this->params = JComponentHelper::getParams($this->option); if (JComponentHelper::isInstalled('com_acymailing')) { // Get projects $this->projects = $this->get('Projects'); array_unshift($this->projects, array('id' => '', 'title' => JText::_('COM_CROWDFUNDING_SELECT_PROJECT'))); // Get lists $this->lists = $this->get('AcyLists'); array_unshift($this->lists, array('id' => '', 'name' => JText::_('COM_CROWDFUNDING_SELECT_LIST'))); } // Prepare actions $this->addToolbar(); $this->addSidebar(); $this->setDocument(); parent::display($tpl); }
/** * install all integrated third party plugins and the xmap system plugin * * @param JAdapterInstance $adapter */ public function install(JAdapterInstance $adapter) { $path = $adapter->getParent()->getPath('source'); $folders = JFolder::folders($path . '/plugins/xmap/'); $plugins = array(); foreach ($folders as $component) { $plugins[$component] = $path . '/plugins/xmap/' . $component; } // install each third party plugin if component installed foreach ($plugins as $component => $plugin) { if (JComponentHelper::isInstalled($component)) { $installer = new JInstaller(); $installer->install($plugin); } } // install xmap system plugin // TODO implement plugin features in XmapDisplayerHtml //$installer = new JInstaller; //$installer->install($path . '/plugins/system/xmap/'); }
/** * Send notification mail to a user when his project be approved. * If I return NULL, an message will not be displayed in the browser. * If I return FALSE, an error message will be displayed in the browser. * * @param string $context * @param array $ids * @param int $state * * @return bool|null */ public function onContentChangeState($context, $ids, $state) { $app = JFactory::getApplication(); /** @var $app JApplicationSite */ if (!$app->isAdmin()) { return null; } if (strcmp('com_crowdfunding.project', $context) !== 0) { return null; } // Initialize plugin $this->init(); if (!JComponentHelper::isInstalled('com_emailtemplates')) { JLog::add($this->errorPrefix . JText::_('LIB_CROWDFUNDING_EMAIL_TEMPLATES_INSTALLATION'), JLog::WARNING, 'com_crowdfunding'); return null; } // Check for enabled option for sending mail // when administrator approve project. $emailId = $this->params->get('send_when_approved', 0); if (!$emailId) { JLog::add($this->errorPrefix . JText::sprintf('PLG_CONTENT_CROWDFUNDINGUSERMAIL_ERROR_INVALID_EMAIL_TEMPLATE'), JLog::WARNING, 'com_crowdfunding'); return null; } $ids = Joomla\Utilities\ArrayHelper::toInteger($ids); if (count($ids) > 0 and $state === Prism\Constants::APPROVED) { $projects = $this->getProjectsData($ids); // Send email to a user. foreach ($projects as $project) { $return = $this->sendMail($project, $emailId); if ($return !== true) { break; } } } return true; }
/** * Method to retrieve information about the site * * @param JObject &$params Params object * * @return array Array containing site information * * @since 3.0 */ public static function getStats(&$params) { $app = JFactory::getApplication(); $db = JFactory::getDbo(); $rows = array(); $query = $db->getQuery(true); $serverinfo = $params->get('serverinfo'); $siteinfo = $params->get('siteinfo'); $counter = $params->get('counter'); $increase = $params->get('increase'); $i = 0; if ($serverinfo) { $rows[$i] = new stdClass(); $rows[$i]->title = JText::_('MOD_STATS_OS'); $rows[$i]->icon = 'screen'; $rows[$i]->data = substr(php_uname(), 0, 7); $i++; $rows[$i] = new stdClass(); $rows[$i]->title = JText::_('MOD_STATS_PHP'); $rows[$i]->icon = 'cogs'; $rows[$i]->data = phpversion(); $i++; $rows[$i] = new stdClass(); $rows[$i]->title = JText::_($db->name); $rows[$i]->icon = 'database'; $rows[$i]->data = $db->getVersion(); $i++; $rows[$i] = new stdClass(); $rows[$i]->title = JTEXT::_('MOD_STATS_TIME'); $rows[$i]->icon = 'clock'; $rows[$i]->data = JHtml::_('date', 'now', 'H:i'); $i++; $rows[$i] = new stdClass(); $rows[$i]->title = JText::_('MOD_STATS_CACHING'); $rows[$i]->icon = 'dashboard'; $rows[$i]->data = $app->get('caching') ? JText::_('JENABLED') : JText::_('JDISABLED'); $i++; $rows[$i] = new stdClass(); $rows[$i]->title = JText::_('MOD_STATS_GZIP'); $rows[$i]->icon = 'lightning'; $rows[$i]->data = $app->get('gzip') ? JText::_('JENABLED') : JText::_('JDISABLED'); $i++; } if ($siteinfo) { $query->select('COUNT(id) AS count_users')->from('#__users'); $db->setQuery($query); $users = $db->loadResult(); $query->clear()->select('COUNT(id) AS count_items')->from('#__content')->where('state = 1'); $db->setQuery($query); $items = $db->loadResult(); if ($users) { $rows[$i] = new stdClass(); $rows[$i]->title = JText::_('MOD_STATS_USERS'); $rows[$i]->icon = 'users'; $rows[$i]->data = $users; $i++; } if ($items) { $rows[$i] = new stdClass(); $rows[$i]->title = JText::_('MOD_STATS_ARTICLES'); $rows[$i]->icon = 'file'; $rows[$i]->data = $items; $i++; } if (JComponentHelper::isInstalled('com_weblinks')) { $query->clear()->select('COUNT(id) AS count_links')->from('#__weblinks')->where('state = 1'); $db->setQuery($query); $links = $db->loadResult(); if ($links) { $rows[$i] = new stdClass(); $rows[$i]->title = JText::_('MOD_STATS_WEBLINKS'); $rows[$i]->icon = 'out-2'; $rows[$i]->data = $links; $i++; } } } if ($counter) { $query->clear()->select('SUM(hits) AS count_hits')->from('#__content')->where('state = 1'); $db->setQuery($query); $hits = $db->loadResult(); if ($hits) { $rows[$i] = new stdClass(); $rows[$i]->title = JText::_('MOD_STATS_ARTICLES_VIEW_HITS'); $rows[$i]->icon = 'eye'; $rows[$i]->data = $hits + $increase; } } return $rows; }
/** * Test JComponentHelper::isInstalled * * @return void * * @since 3.4 * @covers JComponentHelper::isInstalled */ public function testIsInstalled() { $this->assertTrue((bool) JComponentHelper::isInstalled('com_content'), 'com_content should be installed'); $this->assertFalse((bool) JComponentHelper::isInstalled('com_willneverhappen'), 'com_willneverhappen should not be enabled'); }
<div id="j-sidebar-container" class="span2"> <?php echo $this->sidebar; ?> </div> <div id="j-main-container" class="span10"> <?php } else { ?> <div id="j-main-container"> <?php } ?> <div class="row-fluid"> <?php if (JComponentHelper::isInstalled('com_acymailing')) { ?> <div class="span4"> <form action="<?php echo JRoute::_('index.php?option=com_crowdfunding'); ?> " method="post" id="js-cftools-acyfunders"> <div class="panel panel-default"> <div class="panel-heading"> AcyMailing <img src="../media/com_crowdfunding/images/ajax-loader.gif" width="16" height="16" id="js-cfacy-ajax-loader" style="display: none;" /> </div> <div class="panel-body"> <?php echo JHtml::_('select.genericlist', $this->projects, 'acy_pid', null, 'id', 'title');
public static function checkComponentEnabled($option) { $version = new JVersion(); $isInstalled = version_compare($version->getShortVersion(), "3.4", "<") ? in_array($option, self::getInstalledComponents()) : JComponentHelper::isInstalled($option); return $isInstalled && JComponentHelper::isEnabled($option) === '1'; }
/** * 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); } } }
/** * Method to retrieve information about the site * * @param JObject &$params Params object * * @return array Array containing site information * * @since 3.0 */ public static function getStats(&$params) { $app = JFactory::getApplication(); $db = JFactory::getDbo(); $rows = array(); $query = $db->getQuery(true); $serverinfo = $params->get('serverinfo'); $siteinfo = $params->get('siteinfo'); $counter = $params->get('counter'); $increase = $params->get('increase'); $i = 0; if ($serverinfo) { $rows[$i] = new stdClass(); $rows[$i]->title = JText::_('MOD_STATS_OS'); $rows[$i]->icon = 'screen'; $rows[$i]->data = substr(php_uname(), 0, 7); $i++; $rows[$i] = new stdClass(); $rows[$i]->title = JText::_('MOD_STATS_PHP'); $rows[$i]->icon = 'cogs'; $rows[$i]->data = phpversion(); $i++; $rows[$i] = new stdClass(); $rows[$i]->title = JText::_($db->name); $rows[$i]->icon = 'database'; $rows[$i]->data = $db->getVersion(); $i++; $rows[$i] = new stdClass(); $rows[$i]->title = JText::_('MOD_STATS_TIME'); $rows[$i]->icon = 'clock'; $rows[$i]->data = JHtml::_('date', 'now', 'H:i'); $i++; $rows[$i] = new stdClass(); $rows[$i]->title = JText::_('MOD_STATS_CACHING'); $rows[$i]->icon = 'dashboard'; $rows[$i]->data = $app->get('caching') ? JText::_('JENABLED') : JText::_('JDISABLED'); $i++; $rows[$i] = new stdClass(); $rows[$i]->title = JText::_('MOD_STATS_GZIP'); $rows[$i]->icon = 'lightning'; $rows[$i]->data = $app->get('gzip') ? JText::_('JENABLED') : JText::_('JDISABLED'); $i++; } if ($siteinfo) { $query->select('COUNT(id) AS count_users')->from('#__users'); $db->setQuery($query); try { $users = $db->loadResult(); } catch (RuntimeException $e) { $users = false; } $query->clear()->select('COUNT(id) AS count_items')->from('#__content')->where('state = 1'); $db->setQuery($query); try { $items = $db->loadResult(); } catch (RuntimeException $e) { $items = false; } if ($users) { $rows[$i] = new stdClass(); $rows[$i]->title = JText::_('MOD_STATS_USERS'); $rows[$i]->icon = 'users'; $rows[$i]->data = $users; $i++; } if ($items) { $rows[$i] = new stdClass(); $rows[$i]->title = JText::_('MOD_STATS_ARTICLES'); $rows[$i]->icon = 'file'; $rows[$i]->data = $items; $i++; } if (JComponentHelper::isInstalled('com_weblinks')) { $query->clear()->select('COUNT(id) AS count_links')->from('#__weblinks')->where('state = 1'); $db->setQuery($query); try { $links = $db->loadResult(); } catch (RuntimeException $e) { $links = false; } if ($links) { $rows[$i] = new stdClass(); $rows[$i]->title = JText::_('MOD_STATS_WEBLINKS'); $rows[$i]->icon = 'out-2'; $rows[$i]->data = $links; $i++; } } } if ($counter) { $query->clear()->select('SUM(hits) AS count_hits')->from('#__content')->where('state = 1'); $db->setQuery($query); try { $hits = $db->loadResult(); } catch (RuntimeException $e) { $hits = false; } if ($hits) { $rows[$i] = new stdClass(); $rows[$i]->title = JText::_('MOD_STATS_ARTICLES_VIEW_HITS'); $rows[$i]->icon = 'eye'; $rows[$i]->data = number_format($hits + $increase, 0, JText::_('DECIMALS_SEPARATOR'), JText::_('THOUSANDS_SEPARATOR')); $i++; } } // Include additional data defined by published system plugins JPluginHelper::importPlugin('system'); $app = JFactory::getApplication(); $arrays = (array) $app->triggerEvent('onGetStats', array('mod_stats_admin')); foreach ($arrays as $response) { foreach ($response as $row) { // We only add a row if the title and data are given if (isset($row['title']) && isset($row['data'])) { $rows[$i] = new stdClass(); $rows[$i]->title = $row['title']; $rows[$i]->icon = isset($row['icon']) ? $row['icon'] : 'info'; $rows[$i]->data = $row['data']; $i++; } } } return $rows; }
protected function getSubscribersIds($projectId) { $db = $this->getDbo(); /** @var $db JDatabaseDriver */ $subscribersIds = array(); // Get the number of items that have to be imported. $query = $db->getQuery(true); $query->select('a.email')->from($db->quoteName('#__users', 'a'))->rightJoin($db->quoteName('#__crowdf_transactions', 'b') . ' ON b.investor_id = a.id')->where('b.project_id = ' . (int) $projectId)->where('b.investor_id > 0')->group('email'); $db->setQuery($query); $emails = (array) $db->loadColumn(); $emails2 = array(); if (JComponentHelper::isInstalled('com_crowdfundingdata')) { $query = $db->getQuery(true); $query->select('a.email')->from($db->quoteName('#__cfdata_records', 'a'))->rightJoin($db->quoteName('#__crowdf_transactions', 'b') . ' ON b.project_id = a.project_id')->where('a.project_id = ' . (int) $projectId)->where('a.transaction_id > 0')->group('email'); $db->setQuery($query); $emails2 = (array) $db->loadColumn(); } if (count($emails2) !== 0) { $emails = array_merge($emails, $emails2); $emails = array_unique($emails); } if (count($emails) !== 0) { foreach ($emails as $key => $email) { $emails[$key] = $db->quote($email); } $query = $db->getQuery(true); $query->select('a.subid')->from($db->quoteName('#__acymailing_subscriber', 'a'))->where('a.email IN (' . implode(',', $emails) . ')'); $db->setQuery($query); $subscribersIds = $db->loadColumn(); $subscribersIds = Joomla\Utilities\ArrayHelper::toInteger($subscribersIds); } return $subscribersIds; }
/** * Method to attach a JForm object to the field. * * @param SimpleXMLElement $element The SimpleXMLElement object representing the <field /> tag for the form field object. * @param mixed $value The form field value to validate. * @param string $group The field name group control value. This acts as as an array container for the field. * For example if the field has name="foo" and the group value is set to "bar" then the * full field name would end up being "bar[foo]". * * @return boolean True on success. * * @see JFormField::setup() * @since 3.2 */ public function setup(SimpleXMLElement $element, $value, $group = null) { $result = parent::setup($element, $value, $group); if ($result == true) { $assetField = $this->element['asset_field'] ? (string) $this->element['asset_field'] : 'asset_id'; $this->authorField = $this->element['created_by_field'] ? (string) $this->element['created_by_field'] : 'created_by'; $this->asset = $this->form->getValue($assetField) ? $this->form->getValue($assetField) : (string) $this->element['asset_id']; $this->link = (string) $this->element['link']; $this->width = isset($this->element['width']) ? (int) $this->element['width'] : 800; $this->height = isset($this->element['height']) ? (int) $this->element['height'] : 500; $this->mode = isset($this->element['mode']) ? (string) $this->element['mode'] : 'normal'; $this->preview = (string) $this->element['preview']; $this->directory = (string) $this->element['directory']; $this->component = isset($this->element['component']) && JComponentHelper::isInstalled($this->element['component']) ? (string) $this->element['component'] : 'com_media'; $this->previewWidth = isset($this->element['preview_width']) ? (int) $this->element['preview_width'] : 200; $this->previewHeight = isset($this->element['preview_height']) ? (int) $this->element['preview_height'] : 200; } return $result; }