From: hickert Date: Thu, 13 Sep 2007 08:40:28 +0000 (+0000) Subject: Updated code. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=3338ab4810fa3b94362548bb73ec7489595f4883;p=gosa.git Updated code. Removed some foreach / for objectClass ... and replaced them with array_functions git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@7286 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/include/class_plugin.inc b/include/class_plugin.inc index 2966e8d44..eb4d40a8f 100644 --- a/include/class_plugin.inc +++ b/include/class_plugin.inc @@ -243,21 +243,16 @@ class plugin /* Get current objectClasses in order to add the required ones */ $ldap->cat($this->dn); $tmp= $ldap->fetch (); + $oc= array(); if (isset($tmp['objectClass'])){ $oc= $tmp['objectClass']; - } else { - $oc= array("count" => 0); + unset($oc['count']); } /* Remove objectClasses from entry */ $ldap->cd($this->dn); $this->attrs= array(); - $this->attrs['objectClass']= array(); - for ($i= 0; $i<$oc["count"]; $i++){ - if (!in_array_ics($oc[$i], $this->objectclasses)){ - $this->attrs['objectClass'][]= $oc[$i]; - } - } + $this->attrs['objectClass']= array_remove_entries($this->objectclasses,$oc); /* Unset attributes from entry */ foreach ($this->attributes as $val){ diff --git a/include/functions.inc b/include/functions.inc index 0d27f10b1..e6645288a 100644 --- a/include/functions.inc +++ b/include/functions.inc @@ -261,6 +261,17 @@ function array_remove_entries($needles, $haystack) } +function gosa_array_merge($ar1,$ar2) +{ + if(!is_array($ar1) || !is_array($ar2)){ + trigger_error("Specified parameter(s) are not valid arrays."); + }else{ + return(array_values(array_unique(array_merge($ar1,$ar2)))); + } +} + + + function gosa_log ($message) { global $ui; diff --git a/plugins/personal/environment/class_environment.inc b/plugins/personal/environment/class_environment.inc index 36597d19b..b1590af36 100644 --- a/plugins/personal/environment/class_environment.inc +++ b/plugins/personal/environment/class_environment.inc @@ -1075,12 +1075,7 @@ class environment extends plugin $ocs = $this->attrs['objectClass']; unset($ocs['count']); $this->attrs = array(); - $this->attrs['objectClass']= $ocs; - foreach($this->objectclasses as $objc){ - if(!in_array($objc,$this->attrs['objectClass'])){ - $this->attrs['objectClass'][]=$objc; - } - } + $this->attrs['objectClass']= gosa_array_merge($ocs,$this->objectclasses); /* 1. Search all printers that have our uid/cn as member * 2. Delete this uid/cn from every single entry and save it again.