Code comments

This commit is contained in:
Christoph Haas 2016-06-19 00:16:25 +02:00
parent e0eb5cf1f0
commit 5c98fe9e56
7 changed files with 139 additions and 44 deletions

View File

@ -2,7 +2,7 @@
* ABOUT.js zarafa contact to vcf im/exporter * ABOUT.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

View File

@ -29,7 +29,7 @@ Ext.namespace("Zarafa.plugins.contactimporter.dialogs");
/** /**
* @class Zarafa.plugins.contactimporter.dialogs.ImportPanel * @class Zarafa.plugins.contactimporter.dialogs.ImportPanel
* @extends Ext.form.FormPanel * @extends Ext.Panel
*/ */
Zarafa.plugins.contactimporter.dialogs.ImportPanel = Ext.extend(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) { getAllContactFolders: function (asDropdownStore) {
asDropdownStore = Ext.isEmpty(asDropdownStore) ? false : 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) { dynamicSort: function (property) {
var sortOrder = 1; var sortOrder = 1;
if (property[0] === "-") { 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) { getContactFolderByName: function (name) {
var folders = this.getAllContactFolders(false); 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 () { createSelectBox: function () {
var myStore = this.getAllContactFolders(true); 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 () { createUploadField: function () {
return { return {
xtype : "fileuploadfield", xtype : "fileuploadfield",
@ -318,6 +341,10 @@ Zarafa.plugins.contactimporter.dialogs.ImportPanel = Ext.extend(Ext.Panel, {
} }
}, },
/**
* Generate the UI submit button.
* @returns {*}
*/
createSubmitButton: function () { createSubmitButton: function () {
return { return {
xtype : "button", xtype : "button",
@ -333,6 +360,10 @@ Zarafa.plugins.contactimporter.dialogs.ImportPanel = Ext.extend(Ext.Panel, {
} }
}, },
/**
* Generate the UI submit all button.
* @returns {*}
*/
createSubmitAllButton: function () { createSubmitAllButton: function () {
return { return {
xtype : "button", xtype : "button",
@ -348,6 +379,10 @@ Zarafa.plugins.contactimporter.dialogs.ImportPanel = Ext.extend(Ext.Panel, {
} }
}, },
/**
* Generate the UI cancel button.
* @returns {*}
*/
createCancelButton: function () { createCancelButton: function () {
return { return {
xtype : "button", 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) { parseContacts: function (vcfPath) {
this.loadMask.show(); 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) { handleParsingResult: function (response) {
this.loadMask.hide(); this.loadMask.hide();
@ -432,16 +475,25 @@ Zarafa.plugins.contactimporter.dialogs.ImportPanel = Ext.extend(Ext.Panel, {
} }
}, },
/**
* Close the UI dialog.
*/
close: function () { close: function () {
this.addContactFormPanel.getForm().reset(); this.addContactFormPanel.getForm().reset();
this.dialog.close() this.dialog.close()
}, },
/**
* Create a request to import all selected contacts.
*/
importCheckedContacts: function () { importCheckedContacts: function () {
var newRecords = this.contactGrid.selModel.getSelections(); var newRecords = this.contactGrid.selModel.getSelections();
this.importContacts(newRecords); this.importContacts(newRecords);
}, },
/**
* Check all contacts and import them.
*/
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
@ -450,8 +502,8 @@ Zarafa.plugins.contactimporter.dialogs.ImportPanel = Ext.extend(Ext.Panel, {
}, },
/** /**
* This function stores all given events to the appointmentstore * This function stores all given events to the contact store
* @param events * @param {array} contacts
*/ */
importContacts: function (contacts) { importContacts: function (contacts) {
//receive existing contact store //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) { importContactsDone: function (response) {
this.loadMask.hide(); this.loadMask.hide();
this.dialog.close(); this.dialog.close();

View File

@ -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) { 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!
@ -96,6 +100,10 @@ Zarafa.plugins.contactimporter.ImportPlugin = Ext.extend(Zarafa.core.Plugin, {
); );
}, },
/**
* Callback for the export request.
* @param {Object} response
*/
downloadVCF: function (response) { downloadVCF: function (response) {
if (response.status == false) { if (response.status == false) {
Zarafa.common.dialogs.MessageBox.show({ Zarafa.common.dialogs.MessageBox.show({
@ -146,6 +154,7 @@ Zarafa.plugins.contactimporter.ImportPlugin = Ext.extend(Zarafa.core.Plugin, {
/** /**
* Callback for getAttachmentFileName * Callback for getAttachmentFileName
* @param {Object} response
*/ */
gotAttachmentFileName: function (response) { gotAttachmentFileName: function (response) {
if (response.status == true) { if (response.status == true) {
@ -162,6 +171,7 @@ Zarafa.plugins.contactimporter.ImportPlugin = Ext.extend(Zarafa.core.Plugin, {
/** /**
* Clickhandler for the button * Clickhandler for the button
* @param {Ext.Button} btn
*/ */
getAttachmentFileName: function (btn) { getAttachmentFileName: function (btn) {
Zarafa.common.dialogs.MessageBox.show({ Zarafa.common.dialogs.MessageBox.show({
@ -225,7 +235,6 @@ 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) {

View File

@ -11,8 +11,7 @@ Zarafa.plugins.contactimporter.ui.ContextMenu = Ext.extend(Zarafa.hierarchy.ui.C
* @constructor * @constructor
* @param {Object} config Configuration object * @param {Object} config Configuration object
*/ */
constructor : function(config) constructor: function (config) {
{
config = config || {}; config = config || {};
if (config.contextNode) { 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} * Note: All handlers are called within the scope of {@link Zarafa.plugins.contactimporter.ui.ContextMenu HierarchyContextMenu}
*/ */
createAdditionalContextMenuItems : function(config) createAdditionalContextMenuItems: function (config) {
{
return [{ return [{
xtype: 'menuseparator' 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); Zarafa.core.data.UIFactory.openLayerComponent(componentType, undefined, config);
}, },
/**
* Callback for the export request.
* @param {Object} response
*/
downloadVCF: function (response) { downloadVCF: function (response) {
if (response.status == false) { if (response.status == false) {
Zarafa.common.dialogs.MessageBox.show({ Zarafa.common.dialogs.MessageBox.show({

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* download.php, zarafa contact to vcf im/exporter * download.php, zarafa contact to vcf im/exporter
* *
@ -22,7 +23,10 @@
*/ */
class DownloadHandler class DownloadHandler
{ {
/**
* Download the given vcf file.
* @return bool
*/
public static function doDownload() public static function doDownload()
{ {
if (isset($_GET["token"])) { if (isset($_GET["token"])) {

View File

@ -29,7 +29,7 @@ use JeroenDesloovere\VCard\VCardParser;
class ContactModule extends Module class ContactModule extends Module
{ {
private $DEBUG = true; // enable error_log debugging private $DEBUG = false; // enable error_log debugging
/** /**
* @constructor * @constructor
@ -249,6 +249,12 @@ class ContactModule extends Module
$GLOBALS["bus"]->addData($this->getResponseData()); $GLOBALS["bus"]->addData($this->getResponseData());
} }
/**
* Get a property from the array.
* @param $props
* @param $propname
* @return string
*/
private function getProp($props, $propname) private function getProp($props, $propname)
{ {
$p = $this->getProperties(); $p = $this->getProperties();
@ -258,6 +264,12 @@ class ContactModule extends Module
return ""; return "";
} }
/**
* Export selected contacts to vCard.
* @param $actionType
* @param $actionData
* @return bool
*/
private function exportContacts($actionType, $actionData) private function exportContacts($actionType, $actionData)
{ {
// Get store id // 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) private function replaceStringPropertyTags($store, $properties)
{ {
$newProperties = array(); $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) private function startswith($haystack, $needle)
{ {
$haystack = str_replace("type=", "", $haystack); // remove type from string $haystack = str_replace("type=", "", $haystack); // remove type from string