Fix broken mail acl editor

This commit is contained in:
Hadi Nategh 2017-03-14 14:49:29 +01:00
parent cbfa9e1d14
commit 1992cd4e14
2 changed files with 25 additions and 8 deletions

View File

@ -203,8 +203,7 @@ class mail_acl
//Make the account owner's fields all readonly as owner has all rights and should not be able to change them //Make the account owner's fields all readonly as owner has all rights and should not be able to change them
foreach($content['grid'] as $key => $fields) foreach($content['grid'] as $key => $fields)
{ {
if ($fields['acc_id'] == $this->imap->acc_imap_username || if (self::_extract_acc_id($fields['acc_id']) == $this->imap->acc_imap_username)
$fields['acc_id'][0] == $this->imap->acc_imap_username)
{ {
foreach (array_keys($fields) as $index) foreach (array_keys($fields) as $index)
{ {
@ -215,6 +214,12 @@ class mail_acl
$preserv ['grid'][$key] = $fields; $preserv ['grid'][$key] = $fields;
$preserv['grid'][$key]['acl_recursive'] = false; $preserv['grid'][$key]['acl_recursive'] = false;
} }
if (count($content['grid']) != $key)
{
$preserv ['grid'][$key]['acc_id'] = self::_extract_acc_id($fields['acc_id']);
$preserv['grid'][$key]['acl_recursive'] = false;
$readonlys['grid'][$key]['acc_id'] = true;
}
} }
//Make entry row's delete button readonly //Make entry row's delete button readonly
$readonlys['grid']['delete['.count($content['grid']).']'] = true; $readonlys['grid']['delete['.count($content['grid']).']'] = true;
@ -303,8 +308,8 @@ class mail_acl
$options['rights'] .= $right[1]; $options['rights'] .= $right[1];
} }
} }
$username = $content['grid'][$keys]['acc_id'] == $this->imap->acc_imap_username $username = self::_extract_acc_id($content['grid'][$keys]['acc_id']);
?$content['grid'][$keys]['acc_id']:$content['grid'][$keys]['acc_id'][0];
//error_log(__METHOD__."(".__LINE__.") setACL($content[mailbox], $username, ".array2string($options).", $recursive)"); //error_log(__METHOD__."(".__LINE__.") setACL($content[mailbox], $username, ".array2string($options).", $recursive)");
if (is_numeric($username) && ($u = $this->imap->getMailBoxUserName($username))) if (is_numeric($username) && ($u = $this->imap->getMailBoxUserName($username)))
{ {
@ -370,8 +375,8 @@ class mail_acl
$row_num = array_keys($content['grid']['delete'],"pressed"); $row_num = array_keys($content['grid']['delete'],"pressed");
if ($row_num) $row_num = $row_num[0]; if ($row_num) $row_num = $row_num[0];
$recursive = $content['grid'][$row_num]['acl_recursive']; $recursive = $content['grid'][$row_num]['acl_recursive'];
$identifier = $content['grid'][$row_num]['acc_id'][0]; $identifier = self::_extract_acc_id($content['grid'][$row_num]['acc_id']);
if (is_array($content['mailbox'])) $content['mailbox'] = $content['mailbox'][0]; $content['mailbox'] = is_array($content['mailbox'])? $content['mailbox'][0] : $content['mailbox'];
if (is_numeric($identifier) && ($u = $this->imap->getMailBoxUserName($identifier))) if (is_numeric($identifier) && ($u = $this->imap->getMailBoxUserName($identifier)))
{ {
$identifier = $u; $identifier = $u;
@ -513,4 +518,16 @@ class mail_acl
return false; return false;
} }
} }
/**
* Method to get acc_id id value whether if is a flat value or an array
*
* @param type $acc_id acc_id value comming from client-side
*
* @return string returns acc_id in flat format
*/
private static function _extract_acc_id ($acc_id)
{
return is_array($acc_id)?$acc_id[0]:$acc_id;
}
} }

View File

@ -14,7 +14,7 @@
</row> </row>
<row> <row>
<description value="Folder"/> <description value="Folder"/>
<taglist id="mailbox" width="100%" maxSelection="1" autocomplete_params='' allowFreeEntries="false" onchange='app.mail.acl_folderChange'/> <taglist id="mailbox" width="100%" maxSelection="1" allowFreeEntries="false" onchange='app.mail.acl_folderChange'/>
</row> </row>
<row> <row>
<description value="Rights"/> <description value="Rights"/>
@ -84,7 +84,7 @@
<hbox> <hbox>
<button label="Save" id="button[save]"/> <button label="Save" id="button[save]"/>
<button label="Apply" id="button[apply]"/> <button label="Apply" id="button[apply]"/>
<button label="Cancel" id="button[cancel]"/> <buttononly label="Cancel" id="button[cancel]" onclick="window.close()"/>
</hbox> </hbox>
</row> </row>
</rows> </rows>