From 445a5866ada6065b63d89e6c89996cda74e402e7 Mon Sep 17 00:00:00 2001 From: Dmitriy Simushev Date: Wed, 22 Oct 2014 14:15:05 +0000 Subject: [PATCH] Add "invitationIgnore" event --- .../libs/classes/Mibew/EventDispatcher/Events.php | 10 ++++++++++ src/mibew/libs/invitation.php | 8 +++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/mibew/libs/classes/Mibew/EventDispatcher/Events.php b/src/mibew/libs/classes/Mibew/EventDispatcher/Events.php index 857285f4..a797eefc 100644 --- a/src/mibew/libs/classes/Mibew/EventDispatcher/Events.php +++ b/src/mibew/libs/classes/Mibew/EventDispatcher/Events.php @@ -98,6 +98,16 @@ final class Events */ const INVITATION_REJECT = 'invitationReject'; + /** + * An invitation is ignored. + * + * This event is triggered after an invitation has been ignored by a + * visitor and automatically closed by the system. An associative array with + * the following items is passed to the event handlers: + * - "invitation": an instance of {@link \Mibew\Thread} class. + */ + const INVITATION_IGNORE = 'invitationIgnore'; + /** * An operator cannot be authenticated. * diff --git a/src/mibew/libs/invitation.php b/src/mibew/libs/invitation.php index 8fedc065..b4db9828 100644 --- a/src/mibew/libs/invitation.php +++ b/src/mibew/libs/invitation.php @@ -245,7 +245,9 @@ function invitation_reject($visitor_id) } /** - * Close old invitations + * Close old invitations. + * + * Triggers {@link \Mibew\EventDispatcher\Events::INVITATION_IGNORE} event. */ function invitation_close_old() { @@ -294,6 +296,10 @@ function invitation_close_old() Thread::KIND_FOR_AGENT, getlocal('Visitor ignored invitation and it was closed automatically', null, $thread->locale, true) ); + + $args = array('invitation' => $thread); + EventDispatcher::getInstance()->triggerEvent(Events::INVITATION_IGNORE, $args); + unset($thread); } }