* Mail/Sieve: check capability if VACATION is supported by SIEVE Server before trying to set an serverside vacation absent notice

code clean up in hooks and conditional debug for sendMDN
This commit is contained in:
Klaus Leithoff 2015-02-06 12:41:03 +00:00
parent 66c6e5203e
commit 2e437352c5
4 changed files with 146 additions and 217 deletions

View File

@ -6228,7 +6228,7 @@ class emailadmin_imapbase
{ {
$acc = emailadmin_account::read($this->profileID); $acc = emailadmin_account::read($this->profileID);
$identity = emailadmin_account::read_identity($acc['ident_id'], true, null, $acc); $identity = emailadmin_account::read_identity($acc['ident_id'], true, null, $acc);
if (self::$debug) error_log(__METHOD__.__LINE__.array2string($identity));
$headers = $this->getMessageHeader($uid, '', 'object', true, $_folder); $headers = $this->getMessageHeader($uid, '', 'object', true, $_folder);
$mdn = new Horde_Mime_Mdn($headers); $mdn = new Horde_Mime_Mdn($headers);

View File

@ -105,8 +105,8 @@ class emailadmin_script {
if ($this->debug) error_log(__CLASS__.'::'.__METHOD__.": error retrieving script: ".$script->getMessage()); if ($this->debug) error_log(__CLASS__.'::'.__METHOD__.": error retrieving script: ".$script->getMessage());
return $script; return $script;
} }
#print "<br>AAA: Script is ". htmlentities($script) ."<br>"; #print "<br>AAA: Script is ". htmlentities($script) ."<br>";
$lines = preg_split("/\n/",$script); //,PREG_SPLIT_NO_EMPTY); $lines = preg_split("/\n/",$script); //,PREG_SPLIT_NO_EMPTY);
$rules = array(); $rules = array();
@ -228,6 +228,7 @@ class emailadmin_script {
$this->script = $script; $this->script = $script;
$this->rules = $rules; $this->rules = $rules;
$this->vacation = $vacation; $this->vacation = $vacation;
if (!(in_array('vacation',$connection->_capability['extensions'])|| in_array('VACATION', $connection->_capability['extensions']))) $this->vacation = false;
$this->emailNotification = $emailNotification; // Added email notifications $this->emailNotification = $emailNotification; // Added email notifications
if ($this->debug) error_log(__CLASS__.'::'.__METHOD__.": Script succesful retrieved: ".print_r($vacation,true)); if ($this->debug) error_log(__CLASS__.'::'.__METHOD__.": Script succesful retrieved: ".print_r($vacation,true));
@ -265,11 +266,13 @@ class emailadmin_script {
#LK } #LK }
// lets generate the main body of the script from our rules // lets generate the main body of the script from our rules
//error_log(__METHOD__.__LINE__.array2string($connection->_capability));
$enotify = $variables= $supportsbody = false; $enotify = $variables= $supportsbody = false;
if (in_array('enotify',$connection->_capability['extensions'])|| in_array('ENOTIFY', $connection->_capability['extensions'])) $enotify = true; if (in_array('enotify',$connection->_capability['extensions'])|| in_array('ENOTIFY', $connection->_capability['extensions'])) $enotify = true;
if (in_array('variables',$connection->_capability['extensions'])|| in_array('VARIABLES', $connection->_capability['extensions'])) $variables = true; if (in_array('variables',$connection->_capability['extensions'])|| in_array('VARIABLES', $connection->_capability['extensions'])) $variables = true;
if (in_array('body', $connection->_capability['extensions']) || in_array('BODY', $connection->_capability['extensions'])) $supportsbody = true; if (in_array('body', $connection->_capability['extensions']) || in_array('BODY', $connection->_capability['extensions'])) $supportsbody = true;
if (!(in_array('vacation',$connection->_capability['extensions'])|| in_array('VACATION', $connection->_capability['extensions']))) $this->vacation = false;
$newscriptbody = ""; $newscriptbody = "";
$continue = 1; $continue = 1;

View File

@ -337,39 +337,6 @@ class mail_hooks
'default'=> 0, 'default'=> 0,
'admin' => False, 'admin' => False,
), ),
/*
// option requested by customer, removed for the new client
'prefaskformultipleforward' => array(
'type' => 'select',
'label' => 'Confirm attach message',
'help' => 'Do you want to be asked for confirmation before attaching selected messages to new mail?',
'name' => 'prefaskformultipleforward',
'values' => $no_yes,
'xmlrpc' => True,
'admin' => False,
'forced' => '1',
),
*/
/*
'mainscreen_showmail' => array(
'type' => 'select',
'label' => 'show new messages on home page',
'help' => 'Should new messages show up on the Home page',
'name' => 'mainscreen_showmail',
'values' => $selectOptions,
'xmlrpc' => True,
'admin' => False,
),
'mainscreen_showfolders' => array(
'type' => 'multiselect',
'label' => 'home page folders',
'help' => 'if shown, which folders should appear on the Home page',
'name' => 'mainscreen_showfolders',
'values' => $folderList,
'xmlrpc' => True,
'admin' => False,
),
*/
array( array(
'type' => 'section', 'type' => 'section',
'title' => lang('Configuration settings'), 'title' => lang('Configuration settings'),
@ -417,57 +384,6 @@ class mail_hooks
'default'=> 0, 'default'=> 0,
'admin' => False, 'admin' => False,
), ),
/*'prefpreventmanagefolders' => array(
'type' => 'select',
'label' => 'Prevent managing folders',
'help' => 'Do you want to prevent the managing of folders (creation, accessrights AND subscribtion)?',
'name' => 'prefpreventmanagefolders',
'values' => $prefAllowManageFolders,
'xmlrpc' => True,
'admin' => False,
'forced' => '0',
),
'prefpreventforwarding' => array(
'type' => 'select',
'label' => 'Prevent managing forwards',
'help' => 'Do you want to prevent the editing/setup for forwarding of mails via settings (, even if SIEVE is enabled)?',
'name' => 'prefpreventforwarding',
'values' => $no_yes,
'xmlrpc' => True,
'admin' => False,
'forced' => '0',
),
'prefpreventnotificationformailviaemail' => array(
'type' => 'select',
'label' => 'Prevent managing notifications',
'help' => 'Do you want to prevent the editing/setup of notification by mail to other emailadresses if emails arrive (, even if SIEVE is enabled)?',
'name' => 'prefpreventnotificationformailviaemail',
'values' => $no_yes,
'xmlrpc' => True,
'admin' => False,
'forced' => '1',
),
'prefpreventeditfilterrules' => array(
'type' => 'select',
'label' => 'Prevent managing filters',
'help' => 'Do you want to prevent the editing/setup of filter rules (, even if SIEVE is enabled)?',
'name' => 'prefpreventeditfilterrules',
'values' => $no_yes,
'xmlrpc' => True,
'admin' => False,
'forced' => '0',
),
'prefpreventabsentnotice' => array(
'type' => 'select',
'label' => 'Prevent managing vacation notice',
'help' => 'Do you want to prevent the editing/setup of the absent/vacation notice (, even if SIEVE is enabled)?',
'name' => 'prefpreventabsentnotice',
'values' => $no_yes,
'xmlrpc' => True,
'admin' => False,
'forced' => '0',
),
*/
'prefaskformove' => array( 'prefaskformove' => array(
'type' => 'select', 'type' => 'select',
'label' => 'Confirm move to folder', 'label' => 'Confirm move to folder',

View File

@ -69,6 +69,8 @@ class mail_sieve
if ($acc_id > 0) if ($acc_id > 0)
{ {
$this->account = emailadmin_account::read($acc_id); $this->account = emailadmin_account::read($acc_id);
$identity = emailadmin_account::read_identity($acc_id,true);
$this->currentIdentity = mail_bo::generateIdentityString($identity,false);
} }
$this->restoreSessionData(); $this->restoreSessionData();
@ -111,7 +113,7 @@ class mail_sieve
} }
else else
{ {
$content['msg'] = lang('error').':'.lang('Serverside Filterrules (Sieve) are not activated').'. '.lang('Please contact your Administrator to validate if your Server supports Serverside Filterrules, and how to enable them in EGroupware for your active Account (%1) with ID:%2.',$this->currentIdentity['identity_string'],$this->mailbo->profileID); $content['msg'] = lang('error').':'.lang('Serverside Filterrules (Sieve) are not activated').'. '.lang('Please contact your Administrator to validate if your Server supports Serverside Filterrules, and how to enable them in EGroupware for your active Account (%1) with ID:%2.',$this->currentIdentity,$this->account->acc_id);
$content['hideIfSieveDisabled']='mail_DisplayNone'; $content['hideIfSieveDisabled']='mail_DisplayNone';
} }
$tmpl->exec('mail.mail_sieve.index',$content,$sel_options,array()); $tmpl->exec('mail.mail_sieve.index',$content,$sel_options,array());
@ -208,7 +210,7 @@ class mail_sieve
} }
else else
{ {
$content['msg'] = lang('error').':'.lang('Serverside Filterrules (Sieve) are not activated').'. '.lang('Please contact your Administrator to validate if your Server supports Serverside Filterrules, and how to enable them in EGroupware for your active Account (%1) with ID:%2.',$this->currentIdentity['identity_string'],$this->mailbo->profileID); $content['msg'] = lang('error').':'.lang('Serverside Filterrules (Sieve) are not activated').'. '.lang('Please contact your Administrator to validate if your Server supports Serverside Filterrules, and how to enable them in EGroupware for your active Account (%1) with ID:%2.',$this->currentIdentity,$this->account->acc_id);
$content['hideIfSieveDisabled']='mail_DisplayNone'; $content['hideIfSieveDisabled']='mail_DisplayNone';
} }
$eNotitmpl->exec('mail.mail_sieve.editEmailNotification', $content,$sel_options); $eNotitmpl->exec('mail.mail_sieve.editEmailNotification', $content,$sel_options);
@ -524,7 +526,14 @@ class mail_sieve
if ($icServer->acc_sieve_enabled) if ($icServer->acc_sieve_enabled)
{ {
$vacRules = $this->getVacation($account_id); $vacRules = $this->getVacation($account_id);
if ($vacRules['vacation']===false)
{
$content['msg'] = lang('error').':'.lang('Serverside Vacationnotice (via Sieve) are not activated').'. '.
lang('Please contact your Administrator to validate if your Server supports Serverside Vacationmessages, and how to enable them in EGroupware for your active Account (%1) with ID:%2.',$this->currentIdentity,$icServer->ImapServerId);
$content['hideIfSieveDisabled']='mail_DisplayNone';
}
else
{
if ($icServer->acc_imap_administration) if ($icServer->acc_imap_administration)
{ {
$ByDate = array('by_date' => lang('By date')); $ByDate = array('by_date' => lang('By date'));
@ -643,7 +652,7 @@ class mail_sieve
} }
// refresh vacationNotice on index // refresh vacationNotice on index
$response = egw_json_response::get(); $response = egw_json_response::get();
$response->call('app.mail.mail_callRefreshVacationNotice',$this->mailbo->profileID); $response->call('app.mail.mail_callRefreshVacationNotice',$icServer->ImapServerId);
egw_framework::refresh_opener($msg, 'mail'); egw_framework::refresh_opener($msg, 'mail');
if ($button === 'apply' || $icServer->error !=="") if ($button === 'apply' || $icServer->error !=="")
{ {
@ -682,9 +691,10 @@ class mail_sieve
} }
$content['msg'] = $msg; $content['msg'] = $msg;
} }
}
else else
{ {
$content['msg'] = lang('error').':'.lang('Serverside Filterrules (Sieve) are not activated').'. '.lang('Please contact your Administrator to validate if your Server supports Serverside Filterrules, and how to enable them in EGroupware for your active Account (%1) with ID:%2.',$this->currentIdentity['identity_string'],$this->mailbo->profileID); $content['msg'] = lang('error').':'.lang('Serverside Filterrules (Sieve) are not activated').'. '.lang('Please contact your Administrator to validate if your Server supports Serverside Filterrules, and how to enable them in EGroupware for your active Account (%1) with ID:%2.',$this->currentIdentity,$icServer->ImapServerId);
$content['hideIfSieveDisabled']='mail_DisplayNone'; $content['hideIfSieveDisabled']='mail_DisplayNone';
} }
$vtmpl->exec('mail.mail_sieve.editVacation',$content,$sel_options,$readonlys,$preserv,2); $vtmpl->exec('mail.mail_sieve.editVacation',$content,$sel_options,$readonlys,$preserv,2);