ソースを参照

Line endings

tags/v2.0.4
コミット
d93d9ca1b2
8個のファイルの変更1741行の追加1741行の削除
  1. +25
    -25
      changelog.txt
  2. +57
    -57
      js/ABOUT.js
  3. +84
    -84
      js/data/ResponseHandler.js
  4. +66
    -66
      js/dialogs/ImportContentPanel.js
  5. +266
    -266
      js/plugin.contactimporter.js
  6. +44
    -44
      manifest.xml
  7. +1169
    -1169
      php/module.contact.php
  8. +30
    -30
      resources/css/contactimporter-main.css

+ 25
- 25
changelog.txt ファイルの表示

@@ -1,25 +1,25 @@
v2.0.2: 29.11.2016
- finally compatible with Kopano Webapp 3.1
- translation to german added
- Export notification is shown
v2.0.1: 01.11.2016
- compatible with Kopano Webapp 3.1
- exporting contacts implemented
- GUI improvements
v1.0.3: 01.05.2014
- compatible with WebApp 1.5 and WebApp 1.6
v1.0.2: 06.11.2013
- fixed: importing attachments
- fixed: plugin not enabled bug
- fixed: importing website bug
- fixed: some other bugs
v1.0.1: 03.10.2013
- compatible with WebApp 1.4
v1.0: 24.6.2013
- import vcards (1 or more vcards in a file)
- chooseable destination addressbook
v2.0.2: 29.11.2016
- finally compatible with Kopano Webapp 3.1
- translation to german added
- Export notification is shown
v2.0.1: 01.11.2016
- compatible with Kopano Webapp 3.1
- exporting contacts implemented
- GUI improvements
v1.0.3: 01.05.2014
- compatible with WebApp 1.5 and WebApp 1.6
v1.0.2: 06.11.2013
- fixed: importing attachments
- fixed: plugin not enabled bug
- fixed: importing website bug
- fixed: some other bugs
v1.0.1: 03.10.2013
- compatible with WebApp 1.4
v1.0: 24.6.2013
- import vcards (1 or more vcards in a file)
- chooseable destination addressbook

+ 57
- 57
js/ABOUT.js ファイルの表示

@@ -1,58 +1,58 @@
/**
* ABOUT.js, Kopano Webapp contact to vcf im/exporter
*
* Author: Christoph Haas <christoph.h@sprinternet.at>
* Copyright (C) 2012-2016 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');
/**
* @class Zarafa.plugins.contactimporter.ABOUT
* @extends String
*
* The copyright string holding the copyright notice for the Zarafa contactimporter Plugin.
*/
Zarafa.plugins.contactimporter.ABOUT = ""
+ "<p>Copyright (C) 2012-2016 Christoph Haas &lt;christoph.h@sprinternet.at&gt;</p>"
+ "<p>This program 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.</p>"
+ "<p>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 "
+ "Lesser General Public License for more details.</p>"
+ "<p>You should have received a copy of the GNU Lesser General Public "
+ "License along with this program; if not, write to the Free Software "
+ "Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</p>"
+ "<hr />"
+ "<p>The contactimporter plugin contains the following third-party components:</p>"
+ "<h1>vCard-parser</h1>"
+ "<p>Copyright (C) 2016 Jeroen Desloovere</p>"
+ "<p>Licensed under the MIT License.</p>"
/**
* ABOUT.js, Kopano Webapp contact to vcf im/exporter
*
* Author: Christoph Haas <christoph.h@sprinternet.at>
* Copyright (C) 2012-2016 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');
/**
* @class Zarafa.plugins.contactimporter.ABOUT
* @extends String
*
* The copyright string holding the copyright notice for the Zarafa contactimporter Plugin.
*/
Zarafa.plugins.contactimporter.ABOUT = ""
+ "<p>Copyright (C) 2012-2016 Christoph Haas &lt;christoph.h@sprinternet.at&gt;</p>"
+ "<p>This program 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.</p>"
+ "<p>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 "
+ "Lesser General Public License for more details.</p>"
+ "<p>You should have received a copy of the GNU Lesser General Public "
+ "License along with this program; if not, write to the Free Software "
+ "Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</p>"
+ "<hr />"
+ "<p>The contactimporter plugin contains the following third-party components:</p>"
+ "<h1>vCard-parser</h1>"
+ "<p>Copyright (C) 2016 Jeroen Desloovere</p>"
+ "<p>Licensed under the MIT License.</p>"
+ "<p>Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.</p>"

