diff --git a/plugins/kolab_addressbook/config.inc.php.dist b/plugins/kolab_addressbook/config.inc.php.dist index 4abebb52..ba8f60d1 100644 --- a/plugins/kolab_addressbook/config.inc.php.dist +++ b/plugins/kolab_addressbook/config.inc.php.dist @@ -1,20 +1,35 @@ diff --git a/plugins/kolab_addressbook/kolab_addressbook.js b/plugins/kolab_addressbook/kolab_addressbook.js index a73a6de9..ea2494c5 100644 --- a/plugins/kolab_addressbook/kolab_addressbook.js +++ b/plugins/kolab_addressbook/kolab_addressbook.js @@ -1,679 +1,688 @@ /** * Client script for the Kolab address book plugin * * @author Aleksander Machniak * @author Thomas Bruederli * * @licstart The following is the entire license notice for the * JavaScript code in this file. * * Copyright (C) 2011-2014, Kolab Systems AG * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * * @licend The above is the entire license notice * for the JavaScript code in this file. */ if (window.rcmail) { rcmail.addEventListener('init', function() { rcmail.set_book_actions(); if (rcmail.gui_objects.editform && rcmail.env.action.match(/^plugin\.book/)) { rcmail.enable_command('book-save', true); } // contextmenu kolab_addressbook_contextmenu(); // append search form for address books if (rcmail.gui_objects.folderlist) { var container = $(rcmail.gui_objects.folderlist); $('') .insertBefore(container.parent()); $('' + rcmail.gettext('findaddressbooks', 'kolab_addressbook') + '') .appendTo('#directorylistbox h2.boxtitle') .click(function(e){ var title = $('#directorylistbox .boxtitle'), box = $('#directorylistbox .listsearchbox'), dir = box.is(':visible') ? -1 : 1; box.slideToggle({ duration: 160, progress: function(animation, progress) { if (dir < 0) progress = 1 - progress; $('#directorylistbox .scroller').css('top', (title.outerHeight() + 34 * progress) + 'px'); }, complete: function() { box.toggleClass('expanded'); if (box.is(':visible')) { box.find('input[type=text]').focus(); } else { $('#directorylistsearch-reset').click(); } } }); }); // remove event handlers set by the regular treelist widget rcmail.treelist.container.off('click mousedown focusin focusout'); // re-initialize folderlist widget // copy form app.js with additional parameters var widget_class = window.kolab_folderlist || rcube_treelist_widget; rcmail.treelist = new widget_class(rcmail.gui_objects.folderlist, { selectable: true, id_prefix: 'rcmli', id_encode: rcmail.html_identifier_encode, id_decode: rcmail.html_identifier_decode, searchbox: '#addressbooksearch', search_action: 'plugin.book-search', search_sources: [ 'folders', 'users' ], search_title: rcmail.gettext('listsearchresults','kolab_addressbook'), check_droptarget: function(node) { return !node.virtual && rcmail.check_droptarget(node.id) } }); rcmail.treelist .addEventListener('collapse', function(node) { rcmail.folder_collapsed(node) }) .addEventListener('expand', function(node) { rcmail.folder_collapsed(node) }) .addEventListener('select', function(node) { rcmail.triggerEvent('selectfolder', { folder:node.id, prefix:'rcmli' }) }) .addEventListener('subscribe', function(node) { var source; if ((source = rcmail.env.address_sources[node.id])) { source.subscribed = node.subscribed || false; rcmail.http_post('plugin.book-subscribe', { _source:node.id, _permanent:source.subscribed?1:0 }); } }) .addEventListener('remove', function(node) { if (rcmail.env.address_sources[node.id]) { rcmail.book_remove(node.id); } }) .addEventListener('insert-item', function(data) { // register new address source rcmail.env.address_sources[data.id] = rcmail.env.contactfolders[data.id] = data.data; // subscribe folder and load groups to add them to the list if (!data.data.virtual) rcmail.http_post('plugin.book-subscribe', { _source:data.id, _permanent:data.data.subscribed?1:0, _groups:1 }); }) .addEventListener('search-complete', function(data) { if (data.length) rcmail.display_message(rcmail.gettext('nraddressbooksfound','kolab_addressbook').replace('$nr', data.length), 'voice'); else rcmail.display_message(rcmail.gettext('noaddressbooksfound','kolab_addressbook'), 'info'); }); } // append button to show contact audit trail if (rcmail.env.action == 'show' && rcmail.env.kolab_audit_trail && rcmail.env.cid) { $('' + 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.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 selected = list.selection.length, source = rcmail.env.source ? rcmail.env.address_sources[rcmail.env.source] : null; if (selected && source.kolab) { rcmail.enable_command('delete', 'move', selected && source.rights.indexOf('t') >= 0); } }); }, 100); } // (De-)activates address book management commands rcube_webmail.prototype.set_book_actions = function() { var source = !this.env.group ? this.env.source : null, sources = this.env.address_sources || {}; var props = source && sources[source] && sources[source].kolab ? sources[source] : { removable: false, rights: '' } this.enable_command('book-create', true); this.enable_command('book-edit', props.rights.indexOf('a') >= 0); this.enable_command('book-delete', props.rights.indexOf('x') >= 0 || props.rights.indexOf('a') >= 0); this.enable_command('book-remove', props.removable); - this.enable_command('book-showurl', !!props.carddavurl); + this.enable_command('book-showurl', !!props.carddavurl || source == this.env.kolab_addressbook_carddav_ldap); }; rcube_webmail.prototype.book_create = function() { this.book_show_contentframe('create'); }; rcube_webmail.prototype.book_edit = function() { this.book_show_contentframe('edit'); }; rcube_webmail.prototype.book_remove = function(id) { if (!id) id = this.env.source; if (id != '' && rcmail.env.address_sources[id]) { rcmail.book_delete_done(id, true); rcmail.http_post('plugin.book-subscribe', { _source:id, _permanent:0, _recursive:1 }); } }; rcube_webmail.prototype.book_delete = function() { if (this.env.source != '' && confirm(this.get_label('kolab_addressbook.bookdeleteconfirm'))) { var lock = this.set_busy(true, 'kolab_addressbook.bookdeleting'); this.http_request('plugin.book', '_act=delete&_source='+urlencode(this.book_realname()), lock); } }; rcube_webmail.prototype.book_showurl = function() { - var source = this.env.source ? this.env.address_sources[this.env.source] : null; - if (source && source.carddavurl) { + var url, source; + + if (this.env.source) { + if (this.env.source == this.env.kolab_addressbook_carddav_ldap) + url = this.env.kolab_addressbook_carddav_ldap_url; + else if (source = this.env.address_sources[this.env.source]) + url = source.carddavurl; + } + + if (url) { $('div.showurldialog:ui-dialog').dialog('close'); - var $dialog = $('
').addClass('showurldialog').append('

'+rcmail.gettext('carddavurldescription', 'kolab_addressbook')+'

'), + var txt = rcmail.gettext('carddavurldescription', 'kolab_addressbook'), + $dialog = $('
').addClass('showurldialog').append('

' + txt + '

'), textbox = $('