Add ability of redirect to multiple addresses in sieve edit popup

This commit is contained in:
Hadi Nategh 2013-12-04 09:04:24 +00:00
parent 6bb5107f5f
commit d49569f78c
3 changed files with 53 additions and 6 deletions

View File

@ -387,7 +387,10 @@ class emailadmin_script {
$rejectused = 1;
}
if (preg_match("/address/i",$rule['action'])) {
$newruletext .= "redirect \"" . $rule['action_arg'] . "\";";
foreach(preg_split('/, ?/',$rule['action_arg']) as $addr)
{
$newruletext .= "\tredirect \"".trim($addr)."\";\n";
}
}
if (preg_match("/discard/i",$rule['action'])) {
$newruletext .= "discard;";

View File

@ -320,6 +320,39 @@
return false;
}
}
/**
* Check if passed email address(s) is valid
*
* @param type $addresses
*
*@return boolean Returns TRUE in case of succes and FALSE in case of failure
*/
function email_validation($addresses)
{
if(is_array($addresses))
{
$regexp="/^[a-z0-9]+([_\\.-][a-z0-9]+)*@([a-z0-9]+([\.-][a-z0-9]+)*)+\\.[a-z]{2,}$/i";
foreach ($addresses as $addr)
{
if (!preg_match($regexp,$addr))
{
$this->errorStack['addresses'] = lang('One address is not valid').'!';
}
}
}
else
{
$this->errorStack['addresses'] = lang('Please select a address').'!';
}
if (!empty($this->errorStack['addresses']))
{
return false;
}
else
{
return true;
}
}
function display_app_header() {
if(preg_match('/^(vacation|filter)$/',get_var('editmode',array('GET'))))
@ -335,6 +368,7 @@
$GLOBALS['egw']->js->set_onunload('opener.fm_sieve_cancelReload();');
}
$GLOBALS['egw_info']['flags']['include_xajax'] = True;
$GLOBALS['egw']->common->egw_header();
switch($_GET['menuaction']) {
@ -487,7 +521,15 @@
$preferences->preferences['prefpreventforwarding'] == 0 )
{
$newRule['action'] = 'address';
$newRule['action_arg'] = get_var('address',array('POST'));
if ($this->email_validation(preg_split('/, ?/',get_var('address',array('POST')))))
{
$newRule['action_arg'] = get_var('address',array('POST'));
}
else
{
$msg .= lang($this->errorStack['addresses']);
}
}
else
{
@ -902,7 +944,7 @@
{
$this->t->set_var('ruleCSS','sieveRowInActive');
}
$this->t->set_var('filter_text',htmlspecialchars($this->buildRule($rule),ENT_QUOTES,$GLOBALS['egw']->translation->charset()));
$this->t->set_var('ruleID',$ruleID);
@ -1092,7 +1134,8 @@
$this->t->set_var("lang_if_mail_body_transform",lang('if mail body message type'));
$this->t->set_var("lang_if_mail_body_content",lang('if mail body content / attachment type'));
$this->t->set_var("lang_file_into",lang('file into'));
$this->t->set_var("lang_forward_to_address",lang('forward to address'));
$this->t->set_var("lang_forward_to_address",lang('forward to addresses'));
$this->t->set_var("lang_forward_to_address_notice",lang('Multiple addresses need to be seprated by comma.'));
$this->t->set_var("lang_send_reject_message",lang('send a reject message'));
$this->t->set_var("lang_discard_message",lang('discard message'));
$this->t->set_var("lang_select_folder",lang('select folder'));

View File

@ -81,7 +81,7 @@ function SubmitForm(a)
</td>
<td>
{bodytransform_select}
{lang_contains}
{lang_contains}<sup><small>(*)</small></sup>
<input class="input_text" TYPE="text" NAME="field_bodytransform" SIZE="30" value="{value_field_bodytransform}">
</td>
</tr>
@ -112,7 +112,7 @@ function SubmitForm(a)
</tr>
<tr CLASS="sieveRowActive">
<td>
<input TYPE="radio" NAME="action" VALUE="address" id="action_address" {checked_action_address} {action_address_disabled}> <label for="action_address">{lang_forward_to_address}:</label>
<input TYPE="radio" NAME="action" VALUE="address" id="action_address" {checked_action_address} {action_address_disabled}> <label for="action_address">{lang_forward_to_address}:<sup><small>(*)</small></sup></label>
</td>
<td>
<input class="input_text" TYPE="text" NAME="address" style="width:250px;" onchange="document.getElementById('action_address').checked = true;" SIZE="40" value="{value_address}" {address_value_disabled}>
@ -133,6 +133,7 @@ function SubmitForm(a)
<td>&nbsp;</td>
</tr>
</table>
(*) <small>{lang_forward_to_address_notice}</small>
</fieldset>
<fieldset style="width:680px;" class="row_on"><legend>{lang_extended}</legend>
<table WIDTH="100%" CELLPADDING="2" CELLSPACING="1" style="border: 1px solid silver;">