From 8bded30158252cb3db910a2532dc65df8af5fa7b Mon Sep 17 00:00:00 2001
From: Daniel Berteaud <daniel@firewall-services.com>
Date: Tue, 3 Apr 2012 11:35:29 +0200
Subject: [PATCH] move conf and add ldap

---
 createlinks                                                | 10 +++++++---
 .../share/sogosync/backend/searchldap/config.php/10Server  |  4 ++++
 .../share/sogosync/backend/searchldap/config.php/20base    | 13 +++++++++++++
 .../usr/share/sogosync/backend/searchldap/config.php/30Map | 14 ++++++++++++++
 .../{etc => usr/share}/sogosync/config.php/10TimeZone      |  0
 .../{etc => usr/share}/sogosync/config.php/20BasePath      |  0
 .../{etc => usr/share}/sogosync/config.php/30Options       |  0
 .../{etc => usr/share}/sogosync/config.php/40Backend       |  0
 .../{etc => usr/share}/sogosync/config.php/45Backend10Mapi |  0
 .../{etc => usr/share}/sogosync/config.php/45Backend20Imap |  0
 .../share}/sogosync/config.php/45Backend30Maildir          |  0
 .../share}/sogosync/config.php/45Backend40Vcard            |  0
 .../share}/sogosync/config.php/45Backend50SearchProvider   |  0
 .../share}/sogosync/config.php/45Backend60Caldav           |  0
 .../share}/sogosync/config.php/45Backend70Carddav          |  0
 smeserver-sogosync.spec                                    |  2 +-
 16 files changed, 39 insertions(+), 4 deletions(-)
 create mode 100644 root/etc/e-smith/templates/usr/share/sogosync/backend/searchldap/config.php/10Server
 create mode 100644 root/etc/e-smith/templates/usr/share/sogosync/backend/searchldap/config.php/20base
 create mode 100644 root/etc/e-smith/templates/usr/share/sogosync/backend/searchldap/config.php/30Map
 rename root/etc/e-smith/templates/{etc => usr/share}/sogosync/config.php/10TimeZone (100%)
 rename root/etc/e-smith/templates/{etc => usr/share}/sogosync/config.php/20BasePath (100%)
 rename root/etc/e-smith/templates/{etc => usr/share}/sogosync/config.php/30Options (100%)
 rename root/etc/e-smith/templates/{etc => usr/share}/sogosync/config.php/40Backend (100%)
 rename root/etc/e-smith/templates/{etc => usr/share}/sogosync/config.php/45Backend10Mapi (100%)
 rename root/etc/e-smith/templates/{etc => usr/share}/sogosync/config.php/45Backend20Imap (100%)
 rename root/etc/e-smith/templates/{etc => usr/share}/sogosync/config.php/45Backend30Maildir (100%)
 rename root/etc/e-smith/templates/{etc => usr/share}/sogosync/config.php/45Backend40Vcard (100%)
 rename root/etc/e-smith/templates/{etc => usr/share}/sogosync/config.php/45Backend50SearchProvider (100%)
 rename root/etc/e-smith/templates/{etc => usr/share}/sogosync/config.php/45Backend60Caldav (100%)
 rename root/etc/e-smith/templates/{etc => usr/share}/sogosync/config.php/45Backend70Carddav (100%)

diff --git a/createlinks b/createlinks
index 9cc1741..efeb189 100644
--- a/createlinks
+++ b/createlinks
@@ -2,6 +2,10 @@
 
 use esmith::Build::CreateLinks qw(:all);
 
