summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: fcde3e4)
raw | patch | inline | side by side (parent: fcde3e4)
author | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 3 Nov 2008 07:06:13 +0000 (07:06 +0000) | ||
committer | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 3 Nov 2008 07:06:13 +0000 (07:06 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@12855 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-core/include/class_plugin.inc | patch | blob | history | |
gosa-core/include/functions.inc | patch | blob | history |
index dc208f2a8dd41b4712d2f3dd90682389aa7e9ce7..4af34f1c63034b6943884472db98e7a5bd36c623 100644 (file)
if (preg_match('/top/i', $obj)){
continue;
}
- if (!isset($this->attrs['objectClass']) || !in_array_ics ($obj, $this->attrs['objectClass'])){
+ if (!in_array_ics ($obj, $this->attrs['objectClass'])){
$found= FALSE;
break;
}
/* Prepare saved attributes */
$this->saved_attributes= $this->attrs;
foreach ($this->saved_attributes as $index => $value){
- if (preg_match('/^[0-9]+$/', $index)){
+ if (is_numeric($index)){
unset($this->saved_attributes[$index]);
continue;
}
- if (!in_array($index, $this->attributes) && $index != "objectClass"){
+
+ if (!in_array_ics($index, $this->attributes) && strcasecmp('objectClass', $index)){
unset($this->saved_attributes[$index]);
continue;
}
}
unset($this->saved_attributes["$index"]["count"]);
}
+
if(isset($this->attrs['gosaUnitTag'])){
$this->saved_attributes['gosaUnitTag'] = $this->attrs['gosaUnitTag'][0];
}
index 3a0263a41f811bfff321c57a77b853671fddecdf..df091fca67fe5fd92252ededf500461974d146e8 100644 (file)
function array_remove_entries($needles, $haystack)
{
- $tmp= array();
-
- /* Loop through entries to be removed */
- foreach ($haystack as $entry){
- if (!in_array($entry, $needles)){
- $tmp[]= $entry;
- }
- }
-
- return ($tmp);
+ return (array_merge(array_diff($haystack, $needles)));
}
function array_remove_entries_ics($needles, $haystack)
{
- $tmp= array();
-
- /* Loop through entries to be removed */
- foreach ($haystack as $entry){
- if (!in_array_ics($entry, $needles)){
- $tmp[]= $entry;
- }
- }
-
- return ($tmp);
+ // strcasecmp will work, because we only compare ASCII values here
+ return (array_merge(array_udiff($haystack, $needles, 'strcasecmp')));
}
}
}
- if(preg_match('/\{id#\d+}/',$uid)){
- $size= preg_replace('/^.*{id#(\d+)}.*$/', '\\1', $uid);
+ if(preg_match('/\{id#\d+}/',$uid)){
+ $size= preg_replace('/^.*{id#(\d+)}.*$/', '\\1', $uid);
- while (true){
- mt_srand((double) microtime()*1000000);
- $number= sprintf("%0".$size."d", mt_rand(0, pow(10, $size)-1));
- $res= preg_replace('/{id#(\d+)}/', $number, $uid);
- if (!in_array($res, $used)){
- $uid= $res;
- break;
+ while (true){
+ mt_srand((double) microtime()*1000000);
+ $number= sprintf("%0".$size."d", mt_rand(0, pow(10, $size)-1));
+ $res= preg_replace('/{id#(\d+)}/', $number, $uid);
+ if (!in_array($res, $used)){
+ $uid= $res;
+ break;
+ }
}
}
- }
-/* Don't assign used ones */
-if (!in_array($uid, $used)){
- $ret[]= $uid;
-}
-}
+ /* Don't assign used ones */
+ if (!in_array($uid, $used)){
+ $ret[]= $uid;
+ }
+ }
-return(array_unique($ret));
+ return(array_unique($ret));
}
function array_key_ics($ikey, $items)
{
- /* Gather keys, make them lowercase */
- $tmp= array();
- foreach ($items as $key => $value){
- $tmp[strtolower($key)]= $key;
+ $tmp= array_change_key_case($itmes, CASE_LOWER);
+ $ikey= strtolower($ikey);
+ if (isset($tmp[$ikey])){
+ return($tmp[$ikey]);
}
- if (isset($tmp[strtolower($ikey)])){
- return($tmp[strtolower($ikey)]);
- }
-
- return ("");
+ return ('');
}
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);
+ return (count(array_diff($src, $dst)) == 0);
}