jablonka.czprosek.czf

freenet-router

Subversion Repositories:
[/] [trunk/] [freenet-router/] [var/] [www/] [freenet-router/] [Framework/] [Controllers/] [NotificationController.php] - Rev 2

Compare with Previous - Blame - Download


<?php

namespace Phem\Controllers;

use DateTime;
use Phem\Environment\Application;
use Phem\Environment\EnvironmentManager;
use Phem\Environment\Message;
use Phem\Environment\MessageArgs;

/**
 *
 * @author kubapet
 */
class NotificationController extends Controller
{

    public function userWentOffline($uid)
    {
        sleep(15);
        
        $lock = Application::lockVarsWait();
        $users = Application::getUsers();
        $rlUsers = Application::getRecentlyLoggedUsers();
        $rlUsers->removeKey($uid);
        Application::setRecentlyLoggedUsers($rlUsers);        
        $lock->unlock();

        if ($users->get($uid) != null)
        {
            exit;
        }

        $msgArgs = new MessageArgs();
        $msgArgs->setActionUrl(EnvironmentManager::getLinkBuilder()->navigate("Administration","loggedUsers"));
        $msgArgs->setActionType("replace");
        $msgArgs->setActionTarget("loggedUsers");

        $msg = new Message;
        $msg->setSubject('UĹživatel je offline');
        $msg->getArgs()->add($msgArgs);
        $msg->setDate(new DateTime(date("Y-m-d")));
        $msg->setFromUsr($uid);

        $msgArgs->setMessage($msg);

            //$msg->setText($uid);
        Application::notify($msg);         
    }

}

Powered by WebSVN 2.2.1