summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a521879)
raw | patch | inline | side by side (parent: a521879)
author | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 16 Feb 2006 13:16:27 +0000 (13:16 +0000) | ||
committer | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 16 Feb 2006 13:16:27 +0000 (13:16 +0000) |
Added functionality convert certain single attribute arrays to the destination type, if needed
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2698 594d385d-05f5-0310-b6e9-bd551577e9d8
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2698 594d385d-05f5-0310-b6e9-bd551577e9d8
include/class_plugin.inc | patch | blob | history | |
include/functions.inc | patch | blob | history |
index 5b57ce3d1b0d264df67037e264c7f8d443282979..ef02566336e6f5c66844a272930d59e734bdd75b 100644 (file)
--- a/include/class_plugin.inc
+++ b/include/class_plugin.inc
}
+
function cleanup()
{
foreach ($this->attrs as $index => $value){
+ /* Convert arrays with one element to non arrays, if the saved
+ attributes are no array, too */
+ if (is_array($this->attrs[$index]) &&
+ count ($this->attrs[$index]) == 1 &&
+ isset($this->saved_attributes[$index]) &&
+ !is_array($this->saved_attributes[$index])){
+
+ $tmp= $this->attrs[$index][0];
+ $this->attrs[$index]= $tmp;
+ }
+
/* Remove emtpy arrays if they do not differ */
- if (is_array($this->attrs[$index]) && count($this->attrs[$index]) == 0 && !isset($this->saved_attributes[$index])){
+ 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]){
+ if (!is_array($this->attrs[$index]) &&
+ isset($this->saved_attributes[$index]) &&
+ !is_array($this->saved_attributes[$index]) &&
+ $this->attrs[$index] == $this->saved_attributes[$index]){
+
unset ($this->attrs[$index]);
continue;
}
/* Remove arrays that do not differ */
- if (is_array($this->attrs[$index]) && isset($this->saved_attributes[$index]) && is_array($this->saved_attributes[$index])){
- if (count(array_diff($this->attrs[$index],$this->saved_attributes[$index]))==0 ){
+ if (is_array($this->attrs[$index]) &&
+ isset($this->saved_attributes[$index]) &&
+ is_array($this->saved_attributes[$index])){
+
+ if (!array_differs($this->attrs[$index],$this->saved_attributes[$index])){
unset ($this->attrs[$index]);
continue;
}
diff --git a/include/functions.inc b/include/functions.inc
index 1fa462740a06a8334e2a92f76b1d05279bdc7531..0d64f1e28a7d0df854f197f0d02bfaeac09afff0 100644 (file)
--- a/include/functions.inc
+++ b/include/functions.inc
return ("");
}
+
+function array_differs($src, $dst)
+{
+ /* If the count is differing, the arrays differ */
+ if (count ($src) != count ($dst)){
+ return (TRUE);
+ }
+
+ /* So the count is the same - lets check the contents */
+ $differs= FALSE;
+ foreach($src as $value){
+ if (!in_array($value, $dst)){
+ $differs= TRUE;
+ }
+ }
+
+ return ($differs);
+}
+
+
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
?>