]> git.donarmstrong.com Git - roundcube.git/blobdiff - plugins/new_user_identity/new_user_identity.php
Imported Debian patch 0.5.2+dfsg-1
[roundcube.git] / plugins / new_user_identity / new_user_identity.php
index 75595693c8f7ba4ad7f4d9a52fe808ebe255d8b8..45750facd46d9ddf5d0a14efbc0df700c6cfa323 100644 (file)
  *  // 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';
- *  
- *  // Use the value in this field to automatically set a new users's
- *  // full name in their new identity.
- *  $rcmail_config['new_user_identity_field'] = 'name';
  */
 class new_user_identity extends rcube_plugin
 {
+    public $task = 'login';
+
     function init()
     {
-        $this->add_hook('create_user', array($this, 'lookup_user_name'));
+        $this->add_hook('user_create', array($this, 'lookup_user_name'));
     }
 
     function lookup_user_name($args)
@@ -40,7 +38,10 @@ class new_user_identity extends rcube_plugin
             $ldap->prop['search_fields'] = array($match);
             $results = $ldap->search($match, $args['user'], TRUE);
             if (count($results->records) == 1) {
-                $args['user_name'] = $results->records[0][$rcmail->config->get('new_user_identity_field')];
+                $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']);
+                }
             }
         }
         return $args;