add support for univentionEmail schema
authorLars Kneschke <l.kneschke@metaways.de>
Sun, 4 Jan 2015 19:07:41 +0000 (20:07 +0100)
committerPhilipp Schüle <p.schuele@metaways.de>
Thu, 12 Mar 2015 15:07:02 +0000 (16:07 +0100)
Change-Id: I4d92ad83674fa0b0df2f7c3585ec1f66c6e8a98f
Reviewed-on: http://gerrit.tine20.com/customers/1501
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
Tested-by: Jenkins CI (http://ci.tine20.com/)
tine20/Setup/js/EmailPanel.js
tine20/Tinebase/EmailUser.php
tine20/Tinebase/EmailUser/Imap/LdapUniventionMailSchema.php [new file with mode: 0644]
tine20/Tinebase/EmailUser/Smtp/LdapUniventionMailSchema.php [new file with mode: 0644]

index 3cf31af..0180ec3 100644 (file)
@@ -147,7 +147,7 @@ Tine.Setup.EmailPanel = Ext.extend(Tine.Tinebase.widgets.form.ConfigPanel, {
         };
         
         // imap combo
-        backendComboConfig.store = [['standard', this.app.i18n._('Standard IMAP')], ['dbmail', 'DBmail  MySQL'], ['ldap_imap', 'DBmail Ldap'], ['cyrus', 'Cyrus'], ['dovecot_imap', 'Dovecot MySQL'], ['dovecotcombined', 'Dovecot SQL (combined schema)']];
+        backendComboConfig.store = [['standard', this.app.i18n._('Standard IMAP')], ['dbmail', 'DBmail  MySQL'], ['ldap_imap', 'DBmail Ldap'], ['cyrus', 'Cyrus'], ['dovecot_imap', 'Dovecot MySQL'], ['dovecotcombined', 'Dovecot SQL (combined schema)'], ['ldap_univention', 'Univention']];
         backendComboConfig.name = 'imap_backend';
         backendComboConfig.listeners = {
             scope: this,
@@ -157,7 +157,7 @@ Tine.Setup.EmailPanel = Ext.extend(Tine.Tinebase.widgets.form.ConfigPanel, {
         this.imapBackendCombo = new Ext.form.ComboBox(backendComboConfig);
         
         // smtp combo
-        backendComboConfig.store = [['standard', this.app.i18n._('Standard SMTP')], ['postfix', 'Postfix MySQL'], ['postfixcombined', 'Postfix SQL (combined schema)'], ['Ldapsmtpmail', 'Ldap (only mail attribute)'], ['ldapSmtp', 'Postfix Ldap (dbmail schema)'], ['ldapSmtpQmail', 'Postfix Ldap (qmail schema)']];
+        backendComboConfig.store = [['standard', this.app.i18n._('Standard SMTP')], ['postfix', 'Postfix MySQL'], ['postfixcombined', 'Postfix SQL (combined schema)'], ['Ldapsmtpmail', 'Ldap (only mail attribute)'], ['ldapSmtp', 'Postfix Ldap (dbmail schema)'], ['ldapSmtpQmail', 'Postfix Ldap (qmail schema)'], ['ldap_univention', 'Univention']];
         backendComboConfig.name = 'smtp_backend';
         backendComboConfig.listeners = {
             scope: this,
index 0f1f2c9..635adf5 100644 (file)
@@ -99,6 +99,20 @@ class Tinebase_EmailUser
     const SMTP_LDAP_QMAIL       = 'Smtp_Ldapsmtpqmail';
     
     /**
+     * univention smtp ldap backend const
+     * 
+     * @staticvar string
+     */
+    const SMTP_LDAP_UNIVENTION  = 'Smtp_Ldap_univention';
+
+    /**
+     * univention imap ldap backend const
+     * 
+     * @staticvar string
+     */
+    const IMAP_LDAP_UNIVENTION  = 'Imap_Ldap_univention';
+
+    /**
      * Smtp standard backend const
      * 
      * @staticvar string
@@ -117,9 +131,11 @@ class Tinebase_EmailUser
         self::IMAP_DOVECOT_COMBINED => 'Tinebase_EmailUser_Imap_DovecotCombined',
         self::IMAP_STANDARD         => 'Tinebase_EmailUser_Imap_Standard',
         self::IMAP_LDAP             => 'Tinebase_EmailUser_Imap_LdapDbmailSchema',
+        self::IMAP_LDAP_UNIVENTION  => 'Tinebase_EmailUser_Imap_LdapUniventionMailSchema',
         self::SMTP_LDAP             => 'Tinebase_EmailUser_Smtp_LdapDbmailSchema',
         self::SMTP_LDAP_MAIL        => 'Tinebase_EmailUser_Smtp_LdapMailSchema',
         self::SMTP_LDAP_QMAIL       => 'Tinebase_EmailUser_Smtp_LdapQmailSchema',
+        self::SMTP_LDAP_UNIVENTION  => 'Tinebase_EmailUser_Smtp_LdapUniventionMailSchema',
         self::SMTP_POSTFIX          => 'Tinebase_EmailUser_Smtp_Postfix',
         self::SMTP_POSTFIX_COMBINED => 'Tinebase_EmailUser_Smtp_PostfixCombined',
         self::SMTP_STANDARD         => 'Tinebase_EmailUser_Smtp_Standard',
diff --git a/tine20/Tinebase/EmailUser/Imap/LdapUniventionMailSchema.php b/tine20/Tinebase/EmailUser/Imap/LdapUniventionMailSchema.php
new file mode 100644 (file)
index 0000000..e6529b2
--- /dev/null
@@ -0,0 +1,44 @@
+<?php
+/**
+ * Tine 2.0
+ * 
+ * @package     Tinebase
+ * @subpackage  EmailUser
+ * @license     http://www.gnu.org/licenses/agpl.html AGPL Version 3
+ * @copyright   Copyright (c) 2014-2015 Metaways Infosystems GmbH (http://www.metaways.de)
+ * @author      Lars Kneschke <l.kneschke@metaways.de>
+ */
+
+/**
+ * plugin to handle imap settings for univentionMail ldap schema
+ * 
+ * @package    Tinebase
+ * @subpackage EmailUser
+ */
+class Tinebase_EmailUser_Imap_LdapUniventionMailSchema extends Tinebase_EmailUser_Ldap implements Tinebase_EmailUser_Imap_Interface
+{
+    /**
+     * user properties mapping 
+     * -> we need to use lowercase for ldap fields because ldap_fetch returns lowercase keys
+     *
+     * @var array
+     */
+    protected $_propertyMapping = array(
+        'emailUsername' => 'mailprimaryaddress',
+        'emailHost'     => 'univentionmailhomeserver'
+    );
+    
+    /**
+     * objectclasses required for users
+     *
+     * @var array
+     */
+    protected $_requiredObjectClass = array(
+        'univentionMail'
+    );
+    
+    protected $_defaults = array(
+        'emailPort'   => 143,
+        'emailSecure' => Felamimail_Model_Account::SECURE_TLS
+    );
+}
diff --git a/tine20/Tinebase/EmailUser/Smtp/LdapUniventionMailSchema.php b/tine20/Tinebase/EmailUser/Smtp/LdapUniventionMailSchema.php
new file mode 100644 (file)
index 0000000..d020aea
--- /dev/null
@@ -0,0 +1,67 @@
+<?php
+/**
+ * Tine 2.0
+ * 
+ * @package     Tinebase
+ * @subpackage  EmailUser
+ * @license     http://www.gnu.org/licenses/agpl.html AGPL Version 3
+ * @copyright   Copyright (c) 2014-2015 Metaways Infosystems GmbH (http://www.metaways.de)
+ * @author      Lars Kneschke <l.kneschke@metaways.de>
+ */
+
+/**
+ * plugin to handle smtp settings for univentionMail ldap schema
+ * 
+ * @package    Tinebase
+ * @subpackage EmailUser
+ */
+class Tinebase_EmailUser_Smtp_LdapUniventionMailSchema extends Tinebase_EmailUser_Ldap implements Tinebase_EmailUser_Smtp_Interface
+{
+    /**
+     * user properties mapping 
+     * -> we need to use lowercase for ldap fields because ldap_fetch returns lowercase keys
+     *
+     * @var array
+     */
+    protected $_propertyMapping = array(
+        'emailUsername' => 'mailprimaryaddress',
+        'emailHost'     => 'univentionmailhomeserver',
+        'emailAddress'  => 'mailprimaryaddress',
+        'emailAliases'  => 'mailalternativeaddress'
+    );
+    
+    /**
+     * objectclasses required for users
+     *
+     * @var array
+     */
+    protected $_requiredObjectClass = array(
+        'univentionMail'
+    );
+    
+    protected $_defaults = array(
+        'emailPort'   => 25,
+        'emailSecure' => Felamimail_Model_Account::SECURE_TLS,
+        'emailAuth'   => 'login'
+    );
+    
+    /**
+     * (non-PHPdoc)
+     * @see Tinebase_EmailUser_Ldap::_user2Ldap()
+     */
+    protected function _user2Ldap(Tinebase_Model_FullUser $_user, array &$_ldapData, array &$_ldapEntry = array())
+    {
+        if (empty($_user->accountEmailAddress)) {
+            foreach ($this->_propertyMapping as $ldapKeyName) {
+                $_ldapData[$ldapKeyName] = array();
+            }
+            
+            $_ldapData['objectclass'] = array_unique(array_diff($_ldapData['objectclass'], $this->_requiredObjectClass));
+            
+        } else {
+            parent::_user2Ldap($_user, $_ldapData, $_ldapEntry);
+        }
+        
+        if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . '  $ldapData: ' . print_r($_ldapData, true));
+    }
+}