Refactor Appbox

This commit is contained in:
Romain Neutron
2012-02-21 16:09:34 +01:00
parent 6ce734c50d
commit 1d6eb86c90
5 changed files with 21 additions and 11 deletions

View File

@@ -710,7 +710,7 @@ class Session_Handler
$rs[$k]['created_on'] = new DateTime($row['created_on']); $rs[$k]['created_on'] = new DateTime($row['created_on']);
$rs[$k]['lastaccess'] = new DateTime($row['lastaccess']); $rs[$k]['lastaccess'] = new DateTime($row['lastaccess']);
$rs[$k]['token'] = !!$row['token']; $rs[$k]['token'] = !!$row['token'];
$rs[$k]['usr_id'] = User_Adapter::getInstance($row['usr_id'], appbox::get_instance()); $rs[$k]['usr_id'] = User_Adapter::getInstance($row['usr_id'], appbox::get_instance(\bootstrap::getCore()));
$datas = $geonames->find_geoname_from_ip($row['ip']); $datas = $geonames->find_geoname_from_ip($row['ip']);

View File

@@ -482,7 +482,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
{ {
try try
{ {
$appbox = appbox::get_instance(); $appbox = appbox::get_instance(\bootstrap::getCore());
$session = $appbox->get_session(); $session = $appbox->get_session();
$user = User_Adapter::getInstance($session->get_usr_id(), $appbox); $user = User_Adapter::getInstance($session->get_usr_id(), $appbox);
@@ -1523,7 +1523,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
public static function updateClientInfos($app_id) public static function updateClientInfos($app_id)
{ {
$appbox = appbox::get_instance(); $appbox = appbox::get_instance(\bootstrap::getCore());
$session = $appbox->get_session(); $session = $appbox->get_session();
if (!$session->is_authenticated()) if (!$session->is_authenticated())
@@ -1632,7 +1632,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
{ {
try try
{ {
$appbox = appbox::get_instance(); $appbox = appbox::get_instance(\bootstrap::getCore());
$session = $appbox->get_session(); $session = $appbox->get_session();
$sql = "UPDATE usr SET create_db='0' WHERE create_db='1' AND usr_id != :usr_id"; $sql = "UPDATE usr SET create_db='0' WHERE create_db='1' AND usr_id != :usr_id";
@@ -1659,7 +1659,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
{ {
$users = self::get_sys_admins(); $users = self::get_sys_admins();
$appbox = appbox::get_instance(); $appbox = appbox::get_instance(\bootstrap::getCore());
$conn = $appbox->get_connection(); $conn = $appbox->get_connection();
foreach ($appbox->get_databoxes() as $databox) foreach ($appbox->get_databoxes() as $databox)
@@ -1717,7 +1717,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
$locale = 'en_GB'; $locale = 'en_GB';
try try
{ {
$appbox = appbox::get_instance(); $appbox = appbox::get_instance(\bootstrap::getCore());
$session = $appbox->get_session(); $session = $appbox->get_session();
$registry = $appbox->get_registry(); $registry = $appbox->get_registry();
$locale = $registry->get('GV_default_lng'); $locale = $registry->get('GV_default_lng');

View File

@@ -209,7 +209,7 @@ class User_Query implements User_QueryInterface
{ {
$this->sql_params = array(); $this->sql_params = array();
$appbox = appbox::get_instance(); $appbox = appbox::get_instance(\bootstrap::getCore());
$session = $appbox->get_session(); $session = $appbox->get_session();
$sql = ' $sql = '

View File

@@ -17,7 +17,7 @@
*/ */
class cache_databox class cache_databox
{ {
protected static $refreshing = false;
/** /**
* *
* @param int $sbas_id * @param int $sbas_id
@@ -25,11 +25,18 @@ class cache_databox
*/ */
public static function refresh($sbas_id) public static function refresh($sbas_id)
{ {
if(self::$refreshing)
{
return;
}
self::$refreshing = true;
$databox = \databox::get_instance((int) $sbas_id); $databox = \databox::get_instance((int) $sbas_id);
$date = new \DateTime('-3 seconds'); $date = new \DateTime('-3 seconds');
$appbox = \appbox::get_instance(); $appbox = \appbox::get_instance(\bootstrap::getCore());
$registry = \registry::get_instance(); $registry = \registry::get_instance();
@@ -49,8 +56,9 @@ class cache_databox
else else
$last_update = new \DateTime('-10 years'); $last_update = new \DateTime('-10 years');
if ($date <= $last_update || !$appbox->get_cache()->ping()) if ($date <= $last_update)
{ {
self::$refreshing = false;
return; return;
} }
@@ -136,6 +144,8 @@ class cache_databox
$stmt->execute(array(':date' => $now)); $stmt->execute(array(':date' => $now));
$stmt->closeCursor(); $stmt->closeCursor();
self::$refreshing = false;
return; return;
} }

View File

@@ -247,7 +247,7 @@ class caption_field
*/ */
public function highlight_thesaurus() public function highlight_thesaurus()
{ {
$appbox = appbox::get_instance(); $appbox = appbox::get_instance(\bootstrap::getCore());
$session = $appbox->get_session(); $session = $appbox->get_session();
$registry = $appbox->get_registry(); $registry = $appbox->get_registry();
$unicode = new unicode(); $unicode = new unicode();