Add "invitationCreate" event

This commit is contained in:
Dmitriy Simushev 2014-10-20 12:27:10 +00:00
parent 09b3d77b19
commit 5ad1044dc0
2 changed files with 18 additions and 0 deletions

View File

@ -50,6 +50,16 @@ final class Events
*/
const GROUP_DELETE = 'groupDelete';
/**
* An invitation is created.
*
* This event is triggered after an invitation has been created. An
* associative array with the following items is passed to the event
* handlers:
* - "invitation": an instance of {@link \Mibew\Thread} class.
*/
const INVITATION_CREATE = 'invitationCreate';
/**
* An operator cannot be authenticated.
*

View File

@ -18,6 +18,8 @@
*/
// Import namespaces and classes of the core
use Mibew\EventDispatcher\EventDispatcher;
use Mibew\EventDispatcher\Events;
use Mibew\Database;
use Mibew\Settings;
use Mibew\Thread;
@ -59,6 +61,8 @@ function invitation_state($visitor_id)
/**
* Invite visitor by operator
*
* Triggers {@link \Mibew\EventDispatcher\Events::INVITATION_CREATE} event.
*
* @param int $visitor_id ID of the visitor, who must be invited.
* @param array $operator Info for operator who invite the visitor
* @return Thread|boolean Thread object related with invitation or boolean
@ -137,6 +141,10 @@ function invitation_invite($visitor_id, $operator)
)
);
// Let plugins know about the invitation.
$args = array('invitation' => $thread);
EventDispatcher::getInstance()->triggerEvent(Events::INVITATION_CREATE, $args);
return $thread;
}