From fccdf16364bec9a15d9f44e0197f1653b0109c91 Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Thu, 02 Jul 2009 06:52:48 -0400
Subject: [PATCH] - check virtuser before create_user hook (#1485950) + one if statement improvement

---
 program/include/rcube_user.php |   27 ++++++++++++++-------------
 1 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/program/include/rcube_user.php b/program/include/rcube_user.php
index e02ed49..d933aa3 100644
--- a/program/include/rcube_user.php
+++ b/program/include/rcube_user.php
@@ -359,21 +359,23 @@
     $user_email = '';
     $rcmail = rcmail::get_instance();
 
-    $data = $rcmail->plugins->exec_hook('create_user', array('user'=>$user, 'user_name'=>$user_name, 'user_email'=>$user_email));
-    $user_name = $data['user_name'];
-    $user_email = $data['user_email'];
-    
+    // try to resolve user in virtuser table and file
+    if (!strpos($user, '@')) {
+      if ($email_list = self::user2email($user, false, true))
+        $user_email = is_array($email_list[0]) ? $email_list[0][0] : $email_list[0];
+    }
+
+    $data = $rcmail->plugins->exec_hook('create_user',
+	array('user'=>$user, 'user_name'=>$user_name, 'user_email'=>$user_email));
+
     // plugin aborted this operation
     if ($data['abort'])
       return false;
 
-    $dbh = $rcmail->get_dbh();
+    $user_name = $data['user_name'];
+    $user_email = $data['user_email'];
 
-    // try to resolve user in virtuser table and file
-    if ($user_email != '' && !strpos($user, '@')) {
-      if ($email_list = self::user2email($user, false, true))
-        $user_email = is_array($email_list[0]) ? $email_list[0][0] : $email_list[0];
-    }
+    $dbh = $rcmail->get_dbh();
 
     $dbh->query(
       "INSERT INTO ".get_table_name('users')."
@@ -400,10 +402,9 @@
       }
 
       if (empty($email_list))
-        $email_list[] = strip_newlines($user_email); 
-
+        $email_list[] = strip_newlines($user_email);
       // identities_level check
-      if (count($email_list) > 1 && $rcmail->config->get('identities_level', 0) > 1)
+      else if (count($email_list) > 1 && $rcmail->config->get('identities_level', 0) > 1)
         $email_list = array($email_list[0]);
 
       // create new identities records

--
Gitblit v1.9.1