Code

Updated enviroment - hotplug handling
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 9 Oct 2007 12:56:11 +0000 (12:56 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 9 Oct 2007 12:56:11 +0000 (12:56 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@7478 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/devices/class_deviceGeneric.inc
plugins/personal/environment/class_environment.inc

index 4ed86e7f2930f74318371864122d8139367e82c2..9581068608b488c30b3256c0c00cb028ca8d41c6 100644 (file)
@@ -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()
   {
index 9d618039e01b61ea49e26b081859fad4a14e7c67..51f09c0d97280f029242ef590ede0b5ad48ea4b3 100644 (file)
@@ -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 */