forked from extern/egroupware
create the default script, if there is none; fix problem on trying to save/create vacation when there is NO rule or vacation existing beforehand
This commit is contained in:
parent
0c91565dfb
commit
a88c169974
@ -92,14 +92,12 @@ class emailadmin_script {
|
||||
return false;
|
||||
}
|
||||
|
||||
// if script doesn't yet exist, nothing to retrieve.
|
||||
// safe to write to this script file.
|
||||
#LK if (!AppSession::scriptExists($this->name)) {
|
||||
#LK $this->so = true;
|
||||
#LK return true;
|
||||
#LK }
|
||||
|
||||
#print "<br><br><br><br>get Script ". $this->name ."<bR>";
|
||||
// If the called script name is not exist then create it
|
||||
// otherwise we might get error due to non existance script
|
||||
if (!in_array($this->name, $connection->listScripts()))
|
||||
{
|
||||
$this->updateScript($connection);
|
||||
}
|
||||
|
||||
if(self::isError($script = $connection->getScript($this->name))) {
|
||||
if ($this->debug) error_log(__CLASS__.'::'.__METHOD__.": error retrieving script: ".$script->getMessage());
|
||||
@ -249,7 +247,7 @@ class emailadmin_script {
|
||||
$vacation_active = false;
|
||||
|
||||
$username = $GLOBALS['egw_info']['user']['account_lid'];
|
||||
$version = $GLOBALS['egw_info']['apps']['felamimail']['version'];
|
||||
$version = $GLOBALS['egw_info']['apps']['mail']['version'];
|
||||
|
||||
//include "$default->lib_dir/version.php";
|
||||
|
||||
@ -432,7 +430,7 @@ class emailadmin_script {
|
||||
$defaultaddr = $sieve->user . '@' . $sieve->maildomain;
|
||||
array_push($vacation['addresses'],$defaultaddr);
|
||||
}
|
||||
if ($vacation['status'] == 'on' || $vacation['status'] == 'by_date' &&
|
||||
if (($vacation['status'] == 'on' && strlen(trim($vacation['text']))>0)|| $vacation['status'] == 'by_date' &&
|
||||
$vacation['start_date'] <= time() && time() < $vacation['end_date']+24*3600) // +24*3600 to include the end_date day
|
||||
{
|
||||
if (trim($vacation['forwards'])) {
|
||||
@ -447,6 +445,8 @@ class emailadmin_script {
|
||||
$newscriptbody .= "\tkeep;\n}\n";
|
||||
}
|
||||
$vacation_active = true;
|
||||
if ($vacation['text'])
|
||||
{
|
||||
if ($regexsupported)
|
||||
{
|
||||
$newscriptbody .= "if header :regex ".'"X-Spam-Status" '.'"\\\\bYES\\\\b"'."{\n\tstop;\n}\n"; //stop vacation reply if it is spam
|
||||
@ -459,6 +459,7 @@ class emailadmin_script {
|
||||
// TODO: refine rule without using regex
|
||||
$newscriptbody .= "if header :contains ".'"X-Spam-Status" '.'"YES"'."{\n\tstop;\n}\n"; //stop vacation reply if it is spam
|
||||
}
|
||||
}
|
||||
$newscriptbody .= "vacation :days " . $vacation['days'] . " :addresses [";
|
||||
$first = 1;
|
||||
foreach ($vacation['addresses'] as $vaddress) {
|
||||
@ -530,7 +531,7 @@ class emailadmin_script {
|
||||
|
||||
$newscripthead = "";
|
||||
$newscripthead .= "#Mail filter rules for " . $username . "\n";
|
||||
$newscripthead .= '#Generated by ' . $username . ' using FeLaMiMail ' . $version . ' ' . date($default->script_date_format);
|
||||
$newscripthead .= '#Generated by ' . $username . ' using Mail ' . $version . ' ' . date($default->script_date_format);
|
||||
$newscripthead .= "\n";
|
||||
|
||||
if ($activerules) {
|
||||
@ -545,9 +546,25 @@ class emailadmin_script {
|
||||
$newscripthead .= "];\n\n";
|
||||
} else {
|
||||
// no active rules, but might still have an active vacation rule
|
||||
$closeRequired = false;
|
||||
if ($this->vacation && $vacation_active)
|
||||
$newscripthead .= "require [\"vacation\"];\n\n";
|
||||
if ($this->emailNotification && $this->emailNotification['status'] == 'on') $newscripthead .= "require [\"".($enotify?'e':'')."notify\"".($variables?',"variables"':'')."];\n\n"; // Added email notifications
|
||||
{
|
||||
$newscripthead .= "require [\"vacation\"";
|
||||
if ($regexsupported && $regexused) $newscripthead .= ",\"regex\"";
|
||||
$closeRequired=true;
|
||||
}
|
||||
if ($this->emailNotification && $this->emailNotification['status'] == 'on')
|
||||
{
|
||||
if ($this->vacation && $vacation_active)
|
||||
{
|
||||
$newscripthead .= ",\"".($enotify?'e':'')."notify\"".($variables?',"variables"':'')."];\n\n"; // Added email notifications
|
||||
}
|
||||
else
|
||||
{
|
||||
$newscripthead .= "require [\"".($enotify?'e':'')."notify\"".($variables?',"variables"':'')."];\n\n"; // Added email notifications
|
||||
}
|
||||
}
|
||||
if ($closeRequired) $newscripthead .= "];\n\n";
|
||||
}
|
||||
|
||||
// generate the encoded script foot
|
||||
|
Loading…
Reference in New Issue
Block a user