2013-05-03 17:02:53 +02:00
|
|
|
<?php
|
2013-05-16 03:16:56 +02:00
|
|
|
/**
|
|
|
|
* PHPCI - Continuous Integration for PHP
|
|
|
|
*
|
|
|
|
* @copyright Copyright 2013, Block 8 Limited.
|
|
|
|
* @license https://github.com/Block8/PHPCI/blob/master/LICENSE.md
|
|
|
|
* @link http://www.phptesting.org/
|
|
|
|
*/
|
2013-05-03 17:02:53 +02:00
|
|
|
|
|
|
|
namespace PHPCI;
|
|
|
|
use b8,
|
|
|
|
b8\Registry;
|
|
|
|
|
2013-05-16 03:16:56 +02:00
|
|
|
/**
|
|
|
|
* PHPCI Front Controller
|
|
|
|
* @author Dan Cryer <dan@block8.co.uk>
|
|
|
|
*/
|
2013-05-03 17:02:53 +02:00
|
|
|
class Application extends b8\Application
|
|
|
|
{
|
|
|
|
public function handleRequest()
|
|
|
|
{
|
2013-05-10 17:25:51 +02:00
|
|
|
$controllerName = \b8\Registry::getInstance()->get('ControllerName');
|
|
|
|
|
|
|
|
if(!in_array($controllerName, array('Bitbucket', 'Github')) && !($controllerName == 'Session' && in_array($this->action, array('login', 'logout'))))
|
|
|
|
{
|
|
|
|
$this->validateSession();
|
|
|
|
}
|
|
|
|
|
2013-05-03 17:02:53 +02:00
|
|
|
$view = new b8\View('Layout');
|
|
|
|
$view->content = parent::handleRequest();
|
|
|
|
|
|
|
|
return $view->render();
|
|
|
|
}
|
2013-05-10 17:25:51 +02:00
|
|
|
|
|
|
|
protected function validateSession()
|
|
|
|
{
|
|
|
|
if(!empty($_SESSION['user_id']))
|
|
|
|
{
|
|
|
|
$user = b8\Store\Factory::getStore('User')->getByPrimaryKey($_SESSION['user_id']);
|
|
|
|
|
|
|
|
if($user)
|
|
|
|
{
|
|
|
|
Registry::getInstance()->set('user', $user);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
unset($_SESSION['user_id']);
|
|
|
|
}
|
|
|
|
|
|
|
|
header('Location: /session/login');
|
|
|
|
die;
|
|
|
|
}
|
2013-05-03 17:02:53 +02:00
|
|
|
}
|