summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7ba1005)
raw | patch | inline | side by side (parent: 7ba1005)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 14 Dec 2007 07:30:30 +0000 (07:30 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 14 Dec 2007 07:30:30 +0000 (07:30 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8122 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-core/include/class_multi_plug.inc | patch | blob | history |
index 9ab38e34467ee9c95d9663903ad869ee25a482bd..c96a0eda623374891b472e6a4ca2da6bd371abfe 100644 (file)
$this->detect_multiple_used_attributes();
}
+
+ /*! \brief Combine two ldap result arrays.
+ * @param array $base Base array
+ * @param array $add Array to add
+ * @returns array Combination of $base and $add
+ */
+ private function array_combine($base,$add)
+ {
+ foreach($add as $key => $attr) {
+ if(!is_numeric($key)){
+ if(!isset($base[$key])){
+ $base[$key] = $add[$key];
+ }elseif(is_array($add[$key])){
+ for($i=0;$i<$add[$key]['count'];$i++){
+ if(!in_array($add[$key][$i],$base[$key])){
+ $base[$key][] = $add[$key][$i];
+ $base[$key]['count']++;
+ }
+ }
+ }
+ }
+ }
+ return($base);
+ }
+
+
+ /*! \brief Intersect two ldap result arrays/Inner join of two ldap result arrays
+ * @param array $base Base array
+ * @param array $minus Array number two
+ * @returns array Result intersection
+ */
+ private function array_intersect($base,$minus)
+ {
+ foreach($base as $key => $entry){
+ if(is_numeric($key) || !isset($minus[$key])){
+ unset($base[$key]);
+ }elseif(gettype($base[$key]) != gettype($minus[$key])){
+ unset($base[$key]);
+ }elseif(is_string($base[$key]) && $base[$key]!=$minus[$key]){
+ unset($base[$key]);
+ }elseif(is_array($base[$key])){
+ for($i = 0 ; $i < $base[$key]['count'] ; $i ++){
+ if(isset($base[$key][$i]) && !in_array($base[$key][$i],$minus[$key])){
+ $base[$key]['count'] --;
+ if($base[$key]['count'] == 0){
+ unset($base[$key]);
+ break;
+ }else{
+ unset($base[$key][$i]);
+ }
+ }
+ }
+ }
+ }
+ return($base);
+ }
+
/*! \brief Detect values that are used in all edited objects.
* @returns array All multiple used attributes
private function detect_multiple_used_attributes()
{
$attrs = array();
- $all = array();
$first = $this->o_tab->current;
+ $all = array();
foreach($this->a_handles as $handle){
if(count($attrs) == 0){
$attrs = $handle->by_object[$first]->attrs;
}else{
- foreach($attrs as $key => $attr){
- if(!isset($handle->by_object[$first]->attrs[$key]) || !($attr === $handle->by_object[$first]->attrs[$key])){
- unset($attrs[$key]);
- }
- }
- }
-
- foreach($handle->by_object[$first]->attrs as $key => $attr) {
- if(!is_numeric($key)){
- if(!isset($all[$key])){
- if(is_array($attr)){
- $all[$key] = $attr;
- }
- }elseif(isset($attr['count'])){
- for($i = 0; $i < $attr['count'] ; $i ++){
- if(!in_array($attr[$i],$all[$key])){
- $all[$key][] = $attr[$i];
- $all[$key]['count']++;
- }
- }
- }
- }
+ $attrs = $this->array_intersect($attrs,$handle->by_object[$first]->attrs);
}
+ $all = $this->array_combine($all,$handle->by_object[$first]->attrs);
}
foreach($this->o_tab->by_object as $name => $obj){
$this->o_tab->by_object[$name]->init_multiple_support($attrs,$all);