From df772d7e0ecb3506ae11b332438f95aec62c0c36 Mon Sep 17 00:00:00 2001 From: hickert Date: Tue, 9 Oct 2007 12:56:11 +0000 Subject: [PATCH] Updated enviroment - hotplug handling git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@7478 594d385d-05f5-0310-b6e9-bd551577e9d8 --- plugins/admin/devices/class_deviceGeneric.inc | 29 +++++++++++++++++++ .../environment/class_environment.inc | 5 ++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/plugins/admin/devices/class_deviceGeneric.inc b/plugins/admin/devices/class_deviceGeneric.inc index 4ed86e7f2..958106860 100644 --- a/plugins/admin/devices/class_deviceGeneric.inc +++ b/plugins/admin/devices/class_deviceGeneric.inc @@ -119,6 +119,35 @@ class deviceGeneric extends plugin } } + + public function remove_from_parent() + { + plugin::remove_from_parent(); + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->search("(&(objectClass=gotoEnvironment)(gotoHotplugDeviceDN=*))",array("cn","gotoHotplugDeviceDN")); + $skip = FALSE; + $str =""; + $cnt = 3; + while($cnt && $attrs = $ldap->fetch()){ + if(in_array($this->dn,$attrs['gotoHotplugDeviceDN'])){ + $skip =TRUE; + $str .= $attrs['cn'][0].", "; + $cnt --; + } + } + if($skip){ + $str = preg_replace("/, $/","",$str); + + if($cnt == 0){ + $str .= "..."; + } + print_red(sprintf(_("Can't remove the device '%s' it is still in use be this user(s) : %s"),$this->cn,$str)); + }else{ + $ldap->rmdir_recursive($this->dn); + } + } + public function save() { diff --git a/plugins/personal/environment/class_environment.inc b/plugins/personal/environment/class_environment.inc index 9d618039e..51f09c0d9 100644 --- a/plugins/personal/environment/class_environment.inc +++ b/plugins/personal/environment/class_environment.inc @@ -59,6 +59,7 @@ class environment extends plugin /* Hotplug Devices */ var $gotoHotplugDevice = array(); // Selected hotplug var $gotoHotplugDevices = array();// Already configured hotplug devices + var $gotoHotplugDeviceDN= array(); var $NewAddedPrinters = array(); var $NewDeletedPrinters = array(); @@ -118,7 +119,7 @@ class environment extends plugin $ldap = $this->config->get_ldap_link(); $ldap->cd($this->config->current['BASE']); for($i = 0 ; $i < $this->attrs['gotoHotplugDeviceDN']['count'] ; $i ++){ - $ldap->cat(base64_decode($this->attrs['gotoHotplugDeviceDN'][$i])); + $ldap->cat($this->attrs['gotoHotplugDeviceDN'][$i]); $attrs = $ldap->fetch(); if(isset($attrs['gotoHotplugDevice'][0])){ @@ -1144,7 +1145,7 @@ class environment extends plugin /* Prepare HotPlug devices */ $this->attrs['gotoHotplugDevice'] = array(); foreach($this->gotoHotplugDevices as $name => $device){ - $this->attrs['gotoHotplugDeviceDN'][]= base64_encode($device['dn']); + $this->attrs['gotoHotplugDeviceDN'][]= $device['dn']; } /* Prepare LogonScripts */ -- 2.30.2