mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-12 04:23:19 +00:00
Refactor Appbox
This commit is contained in:
@@ -41,15 +41,16 @@ class gatekeeper
|
||||
* @var gatekeeper
|
||||
*/
|
||||
protected static $_instance;
|
||||
protected $Core;
|
||||
|
||||
/**
|
||||
*
|
||||
* @return gatekeeper
|
||||
*/
|
||||
public static function getInstance()
|
||||
public static function getInstance(\Alchemy\Phrasea\Core $Core)
|
||||
{
|
||||
if (!(self::$_instance instanceof self))
|
||||
self::$_instance = new self();
|
||||
self::$_instance = new self($Core);
|
||||
|
||||
return self::$_instance;
|
||||
}
|
||||
@@ -58,8 +59,10 @@ class gatekeeper
|
||||
*
|
||||
* @return gatekeeper
|
||||
*/
|
||||
function __construct()
|
||||
function __construct(\Alchemy\Phrasea\Core $Core)
|
||||
{
|
||||
$this->Core = $Core;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -72,11 +75,10 @@ class gatekeeper
|
||||
function check_directory()
|
||||
{
|
||||
$request = \Symfony\Component\HttpFoundation\Request::createFromGlobals();
|
||||
$appbox = appbox::get_instance();
|
||||
$appbox = appbox::get_instance($this->Core);
|
||||
$session = $appbox->get_session();
|
||||
|
||||
if (http_request::is_command_line())
|
||||
|
||||
return;
|
||||
|
||||
if (isset($_SERVER['PHP_SELF']) && trim($_SERVER['PHP_SELF']))
|
||||
@@ -100,7 +102,7 @@ class gatekeeper
|
||||
try
|
||||
{
|
||||
$cookie = Session_Handler::get_cookie('persistent');
|
||||
$auth = new Session_Authentication_PersistentCookie($appbox, $cookie);
|
||||
$auth = new Session_Authentication_PersistentCookie($appbox, $cookie);
|
||||
$session->restore($auth->get_user(), $auth->get_ses_id());
|
||||
}
|
||||
catch (Exception $e)
|
||||
@@ -116,7 +118,7 @@ class gatekeeper
|
||||
case 'prod':
|
||||
case 'client':
|
||||
$this->give_guest_access();
|
||||
if($request->isXmlHttpRequest())
|
||||
if ($request->isXmlHttpRequest())
|
||||
{
|
||||
phrasea::headers(404);
|
||||
}
|
||||
@@ -127,9 +129,8 @@ class gatekeeper
|
||||
break;
|
||||
case 'thesaurus2':
|
||||
if ($this->_PHP_SELF == '/thesaurus2/xmlhttp/getterm.x.php'
|
||||
|| $this->_PHP_SELF == '/thesaurus2/xmlhttp/searchcandidate.x.php'
|
||||
|| $this->_PHP_SELF == '/thesaurus2/xmlhttp/getsy.x.php')
|
||||
|
||||
|| $this->_PHP_SELF == '/thesaurus2/xmlhttp/searchcandidate.x.php'
|
||||
|| $this->_PHP_SELF == '/thesaurus2/xmlhttp/getsy.x.php')
|
||||
return;
|
||||
phrasea::redirect('/login/?redirect=/thesaurus2');
|
||||
break;
|
||||
@@ -138,7 +139,6 @@ class gatekeeper
|
||||
break;
|
||||
case 'admin':
|
||||
if ($this->_script_name === 'runscheduler.php')
|
||||
|
||||
return;
|
||||
phrasea::redirect('/login/?redirect=' . $_SERVER['REQUEST_URI']);
|
||||
break;
|
||||
@@ -158,7 +158,6 @@ class gatekeeper
|
||||
return;
|
||||
case 'setup':
|
||||
if ($appbox->upgradeavailable())
|
||||
|
||||
return;
|
||||
else
|
||||
phrasea::redirect('/login/');
|
||||
@@ -237,7 +236,7 @@ class gatekeeper
|
||||
*/
|
||||
protected function give_guest_access()
|
||||
{
|
||||
$appbox = appbox::get_instance();
|
||||
$appbox = appbox::get_instance($this->Core);
|
||||
$request = http_request::getInstance();
|
||||
$session = $appbox->get_session();
|
||||
|
||||
@@ -253,7 +252,7 @@ class gatekeeper
|
||||
catch (Exception $e)
|
||||
{
|
||||
$url = '/login/?redirect=' . $parm['redirect']
|
||||
. '&error=' . urlencode($e->getMessage());
|
||||
. '&error=' . urlencode($e->getMessage());
|
||||
phrasea::redirect($url);
|
||||
}
|
||||
phrasea::redirect('/' . $this->_directory . '/');
|
||||
@@ -269,13 +268,12 @@ class gatekeeper
|
||||
*/
|
||||
protected function token_access()
|
||||
{
|
||||
$appbox = appbox::get_instance();
|
||||
$appbox = appbox::get_instance($this->Core);
|
||||
$request = new http_request();
|
||||
$session = $appbox->get_session();
|
||||
$parm = $request->get_parms('LOG');
|
||||
$parm = $request->get_parms('LOG');
|
||||
|
||||
if (is_null($parm["LOG"]))
|
||||
|
||||
return $this;
|
||||
|
||||
try
|
||||
@@ -312,7 +310,7 @@ class gatekeeper
|
||||
*/
|
||||
public function require_session()
|
||||
{
|
||||
$appbox = appbox::get_instance();
|
||||
$appbox = appbox::get_instance($this->Core);
|
||||
$session = $appbox->get_session();
|
||||
if ($session->is_authenticated())
|
||||
{
|
||||
|
Reference in New Issue
Block a user