From b74a6ff0ea867aee2f59f9c81937d6bd6b135c64 Mon Sep 17 00:00:00 2001 From: cajus Date: Thu, 27 Oct 2005 20:58:41 +0000 Subject: [PATCH] Updated ppd manager - there's some stuff missing esp. the file move git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@1710 594d385d-05f5-0310-b6e9-bd551577e9d8 --- include/class_ppdManager.inc | 64 +++++++++++++++++++++++++++++++++--- 1 file changed, 60 insertions(+), 4 deletions(-) diff --git a/include/class_ppdManager.inc b/include/class_ppdManager.inc index f93181951..1852a3e5f 100644 --- a/include/class_ppdManager.inc +++ b/include/class_ppdManager.inc @@ -8,7 +8,6 @@ class ppdManager function ppdManager($path) { $this->path= $path; - echo "Path set to $path
"; } @@ -42,12 +41,69 @@ class ppdManager return ($list); } + + function updateAttribute($file, $section, $attribute, $value) + { + $fsection= false; + $fattribute= false; + $section= preg_replace('/^\*/', '', $section); + $attribute= preg_replace('/^\*/', '', $attribute); + + $rp= fopen($file, "r"); + $wp= fopen("$file.tmp", "w"); + + while (!feof($rp)){ + $line= fgets($rp, 1024); + + if (preg_match("/\*OpenGroup:*\s+\**$section\/*/", $line)){ + $fsection= true; + continue; + } + + if ($fsection){ + if (preg_match("/^\*CloseGroup:*\s+\**$section\/*/", $line)){ + $fsection= false; + fwrite ($wp, $line); + continue; + } + + if (preg_match("/^\*OpenUI:*\s+\**$attribute\/*/", $line)){ + $fattribute= true; + fwrite ($wp, $line); + continue; + } + + if ($fattribute){ + if (preg_match("/^\*CloseUI:*\s+\**$attribute\/*/", $line)){ + $fattribute= false; + fwrite ($wp, $line); + continue; + } + + if (preg_match("/^\*Default$attribute:*\s+/", $line)){ + $line= "*Default$attribute: $value\n"; + } + } + } + fwrite ($wp, $line); + } + + fclose($wp); + fclose($rp); + + echo "Move $file.tmp to $file
"; + } + function saveProperties($ppdFile, $properties) { - echo "
";
-		print_r ($properties);
-		echo "
"; + foreach ($properties as $name => $section){ + foreach ($section as $attribute => $value){ + if (is_array($value)){ + $this->updateAttribute($ppdFile, $name, $attribute, $value['_default']); + } + } + } } -- 2.30.2