From 48e9c14ebded89d858c8be0333f77f77a81b0877 Mon Sep 17 00:00:00 2001 From: thomascube Date: Sat, 31 Mar 2012 12:25:48 +0000 Subject: Move plugins repository into roundcubemail root folder; svn:externals are not defined anymore --- plugins/new_user_identity/new_user_identity.php | 89 +++++++++++++++++++++++++ plugins/new_user_identity/package.xml | 49 ++++++++++++++ 2 files changed, 138 insertions(+) create mode 100644 plugins/new_user_identity/new_user_identity.php create mode 100644 plugins/new_user_identity/package.xml (limited to 'plugins/new_user_identity') diff --git a/plugins/new_user_identity/new_user_identity.php b/plugins/new_user_identity/new_user_identity.php new file mode 100644 index 000000000..7b67578bf --- /dev/null +++ b/plugins/new_user_identity/new_user_identity.php @@ -0,0 +1,89 @@ +add_hook('user_create', array($this, 'lookup_user_name')); + } + + function lookup_user_name($args) + { + $rcmail = rcmail::get_instance(); + + if ($this->init_ldap($args['host'])) { + $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'], '@')) { + $args['user_email'] = rcube_idn_to_ascii($results->records[0]['email']); + } + if (($alias_col = $rcmail->config->get('new_user_identity_alias')) && $results->records[0][$alias_col]) { + $args['alias'] = $results->records[0][$alias_col]; + } + } + } + return $args; + } + + private function init_ldap($host) + { + 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($host), + $match); + + return $this->ldap->ready; + } +} + +class new_user_identity_ldap_backend extends rcube_ldap +{ + function __construct($p, $debug, $mail_domain, $search) + { + parent::__construct($p, $debug, $mail_domain); + $this->prop['search_fields'] = (array)$search; + } +} diff --git a/plugins/new_user_identity/package.xml b/plugins/new_user_identity/package.xml new file mode 100644 index 000000000..95f1dc0dc --- /dev/null +++ b/plugins/new_user_identity/package.xml @@ -0,0 +1,49 @@ + + + new_user_identity + pear.roundcube.net + Populates a new user's default identity from LDAP on their first visit. + + Populates a new user's default identity from LDAP on their first visit. + + + Aleksander Machniak + alec + alec@alec.pl + yes + + 2011-11-21 + + 1.0.5 + 1.0 + + + stable + stable + + GNU GPLv2 + - + + + + + + + + + + + + + 5.2.1 + + + 1.7.0 + + + + + -- cgit v1.2.3