+ 84
- 84
js/data/ResponseHandler.js ファイルの表示

@@ -1,85 +1,85 @@
/**
* ResponseHandler.js, Kopano Webapp contact to vcf im/exporter
*
* Author: Christoph Haas <christoph.h@sprinternet.at>
* Copyright (C) 2012-2016 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
*
*/
/**
* ResponseHandler
*
* This class handles all responses from the php backend
*/
Ext.namespace('Zarafa.plugins.contactimporter.data');
/**
* @class Zarafa.plugins.contactimporter.data.ResponseHandler
* @extends Zarafa.plugins.contactimporter.data.AbstractResponseHandler
*
* Calendar specific response handler.
*/
Zarafa.plugins.contactimporter.data.ResponseHandler = Ext.extend(Zarafa.core.data.AbstractResponseHandler, {
/**
* @cfg {Function} successCallback The function which
* will be called after success request.
*/
successCallback: null,
/**
* Call the successCallback callback function.
* @param {Object} response Object contained the response data.
*/
doLoad: function (response) {
this.successCallback(response);
},
/**
* Call the successCallback callback function.
* @param {Object} response Object contained the response data.
*/
doImport: function (response) {
this.successCallback(response);
},
/**
* Call the successCallback callback function.
* @param {Object} response Object contained the response data.
*/
doExport: function (response) {
this.successCallback(response);
},
/**
* Call the successCallback callback function.
* @param {Object} response Object contained the response data.
*/
doImportattachment: function (response) {
this.successCallback(response);
},
/**
* In case exception happened on server, server will return
* exception response with the code of exception.
* @param {Object} response Object contained the response data.
*/
doError: function (response) {
alert("error response code: " + response.error.info.code);
}
});
/**
* ResponseHandler.js, Kopano Webapp contact to vcf im/exporter
*
* Author: Christoph Haas <christoph.h@sprinternet.at>
* Copyright (C) 2012-2016 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
*
*/
/**
* ResponseHandler
*
* This class handles all responses from the php backend
*/
Ext.namespace('Zarafa.plugins.contactimporter.data');
/**
* @class Zarafa.plugins.contactimporter.data.ResponseHandler
* @extends Zarafa.plugins.contactimporter.data.AbstractResponseHandler
*
* Calendar specific response handler.
*/
Zarafa.plugins.contactimporter.data.ResponseHandler = Ext.extend(Zarafa.core.data.AbstractResponseHandler, {
/**
* @cfg {Function} successCallback The function which
* will be called after success request.
*/
successCallback: null,
/**
* Call the successCallback callback function.
* @param {Object} response Object contained the response data.
*/
doLoad: function (response) {
this.successCallback(response);
},
/**
* Call the successCallback callback function.
* @param {Object} response Object contained the response data.
*/
doImport: function (response) {
this.successCallback(response);
},
/**
* Call the successCallback callback function.
* @param {Object} response Object contained the response data.
*/
doExport: function (response) {
this.successCallback(response);
},
/**
* Call the successCallback callback function.
* @param {Object} response Object contained the response data.
*/
doImportattachment: function (response) {
this.successCallback(response);
},
/**
* In case exception happened on server, server will return
* exception response with the code of exception.
* @param {Object} response Object contained the response data.
*/
doError: function (response) {
alert("error response code: " + response.error.info.code);
}
});
Ext.reg('contactimporter.contactresponsehandler', Zarafa.plugins.contactimporter.data.ResponseHandler);

+ 66
- 66
js/dialogs/ImportContentPanel.js ファイルの表示

