From cf46aefd9d8be57722514ab0b6047fa573f46a36 Mon Sep 17 00:00:00 2001
From: Thomas Bruederli <thomas@roundcube.net>
Date: Sat, 28 Sep 2013 06:04:35 -0400
Subject: [PATCH] Make password plugin use the new 'settings_actions' hook to register its link in the settings navigation

---
 program/include/rcmail.php |   27 +++++++++++++++++----------
 1 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/program/include/rcmail.php b/program/include/rcmail.php
index 1c9f3dd..0483f0e 100644
--- a/program/include/rcmail.php
+++ b/program/include/rcmail.php
@@ -481,15 +481,22 @@
         $port = $config['default_port'];
     }
 
-    /* Modify username with domain if required
-       Inspired by Marco <P0L0_notspam_binware.org>
-    */
-    // Check if we need to add domain
-    if (!empty($config['username_domain']) && strpos($username, '@') === false) {
-      if (is_array($config['username_domain']) && isset($config['username_domain'][$host]))
-        $username .= '@'.rcube_utils::parse_host($config['username_domain'][$host], $host);
-      else if (is_string($config['username_domain']))
-        $username .= '@'.rcube_utils::parse_host($config['username_domain'], $host);
+    // Check if we need to add/force domain to username
+    if (!empty($config['username_domain'])) {
+      $domain = is_array($config['username_domain']) ? $config['username_domain'][$host] : $config['username_domain'];
+
+      if ($domain = rcube_utils::parse_host((string)$domain, $host)) {
+        $pos = strpos($username, '@');
+
+        // force configured domains
+        if (!empty($config['username_domain_forced']) && $pos !== false) {
+          $username = substr($username, 0, $pos) . '@' . $domain;
+        }
+        // just add domain if not specified
+        else if ($pos === false) {
+          $username .= '@' . $domain;
+        }
+      }
     }
 
     if (!isset($config['login_lc'])) {
@@ -954,7 +961,7 @@
     /**
      * Write login data (name, ID, IP address) to the 'userlogins' log file.
      */
-    public function log_login($user, $failed_login = false, $error_code = 0)
+    public function log_login($user = null, $failed_login = false, $error_code = 0)
     {
         if (!$this->config->get('log_logins')) {
             return;

--
Gitblit v1.9.1