diff --git a/plugins/kolab_addressbook/kolab_addressbook.js b/plugins/kolab_addressbook/kolab_addressbook.js index 38b7a8ff..62cada48 100644 --- a/plugins/kolab_addressbook/kolab_addressbook.js +++ b/plugins/kolab_addressbook/kolab_addressbook.js @@ -84,43 +84,36 @@ if (window.rcmail) { }); } - // append button to show contact audit trail - if (rcmail.env.action == 'show' && rcmail.env.kolab_audit_trail && rcmail.env.cid) { - $('').attr({href: '#history', 'class': 'btn btn-secondary history contact-history', role: 'button', tabindex: 0}) - .append($('').text(rcmail.get_label('kolab_addressbook.showhistory'))) - .click(function(e) { - var rc = rcmail.is_framed() && parent.rcmail.contact_history_dialog ? parent.rcmail : rcmail; - rc.contact_history_dialog(); - return false; - }) - .appendTo($('
').addClass('formbuttons-secondary-kolab').appendTo('.formbuttons')); - } + rcmail.contact_list && rcmail.contact_list.addEventListener('select', function(list) { + var source, is_writable = true, is_traceable = false; + + // delete/move commands status was set by Roundcube core, + // however, for Kolab addressbooks we like to check folder ACL + if (list.selection.length && rcmail.commands['delete']) { + $.each(rcmail.env.selection_sources, function() { + source = rcmail.env.address_sources[this]; + if (source && source.kolab && source.rights.indexOf('t') < 0) { + return is_writable = false; + } + }); + + rcmail.enable_command('delete', 'move', is_writable); + } + + if (list.get_single_selection()) { + $.each(rcmail.env.selection_sources, function() { + source = rcmail.env.address_sources[this]; + is_traceable = source && !!source.audittrail; + }); + } + + rcmail.enable_command('contact-history-dialog', is_traceable); + }); }); rcmail.addEventListener('listupdate', function() { rcmail.set_book_actions(); }); - - // wait until rcmail.contact_list is ready and subscribe to 'select' events - setTimeout(function() { - rcmail.contact_list && rcmail.contact_list.addEventListener('select', function(list) { - var source, is_writable = true; - - // delete/move commands status was set by Roundcube core, - // however, for Kolab addressbooks we like to check folder ACL - if (list.selection.length && rcmail.commands['delete']) { - for (n in rcmail.env.selection_sources) { - source = rcmail.env.address_sources[n]; - if (source && source.kolab && source.rights.indexOf('t') < 0) { - is_writable = false; - break; - } - } - - rcmail.enable_command('delete', 'move', is_writable); - } - }); - }, 100); } // (De-)activates address book management commands @@ -562,21 +555,6 @@ function kolab_addressbook_contextmenu() } }); } - else if (menu.menu_name == 'contactlist' && rcmail.env.kolab_audit_trail) { - // add "Show History" item to context menu - menu.menu_source.push({ - label: rcmail.get_label('kolab_addressbook.showhistory'), - command: 'contact_history_dialog', - classes: 'history' - }); - // enable history item if the contact source supports it - menu.addEventListener('activate', function(p) { - if (p.command == 'contact_history_dialog') { - var source = rcmail.env.address_sources ? rcmail.env.address_sources[rcmail.env.source] : {}; - return !!source.audittrail; - } - }); - } }); } }; diff --git a/plugins/kolab_addressbook/kolab_addressbook.php b/plugins/kolab_addressbook/kolab_addressbook.php index b9b4c47b..7c6719aa 100644 --- a/plugins/kolab_addressbook/kolab_addressbook.php +++ b/plugins/kolab_addressbook/kolab_addressbook.php @@ -84,6 +84,17 @@ class kolab_addressbook extends rcube_plugin $this->load_config(); require_once($this->home . '/lib/kolab_addressbook_ui.php'); $this->ui = new kolab_addressbook_ui($this); + + if ($this->bonnie_api) { + $this->add_button(array( + 'command' => 'contact-history-dialog', + 'class' => 'history contact-history', + 'classact' => 'history contact-history active', + 'innerclass' => 'icon inner', + 'label' => 'kolab_addressbook.showhistory', + 'type' => 'link-menuitem' + ), 'contactmenu'); + } } } else if ($this->rc->task == 'settings') { diff --git a/plugins/libkolab/skins/larry/libkolab.css b/plugins/libkolab/skins/larry/libkolab.css index 3be1c926..d17bd262 100644 --- a/plugins/libkolab/skins/larry/libkolab.css +++ b/plugins/libkolab/skins/larry/libkolab.css @@ -1,5 +1,10 @@ -ul.toolbarmenu li a.history span.history { +ul.toolbarmenu li a.history { + padding: 2px 6px; + color: #eee; +} + +ul.toolbarmenu li a.history span.icon { background-image: url('data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAQAAAD8x0bcAAABXUlEQVQoFbXBvUsCYQAH4N/mdm5uN9UStzn1AYG0HC1Jg01tV/9A0NYQ5dRm4BI0VYRYUYOD3CSB2FaLXBJhIXYeXr7veVGd8qus0D6Whp4H+Duq1LnEBDX8jiqz3XpgPzqB3a0zSw3fUetavlux0hkjlc5cnPtut84EBlEJLr1WOoN5RKEiisTylmMHNjX0Pa17rd0TRAFqzOLN8Ma2FN4u+tpVx8Y4Xp1O+y7eaRXroUkFn7xWqYieXFwKfDjek6IxCYAqy6xJ8dBkjatALi4FDfQUN6XIxfEqPJt0bCmkMAuIAXMjx/nnBvPUAGtfip0p9ERmk45tFqDjTQix0TXrzFqg4t3cVhHBh8jECnQqVPAujAS0zqHXOshgQJhKx+ycUUcPx5j33YqFcXwRMo/a94HNMrMsd+58t1gaWsQPMSNlFq7Kvlu7LpaMFGYQwi9U6JjHEgzMQMU/eAHASL3dDo5S4wAAAABJRU5ErkJggg=='); background-position: 0px 2px; background-repeat: no-repeat;