From 95dc6489fc129f8f692f826bc44f910327b7555d Mon Sep 17 00:00:00 2001 From: Miles Lott Date: Fri, 30 Mar 2001 04:18:22 +0000 Subject: [PATCH] Add change_owner for admin --- addressbook/inc/class.contacts_ldap.inc.php | 22 ++++++++++++++++++++- addressbook/inc/class.contacts_sql.inc.php | 14 +++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/addressbook/inc/class.contacts_ldap.inc.php b/addressbook/inc/class.contacts_ldap.inc.php index ec8efb4311..a19667b92a 100644 --- a/addressbook/inc/class.contacts_ldap.inc.php +++ b/addressbook/inc/class.contacts_ldap.inc.php @@ -701,6 +701,26 @@ } } + // Used by admin to change ownership on account delete + function change_owner($old_owner='',$new_owner='') + { + if (!($new_owner && $old_owner)) + { + return False; + } + + $sri = ldap_search($this->ldap, $phpgw_info["server"]["ldap_contact_context"], "phpgwowner=".$old_owner); + $ldap_fields = ldap_get_entries($this->ldap, $sri); + + $entry = ""; + while (list($null,$entry) = each($ldap_fields)) { + $err = ldap_modify($this->ldap,$dn,array('phpgwowner' => $new_owner)); + } + + $this->db->query("update $this->ext_table set contact_owner='$new_owner' WHERE contact_owner=$owner",__LINE__,__FILE__); + return; + } + // This is where the real work of delete() is done, shared class file contains calling function function delete_($id) { @@ -733,7 +753,7 @@ } if ($owner) { - $sri = ldap_search($this->ldap, $phpgw_info["server"]["ldap_contact_context"], "uidnumber=".$owner); + $sri = ldap_search($this->ldap, $phpgw_info["server"]["ldap_contact_context"], "phpgwowner=".$owner); $ldap_fields = ldap_get_entries($this->ldap, $sri); $entry = ""; diff --git a/addressbook/inc/class.contacts_sql.inc.php b/addressbook/inc/class.contacts_sql.inc.php index bc347a8364..b66deb3542 100644 --- a/addressbook/inc/class.contacts_sql.inc.php +++ b/addressbook/inc/class.contacts_sql.inc.php @@ -577,6 +577,20 @@ } } + // Used by admin to change ownership on account delete + function change_owner($old_owner='',$new_owner='') + { + if (!($new_owner && $old_owner)) + { + return False; + } + + $this->db->query("update $this->std_table set owner='$new_owner' WHERE owner=$old_owner",__LINE__,__FILE__); + $this->db->query("update $this->ext_table set contact_owner='$new_owner' WHERE contact_owner=$old_owner",__LINE__,__FILE__); + + return; + } + // This is where the real work of delete() is done, shared class file contains calling function function delete_($id) {