-templates2events("/etc/sogosync/config.php", qw(webapps-update bootstrap-console-save email-update));
-safe_symlink("/etc/e-smith/templates-default/template-begin-php", "root/etc/e-smith/templates/etc/sogosync/config.php/template-begin");
-safe_symlink("/etc/e-smith/templates-default/template-end-php", "root/etc/e-smith/templates/etc/sogosync/config.php/template-end");
+templates2events("/usr/share/sogosync/config.php", qw(webapps-update bootstrap-console-save email-update));
+templates2events("/usr/share/sogosync/backend/searchldap/config.php", qw(webapps-update bootstrap-console-save email-update));
+safe_symlink("/etc/e-smith/templates-default/template-begin-php", "root/etc/e-smith/templates/usr/share/sogosync/config.php/template-begin");
+safe_symlink("/etc/e-smith/templates-default/template-end-php", "root/etc/e-smith/templates/usr/share/sogosync/config.php/template-end");
+safe_symlink("/etc/e-smith/templates-default/template-begin-php", "root/etc/e-smith/templates/usr/share/sogosync/backend/searchldap/config.php/template-begin");
+safe_symlink("/etc/e-smith/templates-default/template-end-php", "root/etc/e-smith/templates/usr/share/sogosync/backend/searchldap/config.php/template-end");
+
diff --git a/root/etc/e-smith/templates/usr/share/sogosync/backend/searchldap/config.php/10Server b/root/etc/e-smith/templates/usr/share/sogosync/backend/searchldap/config.php/10Server
new file mode 100644
index 0000000..b69afb9
--- /dev/null
+++ b/root/etc/e-smith/templates/usr/share/sogosync/backend/searchldap/config.php/10Server
@@ -0,0 +1,4 @@
+define("LDAP_HOST", "ldap://127.0.0.1/");
+define("LDAP_PORT", "389");
+define("ANONYMOUS_BIND", true);
+
diff --git a/root/etc/e-smith/templates/usr/share/sogosync/backend/searchldap/config.php/20base b/root/etc/e-smith/templates/usr/share/sogosync/backend/searchldap/config.php/20base
new file mode 100644
index 0000000..4243584
--- /dev/null
+++ b/root/etc/e-smith/templates/usr/share/sogosync/backend/searchldap/config.php/20base
@@ -0,0 +1,13 @@
+{
+use esmith::util;
+my $c = esmith::ConfigDB->open_ro;
+my $domain = $c->get('DomainName')->value;
+my $basedn = esmith::util::ldapBase($domain);
+
+$OUT .=<<"EOF";
+
+define("LDAP_SEARCH_BASE", "ou=Users,$basedn");
+define("LDAP_SEARCH_FILTER", "(|(cn=*SEARCHVALUE*)(mail=*SEARCHVALUE*))");
+
+EOF
+}
diff --git a/root/etc/e-smith/templates/usr/share/sogosync/backend/searchldap/config.php/30Map b/root/etc/e-smith/templates/usr/share/sogosync/backend/searchldap/config.php/30Map
new file mode 100644
index 0000000..a2fd3c3
--- /dev/null
+++ b/root/etc/e-smith/templates/usr/share/sogosync/backend/searchldap/config.php/30Map
@@ -0,0 +1,14 @@
+global $ldap_field_map;
+$ldap_field_map = array(
+                    SYNC_GAL_DISPLAYNAME    => 'cn',
+                    SYNC_GAL_PHONE          => 'telephonenumber',
+                    SYNC_GAL_OFFICE         => 'l',
+                    SYNC_GAL_TITLE          => 'title',
+                    SYNC_GAL_COMPANY        => 'o',
+                    SYNC_GAL_ALIAS          => 'uid',
+                    SYNC_GAL_FIRSTNAME      => 'givenname',
+                    SYNC_GAL_LASTNAME       => 'sn',
+                    SYNC_GAL_HOMEPHONE      => 'extensionnumber',
+                    SYNC_GAL_MOBILEPHONE    => 'mobile',
+                    SYNC_GAL_EMAILADDRESS   => 'mail',
+                );
diff --git a/root/etc/e-smith/templates/etc/sogosync/config.php/10TimeZone b/root/etc/e-smith/templates/usr/share/sogosync/config.php/10TimeZone
similarity index 100%
rename from root/etc/e-smith/templates/etc/sogosync/config.php/10TimeZone
rename to root/etc/e-smith/templates/usr/share/sogosync/config.php/10TimeZone
diff --git a/root/etc/e-smith/templates/etc/sogosync/config.php/20BasePath b/root/etc/e-smith/templates/usr/share/sogosync/config.php/20BasePath
similarity index 100%
rename from root/etc/e-smith/templates/etc/sogosync/config.php/20BasePath
rename to root/etc/e-smith/templates/usr/share/sogosync/config.php/20BasePath
diff --git a/root/etc/e-smith/templates/etc/sogosync/config.php/30Options b/root/etc/e-smith/templates/usr/share/sogosync/config.php/30Options
similarity index 100%
rename from root/etc/e-smith/templates/etc/sogosync/config.php/30Options
rename to root/etc/e-smith/templates/usr/share/sogosync/config.php/30Options
diff --git a/root/etc/e-smith/templates/etc/sogosync/config.php/40Backend b/root/etc/e-smith/templates/usr/share/sogosync/config.php/40Backend
similarity index 100%
rename from root/etc/e-smith/templates/etc/sogosync/config.php/40Backend
rename to root/etc/e-smith/templates/usr/share/sogosync/config.php/40Backend
diff --git a/root/etc/e-smith/templates/etc/sogosync/config.php/45Backend10Mapi b/root/etc/e-smith/templates/usr/share/sogosync/config.php/45Backend10Mapi
similarity index 100%
rename from root/etc/e-smith/templates/etc/sogosync/config.php/45Backend10Mapi
rename to root/etc/e-smith/templates/usr/share/sogosync/config.php/45Backend10Mapi
diff --git a/root/etc/e-smith/templates/etc/sogosync/config.php/45Backend20Imap b/root/etc/e-smith/templates/usr/share/sogosync/config.php/45Backend20Imap
similarity index 100%
rename from root/etc/e-smith/templates/etc/sogosync/config.php/45Backend20Imap
rename to root/etc/e-smith/templates/usr/share/sogosync/config.php/45Backend20Imap
diff --git a/root/etc/e-smith/templates/etc/sogosync/config.php/45Backend30Maildir b/root/etc/e-smith/templates/usr/share/sogosync/config.php/45Backend30Maildir
similarity index 100%
rename from root/etc/e-smith/templates/etc/sogosync/config.php/45Backend30Maildir
rename to root/etc/e-smith/templates/usr/share/sogosync/config.php/45Backend30Maildir
diff --git a/root/etc/e-smith/templates/etc/sogosync/config.php/45Backend40Vcard b/root/etc/e-smith/templates/usr/share/sogosync/config.php/45Backend40Vcard
similarity index 100%
rename from root/etc/e-smith/templates/etc/sogosync/config.php/45Backend40Vcard
rename to root/etc/e-smith/templates/usr/share/sogosync/config.php/45Backend40Vcard
diff --git a/root/etc/e-smith/templates/etc/sogosync/config.php/45Backend50SearchProvider b/root/etc/e-smith/templates/usr/share/sogosync/config.php/45Backend50SearchProvider
similarity index 100%
rename from root/etc/e-smith/templates/etc/sogosync/config.php/45Backend50SearchProvider
rename to root/etc/e-smith/templates/usr/share/sogosync/config.php/45Backend50SearchProvider
diff --git a/root/etc/e-smith/templates/etc/sogosync/config.php/45Backend60Caldav b/root/etc/e-smith/templates/usr/share/sogosync/config.php/45Backend60Caldav
similarity index 100%
rename from root/etc/e-smith/templates/etc/sogosync/config.php/45Backend60Caldav
rename to root/etc/e-smith/templates/usr/share/sogosync/config.php/45Backend60Caldav
diff --git a/root/etc/e-smith/templates/etc/sogosync/config.php/45Backend70Carddav b/root/etc/e-smith/templates/usr/share/sogosync/config.php/45Backend70Carddav
similarity index 100%
rename from root/etc/e-smith/templates/etc/sogosync/config.php/45Backend70Carddav
rename to root/etc/e-smith/templates/usr/share/sogosync/config.php/45Backend70Carddav
diff --git a/smeserver-sogosync.spec b/smeserver-sogosync.spec
index 2cdd059..5ae51f4 100644
--- a/smeserver-sogosync.spec
+++ b/smeserver-sogosync.spec
@@ -1,6 +1,6 @@
 Name:		smeserver-sogosync
 Version:	0.0.1
-Release:	0.beta1%{?dist}
+Release:	0.beta2%{?dist}
 Summary:	SME Server integration for sogosync
 
 Group:		Application/System