public static function show()
 {
     $app = JCommentsFactory::getApplication('administrator');
     $context = 'com_jcomments.custombbcodes.';
     $limit = intval($app->getUserStateFromRequest($context . 'limit', 'limit', $app->getCfg('list_limit')));
     $limitstart = intval($app->getUserStateFromRequest($context . 'limitstart', 'limitstart', 0));
     $db = JCommentsFactory::getDBO();
     $db->setQuery('SELECT COUNT(*) FROM #__jcomments_custom_bbcodes');
     $total = $db->loadResult();
     $lists['pageNav'] = JCommentsAdmin::getPagination($total, $limitstart, $limit);
     $query = "SELECT * FROM #__jcomments_custom_bbcodes ORDER BY ordering";
     $db->setQuery($query, $lists['pageNav']->limitstart, $lists['pageNav']->limit);
     $lists['rows'] = $db->loadObjectList();
     HTML_JCommentsACustomBBCodes::show($lists);
 }
Exemplo n.º 2
0
 public static function show()
 {
     $app = JCommentsFactory::getApplication('administrator');
     $config = JCommentsFactory::getConfig();
     if ($config->getInt('enable_blacklist') == 0) {
         if (JCOMMENTS_JVERSION != '1.0') {
             JError::raiseWarning(500, JText::_('A_BLACKLIST_WARNING_BLACKLIST_IS_DISABLED'));
         }
     }
     $context = 'com_jcomments.blacklist.';
     $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', 'bl.created');
     $filter_order_Dir = $app->getUserStateFromRequest($context . 'filter_order_Dir', 'filter_order_Dir', 'desc');
     $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 = 'bl.created';
     }
     if ($filter_order_Dir == '') {
         $filter_order_Dir = 'desc';
     }
     $lists['order'] = $filter_order;
     $lists['order_Dir'] = $filter_order_Dir;
     $lists['search'] = $search;
     $db = JCommentsFactory::getDBO();
     $where = array();
     if ($search != '') {
         $where[] = '(LOWER(bl.ip) like "%' . $db->getEscaped($search, true) . '%")' . ' OR LOWER(bl.reason) like "%' . $db->getEscaped($search, true) . '%"' . ' OR LOWER(bl.notes) like "%' . $db->getEscaped($search, true) . '%"';
     }
     $query = "SELECT COUNT(*)" . " FROM #__jcomments_blacklist AS bl" . (count($where) ? " WHERE " . implode(' AND ', $where) : "");
     $db->setQuery($query);
     $total = $db->loadResult();
     $lists['pageNav'] = JCommentsAdmin::getPagination($total, $limitstart, $limit);
     $query = "SELECT bl.*, u.name AS editor" . " FROM #__jcomments_blacklist AS bl" . " LEFT JOIN #__users AS u ON u.id = bl.checked_out" . (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();
     HTML_JCommentsAdminBlacklistManager::show($lists);
 }
 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);
 }
