From af2ca7f9a0c4f9aeb7f8d812435ba9147c371b13 Mon Sep 17 00:00:00 2001
From: Lucas Bickel <hairmare@rabe.ch>
Date: Mon, 3 Apr 2017 13:46:28 +0200
Subject: [PATCH] Only grab ldap config from ini if it exists

This is a workaround to make updating easier for folks who do not re-install. A proper solution would get rid of most of the Config class and use something based on Zend_Config_Ini instead. It would also have some sensible defaults in the code and nor error when new values get added.
---
 airtime_mvc/application/configs/conf.php | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/airtime_mvc/application/configs/conf.php b/airtime_mvc/application/configs/conf.php
index d51be7f50..f12d04c86 100644
--- a/airtime_mvc/application/configs/conf.php
+++ b/airtime_mvc/application/configs/conf.php
@@ -98,17 +98,19 @@ class Config {
         }
 
         // ldap config
-        $CC_CONFIG['ldap_hostname'] = $values['ldap']['hostname'];
-        $CC_CONFIG['ldap_binddn'] = $values['ldap']['binddn'];
-        $CC_CONFIG['ldap_password'] = $values['ldap']['password'];
-        $CC_CONFIG['ldap_account_domain'] = $values['ldap']['account_domain'];
-        $CC_CONFIG['ldap_basedn'] = $values['ldap']['basedn'];
-        $CC_CONFIG['ldap_groupmap_guest'] = $values['ldap']['groupmap_guest'];
-        $CC_CONFIG['ldap_groupmap_host'] = $values['ldap']['groupmap_host'];
-        $CC_CONFIG['ldap_groupmap_program_manager'] = $values['ldap']['groupmap_program_manager'];
-        $CC_CONFIG['ldap_groupmap_admin'] = $values['ldap']['groupmap_admin'];
-        $CC_CONFIG['ldap_groupmap_superadmin'] = $values['ldap']['groupmap_superadmin'];
-        $CC_CONFIG['ldap_filter_field'] = $values['ldap']['filter_field'];
+        if (array_key_exists('ldap', $values)) {
+            $CC_CONFIG['ldap_hostname'] = $values['ldap']['hostname'];
+            $CC_CONFIG['ldap_binddn'] = $values['ldap']['binddn'];
+            $CC_CONFIG['ldap_password'] = $values['ldap']['password'];
+            $CC_CONFIG['ldap_account_domain'] = $values['ldap']['account_domain'];
+            $CC_CONFIG['ldap_basedn'] = $values['ldap']['basedn'];
+            $CC_CONFIG['ldap_groupmap_guest'] = $values['ldap']['groupmap_guest'];
+            $CC_CONFIG['ldap_groupmap_host'] = $values['ldap']['groupmap_host'];
+            $CC_CONFIG['ldap_groupmap_program_manager'] = $values['ldap']['groupmap_program_manager'];
+            $CC_CONFIG['ldap_groupmap_admin'] = $values['ldap']['groupmap_admin'];
+            $CC_CONFIG['ldap_groupmap_superadmin'] = $values['ldap']['groupmap_superadmin'];
+            $CC_CONFIG['ldap_filter_field'] = $values['ldap']['filter_field'];
+        }
 
         if(isset($values['demo']['demo'])){
             $CC_CONFIG['demo'] = $values['demo']['demo'];