mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-24 23:58:54 +01:00
do NOT store user preferences and apps in session, we restore them from instance cache
This commit is contained in:
parent
99595ba1cf
commit
2adeddce8d
@ -12,6 +12,7 @@
|
||||
*/
|
||||
|
||||
namespace EGroupware\Api\Egw;
|
||||
use EGroupware\Api;
|
||||
|
||||
/**
|
||||
* Application (sub-)object of Egw-object used to load $GLOBALS['egw_info'](['user'])['apps']
|
||||
@ -19,7 +20,6 @@ namespace EGroupware\Api\Egw;
|
||||
class Applications
|
||||
{
|
||||
var $account_id;
|
||||
var $data = Array();
|
||||
/**
|
||||
* Reference to the global db class
|
||||
*
|
||||
@ -62,20 +62,12 @@ class Applications
|
||||
{
|
||||
$this->read_installed_apps();
|
||||
}
|
||||
$this->data = Array();
|
||||
if(!$this->account_id)
|
||||
{
|
||||
return False;
|
||||
}
|
||||
$apps = $GLOBALS['egw']->acl->get_user_applications($this->account_id);
|
||||
foreach(array_keys($GLOBALS['egw_info']['apps']) as $app)
|
||||
{
|
||||
if (isset($apps[$app]) && $apps[$app])
|
||||
{
|
||||
$this->data[$app] =& $GLOBALS['egw_info']['apps'][$app];
|
||||
}
|
||||
}
|
||||
return $this->data;
|
||||
return array_intersect_key($GLOBALS['egw_info']['apps'],
|
||||
$GLOBALS['egw']->acl->get_user_applications($this->account_id));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -84,26 +76,39 @@ class Applications
|
||||
*/
|
||||
function read_installed_apps()
|
||||
{
|
||||
foreach($this->db->select($this->table_name,'*',false,__LINE__,__FILE__,false,'ORDER BY app_order ASC') as $row)
|
||||
$GLOBALS['egw_info']['apps'] = Api\Cache::getInstance(__CLASS__, 'apps', function()
|
||||
{
|
||||
$title = $app_name = $row['app_name'];
|
||||
|
||||
if (@is_array($GLOBALS['egw_info']['user']['preferences']) && ($t = lang($app_name)) != $app_name.'*')
|
||||
$apps = array();
|
||||
foreach($this->db->select($this->table_name,'*',false,__LINE__,__FILE__,false,'ORDER BY app_order ASC') as $row)
|
||||
{
|
||||
$title = $t;
|
||||
$title = $app_name = $row['app_name'];
|
||||
|
||||
if (@is_array($GLOBALS['egw_info']['user']['preferences']) && ($t = lang($app_name)) != $app_name.'*')
|
||||
{
|
||||
$title = $t;
|
||||
}
|
||||
$apps[$app_name] = Array(
|
||||
'title' => $title,
|
||||
'name' => $app_name,
|
||||
'enabled' => True,
|
||||
'status' => $row['app_enabled'],
|
||||
'id' => (int)$row['app_id'],
|
||||
'order' => (int)$row['app_order'],
|
||||
'version' => $row['app_version'],
|
||||
'index' => $row['app_index'],
|
||||
'icon' => $row['app_icon'],
|
||||
'icon_app'=> $row['app_icon_app'],
|
||||
);
|
||||
}
|
||||
$GLOBALS['egw_info']['apps'][$app_name] = Array(
|
||||
'title' => $title,
|
||||
'name' => $app_name,
|
||||
'enabled' => True,
|
||||
'status' => $row['app_enabled'],
|
||||
'id' => (int)$row['app_id'],
|
||||
'order' => (int)$row['app_order'],
|
||||
'version' => $row['app_version'],
|
||||
'index' => $row['app_index'],
|
||||
'icon' => $row['app_icon'],
|
||||
'icon_app'=> $row['app_icon_app'],
|
||||
);
|
||||
}
|
||||
return $apps;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Invalidate cached apps
|
||||
*/
|
||||
public static function invalidate()
|
||||
{
|
||||
Api\Cache::unsetInstance(__CLASS__, 'apps');
|
||||
}
|
||||
}
|
||||
|
@ -959,8 +959,17 @@ class Session
|
||||
}
|
||||
else
|
||||
{
|
||||
// update prefs, which might be changed by an other session
|
||||
// set prefs, they are no longer stored in session
|
||||
$GLOBALS['egw_info']['user']['preferences'] = $GLOBALS['egw']->preferences->read_repository();
|
||||
|
||||
// restore apps to $GLOBALS['egw_info']['apps']
|
||||
$GLOBALS['egw']->applications->read_installed_apps();
|
||||
|
||||
// session only stores app-names, restore apps from egw_info[apps]
|
||||
if (!is_array($GLOBALS['egw_info']['user']['apps']['api']))
|
||||
{
|
||||
$GLOBALS['egw_info']['user']['apps'] = array_intersect_key($GLOBALS['egw_info']['apps'], array_flip($GLOBALS['egw_info']['user']['apps']));
|
||||
}
|
||||
}
|
||||
|
||||
if ($GLOBALS['egw']->accounts->is_expired($GLOBALS['egw_info']['user']))
|
||||
|
@ -134,5 +134,14 @@ if ($GLOBALS['egw_info']['flags']['currentapp'] != 'login')
|
||||
$_SESSION[Session::EGW_INFO_CACHE] = $GLOBALS['egw_info'];
|
||||
unset($_SESSION[Session::EGW_INFO_CACHE]['flags']); // dont save the flags, they change on each request
|
||||
|
||||
// dont save preferences, as Session::verify restores them from instance cache anyway
|
||||
unset($_SESSION[Session::EGW_INFO_CACHE]['user']['preferences']);
|
||||
|
||||
// dont save apps, as Session::verify restores them from instance cache anyway
|
||||
unset($_SESSION[Session::EGW_INFO_CACHE]['apps']);
|
||||
|
||||
// store only which apps user has, Session::verify restores it from egw_info[apps]
|
||||
$_SESSION[Session::EGW_INFO_CACHE]['user']['apps'] = array_keys($_SESSION[Session::EGW_INFO_CACHE]['user']['apps']);
|
||||
|
||||
$_SESSION[Session::EGW_OBJECT_CACHE] = serialize($GLOBALS['egw']);
|
||||
}
|
||||
|
@ -502,7 +502,7 @@ class setup
|
||||
'app_icon_app' => $setup_info[$appname]['icon_app'],
|
||||
),False,__LINE__,__FILE__);
|
||||
|
||||
$this->clear_session_cache();
|
||||
Api\Egw\Applications::invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
@ -582,6 +582,8 @@ class setup
|
||||
'app_icon' => $setup_info[$appname]['icon'],
|
||||
'app_icon_app' => $setup_info[$appname]['icon_app'],
|
||||
),array('app_name'=>$appname),__LINE__,__FILE__);
|
||||
|
||||
Api\Egw\Applications::invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
@ -608,6 +610,8 @@ class setup
|
||||
$this->db->update($this->applications_table,array(
|
||||
'app_version' => $setup_info[$appname]['currentver'],
|
||||
),array('app_name'=>$appname),__LINE__,__FILE__);
|
||||
|
||||
Api\Egw\Applications::invalidate();
|
||||
}
|
||||
return $setup_info;
|
||||
}
|
||||
@ -636,10 +640,10 @@ class setup
|
||||
//echo 'DELETING application: ' . $appname;
|
||||
$this->db->delete($this->applications_table,array('app_name'=>$appname),__LINE__,__FILE__);
|
||||
|
||||
Api\Egw\Applications::invalidate();
|
||||
|
||||
// Remove links to the app
|
||||
Link::unlink(0, $appname);
|
||||
|
||||
$this->clear_session_cache();
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user