From 3619f9faaa7e7cd801fd654883630b7136774c05 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 20 Mar 2012 16:38:56 -0400 Subject: [PATCH] New events for overriding scope checks --- EVENTS.txt | 12 ++++++++++++ classes/Notice.php | 6 +++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/EVENTS.txt b/EVENTS.txt index 5fb775c765..eb3edb9b13 100644 --- a/EVENTS.txt +++ b/EVENTS.txt @@ -1430,3 +1430,15 @@ StartShowNoticeOptionItems: Before showing first controls in a notice list item; EndShowNoticeOptionItems: After showing last controls in a notice list item; inside the div - $nli: NoticeListItem being shown + +StartNoticeInScope: Before checking if a notice should be visible to a user +- $notice: The notice to check +- $profile: The profile to check for scope +- &$bResult: The boolean result; fill this in if you want to skip + +EndNoticeInScope: After checking if a notice should be visible to a user +- $notice: The notice to check +- $profile: The profile to check for scope +- &$bResult: The boolean result; overwrite this if you so desire + + diff --git a/classes/Notice.php b/classes/Notice.php index 9ee5696e3f..9e4dbec9e3 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -2365,7 +2365,11 @@ class Notice extends Managed_DataObject $result = self::cacheGet($keypart); if ($result === false) { - $bResult = $this->_inScope($profile); + $bResult = false; + if (Event::handle('StartNoticeInScope', array($notice, $profile, &$bResult))) { + $bResult = $this->_inScope($profile); + Event::handle('EndNoticeInScope', array($notice, $profile, &$bResult)); + } $result = ($bResult) ? 1 : 0; self::cacheSet($keypart, $result, 0, 300); } -- 2.39.5