From f5584cbfeb098fbf26f57c74fa36464a634e2397 Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Fri, 01 Mar 2013 11:46:41 -0500
Subject: [PATCH] Fixed ACL edition in advanced mode

---
 plugins/acl/acl.php |   26 ++++++++++++++++++++++++--
 1 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/plugins/acl/acl.php b/plugins/acl/acl.php
index 1442504..a4abe28 100644
--- a/plugins/acl/acl.php
+++ b/plugins/acl/acl.php
@@ -233,7 +233,7 @@
 
         // Advanced rights
         $attrib['id'] = 'advancedrights';
-        foreach ($supported as $val) {
+        foreach ($supported as $key => $val) {
             $id = "acl$val";
             $ul .= html::tag('li', null,
                 $input->show('', array(
@@ -442,7 +442,7 @@
             if (!empty($this->specials) && in_array($user, $this->specials)) {
                 $username = $this->gettext($user);
             }
-            else {
+            else if (!empty($user)) {
                 if (!strpos($user, '@') && ($realm = $this->get_realm())) {
                     $user .= '@' . rcube_idn_to_ascii(preg_replace('/^@/', '', $realm));
                 }
@@ -452,6 +452,9 @@
             if (!$acl || !$user || !strlen($mbox)) {
                 continue;
             }
+
+            $user     = $this->mod_login($user);
+            $username = $this->mod_login($username);
 
             if ($user != $_SESSION['username'] && $username != $_SESSION['username']) {
                 if ($this->rc->storage->set_acl($mbox, $user, $acl)) {
@@ -704,4 +707,23 @@
 
         return $this->ldap->ready;
     }
+
+    /**
+     * Modify user login according to 'login_lc' setting
+     */
+    protected function mod_login($user)
+    {
+        $login_lc = $this->rc->config->get('login_lc');
+
+        if ($login_lc === true || $login_lc == 2) {
+            $user = mb_strtolower($user);
+        }
+        // lowercase domain name
+        else if ($login_lc && strpos($user, '@')) {
+            list($local, $domain) = explode('@', $user);
+            $user = $local . '@' . mb_strtolower($domain);
+        }
+
+        return $user;
+    }
 }

--
Gitblit v1.9.1