Exemple #1
0
 public static function yesnoSelectList($tag_name, $tag_attribs, $selected, $yes = 'yes', $no = 'no')
 {
     if (JCOMMENTS_JVERSION == '1.0') {
         $arr = array(JCommentsHTML::makeOption(0, $no), JCommentsHTML::makeOption(1, $yes));
     } else {
         $arr = array(JCommentsHTML::makeOption(0, $no), JCommentsHTML::makeOption(1, $yes));
     }
     return JCommentsHTML::selectList($arr, $tag_name, $tag_attribs, 'value', 'text', (int) $selected);
 }
 public static function show()
 {
     $app = JCommentsFactory::getApplication('administrator');
     $context = 'com_jcomments.subscriptions.';
     $object_group = trim($app->getUserStateFromRequest($context . 'fog', 'fog', ''));
     $object_id = intval($app->getUserStateFromRequest($context . 'foid', 'foid', 0));
     $flang = trim($app->getUserStateFromRequest($context . 'flang', 'flang', '-1'));
     $fauthor = trim($app->getUserStateFromRequest($context . 'fauthor', 'fauthor', ''));
     $fstate = trim($app->getUserStateFromRequest($context . 'fstate', 'fstate', '-1'));
     $limit = intval($app->getUserStateFromRequest($context . 'limit', 'limit', $app->getCfg('list_limit')));
     $limitstart = intval($app->getUserStateFromRequest($context . 'limitstart', 'limitstart', 0));
     $filter_order = $app->getUserStateFromRequest($context . 'filter_order', 'filter_order', 'js.name');
     $filter_order_Dir = $app->getUserStateFromRequest($context . 'filter_order_Dir', 'filter_order_Dir', 'asc');
     $search = trim($app->getUserStateFromRequest($context . 'search', 'search', ''));
     if (JCOMMENTS_JVERSION == '1.0') {
         $search = strtolower($search);
     } else {
         $search = JString::strtolower($search);
     }
     if ($filter_order == '') {
         $filter_order = 'js.name';
     }
     if ($filter_order_Dir == '') {
         $filter_order_Dir = 'asc';
     }
     $lists['order'] = $filter_order;
     $lists['order_Dir'] = $filter_order_Dir;
     $lists['search'] = $search;
     $db = JCommentsFactory::getDBO();
     $where = array();
     if ($object_group != '') {
         $where[] = 'js.object_group = "' . $db->getEscaped($object_group, true) . '"';
     }
     if ($object_id != 0) {
         $where[] = 'js.object_id = ' . intval($object_id);
     }
     if ($flang != '-1') {
         $where[] = 'js.lang = "' . $db->getEscaped($flang, true) . '"';
     }
     if ($fauthor != '') {
         $where[] = 'js.name = "' . $db->getEscaped($fauthor, true) . '"';
     }
     if ($fstate != '' && $fstate != '-1') {
         $where[] = 'js.published = ' . intval($fstate);
     }
     if ($search != '') {
         $where[] = '(js.name like "%' . $db->getEscaped($search, true) . '%" OR js.email like "%' . $db->getEscaped($search, true) . '%")';
     }
     $query = "SELECT COUNT(*)" . " FROM #__jcomments_subscriptions AS js" . (count($where) ? "\nWHERE " . implode(' AND ', $where) : "");
     $db->setQuery($query);
     $total = $db->loadResult();
     $lists['pageNav'] = JCommentsAdmin::getPagination($total, $limitstart, $limit);
     $query = "SELECT js.*, u.name AS editor" . " FROM #__jcomments_subscriptions AS js" . " LEFT JOIN #__users AS u ON u.id = js.userid" . (count($where) ? " WHERE " . implode(' AND ', $where) : "") . " ORDER BY " . $filter_order . ' ' . $filter_order_Dir;
     $db->setQuery($query, $lists['pageNav']->limitstart, $lists['pageNav']->limit);
     $lists['rows'] = $db->loadObjectList();
     // Filter by object_group (component)
     $query = "SELECT DISTINCT(object_group) AS name, object_group AS value " . " FROM #__jcomments_subscriptions" . " ORDER BY name";
     $db->setQuery($query);
     $rows = $db->loadObjectList();
     $cnt = count($rows);
     if ($cnt > 1 || $cnt == 1 && $total == 0) {
         array_unshift($rows, JCommentsHTML::makeOption('', JText::_('A_FILTER_COMPONENT'), 'name', 'value'));
         $lists['fog'] = JCommentsHTML::selectList($rows, 'fog', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'name', 'value', $object_group);
     } else {
         if ($cnt == 1) {
             if ($object_group == '') {
                 $object_group = $rows[0]->name;
             }
         }
     }
     unset($rows);
     if ($object_group != '') {
         $query = "SELECT DISTINCT object_id AS value, lang " . " FROM #__jcomments_subscriptions " . " WHERE object_group = " . $db->Quote($object_group) . ($flang != '-1' ? " AND lang = " . $db->Quote($flang) : "");
         $db->setQuery($query);
         $rows = $db->loadObjectList();
         for ($i = 0, $n = count($rows); $i < $n; $i++) {
             $rows[$i]->name = JCommentsObjectHelper::getTitle($rows[$i]->value, $object_group, $rows[$i]->lang);
             if ($rows[$i]->name == '') {
                 $rows[$i]->name = 'Untitled' . $rows[$i]->value;
             }
         }
         // Don't show filter if we have more than 100 objects
         if (count($rows) > 1 && count($rows) < 100) {
             usort($rows, create_function('$a, $b', 'return strcasecmp( $a->name, $b->name);'));
             array_unshift($rows, JCommentsHTML::makeOption('', JText::_('A_FILTER_OBJECT'), 'value', 'name'));
             $lists['foid'] = JCommentsHTML::selectList($rows, 'foid', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'value', 'name', $object_id);
             unset($rows);
         }
     }
     // Filter by language
     $query = "SELECT DISTINCT(lang) AS text, lang AS value " . " FROM #__jcomments_subscriptions" . " ORDER BY lang";
     $db->setQuery($query);
     $rows = $db->loadObjectList();
     if (count($rows) > 1) {
         array_unshift($rows, JCommentsHTML::makeOption('-1', JText::_('A_FILTER_LANGUAGE'), 'text', 'value'));
         $lists['flang'] = JCommentsHTML::selectList($rows, 'flang', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'text', 'value', $flang);
     }
     unset($rows);
     // Filter by published state
     $stateOptions = array();
     $stateOptions[] = JCommentsHTML::makeOption('-1', JText::_('A_FILTER_STATE'), 'text', 'value');
     $stateOptions[] = JCommentsHTML::makeOption('', JText::_('A_FILTER_STATE_ALL'), 'text', 'value');
     $stateOptions[] = JCommentsHTML::makeOption('1', JText::_('A_FILTER_STATE_PUBLISHED'), 'text', 'value');
     $stateOptions[] = JCommentsHTML::makeOption('0', JText::_('A_FILTER_STATE_UNPUBLISHED'), 'text', 'value');
     $lists['fstate'] = JCommentsHTML::selectList($stateOptions, 'fstate', 'class="inputbox" size="1" onchange="document.adminForm.submit();"', 'text', 'value', $fstate);
     unset($stateOptions);
     // Filter by author
     $lists['fauthor'] = '';
     $db->setQuery("SELECT COUNT(DISTINCT(name)) FROM #__jcomments_subscriptions;");
     $usersCount = $db->loadResult();
     // Don't show filter if we have more than 100 comments' authors
     if ($usersCount > 0 && $usersCount < 100) {
         $query = "SELECT DISTINCT(name) AS author, name AS value " . " FROM #__jcomments_subscriptions" . " ORDER BY name";
         $db->setQuery($query);
         $rows = $db->loadObjectList();
         if (count($rows) > 1) {
             array_unshift($rows, JCommentsHTML::makeOption('', JText::_('A_FILTER_AUTHOR'), 'author', 'value'));
             $lists['fauthor'] = JCommentsHTML::selectList($rows, 'fauthor', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'author', 'value', $fauthor);
         }
         unset($rows);
     }
     HTML_JCommentsAdminSubscriptionManager::show($lists);
 }
 public static function showSettings()
 {
     $db = JCommentsFactory::getDBO();
     $config = JCommentsFactory::getConfig();
     // check current site template for afterDisplayContent event
     if (JCOMMENTS_JVERSION == '1.5') {
         $db->setQuery('SELECT template FROM #__templates_menu WHERE client_id = 0 AND menuid = 0', 0, 1);
         $template = $db->loadResult();
         $articleTemplate = JPATH_SITE . '/templates/' . $template . '/html/com_content/article/default.php';
         if (is_file($articleTemplate)) {
             $tmpl = implode('', file($articleTemplate));
             if (strpos($tmpl, 'afterDisplayContent') === false && !(strpos($tmpl, 'include') !== false || strpos($tmpl, 'require') !== false)) {
                 JError::raiseWarning(500, JText::_('A_WARNINGS_TEMPLATE_EVENT'));
             }
         }
     }
     $joomfish = JOOMLATUNE_JPATH_SITE . '/components/com_joomfish/joomfish.php';
     if (is_file($joomfish) || JCommentsMultilingual::isEnabled()) {
         $languages = JCommentsMultilingual::getLanguages();
         if (count($languages)) {
             $lang = trim(JCommentsInput::getVar('lang', ''));
             if ($lang == '') {
                 if (JCOMMENTS_JVERSION != '1.0') {
                     $params = JComponentHelper::getParams('com_languages');
                     $lang = $params->get("site", 'en-GB');
                 }
                 if ($lang == '') {
                     $lang = JCommentsMultilingual::getLanguage();
                 }
             }
             // reload configuration
             $config = JCommentsFactory::getConfig($lang);
             $lists['languages'] = JCommentsHTML::selectList($languages, 'lang', 'class="inputbox" size="1" onchange="submitform(\'settings\');"', 'value', 'name', $lang);
         }
     }
     $forbiddenNames = $config->get('forbidden_names');
     $forbiddenNames = preg_replace('#,+#', "\n", $forbiddenNames);
     $config->set('forbidden_names', $forbiddenNames);
     $badWords = $config->get('badwords');
     if ($badWords != '') {
         $config->set('badwords', implode("\n", $badWords));
     }
     require_once JCOMMENTS_LIBRARIES . '/joomlatune/filesystem.php';
     // path to images directory
     $path = JCOMMENTS_BASE . DS . 'tpl' . DS;
     $items = JoomlaTuneFS::readDirectory($path);
     $templates = array();
     foreach ($items as $item) {
         if (is_dir($path . $item)) {
             $tpl = new StdClass();
             $tpl->text = $item;
             $tpl->value = $item;
             $templates[] = $tpl;
         }
     }
     $currentTemplate = $config->get('template');
     $lists['templates'] = JCommentsHTML::selectList($templates, 'cfg_template', 'class="inputbox"', 'value', 'text', $currentTemplate);
     require_once JCOMMENTS_HELPERS . '/user.php';
     $groups = JCommentsUserHelper::getUserGroups();
     $captchaError = '';
     $captchaExclude = array();
     if (!extension_loaded('gd') || !function_exists('imagecreatefrompng')) {
         if ($config->get('captcha_engine', 'kcaptcha') != 'recaptcha') {
             foreach ($groups as $group) {
                 $captchaExclude[] = $group->id;
             }
             $captchaError = JText::_('A_WARNINGS_PHP_GD');
         }
     }
     $reportError = '';
     $reportExclude = array();
     if ($config->getInt('enable_notification') == 0 || $config->check('notification_type', 2) == false) {
         foreach ($groups as $group) {
             $reportExclude[] = $group->id;
         }
         $reportError = JText::_('A_REPORTS_WARNING_NOTIFICATIONS_DISABLED');
     }
     $lists['group_names'] = $groups;
     $permissions = array();
     // Post
     JCommentsAdmin::loadParam($permissions, 'can_comment', $groups, JText::_('A_RIGHTS_POST'), JText::_('AP_CAN_COMMENT'), JText::_('AP_CAN_COMMENT_DESC'));
     JCommentsAdmin::loadParam($permissions, 'can_reply', $groups, JText::_('A_RIGHTS_POST'), JText::_('AP_CAN_REPLY'), JText::_('AP_CAN_REPLY_DESC'));
     JCommentsAdmin::loadParam($permissions, 'autopublish', $groups, JText::_('A_RIGHTS_POST'), JText::_('AP_AUTOPUBLISH'), JText::_('AP_AUTOPUBLISH_DESC'));
     JCommentsAdmin::loadParam($permissions, 'show_policy', $groups, JText::_('A_RIGHTS_POST'), JText::_('AP_SHOW_POLICY'), JText::_('AP_SHOW_POLICY_DESC'));
     JCommentsAdmin::loadParam($permissions, 'enable_captcha', $groups, JText::_('A_RIGHTS_POST'), JText::_('AP_ENABLE_CAPTCHA'), JText::_('AP_ENABLE_CAPTCHA_DESC'), $captchaExclude, $captchaError);
     JCommentsAdmin::loadParam($permissions, 'floodprotection', $groups, JText::_('A_RIGHTS_POST'), JText::_('AP_ENABLE_FLOODPROTECTION'), JText::_('AP_ENABLE_FLOODPROTECTION_DESC'));
     JCommentsAdmin::loadParam($permissions, 'enable_comment_length_check', $groups, JText::_('A_RIGHTS_POST'), JText::_('AP_ENABLE_COMMENT_LENGTH_CHECK'), JText::_('AP_ENABLE_COMMENT_LENGTH_CHECK_DESC'));
     JCommentsAdmin::loadParam($permissions, 'enable_autocensor', $groups, JText::_('A_RIGHTS_POST'), JText::_('AP_ENABLE_AUTOCENSOR'), JText::_('AP_ENABLE_AUTOCENSOR_DESC'));
     JCommentsAdmin::loadParam($permissions, 'enable_subscribe', $groups, JText::_('A_RIGHTS_POST'), JText::_('AP_ENABLE_SUBSCRIBE'), JText::_('AP_ENABLE_SUBSCRIBE_DESC'));
     // BBCodes
     JCommentsAdmin::loadParam($permissions, 'enable_bbcode_b', $groups, JText::_('A_RIGHTS_BBCODE'), JText::_('AP_ENABLE_BBCODE_B'), JText::_('AP_ENABLE_BBCODE_B_DESC'));
     JCommentsAdmin::loadParam($permissions, 'enable_bbcode_i', $groups, JText::_('A_RIGHTS_BBCODE'), JText::_('AP_ENABLE_BBCODE_I'), JText::_('AP_ENABLE_BBCODE_I_DESC'));
     JCommentsAdmin::loadParam($permissions, 'enable_bbcode_u', $groups, JText::_('A_RIGHTS_BBCODE'), JText::_('AP_ENABLE_BBCODE_U'), JText::_('AP_ENABLE_BBCODE_U_DESC'));
     JCommentsAdmin::loadParam($permissions, 'enable_bbcode_s', $groups, JText::_('A_RIGHTS_BBCODE'), JText::_('AP_ENABLE_BBCODE_S'), JText::_('AP_ENABLE_BBCODE_S_DESC'));
     JCommentsAdmin::loadParam($permissions, 'enable_bbcode_url', $groups, JText::_('A_RIGHTS_BBCODE'), JText::_('AP_ENABLE_BBCODE_URL'), JText::_('AP_ENABLE_BBCODE_URL_DESC'));
     JCommentsAdmin::loadParam($permissions, 'enable_bbcode_img', $groups, JText::_('A_RIGHTS_BBCODE'), JText::_('AP_ENABLE_BBCODE_IMG'), JText::_('AP_ENABLE_BBCODE_IMG_DESC'));
     JCommentsAdmin::loadParam($permissions, 'enable_bbcode_list', $groups, JText::_('A_RIGHTS_BBCODE'), JText::_('AP_ENABLE_BBCODE_LIST'), JText::_('AP_ENABLE_BBCODE_LIST_DESC'));
     JCommentsAdmin::loadParam($permissions, 'enable_bbcode_hide', $groups, JText::_('A_RIGHTS_BBCODE'), JText::_('AP_ENABLE_BBCODE_HIDE'), JText::_('AP_ENABLE_BBCODE_HIDE_DESC'), array('Public'));
     JCommentsAdmin::loadParam($permissions, 'enable_bbcode_quote', $groups, JText::_('A_RIGHTS_BBCODE'), JText::_('AP_ENABLE_BBCODE_QUOTE'), JText::_('AP_ENABLE_BBCODE_QUOTE_DESC'));
     // View
     JCommentsAdmin::loadParam($permissions, 'autolinkurls', $groups, JText::_('A_RIGHTS_VIEW'), JText::_('AP_ENABLE_AUTOLINKURLS'), JText::_('AP_ENABLE_AUTOLINKURLS_DESC'));
     JCommentsAdmin::loadParam($permissions, 'emailprotection', $groups, JText::_('A_RIGHTS_VIEW'), JText::_('AP_ENABLE_EMAILPROTECTION'), JText::_('AP_ENABLE_EMAILPROTECTION_DESC'));
     JCommentsAdmin::loadParam($permissions, 'enable_gravatar', $groups, JText::_('A_RIGHTS_VIEW'), JText::_('AP_ENABLE_GRAVATAR'), JText::_('AP_ENABLE_GRAVATAR_DESC'));
     JCommentsAdmin::loadParam($permissions, 'can_view_email', $groups, JText::_('A_RIGHTS_VIEW'), JText::_('AP_CAN_VIEW_AUTHOR_EMAIL'), JText::_('AP_CAN_VIEW_AUTHOR_EMAIL_DESC'));
     JCommentsAdmin::loadParam($permissions, 'can_view_homepage', $groups, JText::_('A_RIGHTS_VIEW'), JText::_('AP_CAN_VIEW_AUTHOR_HOMEPAGE'), JText::_('AP_CAN_VIEW_AUTHOR_HOMEPAGE_DESC'));
     JCommentsAdmin::loadParam($permissions, 'can_view_ip', $groups, JText::_('A_RIGHTS_VIEW'), JText::_('AP_CAN_VIEW_AUTHOR_IP'), JText::_('AP_CAN_VIEW_AUTHOR_IP_DESC'), array('Public', 'Registered'));
     // Edit
     JCommentsAdmin::loadParam($permissions, 'can_edit_own', $groups, JText::_('A_RIGHTS_EDIT'), JText::_('AP_CAN_EDIT_OWN'), JText::_('AP_CAN_EDIT_OWN_DESC'), array('Public'));
     JCommentsAdmin::loadParam($permissions, 'can_delete_own', $groups, JText::_('A_RIGHTS_EDIT'), JText::_('AP_CAN_DELETE_OWN'), JText::_('AP_CAN_DELETE_OWN_DESC'), array('Public'));
     // Administration
     JCommentsAdmin::loadParam($permissions, 'can_edit', $groups, JText::_('A_RIGHTS_ADMINISTRATION'), JText::_('AP_CAN_EDIT'), JText::_('AP_CAN_EDIT_DESC'), array('Public', 'Registered'));
     JCommentsAdmin::loadParam($permissions, 'can_edit_for_my_object', $groups, JText::_('A_RIGHTS_ADMINISTRATION'), JText::_('AP_CAN_EDIT_FOR_MY_OBJECT'), JText::_('AP_CAN_EDIT_FOR_MY_OBJECT_DESC'), array('Public'));
     JCommentsAdmin::loadParam($permissions, 'can_publish', $groups, JText::_('A_RIGHTS_ADMINISTRATION'), JText::_('AP_CAN_PUBLISH'), JText::_('AP_CAN_PUBLISH_DESC'), array('Public', 'Registered'));
     JCommentsAdmin::loadParam($permissions, 'can_publish_for_my_object', $groups, JText::_('A_RIGHTS_ADMINISTRATION'), JText::_('AP_CAN_PUBLISH_FOR_MY_OBJECT'), JText::_('AP_CAN_PUBLISH_FOR_MY_OBJECT_DESC'), array('Public'));
     JCommentsAdmin::loadParam($permissions, 'can_delete', $groups, JText::_('A_RIGHTS_ADMINISTRATION'), JText::_('AP_CAN_DELETE'), JText::_('AP_CAN_DELETE_DESC'), array('Public', 'Registered'));
     JCommentsAdmin::loadParam($permissions, 'can_delete_for_my_object', $groups, JText::_('A_RIGHTS_ADMINISTRATION'), JText::_('AP_CAN_DELETE_FOR_MY_OBJECT'), JText::_('AP_CAN_DELETE_FOR_MY_OBJECT_DESC'), array('Public'));
     // Votes
     JCommentsAdmin::loadParam($permissions, 'can_vote', $groups, JText::_('A_RIGHTS_MISC'), JText::_('AP_CAN_VOTE'), JText::_('AP_CAN_VOTE_DESC'));
     JCommentsAdmin::loadParam($permissions, 'can_report', $groups, JText::_('A_RIGHTS_MISC'), JText::_('AP_CAN_REPORT'), JText::_('AP_CAN_REPORT_DESC'), $reportExclude, $reportError);
     JCommentsAdmin::loadParam($permissions, 'can_ban', $groups, JText::_('A_RIGHTS_MISC'), JText::_('AP_CAN_BAN'), JText::_('AP_CAN_BAN_DESC'), array('Public', 'Registered'));
     $lists['groups'] =& $permissions;
     if (JCOMMENTS_JVERSION == '1.0') {
         $lookupQuery = "SELECT c.id AS `value`, CONCAT_WS( ' / ', s.title, c.title) AS `text`" . "\n FROM #__sections AS s" . "\n INNER JOIN #__categories AS c ON c.section = s.id" . "\n WHERE c.id IN ( " . $config->get('enable_categories') . " )" . "\n ORDER BY s.title,c.title";
         $categoriesQuery = "SELECT c.id AS `value`, CONCAT_WS( ' / ', s.title, c.title) AS `text`" . "\n FROM #__sections AS s" . "\n INNER JOIN #__categories AS c ON c.section = s.id" . "\n ORDER BY s.title,c.title";
     } elseif (JCOMMENTS_JVERSION == '1.5') {
         $lookupQuery = "SELECT c.id AS `value`, CONCAT_WS( ' / ', s.title, c.title) AS `text`" . "\n FROM #__sections AS s" . "\n INNER JOIN #__categories AS c ON c.section = s.id" . "\n WHERE c.id IN ( " . $config->get('enable_categories') . " )" . "\n ORDER BY s.title,c.title";
         $categoriesQuery = "SELECT c.id AS `value`, CONCAT_WS( ' / ', s.title, c.title) AS `text`" . "\n FROM #__sections AS s" . "\n INNER JOIN #__categories AS c ON c.section = s.id" . "\n ORDER BY s.title,c.title";
     } else {
         $lookupQuery = "SELECT c.id AS `value`, c.title AS `text`" . "\n FROM #__categories AS c" . "\n WHERE c.extension = 'com_content'" . "\n AND c.id IN ( " . $config->get('enable_categories') . " )" . "\n ORDER BY c.title";
         $categoriesQuery = "SELECT c.id AS `value`, c.title AS `text`, c.level" . "\n FROM #__categories AS c" . "\n WHERE c.extension = 'com_content'" . "\n ORDER BY c.lft, c.title";
     }
     $db->setQuery($categoriesQuery);
     $categories = $db->loadObjectList();
     if (!is_array($categories)) {
         $categories = array();
     } else {
         if (JCOMMENTS_JVERSION == '1.7') {
             for ($i = 0, $n = count($categories); $i < $n; $i++) {
                 $repeat = $categories[$i]->level - 1 >= 0 ? $categories[$i]->level - 1 : 0;
                 $categories[$i]->text = str_repeat('- ', $repeat) . $categories[$i]->text;
             }
         }
     }
     if ($config->get('enable_categories') != '') {
         $db->setQuery($lookupQuery);
         $lookup = $db->loadObjectList();
     } else {
         $lookup = '';
     }
     $lists['categories'] = JCommentsHTML::selectList($categories, 'cfg_enable_categories[]', 'class="inputbox categories" size="10" multiple="multiple"', 'value', 'text', $lookup);
     $captcha = array();
     $captcha[] = JCommentsHTML::makeOption('kcaptcha', 'KCAPTCHA');
     $config->set('enable_mambots', 1);
     $enginesList = JCommentsEvent::trigger('onJCommentsCaptchaEngines');
     foreach ($enginesList as $engines) {
         foreach ($engines as $code => $text) {
             $captcha[] = JCommentsHTML::makeOption($code, $text);
         }
     }
     $disabledCAPTCHA = count($captcha) == 1 ? ' disabled="disabled"' : '';
     $lists["captcha"] = JCommentsHTML::selectList($captcha, 'cfg_captcha_engine', 'class="inputbox"' . $disabledCAPTCHA, 'value', 'text', $config->get('captcha_engine', 'kcaptcha'));
     HTML_JComments::showSettings($lists);
 }
 function show()
 {
     global $mainframe;
     $option = JCommentsInput::getVar('option');
     $object_group = trim($mainframe->getUserStateFromRequest("fog{$option}", 'fog', ''));
     $object_id = intval($mainframe->getUserStateFromRequest("foid{$option}", 'foid', 0));
     $flang = trim($mainframe->getUserStateFromRequest("flang{$option}", 'flang', ''));
     $fauthor = trim($mainframe->getUserStateFromRequest("fauthor{$option}", 'fauthor', ''));
     $fstate = trim($mainframe->getUserStateFromRequest("fstate{$option}", 'fstate', ''));
     $limit = intval($mainframe->getUserStateFromRequest("view{$option}limit", 'limit', $mainframe->getCfg('list_limit')));
     $limitstart = intval($mainframe->getUserStateFromRequest("view{$option}limitstart", 'limitstart', 0));
     $filter_order = $mainframe->getUserStateFromRequest($option . 'filter_order', 'filter_order', 'js.name');
     $filter_order_Dir = $mainframe->getUserStateFromRequest($option . 'filter_order_Dir', 'filter_order_Dir', 'asc');
     $search = trim($mainframe->getUserStateFromRequest($option . 'subscriptions.search', 'search', ''));
     if (JCOMMENTS_JVERSION == '1.5') {
         $search = JString::strtolower($search);
     } else {
         $search = strtolower($search);
     }
     if ($filter_order == "") {
         $filter_order = 'js.name';
     }
     if ($filter_order_Dir == "") {
         $filter_order_Dir = 'asc';
     }
     $lists['order'] = $filter_order;
     $lists['order_Dir'] = $filter_order_Dir;
     $lists['search'] = $search;
     $db =& JCommentsFactory::getDBO();
     $where = array();
     if ($object_group != '') {
         $where[] = 'js.object_group = "' . $object_group . '"';
     }
     if ($object_id != 0) {
         $where[] = 'js.object_id = ' . $object_id;
     }
     if ($flang != '') {
         $where[] = 'js.lang = "' . $flang . '"';
     }
     if (trim($fauthor) != '') {
         $where[] = 'js.name = "' . $fauthor . '"';
     }
     if (trim($fstate) != '' && trim($fstate) != '-1') {
         $where[] = 'js.published = "' . intval($fstate) . '"';
     }
     if ($search != '') {
         $where[] = '(js.name like "%' . $search . '%" OR js.email like "%' . $search . '%")';
     }
     $query = "SELECT COUNT(*)" . "\nFROM #__jcomments_subscriptions AS js" . (count($where) ? "\nWHERE " . implode(' AND ', $where) : "");
     $db->setQuery($query);
     $total = $db->loadResult();
     if (JCOMMENTS_JVERSION == '1.0') {
         require_once $mainframe->getCfg('absolute_path') . DS . 'administrator' . DS . 'includes' . DS . 'pageNavigation.php';
         $lists['pageNav'] = new mosPageNav($total, $limitstart, $limit);
     } else {
         jimport('joomla.html.pagination');
         $lists['pageNav'] = new JPagination($total, $limitstart, $limit);
     }
     $query = "SELECT js.*, u.name AS editor" . "\nFROM #__jcomments_subscriptions AS js" . "\n LEFT JOIN #__users AS u ON u.id = js.userid" . (count($where) ? "\nWHERE " . implode(' AND ', $where) : "") . "\nORDER BY " . $filter_order . ' ' . $filter_order_Dir;
     $db->setQuery($query, $lists['pageNav']->limitstart, $lists['pageNav']->limit);
     $lists['rows'] = $db->loadObjectList();
     // Filter by object_group (component)
     $query = "SELECT DISTINCT(object_group) AS name, object_group AS value " . "\nFROM #__jcomments_subscriptions" . "\nORDER BY name";
     $db->setQuery($query);
     $rows = $db->loadObjectList();
     $cnt = count($rows);
     if ($cnt > 1 || $cnt == 1 && ($total = 0)) {
         array_unshift($rows, JCommentsHTML::makeOption('', JText::_('A_FILTER_ALL_COMPONENTS'), 'name', 'value'));
         $lists['fog'] = JCommentsHTML::selectList($rows, 'fog', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'name', 'value', $object_group);
     } else {
         if ($cnt == 1) {
             if ($object_group == '') {
                 $object_group = $rows[0]->name;
             }
         }
     }
     unset($rows);
     if ($object_group != '') {
         $query = "SELECT DISTINCT(object_id) AS value " . "\nFROM #__jcomments_subscriptions " . "\nWHERE object_group = '" . $object_group . "'" . ($flang != '' ? "AND lang = '" . $flang . "'" : "");
         $db->setQuery($query);
         $rows = $db->loadObjectList();
         for ($i = 0, $n = count($rows); $i < $n; $i++) {
             $rows[$i]->name = JCommentsObjectHelper::getTitle($rows[$i]->value, $object_group, $flang);
             if ($rows[$i]->name == '') {
                 $rows[$i]->name = 'Untitled' . $rows[$i]->value;
             }
         }
         // Don't show filter if we have more than 100 objects
         if (count($rows) < 100) {
             usort($rows, create_function('$a, $b', 'return strcasecmp( $a->name, $b->name);'));
             array_unshift($rows, JCommentsHTML::makeOption('', '', 'name', 'value'));
             $lists['foid'] = JCommentsHTML::selectList($rows, 'foid', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'value', 'name', $object_id);
             unset($rows);
         }
     }
     // Filter by language
     $query = "SELECT DISTINCT(lang) AS text, lang AS value " . "\nFROM #__jcomments_subscriptions" . "\nORDER BY lang";
     $db->setQuery($query);
     $rows = $db->loadObjectList();
     if (count($rows) > 1) {
         array_unshift($rows, JCommentsHTML::makeOption('', '', 'text', 'value'));
         $lists['flang'] = JCommentsHTML::selectList($rows, 'flang', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'text', 'value', $flang);
     }
     unset($rows);
     // Filter by published state
     $stateOptions = array();
     $stateOptions[] = JCommentsHTML::makeOption('', JText::_('Select state'), 'text', 'value');
     $stateOptions[] = JCommentsHTML::makeOption('-1', JText::_('All'), 'text', 'value');
     $stateOptions[] = JCommentsHTML::makeOption('1', JText::_('Published'), 'text', 'value');
     $stateOptions[] = JCommentsHTML::makeOption('0', JText::_('Unpublished'), 'text', 'value');
     $lists['fstate'] = JCommentsHTML::selectList($stateOptions, 'fstate', 'class="inputbox" size="1" onchange="document.adminForm.submit();"', 'text', 'value', $fstate);
     unset($stateOptions);
     // Filter by author
     $lists['fauthor'] = '';
     $db->setQuery("SELECT COUNT(DISTINCT(name)) FROM #__jcomments_subscriptions;");
     $usersCount = $db->loadResult();
     // Don't show filter if we have more than 100 comments' authors
     if ($usersCount > 0 && $usersCount < 100) {
         $query = "SELECT DISTINCT(name) AS author, name AS value " . "\nFROM #__jcomments_subscriptions" . "\nORDER BY name";
         $db->setQuery($query);
         $rows = $db->loadObjectList();
         if (count($rows) > 1) {
             array_unshift($rows, JCommentsHTML::makeOption('', JText::_('A_FILTER_ALL_AUTHORS'), 'author', 'value'));
             $lists['fauthor'] = JCommentsHTML::selectList($rows, 'fauthor', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'author', 'value', $fauthor);
         }
         unset($rows);
     }
     HTML_JCommentsAdminSubscriptionManager::show($lists);
 }
 function showSettings()
 {
     $db =& JCommentsFactory::getDBO();
     $config =& JCommentsFactory::getConfig();
     // check current site template for afterDisplayContent event
     if (JCOMMENTS_JVERSION == '1.5') {
         $db->setQuery('SELECT template FROM #__templates_menu WHERE client_id = 0 AND menuid = 0', 0, 1);
         $template = $db->loadResult();
         $articleTemplate = JPATH_SITE . DS . 'templates' . DS . $template . DS . 'html' . DS . 'com_content' . DS . 'article' . DS . 'default.php';
         if (is_file($articleTemplate)) {
             $tmpl = implode('', file($articleTemplate));
             if (strpos($tmpl, 'afterDisplayContent') === false) {
                 JError::raiseWarning(500, JText::_('Your current site template doesn\'t have afterDisplayContent event!'));
             }
         }
     }
     $languages = array();
     $joomfish = JOOMLATUNE_JPATH_SITE . DS . 'components' . DS . 'com_joomfish' . DS . 'joomfish.php';
     if (is_file($joomfish)) {
         $db =& JCommentsFactory::getDBO();
         $db->setQuery("SELECT `name`, `code` as value FROM `#__languages` WHERE `active` = 1");
         $languages = $db->loadObjectList();
         if (is_array($languages)) {
             $lang = trim(JCommentsInput::getVar('lang', ''));
             if ($lang == '') {
                 if (JCOMMENTS_JVERSION == '1.5') {
                     $params = JComponentHelper::getParams('com_languages');
                     $lang = $params->get("site", 'en-GB');
                 }
                 if ($lang == '') {
                     $lang = JCommentsMultilingual::getLanguage();
                 }
             }
             // reload configuration
             $config =& JCommentsFactory::getConfig($lang);
             $lists['languages'] = JCommentsHTML::selectList($languages, 'lang', 'class="inputbox" size="1" onchange="submitform(\'settings\');"', 'value', 'name', $lang);
         }
     }
     $forbiddenNames = $config->get('forbidden_names');
     $forbiddenNames = preg_replace('#,+#', "\n", $forbiddenNames);
     $config->set('forbidden_names', $forbiddenNames);
     $badWords = $config->get('badwords');
     if ($badWords != '') {
         $config->set('badwords', implode("\n", $badWords));
     }
     require_once JCOMMENTS_LIBRARIES . DS . 'joomlatune' . DS . 'filesystem.php';
     // path to images directory
     $path = JCOMMENTS_BASE . DS . 'tpl' . DS;
     $items = JoomlaTuneFS::readDirectory($path);
     $templates = array();
     foreach ($items as $item) {
         if (is_dir($path . $item)) {
             $tpl = new StdClass();
             $tpl->text = $item;
             $tpl->value = $item;
             $templates[] = $tpl;
         }
     }
     $currentTemplate = $config->get('template');
     $lists['templates'] = JCommentsHTML::selectList($templates, 'cfg_template', 'class="inputbox"', 'value', 'text', $currentTemplate);
     $rows = JCommentsAdmin::getAllGroups();
     $exclude = JCommentsAdmin::getHigherGroups();
     if (count($exclude)) {
         // remove users 'above' me
         $i = 0;
         while ($i < count($rows)) {
             if (in_array($rows[$i]->group_id, $exclude)) {
                 array_splice($rows, $i, 1);
             } else {
                 $i++;
             }
         }
     }
     $captchaError = '';
     $captchaExclude = array();
     if (!extension_loaded('gd') || !function_exists('imagecreatefrompng')) {
         if ($config->get('captcha_engine', 'kcaptcha') != 'recaptcha') {
             foreach ($rows as $row) {
                 $captchaExclude[] = $row->value;
             }
             $captchaError = JText::_('GD library is not installed!');
         }
     }
     $lists['group_names'] = $rows;
     $groups = array();
     // Post
     JCommentsAdmin::loadParam($groups, 'can_comment', $rows, JText::_('A_RIGHTS_POST'), JText::_('AP_CAN_COMMENT'), JText::_('AP_CAN_COMMENT_DESC'));
     JCommentsAdmin::loadParam($groups, 'can_reply', $rows, JText::_('A_RIGHTS_POST'), JText::_('AP_CAN_REPLY'), JText::_('AP_CAN_REPLY_DESC'));
     JCommentsAdmin::loadParam($groups, 'autopublish', $rows, JText::_('A_RIGHTS_POST'), JText::_('AP_AUTOPUBLISH'), JText::_('AP_AUTOPUBLISH_DESC'));
     JCommentsAdmin::loadParam($groups, 'show_policy', $rows, JText::_('A_RIGHTS_POST'), JText::_('AP_SHOW_POLICY'), JText::_('AP_SHOW_POLICY_DESC'));
     JCommentsAdmin::loadParam($groups, 'enable_captcha', $rows, JText::_('A_RIGHTS_POST'), JText::_('AP_ENABLE_CAPTCHA'), JText::_('AP_ENABLE_CAPTCHA_DESC'), $captchaExclude, $captchaError);
     JCommentsAdmin::loadParam($groups, 'floodprotection', $rows, JText::_('A_RIGHTS_POST'), JText::_('AP_ENABLE_FLOODPROTECTION'), JText::_('AP_ENABLE_FLOODPROTECTION_DESC'));
     JCommentsAdmin::loadParam($groups, 'enable_comment_length_check', $rows, JText::_('A_RIGHTS_POST'), JText::_('AP_ENABLE_COMMENT_LENGTH_CHECK'), JText::_('AP_ENABLE_COMMENT_LENGTH_CHECK_DESC'));
     JCommentsAdmin::loadParam($groups, 'enable_autocensor', $rows, JText::_('A_RIGHTS_POST'), JText::_('AP_ENABLE_AUTOCENSOR'), JText::_('AP_ENABLE_AUTOCENSOR_DESC'));
     JCommentsAdmin::loadParam($groups, 'enable_subscribe', $rows, JText::_('A_RIGHTS_POST'), JText::_('AP_ENABLE_SUBSCRIBE'), JText::_('AP_ENABLE_SUBSCRIBE_DESC'));
     // BBCodes
     JCommentsAdmin::loadParam($groups, 'enable_bbcode_b', $rows, JText::_('A_RIGHTS_BBCODE'), JText::_('AP_ENABLE_BBCODE_B'), JText::_('AP_ENABLE_BBCODE_B_DESC'));
     JCommentsAdmin::loadParam($groups, 'enable_bbcode_i', $rows, JText::_('A_RIGHTS_BBCODE'), JText::_('AP_ENABLE_BBCODE_I'), JText::_('AP_ENABLE_BBCODE_I_DESC'));
     JCommentsAdmin::loadParam($groups, 'enable_bbcode_u', $rows, JText::_('A_RIGHTS_BBCODE'), JText::_('AP_ENABLE_BBCODE_U'), JText::_('AP_ENABLE_BBCODE_U_DESC'));
     JCommentsAdmin::loadParam($groups, 'enable_bbcode_s', $rows, JText::_('A_RIGHTS_BBCODE'), JText::_('AP_ENABLE_BBCODE_S'), JText::_('AP_ENABLE_BBCODE_S_DESC'));
     JCommentsAdmin::loadParam($groups, 'enable_bbcode_url', $rows, JText::_('A_RIGHTS_BBCODE'), JText::_('AP_ENABLE_BBCODE_URL'), JText::_('AP_ENABLE_BBCODE_URL_DESC'));
     JCommentsAdmin::loadParam($groups, 'enable_bbcode_img', $rows, JText::_('A_RIGHTS_BBCODE'), JText::_('AP_ENABLE_BBCODE_IMG'), JText::_('AP_ENABLE_BBCODE_IMG_DESC'));
     JCommentsAdmin::loadParam($groups, 'enable_bbcode_list', $rows, JText::_('A_RIGHTS_BBCODE'), JText::_('AP_ENABLE_BBCODE_LIST'), JText::_('AP_ENABLE_BBCODE_LIST_DESC'));
     JCommentsAdmin::loadParam($groups, 'enable_bbcode_hide', $rows, JText::_('A_RIGHTS_BBCODE'), JText::_('AP_ENABLE_BBCODE_HIDE'), JText::_('AP_ENABLE_BBCODE_HIDE_DESC'), array('Unregistered'));
     JCommentsAdmin::loadParam($groups, 'enable_bbcode_quote', $rows, JText::_('A_RIGHTS_BBCODE'), JText::_('AP_ENABLE_BBCODE_QUOTE'), JText::_('AP_ENABLE_BBCODE_QUOTE_DESC'));
     // View
     JCommentsAdmin::loadParam($groups, 'autolinkurls', $rows, JText::_('A_RIGHTS_VIEW'), JText::_('AP_ENABLE_AUTOLINKURLS'), JText::_('AP_ENABLE_AUTOLINKURLS_DESC'));
     JCommentsAdmin::loadParam($groups, 'emailprotection', $rows, JText::_('A_RIGHTS_VIEW'), JText::_('AP_ENABLE_EMAILPROTECTION'), JText::_('AP_ENABLE_EMAILPROTECTION_DESC'));
     JCommentsAdmin::loadParam($groups, 'enable_gravatar', $rows, JText::_('A_RIGHTS_VIEW'), JText::_('AP_ENABLE_GRAVATAR'), JText::_('AP_ENABLE_GRAVATAR_DESC'));
     JCommentsAdmin::loadParam($groups, 'can_view_email', $rows, JText::_('A_RIGHTS_VIEW'), JText::_('AP_CAN_VIEW_AUTHOR_EMAIL'), JText::_('AP_CAN_VIEW_AUTHOR_EMAIL_DESC'));
     JCommentsAdmin::loadParam($groups, 'can_view_homepage', $rows, JText::_('A_RIGHTS_VIEW'), JText::_('AP_CAN_VIEW_AUTHOR_HOMEPAGE'), JText::_('AP_CAN_VIEW_AUTHOR_HOMEPAGE_DESC'));
     JCommentsAdmin::loadParam($groups, 'can_view_ip', $rows, JText::_('A_RIGHTS_VIEW'), JText::_('AP_CAN_VIEW_AUTHOR_IP'), JText::_('AP_CAN_VIEW_AUTHOR_IP_DESC'), array('Unregistered', 'Registered'));
     // Edit
     JCommentsAdmin::loadParam($groups, 'can_edit_own', $rows, JText::_('A_RIGHTS_EDIT'), JText::_('AP_CAN_EDIT_OWN'), JText::_('AP_CAN_EDIT_OWN_DESC'), array('Unregistered'));
     JCommentsAdmin::loadParam($groups, 'can_delete_own', $rows, JText::_('A_RIGHTS_EDIT'), JText::_('AP_CAN_DELETE_OWN'), JText::_('AP_CAN_DELETE_OWN_DESC'), array('Unregistered'));
     // Administration
     JCommentsAdmin::loadParam($groups, 'can_edit', $rows, JText::_('A_RIGHTS_ADMINISTRATION'), JText::_('AP_CAN_EDIT'), JText::_('AP_CAN_EDIT_DESC'), array('Unregistered', 'Registered'));
     JCommentsAdmin::loadParam($groups, 'can_publish', $rows, JText::_('A_RIGHTS_ADMINISTRATION'), JText::_('AP_CAN_PUBLISH'), JText::_('AP_CAN_PUBLISH_DESC'), array('Unregistered', 'Registered'));
     JCommentsAdmin::loadParam($groups, 'can_delete', $rows, JText::_('A_RIGHTS_ADMINISTRATION'), JText::_('AP_CAN_DELETE'), JText::_('AP_CAN_DELETE_DESC'), array('Unregistered', 'Registered'));
     // Votes
     JCommentsAdmin::loadParam($groups, 'can_vote', $rows, JText::_('A_RIGHTS_MISC'), JText::_('AP_CAN_VOTE'), JText::_('AP_CAN_VOTE_DESC'));
     $reportError = '';
     $reportExclude = array();
     if ($config->getInt('enable_notification') == 0 || $config->check('notification_type', 2) == false) {
         foreach ($rows as $row) {
             $reportExclude[] = $row->value;
         }
         $reportError = JText::_('Notifications are disabled! Please, enable notifications first.');
     }
     JCommentsAdmin::loadParam($groups, 'can_report', $rows, JText::_('A_RIGHTS_MISC'), JText::_('AP_CAN_REPORT'), JText::_('AP_CAN_REPORT_DESC'), $reportExclude, $reportError);
     $lists['groups'] =& $groups;
     if ($config->get('enable_categories') != '') {
         $query = "SELECT c.id AS `value`, CONCAT_WS( ' / ', s.title, c.title) AS `text`" . "\n FROM #__sections AS s" . "\n INNER JOIN #__categories AS c ON c.section = s.id" . "\n WHERE c.id IN ( " . $config->get('enable_categories') . " )" . "\n ORDER BY s.name,c.name";
         $db->setQuery($query);
         $lookup = $db->loadObjectList();
     } else {
         $lookup = '';
     }
     $query = "SELECT c.id AS `value`, CONCAT_WS( ' / ', s.title, c.title) AS `text`" . "\n FROM #__sections AS s" . "\n INNER JOIN #__categories AS c ON c.section = s.id" . "\n ORDER BY s.name,c.name";
     $db->setQuery($query);
     $categories = $db->loadObjectList();
     if (!is_array($categories)) {
         $categories = array();
     }
     $lists['categories'] = JCommentsHTML::selectList($categories, 'cfg_enable_categories[]', 'class="inputbox" size="10" multiple="multiple"', 'value', 'text', $lookup);
     $captcha = array();
     $captcha[] = JCommentsHTML::makeOption('kcaptcha', 'KCAPTCHA');
     require_once JCOMMENTS_HELPERS . DS . 'plugin.php';
     JCommentsPluginHelper::importPlugin('jcomments');
     $enginesList = JCommentsPluginHelper::trigger('onJCommentsCaptchaEngines');
     foreach ($enginesList as $engines) {
         foreach ($engines as $code => $text) {
             $captcha[] = JCommentsHTML::makeOption($code, $text);
         }
     }
     $disabledCAPTCHA = count($captcha) == 1 ? ' disabled="disabled"' : '';
     $lists["captcha"] = JCommentsHTML::selectList($captcha, 'cfg_captcha_engine', 'class="inputbox"' . $disabledCAPTCHA, 'value', 'text', $config->get('captcha_engine'));
     HTML_JComments::showSettings($lists);
 }