From d8faef3503af79b8c7a1d94a94abf3188b88263a Mon Sep 17 00:00:00 2001 From: nathangray Date: Thu, 7 Nov 2019 13:46:14 -0700 Subject: [PATCH] Admin: Extend Vfs::deleteAccount hook to all the files it can find, not just home dir. --- admin/inc/class.admin_account.inc.php | 16 +++++----------- admin/lang/egw_en.lang | 2 +- admin/templates/default/account.delete.xet | 2 +- api/src/Accounts.php | 4 ++++ api/src/Vfs/Hooks.php | 10 ++++++++++ 5 files changed, 21 insertions(+), 13 deletions(-) diff --git a/admin/inc/class.admin_account.inc.php b/admin/inc/class.admin_account.inc.php index 8a7fb67737..f887fe8e9d 100644 --- a/admin/inc/class.admin_account.inc.php +++ b/admin/inc/class.admin_account.inc.php @@ -302,7 +302,10 @@ class admin_account { $entry = lang('Entries'); } - if($counts['total'] && Api\Hooks::exists('deleteaccount', $app)) + if($counts['total'] && ( + // Filemanager is a special case, since the hook is in API + Api\Hooks::exists('deleteaccount', $app) || in_array($app, array('filemanager')) + )) { $content['delete_apps'][] = $app; $sel_options['delete_apps'][] = array( @@ -319,16 +322,7 @@ class admin_account ); } } - // Add filemanager home directory in as special case, hook is in the API - if(Api\Vfs::file_exists('/home/'.$GLOBALS['egw']->accounts->id2name($content['account_id']))) - { - $app = 'filemanager'; - $sel_options['delete_apps'][] = array( - 'value' => $app, - 'label' => lang($app) . ': ' . lang('home directory') - ); - $content['delete_apps'][] = $app; - } + $tpl = new Etemplate('admin.account.delete'); $tpl->exec('admin_account::delete', $content, $sel_options, array(), $preserve, 2); } diff --git a/admin/lang/egw_en.lang b/admin/lang/egw_en.lang index 4f716282ed..f2db603457 100644 --- a/admin/lang/egw_en.lang +++ b/admin/lang/egw_en.lang @@ -201,6 +201,7 @@ change config settings admin en Change config settings change domain of email address and aliases admin en change domain of email address and aliases change login screen message admin en Change login screen message change owner admin en Change owner +change owner of found files to the new user, and move the home folder to /home/new-user/old-home-username. admin en Found files will have owner changed to the new user. The home folder will be moved to /home/new-user/old-home-username. change password for %1 admin en Change password for %1 change password hash to admin en Change password hash to changed password hash for %1 to %2. admin en Changed password hash for %1 to %2. @@ -706,7 +707,6 @@ phpinfo admin en PHP information phrase admin en Phrase phrase deleted admin en Phrase deleted please check email. it gets automatically deleted if email integration is used. admin en Please check email. It gets automatically deleted if email integration is used. -please check home folder. all files and folders of the user will be unusable by other users. admin en Please check home folder. All files and folders of the user will be unusable by other users. please enter a name admin en Enter a name please enter a name for that server ! admin en Enter a name for that server! please manually deal with entries owned by the user: admin en Please manually deal with entries owned by the user: diff --git a/admin/templates/default/account.delete.xet b/admin/templates/default/account.delete.xet index e089dfd966..12cf9ba303 100644 --- a/admin/templates/default/account.delete.xet +++ b/admin/templates/default/account.delete.xet @@ -29,7 +29,7 @@ - + diff --git a/api/src/Accounts.php b/api/src/Accounts.php index 2c7b6541a8..299490009f 100644 --- a/api/src/Accounts.php +++ b/api/src/Accounts.php @@ -1089,6 +1089,10 @@ class Accounts } } + // Add filemanager as special case, since most of it is in Api + $files = Vfs::find('/', array('uid' => (int)$account_id, 'limit' => 50)); + $counts['filemanager']['total'] = Vfs::$find_total; + return $counts; } protected function get_owner_columns() diff --git a/api/src/Vfs/Hooks.php b/api/src/Vfs/Hooks.php index f5068a4e1d..6be56f2fb5 100644 --- a/api/src/Vfs/Hooks.php +++ b/api/src/Vfs/Hooks.php @@ -87,6 +87,8 @@ class Hooks { if (self::LOG_LEVEL > 0) error_log(__METHOD__.'('.array2string($data).')'); Api\Vfs::$is_root = true; + + // Home directory if ($data['new_owner'] && ($new_lid = $GLOBALS['egw']->accounts->id2name($data['new_owner']))) { // copy content of user-dir to new owner's user-dir as old-home-$name @@ -107,6 +109,14 @@ class Hooks { throw new Api\Exception\AssertionFailed(__METHOD__.'('.array2string($data).') account_lid NOT set!'); } + + // Other files + Api\Vfs::find( + '/', + array('user' => $data['account_lid']), + $data['new_owner'] ? 'EGroupware\Api\Vfs::chown' : 'EGroupware\Api\Vfs::remove', $data['new_owner'] + ); + Api\Vfs::$is_root = false; }