Author Topic: SVN 437 : virtuser_query and virtuser_file  (Read 7248 times)

Offline devil1591

  • Newbie
  • *
  • Posts: 2
SVN 437 : virtuser_query and virtuser_file
« on: December 28, 2006, 10:08:46 AM »
Hello,
I made a little mod for virtuser_query and virtuser_file !

in program/include/main.inc line 513 remove
Code: [Select]
// try to resolve email address from virtuser table  
 if (!empty($CONFIG['virtuser_file']) && strstr($user, '@'))
  $user = rcmail_email2user($user);

in program/include/main.inc line 497 add
Code: [Select]
/*
 ** devil1591
 */

 // try to resolve email address from virtuser table  
 if (!empty($CONFIG['virtuser_file']) && strstr($user, '@'))
  $user = rcmail_email2user($user);

 // try to resolve the e-mail address from the virtuser table
 if (!empty($CONFIG['virtuser_query']) && !strstr($user, '@'))
 {
   $sql_result = $DB->query(preg_replace('/%u/', $user, $CONFIG['virtuser_query']));
   if ($DB->num_rows()>0) {
 while ($sql_arr = $DB->fetch_array($sql_result)) {
$user = $sql_arr[0];
 }
   }
 }

in fact, this improvement will check if an email can be found in the query or file from config.
In this case, the webmail will try to login to the IMAP.
If a user already exist in our DB, it'll use it, if not, it will create a new one...

I made this mod in order to login with Wordpress login with the email associated to this login
ex : admin is associated to devil@yahoo.com
my virtuser_query config :
Code: [Select]
$rcmail_config['virtuser_query'] = "SELECT meta_value FROM wordpresstable.wp_users WHERE user_login = '%u'";
I hope this will be incorporated in latest svn :P