From a6d2168f754660bb97c7b97c4405044302eb7864 Mon Sep 17 00:00:00 2001 From: hickert Date: Fri, 4 May 2007 07:50:36 +0000 Subject: [PATCH] Added automtic requirement add git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@6259 594d385d-05f5-0310-b6e9-bd551577e9d8 --- include/sieve/class_My_Tree.inc | 44 +++++++++++++++---------- include/sieve/class_sieveManagement.inc | 7 ++++ 2 files changed, 33 insertions(+), 18 deletions(-) diff --git a/include/sieve/class_My_Tree.inc b/include/sieve/class_My_Tree.inc index 99a076f3a..ed66cfe9e 100644 --- a/include/sieve/class_My_Tree.inc +++ b/include/sieve/class_My_Tree.inc @@ -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; + } } } diff --git a/include/sieve/class_sieveManagement.inc b/include/sieve/class_sieveManagement.inc index 72e932118..92fbed8db 100644 --- a/include/sieve/class_sieveManagement.inc +++ b/include/sieve/class_sieveManagement.inc @@ -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; -- 2.30.2