From c917cbd8652292d2c87fc3c6f8981bb0a31dc366 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Wed, 29 Oct 2014 23:03:35 +0000 Subject: [PATCH] Link enhancements: - Add confirm dialog to delete link - Log unlinking files into historylog --- etemplate/js/et2_widget_link.js | 23 ++++++++++++++++++----- phpgwapi/inc/class.egw_link.inc.php | 9 +++++++++ 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/etemplate/js/et2_widget_link.js b/etemplate/js/et2_widget_link.js index 2b1be8c0a3..c56b353539 100644 --- a/etemplate/js/et2_widget_link.js +++ b/etemplate/js/et2_widget_link.js @@ -1533,7 +1533,10 @@ var et2_link_list = et2_link_string.extend( this.context.addItem("delete", this.egw().lang("Delete link"), this.egw().image("delete"), function(menu_item) { var link_id = isNaN(self.context.data.link_id) ? self.context.data : self.context.data.link_id; var row = jQuery('#link_'+(self.context.data.dom_id ? self.context.data.dom_id : self.context.data.link_id), self.list); - self._delete_link(link_id, row); + et2_dialog.show_dialog( + function(button) { debugger; if(button == et2_dialog.YES_BUTTON) self._delete_link(link_id,row);}, + egw.lang('Delete link?') + ); }); // Native DnD - Doesn't play nice with jQueryUI Sortable @@ -1660,10 +1663,20 @@ var et2_link_list = et2_link_string.extend( .appendTo(delete_button) // We don't use ui-icon because it assigns a bg image .addClass("delete icon") - .bind( 'click', function() {self._delete_link( - self.value && typeof self.value.to_id != 'object' && _link_data.link_id ? _link_data.link_id:_link_data, - row - );}); + .bind( 'click', function() { + et2_dialog.show_dialog( + function(button) { + if(button == et2_dialog.YES_BUTTON) + { + self._delete_link( + self.value && typeof self.value.to_id != 'object' && _link_data.link_id ? _link_data.link_id:_link_data, + row + ); + } + }, + egw.lang('Delete link?') + ); + }); // Context menu row.bind("contextmenu", function(e) { diff --git a/phpgwapi/inc/class.egw_link.inc.php b/phpgwapi/inc/class.egw_link.inc.php index 228414e35b..40e871d6d1 100644 --- a/phpgwapi/inc/class.egw_link.inc.php +++ b/phpgwapi/inc/class.egw_link.inc.php @@ -1231,6 +1231,15 @@ class egw_link extends solink { echo '

'.__METHOD__."('$app','$id','$fname') url=$url

\n"; } + // Log in history - Need to load it first + if((int)$app > 0) + { + $link = self::get_link(-$app); + if($link['app2'] && $link['id2']) + { + historylog::static_add($link['app2'],$link['id2'],$GLOBALS['egw_info']['user']['account_id'],'~file~','', basename($url)); + } + } if (($Ok = !file_exists($url) || egw_vfs::remove($url,true)) && ((int)$app > 0 || $fname)) { // try removing the dir, in case it's empty