On Fri, May 30, 2008 at 11:26 AM, Nik Soggia roundcube@telnetwork.it wrote:
Hello everybody, this is my first post in this list.
As soon as I installed roundcubemail, I really appreciated the virtuser_file/virtuser_query config options to automatically fill-in the email address when auto_create_user is set to true, but I was a little disappointed to see that there is no way to automatically set the user's real name. Moreover silently setting the login name as the sender's real name reveals to mail recipients an information that should be usually kept secret.
For these two reasons I wrote this very little patch to add some more automation. you can apply it to svn 1452 directly, with "patch -p1 <this_message" or you can apply it to release 0.1.1 tweaking a file name: "sed 's/rcube_user.php/rcube_user.inc/g' <this_message | patch -p1"
there are two new config entries, leaving both empty preserves the actual behavior.
"passwd_query" works exactly as "virtuser_query", a example query may be: select real_name from some_table where login_name="%u"
"passwd_file" will extract the "gecos" field from a passwd-like file, a example line may be: unixname:x:1000:100:John Doe:/usr/share/empty:/bin/false
I hope that this very little unintrusive patch will be included in the next release :)
diff -Naubr roundcubemail.old/config/main.inc.php.dist roundcubemail.new/config/main.inc.php.dist --- roundcubemail.old/config/main.inc.php.dist 2008-05-29 17:21:51.000000000 +0200 +++ roundcubemail.new/config/main.inc.php.dist 2008-05-29 17:19:21.000000000 +0200 @@ -61,6 +61,14 @@ // The query should select the user's e-mail address as first col $rcmail_config['virtuser_query'] = '';
+// Path to a passwd-like file to get real name from user name +$rcmail_config['passwd_file'] = '';
+// Query to get real name from user name +// %u will be replaced with the current username for login. +// The query should select the user's real name as first col +$rcmail_config['passwd_query'] = '';
// use this host for sending mails. // to use SSL connection, set ssl://smtp.host.com // if left blank, the PHP mail() function is used diff -Naubr roundcubemail.old/program/include/rcube_user.php roundcubemail.new/program/include/rcube_user.php --- roundcubemail.old/program/include/rcube_user.php 2008-05-29 17:21:54.000000000 +0200 +++ roundcubemail.new/program/include/rcube_user.php 2008-05-29 17:39:45.000000000 +0200 @@ -368,6 +368,25 @@ $user_email = strpos($user, '@') ? $user : sprintf('%s@%s', $user, $mail_domain);
$user_name = $user != $user_email ? $user : '';
if (!empty($CONFIG['passwd_file'])) {
if ($fp = fopen ($CONFIG['passwd_file'], 'r')) {
do {
$line = explode (':', fgets ($fp));
if ((count ($line) >= 5) && ($line[0] == $user)) {
$user_name = $line[4];
break;
}
} while (feof ($fp) == FALSE);
fclose ($fp);
}
}
if (!empty($CONFIG['passwd_query'])) {
if ($sql_result = $DB->query (preg_replace('/%u/', $DB->escapeSimple($user), $CONFIG['passwd_query']))) {
while ($sql_arr = $DB->fetch_array($sql_result)) {
$user_name = $sql_arr[0];
}
}
} // try to resolve the e-mail address from the virtuser table if ($virtuser_query = $rcmail->config->get('virtuser_query') &&
With virtual users, who has a /etc/passwd that matches your mail accounts? What are the chances? ;-) _______________________________________________ List info: http://lists.roundcube.net/dev/