Code

Kiosk Profiles will be saved when tab is saved
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 26 Aug 2005 12:24:28 +0000 (12:24 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 26 Aug 2005 12:24:28 +0000 (12:24 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@1232 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/personal/environment/class_environment.inc
plugins/personal/environment/class_kioskManagementDialog.inc

index 365ccc98033127278636eb3df7d850ea7fd8e0e0..c8fd3ea3ac0fbc553dc820f1f69a2a8cc588abac 100644 (file)
@@ -47,6 +47,7 @@ class environment extends plugin
   /* Kiosk profile */
   var $gotoKioskProfile   = "";     // The selected Kiosk Profile
   var $gotoKioskProfiles  = array();// All available Kiosk profiles
+  VAR $newKioskProfiles   = array();
 
   /* Hotplug Devices */
   var $gotoHotplugDevice  = "";     // Selected hotplug
@@ -254,24 +255,26 @@ class environment extends plugin
      * Read available from filesystem
      * Open management if post is transmitted
      */
-    $tmp = new kioskManagementDialog($this->config,$this->dn);
-    $list = $tmp->getKioskProfiles();
-
-    $smarty->assign("gotoKioskProfiles",$list);
-    $smarty->assign("gotoKioskProfileKeys",array_flip($list));
 
     /* Open Management Dialog */
     if(isset($_POST['KioskManagementDialog'])){
-      $this->dialog = new kioskManagementDialog($this->config,$this->dn); 
+      $this->dialog = new kioskManagementDialog($this->config,$this->dn,$this->newKioskProfiles); 
       $this->is_dialog = true;
     }
 
     /* Save */
     if(isset($_POST['KioskClose'])){
+      $this->newKioskProfiles = array_merge($this->newKioskProfiles,$this->dialog->save());
+  
       unset($this->dialog);
       $this->dialog=NULL;
       $this->is_dialog = false;
     }
+    $tmp = new kioskManagementDialog($this->config,$this->dn);
+    $list = $tmp->getKioskProfiles($this->newKioskProfiles);
+
+    $smarty->assign("gotoKioskProfiles",$list);
+    $smarty->assign("gotoKioskProfileKeys",array_flip($list));
 
     /* Logonscript Management
      * Get available LogonScripts (possibly grey out (or mark) these script that are defined for the group) 
@@ -571,7 +574,26 @@ class environment extends plugin
     $ldap= $this->config->get_ldap_link();
 
     $realyUsedAttrs= array();
-  
+
+
+    $path = search_config($this->config->data['MENU'],"environment", "KIOSKPATH"); 
+    /* Creating Kiosk Profiles */
+    foreach($this->newKioskProfiles as $file){
+      $contents = $file['contents'];
+      $fp = @fopen($path."/".$file['name'],"w");
+      if(!$fp){
+        print_red("Can't save new kiosk profiles, possibly permission denied for folder :",$path);
+      }else{
+        fwrite($fp,$contents,strlen($contents));
+      }
+      @unlink($file['tmp_name']);
+    }
+
+
+
+
+
     /* Save already used objectClasses */
     $ocs        = $this->attrs['objectClass'];
     unset($ocs['count']);
index 4d2663f46cc042cd6d6d68937eae1915565e9ea2..80b2c8f78befeee7281ca0c4477eb174b2ad21ee 100644 (file)
@@ -9,16 +9,19 @@ class kioskManagementDialog extends plugin
 
   /* attribute list for save action */
   var $ignore_account       = TRUE;
-  var $attributes           = array();
+  var $attributes           = array("filesToAttach");
   var $objectclasses        = array("whatever");
   var $use_existing         = false;  
+  var $filesToAttach        = array();
 
   var $baseDir              = "../kioskProfiles/";
 
-  function kioskManagementDialog ($config, $dn= NULL,$use_existing=false )
+  function kioskManagementDialog ($config, $dn= NULL,$attach=false )
   {
-    $this->use_existing = $use_existing;
     plugin::plugin ($config, $dn);
+    if($attach){
+      $this->filesToAttach = $attach;
+    }
     $this->baseDir = search_config($this->config->data['MENU'],"environment", "KIOSKPATH");
   }
 
@@ -34,16 +37,8 @@ class kioskManagementDialog extends plugin
     if((isset($_POST['profileAdd']))&&(isset($_FILES['newProfile']))){
       $file = $_FILES['newProfile'];
       if(!file_exists($this->baseDir.$file['name'])){
-        $name = $file['name'];
-        $str  = file_get_contents($file['tmp_name']);
-        $fp   = @fopen($this->baseDir."/".$name,"w");
-        if($fp){
-          fwrite($fp,$str,strlen($str));
-          fclose($fp);
-        }else{
-          print_red(_("Can't save kioskProfile. Permission denied.")." ".$this->baseDir);
-        }
-        unlink($file['tmp_name']);;
+        $this->filesToAttach[$file['name']]=$file;
+        $this->filesToAttach[$file['name']]['contents'] = file_get_contents($file['tmp_name']);
       }
     }
       
@@ -73,7 +68,11 @@ class kioskManagementDialog extends plugin
     return($display);
   }
 
-  function getKioskProfiles()
+  function save(){
+    return($this->filesToAttach);
+  }
+
+  function getKioskProfiles($attach = false)
   {
     $a_return = array();
     $dir = @opendir($this->baseDir);
@@ -88,6 +87,17 @@ class kioskManagementDialog extends plugin
         }
       }
     }
+    
+    foreach($this->filesToAttach as $file){
+      $a_return[$file['name']] = $file['name'];
+    }
+
+    if($attach){
+      foreach($attach as $file){
+        $a_return[$file['name']] = $file['name'];
+      }
+    }
+
     return($a_return);
   }