From 7fed37aa5c56deb0bfe7379440d6eaf2bcc243a8 Mon Sep 17 00:00:00 2001 From: cajus Date: Mon, 13 Feb 2006 13:30:38 +0000 Subject: [PATCH] Reverted to earlier version git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2677 594d385d-05f5-0310-b6e9-bd551577e9d8 --- include/class_plugin.inc | 56 +++++++++------------------------------- 1 file changed, 12 insertions(+), 44 deletions(-) diff --git a/include/class_plugin.inc b/include/class_plugin.inc index ac449d59f..fc553bf76 100644 --- a/include/class_plugin.inc +++ b/include/class_plugin.inc @@ -319,68 +319,36 @@ class plugin function cleanup() { - /* Clean up */ foreach ($this->attrs as $index => $value){ + + /* Remove emtpy arrays if they do not differ */ if (is_array($this->attrs[$index]) && count($this->attrs[$index]) == 0 && !isset($this->saved_attributes[$index])){ unset ($this->attrs[$index]); continue; } + /* Remove single attributes that do not differ */ if (!is_array($this->attrs[$index]) && isset($this->saved_attributes[$index]) && !is_array($this->saved_attributes[$index]) && $value == $this->saved_attributes[$index]){ unset ($this->attrs[$index]); continue; } - /* Array checks */ - if(is_array($this->attrs[$index]) && isset($this->saved_attributes[$index]) && is_array($this->saved_attributes[$index])){ - - /* Different number of elements, so this attribute has changed - We must do this, because array_diff only shows differnces between - array1 -> array2 - and not - array2 -> array1 - */ - if(count($this->attrs[$index])!= count($this->saved_attributes[$index])){ - continue; - }elseif( - - /* Same number of elements, so we must check if all elements contain the same value - */ - count( - array_diff( - array_change_key_case( - array_flip( - $this->attrs[$index]), - CASE_UPPER), - array_change_key_case( - array_flip( - $this->saved_attributes[$index]), - CASE_UPPER) - ) - ) ==0 - ){ + /* Remove arrays that do not differ */ + if (is_array($this->attrs[$index]) && isset($this->saved_attributes[$index]) && is_array($this->saved_attributes[$index])){ + $dst= $this->attrs[$index]; + $src= $this->saved_attributes[$index]; + sort($dst); + sort($src); + if (count(array_diff($src, $dst))==0 ){ unset ($this->attrs[$index]); continue; - } - } - - /* Check for this combination, one value is an array and one is string. - Both contain the same value (nothing changed). - - Example : check for - $this->attrs['name']= "test"; - $this->saved_attributes['name'][0]= "test"; - - noting changed, but one is string and one is array; - */ - if(is_array($this->attrs[$index])&& count($this->attrs[$index])==1 && isset($this->saved_attributes[$index]) && (!is_array($this->saved_attributes[$index])) && $this->attrs[$index][0] == $this->saved_attributes[$index]){ - unset ($this->attrs[$index]); + } } } ####################################################### - ; echo "--- DEBUG: changes ---".get_class($this)."
" ; + ; echo "--- DEBUG: changes ---
" ; ; print_a ($this->attrs) ; ; if (count($this->attrs)==0)echo "Skipped
"; ####################################################### -- 2.30.2