From 933685fb30b245a05586fdd9a4c8c5f56651835d Mon Sep 17 00:00:00 2001 From: Miles Lott Date: Sat, 24 Mar 2001 07:58:03 +0000 Subject: [PATCH] Add checks to make sure ldap_contact_context is set --- addressbook/inc/class.contacts_ldap.inc.php | 22 +++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/addressbook/inc/class.contacts_ldap.inc.php b/addressbook/inc/class.contacts_ldap.inc.php index eb7e1b0d3d..ea2865fa10 100644 --- a/addressbook/inc/class.contacts_ldap.inc.php +++ b/addressbook/inc/class.contacts_ldap.inc.php @@ -461,6 +461,11 @@ function add($owner,$fields) { global $phpgw,$phpgw_info; + + if (!$phpgw_info["server"]["ldap_contact_context"]) { + return False; + } + list($stock_fields,$stock_fieldnames,$extra_fields) = $this->split_stock_and_extras($fields); $free = 0; @@ -535,6 +540,11 @@ function update($id,$owner,$fields) { global $phpgw_info; + + if (!$phpgw_info["server"]["ldap_contact_context"]) { + return False; + } + // First make sure that id number exists $sri = ldap_search($this->ldap, $phpgw_info["server"]["ldap_contact_context"], "uidnumber=".$id); $ldap_fields = ldap_get_entries($this->ldap, $sri); @@ -625,6 +635,11 @@ function delete_($id) { global $phpgw_info; + + if (!$phpgw_info["server"]["ldap_contact_context"]) { + return False; + } + $sri = ldap_search($this->ldap, $phpgw_info["server"]["ldap_contact_context"], "uidnumber=".$id); $ldap_fields = ldap_get_entries($this->ldap, $sri); @@ -638,9 +653,15 @@ } } + // This is for testing, not intended for release function delete_all() { global $phpgw_info; + + if (!$phpgw_info["server"]["ldap_contact_context"]) { + return False; + } + $sri = ldap_search($this->ldap, $phpgw_info["server"]["ldap_contact_context"], "uidnumber=*"); $ldap_fields = ldap_get_entries($this->ldap, $sri); @@ -648,6 +669,7 @@ while (list($null,$entry) = each($ldap_fields)) { $err = ldap_delete($this->ldap,$entry['dn']); } + return; } }