code beautifications
This commit is contained in:
parent
21af50aa6c
commit
4ce04ab6f9
18
config.php
18
config.php
@ -1,12 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
/** Disable the import plugin for all clients */
|
/** Disable the import plugin for all clients */
|
||||||
define('PLUGIN_CONTACTIMPORTER_USER_DEFAULT_ENABLE', false);
|
define('PLUGIN_CONTACTIMPORTER_USER_DEFAULT_ENABLE', false);
|
||||||
/** Disable the export feature for all clients */
|
|
||||||
define('PLUGIN_CONTACTIMPORTER_USER_DEFAULT_ENABLE_EXPORT', false);
|
/** The default addressbook to import to (default: contact)*/
|
||||||
|
define('PLUGIN_CONTACTIMPORTER_DEFAULT', "contact");
|
||||||
/** The default addressbook to import to (default: contact)*/
|
|
||||||
define('PLUGIN_CONTACTIMPORTER_DEFAULT', "contact");
|
/** Tempory path for uploaded files... */
|
||||||
|
define('PLUGIN_CONTACTIMPORTER_TMP_UPLOAD', "/var/lib/zarafa-webapp/tmp/");
|
||||||
/** Tempory path for uploaded files... */
|
|
||||||
define('PLUGIN_CONTACTIMPORTER_TMP_UPLOAD', "/var/lib/zarafa-webapp/tmp/");
|
|
||||||
?>
|
?>
|
||||||
|
42
js/ABOUT.js
42
js/ABOUT.js
@ -19,7 +19,7 @@
|
|||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Ext.namespace('Zarafa.plugins.contactimporter');
|
Ext.namespace('Zarafa.plugins.contactimporter');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -29,30 +29,30 @@ Ext.namespace('Zarafa.plugins.contactimporter');
|
|||||||
* The copyright string holding the copyright notice for the Zarafa contactimporter Plugin.
|
* The copyright string holding the copyright notice for the Zarafa contactimporter Plugin.
|
||||||
*/
|
*/
|
||||||
Zarafa.plugins.contactimporter.ABOUT = ""
|
Zarafa.plugins.contactimporter.ABOUT = ""
|
||||||
+ "<p>Copyright (C) 2012-2013 Christoph Haas <christoph.h@sprinternet.at></p>"
|
+ "<p>Copyright (C) 2012-2016 Christoph Haas <christoph.h@sprinternet.at></p>"
|
||||||
|
|
||||||
+ "<p>This program is free software; you can redistribute it and/or "
|
+ "<p>This program is free software; you can redistribute it and/or "
|
||||||
+ "modify it under the terms of the GNU Lesser General Public "
|
+ "modify it under the terms of the GNU Lesser General Public "
|
||||||
+ "License as published by the Free Software Foundation; either "
|
+ "License as published by the Free Software Foundation; either "
|
||||||
+ "version 2.1 of the License, or (at your option) any later version.</p>"
|
+ "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, "
|
+ "<p>This program is distributed in the hope that it will be useful, "
|
||||||
+ "but WITHOUT ANY WARRANTY; without even the implied warranty of "
|
+ "but WITHOUT ANY WARRANTY; without even the implied warranty of "
|
||||||
+ "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU "
|
+ "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU "
|
||||||
+ "Lesser General Public License for more details.</p>"
|
+ "Lesser General Public License for more details.</p>"
|
||||||
|
|
||||||
+ "<p>You should have received a copy of the GNU Lesser General Public "
|
+ "<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 "
|
+ "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>"
|
+ "Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</p>"
|
||||||
|
|
||||||
+ "<hr />"
|
+ "<hr />"
|
||||||
|
|
||||||
+ "<p>The contactimporter plugin contains the following third-party components:</p>"
|
+ "<p>The contactimporter plugin contains the following third-party components:</p>"
|
||||||
|
|
||||||
+ "<h1>vCard-parser</h1>"
|
|
||||||
|
|
||||||
+ "<p>Copyright (C) 2012 Nuovo</p>"
|
+ "<h1>vCard-parser</h1>"
|
||||||
|
|
||||||
+ "<p>Licensed under the MIT License.</p>"
|
+ "<p>Copyright (C) 2016 Jeroen Desloovere</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>"
|
+ "<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>"
|
@ -2,7 +2,7 @@
|
|||||||
* ResponseHandler.js zarafa contact im/exporter
|
* ResponseHandler.js zarafa contact im/exporter
|
||||||
*
|
*
|
||||||
* Author: Christoph Haas <christoph.h@sprinternet.at>
|
* Author: Christoph Haas <christoph.h@sprinternet.at>
|
||||||
* Copyright (C) 2012-2013 Christoph Haas
|
* Copyright (C) 2012-2016 Christoph Haas
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
@ -19,7 +19,7 @@
|
|||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ResponseHandler
|
* ResponseHandler
|
||||||
*
|
*
|
||||||
@ -38,21 +38,13 @@ Zarafa.plugins.contactimporter.data.ResponseHandler = Ext.extend(Zarafa.core.dat
|
|||||||
* @cfg {Function} successCallback The function which
|
* @cfg {Function} successCallback The function which
|
||||||
* will be called after success request.
|
* will be called after success request.
|
||||||
*/
|
*/
|
||||||
successCallback : null,
|
successCallback: null,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call the successCallback callback function.
|
* Call the successCallback callback function.
|
||||||
* @param {Object} response Object contained the response data.
|
* @param {Object} response Object contained the response data.
|
||||||
*/
|
*/
|
||||||
doLoad : function(response) {
|
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);
|
this.successCallback(response);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -60,24 +52,32 @@ Zarafa.plugins.contactimporter.data.ResponseHandler = Ext.extend(Zarafa.core.dat
|
|||||||
* Call the successCallback callback function.
|
* Call the successCallback callback function.
|
||||||
* @param {Object} response Object contained the response data.
|
* @param {Object} response Object contained the response data.
|
||||||
*/
|
*/
|
||||||
doExport : function(response) {
|
doImport: function (response) {
|
||||||
this.successCallback(response);
|
this.successCallback(response);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call the successCallback callback function.
|
* Call the successCallback callback function.
|
||||||
* @param {Object} response Object contained the response data.
|
* @param {Object} response Object contained the response data.
|
||||||
*/
|
*/
|
||||||
doImportattachment : function(response) {
|
doExport: function (response) {
|
||||||
this.successCallback(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
|
* In case exception happened on server, server will return
|
||||||
* exception response with the code of exception.
|
* exception response with the code of exception.
|
||||||
* @param {Object} response Object contained the response data.
|
* @param {Object} response Object contained the response data.
|
||||||
*/
|
*/
|
||||||
doError: function(response) {
|
doError: function (response) {
|
||||||
alert("error response code: " + response.error.info.code);
|
alert("error response code: " + response.error.info.code);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* ImportContentPanel.js zarafa contact to vcf im/exporter
|
* ImportContentPanel.js zarafa contact to vcf im/exporter
|
||||||
*
|
*
|
||||||
* Author: Christoph Haas <christoph.h@sprinternet.at>
|
* Author: Christoph Haas <christoph.h@sprinternet.at>
|
||||||
* Copyright (C) 2012-2013 Christoph Haas
|
* Copyright (C) 2012-2016 Christoph Haas
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
@ -19,13 +19,13 @@
|
|||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ImportContentPanel
|
* ImportContentPanel
|
||||||
*
|
*
|
||||||
* Container for the importpanel.
|
* Container for the importpanel.
|
||||||
*/
|
*/
|
||||||
Ext.namespace("Zarafa.plugins.contactimporter.dialogs");
|
Ext.namespace("Zarafa.plugins.contactimporter.dialogs");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @class Zarafa.plugins.contactimporter.dialogs.ImportContentPanel
|
* @class Zarafa.plugins.contactimporter.dialogs.ImportContentPanel
|
||||||
@ -40,23 +40,20 @@ Zarafa.plugins.contactimporter.dialogs.ImportContentPanel = Ext.extend(Zarafa.co
|
|||||||
* @constructor
|
* @constructor
|
||||||
* @param config Configuration structure
|
* @param config Configuration structure
|
||||||
*/
|
*/
|
||||||
constructor : function(config) {
|
constructor: function (config) {
|
||||||
config = config || {};
|
config = config || {};
|
||||||
var title = _('Import Contacts');
|
var title = _('Import Contacts');
|
||||||
if(container.getSettingsModel().get("zarafa/v1/plugins/contactimporter/enable_export")){
|
|
||||||
title = _('Import/Export Contacts');
|
|
||||||
}
|
|
||||||
Ext.applyIf(config, {
|
Ext.applyIf(config, {
|
||||||
layout : 'fit',
|
layout : 'fit',
|
||||||
title : title,
|
title : title,
|
||||||
closeOnSave : true,
|
closeOnSave: true,
|
||||||
width : 620,
|
width : 620,
|
||||||
height : 465,
|
height : 465,
|
||||||
//Add panel
|
//Add panel
|
||||||
items : [
|
items : [
|
||||||
{
|
{
|
||||||
xtype : 'contactimporter.importcontactpanel',
|
xtype : 'contactimporter.importcontactpanel',
|
||||||
filename : config.filename
|
filename: config.filename
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
@ -66,4 +63,4 @@ Zarafa.plugins.contactimporter.dialogs.ImportContentPanel = Ext.extend(Zarafa.co
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Ext.reg('contactimporter.contentpanel' ,Zarafa.plugins.contactimporter.dialogs.ImportContentPanel);
|
Ext.reg('contactimporter.contentpanel', Zarafa.plugins.contactimporter.dialogs.ImportContentPanel);
|
@ -2,7 +2,7 @@
|
|||||||
* ImportPanel.js zarafa contact to vcf im/exporter
|
* ImportPanel.js zarafa contact to vcf im/exporter
|
||||||
*
|
*
|
||||||
* Author: Christoph Haas <christoph.h@sprinternet.at>
|
* Author: Christoph Haas <christoph.h@sprinternet.at>
|
||||||
* Copyright (C) 2012-2013 Christoph Haas
|
* Copyright (C) 2012-2016 Christoph Haas
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
@ -13,7 +13,7 @@
|
|||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
* Lesser General Public License for more details.
|
* Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
* License along with this library; if not, write to the Free Software
|
* License along with this library; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
@ -25,7 +25,7 @@
|
|||||||
*
|
*
|
||||||
* The main Panel of the contactimporter plugin.
|
* The main Panel of the contactimporter plugin.
|
||||||
*/
|
*/
|
||||||
Ext.namespace("Zarafa.plugins.contactimporter.dialogs");
|
Ext.namespace("Zarafa.plugins.contactimporter.dialogs");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @class Zarafa.plugins.contactimporter.dialogs.ImportPanel
|
* @class Zarafa.plugins.contactimporter.dialogs.ImportPanel
|
||||||
@ -35,22 +35,22 @@ Zarafa.plugins.contactimporter.dialogs.ImportPanel = Ext.extend(Ext.Panel, {
|
|||||||
|
|
||||||
/* path to vcf file on server... */
|
/* path to vcf file on server... */
|
||||||
vcffile: null,
|
vcffile: null,
|
||||||
|
|
||||||
/* The store for the selection grid */
|
/* The store for the selection grid */
|
||||||
store: null,
|
store : null,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
* @param {object} config
|
* @param {object} config
|
||||||
*/
|
*/
|
||||||
constructor : function (config) {
|
constructor: function (config) {
|
||||||
config = config || {};
|
config = config || {};
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
if(!Ext.isEmpty(config.filename)) {
|
if (!Ext.isEmpty(config.filename)) {
|
||||||
this.vcffile = config.filename;
|
this.vcffile = config.filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
// create the data store
|
// create the data store
|
||||||
// we only display the firstname, lastname, homephone and primary email address in our grid
|
// we only display the firstname, lastname, homephone and primary email address in our grid
|
||||||
this.store = new Ext.data.ArrayStore({
|
this.store = new Ext.data.ArrayStore({
|
||||||
@ -62,42 +62,42 @@ Zarafa.plugins.contactimporter.dialogs.ImportPanel = Ext.extend(Ext.Panel, {
|
|||||||
{name: 'record'}
|
{name: 'record'}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
Ext.apply(config, {
|
Ext.apply(config, {
|
||||||
xtype : 'contactimporter.importpanel',
|
xtype : 'contactimporter.importpanel',
|
||||||
ref : "importcontactpanel",
|
ref : "importcontactpanel",
|
||||||
layout : {
|
layout : {
|
||||||
type : 'form',
|
type : 'form',
|
||||||
align : 'stretch'
|
align: 'stretch'
|
||||||
},
|
},
|
||||||
anchor : '100%',
|
anchor : '100%',
|
||||||
bodyStyle : 'background-color: inherit;',
|
bodyStyle: 'background-color: inherit;',
|
||||||
defaults : {
|
defaults : {
|
||||||
border : true,
|
border : true,
|
||||||
bodyStyle : 'background-color: inherit; padding: 3px 0px 3px 0px; border-style: none none solid none;'
|
bodyStyle: 'background-color: inherit; padding: 3px 0px 3px 0px; border-style: none none solid none;'
|
||||||
},
|
},
|
||||||
items : [
|
items : [
|
||||||
this.createSelectBox(),
|
this.createSelectBox(),
|
||||||
this.initForm(),
|
this.initForm(),
|
||||||
this.createGrid()
|
this.createGrid()
|
||||||
],
|
],
|
||||||
buttons: [
|
buttons : [
|
||||||
this.createSubmitAllButton(),
|
this.createSubmitAllButton(),
|
||||||
this.createSubmitButton(),
|
this.createSubmitButton(),
|
||||||
this.createCancelButton()
|
this.createCancelButton()
|
||||||
],
|
],
|
||||||
listeners: {
|
listeners: {
|
||||||
afterrender: function (cmp) {
|
afterrender: function (cmp) {
|
||||||
this.loadMask = new Ext.LoadMask(this.getEl(), {msg:'Loading...'});
|
this.loadMask = new Ext.LoadMask(this.getEl(), {msg: 'Loading...'});
|
||||||
|
|
||||||
if(this.vcffile != null) { // if we have got the filename from an attachment
|
if (this.vcffile != null) { // if we have got the filename from an attachment
|
||||||
this.parseContacts(this.vcffile);
|
this.parseContacts(this.vcffile);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
scope: this
|
scope : this
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Zarafa.plugins.contactimporter.dialogs.ImportPanel.superclass.constructor.call(this, config);
|
Zarafa.plugins.contactimporter.dialogs.ImportPanel.superclass.constructor.call(this, config);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -106,22 +106,22 @@ Zarafa.plugins.contactimporter.dialogs.ImportPanel = Ext.extend(Ext.Panel, {
|
|||||||
* posted and contains the attachments
|
* posted and contains the attachments
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
initForm : function () {
|
initForm: function () {
|
||||||
return {
|
return {
|
||||||
xtype: 'form',
|
xtype : 'form',
|
||||||
ref: 'addContactFormPanel',
|
ref : 'addContactFormPanel',
|
||||||
layout : 'column',
|
layout : 'column',
|
||||||
fileUpload: true,
|
fileUpload: true,
|
||||||
autoWidth: true,
|
autoWidth : true,
|
||||||
autoHeight: true,
|
autoHeight: true,
|
||||||
border: false,
|
border : false,
|
||||||
bodyStyle: 'padding: 5px;',
|
bodyStyle : 'padding: 5px;',
|
||||||
defaults: {
|
defaults : {
|
||||||
anchor: '95%',
|
anchor : '95%',
|
||||||
border: false,
|
border : false,
|
||||||
bodyStyle: 'padding: 5px;'
|
bodyStyle: 'padding: 5px;'
|
||||||
},
|
},
|
||||||
items: [this.createUploadField()]
|
items : [this.createUploadField()]
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -129,14 +129,14 @@ Zarafa.plugins.contactimporter.dialogs.ImportPanel = Ext.extend(Ext.Panel, {
|
|||||||
* Reloads the data of the grid
|
* Reloads the data of the grid
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
reloadGridStore: function(contactdata) {
|
reloadGridStore: function (contactdata) {
|
||||||
var parsedData = [];
|
var parsedData = [];
|
||||||
|
|
||||||
if(contactdata) {
|
if (contactdata) {
|
||||||
parsedData = new Array(contactdata.contacts.length);
|
parsedData = new Array(contactdata.contacts.length);
|
||||||
var i = 0;
|
var i = 0;
|
||||||
for(i = 0; i < contactdata.contacts.length; i++) {
|
for (i = 0; i < contactdata.contacts.length; i++) {
|
||||||
|
|
||||||
parsedData[i] = [
|
parsedData[i] = [
|
||||||
contactdata.contacts[i]["display_name"],
|
contactdata.contacts[i]["display_name"],
|
||||||
contactdata.contacts[i]["given_name"],
|
contactdata.contacts[i]["given_name"],
|
||||||
@ -151,63 +151,63 @@ Zarafa.plugins.contactimporter.dialogs.ImportPanel = Ext.extend(Ext.Panel, {
|
|||||||
|
|
||||||
this.store.loadData(parsedData, false);
|
this.store.loadData(parsedData, false);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Init embedded form, this is the form that is
|
* Init embedded form, this is the form that is
|
||||||
* posted and contains the attachments
|
* posted and contains the attachments
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
createGrid : function() {
|
createGrid: function () {
|
||||||
return {
|
return {
|
||||||
xtype: 'grid',
|
xtype : 'grid',
|
||||||
ref: 'contactGrid',
|
ref : 'contactGrid',
|
||||||
columnWidth: 1.0,
|
columnWidth: 1.0,
|
||||||
store: this.store,
|
store : this.store,
|
||||||
width: '100%',
|
width : '100%',
|
||||||
height: 300,
|
height : 300,
|
||||||
title: 'Select contacts to import',
|
title : 'Select contacts to import',
|
||||||
frame: false,
|
frame : false,
|
||||||
viewConfig:{
|
viewConfig : {
|
||||||
forceFit:true
|
forceFit: true
|
||||||
},
|
},
|
||||||
colModel: new Ext.grid.ColumnModel({
|
colModel : new Ext.grid.ColumnModel({
|
||||||
defaults: {
|
defaults: {
|
||||||
width: 300,
|
width : 300,
|
||||||
sortable: true
|
sortable: true
|
||||||
},
|
},
|
||||||
columns: [
|
columns : [
|
||||||
{id: 'Displayname', header: 'Displayname', width: 350, sortable: true, dataIndex: 'display_name'},
|
{id: 'Displayname', header: 'Displayname', width: 350, sortable: true, dataIndex: 'display_name'},
|
||||||
{header: 'Firstname', width: 200, sortable: true, dataIndex: 'given_name'},
|
{header: 'Firstname', width: 200, sortable: true, dataIndex: 'given_name'},
|
||||||
{header: 'Lastname', width: 200, sortable: true, dataIndex: 'surname'},
|
{header: 'Lastname', width: 200, sortable: true, dataIndex: 'surname'},
|
||||||
{header: 'Company', sortable: true, dataIndex: 'company_name'}
|
{header: 'Company', sortable: true, dataIndex: 'company_name'}
|
||||||
]
|
]
|
||||||
}),
|
}),
|
||||||
sm: new Ext.grid.RowSelectionModel({multiSelect:true})
|
sm : new Ext.grid.RowSelectionModel({multiSelect: true})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
createSelectBox: function() {
|
createSelectBox: function () {
|
||||||
var defaultFolder = container.getHierarchyStore().getDefaultFolder('contact'); // @type: Zarafa.hierarchy.data.MAPIFolderRecord
|
var defaultFolder = container.getHierarchyStore().getDefaultFolder('contact'); // @type: Zarafa.hierarchy.data.MAPIFolderRecord
|
||||||
var subFolders = defaultFolder.getChildren();
|
var subFolders = defaultFolder.getChildren();
|
||||||
var myStore = [];
|
var myStore = [];
|
||||||
|
|
||||||
/* add all local contact folders */
|
/* add all local contact folders */
|
||||||
var i = 0;
|
var i = 0;
|
||||||
myStore.push([defaultFolder.getDefaultFolderKey(), defaultFolder.getDisplayName()]);
|
myStore.push([defaultFolder.getDefaultFolderKey(), defaultFolder.getDisplayName()]);
|
||||||
for(i = 0; i < subFolders.length; i++) {
|
for (i = 0; i < subFolders.length; i++) {
|
||||||
/* Store all subfolders */
|
/* Store all subfolders */
|
||||||
myStore.push([subFolders[i].getDisplayName(), subFolders[i].getDisplayName(), false]); // 3rd field = isPublicfolder
|
myStore.push([subFolders[i].getDisplayName(), subFolders[i].getDisplayName(), false]); // 3rd field = isPublicfolder
|
||||||
}
|
}
|
||||||
|
|
||||||
/* add all shared contact folders */
|
/* add all shared contact folders */
|
||||||
var pubStore = container.getHierarchyStore().getPublicStore();
|
var pubStore = container.getHierarchyStore().getPublicStore();
|
||||||
|
|
||||||
if(typeof pubStore !== "undefined") {
|
if (typeof pubStore !== "undefined") {
|
||||||
try {
|
try {
|
||||||
var pubFolder = pubStore.getDefaultFolder("publicfolders");
|
var pubFolder = pubStore.getDefaultFolder("publicfolders");
|
||||||
var pubSubFolders = pubFolder.getChildren();
|
var pubSubFolders = pubFolder.getChildren();
|
||||||
for(i = 0; i < pubSubFolders.length; i++) {
|
for (i = 0; i < pubSubFolders.length; i++) {
|
||||||
if(pubSubFolders[i].isContainerClass("IPF.Contact")){
|
if (pubSubFolders[i].isContainerClass("IPF.Contact")) {
|
||||||
myStore.push([pubSubFolders[i].getDisplayName(), pubSubFolders[i].getDisplayName() + " [Shared]", true]); // 3rd field = isPublicfolder
|
myStore.push([pubSubFolders[i].getDisplayName(), pubSubFolders[i].getDisplayName() + " [Shared]", true]); // 3rd field = isPublicfolder
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -216,128 +216,128 @@ Zarafa.plugins.contactimporter.dialogs.ImportPanel = Ext.extend(Ext.Panel, {
|
|||||||
console.log(e);
|
console.log(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
xtype: "selectbox",
|
xtype : "selectbox",
|
||||||
ref: 'addressbookSelector',
|
ref : 'addressbookSelector',
|
||||||
editable: false,
|
editable : false,
|
||||||
name: "choosen_addressbook",
|
name : "choosen_addressbook",
|
||||||
value: container.getSettingsModel().get("zarafa/v1/plugins/contactimporter/default_addressbook"),
|
value : container.getSettingsModel().get("zarafa/v1/plugins/contactimporter/default_addressbook"),
|
||||||
width: 100,
|
width : 100,
|
||||||
fieldLabel: "Select an addressbook",
|
fieldLabel : "Select an addressbook",
|
||||||
store: myStore,
|
store : myStore,
|
||||||
mode: 'local',
|
mode : 'local',
|
||||||
labelSeperator: ":",
|
labelSeperator: ":",
|
||||||
border: false,
|
border : false,
|
||||||
anchor: "100%",
|
anchor : "100%",
|
||||||
scope: this,
|
scope : this,
|
||||||
allowBlank: false
|
allowBlank : false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
createUploadField: function() {
|
createUploadField: function () {
|
||||||
return {
|
return {
|
||||||
xtype: "fileuploadfield",
|
xtype : "fileuploadfield",
|
||||||
ref: 'contactfileuploadfield',
|
ref : 'contactfileuploadfield',
|
||||||
columnWidth: 1.0,
|
columnWidth: 1.0,
|
||||||
id: 'form-file',
|
id : 'form-file',
|
||||||
name: 'vcfdata',
|
name : 'vcfdata',
|
||||||
emptyText: 'Select an .vcf addressbook',
|
emptyText : 'Select an .vcf addressbook',
|
||||||
border: false,
|
border : false,
|
||||||
anchor: "100%",
|
anchor : "100%",
|
||||||
scope: this,
|
scope : this,
|
||||||
allowBlank: false,
|
allowBlank : false,
|
||||||
listeners: {
|
listeners : {
|
||||||
'fileselected': this.onFileSelected,
|
'fileselected': this.onFileSelected,
|
||||||
scope: this
|
scope : this
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
createSubmitButton: function() {
|
createSubmitButton: function () {
|
||||||
return {
|
return {
|
||||||
xtype: "button",
|
xtype : "button",
|
||||||
ref: "../submitButton",
|
ref : "../submitButton",
|
||||||
disabled: true,
|
disabled : true,
|
||||||
width: 100,
|
width : 100,
|
||||||
border: false,
|
border : false,
|
||||||
text: _("Import"),
|
text : _("Import"),
|
||||||
anchor: "100%",
|
anchor : "100%",
|
||||||
handler: this.importCheckedContacts,
|
handler : this.importCheckedContacts,
|
||||||
scope: this,
|
scope : this,
|
||||||
allowBlank: false
|
allowBlank: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
createSubmitAllButton: function() {
|
createSubmitAllButton: function () {
|
||||||
return {
|
return {
|
||||||
xtype: "button",
|
xtype : "button",
|
||||||
ref: "../submitAllButton",
|
ref : "../submitAllButton",
|
||||||
disabled: true,
|
disabled : true,
|
||||||
width: 100,
|
width : 100,
|
||||||
border: false,
|
border : false,
|
||||||
text: _("Import All"),
|
text : _("Import All"),
|
||||||
anchor: "100%",
|
anchor : "100%",
|
||||||
handler: this.importAllContacts,
|
handler : this.importAllContacts,
|
||||||
scope: this,
|
scope : this,
|
||||||
allowBlank: false
|
allowBlank: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
createCancelButton: function() {
|
createCancelButton: function () {
|
||||||
return {
|
return {
|
||||||
xtype: "button",
|
xtype : "button",
|
||||||
width: 100,
|
width : 100,
|
||||||
border: false,
|
border : false,
|
||||||
text: _("Cancel"),
|
text : _("Cancel"),
|
||||||
anchor: "100%",
|
anchor : "100%",
|
||||||
handler: this.close,
|
handler : this.close,
|
||||||
scope: this,
|
scope : this,
|
||||||
allowBlank: false
|
allowBlank: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is called when a file has been seleceted in the file dialog
|
* This is called when a file has been seleceted in the file dialog
|
||||||
* in the {@link Ext.ux.form.FileUploadField} and the dialog is closed
|
* in the {@link Ext.ux.form.FileUploadField} and the dialog is closed
|
||||||
* @param {Ext.ux.form.FileUploadField} uploadField being added a file to
|
* @param {Ext.ux.form.FileUploadField} uploadField being added a file to
|
||||||
*/
|
*/
|
||||||
onFileSelected : function(uploadField) {
|
onFileSelected: function (uploadField) {
|
||||||
var form = this.addContactFormPanel.getForm();
|
var form = this.addContactFormPanel.getForm();
|
||||||
|
|
||||||
if (form.isValid()) {
|
if (form.isValid()) {
|
||||||
form.submit({
|
form.submit({
|
||||||
waitMsg: 'Uploading and parsing contacts...',
|
waitMsg: 'Uploading and parsing contacts...',
|
||||||
url: 'plugins/contactimporter/php/upload.php',
|
url : 'plugins/contactimporter/php/upload.php',
|
||||||
failure: function(file, action) {
|
failure: function (file, action) {
|
||||||
this.submitButton.disable();
|
this.submitButton.disable();
|
||||||
this.submitAllButton.disable();
|
this.submitAllButton.disable();
|
||||||
Zarafa.common.dialogs.MessageBox.show({
|
Zarafa.common.dialogs.MessageBox.show({
|
||||||
title : _('Error'),
|
title : _('Error'),
|
||||||
msg : _(action.result.error),
|
msg : _(action.result.error),
|
||||||
icon : Zarafa.common.dialogs.MessageBox.ERROR,
|
icon : Zarafa.common.dialogs.MessageBox.ERROR,
|
||||||
buttons : Zarafa.common.dialogs.MessageBox.OK
|
buttons: Zarafa.common.dialogs.MessageBox.OK
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
success: function(file, action){
|
success: function (file, action) {
|
||||||
uploadField.reset();
|
uploadField.reset();
|
||||||
this.vcffile = action.result.vcf_file;
|
this.vcffile = action.result.vcf_file;
|
||||||
|
|
||||||
this.parseContacts(this.vcffile);
|
this.parseContacts(this.vcffile);
|
||||||
},
|
},
|
||||||
scope : this
|
scope : this
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
parseContacts: function (vcfPath) {
|
parseContacts: function (vcfPath) {
|
||||||
this.loadMask.show();
|
this.loadMask.show();
|
||||||
|
|
||||||
// call export function here!
|
// call export function here!
|
||||||
var responseHandler = new Zarafa.plugins.contactimporter.data.ResponseHandler({
|
var responseHandler = new Zarafa.plugins.contactimporter.data.ResponseHandler({
|
||||||
successCallback: this.handleParsingResult.createDelegate(this)
|
successCallback: this.handleParsingResult.createDelegate(this)
|
||||||
});
|
});
|
||||||
|
|
||||||
container.getRequest().singleRequest(
|
container.getRequest().singleRequest(
|
||||||
'contactmodule',
|
'contactmodule',
|
||||||
'load',
|
'load',
|
||||||
@ -347,23 +347,23 @@ Zarafa.plugins.contactimporter.dialogs.ImportPanel = Ext.extend(Ext.Panel, {
|
|||||||
responseHandler
|
responseHandler
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
handleParsingResult: function(response) {
|
handleParsingResult: function (response) {
|
||||||
this.loadMask.hide();
|
this.loadMask.hide();
|
||||||
|
|
||||||
if(response["status"] == true) {
|
if (response["status"] == true) {
|
||||||
this.submitButton.enable();
|
this.submitButton.enable();
|
||||||
this.submitAllButton.enable();
|
this.submitAllButton.enable();
|
||||||
|
|
||||||
this.reloadGridStore(response.parsed);
|
this.reloadGridStore(response.parsed);
|
||||||
} else {
|
} else {
|
||||||
this.submitButton.disable();
|
this.submitButton.disable();
|
||||||
this.submitAllButton.disable();
|
this.submitAllButton.disable();
|
||||||
Zarafa.common.dialogs.MessageBox.show({
|
Zarafa.common.dialogs.MessageBox.show({
|
||||||
title : _('Parser Error'),
|
title : _('Parser Error'),
|
||||||
msg : _(response["message"]),
|
msg : _(response["message"]),
|
||||||
icon : Zarafa.common.dialogs.MessageBox.ERROR,
|
icon : Zarafa.common.dialogs.MessageBox.ERROR,
|
||||||
buttons : Zarafa.common.dialogs.MessageBox.OK
|
buttons: Zarafa.common.dialogs.MessageBox.OK
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -376,117 +376,117 @@ Zarafa.plugins.contactimporter.dialogs.ImportPanel = Ext.extend(Ext.Panel, {
|
|||||||
importCheckedContacts: function () {
|
importCheckedContacts: function () {
|
||||||
var newRecords = this.contactGrid.selModel.getSelections();
|
var newRecords = this.contactGrid.selModel.getSelections();
|
||||||
this.importContacts(newRecords);
|
this.importContacts(newRecords);
|
||||||
},
|
},
|
||||||
|
|
||||||
importAllContacts: function () {
|
importAllContacts: function () {
|
||||||
//receive Records from grid rows
|
//receive Records from grid rows
|
||||||
this.contactGrid.selModel.selectAll(); // select all entries
|
this.contactGrid.selModel.selectAll(); // select all entries
|
||||||
var newRecords = this.contactGrid.selModel.getSelections();
|
var newRecords = this.contactGrid.selModel.getSelections();
|
||||||
this.importContacts(newRecords);
|
this.importContacts(newRecords);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function stores all given events to the appointmentstore
|
* This function stores all given events to the appointmentstore
|
||||||
* @param events
|
* @param events
|
||||||
*/
|
*/
|
||||||
importContacts: function (contacts) {
|
importContacts: function (contacts) {
|
||||||
//receive existing contact store
|
//receive existing contact store
|
||||||
var folderValue = this.addressbookSelector.getValue();
|
var folderValue = this.addressbookSelector.getValue();
|
||||||
|
|
||||||
if(folderValue == undefined) { // no addressbook choosen
|
if (folderValue == undefined) { // no addressbook choosen
|
||||||
Zarafa.common.dialogs.MessageBox.show({
|
Zarafa.common.dialogs.MessageBox.show({
|
||||||
title : _('Error'),
|
title : _('Error'),
|
||||||
msg : _('You have to choose an addressbook!'),
|
msg : _('You have to choose an addressbook!'),
|
||||||
icon : Zarafa.common.dialogs.MessageBox.ERROR,
|
icon : Zarafa.common.dialogs.MessageBox.ERROR,
|
||||||
buttons : Zarafa.common.dialogs.MessageBox.OK
|
buttons: Zarafa.common.dialogs.MessageBox.OK
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
var addressbookexist = true;
|
var addressbookexist = true;
|
||||||
if(this.contactGrid.selModel.getCount() < 1) {
|
if (this.contactGrid.selModel.getCount() < 1) {
|
||||||
Zarafa.common.dialogs.MessageBox.show({
|
Zarafa.common.dialogs.MessageBox.show({
|
||||||
title : _('Error'),
|
title : _('Error'),
|
||||||
msg : _('You have to choose at least one contact to import!'),
|
msg : _('You have to choose at least one contact to import!'),
|
||||||
icon : Zarafa.common.dialogs.MessageBox.ERROR,
|
icon : Zarafa.common.dialogs.MessageBox.ERROR,
|
||||||
buttons : Zarafa.common.dialogs.MessageBox.OK
|
buttons: Zarafa.common.dialogs.MessageBox.OK
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
var contactStore = new Zarafa.contact.ContactStore();
|
var contactStore = new Zarafa.contact.ContactStore();
|
||||||
var contactFolder = container.getHierarchyStore().getDefaultFolder('contact');
|
var contactFolder = container.getHierarchyStore().getDefaultFolder('contact');
|
||||||
var pubStore = container.getHierarchyStore().getPublicStore();
|
var pubStore = container.getHierarchyStore().getPublicStore();
|
||||||
var pubFolder = pubStore.getDefaultFolder("publicfolders");
|
var pubFolder = pubStore.getDefaultFolder("publicfolders");
|
||||||
var pubSubFolders = pubFolder.getChildren();
|
var pubSubFolders = pubFolder.getChildren();
|
||||||
|
|
||||||
if(folderValue != "contact") {
|
if (folderValue != "contact") {
|
||||||
var subFolders = contactFolder.getChildren();
|
var subFolders = contactFolder.getChildren();
|
||||||
var i = 0;
|
var i = 0;
|
||||||
for(i = 0; i < pubSubFolders.length; i++) {
|
for (i = 0; i < pubSubFolders.length; i++) {
|
||||||
if(pubSubFolders[i].isContainerClass("IPF.Contact")){
|
if (pubSubFolders[i].isContainerClass("IPF.Contact")) {
|
||||||
subFolders.push(pubSubFolders[i]);
|
subFolders.push(pubSubFolders[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(i=0;i<subFolders.length;i++) {
|
for (i = 0; i < subFolders.length; i++) {
|
||||||
// look up right folder
|
// look up right folder
|
||||||
// TODO: improve!!
|
// TODO: improve!!
|
||||||
if(subFolders[i].getDisplayName() == folderValue) {
|
if (subFolders[i].getDisplayName() == folderValue) {
|
||||||
contactFolder = subFolders[i];
|
contactFolder = subFolders[i];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(contactFolder.isDefaultFolder()) {
|
if (contactFolder.isDefaultFolder()) {
|
||||||
Zarafa.common.dialogs.MessageBox.show({
|
Zarafa.common.dialogs.MessageBox.show({
|
||||||
title : _('Error'),
|
title : _('Error'),
|
||||||
msg : _('Selected addressbook does not exist!'),
|
msg : _('Selected addressbook does not exist!'),
|
||||||
icon : Zarafa.common.dialogs.MessageBox.ERROR,
|
icon : Zarafa.common.dialogs.MessageBox.ERROR,
|
||||||
buttons : Zarafa.common.dialogs.MessageBox.OK
|
buttons: Zarafa.common.dialogs.MessageBox.OK
|
||||||
});
|
});
|
||||||
addressbookexist = false;
|
addressbookexist = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(addressbookexist) {
|
if (addressbookexist) {
|
||||||
this.loadMask.show();
|
this.loadMask.show();
|
||||||
var uids = [];
|
var uids = [];
|
||||||
var store_entryid = "";
|
var store_entryid = "";
|
||||||
|
|
||||||
//receive Records from grid rows
|
//receive Records from grid rows
|
||||||
Ext.each(contacts, function(newRecord) {
|
Ext.each(contacts, function (newRecord) {
|
||||||
uids.push(newRecord.data.record.internal_fields.contact_uid);
|
uids.push(newRecord.data.record.internal_fields.contact_uid);
|
||||||
}, this);
|
}, this);
|
||||||
store_entryid = contactFolder.get('store_entryid');
|
store_entryid = contactFolder.get('store_entryid');
|
||||||
|
|
||||||
var responseHandler = new Zarafa.plugins.contactimporter.data.ResponseHandler({
|
var responseHandler = new Zarafa.plugins.contactimporter.data.ResponseHandler({
|
||||||
successCallback: this.importContactsDone.createDelegate(this)
|
successCallback: this.importContactsDone.createDelegate(this)
|
||||||
});
|
});
|
||||||
|
|
||||||
container.getRequest().singleRequest(
|
container.getRequest().singleRequest(
|
||||||
'contactmodule',
|
'contactmodule',
|
||||||
'import',
|
'import',
|
||||||
{
|
{
|
||||||
storeid: contactFolder.get("store_entryid"),
|
storeid : contactFolder.get("store_entryid"),
|
||||||
folderid: contactFolder.get("entryid"),
|
folderid : contactFolder.get("entryid"),
|
||||||
uids: uids,
|
uids : uids,
|
||||||
vcf_filepath: this.vcffile
|
vcf_filepath: this.vcffile
|
||||||
},
|
},
|
||||||
responseHandler
|
responseHandler
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
importContactsDone : function (response) {
|
importContactsDone: function (response) {
|
||||||
this.loadMask.hide();
|
this.loadMask.hide();
|
||||||
this.dialog.close();
|
this.dialog.close();
|
||||||
if(response.status == true) {
|
if (response.status == true) {
|
||||||
container.getNotifier().notify('info', 'Imported', 'Imported ' + response.count + ' contacts. Please reload your addressbook!');
|
container.getNotifier().notify('info', 'Imported', 'Imported ' + response.count + ' contacts. Please reload your addressbook!');
|
||||||
} else {
|
} else {
|
||||||
Zarafa.common.dialogs.MessageBox.show({
|
Zarafa.common.dialogs.MessageBox.show({
|
||||||
title : _('Error'),
|
title : _('Error'),
|
||||||
msg : _('Import failed: ') + response.message,
|
msg : _('Import failed: ') + response.message,
|
||||||
icon : Zarafa.common.dialogs.MessageBox.ERROR,
|
icon : Zarafa.common.dialogs.MessageBox.ERROR,
|
||||||
buttons : Zarafa.common.dialogs.MessageBox.OK
|
buttons: Zarafa.common.dialogs.MessageBox.OK
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* plugin.contactimporter.js zarafa contactimporter
|
* plugin.contactimporter.js zarafa contactimporter
|
||||||
*
|
*
|
||||||
* Author: Christoph Haas <christoph.h@sprinternet.at>
|
* Author: Christoph Haas <christoph.h@sprinternet.at>
|
||||||
* Copyright (C) 2012-2013 Christoph Haas
|
* Copyright (C) 2012-2016 Christoph Haas
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
@ -19,34 +19,34 @@
|
|||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Ext.namespace("Zarafa.plugins.contactimporter"); // Assign the right namespace
|
Ext.namespace("Zarafa.plugins.contactimporter"); // Assign the right namespace
|
||||||
|
|
||||||
Zarafa.plugins.contactimporter.ImportPlugin = Ext.extend(Zarafa.core.Plugin, { // create new import plugin
|
Zarafa.plugins.contactimporter.ImportPlugin = Ext.extend(Zarafa.core.Plugin, { // create new import plugin
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
* @param {Object} config Configuration object
|
* @param {Object} config Configuration object
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
constructor: function (config) {
|
constructor: function (config) {
|
||||||
config = config || {};
|
config = config || {};
|
||||||
|
|
||||||
Zarafa.plugins.contactimporter.ImportPlugin.superclass.constructor.call(this, config);
|
Zarafa.plugins.contactimporter.ImportPlugin.superclass.constructor.call(this, config);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* initialises insertion point for plugin
|
* initialises insertion point for plugin
|
||||||
* @protected
|
* @protected
|
||||||
*/
|
*/
|
||||||
initPlugin : function() {
|
initPlugin: function () {
|
||||||
Zarafa.plugins.contactimporter.ImportPlugin.superclass.initPlugin.apply(this, arguments);
|
Zarafa.plugins.contactimporter.ImportPlugin.superclass.initPlugin.apply(this, arguments);
|
||||||
|
|
||||||
/* our panel */
|
/* our panel */
|
||||||
Zarafa.core.data.SharedComponentType.addProperty('plugins.contactimporter.dialogs.importcontacts');
|
Zarafa.core.data.SharedComponentType.addProperty('plugins.contactimporter.dialogs.importcontacts');
|
||||||
|
|
||||||
/* directly import received vcfs */
|
/* directly import received vcfs */
|
||||||
this.registerInsertionPoint('common.contextmenu.attachment.actions', this.createAttachmentImportButton);
|
this.registerInsertionPoint('common.contextmenu.attachment.actions', this.createAttachmentImportButton, this);
|
||||||
|
|
||||||
/* add import button to south navigation */
|
/* add import button to south navigation */
|
||||||
this.registerInsertionPoint("navigation.south", this.createImportButton, this);
|
this.registerInsertionPoint("navigation.south", this.createImportButton, this);
|
||||||
@ -54,28 +54,24 @@ Zarafa.plugins.contactimporter.ImportPlugin = Ext.extend(Zarafa.core.Plugin, {
|
|||||||
/* export a contact via rightclick */
|
/* export a contact via rightclick */
|
||||||
this.registerInsertionPoint('context.contact.contextmenu.actions', this.createItemExportInsertionPoint, this);
|
this.registerInsertionPoint('context.contact.contextmenu.actions', this.createItemExportInsertionPoint, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the button
|
* Creates the button
|
||||||
*
|
*
|
||||||
* @return {Object} Configuration object for a {@link Ext.Button button}
|
* @return {Object} Configuration object for a {@link Ext.Button button}
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
createImportButton: function () {
|
createImportButton: function () {
|
||||||
var button = {
|
var button = {
|
||||||
xtype : 'button',
|
xtype : 'button',
|
||||||
text : _('Import Contacts'),
|
text : _('Import Contacts'),
|
||||||
iconCls : 'icon_contactimporter_button',
|
iconCls : 'icon_contactimporter_button',
|
||||||
navigationContext : container.getContextByName('contact'),
|
navigationContext: container.getContextByName('contact'),
|
||||||
handler : this.onImportButtonClick,
|
handler : this.onImportButtonClick,
|
||||||
scope : this
|
scope : this
|
||||||
};
|
};
|
||||||
|
|
||||||
if(container.getSettingsModel().get("zarafa/v1/plugins/contactimporter/enable_export")) {
|
return button;
|
||||||
button.text = _('Import/Export Contacts');
|
|
||||||
}
|
|
||||||
|
|
||||||
return button;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -94,20 +90,20 @@ Zarafa.plugins.contactimporter.ImportPlugin = Ext.extend(Zarafa.core.Plugin, {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
exportToVCF: function(btn) {
|
exportToVCF: function (btn) {
|
||||||
if(btn.records.length == 0) {
|
if (btn.records.length == 0) {
|
||||||
return; // skip if no records where given!
|
return; // skip if no records where given!
|
||||||
}
|
}
|
||||||
|
|
||||||
var recordIds = [];
|
var recordIds = [];
|
||||||
|
|
||||||
for(var i=0;i<btn.records.length;i++) {
|
for (var i = 0; i < btn.records.length; i++) {
|
||||||
recordIds.push(btn.records[i].get("entryid"));
|
recordIds.push(btn.records[i].get("entryid"));
|
||||||
}
|
}
|
||||||
|
|
||||||
var responseHandler = new Zarafa.plugins.contactimporter.data.ResponseHandler({
|
var responseHandler = new Zarafa.plugins.contactimporter.data.ResponseHandler({
|
||||||
successCallback: this.downloadVCF,
|
successCallback: this.downloadVCF,
|
||||||
scope: this
|
scope : this
|
||||||
});
|
});
|
||||||
|
|
||||||
// request attachment preperation
|
// request attachment preperation
|
||||||
@ -115,14 +111,14 @@ Zarafa.plugins.contactimporter.ImportPlugin = Ext.extend(Zarafa.core.Plugin, {
|
|||||||
'contactmodule',
|
'contactmodule',
|
||||||
'export',
|
'export',
|
||||||
{
|
{
|
||||||
storeid : btn.records[0].get("store_entryid"),
|
storeid: btn.records[0].get("store_entryid"),
|
||||||
records: recordIds
|
records: recordIds
|
||||||
},
|
},
|
||||||
responseHandler
|
responseHandler
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
downloadVCF: function(response) {
|
downloadVCF: function (response) {
|
||||||
var downloadFrame = Ext.getBody().createChild({
|
var downloadFrame = Ext.getBody().createChild({
|
||||||
tag: 'iframe',
|
tag: 'iframe',
|
||||||
cls: 'x-hidden'
|
cls: 'x-hidden'
|
||||||
@ -137,22 +133,22 @@ Zarafa.plugins.contactimporter.ImportPlugin = Ext.extend(Zarafa.core.Plugin, {
|
|||||||
|
|
||||||
downloadFrame.dom.contentWindow.location = link;
|
downloadFrame.dom.contentWindow.location = link;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Insert import button in all attachment suggestions
|
* Insert import button in all attachment suggestions
|
||||||
|
|
||||||
* @return {Object} Configuration object for a {@link Ext.Button button}
|
* @return {Object} Configuration object for a {@link Ext.Button button}
|
||||||
*/
|
*/
|
||||||
createAttachmentImportButton : function(include, btn) {
|
createAttachmentImportButton: function (include, btn) {
|
||||||
return {
|
return {
|
||||||
text : _('Import Contacts'),
|
text : _('Import Contacts'),
|
||||||
handler : this.getAttachmentFileName.createDelegate(this, [btn]),
|
handler : this.getAttachmentFileName.createDelegate(this, [btn]),
|
||||||
scope : this,
|
scope : this,
|
||||||
iconCls : 'icon_contactimporter_button',
|
iconCls : 'icon_contactimporter_button',
|
||||||
beforeShow : function(item, record) {
|
beforeShow: function (item, record) {
|
||||||
var extension = record.data.name.split('.').pop().toLowerCase();
|
var extension = record.data.name.split('.').pop().toLowerCase();
|
||||||
|
|
||||||
if(record.data.filetype == "text/vcard" || record.data.filetype == "text/x-vcard" || extension == "vcf" || extension == "vcard") {
|
if (record.data.filetype == "text/vcard" || record.data.filetype == "text/x-vcard" || extension == "vcf" || extension == "vcard") {
|
||||||
item.setVisible(true);
|
item.setVisible(true);
|
||||||
} else {
|
} else {
|
||||||
item.setVisible(false);
|
item.setVisible(false);
|
||||||
@ -160,19 +156,19 @@ Zarafa.plugins.contactimporter.ImportPlugin = Ext.extend(Zarafa.core.Plugin, {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Callback for getAttachmentFileName
|
* Callback for getAttachmentFileName
|
||||||
*/
|
*/
|
||||||
gotAttachmentFileName: function(response) {
|
gotAttachmentFileName: function (response) {
|
||||||
if(response.status == true) {
|
if (response.status == true) {
|
||||||
this.openImportDialog(response.tmpname);
|
this.openImportDialog(response.tmpname);
|
||||||
} else {
|
} else {
|
||||||
Zarafa.common.dialogs.MessageBox.show({
|
Zarafa.common.dialogs.MessageBox.show({
|
||||||
title : _('Error'),
|
title : _('Error'),
|
||||||
msg : _(response["message"]),
|
msg : _(response["message"]),
|
||||||
icon : Zarafa.common.dialogs.MessageBox.ERROR,
|
icon : Zarafa.common.dialogs.MessageBox.ERROR,
|
||||||
buttons : Zarafa.common.dialogs.MessageBox.OK
|
buttons: Zarafa.common.dialogs.MessageBox.OK
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -182,63 +178,64 @@ Zarafa.plugins.contactimporter.ImportPlugin = Ext.extend(Zarafa.core.Plugin, {
|
|||||||
*/
|
*/
|
||||||
getAttachmentFileName: function (btn) {
|
getAttachmentFileName: function (btn) {
|
||||||
Zarafa.common.dialogs.MessageBox.show({
|
Zarafa.common.dialogs.MessageBox.show({
|
||||||
title: 'Please wait',
|
title : 'Please wait',
|
||||||
msg: 'Loading attachment...',
|
msg : 'Loading attachment...',
|
||||||
progressText: 'Initializing...',
|
progressText: 'Initializing...',
|
||||||
width:300,
|
width : 300,
|
||||||
progress:true,
|
progress : true,
|
||||||
closable:false
|
closable : false
|
||||||
});
|
});
|
||||||
|
|
||||||
// progress bar... ;)
|
// progress bar... ;)
|
||||||
var f = function(v){
|
var f = function (v) {
|
||||||
return function(){
|
return function () {
|
||||||
if(v == 100){
|
if (v == 100) {
|
||||||
Zarafa.common.dialogs.MessageBox.hide();
|
Zarafa.common.dialogs.MessageBox.hide();
|
||||||
}else{
|
} else {
|
||||||
Zarafa.common.dialogs.MessageBox.updateProgress(v/100, Math.round(v)+'% loaded');
|
Zarafa.common.dialogs.MessageBox.updateProgress(v / 100, Math.round(v) + '% loaded');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
for(var i = 1; i < 101; i++){
|
for (var i = 1; i < 101; i++) {
|
||||||
setTimeout(f(i), 20*i);
|
setTimeout(f(i), 20 * i);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* store the attachment to a temporary folder and prepare it for uploading */
|
/* store the attachment to a temporary folder and prepare it for uploading */
|
||||||
var attachmentRecord = btn.records;
|
var attachmentRecord = btn.records;
|
||||||
var attachmentStore = attachmentRecord.store;
|
var attachmentStore = attachmentRecord.store;
|
||||||
|
|
||||||
var store = attachmentStore.getParentRecord().get('store_entryid');
|
var store = attachmentStore.getParentRecord().get('store_entryid');
|
||||||
var entryid = attachmentStore.getAttachmentParentRecordEntryId();
|
var entryid = attachmentStore.getAttachmentParentRecordEntryId();
|
||||||
var attachNum = new Array(1);
|
var attachNum = new Array(1);
|
||||||
if (attachmentRecord.get('attach_num') != -1)
|
if (attachmentRecord.get('attach_num') != -1) {
|
||||||
attachNum[0] = attachmentRecord.get('attach_num');
|
attachNum[0] = attachmentRecord.get('attach_num');
|
||||||
else
|
} else {
|
||||||
attachNum[0] = attachmentRecord.get('tmpname');
|
attachNum[0] = attachmentRecord.get('tmpname');
|
||||||
|
}
|
||||||
var dialog_attachments = attachmentStore.getId();
|
var dialog_attachments = attachmentStore.getId();
|
||||||
var filename = attachmentRecord.data.name;
|
var filename = attachmentRecord.data.name;
|
||||||
|
|
||||||
var responseHandler = new Zarafa.plugins.contactimporter.data.ResponseHandler({
|
var responseHandler = new Zarafa.plugins.contactimporter.data.ResponseHandler({
|
||||||
successCallback: this.gotAttachmentFileName.createDelegate(this),
|
successCallback: this.gotAttachmentFileName.createDelegate(this),
|
||||||
scope: this
|
scope : this
|
||||||
});
|
});
|
||||||
|
|
||||||
// request attachment preperation
|
// request attachment preperation
|
||||||
container.getRequest().singleRequest(
|
container.getRequest().singleRequest(
|
||||||
'contactmodule',
|
'contactmodule',
|
||||||
'importattachment',
|
'importattachment',
|
||||||
{
|
{
|
||||||
entryid : entryid,
|
entryid : entryid,
|
||||||
store: store,
|
store : store,
|
||||||
attachNum: attachNum,
|
attachNum : attachNum,
|
||||||
dialog_attachments: dialog_attachments,
|
dialog_attachments: dialog_attachments,
|
||||||
filename: filename
|
filename : filename
|
||||||
},
|
},
|
||||||
responseHandler
|
responseHandler
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clickhandler for the button
|
* Clickhandler for the button
|
||||||
*/
|
*/
|
||||||
@ -250,8 +247,8 @@ Zarafa.plugins.contactimporter.ImportPlugin = Ext.extend(Zarafa.core.Plugin, {
|
|||||||
* Open the import dialog.
|
* Open the import dialog.
|
||||||
*
|
*
|
||||||
* @param {String} filename
|
* @param {String} filename
|
||||||
*/
|
*/
|
||||||
openImportDialog: function(filename) {
|
openImportDialog: function (filename) {
|
||||||
var componentType = Zarafa.core.data.SharedComponentType['plugins.contactimporter.dialogs.importcontacts'];
|
var componentType = Zarafa.core.data.SharedComponentType['plugins.contactimporter.dialogs.importcontacts'];
|
||||||
var config = {
|
var config = {
|
||||||
filename: filename
|
filename: filename
|
||||||
@ -268,9 +265,9 @@ Zarafa.plugins.contactimporter.ImportPlugin = Ext.extend(Zarafa.core.Plugin, {
|
|||||||
* @param {Ext.data.Record} record Optionally passed record.
|
* @param {Ext.data.Record} record Optionally passed record.
|
||||||
* @return {Number} The bid for the shared component
|
* @return {Number} The bid for the shared component
|
||||||
*/
|
*/
|
||||||
bidSharedComponent : function(type, record) {
|
bidSharedComponent: function (type, record) {
|
||||||
var bid = -1;
|
var bid = -1;
|
||||||
switch(type) {
|
switch (type) {
|
||||||
case Zarafa.core.data.SharedComponentType['plugins.contactimporter.dialogs.importcontacts']:
|
case Zarafa.core.data.SharedComponentType['plugins.contactimporter.dialogs.importcontacts']:
|
||||||
bid = 1;
|
bid = 1;
|
||||||
break;
|
break;
|
||||||
@ -285,9 +282,9 @@ Zarafa.plugins.contactimporter.ImportPlugin = Ext.extend(Zarafa.core.Plugin, {
|
|||||||
* @param {Ext.data.Record} record Optionally passed record.
|
* @param {Ext.data.Record} record Optionally passed record.
|
||||||
* @return {Ext.Component} Component
|
* @return {Ext.Component} Component
|
||||||
*/
|
*/
|
||||||
getSharedComponent : function(type, record) {
|
getSharedComponent: function (type, record) {
|
||||||
var component;
|
var component;
|
||||||
switch(type) {
|
switch (type) {
|
||||||
case Zarafa.core.data.SharedComponentType['plugins.contactimporter.dialogs.importcontacts']:
|
case Zarafa.core.data.SharedComponentType['plugins.contactimporter.dialogs.importcontacts']:
|
||||||
component = Zarafa.plugins.contactimporter.dialogs.ImportContentPanel;
|
component = Zarafa.plugins.contactimporter.dialogs.ImportContentPanel;
|
||||||
break;
|
break;
|
||||||
@ -301,11 +298,11 @@ Zarafa.plugins.contactimporter.ImportPlugin = Ext.extend(Zarafa.core.Plugin, {
|
|||||||
/*############################################################################################################################
|
/*############################################################################################################################
|
||||||
* STARTUP
|
* STARTUP
|
||||||
*############################################################################################################################*/
|
*############################################################################################################################*/
|
||||||
Zarafa.onReady(function() {
|
Zarafa.onReady(function () {
|
||||||
container.registerPlugin(new Zarafa.core.PluginMetaData({
|
container.registerPlugin(new Zarafa.core.PluginMetaData({
|
||||||
name : 'contactimporter',
|
name : 'contactimporter',
|
||||||
displayName : _('Contactimporter Plugin'),
|
displayName : _('Contactimporter Plugin'),
|
||||||
about : Zarafa.plugins.contactimporter.ABOUT,
|
about : Zarafa.plugins.contactimporter.ABOUT,
|
||||||
pluginConstructor : Zarafa.plugins.contactimporter.ImportPlugin
|
pluginConstructor: Zarafa.plugins.contactimporter.ImportPlugin
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
<client>
|
<client>
|
||||||
<clientfile load="release">js/contactimporter-debug.js</clientfile>
|
<clientfile load="release">js/contactimporter-debug.js</clientfile>
|
||||||
<clientfile load="debug">js/contactimporter-debug.js</clientfile>
|
<clientfile load="debug">js/contactimporter-debug.js</clientfile>
|
||||||
|
|
||||||
<clientfile load="source">js/plugin.contactimporter.js</clientfile>
|
<clientfile load="source">js/plugin.contactimporter.js</clientfile>
|
||||||
<clientfile load="source">js/ABOUT.js</clientfile>
|
<clientfile load="source">js/ABOUT.js</clientfile>
|
||||||
<clientfile load="source">js/data/ResponseHandler.js</clientfile>
|
<clientfile load="source">js/data/ResponseHandler.js</clientfile>
|
||||||
|
@ -1,9 +1,30 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* download.php, zarafa 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
|
||||||
|
*
|
||||||
|
*/
|
||||||
class DownloadHandler
|
class DownloadHandler
|
||||||
{
|
{
|
||||||
|
|
||||||
public static function doDownload() {
|
public static function doDownload()
|
||||||
|
{
|
||||||
if (isset($_GET["token"])) {
|
if (isset($_GET["token"])) {
|
||||||
$token = $_GET["token"];
|
$token = $_GET["token"];
|
||||||
} else {
|
} else {
|
||||||
@ -23,7 +44,7 @@ class DownloadHandler
|
|||||||
|
|
||||||
$file = PLUGIN_CONTACTIMPORTER_TMP_UPLOAD . "vcf_" . $token . ".vcf";
|
$file = PLUGIN_CONTACTIMPORTER_TMP_UPLOAD . "vcf_" . $token . ".vcf";
|
||||||
|
|
||||||
if(!file_exists($file)) { // invalid token
|
if (!file_exists($file)) { // invalid token
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -3,7 +3,7 @@
|
|||||||
* plugin.contactimporter.php, zarafa contact to vcf im/exporter
|
* plugin.contactimporter.php, zarafa contact to vcf im/exporter
|
||||||
*
|
*
|
||||||
* Author: Christoph Haas <christoph.h@sprinternet.at>
|
* Author: Christoph Haas <christoph.h@sprinternet.at>
|
||||||
* Copyright (C) 2012-2013 Christoph Haas
|
* Copyright (C) 2012-2016 Christoph Haas
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
@ -28,18 +28,22 @@ require_once __DIR__ . "/download.php";
|
|||||||
* With this plugin you can import a vcf file to your zarafa addressbook
|
* With this plugin you can import a vcf file to your zarafa addressbook
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class Plugincontactimporter extends Plugin {
|
class Plugincontactimporter extends Plugin
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
function Plugincontactimporter() {}
|
function Plugincontactimporter()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function initializes the Plugin and registers all hooks
|
* Function initializes the Plugin and registers all hooks
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function init() {
|
function init()
|
||||||
|
{
|
||||||
$this->registerHook('server.core.settings.init.before');
|
$this->registerHook('server.core.settings.init.before');
|
||||||
$this->registerHook('server.index.load.custom');
|
$this->registerHook('server.index.load.custom');
|
||||||
}
|
}
|
||||||
@ -51,8 +55,9 @@ class Plugincontactimporter extends Plugin {
|
|||||||
* @param mixed $data object(s) related to the hook
|
* @param mixed $data object(s) related to the hook
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function execute($eventID, &$data) {
|
function execute($eventID, &$data)
|
||||||
switch($eventID) {
|
{
|
||||||
|
switch ($eventID) {
|
||||||
case 'server.core.settings.init.before' :
|
case 'server.core.settings.init.before' :
|
||||||
$this->injectPluginSettings($data);
|
$this->injectPluginSettings($data);
|
||||||
break;
|
break;
|
||||||
@ -69,15 +74,15 @@ class Plugincontactimporter extends Plugin {
|
|||||||
* settings.
|
* settings.
|
||||||
* @param Array $data Reference to the data of the triggered hook
|
* @param Array $data Reference to the data of the triggered hook
|
||||||
*/
|
*/
|
||||||
function injectPluginSettings(&$data) {
|
function injectPluginSettings(&$data)
|
||||||
|
{
|
||||||
$data['settingsObj']->addSysAdminDefaults(Array(
|
$data['settingsObj']->addSysAdminDefaults(Array(
|
||||||
'zarafa' => Array(
|
'zarafa' => Array(
|
||||||
'v1' => Array(
|
'v1' => Array(
|
||||||
'plugins' => Array(
|
'plugins' => Array(
|
||||||
'contactimporter' => Array(
|
'contactimporter' => Array(
|
||||||
'enable' => PLUGIN_CONTACTIMPORTER_USER_DEFAULT_ENABLE,
|
'enable' => PLUGIN_CONTACTIMPORTER_USER_DEFAULT_ENABLE,
|
||||||
'enable_export' => PLUGIN_CONTACTIMPORTER_USER_DEFAULT_ENABLE_EXPORT,
|
'default_addressbook' => PLUGIN_CONTACTIMPORTER_DEFAULT
|
||||||
'default_addressbook' => PLUGIN_CONTACTIMPORTER_DEFAULT
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -85,4 +90,5 @@ class Plugincontactimporter extends Plugin {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
* upload.php, zarafa contact to vcf im/exporter
|
* upload.php, zarafa contact to vcf im/exporter
|
||||||
*
|
*
|
||||||
* Author: Christoph Haas <christoph.h@sprinternet.at>
|
* Author: Christoph Haas <christoph.h@sprinternet.at>
|
||||||
* Copyright (C) 2012-2013 Christoph Haas
|
* Copyright (C) 2012-2016 Christoph Haas
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
@ -20,17 +20,18 @@
|
|||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once("../config.php");
|
require_once("../config.php");
|
||||||
|
|
||||||
/* disable error printing - otherwise json communication might break... */
|
/* disable error printing - otherwise json communication might break... */
|
||||||
ini_set('display_errors', '0');
|
ini_set('display_errors', '0');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* respond/echo JSON
|
* respond/echo JSON
|
||||||
* @param $arr
|
* @param $arr
|
||||||
*/
|
*/
|
||||||
function respondJSON($arr) {
|
function respondJSON($arr)
|
||||||
|
{
|
||||||
echo json_encode($arr);
|
echo json_encode($arr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,11 +40,12 @@ function respondJSON($arr) {
|
|||||||
* @param $length the lenght of the generated string
|
* @param $length the lenght of the generated string
|
||||||
* @return string a random string
|
* @return string a random string
|
||||||
*/
|
*/
|
||||||
function randomstring($length = 6) {
|
function randomstring($length = 6)
|
||||||
|
{
|
||||||
// $chars - all allowed charakters
|
// $chars - all allowed charakters
|
||||||
$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
|
$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
|
||||||
|
|
||||||
srand((double)microtime()*1000000);
|
srand((double)microtime() * 1000000);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
$pass = "";
|
$pass = "";
|
||||||
while ($i < $length) {
|
while ($i < $length) {
|
||||||
@ -58,15 +60,15 @@ function randomstring($length = 6) {
|
|||||||
$destpath = PLUGIN_CONTACTIMPORTER_TMP_UPLOAD;
|
$destpath = PLUGIN_CONTACTIMPORTER_TMP_UPLOAD;
|
||||||
$destpath .= $_FILES['vcfdata']['name'] . randomstring();
|
$destpath .= $_FILES['vcfdata']['name'] . randomstring();
|
||||||
|
|
||||||
if(is_readable ($_FILES['vcfdata']['tmp_name'])) {
|
if (is_readable($_FILES['vcfdata']['tmp_name'])) {
|
||||||
$result = move_uploaded_file($_FILES['vcfdata']['tmp_name'],$destpath);
|
$result = move_uploaded_file($_FILES['vcfdata']['tmp_name'], $destpath);
|
||||||
|
|
||||||
if($result) {
|
if ($result) {
|
||||||
respondJSON(array ('success'=>true, 'vcf_file'=>$destpath));
|
respondJSON(array('success' => true, 'vcf_file' => $destpath));
|
||||||
} else {
|
} else {
|
||||||
respondJSON(array ('success'=>false,'error'=>"File could not be moved to TMP path! Check plugin config and folder permissions!"));
|
respondJSON(array('success' => false, 'error' => "File could not be moved to TMP path! Check plugin config and folder permissions!"));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
respondJSON(array ('success'=>false,'error'=>"File could not be read by server, upload error!"));
|
respondJSON(array('success' => false, 'error' => "File could not be read by server, upload error!"));
|
||||||
}
|
}
|
||||||
?>
|
?>
|
@ -1,12 +1,12 @@
|
|||||||
.icon_contactimporter_button {
|
.icon_contactimporter_button {
|
||||||
background: url(../images/import_icon.png) no-repeat !important;
|
background: url(../images/import_icon.png) no-repeat !important;
|
||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
background-position: center;
|
background-position: center;
|
||||||
background-size: 18px!important;
|
background-size: 18px !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.icon_contactimporter_export {
|
.icon_contactimporter_export {
|
||||||
background: url(../images/download.png) no-repeat;
|
background: url(../images/download.png) no-repeat;
|
||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
background-position: center;
|
background-position: center;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user