From 209483409ce343a9960ae973bfcac138fc2a0c39 Mon Sep 17 00:00:00 2001 From: nathan Date: Tue, 1 Nov 2022 09:07:55 -0600 Subject: [PATCH] Filemanager: Push updates from share UI into regular filemanager UI --- .../inc/class.filemanager_hooks.inc.php | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/filemanager/inc/class.filemanager_hooks.inc.php b/filemanager/inc/class.filemanager_hooks.inc.php index b1f8c84f56..3a21b0cf18 100644 --- a/filemanager/inc/class.filemanager_hooks.inc.php +++ b/filemanager/inc/class.filemanager_hooks.inc.php @@ -353,9 +353,26 @@ class filemanager_hooks */ protected static function push(array $data, array $stat) { + $path = $data['to'] ?? $data['from'] ?? $data['path']; + if($path && $data['url'] && $path != $data['url'] && + ($path_dir = Vfs::parse_url($path, PHP_URL_PATH)) !== ($url_dir = Vfs::parse_url($data['url'], PHP_URL_PATH))) + { + // Looks like some path remapping going on, probably a share + // Try to notify the url path too + $remap = []; + foreach(['from', 'to', 'path'] as $map_path) + { + if($data[$map_path]) + { + $remap[$map_path] = str_replace($path_dir, $url_dir, Vfs::parse_url($data[$map_path], PHP_URL_PATH)); + } + } + static::push($remap + $data, $stat); + } + // Who do we want to broadcast to $account_id = []; - if(str_starts_with($data['from'], '/home/') || str_starts_with($data['to'], '/home/')) + if(str_starts_with($data['from'], '/home/') || str_starts_with($data['to'], '/home/') || str_starts_with($path, '/home/')) { // In home, send to just owner and group members if($stat['uid']) @@ -383,9 +400,9 @@ class filemanager_hooks { $acl[] = -$stat['gid']; } - foreach(['to', 'from'] as $field) + foreach(['to', 'from', 'path'] as $field) { - $eacl = Vfs::get_eacl($data['to']); + $eacl = Vfs::get_eacl($data[$field]); if($eacl) { $acl = array_merge($acl, array_column($eacl, 'owner')); @@ -424,7 +441,7 @@ class filemanager_hooks $push->apply("egw.push", [[ 'app' => 'filemanager', - 'id' => $data['to'] ?? $data['path'], + 'id' => $data['to'] ?? $path, 'type' => $type, 'acl' => $acl, 'account_id' => $GLOBALS['egw_info']['user']['account_id']