Support Organization field in identities.

Fix purging identities - use the same email fields as in kolab_auth.
This commit is contained in:
Aleksander Machniak 2012-12-19 15:31:14 +01:00
parent 035bd6fc3b
commit cbd97e52cd
3 changed files with 31 additions and 28 deletions

View file

@ -1,25 +1,14 @@
<?php
// This will overwrite defined LDAP filter
// Note: LDAP addressbook defined for kolab_auth plugin is used
$rcmail_config['kolab_delegation_filter'] = '(objectClass=kolabInetOrgPerson)';
// Delegates field (from fieldmap configuration) to get delegates list
// Note: This is a field name, not LDAP attribute name
// Note: LDAP addressbook defined for kolab_auth plugin is used
$rcmail_config['kolab_delegation_delegate_field'] = 'kolabDelegate';
// User authentication ID field (from fieldmap configuration)
// Note: This is a field name, not LDAP attribute name
// See kolab_auth plugin config
$rcmail_config['kolab_delegation_login_field'] = 'email';
// Use this fields (from fieldmap configuration) for identities
// If the value array contains more than one field, first non-empty will be used
// Note: These aren't LDAP attributes, but field names in config
// Note: If there's more than one email address, as many identities will be created
// See kolab_auth plugin config
$rcmail_config['kolab_delegation_name_field'] = array('name', 'cn');
$rcmail_config['kolab_delegation_email_field'] = array('email');
// Remove all user identities which do not match the user's primary or alias
// addresses and delegator's addresses
$rcmail_config['kolab_delegation_purge_identities'] = false;

View file

@ -33,6 +33,7 @@ class kolab_delegation_engine
private $ldap_login_field;
private $ldap_name_field;
private $ldap_email_field;
private $ldap_org_field;
private $ldap_dn;
private $cache = array();
private $folder_types = array('mail', 'event', 'task');
@ -46,19 +47,6 @@ class kolab_delegation_engine
public function __construct()
{
$this->rc = rcube::get_instance();
// Default filter of LDAP queries
$this->ldap_filter = $this->rc->config->get('kolab_delegation_filter');
// Name of the LDAP field for delegates list
$this->ldap_delegate_field = $this->rc->config->get('kolab_delegation_delegate_field');
// Name of the LDAP field with authentication ID
$this->ldap_login_field = $this->rc->config->get('kolab_delegation_login_field');
// Name of the LDAP field with user name used for identities
$this->ldap_name_field = $this->rc->config->get('kolab_delegation_name_field');
// Name of the LDAP field with email addresses used for identities
$this->ldap_email_field = $this->rc->config->get('kolab_delegation_email_field');
// Encoded LDAP DN of current user, set on login by kolab_auth plugin
$this->ldap_dn = $_SESSION['kolab_dn'];
}
/**
@ -234,6 +222,22 @@ class kolab_delegation_engine
return null;
}
// Default filter of LDAP queries
$this->ldap_filter = $this->rc->config->get('kolab_delegation_filter');
// Name of the LDAP field for delegates list
$this->ldap_delegate_field = $this->rc->config->get('kolab_delegation_delegate_field');
// Encoded LDAP DN of current user, set on login by kolab_auth plugin
$this->ldap_dn = $_SESSION['kolab_dn'];
// Name of the LDAP field with authentication ID
$this->ldap_login_field = $this->rc->config->get('kolab_auth_login');
// Name of the LDAP field with user name used for identities
$this->ldap_name_field = $this->rc->config->get('kolab_auth_name');
// Name of the LDAP field with email addresses used for identities
$this->ldap_email_field = $this->rc->config->get('kolab_auth_email');
// Name of the LDAP field with organization name for identities
$this->ldap_org_field = $this->rc->config->get('kolab_auth_organization');
$ldap->set_filter($this->ldap_filter);
return $ldap;
@ -470,6 +474,14 @@ class kolab_delegation_engine
}
}
// Organization for identity
foreach ((array)$this->ldap_org_field as $field) {
$organization = is_array($data[$field]) ? $data[$field][0] : $data[$field];
if (!empty($organization)) {
break;
}
}
$realname = $name;
if ($uid && $name) {
$name .= ' (' . $uid . ')';
@ -491,6 +503,7 @@ class kolab_delegation_engine
'imap_uid' => $imap_uid,
'email' => $email,
'ID' => $data['ID'],
'organization' => $organization,
);
}
@ -610,6 +623,7 @@ class kolab_delegation_engine
// @TODO: "Delegatorname" or "Username on behalf of Delegatorname"?
$default['name'] = $delegator['realname'];
$default['email'] = $email;
$default['organization'] = $delegator['organization'];
$this->rc->user->insert_identity($default);
}

View file

@ -15,9 +15,9 @@
<email>machniak@kolabsys.com</email>
<active>yes</active>
</lead>
<date>2012-12-04</date>
<date>2012-12-19</date>
<version>
<release>0.1</release>
<release>0.2</release>
<api>0.1</api>
</version>
<stability>