Menu

#778 Recent comments blocks shows all comments

XOOPS_2.0.x
closed
5
2014-12-28
2007-10-06
InstantZero
No

The recent comments block shows the comments of all the modules, even those where you don't have access.

Modify the file /xoops/modules/system/blocks/system_blocks.php

In the function b_system_comments_show() just after this line :
$criteria->setOrder('DESC');

insert :

global $xoopsUser;
$moduleperm_handler =& xoops_gethandler('groupperm');

$gperm_groupid = is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS;
$criteria1 = new CriteriaCompo(new Criteria('gperm_name', 'module_read','='));
if (is_array($gperm_groupid)) {
    $criteria2 = new CriteriaCompo();
    foreach ($gperm_groupid as $gid) {
        $criteria2->add(new Criteria('gperm_groupid', $gid), 'OR');
    }
    $criteria1->add($criteria2);
} else {
    $criteria1->add(new Criteria('gperm_groupid', intval($gperm_groupid)));
}
$perms = $moduleperm_handler->getObjects($criteria1, true);
$modIds = array();
foreach($perms as $item) {
    $modIds[] = $item->getVar('gperm_itemid');
}
if(count($modIds) > 0 ) {
    $modIds = array_unique($modIds);
    $criteria->add(new Criteria('com_modid', '('.implode(',', $modIds).')', 'IN'));
}

See this :
http://www.frxoops.org/modules/newbb/viewtopic.php?topic_id=21864&viewmode=flat&order=ASC&start=0

Discussion

  • GibaPhp

    GibaPhp - 2007-10-06

    Logged In: YES
    user_id=1129857
    Originator: NO

    Thanks Hervé ;-)

     
  • Laurent JEN

    Laurent JEN - 2007-10-24

    Logged In: YES
    user_id=1528770
    Originator: NO

    // Check modules permissions
    global $xoopsUser;
    $moduleperm_handler =& xoops_gethandler('groupperm');
    $gperm_groupid = is_object($xoopsUser) ? $xoopsUser->getGroups() : array(XOOPS_GROUP_ANONYMOUS);
    $criteria1 = new CriteriaCompo(new Criteria('gperm_name','module_read','='));
    $criteria1->add(new Criteria('gperm_groupid', '('.implode(',', $gperm_groupid).')', 'IN'));
    $perms = $moduleperm_handler->getObjects($criteria1, true);
    $modIds = array();
    foreach($perms as $item) {
        $modIds[] = $item->getVar('gperm_itemid');
    }
    if(count($modIds) > 0 ) {
        $modIds = array_unique($modIds);
        $criteria->add(new Criteria('com_modid', '('.implode(',', $modIds).')', 'IN'));
    }
    // Check modules permissions
    

    fixed on xoops 2.0.18

     

Log in to post a comment.