Implement *deactivate-catchall*-feature, refs #fixes 1114

Signed-off-by: Arnold Bechtoldt <mail@arnoldbechtoldt.com>
This commit is contained in:
Arnold Bechtoldt 2012-08-21 20:08:20 +02:00
parent 3655055030
commit 78f286cbda
10 changed files with 121 additions and 25 deletions

View File

@ -99,6 +99,14 @@ return array(
'type' => 'hidden',
'default' => 0,
),
'system_catchall_enabled' => array(
'label' => $lng['serversettings']['catchall_enabled'],
'settinggroup' => 'catchall',
'varname' => 'catchall_enabled',
'type' => 'bool',
'default' => true,
'save_method' => 'storeSettingResetCatchall',
),
),
),
),

View File

@ -284,6 +284,12 @@ elseif($page == 'emails')
//$iscatchall = makeyesno('iscatchall', '1', '0', '0');
$email_add_data = include_once dirname(__FILE__).'/lib/formfields/customer/email/formfield.emails_add.php';
if ( $settings['catchall']['catchall_enabled'] != '1' )
{
unset($email_add_data['emails_add']['sections']['section_a']['fields']['iscatchall']);
}
$email_add_form = htmlform::genHTMLForm($email_add_data);
$title = $email_add_data['emails_add']['title'];
@ -330,6 +336,12 @@ elseif($page == 'emails')
$result = htmlentities_array($result);
$email_edit_data = include_once dirname(__FILE__).'/lib/formfields/customer/email/formfield.emails_edit.php';
if ( $settings['catchall']['catchall_enabled'] != '1' )
{
unset($email_edit_data['emails_edit']['sections']['section_a']['fields']['mail_catchall']);
}
$email_edit_form = htmlform::genHTMLForm($email_edit_data);
$title = $email_edit_data['emails_edit']['title'];
@ -341,34 +353,41 @@ elseif($page == 'emails')
elseif($action == 'togglecatchall'
&& $id != 0)
{
$result = $db->query_first("SELECT `id`, `email`, `email_full`, `iscatchall`, `destination`, `customerid`, `popaccountid` FROM `" . TABLE_MAIL_VIRTUAL . "` WHERE `customerid`='" . (int)$userinfo['customerid'] . "' AND `id`='" . (int)$id . "'");
if(isset($result['email'])
&& $result['email'] != '')
if ( $settings['catchall']['catchall_enabled'] == '1' )
{
if($result['iscatchall'] == '1')
{
$db->query("UPDATE `" . TABLE_MAIL_VIRTUAL . "` SET `email` = '" . $db->escape($result['email_full']) . "', `iscatchall` = '0' WHERE `customerid`='" . (int)$userinfo['customerid'] . "' AND `id`='" . (int)$result['id'] . "'");
}
else
{
$email_parts = explode('@', $result['email_full']);
$email = '@' . $email_parts[1];
$email_check = $db->query_first("SELECT `id`, `email`, `email_full`, `iscatchall`, `destination`, `customerid` FROM `" . TABLE_MAIL_VIRTUAL . "` WHERE `email`='" . $db->escape($email) . "' AND `customerid`='" . (int)$userinfo['customerid'] . "'");
$result = $db->query_first("SELECT `id`, `email`, `email_full`, `iscatchall`, `destination`, `customerid`, `popaccountid` FROM `" . TABLE_MAIL_VIRTUAL . "` WHERE `customerid`='" . (int)$userinfo['customerid'] . "' AND `id`='" . (int)$id . "'");
if($email_check['email'] == $email)
if(isset($result['email'])
&& $result['email'] != '')
{
if($result['iscatchall'] == '1')
{
standard_error('youhavealreadyacatchallforthisdomain');
exit;
$db->query("UPDATE `" . TABLE_MAIL_VIRTUAL . "` SET `email` = '" . $db->escape($result['email_full']) . "', `iscatchall` = '0' WHERE `customerid`='" . (int)$userinfo['customerid'] . "' AND `id`='" . (int)$result['id'] . "'");
}
else
{
$db->query("UPDATE `" . TABLE_MAIL_VIRTUAL . "` SET `email` = '$email' , `iscatchall` = '1' WHERE `customerid`='" . $userinfo['customerid'] . "' AND `id`='" . $result['id'] . "'");
$log->logAction(USR_ACTION, LOG_INFO, "edited email address '" . $email . "'");
}
}
$email_parts = explode('@', $result['email_full']);
$email = '@' . $email_parts[1];
$email_check = $db->query_first("SELECT `id`, `email`, `email_full`, `iscatchall`, `destination`, `customerid` FROM `" . TABLE_MAIL_VIRTUAL . "` WHERE `email`='" . $db->escape($email) . "' AND `customerid`='" . (int)$userinfo['customerid'] . "'");
redirectTo($filename, Array('page' => $page, 'action' => 'edit', 'id' => $id, 's' => $s));
if($email_check['email'] == $email)
{
standard_error('youhavealreadyacatchallforthisdomain');
exit;
}
else
{
$db->query("UPDATE `" . TABLE_MAIL_VIRTUAL . "` SET `email` = '$email' , `iscatchall` = '1' WHERE `customerid`='" . $userinfo['customerid'] . "' AND `id`='" . $result['id'] . "'");
$log->logAction(USR_ACTION, LOG_INFO, "edited email address '" . $email . "'");
}
}
redirectTo($filename, Array('page' => $page, 'action' => 'edit', 'id' => $id, 's' => $s));
}
}
else
{
standard_error(array('operationnotpermitted', 'featureisdisabled'), 'Catchall');
}
}
}

