diff -urN ../vacation-1.9.9.orig/config.ini ./config.ini --- ../vacation-1.9.9.orig/config.ini 2010-06-13 15:39:04.000000000 +0300 +++ ./config.ini 2013-09-02 21:13:26.000000000 +0300 @@ -9,10 +9,12 @@ ; [default] -driver = "ftp" -subject = "Default subject" +driver = "sieve" +subject = "Out of office reply" body = "default.txt" - +server = "localhost" +port = "4190" +tls = false [dotforward] binary = "/usr/bin/vacation" diff -urN ../vacation-1.9.9.orig/default.txt ./default.txt --- ../vacation-1.9.9.orig/default.txt 2010-02-28 14:35:18.000000000 +0200 +++ ./default.txt 2012-01-05 00:08:35.000000000 +0200 @@ -1,8 +1,7 @@ -Hi, - -Please ask your system administrator to translate this file (default.txt). - -He can set a better default text for out of office replies. - -Feel free to edit this text. - +Приветствую. + +Меня сейчас нет на рабочем месте. + +Я прочту Ваше сообщение как только смогу. + +Спасибо за понимание. diff -urN ../vacation-1.9.9.orig/lib/sieve.class.php ./lib/sieve.class.php --- ../vacation-1.9.9.orig/lib/sieve.class.php 2010-03-08 17:25:52.000000000 +0200 +++ ./lib/sieve.class.php 2013-09-02 23:18:20.000000000 +0300 @@ -20,55 +20,147 @@ class Sieve extends VacationDriver { - private $sieve = null; + private $sieve = null; // Net_Sieve object + private $script; // rcube_sieve_script object - private $tls = false; - private $port = 2000; - - public function init() { - // try to connect to managesieve server and to fetch the script - - $username = Q($this->user->data['username']); - $userpass = $this->rcmail->decrypt($_SESSION['password']); - - // Standard plugin - require 'plugins/managesieve/lib/Net/Sieve.php'; - - $this->sieve = new Net_Sieve(); - $error = $this->sieve->connect("192.168.178.25", $this->cfg['port'], NULL, $this->cfg['tls']); - - echo $error; - - exit(0); - - - if (PEAR::isError($this->sieve->login($username, $userpass))) { - echo "Fout"; - } - } + private $server = "localhost"; + private $port = 2000; + private $tls = false; + private $script_name = "vacation"; + + public function init() { + // try to connect to managesieve server and to fetch the script + + $username = Q($this->user->data['username']); + $userpass = $this->rcmail->decrypt($_SESSION['password']); + + // Standard plugin + require_once 'plugins/managesieve/lib/Net/Sieve.php'; + + $this->sieve = new Net_Sieve(); + if (PEAR::isError( + $this->sieve->connect($this->cfg['server'] ? $this->cfg['server'] : $this->server, $this->cfg['port'] ? $this->cfg['port'] : $this->port, NULL, $this->cfg['tls'] ? $this->cfg['tls'] : $this->tls) + )) { + raise_error(array('code' => 601, 'type' => 'php', 'file' => __FILE__, + 'message' => sprintf("Vacation plugin: Cannot connect to the Sieve server '%s'", $this->cfg['server'] ? $this->cfg['server'] : $this->server) + ),true, true); + } + + if (PEAR::isError($this->sieve->login($username, $userpass))) { + raise_error(array('code' => 601, 'type' => 'php', 'file' => __FILE__, + 'message' => sprintf("Vacation plugin: Cannot login to the Sieve server '%s'", $this->cfg['server'] ? $this->cfg['server'] : $this->server) + ),true, true); + } + } // Download .forward and .vacation.message file public function _get() { $vacArr = array("subject"=>"","aliases"=>"", "body"=>"","forward"=>"","keepcopy"=>true,"enabled"=>false); - if ($script = $this->sieve->getScript("vacation")) - { + if ($script = $this->sieve->getScript($this->script_name)) { - } - +/* + if (PEAR::isError($script)) { + raise_error(array('code' => 601, 'type' => 'php', 'file' => __FILE__, + 'message' => sprintf("Vacation plugin: Cannot get sieve script from Sieve server '%s'", $this->cfg['server'] ? $this->cfg['server'] : $this->server) + ),true, true); + } +*/ + + $tokens = preg_split('/(# rule:\[.*\])\r?\n/', $script, -1, PREG_SPLIT_DELIM_CAPTURE); + + $vacation_rule = ""; + $forward_rule = ""; + while ($token = array_shift($tokens)) { + if ($token == "# rule:[vacation]") $vacation_rule = array_shift($tokens); + if ($token == "# rule:[forward]") $forward_rule = array_shift($tokens); + } + + if ($vacation_rule) { + if (preg_match('/vacation :subject "(.*?)" "((?:.*\r?\n)*?.*?)";/', $vacation_rule, $matches)) { + $vacArr["subject"] = str_replace('\"', '"', $matches[1]); + $vacArr["body"] = str_replace('\"', '"', $matches[2]); + } + if (preg_match('/if false/', $vacation_rule)) { + $vacArr["enabled"] = false; + } else { + $vacArr["enabled"] = true; + } + } + + if ($forward_rule) { + if (preg_match('/discard\s*;/', $forward_rule)) { + $vacArr["keepcopy"] = false; + } else { + $vacArr["keepcopy"] = true; + } + $addresses = array(); + $forward_rule = str_replace("\n", " ", str_replace("\r", "", $forward_rule)); + while (preg_match('/redirect .*?"(.*?)"\s*;\s*\r?\n?(.*)$/', $forward_rule, $matches)) { + $addresses[] = $matches[1]; + $forward_rule = $matches[2]; + } + $vacArr["forward"] = implode(", ", $addresses); + } - return $vacArr; + } + return $vacArr; } protected function setVacation() { - $script = ""; - if (! $this->enable) - { - $this->sieve->removeScript("vacation"); - } - $this->sieve->installScript("vacation", $script); - + $script = ""; + + $script = sprintf("require [\"fileinto\", \"reject\", \"vacation\", \"copy\", \"regex\"]; +# rule:[vacation] +if allof (header :contains \"X-Spam-Flag\" \"YES\") { + keep; +} elsif allof (header :contains \"X-Quarantined\" \"YES\") { + keep; +} elsif allof (header :regex \"X-Spam-Status\" \"^Yes\") { + keep; +} elsif allof (header :contains \"X-SpamTest-Status\" \"SPAM\") { + keep; +} elsif allof (header :contains \"X-MimeOLE\" \"Produced By phpBB2\") { + keep; +} elsif anyof (header :is \"Precedence\" \"List\", header :is \"Precedence\" \"list\", header :is \"Precedence\" \"bulk\", header :is \"Precedence\" \"junk\") { + keep; +} elsif anyof (exists \"List-Id\", exists \"List-Post\", exists \"List-Help\", exists \"List-Archive\", exists \"List-Subscribe\", exists \"List-Unsubscribe\", exists \"X-Mailman-Version\", exists \"Mailing-List-Server\", exists \"X-Mailing-List\", exists \"X-List-Administrivia\", exists \"X-list\", exists \"X-Notifier\", exists \"X-Broadcast-Id\") { + keep; +} elsif %sallof (header :contains [ \"To\", \"Cc\" ] \"@\") { + vacation :subject \"%s\" \"%s\"; + keep; +} else { + keep; +} +", ($this->enable ? "" : "false { # "), str_replace('"', '\"', $this->subject), str_replace('"', '\"', $this->body)); + + if ($this->forward) { + $redirects = array(); + foreach (preg_split('/\s*,\s*/', $this->forward) as $addr) $redirects[] = sprintf("\tredirect :copy \"%s\";", $addr); + $script .= sprintf("# rule:[forward] +if true +{ +%s +\t%s +} +", implode("\n", $redirects), ($this->keepcopy ? "keep;" : "discard;")); + } + + if (PEAR::isError($this->sieve->installScript($this->script_name, $script))) { + raise_error(array('code' => 601, 'type' => 'php', 'file' => __FILE__, + 'message' => sprintf("Vacation plugin: Cannot install sieve script on Sieve server '%s'", $this->cfg['server'] ? $this->cfg['server'] : $this->server) + ),true, true); + } else { + if (PEAR::isError($this->sieve->setActive($this->script_name))) { + raise_error(array('code' => 601, 'type' => 'php', 'file' => __FILE__, + 'message' => sprintf("Vacation plugin: Cannot activate sieve script '%s' on Sieve server '%s'", $this->script_name, $this->cfg['server'] ? $this->cfg['server'] : $this->server) + ),true, true); + } else { + return(true); + } + } + return(false); } // Cleans up files @@ -77,22 +169,10 @@ } - - - - - - - public function __destruct() - { - $this->sieve->disconnect(); - $this->sieve = null; - } - - - - - + public function __destruct() { + if ($this->sieve) $this->sieve->disconnect(); + $this->sieve = null; + } } ?> diff -urN ../vacation-1.9.9.orig/localization/ru_RU.inc ./localization/ru_RU.inc --- ../vacation-1.9.9.orig/localization/ru_RU.inc 1970-01-01 03:00:00.000000000 +0300 +++ ./localization/ru_RU.inc 2012-01-04 19:38:58.000000000 +0200 @@ -0,0 +1,20 @@ + \ No newline at end of file diff -urN ../vacation-1.9.9.orig/skins/classic/templates/vacation.html ./skins/classic/templates/vacation.html --- ../vacation-1.9.9.orig/skins/classic/templates/vacation.html 1970-01-01 03:00:00.000000000 +0300 +++ ./skins/classic/templates/vacation.html 2013-09-02 21:58:54.000000000 +0300 @@ -0,0 +1,30 @@ + + +
+%s
\n", $field_id, rep_specialchars_output($this->gettext('autoreplymessage')),