gunnar: server/kolab-webadmin/kolab-webadmin/lib/KolabAdmin Sieve.php, 1.5, 1.6
cvs at kolab.org
cvs at kolab.org
Tue Apr 6 19:46:20 CEST 2010
Author: gunnar
Update of /kolabrepository/server/kolab-webadmin/kolab-webadmin/lib/KolabAdmin
In directory doto:/tmp/cvs-serv7641/kolab-webadmin/lib/KolabAdmin
Modified Files:
Sieve.php
Log Message:
Fix segment detection and add functionality to generate the combined script.
Index: Sieve.php
===================================================================
RCS file: /kolabrepository/server/kolab-webadmin/kolab-webadmin/lib/KolabAdmin/Sieve.php,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- Sieve.php 6 Apr 2010 08:56:32 -0000 1.5
+++ Sieve.php 6 Apr 2010 17:46:18 -0000 1.6
@@ -110,18 +110,16 @@
private function _splitSegments($script)
{
$segments = array();
- preg_match_all('/^### SEGMENT START [^#]*.*?### SEGMENT END [^#]*/s', $script, $matches);
- foreach ($matches as $match) {
- preg_match('/^### SEGMENT START ([^# ]*) ?(ENABLED)?/s', $match[0], $id);
+ preg_match_all('/### SEGMENT START [^#]*.*?### SEGMENT END [^#]*/s', $script, $matches);
+ foreach ($matches[0] as $match) {
+ preg_match('/### SEGMENT START ([^# ]*) ?(ENABLED)?/s', $match, $id);
if (!empty($id[1])) {
$type = strtolower($id[1]);
$class = 'KolabAdmin_Sieve_Segment_' . ucfirst($type);
- $segments[$type] = new $class($match[0]);
+ $segments[$type] = new $class($match);
if (isset($id[2]) && $id[2] == 'ENABLED') {
$segments[$type]->setActive();
}
- } else {
- throw new Exception('Unknown segment type.');
}
}
return $segments;
@@ -143,5 +141,22 @@
{
$this->_init();
return $this->_segments['vacation'];
+ }
+
+ public function store()
+ {
+ $result = $this->_sieve->installScript(self::SCRIPT, $this->getScript(), true);
+ if ($result instanceOf PEAR_Error) {
+ throw new Exception($result->getMessage());
+ }
+ }
+
+ public function getScript()
+ {
+ $script = 'require "fileinto";' . "\r\n" . 'require "vacation";' . "\r\n\r\n\r\n";
+ foreach ($this->_segments as $segment) {
+ $script .= $segment->generate() . "\r\n\r\n";
+ }
+ return $script;
}
}
More information about the commits
mailing list