From d5dd44ab6b642aca6ee4683e178866f7c8674718 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Fri, 18 Dec 2009 21:02:06 +0000 Subject: [PATCH] easier reoval of extension --- lam/lib/modules/phpGroupwareGroup.inc | 33 ++---------------- lam/lib/modules/phpGroupwareUser.inc | 50 +++------------------------ 2 files changed, 8 insertions(+), 75 deletions(-) diff --git a/lam/lib/modules/phpGroupwareGroup.inc b/lam/lib/modules/phpGroupwareGroup.inc index 1cc2e59b..cdc069f6 100644 --- a/lam/lib/modules/phpGroupwareGroup.inc +++ b/lam/lib/modules/phpGroupwareGroup.inc @@ -3,7 +3,7 @@ $Id$ This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) - Copyright (C) 2008 Roland Gruber + Copyright (C) 2008 - 2009 Roland Gruber 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 @@ -120,12 +120,8 @@ class phpGroupwareGroup extends baseModule { $this->attributes['objectClass'][] = 'phpgwGroup'; } elseif (isset($_POST['form_subpage_phpGroupwareGroup_attributes_remObjectClass'])) { - for ($i = 0; $i < sizeof($this->attributes['objectClass']); $i++) { - if ($this->attributes['objectClass'][$i] == 'phpgwGroup') { - unset($this->attributes['objectClass'][$i]); - break; - } - } + $this->attributes['objectClass'] = array_delete(array('phpgwGroup'), $this->attributes['objectClass']); + if (isset($this->attributes['phpgwGroupID'])) unset($this->attributes['phpgwGroupID']); } return array(); } @@ -169,29 +165,6 @@ class phpGroupwareGroup extends baseModule { return null; } - /** - * @see baseModule::postModifyActions() - * - * @param boolean $newAccount - * @param array $attributes LDAP attributes of this entry - */ - public function postModifyActions($newAccount, $attributes) { - // check if extension was removed - if (!$newAccount && - (in_array('phpgwGroup', $this->orig['objectClass']) && !in_array('phpgwGroup', $this->attributes['objectClass']))) { - $dn = $this->getAccountContainer()->finalDN; - $myattributes = array( - 'objectClass' => array('phpgwGroup'), - 'phpgwGroupID' => $this->attributes['phpgwGroupID'] - ); - $success = @ldap_mod_del($_SESSION['ldap']->server(), $dn, $myattributes); - if (!$success) { - StatusMessage('ERROR', sprintf(_('Was unable to remove attribtues from DN: %s.'), $dn), ldap_error($_SESSION['ldap']->server())); - } - } - return; - } - /** * In this function the LDAP account is built up. * diff --git a/lam/lib/modules/phpGroupwareUser.inc b/lam/lib/modules/phpGroupwareUser.inc index a8bd579a..fa26e4c3 100644 --- a/lam/lib/modules/phpGroupwareUser.inc +++ b/lam/lib/modules/phpGroupwareUser.inc @@ -3,7 +3,7 @@ $Id$ This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) - Copyright (C) 2008 Roland Gruber + Copyright (C) 2008 - 2009 Roland Gruber 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 @@ -202,10 +202,10 @@ class phpGroupwareUser extends baseModule implements passwordService { $this->attributes['phpgwLastPasswordChange'][0] = time(); } elseif (isset($_POST['form_subpage_phpGroupwareUser_attributes_remObjectClass'])) { - for ($i = 0; $i < sizeof($this->attributes['objectClass']); $i++) { - if ($this->attributes['objectClass'][$i] == 'phpgwAccount') { - unset($this->attributes['objectClass'][$i]); - break; + $this->attributes['objectClass'] = array_delete(array('phpgwAccount'), $this->attributes['objectClass']); + for ($i = 0; $i < sizeof($this->meta['attributes']); $i++) { + if (isset($this->attributes[$this->meta['attributes'][$i]])) { + unset($this->attributes[$this->meta['attributes'][$i]]); } } } @@ -309,46 +309,6 @@ class phpGroupwareUser extends baseModule implements passwordService { return parent::save_attributes(); } - /** - * @see baseModule::postModifyActions() - * - * @param boolean $newAccount - * @param array $attributes LDAP attributes of this entry - */ - public function postModifyActions($newAccount, $attributes) { - // check if extension was removed - if (!$newAccount && - (in_array('phpgwAccount', $this->orig['objectClass']) && !in_array('phpgwAccount', $this->attributes['objectClass']))) { - $dn = $this->getAccountContainer()->finalDN; - $myattributes = array_merge(array('objectClass'), $this->meta['attributes']); - $sr = @ldap_read($_SESSION['ldap']->server(), $dn, 'objectClass=*', $myattributes); - if (!$sr) { - StatusMessage('ERROR', sprintf(_('Was unable to remove attribtues from DN: %s.'), $dn), ldap_error($_SESSION['ldap']->server())); - return; - } - $entry = ldap_get_entries($_SESSION['ldap']->server(), $sr); - $newAttributes = array(); - $newAttributes['objectclass'] = $entry[0]['objectclass']; - unset($newAttributes['objectclass']['count']); - for ($i = 0; $i < sizeof($newAttributes['objectclass']); $i++) { - if ($newAttributes['objectclass'][$i] == 'phpgwAccount') { - unset($newAttributes['objectclass'][$i]); - break; - } - } - for ($i = 0; $i < sizeof($this->meta['attributes']); $i++) { - if (isset($entry[0][strtolower($this->meta['attributes'][$i])])) { - $newAttributes[$this->meta['attributes'][$i]] = array(); - } - } - $success = @ldap_mod_replace($_SESSION['ldap']->server(), $dn, $newAttributes); - if (!$success) { - StatusMessage('ERROR', sprintf(_('Was unable to remove attribtues from DN: %s.'), $dn), ldap_error($_SESSION['ldap']->server())); - } - } - return; - } - /** * Returns the PDF entries for this module. *