Skip to content
Snippets Groups Projects
Commit ce648830 authored by Jesse Norell's avatar Jesse Norell
Browse files

allow client to use mail whitelist

parent 46e09fda
No related branches found
No related tags found
No related merge requests found
......@@ -118,5 +118,9 @@ $form["tabs"]['whitelist'] = array (
)
);
if (! $app->auth->is_admin()) {
$form["tabs"]['whitelist']['fields']['type']['value'] = array('recipient' => 'Recipient', 'sender' => 'Sender');
}
?>
......@@ -61,6 +61,20 @@ if($app->auth->get_client_limit($userid, 'mailcatchall') != 0)
'html_id' => 'mail_domain_catchall_list');
}
if(! $app->auth->is_admin())
{
$items[] = array( 'title' => 'Email Whitelist',
'target' => 'content',
'link' => 'mail/mail_whitelist_list.php',
'html_id' => 'mail_whitelist_list');
$items[] = array( 'title' => 'Email Blacklist',
'target' => 'content',
'link' => 'mail/mail_blacklist_list.php',
'html_id' => 'mail_blacklist_list');
}
if($app->auth->get_client_limit($userid, 'mailrouting') != 0)
{
$items[] = array( 'title' => 'Email Routing',
......@@ -110,8 +124,8 @@ if($app->auth->get_client_limit($userid, 'spamfilter_wblist') != 0)
'html_id' => 'spamfilter_blacklist_list');
}
if($app->auth->is_admin()) {
if($app->auth->is_admin())
{
$items[] = array( 'title' => 'User / Domain',
'target' => 'content',
'link' => 'mail/spamfilter_users_list.php',
......@@ -191,7 +205,9 @@ $items[] = array( 'title' => 'Mailbox traffic',
'target' => 'content',
'link' => 'mail/mail_user_stats.php',
'html_id' => 'mail_user_stats');
if($app->auth->get_client_limit($userid, 'backup') == 'y') {
if($app->auth->get_client_limit($userid, 'backup') == 'y')
{
$items[] = array (
'title' => 'Backup Stats',
'target' => 'content',
......@@ -206,8 +222,8 @@ $module['nav'][] = array( 'title' => 'Statistics',
//**** Global filters menu
$items = array();
if($_SESSION['s']['user']['typ'] == 'admin') {
if($app->auth->is_admin())
{
$items[] = array( 'title' => 'Postfix Whitelist',
'target' => 'content',
'link' => 'mail/mail_whitelist_list.php',
......
......@@ -78,17 +78,32 @@ $liste["item"][] = array( 'field' => "source",
'op' => "like",
'prefix' => "%",
'suffix' => "%",
'datasource' => array ( 'type' => 'SQL',
'querystring' => 'SELECT access_id,source FROM mail_access WHERE {AUTHSQL} ORDER BY source',
'keyfield'=> 'access_id',
'valuefield'=> 'source'
),
'width' => "",
'value' => "");
$liste["item"][] = array( 'field' => "type",
'datatype' => "VARCHAR",
'formtype' => "SELECT",
'op' => "=",
'prefix' => "",
'suffix' => "",
'width' => "",
'value' => array('recipient' => 'recipient_txt', 'sender' => 'sender_txt', 'client' => 'client_txt'));
if ($app->auth->is_admin()) {
$liste["item"][] = array( 'field' => "type",
'datatype' => "VARCHAR",
'formtype' => "SELECT",
'op' => "=",
'prefix' => "",
'suffix' => "",
'width' => "",
'value' => array('recipient' => 'recipient_txt', 'sender' => 'sender_txt', 'client' => 'client_txt'));
} else {
$liste["item"][] = array( 'field' => "type",
'datatype' => "VARCHAR",
'formtype' => "SELECT",
'op' => "=",
'prefix' => "",
'suffix' => "",
'width' => "",
'value' => array('recipient' => 'recipient_txt', 'sender' => 'sender_txt'));
}
?>
......@@ -42,8 +42,6 @@ $tform_def_file = "form/mail_whitelist.tform.php";
require_once '../../lib/config.inc.php';
require_once '../../lib/app.inc.php';
if($_SESSION["s"]["user"]["typ"] != 'admin') $app->error('This function needs admin privileges');
//* Check permissions for module
$app->auth->check_module_permissions('mail');
......
......@@ -50,19 +50,11 @@ $app->load('tform_actions');
class page_action extends tform_actions {
function onShowNew() {
global $app, $conf;
if($_SESSION["s"]["user"]["typ"] != 'admin') die('This function needs admin privileges');
parent::onShowNew();
}
protected $client_allowed_types = array( 'recipient', 'sender' );
function onBeforeUpdate() {
global $app, $conf;
if($_SESSION["s"]["user"]["typ"] != 'admin') die('This function needs admin privileges');
//* Check if the server has been changed
// We do this only for the admin or reseller users, as normal clients can not change the server ID anyway
$rec = $app->db->queryOneRecord("SELECT server_id from mail_access WHERE access_id = ?", $this->id);
......@@ -77,7 +69,26 @@ class page_action extends tform_actions {
function onSubmit() {
global $app, $conf;
if($_SESSION["s"]["user"]["typ"] != 'admin') die('This function needs admin privileges');
// Non-admin checks
if($_SESSION["s"]["user"]["typ"] != 'admin') {
// Non-admin can only use type 'sender' or 'recipient' and address must belong to the client's domains
if(! in_array($this->dataRecord["type"], $this->client_allowed_types)) {
$app->tform->errorMessage .= $app->lng('Whitelist type requires admin permissions');
}
// address must be valid email
if(! filter_var( $this->dataRecord["source"], FILTER_VALIDATE_EMAIL )) {
$app->tform->errorMessage .= $app->lng('Invalid address: must be a valid email address');
}
$tmp = explode('@', $this->dataRecord["source"]);
$domain = trim( array_pop($tmp) );
$AUTHSQL = $app->tform->getAuthSQL('r');
$rec = $app->db->queryOneRecord("SELECT domain_id from mail_domain WHERE ${AUTHSQL} AND domain = ?", $domain);
// address must belong to the client's domains
if(! (is_array($rec) && isset($rec['domain_id']) && is_numeric($rec['domain_id']))) {
$app->tform->errorMessage .= $app->lng('Invalid address: you have no permission for this domain.');
}
unset($rec);
}
if(substr($this->dataRecord['source'], 0, 1) === '@') $this->dataRecord['source'] = substr($this->dataRecord['source'], 1);
......
......@@ -12,8 +12,6 @@ $list_def_file = "list/mail_whitelist.list.php";
* End Form configuration
******************************************/
if($_SESSION["s"]["user"]["typ"] != 'admin') $app->error('This function needs admin privileges');
//* Check permissions for module
$app->auth->check_module_permissions('mail');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment