Aleksander Machniak
2012-06-28 9899abc36caf00ed2a054b309607aa868e314e07
plugins/acl/acl.php
@@ -3,7 +3,7 @@
/**
 * Folders Access Control Lists Management (RFC4314, RFC2086)
 *
 * @version 0.6.3
 * @version @package_version@
 * @author Aleksander Machniak <alec@alec.pl>
 *
 *
@@ -129,8 +129,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;
        }
@@ -140,18 +142,17 @@
            return $args;
        }
*/
        // Namespace root
        if ($args['options']['is_root']) {
            return $args;
        }
        // Get MYRIGHTS
<<<<<<< HEAD
        if (!($myrights = $args['options']['rights'])) {
            return $args;
        }
        // Do nothing if no ACL support
        if (!$this->rc->imap->get_capability('ACL')) {
=======
        if (empty($myrights)) {
>>>>>>> e4c9942... Fix handling of MYRIGHTS on private namespace roots - fixes issue where
            return $args;
        }
@@ -441,26 +442,37 @@
        $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());
        $acl   = array_intersect(str_split($acl), $this->rights_supported());
        $users = $oldid ? array($user) : explode(',', $user);
        if (!empty($this->specials) && in_array($user, $this->specials)) {
            $username = $this->gettext($user);
        }
        else {
            if (!strpos($user, '@') && ($realm = $this->get_realm())) {
                $user .= '@' . rcube_idn_to_ascii(preg_replace('/^@/', '', $realm));
        foreach ($users as $user) {
            $user = trim($user);
            if (!empty($this->specials) && in_array($user, $this->specials)) {
                $username = $this->gettext($user);
            }
            $username = $user;
        }
            else {
                if (!strpos($user, '@') && ($realm = $this->get_realm())) {
                    $user .= '@' . rcube_idn_to_ascii(preg_replace('/^@/', '', $realm));
                }
                $username = $user;
            }
        if ($acl && $user && $user != $_SESSION['username'] && strlen($mbox)) {
            $result = $this->rc->imap->set_acl($mbox, $user, $acl);
            if (!$acl || !$user || !strlen($mbox)) {
                continue;
            }
            if ($user != $_SESSION['username'] && $username != $_SESSION['username']) {
                if ($this->rc->imap->set_acl($mbox, $user, $acl)) {
                    $ret = array('id' => html_identifier($user),
                         'username' => $username, 'acl' => implode($acl), 'old' => $oldid);
                    $this->rc->output->command('acl_update', $ret);
                    $result++;
                }
            }
        }
        if ($result) {
            $ret = array('id' => html_identifier($user),
                 'username' => $username, 'acl' => implode($acl), 'old' => $oldid);
            $this->rc->output->command('acl_update', $ret);
            $this->rc->output->show_message($oldid ? 'acl.updatesuccess' : 'acl.createsuccess', 'confirmation');
        }
        else {
@@ -479,6 +491,7 @@
        $user = explode(',', $user);
        foreach ($user as $u) {
            $u = trim($u);
            if ($this->rc->imap->delete_acl($mbox, $u)) {
                $this->rc->output->command('acl_remove_row', html_identifier($u));
            }
@@ -627,7 +640,6 @@
            $acl = $this->rc->imap->get_acl('INBOX');
            if (is_array($acl)) {
                $regexp = '/^' . preg_quote($_SESSION['username'], '/') . '@(.*)$/';
                $regexp = '/^' . preg_quote('aleksander.machniak', '/') . '@(.*)$/';
                foreach (array_keys($acl) as $name) {
                    if (preg_match($regexp, $name, $matches)) {
                        $domain = $matches[1];