View File

@ -337,6 +337,7 @@ CREATE TABLE `panel_settings` (
INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES
('catchall', 'catchall_enabled', '1'),
('session', 'allow_multiple_login', '0'),
('session', 'sessiontimeout', '600'),
('customer', 'accountprefix', 'web'),
@ -530,7 +531,7 @@ INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES
('panel', 'allow_preset', '1'),
('panel', 'allow_preset_admin', '0'),
('panel', 'password_regex', ''),
('panel', 'version', '0.9.28-svn4');
('panel', 'version', '0.9.28-svn5');

View File

@ -1951,3 +1951,14 @@ if(isFroxlorVersion('0.9.28-svn3'))
updateToVersion('0.9.28-svn4');
}
if(isFroxlorVersion('0.9.28-svn4')) {
showUpdateStep("Updating from 0.9.28-svn4 to 0.9.28-svn5");
// Catchall functionality (enabled by default) see #1114
$db->query("INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES ('catchall', 'catchall_enabled', '1');");
lastStepStatus(0);
updateToVersion('0.9.28-svn5');
}

View File

@ -0,0 +1,43 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
*
*/
function storeSettingResetCatchall($fieldname, $fielddata, $newfieldvalue)
{
$returnvalue = storeSettingField($fieldname, $fielddata, $newfieldvalue);
if($returnvalue !== false
&& is_array($fielddata)
&& isset($fielddata['settinggroup'])
&& $fielddata['settinggroup'] == 'catchall'
&& isset($fielddata['varname'])
&& $fielddata['varname'] == 'catchall_enabled'
&& $newfieldvalue == '0')
{
global $db;
$result = $db->query("SELECT `id`, `email`, `email_full`, `iscatchall` FROM `" . TABLE_MAIL_VIRTUAL . "` WHERE `iscatchall`='1'");
while($result_row = $db->fetch_array($result))
{
$db->query("UPDATE `" . TABLE_MAIL_VIRTUAL . "` SET `email` = '" . $db->escape($result_row['email_full']) . "', `iscatchall` = '0' WHERE `id`='" . (int)$result_row['id'] . "'");
}
}
return $returnvalue;
}
?>

View File

@ -73,6 +73,6 @@ define('PACKAGE_ENABLED', 2);
// VERSION INFO
$version = '0.9.28-svn4';
$version = '0.9.28-svn5';
$dbversion = '2';
$branding = '';

