summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authoralec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c>2011-07-06 17:59:12 +0000
committeralec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c>2011-07-06 17:59:12 +0000
commitac1af6d3daf377002fb9875c49dde0a0025a980a (patch)
treea534ec9b99cbd351d32083a38d0cdf3ec1d0cd85 /plugins
parentbc395f96d37bf50bfe22745afae3976876026369 (diff)
Fix new_user_identity after some changes in rcube_ldap class (#1487758)
git-svn-id: https://svn.roundcube.net/trunk@4915 208e9e7b-5314-0410-a742-e7e81cd9613c
Diffstat (limited to 'plugins')
-rw-r--r--plugins/new_user_identity/new_user_identity.php46
1 files changed, 38 insertions, 8 deletions
diff --git a/plugins/new_user_identity/new_user_identity.php b/plugins/new_user_identity/new_user_identity.php
index 45750facd..a8894a299 100644
--- a/plugins/new_user_identity/new_user_identity.php
+++ b/plugins/new_user_identity/new_user_identity.php
@@ -15,7 +15,7 @@
* // user's full name in their new identity. (This should be an
* // string, which refers to the $rcmail_config['ldap_public'] array.)
* $rcmail_config['new_user_identity_addressbook'] = 'People';
- *
+ *
* // When automatically setting a new users's full name in their
* // new identity, match the user's login name against this field.
* $rcmail_config['new_user_identity_match'] = 'uid';
@@ -24,6 +24,8 @@ class new_user_identity extends rcube_plugin
{
public $task = 'login';
+ private $ldap;
+
function init()
{
$this->add_hook('user_create', array($this, 'lookup_user_name'));
@@ -31,12 +33,8 @@ class new_user_identity extends rcube_plugin
function lookup_user_name($args)
{
- $rcmail = rcmail::get_instance();
- if ($addressbook = $rcmail->config->get('new_user_identity_addressbook')) {
- $match = $rcmail->config->get('new_user_identity_match');
- $ldap = $rcmail->get_address_book($addressbook);
- $ldap->prop['search_fields'] = array($match);
- $results = $ldap->search($match, $args['user'], TRUE);
+ if ($this->init_ldap()) {
+ $results = $this->ldap->search('*', $args['user'], TRUE);
if (count($results->records) == 1) {
$args['user_name'] = $results->records[0]['name'];
if (!$args['user_email'] && strpos($results->records[0]['email'], '@')) {
@@ -46,5 +44,37 @@ class new_user_identity extends rcube_plugin
}
return $args;
}
+
+ private function init_ldap()
+ {
+ if ($this->ldap)
+ return $this->ldap->ready;
+
+ $rcmail = rcmail::get_instance();
+
+ $addressbook = $rcmail->config->get('new_user_identity_addressbook');
+ $ldap_config = (array)$rcmail->config->get('ldap_public');
+ $match = $rcmail->config->get('new_user_identity_match');
+
+ if (empty($addressbook) || empty($match) || empty($ldap_config[$addressbook])) {
+ return false;
+ }
+
+ $this->ldap = new new_user_identity_ldap_backend(
+ $ldap_config[$addressbook],
+ $rcmail->config->get('ldap_debug'),
+ $rcmail->config->mail_domain($_SESSION['imap_host']),
+ $match);
+
+ return $this->ldap->ready;
+ }
+}
+
+class new_user_identity_ldap_backend extends rcube_ldap
+{
+ function __construct($p, $debug=false, $mail_domain=NULL, $search=null)
+ {
+ parent::__construct($p, $debug, $mail_domain);
+ $this->prop['search_fields'] = $search;
+ }
}
-?>