/** * plugin.contactimporter.js zarafa contactimporter * * Author: Christoph Haas * Copyright (C) 2012-2013 Christoph Haas * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ Ext.namespace("Zarafa.plugins.contactimporter"); // Assign the right namespace Zarafa.plugins.contactimporter.ImportPlugin = Ext.extend(Zarafa.core.Plugin, { // create new import plugin /** * @constructor * @param {Object} config Configuration object * */ constructor: function (config) { config = config || {}; Zarafa.plugins.contactimporter.ImportPlugin.superclass.constructor.call(this, config); }, /** * initialises insertion point for plugin * @protected */ initPlugin : function() { Zarafa.plugins.contactimporter.ImportPlugin.superclass.initPlugin.apply(this, arguments); /* our panel */ Zarafa.core.data.SharedComponentType.addProperty('plugins.contactimporter.dialogs.importcontacts'); /* directly import received vcfs */ this.registerInsertionPoint('common.contextmenu.attachment.actions', this.createAttachmentImportButton); /* add import button to south navigation */ this.registerInsertionPoint("navigation.south", this.createImportButton, this); /* export a contact via rightclick */ this.registerInsertionPoint('context.contact.contextmenu.actions', this.createItemExportInsertionPoint, this); }, /** * Creates the button * * @return {Object} Configuration object for a {@link Ext.Button button} * */ createImportButton: function () { var button = { xtype : 'button', text : _('Import Contacts'), iconCls : 'icon_contactimporter_button', navigationContext : container.getContextByName('contact'), handler : this.onImportButtonClick, scope : this }; if(container.getSettingsModel().get("zarafa/v1/plugins/contactimporter/enable_export")) { button.text = _('Import/Export Contacts'); } return button; }, /** * This method hooks to the contact context menu and allows users to export users to vcf. * * @param include * @param btn * @returns {Object} */ createItemExportInsertionPoint: function (include, btn) { return { text : dgettext('plugin_files', 'Export VCF'), handler: this.exportToVCF.createDelegate(this, [btn]), scope : this, iconCls: 'icon_contactimporter_export' }; }, exportToVCF: function(btn) { if(btn.records.length == 0) { return; // skip if no records where given! } var recordIds = []; for(var i=0;i