Code

Added automtic requirement add
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 4 May 2007 07:50:36 +0000 (07:50 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 4 May 2007 07:50:36 +0000 (07:50 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@6259 594d385d-05f5-0310-b6e9-bd551577e9d8

include/sieve/class_My_Tree.inc
include/sieve/class_sieveManagement.inc

index 99a076f3a7f0d263035c1a58c57a6aa821670714..ed66cfe9eef3b564aa18e91cc769cd8dfca47b99 100644 (file)
@@ -674,28 +674,36 @@ class My_Tree extends Tree
    *  This function is called by the 
    *  sieveElement_Classes->parent->add_require()  
    */ 
-  function add_require($str)
+  function add_require($str, $force = FALSE)
   {
-    $require_id = -1;
-    foreach($this->pap as $key => $obj){
-      if(get_class($obj) == "sieve_require"){
-        $require_id = $key;
+    if(!is_php4() || $force){
+      $require_id = -1;
+      foreach($this->pap as $key => $obj){
+        if(get_class($obj) == "sieve_require"){
+          $require_id = $key;
+        }
       }
-    }
 
-    /* No require found, add one */
-    if($require_id == -1){
-      $require = new sieve_require(NULL,preg_replace("/[^0-9]/","",microtime()),$this);
-      $require -> Add_Require($str);
-      $new = array();
-      $new[] = $require;
-      foreach($this->pap as $obj){
-        $new[] = $obj;
+      /* No require found, add one */
+      if($require_id == -1){
+        $require = new sieve_require(NULL,preg_replace("/[^0-9]/","",microtime()),$this);
+        $require -> Add_Require($str);
+        $new = array();
+        $new[] = $require;
+        foreach($this->pap as $obj){
+          $new[] = $obj;
+        }
+        $this->pap = $new;
+      } else { 
+        $this->pap[$require_id]->Add_Require($str); 
+      } 
+
+    }else{
+      if(!isset($_SESSION['add_require'])){
+        $_SESSION['add_require'] =array();
       }
-      $this->pap = $new;
-    } else { 
-      $this->pap[$require_id]->Add_Require($str);
-    } 
+      $_SESSION['add_require'][] = $str;
+    }
   }
 }
 
index 72e93211867c49dc082b637816fc148f0a6c9204..92fbed8dbc7f65ccd2eb9e794501aca4be222feb 100644 (file)
@@ -807,6 +807,13 @@ class sieveManagement extends plugin
       $ele[] = new $this->add_element_type(NULL, preg_replace("/[^0-9]/","",microtime()),$parent);
     }
 
+    /* PHP 4 automatic requirement add */
+    if(isset($_SESSION['add_require']) && count($_SESSION['add_require'])){
+      foreach($_SESSION['add_require'] as $reg){
+        $this->current_handler->tree_->add_require($reg,true);
+      }
+    }
+
     /* Get index of the element identified by object_id == $id; 
      */
     $index = -1;