Code comments
This commit is contained in:
parent
e0eb5cf1f0
commit
5c98fe9e56
@ -2,7 +2,7 @@
|
||||
* ABOUT.js zarafa contact to vcf im/exporter
|
||||
*
|
||||
* 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
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -29,7 +29,7 @@ Ext.namespace("Zarafa.plugins.contactimporter.dialogs");
|
||||
|
||||
/**
|
||||
* @class Zarafa.plugins.contactimporter.dialogs.ImportPanel
|
||||
* @extends Ext.form.FormPanel
|
||||
* @extends Ext.Panel
|
||||
*/
|
||||
Zarafa.plugins.contactimporter.dialogs.ImportPanel = Ext.extend(Ext.Panel, {
|
||||
|
||||
@ -132,6 +132,11 @@ Zarafa.plugins.contactimporter.dialogs.ImportPanel = Ext.extend(Ext.Panel, {
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Get all contact folders.
|
||||
* @param {boolean} asDropdownStore If true, a simple array store will be returned.
|
||||
* @returns {*}
|
||||
*/
|
||||
getAllContactFolders: function (asDropdownStore) {
|
||||
asDropdownStore = Ext.isEmpty(asDropdownStore) ? false : asDropdownStore;
|
||||
|
||||
@ -191,6 +196,11 @@ Zarafa.plugins.contactimporter.dialogs.ImportPanel = Ext.extend(Ext.Panel, {
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Dynamic sort function, sorts by property name.
|
||||
* @param {string|int} property
|
||||
* @returns {Function}
|
||||
*/
|
||||
dynamicSort: function (property) {
|
||||
var sortOrder = 1;
|
||||
if (property[0] === "-") {
|
||||
@ -203,6 +213,11 @@ Zarafa.plugins.contactimporter.dialogs.ImportPanel = Ext.extend(Ext.Panel, {
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Return a contact folder element by name.
|
||||
* @param {string} name
|
||||
* @returns {*}
|
||||
*/
|
||||
getContactFolderByName: function (name) {
|
||||
var folders = this.getAllContactFolders(false);
|
||||
|
||||
@ -276,6 +291,10 @@ Zarafa.plugins.contactimporter.dialogs.ImportPanel = Ext.extend(Ext.Panel, {
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Generate the UI calendar select box.
|
||||
* @returns {*}
|
||||
*/
|
||||
createSelectBox: function () {
|
||||
var myStore = this.getAllContactFolders(true);
|
||||
|
||||
@ -298,6 +317,10 @@ Zarafa.plugins.contactimporter.dialogs.ImportPanel = Ext.extend(Ext.Panel, {
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Generate the UI upload field.
|
||||
* @returns {*}
|
||||
*/
|
||||
createUploadField: function () {
|
||||
return {
|
||||
xtype : "fileuploadfield",
|
||||
@ -318,6 +341,10 @@ Zarafa.plugins.contactimporter.dialogs.ImportPanel = Ext.extend(Ext.Panel, {
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Generate the UI submit button.
|
||||
* @returns {*}
|
||||
*/
|
||||
createSubmitButton: function () {
|
||||
return {
|
||||
xtype : "button",
|
||||
@ -333,6 +360,10 @@ Zarafa.plugins.contactimporter.dialogs.ImportPanel = Ext.extend(Ext.Panel, {
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Generate the UI submit all button.
|
||||
* @returns {*}
|
||||
*/
|
||||
createSubmitAllButton: function () {
|
||||
return {
|
||||
xtype : "button",
|
||||
@ -348,6 +379,10 @@ Zarafa.plugins.contactimporter.dialogs.ImportPanel = Ext.extend(Ext.Panel, {
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Generate the UI cancel button.
|
||||
* @returns {*}
|
||||
*/
|
||||
createCancelButton: function () {
|
||||
return {
|
||||
xtype : "button",
|
||||
@ -394,6 +429,10 @@ Zarafa.plugins.contactimporter.dialogs.ImportPanel = Ext.extend(Ext.Panel, {
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Start request to server to parse the given vCard file.
|
||||
* @param {string} vcfPath
|
||||
*/
|
||||
parseContacts: function (vcfPath) {
|
||||
this.loadMask.show();
|
||||
|
||||
@ -412,6 +451,10 @@ Zarafa.plugins.contactimporter.dialogs.ImportPanel = Ext.extend(Ext.Panel, {
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* Callback for the parsing request.
|
||||
* @param {Object} response
|
||||
*/
|
||||
handleParsingResult: function (response) {
|
||||
this.loadMask.hide();
|
||||
|
||||
@ -432,16 +475,25 @@ Zarafa.plugins.contactimporter.dialogs.ImportPanel = Ext.extend(Ext.Panel, {
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Close the UI dialog.
|
||||
*/
|
||||
close: function () {
|
||||
this.addContactFormPanel.getForm().reset();
|
||||
this.dialog.close()
|
||||
},
|
||||
|
||||
/**
|
||||
* Create a request to import all selected contacts.
|
||||
*/
|
||||
importCheckedContacts: function () {
|
||||
var newRecords = this.contactGrid.selModel.getSelections();
|
||||
this.importContacts(newRecords);
|
||||
},
|
||||
|
||||
/**
|
||||
* Check all contacts and import them.
|
||||
*/
|
||||
importAllContacts: function () {
|
||||
//receive Records from grid rows
|
||||
this.contactGrid.selModel.selectAll(); // select all entries
|
||||
@ -450,8 +502,8 @@ Zarafa.plugins.contactimporter.dialogs.ImportPanel = Ext.extend(Ext.Panel, {
|
||||
},
|
||||
|
||||
/**
|
||||
* This function stores all given events to the appointmentstore
|
||||
* @param events
|
||||
* This function stores all given events to the contact store
|
||||
* @param {array} contacts
|
||||
*/
|
||||
importContacts: function (contacts) {
|
||||
//receive existing contact store
|
||||
@ -540,6 +592,10 @@ Zarafa.plugins.contactimporter.dialogs.ImportPanel = Ext.extend(Ext.Panel, {
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Callback for the import request.
|
||||
* @param {Object} response
|
||||
*/
|
||||
importContactsDone: function (response) {
|
||||
this.loadMask.hide();
|
||||
this.dialog.close();
|
||||
|
@ -68,6 +68,10 @@ Zarafa.plugins.contactimporter.ImportPlugin = Ext.extend(Zarafa.core.Plugin, {
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* 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!
|
||||
@ -96,6 +100,10 @@ Zarafa.plugins.contactimporter.ImportPlugin = Ext.extend(Zarafa.core.Plugin, {
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* Callback for the export request.
|
||||
* @param {Object} response
|
||||
*/
|
||||
downloadVCF: function (response) {
|
||||
if (response.status == false) {
|
||||
Zarafa.common.dialogs.MessageBox.show({
|
||||
@ -146,6 +154,7 @@ Zarafa.plugins.contactimporter.ImportPlugin = Ext.extend(Zarafa.core.Plugin, {
|
||||
|
||||
/**
|
||||
* Callback for getAttachmentFileName
|
||||
* @param {Object} response
|
||||
*/
|
||||
gotAttachmentFileName: function (response) {
|
||||
if (response.status == true) {
|
||||
@ -162,6 +171,7 @@ Zarafa.plugins.contactimporter.ImportPlugin = Ext.extend(Zarafa.core.Plugin, {
|
||||
|
||||
/**
|
||||
* Clickhandler for the button
|
||||
* @param {Ext.Button} btn
|
||||
*/
|
||||
getAttachmentFileName: function (btn) {
|
||||
Zarafa.common.dialogs.MessageBox.show({
|
||||
@ -225,7 +235,6 @@ Zarafa.plugins.contactimporter.ImportPlugin = Ext.extend(Zarafa.core.Plugin, {
|
||||
|
||||
/**
|
||||
* Open the import dialog.
|
||||
*
|
||||
* @param {String} filename
|
||||
*/
|
||||
openImportDialog: function (filename) {
|
||||
|
@ -11,8 +11,7 @@ Zarafa.plugins.contactimporter.ui.ContextMenu = Ext.extend(Zarafa.hierarchy.ui.C
|
||||
* @constructor
|
||||
* @param {Object} config Configuration object
|
||||
*/
|
||||
constructor : function(config)
|
||||
{
|
||||
constructor: function (config) {
|
||||
config = config || {};
|
||||
|
||||
if (config.contextNode) {
|
||||
@ -38,8 +37,7 @@ Zarafa.plugins.contactimporter.ui.ContextMenu = Ext.extend(Zarafa.hierarchy.ui.C
|
||||
*
|
||||
* Note: All handlers are called within the scope of {@link Zarafa.plugins.contactimporter.ui.ContextMenu HierarchyContextMenu}
|
||||
*/
|
||||
createAdditionalContextMenuItems : function(config)
|
||||
{
|
||||
createAdditionalContextMenuItems: function (config) {
|
||||
return [{
|
||||
xtype: 'menuseparator'
|
||||
}, {
|
||||
@ -105,6 +103,10 @@ Zarafa.plugins.contactimporter.ui.ContextMenu = Ext.extend(Zarafa.hierarchy.ui.C
|
||||
Zarafa.core.data.UIFactory.openLayerComponent(componentType, undefined, config);
|
||||
},
|
||||
|
||||
/**
|
||||
* Callback for the export request.
|
||||
* @param {Object} response
|
||||
*/
|
||||
downloadVCF: function (response) {
|
||||
if (response.status == false) {
|
||||
Zarafa.common.dialogs.MessageBox.show({
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* download.php, zarafa contact to vcf im/exporter
|
||||
*
|
||||
@ -22,7 +23,10 @@
|
||||
*/
|
||||
class DownloadHandler
|
||||
{
|
||||
|
||||
/**
|
||||
* Download the given vcf file.
|
||||
* @return bool
|
||||
*/
|
||||
public static function doDownload()
|
||||
{
|
||||
if (isset($_GET["token"])) {
|
||||
|
@ -29,7 +29,7 @@ use JeroenDesloovere\VCard\VCardParser;
|
||||
class ContactModule extends Module
|
||||
{
|
||||
|
||||
private $DEBUG = true; // enable error_log debugging
|
||||
private $DEBUG = false; // enable error_log debugging
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
@ -249,6 +249,12 @@ class ContactModule extends Module
|
||||
$GLOBALS["bus"]->addData($this->getResponseData());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a property from the array.
|
||||
* @param $props
|
||||
* @param $propname
|
||||
* @return string
|
||||
*/
|
||||
private function getProp($props, $propname)
|
||||
{
|
||||
$p = $this->getProperties();
|
||||
@ -258,6 +264,12 @@ class ContactModule extends Module
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Export selected contacts to vCard.
|
||||
* @param $actionType
|
||||
* @param $actionData
|
||||
* @return bool
|
||||
*/
|
||||
private function exportContacts($actionType, $actionData)
|
||||
{
|
||||
// Get store id
|
||||
@ -481,6 +493,12 @@ class ContactModule extends Module
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace String Property Tags
|
||||
* @param $store
|
||||
* @param $properties
|
||||
* @return array
|
||||
*/
|
||||
private function replaceStringPropertyTags($store, $properties)
|
||||
{
|
||||
$newProperties = array();
|
||||
@ -1131,6 +1149,12 @@ class ContactModule extends Module
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if string starts with other string.
|
||||
* @param $haystack
|
||||
* @param $needle
|
||||
* @return bool
|
||||
*/
|
||||
private function startswith($haystack, $needle)
|
||||
{
|
||||
$haystack = str_replace("type=", "", $haystack); // remove type from string
|
||||
|
Loading…
Reference in New Issue
Block a user