From b8b730b0cde2cd00eb1cd785e3d1543d54c0043f Mon Sep 17 00:00:00 2001 From: nathan Date: Mon, 21 Aug 2023 14:23:21 -0600 Subject: [PATCH] Sharing updates - admin can set / change share password, encrypted using system - admin can change share owner - now recording last modified date / user when changing share - change encrypted password column name - new share column for encrypted type --- api/setup/setup.inc.php | 2 +- api/setup/tables_current.inc.php | 6 +++++- api/setup/tables_update.inc.php | 19 +++++++++++++++++++ api/src/Sharing.php | 2 ++ .../inc/class.filemanager_hooks.inc.php | 4 ++++ .../inc/class.filemanager_shares.inc.php | 13 +++++++++++-- filemanager/templates/default/shares.xet | 3 +++ 7 files changed, 45 insertions(+), 4 deletions(-) diff --git a/api/setup/setup.inc.php b/api/setup/setup.inc.php index 9b872939d4..7e23fe02d8 100644 --- a/api/setup/setup.inc.php +++ b/api/setup/setup.inc.php @@ -11,7 +11,7 @@ /* Basic information about this app */ $setup_info['api']['name'] = 'api'; $setup_info['api']['title'] = 'EGroupware API'; -$setup_info['api']['version'] = '23.1.003'; +$setup_info['api']['version'] = '23.1.004'; $setup_info['api']['versions']['current_header'] = '1.29'; // maintenance release in sync with changelog in doc/rpm-build/debian.changes $setup_info['api']['versions']['maintenance_release'] = '23.1.20230824'; diff --git a/api/setup/tables_current.inc.php b/api/setup/tables_current.inc.php index 2641cb49b8..8764ae01b5 100644 --- a/api/setup/tables_current.inc.php +++ b/api/setup/tables_current.inc.php @@ -397,8 +397,12 @@ $phpgw_baseline = array( 'share_writable' => array('type' => 'int','precision' => '1','nullable' => False,'default' => '0','comment' => '0=readable, 1=writable'), 'share_with' => array('type' => 'varchar','precision' => '4096','comment' => 'email addresses, comma seperated'), 'share_passwd' => array('type' => 'varchar','precision' => '128','comment' => 'optional password-hash'), - 'share_password' => array('type' => 'varchar', 'precision' => '128', + 'share_pw_reversable' => array('type' => 'varchar', 'precision' => '128', 'comment' => 'optional reversible password'), + 'share_encryption' => array('type' => 'int', 'nullable' => true, + 'comment' => 'Type of encryption, user or system (See Credentials)'), + 'share_modified' => array('type' => 'timestamp', 'precision' => '8', 'nullable' => False), + 'share_modifier' => array('type' => 'int', 'meta' => 'user', 'precision' => '4'), 'share_created' => array('type' => 'timestamp','nullable' => False,'comment' => 'creation date'), 'share_last_accessed' => array('type' => 'timestamp','comment' => 'last access of share') ), diff --git a/api/setup/tables_update.inc.php b/api/setup/tables_update.inc.php index 3174999f85..a215b405e9 100644 --- a/api/setup/tables_update.inc.php +++ b/api/setup/tables_update.inc.php @@ -913,4 +913,23 @@ function api_upgrade23_1_002() )); return $GLOBALS['setup_info']['api']['currentver'] = '23.1.003'; +} + +function api_upgrade23_1_003() +{ + $GLOBALS['egw_setup']->oProc->RenameColumn('egw_sharing', 'share_password', 'share_pw_reversable'); + $GLOBALS['egw_setup']->oProc->AddColumn('egw_sharing', 'share_encryption', + array( + 'type' => 'int', 'nullable' => true, + 'comment' => 'Type of encryption, user or system (See Credentials)' + ) + ); + + $GLOBALS['egw_setup']->oProc->AddColumn('egw_sharing', 'share_modified', + array('type' => 'timestamp', 'precision' => '8', 'nullable' => False), + ); + $GLOBALS['egw_setup']->oProc->AddColumn('egw_sharing', 'share_modifier', + array('type' => 'int', 'meta' => 'user', 'precision' => '4') + ); + return $GLOBALS['setup_info']['api']['currentver'] = '23.1.004'; } \ No newline at end of file diff --git a/api/src/Sharing.php b/api/src/Sharing.php index 5f7cc07f4b..0e7234c5c3 100644 --- a/api/src/Sharing.php +++ b/api/src/Sharing.php @@ -655,6 +655,8 @@ class Sharing 'share_token' => self::token(), 'share_path' => $path, 'share_owner' => Vfs::$user, + 'share_modified' => (new DateTime('now', DateTime::$server_timezone))->format('ts'), + 'share_modifier' => Vfs::$user, 'share_with' => implode(',', (array)$recipients), 'share_created' => time(), )+$extra, false, __LINE__, __FILE__, Db::API_APPNAME); diff --git a/filemanager/inc/class.filemanager_hooks.inc.php b/filemanager/inc/class.filemanager_hooks.inc.php index 0fdbc63031..bf82474bae 100644 --- a/filemanager/inc/class.filemanager_hooks.inc.php +++ b/filemanager/inc/class.filemanager_hooks.inc.php @@ -101,6 +101,10 @@ class filemanager_hooks 'Quota' => Egw::link('/index.php', 'menuaction=filemanager.filemanager_admin.quota&ajax=true'), 'VFS mounts and versioning' => Egw::link('/index.php', 'menuaction=filemanager.filemanager_admin.index&ajax=true'), ); + if($GLOBALS['egw_info']['user']['apps']['stylite']) + { + $file['Sharing'] = Egw::link('/index.php', 'menuaction=filemanager.filemanager_shares.index&admin=true&ajax=true'); + } if ($location == 'admin') { display_section(self::$appname,$file); diff --git a/filemanager/inc/class.filemanager_shares.inc.php b/filemanager/inc/class.filemanager_shares.inc.php index 1ef8247288..f874a7a72d 100644 --- a/filemanager/inc/class.filemanager_shares.inc.php +++ b/filemanager/inc/class.filemanager_shares.inc.php @@ -91,7 +91,10 @@ class filemanager_shares extends filemanager_ui } unset($query['col_filter']['share_passwd']); - $query['col_filter']['share_owner'] = $GLOBALS['egw_info']['user']['account_id']; + if(!$query['admin'] || !isset($GLOBALS['egw_info']['apps']['admin'])) + { + $query['col_filter']['share_owner'] = $GLOBALS['egw_info']['user']['account_id']; + } $readonlys = null; $total = Sharing::so()->get_rows($query, $rows, $readonlys); @@ -142,7 +145,7 @@ class filemanager_shares extends filemanager_ui 'group' => 1, 'icon' => 'edit', 'allowOnMultiple' => false, - 'popup' => '500x200', + 'popup' => '600x200', 'url' => 'menuaction=stylite.stylite_filemanager.edit_share&share_id=$id', 'disableIfNoEPL' => true ), @@ -204,6 +207,11 @@ class filemanager_shares extends filemanager_ui unset($content['nm']['id']); } $content['is_setup'] = self::$is_setup; + $content['nm']['admin'] = $content['nm']['admin'] || !empty($GLOBALS['egw_info']['user']['apps']['admin']) && $_GET['admin']; + if($content['nm']['admin']) + { + $content['nm']['columnselection_pref'] = "filemanager.shares.rows-admin"; + } $sel_options = array( 'type' => Sharing::$modes, @@ -215,6 +223,7 @@ class filemanager_shares extends filemanager_ui unset($sel_options['type'][Sharing::ATTACH]); $tpl = new Etemplate('filemanager.shares'); + $tpl->set_dom_id($tpl->name . ($content['nm']['admin'] ? '-admin' : '')); $tpl->exec('filemanager.filemanager_shares.index', $content, $sel_options, null, $content); } } \ No newline at end of file diff --git a/filemanager/templates/default/shares.xet b/filemanager/templates/default/shares.xet index adbe9a11c5..9e30772ec2 100644 --- a/filemanager/templates/default/shares.xet +++ b/filemanager/templates/default/shares.xet @@ -4,6 +4,7 @@