Code

Added check to prevent removing of used profiles
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 22 Jun 2007 10:41:36 +0000 (10:41 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 22 Jun 2007 10:41:36 +0000 (10:41 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@6661 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/personal/environment/class_kioskManagementDialog.inc

index 0f28bde8945509b676af6eb6d4a4843eeaa4e2ff..17bd5d2f43042589b69e43588bb70c31c5a37a95 100644 (file)
@@ -47,7 +47,7 @@ class kioskManagementDialog extends plugin
         $this->filesToAttach[$file['name']]['contents'] = file_get_contents($file['tmp_name']);
       }
     }
-     
+
     $only_once = true;
     foreach($_POST as $name => $value){
       
@@ -59,8 +59,25 @@ class kioskManagementDialog extends plugin
         $name = preg_replace("/^.*\//i","",base64_decode($id));
         
         $filename = $this->baseDir."/".$name;
+   
+        /* check if profile is still in use */ 
+        $ldap = $this->config->get_ldap_link();
+        $ldap->cd($this->config->current['BASE']);
+        $ldap->search("(gotoKioskProfile=*lhs.schema*)",array("cn","uid","gotoKioskProfile"));
+        $used_by = "";
+        $cnt = 3;
+        while(($attrs = $ldap->fetch()) && ($cnt)){
+          $cnt --;
+          $check = preg_replace("/^.*\//i","",$attrs['gotoKioskProfile'][0]);
+          if($check == $name){
+            $used_by .= $attrs['cn'][0].", ";
+          }
+        }
+        $used_by = preg_replace("/, $/","",$used_by);
 
-        if(isset($this->filesToAttach[$name])){
+        if(!empty($used_by)){
+          print_red(sprintf(_("Can't remove kioks profile, it is still in use by the following objects '%s'."),$used_by));
+        }elseif(isset($this->filesToAttach[$name])){
           unset($this->filesToAttach[$name]);
         }else{