Record share emails in history log & display them instead of user when set

This commit is contained in:
nathangray 2018-06-06 15:51:46 -06:00
parent d4c40e8ce3
commit 6708ccb043
6 changed files with 54 additions and 11 deletions

View File

@ -466,6 +466,13 @@ var et2_historylog = (function(){ "use strict"; return et2_valueWidget.extend([e
jQuery("div", row).each(function (i) { jQuery("div", row).each(function (i) {
var nodes = []; var nodes = [];
var widget = self.columns[i].widget; 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') if(typeof widget == 'undefined' && typeof self.fields[_data.status] != 'undefined')
{ {
widget = self.fields[_data.status].widget; 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") 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], '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'); jthis.css("width", (self.dataview.columnMgr.columnWidths[i] + self.dataview.columnMgr.columnWidths[i+1]-10)+'px');
if(widget) widget.setDetachedAttributes(nodes, { if(widget) widget.setDetachedAttributes(nodes, {
value:_data[self.columns[i].id], value: value,
label: jthis.parents("td").prev().text() label: jthis.parents("td").prev().text()
}); });
@ -524,7 +531,7 @@ var et2_historylog = (function(){ "use strict"; return et2_valueWidget.extend([e
else else
{ {
// No widget fallback - display actual value // No widget fallback - display actual value
nodes = '<span>'+_data[self.columns[i].id] + '</span>'; nodes = '<span>'+ value + '</span>';
} }
if(widget) if(widget)
{ {
@ -534,14 +541,14 @@ var et2_historylog = (function(){ "use strict"; return et2_valueWidget.extend([e
var box = jQuery(widget.getDOMNode()).clone(); var box = jQuery(widget.getDOMNode()).clone();
for(var j = 0; j < widget._children.length; j++) 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]); box.append(nodes[j]);
} }
nodes = box; nodes = box;
} }
else else
{ {
widget.setDetachedAttributes(nodes, {value:_data[self.columns[i].id]}); widget.setDetachedAttributes(nodes, {value:value});
} }
} }
jQuery(this).append(nodes); jQuery(this).append(nodes);

View File

@ -11,7 +11,7 @@
/* Basic information about this app */ /* Basic information about this app */
$setup_info['api']['name'] = 'api'; $setup_info['api']['name'] = 'api';
$setup_info['api']['title'] = 'EGroupware 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'; $setup_info['api']['versions']['current_header'] = '1.29';
// maintenance release in sync with changelog in doc/rpm-build/debian.changes // maintenance release in sync with changelog in doc/rpm-build/debian.changes
$setup_info['api']['versions']['maintenance_release'] = '17.1.20180523'; $setup_info['api']['versions']['maintenance_release'] = '17.1.20180523';

View File

@ -154,7 +154,8 @@ $phpgw_baseline = array(
'history_new_value' => array('type' => 'text','nullable' => False), 'history_new_value' => array('type' => 'text','nullable' => False),
'history_timestamp' => array('type' => 'timestamp','nullable' => False,'default' => 'current_timestamp'), 'history_timestamp' => array('type' => 'timestamp','nullable' => False,'default' => 'current_timestamp'),
'history_old_value' => array('type' => 'text','nullable' => False), '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'), 'pk' => array('history_id'),
'fk' => array(), 'fk' => array(),

View File

@ -422,4 +422,19 @@ function api_upgrade17_1()
)); ));
return $GLOBALS['setup_info']['api']['currentver'] = '17.1.001'; 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';
} }

View File

@ -118,6 +118,14 @@ class Sharing
return $this->share['share_root']; return $this->share['share_root'];
} }
/**
* Get share with email addresses
*/
public function get_share_with()
{
return $this->share['share_with'];
}
/** /**
* Create sharing session * Create sharing session
* *
@ -432,7 +440,7 @@ class Sharing
{ {
Header\Content::disposition(Vfs::basename($this->share['share_path']), false); 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 = new Vfs\WebDAV();
$webdav_server->ServeRequest(Vfs::concat($this->share['share_root'], $this->share['share_token'])); $webdav_server->ServeRequest(Vfs::concat($this->share['share_root'], $this->share['share_token']));
return; return;

View File

@ -106,6 +106,7 @@ class History
'history_old_value' => $old_value, 'history_old_value' => $old_value,
'history_timestamp' => time(), 'history_timestamp' => time(),
'sessionid' => $GLOBALS['egw']->session->sessionid_access_log, 'sessionid' => $GLOBALS['egw']->session->sessionid_access_log,
'share_email' => isset($GLOBALS['egw']->sharing) ? $GLOBALS['egw']->sharing->get_share_with() : '',
),false,__LINE__,__FILE__); ),false,__LINE__,__FILE__);
} }
} }
@ -126,6 +127,7 @@ class History
'history_old_value' => $old_value, 'history_old_value' => $old_value,
'history_timestamp' => time(), 'history_timestamp' => time(),
'sessionid' => $GLOBALS['egw']->session->sessionid_access_log, 'sessionid' => $GLOBALS['egw']->session->sessionid_access_log,
'share_email' => isset($GLOBALS['egw']->sharing) ? $GLOBALS['egw']->sharing->get_share_with() : '',
),false,__LINE__,__FILE__); ),false,__LINE__,__FILE__);
} }
} }
@ -221,7 +223,17 @@ class History
} }
$_query = array(array( $_query = array(array(
'table' => self::TABLE, '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, 'where' => $filter,
)); ));
@ -232,7 +244,7 @@ class History
{ {
$_query[] = array( $_query[] = array(
'table' => Api\Vfs\Sqlfs\StreamWrapper::TABLE, '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']) 'where' => array('fs_dir' => $file['ino'])
); );
} }