Skip to content
This repository was archived by the owner on Dec 29, 2022. It is now read-only.

Commit cada8bb

Browse files
committed
Merge pull request #49 from Guite/master
Added filtering for hook areas
2 parents cd9e189 + 9704cab commit cada8bb

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

lib/EZComments/Api/User.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ public function getall($args = array())
6363
// object id
6464
if (isset($args['mod'])) {
6565
$whereclause[] = "$columns[modname] = '" . DataUtil::formatForStore($args['mod']) . "'";
66+
if (isset($args['areaId'])) {
67+
$whereclause[] = "$columns[areaid] = '" . DataUtil::formatForStore($args['areaId']) . "'";
68+
} elseif (isset($args['areaid'])) {
69+
$whereclause[] = "$columns[areaid] = '" . DataUtil::formatForStore($args['areaid']) . "'";
70+
}
6671
if (isset($args['objectid'])) {
6772
$whereclause[] = "$columns[objectid] = '" . DataUtil::formatForStore($args['objectid']) . "'";
6873
}

lib/EZComments/HookHandlers.php

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public function uiView(Zikula_DisplayHook $hook)
3232
{
3333
// work out the input from the hook
3434
$mod = $hook->getCaller();
35+
$areaId = $hook->getAreaId();
3536
$objectid = $hook->getId();
3637

3738
// first check if the user is allowed to do any comments for this module/objectid
@@ -70,7 +71,7 @@ public function uiView(Zikula_DisplayHook $hook)
7071
$numitems = -1;
7172
}
7273

73-
$params = compact('mod', 'objectid', 'sortorder', 'status', 'numitems', 'startnum');
74+
$params = compact('mod', 'areaId', 'objectid', 'sortorder', 'status', 'numitems', 'startnum');
7475
$items = ModUtil::apiFunc('EZComments', 'user', 'getall', $params);
7576

7677
if ($items === false) {
@@ -88,16 +89,16 @@ public function uiView(Zikula_DisplayHook $hook)
8889
// create the output object
8990
$view = Zikula_View::getInstance('EZComments', false, null, true);
9091

91-
$view->assign('areaid', $hook->getAreaId());
92-
$view->assign('comments', $items);
93-
$view->assign('commentcount', $commentcount);
94-
$view->assign('ezcomment', $ezcomment);
95-
$view->assign('ezc_info', compact('mod', 'objectid', 'sortorder', 'status'));
96-
$view->assign('modinfo', ModUtil::getInfo(ModUtil::getIdFromName($mod)));
97-
$view->assign('msgmodule', System::getVar('messagemodule', ''));
98-
$view->assign('prfmodule', System::getVar('profilemodule', ''));
99-
$view->assign('allowadd', SecurityUtil::checkPermission('EZComments::', "$mod:$objectid:", ACCESS_COMMENT));
100-
$view->assign('loggedin', UserUtil::isLoggedIn());
92+
$view->assign('areaid', $areaId)
93+
->assign('comments', $items)
94+
->assign('commentcount', $commentcount)
95+
->assign('ezcomment', $ezcomment)
96+
->assign('ezc_info', compact('mod', 'objectid', 'sortorder', 'status'))
97+
->assign('modinfo', ModUtil::getInfo(ModUtil::getIdFromName($mod)))
98+
->assign('msgmodule', System::getVar('messagemodule', ''))
99+
->assign('prfmodule', System::getVar('profilemodule', ''))
100+
->assign('allowadd', SecurityUtil::checkPermission('EZComments::', "$mod:$objectid:", ACCESS_COMMENT))
101+
->assign('loggedin', UserUtil::isLoggedIn());
101102

102103
$modUrl = $hook->getUrl();
103104
$redirect = (!is_null($modUrl)) ? $modUrl->getUrl() : '';

0 commit comments

Comments
 (0)