Hey there!
Sorry for the delay! I suppose you both are using 1.5.
The problem was comming from the fact that we were declaring
The global $database object was there, but the gid was not.
So if you log in - your group id was always 0.
Now change that to
$database = JFactory::getDBO();
$user = JFactory::getUser();
$gid = $user->gid;
and it should work.
Open administrator/components/com_comment/plugins/com_content/jos_com_content.class.php
find the 2 functions mod_commentsGetMostCommentedQuery , mod_commentsGetOthersQuery and made the above changes.
At the end - the functions should look like this:
/*----------------------------------------------------------------------------------
* F U N C T I O N S F O R MOD_COMMENTS M O D U L E
*----------------------------------------------------------------------------------
*/
function mod_commentsGetMostCommentedQuery($secids, $catids, $maxlines)
{
$database = JFactory::getDBO();
$user = JFactory::getUser();
$gid = $user->gid;
$component = $this->_component;
$limit = $maxlines>=0 ? " limit $maxlines " : "";
$where = array();
if ($catids)
$where[] = "cat.id IN ($catids)";
if ($secids)
$where[] = "cat.section IN ($secids)";
/*
* Count comment id group by contentid
* TODO: restrict according content item user rights, dates and category/secitons published and dates...
*/
$query = "SELECT COUNT(c.id) AS countid, ct.id, ct.title "
. "\n FROM `vpo_comment` AS c "
. "\n INNER JOIN `vpo_content` AS ct ON ct.id = c.contentid "
. "\n INNER JOIN `vpo_categories` AS cat ON cat.id = ct.catid "
. "\n INNER JOIN `vpo_sections` AS sec ON sec.id = cat.section "
. "\n WHERE c.published='1' "
. "\n AND c.component='$component' "
. "\n AND sec.access <= " . (int) $gid
. "\n AND sec.published='1' "
. "\n AND cat.access <= " . (int) $gid
. "\n AND cat.published='1' "
. "\n AND ct.access <= " . (int) $gid
. "\n ". (count($where) ? (" AND ".implode(" AND ", $where)) : "")
. "\n GROUP BY c.contentid"
. "\n ORDER BY countid DESC"
. "\n $limit"
;
$database->SetQuery($query);
$rows = $database->loadAssocList();
return $rows;
}
function mod_commentsGetOthersQuery($secids, $catids, $maxlines, $orderby)
{
$database = JFactory::getDBO();
$user = JFactory::getUser();
$gid = $user->gid;
$component = $this->_component;
$limit = $maxlines>=0 ? " limit $maxlines " : "";
$where = array();
if ($catids)
$where[] = "cat.id IN ($catids)";
if ($secids)
$where[] = "cat.section IN ($secids)";
if ($orderby=='mostrated') {
$mostrated = ", (c.voting_yes-c.voting_no)/2 AS mostrated";
$where[] = "(c.voting_yes > 0 OR c.voting_no > 0)";
} else {
$mostrated = "";
$orderby = "c.$orderby";
}
$query = "SELECT c.*, ct.title AS ctitle $mostrated "
. "\n FROM `vpo_comment` AS c "
. "\n INNER JOIN `vpo_content` AS ct ON ct.id = c.contentid "
. "\n INNER JOIN `vpo_categories` AS cat ON cat.id = ct.catid "
. "\n INNER JOIN `vpo_sections` AS sec ON sec.id = cat.section "
. "\n WHERE c.published='1' "
. "\n AND c.component='$component' "
. "\n AND sec.access <= " . (int) $gid
. "\n AND sec.published='1' "
. "\n AND cat.access <= " . (int) $gid
. "\n AND cat.published='1' "
. "\n AND ct.access <= " . (int) $gid
. "\n ". (count($where) ? (" AND ".implode(" AND ", $where)) : "")
. "\n ORDER BY $orderby DESC "
. "\n $limit"
;
$database->SetQuery($query);
$rows = $database->loadAssocList();
return $rows;
}
Hope that solves the problem! Awaiting feedback!
Greetings!
Daniel