@@ -1,67 +1,67 @@
/**
* ImportContentPanel.js, Kopano Webapp contact to vcf im/exporter
*
* Author: Christoph Haas <christoph.h@sprinternet.at>
* Copyright (C) 2012-2016 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
*
*/
/**
* ImportContentPanel
*
* Container for the importpanel.
*/
Ext.namespace("Zarafa.plugins.contactimporter.dialogs");
/**
* @class Zarafa.plugins.contactimporter.dialogs.ImportContentPanel
* @extends Zarafa.core.ui.ContentPanel
*
* The content panel which shows the hierarchy tree of Owncloud account files.
* @xtype contactimportercontentpanel
*/
Zarafa.plugins.contactimporter.dialogs.ImportContentPanel = Ext.extend(Zarafa.core.ui.ContentPanel, {
/**
* @constructor
* @param config Configuration structure
*/
constructor: function (config) {
config = config || {};
var title = dgettext('plugin_contactimporter', 'Import Contacts');
Ext.applyIf(config, {
layout: 'fit',
title: title,
closeOnSave: true,
width: 620,
height: 465,
//Add panel
items: [
{
xtype: 'contactimporter.importcontactpanel',
filename: config.filename,
folder: config.folder
}
]
});
Zarafa.plugins.contactimporter.dialogs.ImportContentPanel.superclass.constructor.call(this, config);
}
});
/**
* ImportContentPanel.js, Kopano Webapp contact to vcf im/exporter
*
* Author: Christoph Haas <christoph.h@sprinternet.at>
* Copyright (C) 2012-2016 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
*
*/
/**
* ImportContentPanel
*
* Container for the importpanel.
*/
Ext.namespace("Zarafa.plugins.contactimporter.dialogs");
/**
* @class Zarafa.plugins.contactimporter.dialogs.ImportContentPanel
* @extends Zarafa.core.ui.ContentPanel
*
* The content panel which shows the hierarchy tree of Owncloud account files.
* @xtype contactimportercontentpanel
*/
Zarafa.plugins.contactimporter.dialogs.ImportContentPanel = Ext.extend(Zarafa.core.ui.ContentPanel, {
/**
* @constructor
* @param config Configuration structure
*/
constructor: function (config) {
config = config || {};
var title = dgettext('plugin_contactimporter', 'Import Contacts');
Ext.applyIf(config, {
layout: 'fit',
title: title,
closeOnSave: true,
width: 620,
height: 465,
//Add panel
items: [
{
xtype: 'contactimporter.importcontactpanel',
filename: config.filename,
folder: config.folder
}
]
});
Zarafa.plugins.contactimporter.dialogs.ImportContentPanel.superclass.constructor.call(this, config);
}
});
Ext.reg('contactimporter.contentpanel', Zarafa.plugins.contactimporter.dialogs.ImportContentPanel);

+ 266
- 266
js/plugin.contactimporter.js ファイルの表示

