summaryrefslogtreecommitdiff
path: root/www/admin/addressbook
diff options
context:
space:
mode:
authorSteffen Hansen <steffen@kdab.com>2006-02-21 02:32:39 (GMT)
committerSteffen Hansen <steffen@kdab.com>2006-02-21 02:32:39 (GMT)
commit85cc67a11f4b64f1166680b130eb78cc189576f2 (patch)
tree5c9438ba8623892bc61e6521c65ec870a035e24e /www/admin/addressbook
parent1478f790d107e37a34f2a1c885d74aaaeddb24de (diff)
downloadkolab-webadmin-85cc67a11f4b64f1166680b130eb78cc189576f2.tar.gz
Fix for issue848 (external address in dist. list)
Diffstat (limited to 'www/admin/addressbook')
-rw-r--r--www/admin/addressbook/addr.php.in75
1 files changed, 47 insertions, 28 deletions
diff --git a/www/admin/addressbook/addr.php.in b/www/admin/addressbook/addr.php.in
index 61050cf..af37c23 100644
--- a/www/admin/addressbook/addr.php.in
+++ b/www/admin/addressbook/addr.php.in
@@ -241,20 +241,17 @@ if( !$errors ) {
}
break;
case 'modify':
- $result = $ldap->search( $dn, '(objectClass=inetOrgPerson)' );
- if( $result ) {
- $ldap_object = ldap_get_entries( $ldap->connection, $result );
- if( $ldap_object['count'] == 1 ) {
- fill_form_for_modify( $form, $ldap_object[0] );
- $form->entries['action']['value'] = 'save';
- $form->entries['dn'] = array( 'name' => 'dn',
- 'type' => 'hidden',
- 'value' => $dn );
- $heading = _('Modify External Address');
- $content = $form->outputForm();
- } else {
- array_push($errors, sprintf(_("Error: Multiple results returned for DN %s"), $dn) );
- }
+ $ldap_object = $ldap->read( $dn );
+ if( $ldap_object ) {
+ fill_form_for_modify( $form, $ldap_object );
+ $form->entries['action']['value'] = 'save';
+ $form->entries['dn'] = array( 'name' => 'dn',
+ 'type' => 'hidden',
+ 'value' => $dn );
+ $heading = _('Modify External Address');
+ $content = $form->outputForm();
+ } else {
+ array_push($errors, sprintf(_("Error: No entry with DN %s found"), $dn) );
}
break;
case 'delete':
@@ -263,24 +260,46 @@ if( !$errors ) {
$form->entries[$k]['attrs'] = 'readonly';
}
}
- $result = $ldap->search( $dn, '(objectClass=*)' );
- if( $result ) {
- $ldap_object = ldap_get_entries( $ldap->connection, $result );
- if( $ldap_object['count'] == 1 ) {
- fill_form_for_modify( $form, $ldap_object[0] );
- $form->entries['action']['value'] = 'kill';
- foreach( array_keys($form->entries) as $key ) {
- $form->entries[$key]['attrs'] = 'readonly';
- }
- $form->submittext = _('Delete');
- $heading = _('Delete External Address');
- $content = $form->outputForm();
- } else {
- array_push($errors, sprintf(_("Error: Multiple results returned for DN %s"), $dn) );
+ $ldap_object = $ldap->read( $dn );
+ if( $ldap_object ) {
+ fill_form_for_modify( $form, $ldap_object );
+ $form->entries['action']['value'] = 'kill';
+ foreach( array_keys($form->entries) as $key ) {
+ $form->entries[$key]['attrs'] = 'readonly';
}
+ $form->submittext = _('Delete');
+ $heading = _('Delete External Address');
+ $content = $form->outputForm();
+ } else {
+ array_push($errors, sprintf(_("Error: No entry with DN %s found"), $dn) );
}
break;
case 'kill':
+ // Check for distribution lists with only this user as member
+ $ldap->search( $_SESSION['base_dn'],
+ '(&(objectClass=kolabGroupOfNames)(member='.$ldap->escape($dn).'))',
+ array( 'dn', 'cn', 'mail', 'member' ) );
+ $distlists = $ldap->getEntries();
+ unset($distlists['count']);
+ foreach( $distlists as $distlist ) {
+ $dlmail = $distlist['mail'][0];
+ if( !$dlmail ) $dlmail = $distlist['cn'][0]; # Compatibility with old stuff
+ if( $distlist['member']['count'] == 1 ) {
+ $errors[] = sprintf(_("Account could not be deleted, distribution list '%s' depends on it."), $dlmail);
+ }
+ }
+ if( !$errors ) foreach( $distlists as $distlist ) {
+ $dlmail = $distlist['mail'][0];
+ if( !$dlmail ) $dlmail = $distlist['cn'][0]; # Compatibility with old stuff
+ if( ldap_mod_del( $ldap->connection, $distlist['dn'], array('member' => $dn ) ) ) {
+ $messages[] = sprintf(_("Addressbook entry removed from distribution list '%s'."), $dlmail);
+ } else {
+ $errors[] = sprintf(_("Failure to remove addressbook entry from distribution list '%s', entry will not be deleted."),
+ $dlmail);
+ break;
+ }
+ }
+
if (!$errors) {
if (!($ldap->deleteObject($dn))) {
array_push($errors, sprintf(_("LDAP Error: could not delete %s: %s"),$dn,