Code

Fixed new script status
[gosa.git] / include / sieve / class_semantics.inc
index e4b1f4c19bc7f7b72dece8bd4338f58359547f12..da6f6998b5eb57b4ec00ef393114e0adcfd71885 100644 (file)
@@ -16,6 +16,7 @@ class Semantics
        function Semantics($command)
        {
                $this->command_ = $command;
+
                $this->unknown = false;
                switch ($command)
                {
@@ -125,7 +126,7 @@ class Semantics
                                'valid_after' => array('require', 'if', 'elsif', 'else', 'reject', 'fileinto', 'redirect', 'stop', 'keep', 'discard'),
                                'arguments' => array(
                                        array('class' => 'string', 'occurrences' => '1', 'values' => array(
-                                               array('occurrences' => '1', 'regex' => '".*"', 'name' => 'reason')
+                                               array('occurrences' => '1', 'regex' => '.*', 'name' => 'reason')
                                        ))
                                )
                        );
@@ -162,7 +163,7 @@ class Semantics
                                                array('occurrences' => '?', 'regex' => ':mime', 'name' => 'mime')
                                        )),
                                        array('class' => 'string', 'occurrences' => '1', 'values' => array(
-                                               array('occurrences' => '1', 'regex' => '".*"', 'name' => 'reason')
+                                               array('occurrences' => '1', 'regex' => '.*', 'name' => 'reason')
                                        ))
                                )
                        );
@@ -329,6 +330,11 @@ class Semantics
        function setRequire_($text)
        {
                global $requires_;
+
+               if(!is_array($requires_)){
+                       $requires_ = array();
+               }
+
                array_push($requires_, $text);
                return true;
        }
@@ -451,11 +457,16 @@ class Semantics
 
        function validToken($class, &$text, &$line)
        {
+               global $requires_;
+
+               if(!is_array($requires_)){
+                       $requires_ = array();
+               }
+
                $name = $class . ($class != $text ? " $text" : '');
 
                // Check if the command needs to be required
                // TODO: move this to somewhere more appropriate
-               global $requires_;
                if (isset($this->s_['requires']) &&
                    !in_array('"'.$this->s_['requires'].'"', $requires_))
                {
@@ -473,6 +484,7 @@ class Semantics
                $arg = &$this->s_['arguments'][0];
                foreach ($arg['values'] as $val)
                {
+
                        if (preg_match('/^'. $val['regex'] .'$/m', $text))
                        {
                                // Check if the argument value needs a 'require'
@@ -550,4 +562,4 @@ class Semantics
        }
 }
 
-?>
\ No newline at end of file
+?>