@@ -1,266 +1,266 @@
/**
* plugin.contactimporter.js, Kopano Webapp contact to vcf im/exporter
*
* Author: Christoph Haas <christoph.h@sprinternet.at>
* Copyright (C) 2012-2016 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, this);
/* export a contact via rightclick */
this.registerInsertionPoint('context.contact.contextmenu.actions', this.createItemExportInsertionPoint, this);
},
/**
* 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_contactimporter', 'Export vCard'),
handler: this.exportToVCF.createDelegate(this, [btn]),
scope: this,
iconCls: 'icon_contactimporter_export'
};
},
/**
* Generates a request to download the selected records as vCard.
* @param {Ext.Button} btn
*/
exportToVCF: function (btn) {
if (btn.records.length == 0) {
return; // skip if no records where given!
}
var recordIds = [];
for (var i = 0; i < btn.records.length; i++) {
recordIds.push(btn.records[i].get("entryid"));
}
Zarafa.plugins.contactimporter.data.Actions.exportToVCF(btn.records[0].get("store_entryid"), recordIds, undefined);
},
/**
* Insert import button in all attachment suggestions
* @return {Object} Configuration object for a {@link Ext.Button button}
*/
createAttachmentImportButton: function (include, btn) {
return {
text: dgettext('plugin_contactimporter', 'Import to Contacts'),
handler: this.getAttachmentFileName.createDelegate(this, [btn]),
scope: this,
iconCls: 'icon_contactimporter_button',
beforeShow: function (item, record) {
var extension = record.data.name.split('.').pop().toLowerCase();
if (record.data.filetype == "text/vcard" || record.data.filetype == "text/x-vcard" || extension == "vcf" || extension == "vcard") {
item.setVisible(true);
} else {
item.setVisible(false);
}
}
};
},
/**
* Callback for getAttachmentFileName
* @param {Object} response
*/
gotAttachmentFileName: function (response) {
if (response.status == true) {
this.openImportDialog(response.tmpname);
} else {
Zarafa.common.dialogs.MessageBox.show({
title: dgettext('plugin_contactimporter', 'Error'),
msg: _(response["message"]),
icon: Zarafa.common.dialogs.MessageBox.ERROR,
buttons: Zarafa.common.dialogs.MessageBox.OK
});
}
},
/**
* Clickhandler for the button
* @param {Ext.Button} btn
*/
getAttachmentFileName: function (btn) {
Zarafa.common.dialogs.MessageBox.show({
title: dgettext('plugin_contactimporter', 'Please wait'),
msg: dgettext('plugin_contactimporter', 'Loading attachment...'),
progressText: dgettext('plugin_contactimporter', 'Initializing...'),
width: 300,
progress: true,
closable: false
});
// progress bar... ;)
var f = function (v) {
return function () {
if (v == 100) {
Zarafa.common.dialogs.MessageBox.hide();
} else {
// # TRANSLATORS: {0} will be replaced by the percentage value (0-100)
Zarafa.common.dialogs.MessageBox.updateProgress(v / 100, String.format(dgettext('plugin_contactimporter', '{0}% loaded'), Math.round(v)));
}
};
};
for (var i = 1; i < 101; i++) {
setTimeout(f(i), 20 * i);
}
/* store the attachment to a temporary folder and prepare it for uploading */
var attachmentRecord = btn.records;
var attachmentStore = attachmentRecord.store;
var store = attachmentStore.getParentRecord().get('store_entryid');
var entryid = attachmentStore.getAttachmentParentRecordEntryId();
var attachNum = new Array(1);
if (attachmentRecord.get('attach_num') != -1) {
attachNum[0] = attachmentRecord.get('attach_num');
} else {
attachNum[0] = attachmentRecord.get('tmpname');
}
var dialog_attachments = attachmentStore.getId();
var filename = attachmentRecord.data.name;
var responseHandler = new Zarafa.plugins.contactimporter.data.ResponseHandler({
successCallback: this.gotAttachmentFileName.createDelegate(this),
scope: this
});
// request attachment preperation
container.getRequest().singleRequest(
'contactmodule',
'importattachment',
{
entryid: entryid,
store: store,
attachNum: attachNum,
dialog_attachments: dialog_attachments,
filename: filename
},
responseHandler
);
},
/**
* Open the import dialog.
* @param {String} filename
*/
openImportDialog: function (filename) {
var componentType = Zarafa.core.data.SharedComponentType['plugins.contactimporter.dialogs.importcontacts'];
var config = {
filename: filename,
modal: true
};
Zarafa.core.data.UIFactory.openLayerComponent(componentType, undefined, config);
},
/**
* Bid for the type of shared component
* and the given record.
* This will bid on calendar.dialogs.importcontacts
* @param {Zarafa.core.data.SharedComponentType} type Type of component a context can bid for.
* @param {Ext.data.Record} record Optionally passed record.
* @return {Number} The bid for the shared component
*/
bidSharedComponent: function (type, record) {
var bid = -1;
switch (type) {
case Zarafa.core.data.SharedComponentType['plugins.contactimporter.dialogs.importcontacts']:
bid = 1;
break;
case Zarafa.core.data.SharedComponentType['common.contextmenu']:
if (record instanceof Zarafa.core.data.MAPIRecord) {
if (record.get('object_type') == Zarafa.core.mapi.ObjectType.MAPI_FOLDER && record.get('container_class') == "IPF.Contact") {
bid = 2;
}
}
break;
}
return bid;
},
/**
* Will return the reference to the shared component.
* Based on the type of component requested a component is returned.
* @param {Zarafa.core.data.SharedComponentType} type Type of component a context can bid for.
* @param {Ext.data.Record} record Optionally passed record.
* @return {Ext.Component} Component
*/
getSharedComponent: function (type, record) {
var component;
switch (type) {
case Zarafa.core.data.SharedComponentType['plugins.contactimporter.dialogs.importcontacts']:
component = Zarafa.plugins.contactimporter.dialogs.ImportContentPanel;
break;
case Zarafa.core.data.SharedComponentType['common.contextmenu']:
component = Zarafa.plugins.contactimporter.ui.ContextMenu;
break;
}
return component;
}
});
/*############################################################################################################################
* STARTUP
*############################################################################################################################*/
Zarafa.onReady(function () {
container.registerPlugin(new Zarafa.core.PluginMetaData({
name: 'contactimporter',
displayName: dgettext('plugin_contactimporter', 'Contactimporter Plugin'),
about: Zarafa.plugins.contactimporter.ABOUT,
pluginConstructor: Zarafa.plugins.contactimporter.ImportPlugin
}));
});
/**
* plugin.contactimporter.js, Kopano Webapp contact to vcf im/exporter
*
* Author: Christoph Haas <christoph.h@sprinternet.at>
* Copyright (C) 2012-2016 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, this);
/* export a contact via rightclick */
this.registerInsertionPoint('context.contact.contextmenu.actions', this.createItemExportInsertionPoint, this);
},
/**
* 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_contactimporter', 'Export vCard'),
handler: this.exportToVCF.createDelegate(this, [btn]),
scope: this,
iconCls: 'icon_contactimporter_export'
};
},
/**
* Generates a request to download the selected records as vCard.
* @param {Ext.Button} btn
*/
exportToVCF: function (btn) {
if (btn.records.length == 0) {
return; // skip if no records where given!
}
var recordIds = [];
for (var i = 0; i < btn.records.length; i++) {
recordIds.push(btn.records[i].get("entryid"));
}
Zarafa.plugins.contactimporter.data.Actions.exportToVCF(btn.records[0].get("store_entryid"), recordIds, undefined);
},
/**
* Insert import button in all attachment suggestions
* @return {Object} Configuration object for a {@link Ext.Button button}
*/
createAttachmentImportButton: function (include, btn) {
return {
text: dgettext('plugin_contactimporter', 'Import to Contacts'),
handler: this.getAttachmentFileName.createDelegate(this, [btn]),
scope: this,
iconCls: 'icon_contactimporter_button',
beforeShow: function (item, record) {
var extension = record.data.name.split('.').pop().toLowerCase();
if (record.data.filetype == "text/vcard" || record.data.filetype == "text/x-vcard" || extension == "vcf" || extension == "vcard") {
item.setVisible(true);
} else {
item.setVisible(false);
}
}
};
},
/**
* Callback for getAttachmentFileName
* @param {Object} response
*/
gotAttachmentFileName: function (response) {
if (response.status == true) {
this.openImportDialog(response.tmpname);
} else {
Zarafa.common.dialogs.MessageBox.show({
title: dgettext('plugin_contactimporter', 'Error'),
msg: _(response["message"]),
icon: Zarafa.common.dialogs.MessageBox.ERROR,
buttons: Zarafa.common.dialogs.MessageBox.OK
});
}
},
/**
* Clickhandler for the button
* @param {Ext.Button} btn
*/
getAttachmentFileName: function (btn) {
Zarafa.common.dialogs.MessageBox.show({
title: dgettext('plugin_contactimporter', 'Please wait'),
msg: dgettext('plugin_contactimporter', 'Loading attachment...'),
progressText: dgettext('plugin_contactimporter', 'Initializing...'),
width: 300,
progress: true,
closable: false
});
// progress bar... ;)
var f = function (v) {
return function () {
if (v == 100) {
Zarafa.common.dialogs.MessageBox.hide();
} else {
// # TRANSLATORS: {0} will be replaced by the percentage value (0-100)
Zarafa.common.dialogs.MessageBox.updateProgress(v / 100, String.format(dgettext('plugin_contactimporter', '{0}% loaded'), Math.round(v)));
}
};
};
for (var i = 1; i < 101; i++) {
setTimeout(f(i), 20 * i);
}
/* store the attachment to a temporary folder and prepare it for uploading */
var attachmentRecord = btn.records;
var attachmentStore = attachmentRecord.store;
var store = attachmentStore.getParentRecord().get('store_entryid');
var entryid = attachmentStore.getAttachmentParentRecordEntryId();
var attachNum = new Array(1);
if (attachmentRecord.get('attach_num') != -1) {
attachNum[0] = attachmentRecord.get('attach_num');
} else {
attachNum[0] = attachmentRecord.get('tmpname');
}
var dialog_attachments = attachmentStore.getId();
var filename = attachmentRecord.data.name;
var responseHandler = new Zarafa.plugins.contactimporter.data.ResponseHandler({
successCallback: this.gotAttachmentFileName.createDelegate(this),
scope: this
});
// request attachment preperation
container.getRequest().singleRequest(
'contactmodule',
'importattachment',
{
entryid: entryid,
store: store,
attachNum: attachNum,
dialog_attachments: dialog_attachments,
filename: filename
},
responseHandler
);
},
/**
* Open the import dialog.
* @param {String} filename
*/
openImportDialog: function (filename) {
var componentType = Zarafa.core.data.SharedComponentType['plugins.contactimporter.dialogs.importcontacts'];
var config = {
filename: filename,
modal: true
};
Zarafa.core.data.UIFactory.openLayerComponent(componentType, undefined, config);
},
/**
* Bid for the type of shared component
* and the given record.
* This will bid on calendar.dialogs.importcontacts
* @param {Zarafa.core.data.SharedComponentType} type Type of component a context can bid for.
* @param {Ext.data.Record} record Optionally passed record.
* @return {Number} The bid for the shared component
*/
bidSharedComponent: function (type, record) {
var bid = -1;
switch (type) {
case Zarafa.core.data.SharedComponentType['plugins.contactimporter.dialogs.importcontacts']:
bid = 1;
break;
case Zarafa.core.data.SharedComponentType['common.contextmenu']:
if (record instanceof Zarafa.core.data.MAPIRecord) {
if (record.get('object_type') == Zarafa.core.mapi.ObjectType.MAPI_FOLDER && record.get('container_class') == "IPF.Contact") {
bid = 2;
}
}
break;
}
return bid;
},
/**
* Will return the reference to the shared component.
* Based on the type of component requested a component is returned.
* @param {Zarafa.core.data.SharedComponentType} type Type of component a context can bid for.
* @param {Ext.data.Record} record Optionally passed record.
* @return {Ext.Component} Component
*/
getSharedComponent: function (type, record) {
var component;
switch (type) {
case Zarafa.core.data.SharedComponentType['plugins.contactimporter.dialogs.importcontacts']:
component = Zarafa.plugins.contactimporter.dialogs.ImportContentPanel;
break;
case Zarafa.core.data.SharedComponentType['common.contextmenu']:
component = Zarafa.plugins.contactimporter.ui.ContextMenu;
break;
}
return component;
}
});
/*############################################################################################################################
* STARTUP
*############################################################################################################################*/
Zarafa.onReady(function () {
container.registerPlugin(new Zarafa.core.PluginMetaData({
name: 'contactimporter',
displayName: dgettext('plugin_contactimporter', 'Contactimporter Plugin'),
about: Zarafa.plugins.contactimporter.ABOUT,
pluginConstructor: Zarafa.plugins.contactimporter.ImportPlugin
}));
});

