fix not working folder ACL

This commit is contained in:
ralf 2022-05-04 16:52:37 +02:00
parent 94eeebbfd6
commit db07f6bb71

View File

@ -117,7 +117,7 @@ class mail_acl
$tmpl = new Etemplate('mail.acl'); $tmpl = new Etemplate('mail.acl');
if (!is_array($content)) if (!is_array($content))
{ {
$acc_id = $_GET['acc_id']?$_GET['acc_id']:$GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID']; $acc_id = $_GET['acc_id'] ?? $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'];
if (isset($_GET['account_id']) && !isset($GLOBALS['egw_info']['user']['apps']['admin'])) if (isset($_GET['account_id']) && !isset($GLOBALS['egw_info']['user']['apps']['admin']))
{ {
Framework::window_close(lang('Permission denied')); Framework::window_close(lang('Permission denied'));
@ -154,25 +154,27 @@ class mail_acl
if (!empty($mailbox)) if (!empty($mailbox))
{ {
$content['mailbox'] = $mailbox; $content['mailbox'] = $mailbox;
$acl = (array)$this->retrieve_acl($mailbox, $msg); if (($acls = $this->retrieve_acl($mailbox, $msg)) === false)
if ($acl[0] === FALSE)
{ {
Api\Framework::window_close($msg); Api\Framework::window_close($msg);
} }
$n = 1; $n = 1;
foreach ($acl as $key => $value) foreach ($acls as $key => $acl)
{ {
$parts = array_values((array)$value); $rights = [];
$virtuals = array_pop($parts); foreach ($acl->getIterator() as $right)
$rights = array_shift($parts); {
$content['grid'][$n]['acl_'. $right] = true;
foreach ($rights as $right) $rights[] = $right;
}
$virtual = $acl->getString(Horde_Imap_Client_Data_Acl::RFC_2086);
foreach(['c', 'd'] as $right)
{
if (strpos($virtual, $right) !== false)
{ {
$content['grid'][$n]['acl_'. $right] = true; $content['grid'][$n]['acl_'. $right] = true;
} }
$virtualD = array('e','t'); }
$content['grid'][$n]['acl_c'] = array_diff($virtuals['c'] ?? [], array_intersect($rights, $virtuals['c'] ?? []))? false: true; //c=kx more information rfc4314, Obsolete Rights
$content['grid'][$n]['acl_d'] = array_diff($virtualD,array_intersect($rights,$virtuals['d'] ?? []))? false: true; //d=et more information rfc4314, Obsolete Rights
sort($rights); sort($rights);
$acl_abbrvs = implode('',$rights); $acl_abbrvs = implode('',$rights);
@ -351,11 +353,11 @@ class mail_acl
unset($value['acl']); unset($value['acl']);
$options = array(); $options = array();
foreach (array_keys($value) as $key) foreach ($value as $key => $set)
{ {
if ($value[$key] == true) if ($set)
{ {
$right = explode("acl_" ,$key); $right = explode("acl_", $key);
if ($right[1] === 'c') $right[1] = 'kx'; // c = kx , rfc 4314 if ($right[1] === 'c') $right[1] = 'kx'; // c = kx , rfc 4314
if ($right[1] === 'd') $right[1] = 'et'; // d = et , rfc 4314 if ($right[1] === 'd') $right[1] = 'et'; // d = et , rfc 4314
$options['rights'] .= $right[1]; $options['rights'] .= $right[1];
@ -401,12 +403,12 @@ class mail_acl
* @param string $mailbox * @param string $mailbox
* @param string &$msg * @param string &$msg
* *
* @return Array | Boolean returns array of acl or false on failure * @return Horde_Imap_Client_Data_Acl[]|false returns array of acl or false on failure
* @todo rights 'c' and 'd' should be fixed * @todo rights 'c' and 'd' should be fixed
*/ */
function retrieve_acl ($mailbox, &$msg) function retrieve_acl ($mailbox, &$msg)
{ {
if (($acl = $this->getACL($mailbox))) if (($acl = $this->getACL($mailbox)) !== false)
{ {
$msg = lang('ACL rights retrieved successfully'); $msg = lang('ACL rights retrieved successfully');
return $acl; return $acl;
@ -563,7 +565,7 @@ class mail_acl
* Get ACL rights of a folder from an account * Get ACL rights of a folder from an account
* *
* @param String $mailbox folder name that needs to be read * @param String $mailbox folder name that needs to be read
* @return Array|Boolean FALSE in case of any exceptions and returns Array in case of success, * @return Horde_Imap_Client_Data_Acl[]|false FALSE in case of any exceptions and returns Array in case of success,
*/ */
function getACL ($mailbox) function getACL ($mailbox)
{ {