Thomas Bruederli
2014-08-19 fc52af24f1418d6590a2d37a0d8cc31b123e38f6
plugins/acl/acl.php
@@ -128,8 +128,10 @@
     */
    function folder_form($args)
    {
        // Edited folder name (empty in create-folder mode)
        $mbox_imap = $args['options']['name'];
        $myrights  = $args['options']['rights'];
        // Edited folder name (empty in create-folder mode)
        if (!strlen($mbox_imap)) {
            return $args;
        }
@@ -139,18 +141,8 @@
            return $args;
        }
*/
        // Namespace root
        if ($args['options']['is_root']) {
            return $args;
        }
        // Get MYRIGHTS
        if (!($myrights = $args['options']['rights'])) {
            return $args;
        }
        // Do nothing if no ACL support
        if (!$this->rc->storage->get_capability('ACL')) {
        if (empty($myrights)) {
            return $args;
        }
@@ -241,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(
@@ -441,8 +433,9 @@
        $acl   = trim(get_input_value('_acl', RCUBE_INPUT_GPC));
        $oldid = trim(get_input_value('_old', RCUBE_INPUT_GPC));
        $acl   = array_intersect(str_split($acl), $this->rights_supported());
        $users = $oldid ? array($user) : explode(',', $user);
        $acl    = array_intersect(str_split($acl), $this->rights_supported());
        $users  = $oldid ? array($user) : explode(',', $user);
        $result = 0;
        foreach ($users as $user) {
            $user = trim($user);
@@ -450,7 +443,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));
                }
@@ -460,6 +453,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)) {
@@ -623,7 +619,7 @@
    private function get_realm()
    {
        // When user enters a username without domain part, realm
        // alows to add it to the username (and display correct username in the table)
        // allows to add it to the username (and display correct username in the table)
        if (isset($_SESSION['acl_username_realm'])) {
            return $_SESSION['acl_username_realm'];
@@ -712,4 +708,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;
    }
}