View File

@ -1921,3 +1921,10 @@ $lng['admin']['speciallogwarning'] = 'WARNING: By changing this setting you will
$lng['serversettings']['vmail_maildirname']['title'] = 'Maildir name';
$lng['serversettings']['vmail_maildirname']['description'] = 'Maildir directory into user\'s account. Normally \'Maildir\', in some implementations \'.maildir\', and directly into user\'s directory if left blank.';
$lng['tasks']['remove_emailacc_files'] = 'Delete customer e-mail data.';
// ADDED IN 0.9.28-svn5
$lng['error']['operationnotpermitted'] = 'Operation not permitted!';
$lng['error']['featureisdisabled'] = 'Feature %s is disabled. Please contact your service provider.';
$lng['serversettings']['catchall_enabled']['title'] = 'Use Catchall';
$lng['serversettings']['catchall_enabled']['description'] = 'Do you want to provide your customers the catchall-feature?';

View File

@ -1646,3 +1646,10 @@ $lng['serversettings']['phpfpm_settings']['idle_timeout']['description'] = 'Time
$lng['panel']['cancel'] = 'abbrechen';
$lng['admin']['delete_statistics'] = 'Statistiken Löschen';
$lng['admin']['speciallogwarning'] = 'ACHTUNG: Durch diese Einstellungen werden Sie alle bisherige Statistiken dieser Domain verlieren. Wenn Sie dabei wirklich sicher sind, geben Sie bitte folgenden Text in das nachfolgende Textfeld ein: "'.$lng['admin']['delete_statistics'].'" und bestätigen Sie mit "'.$lng['panel']['delete'].'".<br /><br />';
// ADDED IN 0.9.28-svn5
$lng['error']['operationnotpermitted'] = 'Diese Aktion ist nicht erlaubt!';
$lng['error']['featureisdisabled'] = 'Die Funktion %s wurde deaktiviert. Kontaktieren Sie bitte Ihren Dienstleister.';
$lng['serversettings']['catchall_enabled']['title'] = 'Catchall verwenden';
$lng['serversettings']['catchall_enabled']['description'] = 'Möchten Sie Ihren Kunden die Funktion Catchall zur Verfügung stellen?';

View File

@ -28,7 +28,7 @@
<th>{$lng['emails']['emailaddress']}&nbsp;{$arrowcode['m.email_full']}</th>
<th>{$lng['emails']['forwarders']}&nbsp;{$arrowcode['m.destination']}</th>
<th>{$lng['emails']['account']}</th>
<th>{$lng['emails']['catchall']}</th>
<if $settings['catchall']['catchall_enabled'] == '1'><th>{$lng['emails']['catchall']}</th></if>
<if $settings['system']['mail_quota_enabled'] == '1'>
<th>{$lng['emails']['quota']}</th>
</if>

View File

@ -2,7 +2,7 @@
<td>{$row['email_full']}</td>
<td><if $row['destination'] == ''>&nbsp;<else>{$row['destination']}</if></td>
<td><if $row['popaccountid'] != 0>{$lng['panel']['yes']}</if><if $row['popaccountid'] == 0>{$lng['panel']['no']}</if></td>
<td><if $row['iscatchall'] != 0>{$lng['panel']['yes']}</if><if $row['iscatchall'] == 0>{$lng['panel']['no']}</if></td>
<if $settings['catchall']['catchall_enabled'] == '1'><td><if $row['iscatchall'] != 0>{$lng['panel']['yes']}</if><if $row['iscatchall'] == 0>{$lng['panel']['no']}</if></td></if>
<if $settings['system']['mail_quota_enabled'] == '1'><td><if $row['quota'] == 0>{$lng['emails']['noquota']}<else>{$row['quota']} MB</if></if></td>
<td>
<a href="{$linker->getLink(array('section' => 'email', 'page' => $page, 'action' => 'edit', 'id' => $row['id']))}" style="text-decoration:none;">