From d98af244925ca7298711452d49ed9cc3b0e60f69 Mon Sep 17 00:00:00 2001 From: Miles Lott Date: Sun, 23 Dec 2001 15:29:52 +0000 Subject: [PATCH] Add new validation hook file for config.php in admin --- addressbook/inc/hook_config_validate.inc.php | 54 ++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 addressbook/inc/hook_config_validate.inc.php diff --git a/addressbook/inc/hook_config_validate.inc.php b/addressbook/inc/hook_config_validate.inc.php new file mode 100644 index 0000000000..30d80be57f --- /dev/null +++ b/addressbook/inc/hook_config_validate.inc.php @@ -0,0 +1,54 @@ + * + * -------------------------------------------- * + * This program is free software; you can redistribute it and/or modify it * + * under the terms of the GNU General Public License as published by the * + * Free Software Foundation; either version 2 of the License, or (at your * + * option) any later version. * + \**************************************************************************/ + + /* $Id$ */ + + /* + Set a global flag to indicate this file was found by admin/config.php. + config.php will unset it after parsing the form values. + */ + $GLOBALS['phpgw_info']['server']['found_validation_hook'] = True; + + /* Check a specific setting. Name must match the setting. */ + function ldap_contact_context($value='') + { + if($value == $GLOBALS['phpgw_info']['server']['ldap_context']) + { + $GLOBALS['config_error'] = 'Contact context for ldap must be different from the context used for accounts'; + } + elseif($value == $GLOBALS['phpgw_info']['server']['ldap_group_context']) + { + $GLOBALS['config_error'] = 'Contact context for ldap must be different from the context used for groups'; + } + else + { + $GLOBALS['config_error'] = ''; + } + } + + /* Check all settings to validate input. Name must be 'final_validation' */ + function final_validation($value='') + { + if($value['contact_repository'] == 'ldap' && !$value['ldap_contact_dn']) + { + $GLOBALS['config_error'] = 'Contact dn must be set'; + } + elseif($value['contact_repository'] == 'ldap' && !$value['ldap_contact_context']) + { + $GLOBALS['config_error'] = 'Contact context must be set'; + } + else + { + $GLOBALS['config_error'] = ''; + } + } +?>