diff --git a/src/mibew/libs/classes/Mibew/EventDispatcher/Events.php b/src/mibew/libs/classes/Mibew/EventDispatcher/Events.php index ac0f0e41..40295809 100644 --- a/src/mibew/libs/classes/Mibew/EventDispatcher/Events.php +++ b/src/mibew/libs/classes/Mibew/EventDispatcher/Events.php @@ -60,6 +60,16 @@ final class Events */ const INVITATION_CREATE = 'invitationCreate'; + /** + * An invitation is accepted. + * + * This event is triggered after an invitation has been accepted by a + * visitor. An associative array with the following items is passed to the + * event handlers: + * - "invitation": an instance of {@link \Mibew\Thread} class. + */ + const INVITATION_ACCEPT = 'invitationAccept'; + /** * An operator cannot be authenticated. * diff --git a/src/mibew/libs/invitation.php b/src/mibew/libs/invitation.php index 12dab322..5b8bf3c2 100644 --- a/src/mibew/libs/invitation.php +++ b/src/mibew/libs/invitation.php @@ -151,6 +151,8 @@ function invitation_invite($visitor_id, $operator) /** * Invitation was accepted by visitor * + * Triggers {@link \Mibew\EventDispatcher\Events::INVITATION_ACCEPT} event. + * * @param int $visitor_id ID of the visitor who accept invitation * @return Thread|boolean Thread object or boolean false on failure */ @@ -195,6 +197,9 @@ function invitation_accept($visitor_id) array(':visitor_id' => $visitor_id) ); + $args = array('invitation' => $thread); + EventDispatcher::getInstance()->triggerEvent(Events::INVITATION_ACCEPT, $args); + return $thread; }