1 <?php
2
3 4 5 6 7 8 9 10
11
12 namespace Icybee\Modules\Users\NonceLogin;
13
14 use ICanBoogie\Operation\ProcessEvent;
15 use ICanBoogie\I18n\Translator\Proxi;
16 use ICanBoogie\Mailer;
17
18 class Hooks
19 {
20 21 22 23 24 25
26 static public function on_nonce_login_request(ProcessEvent $event, NonceLoginRequestOperation $target)
27 {
28 global $core;
29
30 $user = $target->user;
31 $ticket = $target->ticket;
32
33 $route = $core->routes['api:nonce-login'];
34 $url = $core->site->url . $route->format($ticket);
35 $until = $ticket->expire_at->local->format('H:i');
36
37 $t = new Proxi(array('scope' => \ICanBoogie\normalize($user->constructor, '_') . '.nonce_login_request.operation'));
38
39 $core->mailer(array
40 (
41 Mailer::T_DESTINATION => $user->email,
42 Mailer::T_FROM => $core->site->title . ' <no-reply@icybee.org>',
43 Mailer::T_SUBJECT => $t('message.subject'),
44 Mailer::T_MESSAGE => $t
45 (
46 'message.template', array
47 (
48 ':url' => $url,
49 ':until' => $until,
50 ':ip' => $event->request->ip
51 )
52 )
53 ));
54 }
55 }