1 | 2 | simandl | <?php |
2 | | | |
3 | | | namespace Phem\Controllers; |
4 | | | |
5 | | | use DateTime; |
6 | | | use Phem\Environment\Application; |
7 | | | use Phem\Environment\EnvironmentManager; |
8 | | | use Phem\Environment\Message; |
9 | | | use Phem\Environment\MessageArgs; |
10 | | | |
11 | | | /** |
12 | | | * |
13 | | | * @author kubapet |
14 | | | */ |
15 | | | class NotificationController extends Controller |
16 | | | { |
17 | | | |
18 | | | public function userWentOffline($uid) |
19 | | | { |
20 | | | sleep(15); |
21 | | | |
22 | | | $lock = Application::lockVarsWait(); |
23 | | | $users = Application::getUsers(); |
24 | | | $rlUsers = Application::getRecentlyLoggedUsers(); |
25 | | | $rlUsers->removeKey($uid); |
26 | | | Application::setRecentlyLoggedUsers($rlUsers); |
27 | | | $lock->unlock(); |
28 | | | |
29 | | | if ($users->get($uid) != null) |
30 | | | { |
31 | | | exit; |
32 | | | } |
33 | | | |
34 | | | $msgArgs = new MessageArgs(); |
35 | | | $msgArgs->setActionUrl(EnvironmentManager::getLinkBuilder()->navigate("Administration","loggedUsers")); |
36 | | | $msgArgs->setActionType("replace"); |
37 | | | $msgArgs->setActionTarget("loggedUsers"); |
38 | | | |
39 | | | $msg = new Message; |
40 | | | $msg->setSubject('UĹživatel je offline'); |
41 | | | $msg->getArgs()->add($msgArgs); |
42 | | | $msg->setDate(new DateTime(date("Y-m-d"))); |
43 | | | $msg->setFromUsr($uid); |
44 | | | |
45 | | | $msgArgs->setMessage($msg); |
46 | | | |
47 | | | //$msg->setText($uid); |
48 | | | Application::notify($msg); |
49 | | | } |
50 | | | |
51 | | | } |