Commit 7b8dfb35 authored by skummer's avatar skummer

ZP-299 #comment moved imap, vcard and maildir backend into an own directory....

ZP-299 #comment moved imap, vcard and maildir backend into an own directory. Moved backend configuration options from main config.php to the backend config.php files. Implemented backend autoload (order: zarafa, combined, imap, vcard, maildir) if no backend provider is defined. Fixed warnings of combined backend (needs testing!) #time 1h 30m

git-svn-id: https://z-push.org/svn/z-push/trunk@1594 b7dd7b3b-3a3c-0410-9da9-bee62a6cc5b5
parent 7074bf15
......@@ -75,7 +75,7 @@ class BackendCombined extends Backend {
foreach ($this->config['backends'] as $i => $b){
// load and instatiate backend
ZPush::IncludeBackend($b['name']);
$this->backends[$i] = new $b['name']($b['config']);
$this->backends[$i] = new $b['name']();
}
ZLog::Write(LOGLEVEL_INFO, sprintf("Combined %d backends loaded.", count($this->backends)));
}
......
......@@ -44,47 +44,6 @@
class BackendCombinedConfig {
// *************************
// BackendZarafa settings
// *************************
public static $BackendZarafa_config = array('MAPI_SERVER' => MAPI_SERVER);
// *************************
// BackendIMAP settings
// *************************
public static $BackendIMAP_config = array(
// Defines the server to which we want to connect
'IMAP_SERVER' => IMAP_SERVER,
// connecting to default port (143)
'IMAP_PORT' => IMAP_PORT,
// best cross-platform compatibility (see http://php.net/imap_open for options)
'IMAP_OPTIONS' => IMAP_OPTIONS,
// overwrite the "from" header if it isn't set when sending emails
// options: 'username' - the username will be set (usefull if your login is equal to your emailaddress)
// 'domain' - the value of the "domain" field is used
// '@mydomain.com' - the username is used and the given string will be appended
'IMAP_DEFAULTFROM' => IMAP_DEFAULTFROM,
// copy outgoing mail to this folder. If not set z-push will try the default folders
'IMAP_SENTFOLDER' => IMAP_SENTFOLDER,
// forward messages inline (default false - as attachment)
'IMAP_INLINE_FORWARD' => IMAP_INLINE_FORWARD,
// use imap_mail() to send emails (default) - if false mail() is used
'IMAP_USE_IMAPMAIL' => IMAP_USE_IMAPMAIL,
);
// *************************
// BackendMaildir settings
// *************************
public static $BackendMaildir_config = array(
'MAILDIR_BASE' => MAILDIR_BASE,
'MAILDIR_SUBDIR' => MAILDIR_SUBDIR,
);
// *************************
// BackendVCardDir settings
// *************************
public static $BackendVCardDir_config = array('VCARDDIR_DIR' => VCARDDIR_DIR);
// *************************
// BackendCombined settings
// *************************
......@@ -105,19 +64,15 @@ class BackendCombinedConfig {
'backends' => array(
'i' => array(
'name' => 'BackendIMAP',
'config' => self::$BackendIMAP_config,
),
'z' => array(
'name' => 'BackendZarafa',
'config' => self::$BackendZarafa_config
),
'm' => array(
'name' => 'BackendMaildir',
'config' => self::$BackendMaildir_config,
),
'v' => array(
'name' => 'BackendVCardDir',
'config' => self::$BackendVCardDir_config,
),
),
'delimiter' => '/',
......
<?php
/***********************************************
* File : config.php
* Project : Z-Push
* Descr : IMAP backend configuration file
*
* Created : 27.11.2012
*
* Copyright 2007 - 2012 Zarafa Deutschland GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation with the following additional
* term according to sec. 7:
*
* According to sec. 7 of the GNU Affero General Public License, version 3,
* the terms of the AGPL are supplemented with the following terms:
*
* "Zarafa" is a registered trademark of Zarafa B.V.
* "Z-Push" is a registered trademark of Zarafa Deutschland GmbH
* The licensing of the Program under the AGPL does not imply a trademark license.
* Therefore any rights, title and interest in our trademarks remain entirely with us.
*
* However, if you propagate an unmodified version of the Program you are
* allowed to use the term "Z-Push" to indicate that you distribute the Program.
* Furthermore you may use our trademarks where it is necessary to indicate
* the intended purpose of a product or service provided you use it in accordance
* with honest practices in industrial or commercial matters.
* If you want to propagate modified versions of the Program under the name "Z-Push",
* you may only do so if you have a written permission by Zarafa Deutschland GmbH
* (to acquire a permission please contact Zarafa at trademark@zarafa.com).
*
* This program 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Consult LICENSE file for details
************************************************/
// ************************
// BackendIMAP settings
// ************************
// Defines the server to which we want to connect
define('IMAP_SERVER', 'localhost');
// connecting to default port (143)
define('IMAP_PORT', 143);
// best cross-platform compatibility (see http://php.net/imap_open for options)
define('IMAP_OPTIONS', '/notls/norsh');
// overwrite the "from" header if it isn't set when sending emails
// options: 'username' - the username will be set (usefull if your login is equal to your emailaddress)
// 'domain' - the value of the "domain" field is used
// '@mydomain.com' - the username is used and the given string will be appended
define('IMAP_DEFAULTFROM', '');
// copy outgoing mail to this folder. If not set z-push will try the default folders
define('IMAP_SENTFOLDER', '');
// forward messages inline (default false - as attachment)
define('IMAP_INLINE_FORWARD', false);
// use imap_mail() to send emails (default) - if false mail() is used
define('IMAP_USE_IMAPMAIL', true);
/* BEGIN fmbiete's contribution r1527, ZP-319 */
// list of folders we want to exclude from sync. Names, or part of it, separated by |
// example: dovecot.sieve|archive|spam
define('IMAP_EXCLUDED_FOLDERS', '');
/* END fmbiete's contribution r1527, ZP-319 */
?>
\ No newline at end of file
......@@ -43,6 +43,9 @@
* Consult LICENSE file for details
************************************************/
// config file
require_once("backend/imap/config.php");
include_once('lib/default/diffbackend/diffbackend.php');
include_once('include/mimeDecode.php');
require_once('include/z_RFC822.php');
......
<?php
/***********************************************
* File : config.php
* Project : Z-Push
* Descr : Maildir backend configuration file
*
* Created : 27.11.2012
*
* Copyright 2007 - 2012 Zarafa Deutschland GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation with the following additional
* term according to sec. 7:
*
* According to sec. 7 of the GNU Affero General Public License, version 3,
* the terms of the AGPL are supplemented with the following terms:
*
* "Zarafa" is a registered trademark of Zarafa B.V.
* "Z-Push" is a registered trademark of Zarafa Deutschland GmbH
* The licensing of the Program under the AGPL does not imply a trademark license.
* Therefore any rights, title and interest in our trademarks remain entirely with us.
*
* However, if you propagate an unmodified version of the Program you are
* allowed to use the term "Z-Push" to indicate that you distribute the Program.
* Furthermore you may use our trademarks where it is necessary to indicate
* the intended purpose of a product or service provided you use it in accordance
* with honest practices in industrial or commercial matters.
* If you want to propagate modified versions of the Program under the name "Z-Push",
* you may only do so if you have a written permission by Zarafa Deutschland GmbH
* (to acquire a permission please contact Zarafa at trademark@zarafa.com).
*
* This program 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Consult LICENSE file for details
************************************************/
// ************************
// BackendMaildir settings
// ************************
define('MAILDIR_BASE', '/tmp');
define('MAILDIR_SUBDIR', 'Maildir');
?>
\ No newline at end of file
......@@ -53,6 +53,9 @@
* Consult LICENSE file for details
************************************************/
// config file
require_once("backend/maildir/config.php");
include_once('lib/default/diffbackend/diffbackend.php');
include_once('include/mimeDecode.php');
require_once('include/z_RFC822.php');
......
<?php
/***********************************************
* File : config.php
* Project : Z-Push
* Descr : VCardDir backend configuration file
*
* Created : 27.11.2012
*
* Copyright 2007 - 2012 Zarafa Deutschland GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation with the following additional
* term according to sec. 7:
*
* According to sec. 7 of the GNU Affero General Public License, version 3,
* the terms of the AGPL are supplemented with the following terms:
*
* "Zarafa" is a registered trademark of Zarafa B.V.
* "Z-Push" is a registered trademark of Zarafa Deutschland GmbH
* The licensing of the Program under the AGPL does not imply a trademark license.
* Therefore any rights, title and interest in our trademarks remain entirely with us.
*
* However, if you propagate an unmodified version of the Program you are
* allowed to use the term "Z-Push" to indicate that you distribute the Program.
* Furthermore you may use our trademarks where it is necessary to indicate
* the intended purpose of a product or service provided you use it in accordance
* with honest practices in industrial or commercial matters.
* If you want to propagate modified versions of the Program under the name "Z-Push",
* you may only do so if you have a written permission by Zarafa Deutschland GmbH
* (to acquire a permission please contact Zarafa at trademark@zarafa.com).
*
* This program 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Consult LICENSE file for details
************************************************/
// **********************
// BackendVCardDir settings
// **********************
define('VCARDDIR_DIR', '/home/%u/.kde/share/apps/kabc/stdvcf');
?>
\ No newline at end of file
......@@ -40,6 +40,10 @@
*
* Consult LICENSE file for details
************************************************/
// config file
require_once("backend/vcarddir/config.php");
include_once('lib/default/diffbackend/diffbackend.php');
class BackendVCardDir extends BackendDiff {
......
<?php
/***********************************************
* File : config.php
* Project : Z-Push
* Descr : VCardDir backend configuration file
*
* Created : 27.11.2012
*
* Copyright 2007 - 2012 Zarafa Deutschland GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation with the following additional
* term according to sec. 7:
*
* According to sec. 7 of the GNU Affero General Public License, version 3,
* the terms of the AGPL are supplemented with the following terms:
*
* "Zarafa" is a registered trademark of Zarafa B.V.
* "Z-Push" is a registered trademark of Zarafa Deutschland GmbH
* The licensing of the Program under the AGPL does not imply a trademark license.
* Therefore any rights, title and interest in our trademarks remain entirely with us.
*
* However, if you propagate an unmodified version of the Program you are
* allowed to use the term "Z-Push" to indicate that you distribute the Program.
* Furthermore you may use our trademarks where it is necessary to indicate
* the intended purpose of a product or service provided you use it in accordance
* with honest practices in industrial or commercial matters.
* If you want to propagate modified versions of the Program under the name "Z-Push",
* you may only do so if you have a written permission by Zarafa Deutschland GmbH
* (to acquire a permission please contact Zarafa at trademark@zarafa.com).
*
* This program 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Consult LICENSE file for details
************************************************/
// ************************
// BackendZarafa settings
// ************************
// Defines the server to which we want to connect
define('MAPI_SERVER', 'file:///var/run/zarafa');
?>
\ No newline at end of file
......@@ -45,6 +45,9 @@
* Consult LICENSE file for details
*************************************************/
// config file
require_once("backend/zarafa/config.php");
// include PHP-MAPI classes
include_once('backend/zarafa/mapi/mapi.util.php');
include_once('backend/zarafa/mapi/mapidefs.php');
......
......@@ -160,55 +160,8 @@
/**********************************************************************************
* Backend settings
*/
// The data providers that we are using (see configuration below)
define('BACKEND_PROVIDER', "BackendZarafa");
// ************************
// BackendZarafa settings
// ************************
// Defines the server to which we want to connect
define('MAPI_SERVER', 'file:///var/run/zarafa');
// ************************
// BackendIMAP settings
// ************************
// Defines the server to which we want to connect
define('IMAP_SERVER', 'localhost');
// connecting to default port (143)
define('IMAP_PORT', 143);
// best cross-platform compatibility (see http://php.net/imap_open for options)
define('IMAP_OPTIONS', '/notls/norsh');
// overwrite the "from" header if it isn't set when sending emails
// options: 'username' - the username will be set (usefull if your login is equal to your emailaddress)
// 'domain' - the value of the "domain" field is used
// '@mydomain.com' - the username is used and the given string will be appended
define('IMAP_DEFAULTFROM', '');
// copy outgoing mail to this folder. If not set z-push will try the default folders
define('IMAP_SENTFOLDER', '');
// forward messages inline (default false - as attachment)
define('IMAP_INLINE_FORWARD', false);
// use imap_mail() to send emails (default) - if false mail() is used
define('IMAP_USE_IMAPMAIL', true);
/* BEGIN fmbiete's contribution r1527, ZP-319 */
// list of folders we want to exclude from sync. Names, or part of it, separated by |
// example: dovecot.sieve|archive|spam
define('IMAP_EXCLUDED_FOLDERS', '');
/* END fmbiete's contribution r1527, ZP-319 */
// ************************
// BackendMaildir settings
// ************************
define('MAILDIR_BASE', '/tmp');
define('MAILDIR_SUBDIR', 'Maildir');
// **********************
// BackendVCardDir settings
// **********************
define('VCARDDIR_DIR', '/home/%u/.kde/share/apps/kabc/stdvcf');
// the backend data provider
define('BACKEND_PROVIDER', '');
/**********************************************************************************
* Search provider settings
......
......@@ -97,6 +97,14 @@ class ZPush {
// Webservice commands
const COMMAND_WEBSERVICE_DEVICE = -100;
static private $autoloadBackendPreference = array(
"BackendZarafa",
"BackendCombined",
"BackendIMAP",
"BackendVCardDir",
"BackendMaildir"
);
static private $supportedASVersions = array(
self::ASV_1,
self::ASV_2,
......@@ -439,7 +447,23 @@ class ZPush {
if (!isset(ZPush::$backend)) {
// Initialize our backend
$ourBackend = @constant('BACKEND_PROVIDER');
self::IncludeBackend($ourBackend);
// if no backend provider is defined, try to include automatically
if ($ourBackend == false || $ourBackend == "") {
$loaded = false;
foreach (self::$autoloadBackendPreference as $autoloadBackend) {
ZLog::Write(LOGLEVEL_DEBUG, sprintf("ZPush::GetBackend(): trying autoload backend '%s'", $autoloadBackend));
$loaded = self::IncludeBackend($autoloadBackend);
if ($loaded) {
$ourBackend = $autoloadBackend;
break;
}
}
if (!$ourBackend || !$loaded)
throw new FatalMisconfigurationException("No Backend provider can not be loaded. Check your installation and configuration!");
}
else
self::IncludeBackend($ourBackend);
if (class_exists($ourBackend))
ZPush::$backend = new $ourBackend();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment