mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-01 04:13:28 +01:00
need to call Vfs\StreamWrapper::init_static() after setting Vfs::$user
Vfs::$user should be protected and moved to Vfs\Base plus a getter and setter method added for public access, as after setting it in 21.1+, Api\Vfs\StreamWrapper::init_static() need to be called to set the default user context!
This commit is contained in:
parent
7a5804c2e7
commit
8a411e7f46
@ -82,7 +82,10 @@ class Vfs extends Vfs\Base
|
|||||||
*/
|
*/
|
||||||
static $is_root = false;
|
static $is_root = false;
|
||||||
/**
|
/**
|
||||||
* Current user id, in case we ever change if away from $GLOBALS['egw_info']['user']['account_id']
|
* Current Vfs user id, set from $GLOBALS['egw_info']['user']['account_id'] by self::init_static()
|
||||||
|
*
|
||||||
|
* Should be protected and moved to Vfs\Base plus a getter and setter method added for public access,
|
||||||
|
* as after setting it in 21.1+, Api\Vfs\StreamWrapper::init_static() need to be called to set the default user context!
|
||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
@ -749,22 +752,22 @@ class Vfs extends Vfs\Base
|
|||||||
* @return boolean
|
* @return boolean
|
||||||
* @todo deprecated or even remove $user parameter and code
|
* @todo deprecated or even remove $user parameter and code
|
||||||
*/
|
*/
|
||||||
static function check_access($path, $check, $stat=null, $user=null)
|
static function check_access($path, $check, $stat=null, int $user=null)
|
||||||
{
|
{
|
||||||
static $vfs = null;
|
static $vfs = null;
|
||||||
|
|
||||||
if (is_null($stat) && $user && $user != self::$user)
|
if (is_null($stat) && $user && $user !== self::$user)
|
||||||
{
|
{
|
||||||
static $path_user_stat = array();
|
static $path_user_stat = array();
|
||||||
|
|
||||||
$backup_user = self::$user;
|
$backup_user = self::$user;
|
||||||
self::$user = $user;
|
self::$user = $user;
|
||||||
|
Vfs\StreamWrapper::init_static();
|
||||||
|
self::clearstatcache($path);
|
||||||
|
|
||||||
if (!isset($path_user_stat[$path]) || !isset($path_user_stat[$path][$user]))
|
if (!isset($path_user_stat[$path]) || !isset($path_user_stat[$path][$user]))
|
||||||
{
|
{
|
||||||
self::clearstatcache($path);
|
$vfs = new Vfs\StreamWrapper();
|
||||||
|
|
||||||
if (!isset($vfs)) $vfs = new Vfs\StreamWrapper();
|
|
||||||
$path_user_stat[$path][$user] = $vfs->url_stat($path, 0);
|
$path_user_stat[$path][$user] = $vfs->url_stat($path, 0);
|
||||||
|
|
||||||
self::clearstatcache($path); // we need to clear the stat-cache after the call too, as the next call might be the regular user again!
|
self::clearstatcache($path); // we need to clear the stat-cache after the call too, as the next call might be the regular user again!
|
||||||
@ -786,6 +789,8 @@ class Vfs extends Vfs\Base
|
|||||||
$ret = false; // no access, if we can not stat the file
|
$ret = false; // no access, if we can not stat the file
|
||||||
}
|
}
|
||||||
self::$user = $backup_user;
|
self::$user = $backup_user;
|
||||||
|
Vfs\StreamWrapper::init_static();
|
||||||
|
$vfs = null;
|
||||||
|
|
||||||
// we need to clear stat-cache again, after restoring original user, as eg. eACL is stored in session
|
// we need to clear stat-cache again, after restoring original user, as eg. eACL is stored in session
|
||||||
self::clearstatcache($path);
|
self::clearstatcache($path);
|
||||||
|
@ -972,6 +972,7 @@ class StreamWrapper extends Base implements StreamWrapperIface
|
|||||||
/**
|
/**
|
||||||
* Init our static properties and register this wrapper
|
* Init our static properties and register this wrapper
|
||||||
*
|
*
|
||||||
|
* Must be called when Vfs::$user is changed!
|
||||||
*/
|
*/
|
||||||
static function init_static()
|
static function init_static()
|
||||||
{
|
{
|
||||||
@ -984,16 +985,31 @@ class StreamWrapper extends Base implements StreamWrapperIface
|
|||||||
{
|
{
|
||||||
self::$fstab = $fstab;
|
self::$fstab = $fstab;
|
||||||
}
|
}
|
||||||
if (!empty($GLOBALS['egw_info']['user']['preferences']['common']['vfs_fstab']) &&
|
|
||||||
is_array($GLOBALS['egw_info']['user']['preferences']['common']['vfs_fstab']))
|
// get the user Vfs is currently using, might be different from $GLOBALS['egw_info']['user']['account_id']
|
||||||
|
if (!isset(Vfs::$user))
|
||||||
{
|
{
|
||||||
self::$fstab += $GLOBALS['egw_info']['user']['preferences']['common']['vfs_fstab'];
|
Vfs::init_static();
|
||||||
|
}
|
||||||
|
if (Vfs::$user != $GLOBALS['egw_info']['user']['account_id'])
|
||||||
|
{
|
||||||
|
$prefs = new Api\Preferences(Vfs::$user);
|
||||||
|
$vfs_fstab = $prefs->data['common']['vfs_fstab'];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$vfs_fstab = $GLOBALS['egw_info']['user']['preferences']['common']['vfs_fstab'];
|
||||||
|
}
|
||||||
|
if (!empty($vfs_fstab) && is_array($vfs_fstab))
|
||||||
|
{
|
||||||
|
self::$fstab += $vfs_fstab;
|
||||||
}
|
}
|
||||||
|
|
||||||
// set default context for our schema ('vfs') with current user
|
// set default context for our schema ('vfs') with current user
|
||||||
if (!($context = stream_context_get_options(stream_context_get_default())) || empty($context[self::SCHEME]['user']))
|
if (!($context = stream_context_get_options(stream_context_get_default())) || empty($context[self::SCHEME]['user']) ||
|
||||||
|
$context[self::SCHEME]['user'] !== (int)Vfs::$user)
|
||||||
{
|
{
|
||||||
$context[self::SCHEME]['user'] = (int)$GLOBALS['egw_info']['user']['account_id'];
|
$context[self::SCHEME]['user'] = (int)Vfs::$user;
|
||||||
stream_context_set_default($context);
|
stream_context_set_default($context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user