<?php

use KupShop\KupShopBundle\Util\Compat\ServiceContainer;

class Checktimeout extends Window
{
    public function get_vars()
    {
        $vars = parent::get_vars();

        $pageVars = getVal('body', $vars);

        if (getVal('frame')) {
            $this->setTemplate('window/checktimeoutFrame.tpl');
        } else {
            $this->setTemplate('window/checktimeoutWindow.tpl');
        }

        $session = ServiceContainer::getService('session');

        $pageVars['expiry'] = $session->get('_expiry');
        $pageVars['time'] = time();

        $vars['body'] = $pageVars;

        return $vars;
    }

    public function handle()
    {
    }

    public function hasRights($name = null)
    {
        switch ($name) {
            case Window::RIGHT_SAVE:
            case Window::RIGHT_DELETE:
            case Window::RIGHT_DUPLICATE:
                return false;
            default:
                return parent::hasRights($name);
        }
    }
}

$checktimeout = new Checktimeout();
$checktimeout->run();