+ 44
- 44
manifest.xml ファイルの表示

@@ -1,44 +1,44 @@
<?xml version="1.0"?>
<!DOCTYPE plugin SYSTEM "manifest.dtd">
<plugin version="2">
<info>
<version>2.0.2</version>
<name>contactimporter</name>
<title>VCF Contact Importer/Exporter</title>
<author>Christoph Haas</author>
<authorURL>http://www.sprinternet.at</authorURL>
<description>Import or Export a VCF file to/from the zarafa addressbook</description>
</info>
<translations>
<translationsdir>languages</translationsdir>
</translations>
<config>
<configfile>config.php</configfile>
</config>
<components>
<component>
<files>
<server>
<serverfile>php/plugin.contactimporter.php</serverfile>
<serverfile type="module" module="contactmodule">php/module.contact.php</serverfile>
</server>
<client>
<clientfile load="release">js/contactimporter.js</clientfile>
<clientfile load="debug">js/contactimporter-debug.js</clientfile>
<clientfile load="source">js/plugin.contactimporter.js</clientfile>
<clientfile load="source">js/ABOUT.js</clientfile>
<clientfile load="source">js/data/ResponseHandler.js</clientfile>
<clientfile load="source">js/dialogs/ImportContentPanel.js</clientfile>
<clientfile load="source">js/dialogs/ImportPanel.js</clientfile>
<clientfile load="source">js/ui/ContextMenu.js</clientfile>
</client>
<resources>
<resourcefile load="release">resources/css/contactimporter.css</resourcefile>
<resourcefile load="debug">resources/css/contactimporter.css</resourcefile>
<resourcefile load="source">resources/css/contactimporter-main.css</resourcefile>
</resources>
</files>
</component>
</components>
</plugin>
<?xml version="1.0"?>
<!DOCTYPE plugin SYSTEM "manifest.dtd">
<plugin version="2">
<info>
<version>2.0.2</version>
<name>contactimporter</name>
<title>VCF Contact Importer/Exporter</title>
<author>Christoph Haas</author>
<authorURL>http://www.sprinternet.at</authorURL>
<description>Import or Export a VCF file to/from the zarafa addressbook</description>
</info>
<translations>
<translationsdir>languages</translationsdir>
</translations>
<config>
<configfile>config.php</configfile>
</config>
<components>
<component>
<files>
<server>
<serverfile>php/plugin.contactimporter.php</serverfile>
<serverfile type="module" module="contactmodule">php/module.contact.php</serverfile>
</server>
<client>
<clientfile load="release">js/contactimporter.js</clientfile>
<clientfile load="debug">js/contactimporter-debug.js</clientfile>
<clientfile load="source">js/plugin.contactimporter.js</clientfile>
<clientfile load="source">js/ABOUT.js</clientfile>
<clientfile load="source">js/data/ResponseHandler.js</clientfile>
<clientfile load="source">js/dialogs/ImportContentPanel.js</clientfile>
<clientfile load="source">js/dialogs/ImportPanel.js</clientfile>
<clientfile load="source">js/ui/ContextMenu.js</clientfile>
</client>
<resources>
<resourcefile load="release">resources/css/contactimporter.css</resourcefile>
<resourcefile load="debug">resources/css/contactimporter.css</resourcefile>
<resourcefile load="source">resources/css/contactimporter-main.css</resourcefile>
</resources>
</files>
</component>
</components>
</plugin>

