code beautifications
This commit is contained in:
parent
21af50aa6c
commit
4ce04ab6f9
@ -1,8 +1,6 @@
|
||||
<?php
|
||||
/** Disable the import plugin for all clients */
|
||||
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");
|
||||
|
@ -29,7 +29,7 @@ Ext.namespace('Zarafa.plugins.contactimporter');
|
||||
* The copyright string holding the copyright notice for the Zarafa contactimporter Plugin.
|
||||
*/
|
||||
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 "
|
||||
+ "modify it under the terms of the GNU Lesser General Public "
|
||||
@ -51,7 +51,7 @@ Zarafa.plugins.contactimporter.ABOUT = ""
|
||||
|
||||
+ "<h1>vCard-parser</h1>"
|
||||
|
||||
+ "<p>Copyright (C) 2012 Nuovo</p>"
|
||||
+ "<p>Copyright (C) 2016 Jeroen Desloovere</p>"
|
||||
|
||||
+ "<p>Licensed under the MIT License.</p>"
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
* ResponseHandler.js zarafa contact 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
|
||||
|
@ -2,7 +2,7 @@
|
||||
* ImportContentPanel.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
|
||||
@ -43,9 +43,6 @@ Zarafa.plugins.contactimporter.dialogs.ImportContentPanel = Ext.extend(Zarafa.co
|
||||
constructor: function (config) {
|
||||
config = config || {};
|
||||
var title = _('Import Contacts');
|
||||
if(container.getSettingsModel().get("zarafa/v1/plugins/contactimporter/enable_export")){
|
||||
title = _('Import/Export Contacts');
|
||||
}
|
||||
Ext.applyIf(config, {
|
||||
layout : 'fit',
|
||||
title : title,
|
||||
|
@ -2,7 +2,7 @@
|
||||
* ImportPanel.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
|
||||
|
@ -2,7 +2,7 @@
|
||||
* plugin.contactimporter.js zarafa contactimporter
|
||||
*
|
||||
* 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
|
||||
@ -46,7 +46,7 @@ Zarafa.plugins.contactimporter.ImportPlugin = Ext.extend(Zarafa.core.Plugin, {
|
||||
Zarafa.core.data.SharedComponentType.addProperty('plugins.contactimporter.dialogs.importcontacts');
|
||||
|
||||
/* 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 */
|
||||
this.registerInsertionPoint("navigation.south", this.createImportButton, this);
|
||||
@ -71,10 +71,6 @@ Zarafa.plugins.contactimporter.ImportPlugin = Ext.extend(Zarafa.core.Plugin, {
|
||||
scope : this
|
||||
};
|
||||
|
||||
if(container.getSettingsModel().get("zarafa/v1/plugins/contactimporter/enable_export")) {
|
||||
button.text = _('Import/Export Contacts');
|
||||
}
|
||||
|
||||
return button;
|
||||
},
|
||||
|
||||
@ -212,10 +208,11 @@ Zarafa.plugins.contactimporter.ImportPlugin = Ext.extend(Zarafa.core.Plugin, {
|
||||
var store = attachmentStore.getParentRecord().get('store_entryid');
|
||||
var entryid = attachmentStore.getAttachmentParentRecordEntryId();
|
||||
var attachNum = new Array(1);
|
||||
if (attachmentRecord.get('attach_num') != -1)
|
||||
if (attachmentRecord.get('attach_num') != -1) {
|
||||
attachNum[0] = attachmentRecord.get('attach_num');
|
||||
else
|
||||
} else {
|
||||
attachNum[0] = attachmentRecord.get('tmpname');
|
||||
}
|
||||
var dialog_attachments = attachmentStore.getId();
|
||||
var filename = attachmentRecord.data.name;
|
||||
|
||||
|
@ -1,9 +1,30 @@
|
||||
<?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
|
||||
{
|
||||
|
||||
public static function doDownload() {
|
||||
public static function doDownload()
|
||||
{
|
||||
if (isset($_GET["token"])) {
|
||||
$token = $_GET["token"];
|
||||
} else {
|
||||
|
@ -3,7 +3,7 @@
|
||||
* class.calendar.php, 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
|
||||
@ -26,7 +26,8 @@ include_once('vendor/autoload.php');
|
||||
use JeroenDesloovere\VCard\VCard;
|
||||
use JeroenDesloovere\VCard\VCardParser;
|
||||
|
||||
class ContactModule extends Module {
|
||||
class ContactModule extends Module
|
||||
{
|
||||
|
||||
private $DEBUG = true; // enable error_log debugging
|
||||
|
||||
@ -35,7 +36,8 @@ class ContactModule extends Module {
|
||||
* @param $id
|
||||
* @param $data
|
||||
*/
|
||||
public function __construct($id, $data) {
|
||||
public function __construct($id, $data)
|
||||
{
|
||||
parent::Module($id, $data);
|
||||
}
|
||||
|
||||
@ -44,7 +46,8 @@ class ContactModule extends Module {
|
||||
* Exception part is used for authentication errors also
|
||||
* @return boolean true on success or false on failure.
|
||||
*/
|
||||
public function execute() {
|
||||
public function execute()
|
||||
{
|
||||
$result = false;
|
||||
|
||||
if (!$this->DEBUG) {
|
||||
@ -95,7 +98,8 @@ class ContactModule extends Module {
|
||||
* @param $length the lenght of the generated string
|
||||
* @return string a random string
|
||||
*/
|
||||
private function randomstring($length = 6) {
|
||||
private function randomstring($length = 6)
|
||||
{
|
||||
// $chars - all allowed charakters
|
||||
$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
|
||||
|
||||
@ -116,7 +120,8 @@ class ContactModule extends Module {
|
||||
* @param $actionType
|
||||
* @param $actionData
|
||||
*/
|
||||
private function importContacts($actionType, $actionData) {
|
||||
private function importContacts($actionType, $actionData)
|
||||
{
|
||||
|
||||
// Get uploaded vcf path
|
||||
$vcffile = false;
|
||||
@ -244,7 +249,8 @@ class ContactModule extends Module {
|
||||
$GLOBALS["bus"]->addData($this->getResponseData());
|
||||
}
|
||||
|
||||
private function getProp($props, $propname) {
|
||||
private function getProp($props, $propname)
|
||||
{
|
||||
$p = $this->getProperties();
|
||||
if (isset($props["props"][$propname])) {
|
||||
return $props["props"][$propname];
|
||||
@ -435,7 +441,8 @@ class ContactModule extends Module {
|
||||
* @param MAPIAttach $attachment attachment which will be dumped to client side
|
||||
* @return Response response to sent to client including attachment data
|
||||
*/
|
||||
private function storeSavedAttachment($temppath, $attachment) {
|
||||
private function storeSavedAttachment($temppath, $attachment)
|
||||
{
|
||||
// Check if the attachment is opened
|
||||
if ($attachment) {
|
||||
// Open a stream to get the attachment data
|
||||
@ -452,7 +459,8 @@ class ContactModule extends Module {
|
||||
}
|
||||
}
|
||||
|
||||
private function replaceStringPropertyTags($store, $properties) {
|
||||
private function replaceStringPropertyTags($store, $properties)
|
||||
{
|
||||
$newProperties = array();
|
||||
|
||||
$ids = array("name" => array(), "id" => array(), "guid" => array(), "type" => array()); // this array stores all the information needed to retrieve a named property
|
||||
@ -516,7 +524,8 @@ class ContactModule extends Module {
|
||||
*
|
||||
* @return [array] the propertyarray
|
||||
*/
|
||||
private function getProperties() {
|
||||
private function getProperties()
|
||||
{
|
||||
$properties = array();
|
||||
|
||||
$properties["subject"] = PR_SUBJECT;
|
||||
@ -655,7 +664,8 @@ class ContactModule extends Module {
|
||||
* @param $actionType
|
||||
* @param $actionData
|
||||
*/
|
||||
private function loadContacts($actionType, $actionData) {
|
||||
private function loadContacts($actionType, $actionData)
|
||||
{
|
||||
$error = false;
|
||||
$error_msg = "";
|
||||
|
||||
@ -704,7 +714,8 @@ class ContactModule extends Module {
|
||||
* @return array parsed contacts
|
||||
* @private
|
||||
*/
|
||||
private function parseContactsToArray($contacts, $csv = false) {
|
||||
private function parseContactsToArray($contacts, $csv = false)
|
||||
{
|
||||
$carr = array();
|
||||
|
||||
if (!$csv) {
|
||||
@ -734,23 +745,37 @@ class ContactModule extends Module {
|
||||
$number = $number[0]; // we only can store one number
|
||||
if ($this->startswith(strtolower($type), "home") || strtolower($type) === "default") {
|
||||
$properties["home_telephone_number"] = $number;
|
||||
} else if($this->startswith(strtolower($type), "cell")) {
|
||||
} else {
|
||||
if ($this->startswith(strtolower($type), "cell")) {
|
||||
$properties["cellular_telephone_number"] = $number;
|
||||
} else if($this->startswith(strtolower($type), "work")) {
|
||||
} else {
|
||||
if ($this->startswith(strtolower($type), "work")) {
|
||||
$properties["business_telephone_number"] = $number;
|
||||
} else if($this->startswith(strtolower($type), "fax")) {
|
||||
} else {
|
||||
if ($this->startswith(strtolower($type), "fax")) {
|
||||
$properties["business_fax_number"] = $number;
|
||||
} else if($this->startswith(strtolower($type), "pager")) {
|
||||
} else {
|
||||
if ($this->startswith(strtolower($type), "pager")) {
|
||||
$properties["pager_telephone_number"] = $number;
|
||||
} else if($this->startswith(strtolower($type), "isdn")) {
|
||||
} else {
|
||||
if ($this->startswith(strtolower($type), "isdn")) {
|
||||
$properties["isdn_number"] = $number;
|
||||
} else if($this->startswith(strtolower($type), "car")) {
|
||||
} else {
|
||||
if ($this->startswith(strtolower($type), "car")) {
|
||||
$properties["car_telephone_number"] = $number;
|
||||
} else if($this->startswith(strtolower($type), "modem")) {
|
||||
} else {
|
||||
if ($this->startswith(strtolower($type), "modem")) {
|
||||
$properties["ttytdd_telephone_number"] = $number;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($vCard->email) && count($vCard->email) > 0) {
|
||||
$emailcount = 0;
|
||||
$properties["address_book_long"] = 0;
|
||||
@ -835,7 +860,8 @@ class ContactModule extends Module {
|
||||
$properties["business_address_postal_code"] = $address->zip;
|
||||
$properties["business_address_country"] = $address->country;
|
||||
$properties["business_address"] = $this->buildAddressString($properties["business_address_street"], $address->zip, $address->city, $address->region, $address->country);
|
||||
} else if($this->startswith(strtolower($type), "home")) {
|
||||
} else {
|
||||
if ($this->startswith(strtolower($type), "home")) {
|
||||
$properties["home_address_street"] = $address->street;
|
||||
if (!empty($address->extended)) {
|
||||
$properties["home_address_street"] .= "\n" . $address->extended;
|
||||
@ -858,6 +884,7 @@ class ContactModule extends Module {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($vCard->birthday)) {
|
||||
$properties["birthday"] = $vCard->birthday->getTimestamp();
|
||||
}
|
||||
@ -910,18 +937,31 @@ class ContactModule extends Module {
|
||||
* @return string the concatinated address string
|
||||
* @private
|
||||
*/
|
||||
private function buildAddressString($street, $zip, $city, $state, $country) {
|
||||
private function buildAddressString($street, $zip, $city, $state, $country)
|
||||
{
|
||||
$out = "";
|
||||
|
||||
if (isset($country) && $street != "") $out = $country;
|
||||
if (isset($country) && $street != "") {
|
||||
$out = $country;
|
||||
}
|
||||
|
||||
$zcs = "";
|
||||
if (isset($zip) && $zip != "") $zcs = $zip;
|
||||
if (isset($city) && $city != "") $zcs .= (($zcs)?" ":"") . $city;
|
||||
if (isset($state) && $state != "") $zcs .= (($zcs)?" ":"") . $state;
|
||||
if ($zcs) $out = $zcs . "\n" . $out;
|
||||
if (isset($zip) && $zip != "") {
|
||||
$zcs = $zip;
|
||||
}
|
||||
if (isset($city) && $city != "") {
|
||||
$zcs .= (($zcs) ? " " : "") . $city;
|
||||
}
|
||||
if (isset($state) && $state != "") {
|
||||
$zcs .= (($zcs) ? " " : "") . $state;
|
||||
}
|
||||
if ($zcs) {
|
||||
$out = $zcs . "\n" . $out;
|
||||
}
|
||||
|
||||
if (isset($street) && $street != "") $out = $street . (($out)?"\n\n". $out: "") ;
|
||||
if (isset($street) && $street != "") {
|
||||
$out = $street . (($out) ? "\n\n" . $out : "");
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
@ -932,7 +972,8 @@ class ContactModule extends Module {
|
||||
* @param $actionData
|
||||
* @private
|
||||
*/
|
||||
private function getAttachmentPath($actionType, $actionData) {
|
||||
private function getAttachmentPath($actionType, $actionData)
|
||||
{
|
||||
// Get store id
|
||||
$storeid = false;
|
||||
if (isset($actionData["store"])) {
|
||||
@ -969,8 +1010,7 @@ class ContactModule extends Module {
|
||||
// Check if attachNum isset
|
||||
if ($attachNum) {
|
||||
// Loop through the attachNums, message in message in message ...
|
||||
for($i = 0; $i < (count($attachNum) - 1); $i++)
|
||||
{
|
||||
for ($i = 0; $i < (count($attachNum) - 1); $i++) {
|
||||
// Open the attachment
|
||||
$tempattach = mapi_message_openattach($message, (int)$attachNum[$i]);
|
||||
if ($tempattach) {
|
||||
@ -996,11 +1036,15 @@ class ContactModule extends Module {
|
||||
// Set filename
|
||||
if (isset($props[PR_ATTACH_LONG_FILENAME])) {
|
||||
$filename = $props[PR_ATTACH_LONG_FILENAME];
|
||||
} else if(isset($props[PR_ATTACH_FILENAME])) {
|
||||
} else {
|
||||
if (isset($props[PR_ATTACH_FILENAME])) {
|
||||
$filename = $props[PR_ATTACH_FILENAME];
|
||||
} else if(isset($props[PR_DISPLAY_NAME])) {
|
||||
} else {
|
||||
if (isset($props[PR_DISPLAY_NAME])) {
|
||||
$filename = $props[PR_DISPLAY_NAME];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set content type
|
||||
if (isset($props[PR_ATTACH_MIME_TAG])) {
|
||||
@ -1065,10 +1109,13 @@ class ContactModule extends Module {
|
||||
}
|
||||
}
|
||||
|
||||
private function startswith($haystack, $needle) {
|
||||
private function startswith($haystack, $needle)
|
||||
{
|
||||
$haystack = str_replace("type=", "", $haystack); // remove type from string
|
||||
return substr($haystack, 0, strlen($needle)) === $needle;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
?>
|
||||
|
@ -3,7 +3,7 @@
|
||||
* plugin.contactimporter.php, 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
|
||||
@ -28,18 +28,22 @@ require_once __DIR__ . "/download.php";
|
||||
* With this plugin you can import a vcf file to your zarafa addressbook
|
||||
*
|
||||
*/
|
||||
class Plugincontactimporter extends Plugin {
|
||||
class Plugincontactimporter extends Plugin
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
function Plugincontactimporter() {}
|
||||
function Plugincontactimporter()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Function initializes the Plugin and registers all hooks
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function init() {
|
||||
function init()
|
||||
{
|
||||
$this->registerHook('server.core.settings.init.before');
|
||||
$this->registerHook('server.index.load.custom');
|
||||
}
|
||||
@ -51,7 +55,8 @@ class Plugincontactimporter extends Plugin {
|
||||
* @param mixed $data object(s) related to the hook
|
||||
* @return void
|
||||
*/
|
||||
function execute($eventID, &$data) {
|
||||
function execute($eventID, &$data)
|
||||
{
|
||||
switch ($eventID) {
|
||||
case 'server.core.settings.init.before' :
|
||||
$this->injectPluginSettings($data);
|
||||
@ -69,14 +74,14 @@ class Plugincontactimporter extends Plugin {
|
||||
* settings.
|
||||
* @param Array $data Reference to the data of the triggered hook
|
||||
*/
|
||||
function injectPluginSettings(&$data) {
|
||||
function injectPluginSettings(&$data)
|
||||
{
|
||||
$data['settingsObj']->addSysAdminDefaults(Array(
|
||||
'zarafa' => Array(
|
||||
'v1' => Array(
|
||||
'plugins' => Array(
|
||||
'contactimporter' => Array(
|
||||
'enable' => PLUGIN_CONTACTIMPORTER_USER_DEFAULT_ENABLE,
|
||||
'enable_export' => PLUGIN_CONTACTIMPORTER_USER_DEFAULT_ENABLE_EXPORT,
|
||||
'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
|
||||
*
|
||||
* 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
|
||||
@ -30,7 +30,8 @@ ini_set('display_errors', '0');
|
||||
* respond/echo JSON
|
||||
* @param $arr
|
||||
*/
|
||||
function respondJSON($arr) {
|
||||
function respondJSON($arr)
|
||||
{
|
||||
echo json_encode($arr);
|
||||
}
|
||||
|
||||
@ -39,7 +40,8 @@ function respondJSON($arr) {
|
||||
* @param $length the lenght of the generated string
|
||||
* @return string a random string
|
||||
*/
|
||||
function randomstring($length = 6) {
|
||||
function randomstring($length = 6)
|
||||
{
|
||||
// $chars - all allowed charakters
|
||||
$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user