Exemplo n.º 4
0
 public static function show()
 {
     require_once JCOMMENTS_BASE . '/jcomments.php';
     $app = JCommentsFactory::getApplication('administrator');
     $context = 'com_jcomments.comments.';
     $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', ''));
     $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', 'c.date');
     $filter_order_Dir = $app->getUserStateFromRequest($context . 'filter_order_Dir', 'filter_order_Dir', 'desc');
     $search = trim($app->getUserStateFromRequest($context . 'search', 'search', ''));
     if ($filter_order == '') {
         $filter_order = 'c.date';
     }
     if ($filter_order_Dir == '') {
         $filter_order_Dir = 'desc';
     }
     if (JCOMMENTS_JVERSION == '1.0') {
         $search = strtolower($search);
     } else {
         $search = JString::strtolower($search);
     }
     $lists['order'] = $filter_order;
     $lists['order_Dir'] = $filter_order_Dir;
     $lists['search'] = $search;
     $db = JCommentsFactory::getDBO();
     // load object_groups (components)
     $query = "SELECT DISTINCT(object_group) AS name, object_group AS value " . " FROM #__jcomments_objects " . " WHERE object_group <> ''" . " ORDER BY object_group";
     $db->setQuery($query);
     $objectGroups = $db->loadObjectList('name');
     $cnt = count($objectGroups);
     if ($cnt == 0 || $cnt > 0 && !in_array($object_group, array_keys($objectGroups))) {
         $app->setUserState($context . "fog", '');
         $app->setUserState($context . "foid", '');
         $object_group = '';
     }
     $where = array();
     if ($object_group != '') {
         $where[] = 'c.object_group = ' . $db->Quote($object_group);
     } else {
         $object_id = 0;
         $app->setUserState($context . "foid", '');
     }
     if ($object_id != 0) {
         $where[] = 'c.object_id = ' . intval($object_id);
     }
     if ($flang != '-1') {
         $where[] = 'c.lang = ' . $db->Quote($flang);
     }
     if (trim($fauthor) != '') {
         $where[] = 'c.name = ' . $db->Quote($fauthor);
     }
     if ($fstate != '' && $fstate != '-1') {
         if ($fstate == '2') {
             $where[] = 'EXISTS (SELECT * FROM #__jcomments_reports AS r WHERE r.commentid = c.id)';
         } else {
             $where[] = 'c.published = ' . intval($fstate);
         }
     }
     if ($search != '') {
         $where[] = '(' . 'LOWER(c.comment) like "%' . $db->getEscaped($search, true) . '%" OR ' . 'LOWER(c.title) like "%' . $db->getEscaped($search, true) . '%" OR ' . 'LOWER(c.name) like "%' . $db->getEscaped($search, true) . '%" OR ' . 'LOWER(c.username) like "%' . $db->getEscaped($search, true) . '%" OR ' . 'LOWER(c.email) like "%' . $db->getEscaped($search, true) . '%"' . ')';
     }
     // TODO: add filter to show deleted comments
     $where[] = 'c.deleted = 0';
     $query = "SELECT COUNT(*)" . "\nFROM #__jcomments AS c" . (count($where) ? "\nWHERE " . implode(' AND ', $where) : "");
     $db->setQuery($query);
     $total = $db->loadResult();
     $lists['pageNav'] = JCommentsAdmin::getPagination($total, $limitstart, $limit);
     $query = "SELECT c.*, u.name AS editor, js.id as subscription, (select count(*) from #__jcomments_reports where commentid = c.id) as reports" . ", jo.title AS object_title, jo.link AS object_link" . "\nFROM #__jcomments AS c" . "\n LEFT JOIN #__jcomments_objects AS jo ON jo.object_id = c.object_id AND jo.object_group = c.object_group AND jo.lang = c.lang" . "\n LEFT JOIN #__users AS u ON u.id = c.checked_out" . "\n LEFT JOIN #__jcomments_subscriptions AS js ON js.object_id = c.object_id AND js.object_group = c.object_group AND ((c.userid > 0 AND js.userid = c.userid) OR (js.email <> '' AND c.email <> '' AND js.email = c.email)) AND js.lang = c.lang" . (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)
     $cnt = count($objectGroups);
     if (JCOMMENTS_JVERSION == '1.0') {
         $a = array();
         if (is_array($objectGroups)) {
             foreach ($objectGroups as $o) {
                 $a[] = $o;
             }
         }
         $objectGroups = $a;
     }
     if ($cnt > 1 || $cnt == 1 && $total == 0) {
         array_unshift($objectGroups, JCommentsHTML::makeOption('', JText::_('A_FILTER_COMPONENT'), 'name', 'value'));
         $lists['fog'] = JCommentsHTML::selectList($objectGroups, 'fog', 'class="inputbox" size="1" onchange="document.adminForm.submit();"', 'name', 'value', $object_group);
     } else {
         if ($cnt == 1) {
             /*
              			if ($object_group == '') {
             	$aGroups = array_keys($objectGroups);
             	$object_group = array_pop($aGroups);
             }
             */
         }
     }
     unset($objectGroups);
     // 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');
     $stateOptions[] = JCommentsHTML::makeOption('2', JText::_('A_FILTER_STATE_REPORTED'), 'text', 'value');
     $lists['fstate'] = JCommentsHTML::selectList($stateOptions, 'fstate', 'class="inputbox" size="1" onchange="document.adminForm.submit();"', 'text', 'value', $fstate);
     unset($stateOptions);
     // Filter by language
     $query = "SELECT DISTINCT(lang) AS text, lang AS value " . " FROM #__jcomments_objects " . "\nORDER 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 author
     $lists['fauthor'] = '';
     // Do not use user filter if we have more than 5000 comments
     if ($total <= 5000) {
         $db->setQuery("SELECT COUNT(DISTINCT(name)) FROM #__jcomments;");
         $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" . "\nWHERE name <> ''" . "\nORDER 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_JComments::show($lists);
 }