From 778d567e80d70978aba02106fa81f79d1be1fab4 Mon Sep 17 00:00:00 2001 From: hickert Date: Fri, 26 Aug 2005 12:24:28 +0000 Subject: [PATCH] Kiosk Profiles will be saved when tab is saved git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@1232 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../environment/class_environment.inc | 36 ++++++++++++++---- .../class_kioskManagementDialog.inc | 38 ++++++++++++------- 2 files changed, 53 insertions(+), 21 deletions(-) diff --git a/plugins/personal/environment/class_environment.inc b/plugins/personal/environment/class_environment.inc index 365ccc980..c8fd3ea3a 100644 --- a/plugins/personal/environment/class_environment.inc +++ b/plugins/personal/environment/class_environment.inc @@ -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']); diff --git a/plugins/personal/environment/class_kioskManagementDialog.inc b/plugins/personal/environment/class_kioskManagementDialog.inc index 4d2663f46..80b2c8f78 100644 --- a/plugins/personal/environment/class_kioskManagementDialog.inc +++ b/plugins/personal/environment/class_kioskManagementDialog.inc @@ -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); } -- 2.30.2