From 5c98fe9e56c2581b7012931edb347fb5edf8edb9 Mon Sep 17 00:00:00 2001 From: Christoph Haas Date: Sun, 19 Jun 2016 00:16:25 +0200 Subject: [PATCH] Code comments --- js/ABOUT.js | 2 +- js/dialogs/ImportContentPanel.js | 2 +- js/dialogs/ImportPanel.js | 94 +++++++++++++++++++++++++------- js/plugin.contactimporter.js | 15 ++++- js/ui/ContextMenu.js | 34 ++++++------ php/download.php | 6 +- php/module.contact.php | 30 +++++++++- 7 files changed, 139 insertions(+), 44 deletions(-) diff --git a/js/ABOUT.js b/js/ABOUT.js index 0c2f1ec..0ab467c 100644 --- a/js/ABOUT.js +++ b/js/ABOUT.js @@ -2,7 +2,7 @@ * ABOUT.js zarafa contact to vcf im/exporter * * Author: Christoph Haas - * 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 diff --git a/js/dialogs/ImportContentPanel.js b/js/dialogs/ImportContentPanel.js index 973be71..1270c32 100644 --- a/js/dialogs/ImportContentPanel.js +++ b/js/dialogs/ImportContentPanel.js @@ -54,7 +54,7 @@ Zarafa.plugins.contactimporter.dialogs.ImportContentPanel = Ext.extend(Zarafa.co { xtype : 'contactimporter.importcontactpanel', filename: config.filename, - folder: config.folder + folder : config.folder } ] }); diff --git a/js/dialogs/ImportPanel.js b/js/dialogs/ImportPanel.js index c8083a2..44db08d 100644 --- a/js/dialogs/ImportPanel.js +++ b/js/dialogs/ImportPanel.js @@ -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,7 +132,12 @@ Zarafa.plugins.contactimporter.dialogs.ImportPanel = Ext.extend(Ext.Panel, { }; }, - getAllContactFolders: function(asDropdownStore) { + /** + * 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; var allFolders = []; @@ -142,11 +147,11 @@ Zarafa.plugins.contactimporter.dialogs.ImportPanel = Ext.extend(Ext.Panel, { var inbox = container.getHierarchyStore().getDefaultStore(); var pub = container.getHierarchyStore().getPublicStore(); - if(!Ext.isEmpty(inbox.subStores) && inbox.subStores.folders.totalLength > 0) { - for(var i=0; i < inbox.subStores.folders.totalLength; i++) { + if (!Ext.isEmpty(inbox.subStores) && inbox.subStores.folders.totalLength > 0) { + for (var i = 0; i < inbox.subStores.folders.totalLength; i++) { var folder = inbox.subStores.folders.getAt(i); - if(folder.get("container_class") == "IPF.Contact") { - if(asDropdownStore) { + if (folder.get("container_class") == "IPF.Contact") { + if (asDropdownStore) { allFolders.push([ folder.get("entryid"), folder.get("display_name") @@ -163,11 +168,11 @@ Zarafa.plugins.contactimporter.dialogs.ImportPanel = Ext.extend(Ext.Panel, { } } - if(!Ext.isEmpty(pub.subStores) && pub.subStores.folders.totalLength > 0) { - for(var j=0; j < pub.subStores.folders.totalLength; j++) { + if (!Ext.isEmpty(pub.subStores) && pub.subStores.folders.totalLength > 0) { + for (var j = 0; j < pub.subStores.folders.totalLength; j++) { var folder = pub.subStores.folders.getAt(j); - if(folder.get("container_class") == "IPF.Contact") { - if(asDropdownStore) { + if (folder.get("container_class") == "IPF.Contact") { + if (asDropdownStore) { allFolders.push([ folder.get("entryid"), folder.get("display_name") + " (Public)" @@ -184,30 +189,40 @@ Zarafa.plugins.contactimporter.dialogs.ImportPanel = Ext.extend(Ext.Panel, { } } - if(asDropdownStore) { + if (asDropdownStore) { return allFolders.sort(this.dynamicSort(1)); } else { return allFolders; } }, - dynamicSort: function(property) { + /** + * Dynamic sort function, sorts by property name. + * @param {string|int} property + * @returns {Function} + */ + dynamicSort: function (property) { var sortOrder = 1; - if(property[0] === "-") { + if (property[0] === "-") { sortOrder = -1; property = property.substr(1); } - return function (a,b) { + return function (a, b) { var result = (a[property].toLowerCase() < b[property].toLowerCase()) ? -1 : (a[property].toLowerCase() > b[property].toLowerCase()) ? 1 : 0; return result * sortOrder; } }, - getContactFolderByName: function(name) { + /** + * Return a contact folder element by name. + * @param {string} name + * @returns {*} + */ + getContactFolderByName: function (name) { var folders = this.getAllContactFolders(false); - for(var i=0; iaddData($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 @@ -290,7 +302,7 @@ class ContactModule extends Module $store = $GLOBALS["mapisession"]->openMessageStore(hex2bin($storeid)); if ($store) { // load folder first - if($folder !== false) { + if ($folder !== false) { $mapifolder = mapi_msgstore_openentry($store, hex2bin($folder)); $table = mapi_folder_getcontentstable($mapifolder); @@ -429,7 +441,7 @@ class ContactModule extends Module return false; } - if(count($records) > 0) { + if (count($records) > 0) { $response['status'] = true; $response['download_token'] = $token; $response['filename'] = count($records) . "contacts.vcf"; @@ -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