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);
 }
 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);
 }