From 1e902786fc6a29c7471f9e4650d11137b5a5a9e1 Mon Sep 17 00:00:00 2001 From: hickert Date: Tue, 2 Sep 2008 08:49:16 +0000 Subject: [PATCH] Updated objectGroups -It s no longer possible to add a workstation to more than one object group. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@12339 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../plugins/admin/ogroups/class_ogroup.inc | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/gosa-core/plugins/admin/ogroups/class_ogroup.inc b/gosa-core/plugins/admin/ogroups/class_ogroup.inc index 029feeb17..497183659 100644 --- a/gosa-core/plugins/admin/ogroups/class_ogroup.inc +++ b/gosa-core/plugins/admin/ogroups/class_ogroup.inc @@ -59,6 +59,10 @@ class ogroup extends plugin var $was_trust_account= FALSE; + /* Already assigned Workstations. Will be hidden in selection. + */ + var $used_workstations = array(); + /* attribute list for save action */ var $attributes= array("cn", "description", "gosaGroupObjects","member","accessTo","trustModel"); var $objectclasses= array("top", "gosaGroupOfNames"); @@ -140,6 +144,28 @@ class ogroup extends plugin } } + /* Detect all workstations, which are already assigned to an object group + - Those objects will be hidden in the add object dialog. + - Check() will complain if such a system is assigned to this object group. + */ + $base = $this->config->current['BASE']; + $res = get_list("(objectClass=gotoWorkstation)","none" , + $base, array("dn"),GL_NO_ACL_CHECK|GL_SUBSEARCH); + $ws_dns = array(); + foreach($res as $data){ + $ws_dns[] = $data['dn']; + } + $res=get_list("(&(member=*)(objectClass=gosaGroupOfNames))","none", + $base, array("dn","member"),GL_NO_ACL_CHECK|GL_SUBSEARCH); + $this->used_workstations = array(); + foreach($res as $og){ + if($og['dn'] == $this->dn) continue; + $test = array_intersect($ws_dns,$og['member']); + if(count($test)){ + $this->used_workstations = array_merge($this->used_workstations,$test); + } + } + $this->orig_cn = $this->cn; $this->orig_base = $this->base; @@ -677,6 +703,12 @@ class ogroup extends plugin /* fetch results and append them to the list */ foreach($res as $attrs){ + /* Skip workstations which are already assigned to an object group. + */ + if(in_array($attrs['dn'],$this->used_workstations)){ + continue; + } + $type= $this->getObjectType($attrs); $name= $this->getObjectName($attrs); @@ -857,6 +889,23 @@ class ogroup extends plugin $new_dn= $this->dn; } + /* Check if we have workstations assigned, that are already assigned to + another object group. + */ + $test =array_intersect($this->used_workstations,$this->member); + if(count($test)){ + $str = ""; + $cnt = 0; + foreach($test as $dn){ + $str .= $dn.", "; + $cnt ++; + if($cnt > 2){ + $str .= "..."; + break; + } + } +# $message[] = sprintf(_("The following workstations are already member in another object group and can not be added: '%s'"),$str); + } $ldap = $this->config->get_ldap_link(); if($this->dn != $new_dn){ -- 2.30.2