sieve sidebox entrys always visible if one or more IMAP profiles support sieve; check if sieve enabled on rules-index, vacation notice and sieve forwarding

This commit is contained in:
Klaus Leithoff 2013-10-11 11:43:01 +00:00
parent c6a97da311
commit 190a98499a
5 changed files with 245 additions and 204 deletions

View File

@ -737,6 +737,17 @@ class mail_hooks
$mail_bo = mail_bo::getInstance(true,$profileID); $mail_bo = mail_bo::getInstance(true,$profileID);
$profileID = $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'] = $mail_bo->profileID; $profileID = $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'] = $mail_bo->profileID;
$preferences =& $mail_bo->mailPreferences; $preferences =& $mail_bo->mailPreferences;
$serverCounter = $sieveEnabledServerCounter = 0;
if (count($preferences->ic_server)) {
foreach ($preferences->ic_server as $tmpkey => $accountData)
{
if ($tmpkey==0) continue;
$icServer =& $accountData;
if (empty($icServer->host)) continue;
if ($icServer->enableSieve && $icServer->sievePort) $sieveEnabledServerCounter++;
$serverCounter++;
}
}
$showMainScreenStuff = false; $showMainScreenStuff = false;
if (!$showMainScreenStuff) if (!$showMainScreenStuff)
{ {
@ -835,9 +846,6 @@ class mail_hooks
$menu_title = lang('Sieve'); $menu_title = lang('Sieve');
if (is_object($preferences)) $icServer = $preferences->getIncomingServer($profileID); if (is_object($preferences)) $icServer = $preferences->getIncomingServer($profileID);
if(($icServer instanceof defaultimap)) {
if($icServer->enableSieve)
{
$linkData = array $linkData = array
( (
'menuaction' => 'mail.mail_sieve.index', 'menuaction' => 'mail.mail_sieve.index',
@ -858,6 +866,17 @@ class mail_hooks
{ {
$file['email notification'] = egw::link('/index.php','menuaction=mail.mail_sieve.editEmailNotification'); //Added email notifications $file['email notification'] = egw::link('/index.php','menuaction=mail.mail_sieve.editEmailNotification'); //Added email notifications
} }
if ($sieveEnabledServerCounter>=1)
{
if($sieveEnabledServerCounter==1 && ($icServer instanceof defaultimap)) {
if($icServer->enableSieve)
{
if (count($file)) display_sidebox($appname,$menu_title,$file);
unset($file);
}
}
else
{
if (count($file)) display_sidebox($appname,$menu_title,$file); if (count($file)) display_sidebox($appname,$menu_title,$file);
unset($file); unset($file);
} }

View File

@ -106,7 +106,8 @@ class mail_sieve
} }
else else
{ {
die(lang('Sieve not activated')); // we intend to die in index, to be able to die graciously
//die(lang('Sieve not activated'));
} }
} }
@ -123,7 +124,9 @@ class mail_sieve
$tmpl = new etemplate_new('mail.sieve.index'); $tmpl = new etemplate_new('mail.sieve.index');
if ($_GET['msg']) $msg = $_GET['msg']; if ($_GET['msg']) $msg = $_GET['msg'];
$content['msg'] = $msg;
if ($this->mailbo->icServer->enableSieve)
{
//Initializes the Grid contents //Initializes the Grid contents
$content['rg']= $this->get_rows($rows,$readonlys); $content['rg']= $this->get_rows($rows,$readonlys);
@ -136,9 +139,13 @@ class mail_sieve
'DISABLED' => lang('Disabled'), 'DISABLED' => lang('Disabled'),
) )
); );
}
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.',mail_bo::generateIdentityString($this->mailPreferences->identities[$this->mailbo->profileID],true),$this->mailbo->profileID);
$content['hideIfSieveDisabled']='mail_DisplayNone';
}
$tmpl->exec('mail.mail_sieve.index',$content,$sel_options,$readonlys); $tmpl->exec('mail.mail_sieve.index',$content,$sel_options,$readonlys);
} }
/** /**
@ -152,6 +159,8 @@ class mail_sieve
//Instantiate an etemplate_new object, representing sieve.emailNotification //Instantiate an etemplate_new object, representing sieve.emailNotification
$eNotitmpl = new etemplate_new('mail.sieve.emailNotification'); $eNotitmpl = new etemplate_new('mail.sieve.emailNotification');
if ($this->mailbo->icServer->enableSieve)
{
$eNotification = $this->getEmailNotification(); $eNotification = $this->getEmailNotification();
if (!is_array($content)) if (!is_array($content))
@ -225,6 +234,12 @@ class mail_sieve
); );
//error_log(__METHOD__. '() new email notification : ' . array2string($content)); //error_log(__METHOD__. '() new email notification : ' . array2string($content));
$content['msg'] = $msg; $content['msg'] = $msg;
}
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.',mail_bo::generateIdentityString($this->mailPreferences->identities[$this->mailbo->profileID],true),$this->mailbo->profileID);
$content['hideIfSieveDisabled']='mail_DisplayNone';
}
$eNotitmpl->exec('mail.mail_sieve.editEmailNotification', $content,$sel_options); $eNotitmpl->exec('mail.mail_sieve.editEmailNotification', $content,$sel_options);
} }
@ -514,7 +529,8 @@ class mail_sieve
//Instantiate an etemplate_new object, representing the sieve.vacation template //Instantiate an etemplate_new object, representing the sieve.vacation template
$vtmpl = new etemplate_new('mail.sieve.vacation'); $vtmpl = new etemplate_new('mail.sieve.vacation');
if ($this->mailbo->icServer->enableSieve)
{
$vacRules = $this->getVacation($vacation,$msg); $vacRules = $this->getVacation($vacation,$msg);
if (!is_array($content)) if (!is_array($content))
@ -628,6 +644,12 @@ class mail_sieve
$content['msg'] = $msg; $content['msg'] = $msg;
error_log(__METHOD__. '() sel_option ' . array2string($sel_options)); error_log(__METHOD__. '() sel_option ' . array2string($sel_options));
}
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.',mail_bo::generateIdentityString($this->mailPreferences->identities[$this->mailbo->profileID],true),$this->mailbo->profileID);
$content['hideIfSieveDisabled']='mail_DisplayNone';
}
$vtmpl->exec('mail.mail_sieve.editVacation',$content,$sel_options,$preserv); $vtmpl->exec('mail.mail_sieve.editVacation',$content,$sel_options,$preserv);
} }

View File

@ -34,9 +34,9 @@
</row> </row>
<row> <row>
<hbox> <hbox>
<button label="Save" id="button[save]"/> <button class="$cont[hideIfSieveDisabled]" label="Save" id="button[save]"/>
<button label="Apply" id="button[apply]"/> <button class="$cont[hideIfSieveDisabled]" label="Apply" id="button[apply]"/>
<button label="Cancel" id="button[cancel]"/> <button class="$cont[hideIfSieveDisabled]" label="Cancel" id="button[cancel]"/>
</hbox> </hbox>
<description/> <description/>
</row> </row>

View File

@ -32,7 +32,7 @@
</columns> </columns>
<rows> <rows>
<row> <row>
<buttononly align="right" label="Add" id="add" onclick="window.open(egw::link('/index.php','menuaction=mail.mail_sieve.edit'),'_blank','dependent=yes,width=600,height=400,scrollbars=yes,status=yes'); return false;"/> <buttononly class="$cont[hideIfSieveDisabled]" align="right" label="Add" id="add" onclick="window.open(egw::link('/index.php','menuaction=mail.mail_sieve.edit'),'_blank','dependent=yes,width=600,height=400,scrollbars=yes,status=yes'); return false;"/>
</row> </row>
<row> <row>
<template id="rows"/> <template id="rows"/>

View File

@ -28,7 +28,7 @@
<description value="Respond to mail sent to:"/> <description value="Respond to mail sent to:"/>
<hbox> <hbox>
<taglist-email id="addresses" width="40%" allowFreeEntries="true" /> <taglist-email id="addresses" width="40%" allowFreeEntries="true" />
<button label="Add all my aliases" id="AllAddresses" onclick='app.mail.sieve_vac_all_aliases()'/> <button class="$cont[hideIfSieveDisabled]" label="Add all my aliases" id="AllAddresses" onclick='app.mail.sieve_vac_all_aliases()'/>
</hbox> </hbox>
</row> </row>
<row> <row>
@ -59,9 +59,9 @@
</row> </row>
<row> <row>
<hbox> <hbox>
<button label="Save" id="button[save]"/> <button class="$cont[hideIfSieveDisabled]" label="Save" id="button[save]"/>
<button label="Apply" id="button[apply]"/> <button class="$cont[hideIfSieveDisabled]" label="Apply" id="button[apply]"/>
<button label="Cancel" id="button[cancel]"/> <button class="$cont[hideIfSieveDisabled]" label="Cancel" id="button[cancel]"/>
</hbox> </hbox>
<description/> <description/>
</row> </row>