From 6708ccb0431e242f07dea7f76e08afe855da3f9c Mon Sep 17 00:00:00 2001 From: nathangray Date: Wed, 6 Jun 2018 15:51:46 -0600 Subject: [PATCH] Record share emails in history log & display them instead of user when set --- api/js/etemplate/et2_widget_historylog.js | 19 +++++++++++++------ api/setup/setup.inc.php | 2 +- api/setup/tables_current.inc.php | 3 ++- api/setup/tables_update.inc.php | 15 +++++++++++++++ api/src/Sharing.php | 10 +++++++++- api/src/Storage/History.php | 16 ++++++++++++++-- 6 files changed, 54 insertions(+), 11 deletions(-) diff --git a/api/js/etemplate/et2_widget_historylog.js b/api/js/etemplate/et2_widget_historylog.js index 6db4bc1ae7..d3cd995022 100644 --- a/api/js/etemplate/et2_widget_historylog.js +++ b/api/js/etemplate/et2_widget_historylog.js @@ -466,6 +466,13 @@ var et2_historylog = (function(){ "use strict"; return et2_valueWidget.extend([e jQuery("div", row).each(function (i) { var nodes = []; var widget = self.columns[i].widget; + var value = _data[self.columns[i].id]; + if(self.OWNER === i && _data['share_email']) + { + // Show share email instead of owner + widget = undefined; + value = _data['share_email']; + } if(typeof widget == 'undefined' && typeof self.fields[_data.status] != 'undefined') { widget = self.fields[_data.status].widget; @@ -501,9 +508,9 @@ var et2_historylog = (function(){ "use strict"; return et2_valueWidget.extend([e if (typeof _data[self.columns[self.NEW_VALUE].id] == "string") { - _data[self.columns[i].id] = { + value = _data[self.columns[i].id] = { 'old': _data[self.columns[i+1].id], - 'new': _data[self.columns[i].id] + 'new': value }; } @@ -513,7 +520,7 @@ var et2_historylog = (function(){ "use strict"; return et2_valueWidget.extend([e jthis.css("width", (self.dataview.columnMgr.columnWidths[i] + self.dataview.columnMgr.columnWidths[i+1]-10)+'px'); if(widget) widget.setDetachedAttributes(nodes, { - value:_data[self.columns[i].id], + value: value, label: jthis.parents("td").prev().text() }); @@ -524,7 +531,7 @@ var et2_historylog = (function(){ "use strict"; return et2_valueWidget.extend([e else { // No widget fallback - display actual value - nodes = ''+_data[self.columns[i].id] + ''; + nodes = ''+ value + ''; } if(widget) { @@ -534,14 +541,14 @@ var et2_historylog = (function(){ "use strict"; return et2_valueWidget.extend([e var box = jQuery(widget.getDOMNode()).clone(); for(var j = 0; j < widget._children.length; j++) { - widget._children[j].setDetachedAttributes(nodes[j], {value:_data[self.columns[i].id][j]}); + widget._children[j].setDetachedAttributes(nodes[j], {value:value[j]}); box.append(nodes[j]); } nodes = box; } else { - widget.setDetachedAttributes(nodes, {value:_data[self.columns[i].id]}); + widget.setDetachedAttributes(nodes, {value:value}); } } jQuery(this).append(nodes); diff --git a/api/setup/setup.inc.php b/api/setup/setup.inc.php index 706787d134..a178cd22ef 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'] = '17.1.001'; +$setup_info['api']['version'] = '17.1.002'; $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'] = '17.1.20180523'; diff --git a/api/setup/tables_current.inc.php b/api/setup/tables_current.inc.php index 62788f5757..07ec657582 100644 --- a/api/setup/tables_current.inc.php +++ b/api/setup/tables_current.inc.php @@ -154,7 +154,8 @@ $phpgw_baseline = array( 'history_new_value' => array('type' => 'text','nullable' => False), 'history_timestamp' => array('type' => 'timestamp','nullable' => False,'default' => 'current_timestamp'), 'history_old_value' => array('type' => 'text','nullable' => False), - 'sessionid' => array('type' => 'int','precision' => '4','comment' => 'primary key to egw_access_log') + 'sessionid' => array('type' => 'int','precision' => '4','comment' => 'primary key to egw_access_log'), + 'share_email' => array('type' => 'varchar','precision' => '4096','nullable' => True,'default'=> NULL,'comment' => 'email addresses of share who made the change, comma seperated') ), 'pk' => array('history_id'), 'fk' => array(), diff --git a/api/setup/tables_update.inc.php b/api/setup/tables_update.inc.php index bbac100e98..622ec11796 100644 --- a/api/setup/tables_update.inc.php +++ b/api/setup/tables_update.inc.php @@ -422,4 +422,19 @@ function api_upgrade17_1() )); return $GLOBALS['setup_info']['api']['currentver'] = '17.1.001'; +} + +/** + * Add field to history log for share email address, if available + */ +function api_upgrade17_1_001() +{ + $GLOBALS['egw_setup']->oProc->AddColumn('egw_history_log','share_email',array( + 'type' => 'varchar', + 'precision' => '4096', + 'default' => NULL, + 'nullable' => True, + 'comment' => 'email addresses of share who made the change, comma seperated' + )); + return $GLOBALS['setup_info']['api']['currentver'] = '17.1.002'; } \ No newline at end of file diff --git a/api/src/Sharing.php b/api/src/Sharing.php index b29bb772b9..a415bcafa4 100644 --- a/api/src/Sharing.php +++ b/api/src/Sharing.php @@ -118,6 +118,14 @@ class Sharing return $this->share['share_root']; } + /** + * Get share with email addresses + */ + public function get_share_with() + { + return $this->share['share_with']; + } + /** * Create sharing session * @@ -432,7 +440,7 @@ class Sharing { Header\Content::disposition(Vfs::basename($this->share['share_path']), false); } - //$GLOBALS['egw']->session->commit_session(); + $GLOBALS['egw']->session->commit_session(); $webdav_server = new Vfs\WebDAV(); $webdav_server->ServeRequest(Vfs::concat($this->share['share_root'], $this->share['share_token'])); return; diff --git a/api/src/Storage/History.php b/api/src/Storage/History.php index f6bf66a8bf..1291bd8ae6 100644 --- a/api/src/Storage/History.php +++ b/api/src/Storage/History.php @@ -106,6 +106,7 @@ class History 'history_old_value' => $old_value, 'history_timestamp' => time(), 'sessionid' => $GLOBALS['egw']->session->sessionid_access_log, + 'share_email' => isset($GLOBALS['egw']->sharing) ? $GLOBALS['egw']->sharing->get_share_with() : '', ),false,__LINE__,__FILE__); } } @@ -126,6 +127,7 @@ class History 'history_old_value' => $old_value, 'history_timestamp' => time(), 'sessionid' => $GLOBALS['egw']->session->sessionid_access_log, + 'share_email' => isset($GLOBALS['egw']->sharing) ? $GLOBALS['egw']->sharing->get_share_with() : '', ),false,__LINE__,__FILE__); } } @@ -221,7 +223,17 @@ class History } $_query = array(array( 'table' => self::TABLE, - 'cols' => array('history_id', 'history_record_id','history_appname','history_owner','history_status','history_new_value', 'history_timestamp','history_old_value'), + 'cols' => array( + 'history_id', + 'history_record_id', + 'history_appname', + 'history_owner', + 'history_status', + 'history_new_value', + 'history_timestamp', + 'history_old_value', + 'share_email' + ), 'where' => $filter, )); @@ -232,7 +244,7 @@ class History { $_query[] = array( 'table' => Api\Vfs\Sqlfs\StreamWrapper::TABLE, - 'cols' =>array('fs_id', 'fs_dir', "'filemanager'",'COALESCE(fs_modifier,fs_creator)',"'~file~'",'fs_name','fs_modified', 'fs_mime'), + 'cols' =>array('fs_id', 'fs_dir', "'filemanager'",'COALESCE(fs_modifier,fs_creator)',"'~file~'",'fs_name','fs_modified', 'fs_mime', '"" AS share_email'), 'where' => array('fs_dir' => $file['ino']) ); }