Mail folder ACLs feature on mail app

This commit is contained in:
Hadi Nategh 2013-11-15 17:22:46 +00:00
parent f8752688e0
commit 34827545cc
4 changed files with 209 additions and 3 deletions

View File

@ -0,0 +1,102 @@
<?php
/**
* EGroupware - Mail Folder ACL- interface class
*
* @link http://www.egroupware.org
* @package mail
* @author Hadi Nategh [hn@stylite.de]
* @copyright (c) 2013 by Stylite AG <info-AT-stylite.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version
*/
class mail_acl
{
/**
* Methods callable via menuaction
*
* @var array
*/
var $public_functions = array(
'edit' => True,
);
/**
* instance of mail_bo
*
* @var mail_bo
*/
var $mail_bo;
/**
*
* @var mail_account
*/
var $current_account;
/**
* Constructor
*
*
*/
function __construct()
{
$this->mail_bo = mail_bo::getInstance(false, (int)$GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID']);
$this->current_account = $this->mail_bo->icServer->acc_imap_username;
}
/**
* Edit folder ACLs for account(s)
*
* @param string $msg
* @param array $content
*/
function edit(array $content=null ,$msg='')
{
if (!is_array($content))
{
$mailbox = $_GET['mailbox'];
if (!empty($mailbox))
{
$acl = $this->retrive_acl($mailbox, $msg);
}
}
$tmpl = new etemplate_new('mail.acl');
$content = array();
$tmpl->exec('mail.mail_ui.edit_acl', $content, $sel_options, $readonlys, array(),2);
}
/**
* Update Folder ACL rights
*
*/
function update_acl ($mailbox, $ident,$options, &$msg)
{
}
/**
* Retrive Folder ACL rights
*
*/
function retrive_acl ($mailbox, &$msg)
{
if ($acl = $this->mail_bo->icServer->getACL($mailbox))
{
if (is_array($acl))
{
$msg = lang('ACL rights retrived successfully!');
}
else
{
$msg = lang('ACL rights retrive failed, seems there are no rights set!');
}
}
else
{
$msg = lang('Get ACL rights failed from IMAP server!');
error_log(__METHOD__. "(" . $acl . ")" );
}
}
}

View File

@ -288,7 +288,13 @@ class mail_ui
$etpl = new etemplate_new('mail.index');
// Set tree actions
$etpl->setElementAttribute(self::$nm_index.'[foldertree]','actions', array(
$tree_actions = array(
'all_folders' => array(
'caption' => 'Show all folders',
'checkbox' => true,
'onExecute' => 'javaScript:app.mail.all_folders',
'group' => $group++,
),
'drop_move_mail' => array(
'type' => 'drop',
'acceptedTypes' => 'mail',
@ -327,8 +333,16 @@ class mail_ui
'onExecute' => 'javaScript:app.mail.edit_account',
//'enableId' => '^\\d+$', // only show action on account itself
),
));
//error_log(__METHOD__.__LINE__.array2string($content));
'edit_acl' => array(
'caption' => 'Edit folder ACL',
'icon' => 'configure',
'onExecute' => 'javaScript:app.mail.edit_acl',
),
);
if (!$this->mail_bo->icServer->queryCapability('ACL')) unset($tree_actions['edit_acl']);
$etpl->setElementAttribute(self::$nm_index.'[foldertree]','actions', $tree_actions);
if (empty($content[self::$nm_index]['filter2']) || empty($content[self::$nm_index]['search'])) $content[self::$nm_index]['filter2']='quick';
$readonlys = $preserv = $sel_options;
return $etpl->exec('mail.mail_ui.index',$content,$sel_options,$readonlys,$preserv);

View File

@ -1949,6 +1949,18 @@ app.classes.mail = AppJS.extend(
request.sendRequest();
},
/**
* Edit a folder acl for account(s)
*
* @param _action
* @param _senders - the representation of the tree leaf to be manipulated
*/
edit_acl: function(_action, _senders)
{
var folder_id = _senders[0].id.split('::INBOX/');
this.egw.open_link('mail.mail_acl.edit&mailbox='+folder_id[1], '_blank', '640x480');
},
/**
* Edit a mail account
*

78
mail/templates/default/acl.xet Executable file
View File

@ -0,0 +1,78 @@
<?xml version="1.0"?>
<!-- $Id$ -->
<overlay>
<template id="mail.acl" template="" lang="" group="0" version="1.9.001">
<grid>
<columns>
<column width="100%" />
</columns>
<rows>
<row disabled="!@msg">
<description id="msg" class="message"/>
</row>
<row>
<grid id="grid">
<columns>
<column/>
<column/>
<column/>
<column/>
<column/>
<column/>
<column/>
<column/>
<column/>
<column/>
<column/>
<column/>
<column/>
</columns>
<rows>
<row class="th">
<description value="Name"/>
<description value="Common ACL"/>
<description align="center" value="L"/>
<description align="center" value="R"/>
<description align="center" value="S"/>
<description align="center" value="W"/>
<description align="center" value="I"/>
<description align="center" value="P"/>
<description align="center" value="C"/>
<description align="center" value="D"/>
<description align="center" value="A"/>
<description align="center" value="Recursively"/>
<description value="Action"/>
</row>
<row class="row">
<taglist-email allowFreeEntries="true" maxSelection="1" />
<menulist>
<menupopup id="${row}[]"/>
</menulist>
<checkbox align="center" id="${row}[]" />
<checkbox align="center" id="${row}[]" />
<checkbox align="center" id="${row}[]" />
<checkbox align="center" id="${row}[]" />
<checkbox align="center" id="${row}[]" />
<checkbox align="center" id="${row}[]" />
<checkbox align="center" id="${row}[]" />
<checkbox align="center" id="${row}[]" />
<checkbox align="center" id="${row}[]" />
<checkbox align="center" id="${row}[]" />
<hbox orient=",0,0" options="0,0,0,0">
<button align="right" statustext="Delete this ACL" label="Delete" id="delete[$row_cont[]]" image="delete"/>
</hbox>
</row>
</rows>
</grid>
</row>
<row>
<hbox>
<button statustext="Saves this ACL" label="Save" id="button[save]"/>
<button statustext="Applies the changes made" label="Apply" id="button[apply]"/>
<button label="Cancel" id="button[cancel]"/>
</hbox>
</row>
</rows>
</grid>
</template>
</overlay>