Opened 7 years ago

Closed 6 years ago

Last modified 5 years ago

#1484002 closed Feature Patches (fixed)

Add multiple identities from virtuser_query

Reported by: wobin Owned by:
Priority: 5 Milestone:
Component: Database Version: 0.1-beta
Severity: normal Keywords: identities virtuser_query
Cc:

Description (last modified by thomasb)

This patch allows RoundCube to add all identities found with virtuser_query, instead of only the first one, when a user logs on for the first time:

Index: program/include/main.inc
===================================================================
--- program/include/main.inc	(revision 336)
+++ program/include/main.inc	(working copy)
@@ -530,18 +530,28 @@
 	if (!empty($CONFIG['virtuser_query']))
 	  {
       $sql_result = $DB->query(preg_replace('/%u/', $user, $CONFIG['virtuser_query']));
-      if ($sql_arr = $DB->fetch_array($sql_result))
+      while ($sql_arr = $DB->fetch_array($sql_result))
+        {
         $user_email = $sql_arr[0];
+        $DB->query("INSERT INTO `.get_table_name('identities').`
+                    (user_id, del, standard, name, email)
+                    VALUES (?, 0, 1, ?, ?)",
+                    $user_id,
+                    $user_name,
+                    preg_replace('/^@/', $user . '@', $user_email));
+        }
       }
+    else
+      {
+      // also create new identity records
+      $DB->query("INSERT INTO `.get_table_name('identities').`
+                  (user_id, del, standard, name, email)
+                  VALUES (?, 0, 1, ?, ?)",
+                  $user_id,
+                  $user_name,
+                  $user_email);
+      }
 
-    // also create new identity records
-    $DB->query("INSERT INTO `.get_table_name('identities').`
-                (user_id, del, standard, name, email)
-                VALUES (?, 0, 1, ?, ?)",
-                $user_id,
-                $user_name,
-                $user_email);
-
                        
     // get existing mailboxes
     $a_mailboxes = $IMAP->list_mailboxes();

Change History (2)

comment:1 Changed 7 years ago by thomasb

  • Description modified (diff)
  • Type changed from Bugs to Patches

comment:2 Changed 6 years ago by robin

  • Resolution set to fixed
  • Status changed from new to closed

I commited this in SVN371.

Note: See TracTickets for help on using tickets.