From eb3fe3299cf7458e1950e8c9e939bb8401cfdc56 Mon Sep 17 00:00:00 2001 From: hickert Date: Mon, 13 Feb 2006 10:32:00 +0000 Subject: [PATCH] Updated class plugin -> cleanup git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2673 594d385d-05f5-0310-b6e9-bd551577e9d8 --- include/class_plugin.inc | 47 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 3 deletions(-) diff --git a/include/class_plugin.inc b/include/class_plugin.inc index 99915df57..ac449d59f 100644 --- a/include/class_plugin.inc +++ b/include/class_plugin.inc @@ -332,14 +332,55 @@ class plugin continue; } - if (is_array($this->attrs[$index]) && isset($this->saved_attributes[$index]) && is_array($this->saved_attributes[$index]) && count(array_diff($this->attrs[$index], $this->saved_attributes[$index]))==0 ){ + /* 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 + ){ + 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]); - continue; } } ####################################################### - ; echo "--- DEBUG: changes ---
" ; + ; echo "--- DEBUG: changes ---".get_class($this)."
" ; ; print_a ($this->attrs) ; ; if (count($this->attrs)==0)echo "Skipped
"; ####################################################### -- 2.30.2