+ 1169
- 1169
php/module.contact.php
ファイル差分が大きすぎるため省略します
ファイルの表示


+ 30
- 30
resources/css/contactimporter-main.css ファイルの表示

@@ -1,30 +1,30 @@
.icon_contactimporter_button {
background: url(../images/import_icon.png) no-repeat !important;
background-repeat: no-repeat;
background-position: center;
}
.icon_contactimporter_export {
background: url(../images/download.png) no-repeat;
background-repeat: no-repeat;
background-position: center;
}
.icon_contactimporter_import {
background: url(../images/upload.png) no-repeat;
background-repeat: no-repeat;
background-position: center;
}
.zarafa-ciplg-container {
width: 100%;
height: 50px;
}
.zarafa-ciplg-button .x-btn-small {
width: 80%;
height: 30px;
margin-left: 10%;
margin-right: 10%;
margin-top: 10px;
}
.icon_contactimporter_button {
background: url(../images/import_icon.png) no-repeat !important;
background-repeat: no-repeat;
background-position: center;
}
.icon_contactimporter_export {
background: url(../images/download.png) no-repeat;
background-repeat: no-repeat;
background-position: center;
}
.icon_contactimporter_import {
background: url(../images/upload.png) no-repeat;
background-repeat: no-repeat;
background-position: center;
}
.zarafa-ciplg-container {
width: 100%;
height: 50px;
}
.zarafa-ciplg-button .x-btn-small {
width: 80%;
height: 30px;
margin-left: 10%;
margin-right: 10%;
margin-top: 10px;
}

読み込み中…
キャンセル
保存