From b71ee632e82bd020a315386d123de454aed04122 Mon Sep 17 00:00:00 2001 From: cajus Date: Wed, 12 Oct 2005 13:03:41 +0000 Subject: [PATCH] * Cosmetic changes * Fixups for template dialog git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@1562 594d385d-05f5-0310-b6e9-bd551577e9d8 --- plugins/admin/fai/class_faiTemplate.inc | 6 +- plugins/admin/fai/class_faiTemplateEntry.inc | 85 ++++++++- plugins/admin/fai/faiPackage.tpl | 6 +- plugins/admin/fai/faiPackageConfiguration.tpl | 1 - plugins/admin/fai/faiPackageEntry.tpl | 2 +- plugins/admin/fai/faiPackageNew.tpl | 1 - plugins/admin/fai/faiProfileEntry.tpl | 3 +- plugins/admin/fai/faiScriptEntry.tpl | 1 - plugins/admin/fai/faiTemplateEntry.tpl | 180 ++++++++++++------ 9 files changed, 210 insertions(+), 75 deletions(-) diff --git a/plugins/admin/fai/class_faiTemplate.inc b/plugins/admin/fai/class_faiTemplate.inc index fd30c52e0..4618e899a 100644 --- a/plugins/admin/fai/class_faiTemplate.inc +++ b/plugins/admin/fai/class_faiTemplate.inc @@ -24,8 +24,8 @@ class faiTemplate extends plugin var $subClassName = "faiTemplateEntry"; /* Attributes to initialise for each subObject */ - var $subAttributes = array("cn","description","FAItemplateFile","FAItemplatePath"); - var $sub64coded = array("FAItemplateFile","FAItemplatePath"); + var $subAttributes = array("cn","description","FAItemplateFile","FAItemplatePath","FAIowner","FAImode"); + var $sub64coded = array("FAItemplatePath"); /* Specific attributes */ var $cn = ""; // The class name for this object @@ -67,7 +67,7 @@ class faiTemplate extends plugin $this->SubObjects[$object['cn'][0]][$codeIt]=base64_decode($this->SubObjects[$object['cn'][0]][$codeIt]); } - $this->SubObjects[$object['cn'][0]]['FAItemplateFile'] =base64_decode($this->readBinary("FAItemplateFile",$object['dn'])); + $this->SubObjects[$object['cn'][0]]['FAItemplateFile'] = $this->readBinary("FAItemplateFile",$object['dn']); $this->SubObjects[$object['cn'][0]]['status'] = "edited"; $this->SubObjects[$object['cn'][0]]['dn'] = $object['dn']; diff --git a/plugins/admin/fai/class_faiTemplateEntry.inc b/plugins/admin/fai/class_faiTemplateEntry.inc index 200e0074a..0399e5d8d 100644 --- a/plugins/admin/fai/class_faiTemplateEntry.inc +++ b/plugins/admin/fai/class_faiTemplateEntry.inc @@ -9,7 +9,7 @@ class faiTemplateEntry extends plugin /* attribute list for save action */ var $ignore_account= TRUE; - var $attributes = array("Object_cn","Object_description","Object_FAItemplateFile","Object_FAItemplatePath"); + var $attributes = array("Object_cn","Object_description","Object_FAItemplateFile","Object_FAItemplatePath","Object_FAImode","Object_user","Object_group","Object_binary","Object_FAIowner"); var $objectclasses= array(); var $orig_cn = ""; @@ -20,6 +20,11 @@ class faiTemplateEntry extends plugin var $Object_FAItemplatePath = ""; var $Object_description = ""; var $Object_status = "new"; + var $Object_FAImode = "0640"; + var $Object_FAIowner = "root.root"; + var $Object_user = "root"; + var $Object_group = "root"; + var $Object_binary = false; function faiTemplateEntry ($config, $dn= NULL,$object=false) { @@ -35,24 +40,35 @@ class faiTemplateEntry extends plugin $this->Object_status = "new"; $this->orig_cn = false; } + $this->Object_user = explode( '.', $this->Object_FAIowner ); + $this->Object_group = $this->Object_user[1]; + $this->Object_user = $this->Object_user[0]; + $_SESSION['binary'] = $this->Object_FAItemplateFile; + $_SESSION['binarytype'] = 'octet-stream'; + $_SESSION['binaryfile'] = basename( $this->Object_FAItemplatePath ); } function execute() { /* Fill templating stuff */ $smarty = get_smarty(); + $smarty->assign("rand", rand(0, 10000)); $display = ""; if(isset($_POST['TmpFileUpload'])){ if($str=file_get_contents($_FILES['FAItemplateFile']['tmp_name'])){ $this->Object_FAItemplateFile = $str; + + /* If we don't have a filename set it from upload filename. */ + if( 0 == strlen( $this->Object_FAItemplatePath ) ) + $this->Object_FAItemplatePath = $_FILES['FAItemplateFile']['name']; } } - $status="
"._("No file uploaded"); + $status= _("no file uploaded yet"); if(strlen($this->Object_FAItemplateFile)){ - $status="
".sprintf(_("File uploaded, size : %s byte"),strlen($this->Object_FAItemplateFile)); + $status= sprintf(_("exists in database (size: %s bytes)"),strlen($this->Object_FAItemplateFile)); } $smarty->assign("status",$status); @@ -67,12 +83,24 @@ class faiTemplateEntry extends plugin } } + /* Assign file modes */ + $tmode= "$this->Object_FAImode "; + foreach (array("s", "u", "g", "o") as $type){ + $current= substr($tmode, 0, 1); + $tmode= preg_replace("/^./", "", $tmode); + $nr= 1; + while ($nr < 5){ + if ($current & $nr){ + $smarty->assign($type.$nr, "checked"); + } else { + $smarty->assign($type.$nr, ""); + } + $nr+= $nr; + } + } + $smarty->assign("Object_FAItemplateFile",""); - for($i =1 ; $i <= 100 ; $i++){ - $Object_FAIprioritys[$i]=$i; - } - $smarty->assign("Object_FAIprioritys",$Object_FAIprioritys); $display.= $smarty->fetch(get_template_path('faiTemplateEntry.tpl', TRUE)); return($display); } @@ -80,9 +108,17 @@ class faiTemplateEntry extends plugin /* Save data to object */ function save_object() { + if (!isset($_POST['Object_FAItemplatePath'])){ + return; + } if(isset($_POST['SubObjectFormSubmitted'])){ foreach($this->attributes as $attrs){ - if($attrs == "Object_FAItemplateFile") continue; + if($attrs == "Object_FAItemplateFile") + continue; + if($attrs == "Object_FAIowner") { + $this->$attrs = $_POST["Object_user"] . '.' . $_POST["Object_group"]; + continue; + } if(isset($_POST[$attrs])){ $this->$attrs = $_POST[$attrs]; }else{ @@ -90,6 +126,21 @@ class faiTemplateEntry extends plugin } } } + + /* Save mode */ + $tmode= ""; + foreach (array("s", "u", "g", "o") as $type){ + $nr= 1; + $dest= 0; + while ($nr < 5){ + if (isset($_POST["$type$nr"])){ + $dest+= $nr; + } + $nr+= $nr; + } + $tmode= $tmode.$dest; + } + $this->Object_FAImode= $tmode; } /* Check supplied data */ @@ -107,10 +158,24 @@ class faiTemplateEntry extends plugin if(empty($this->Object_cn)){ $message[] = _("Please enter a name."); } - - if(preg_match("/[^0-9a-z]/i",$this->Object_cn)){ + elseif(preg_match("/[^0-9a-z]/i",$this->Object_cn)){ $message[] = _("Please enter a valid name. Only a-Z 0-9 are allowed."); } + + if(empty($this->Object_user)){ + $message[] = _("Please enter a user."); + } + elseif(preg_match("/[^0-9a-z]/i",$this->Object_user)){ + $message[] = _("Please enter a valid user. Only a-Z 0-9 are allowed."); + } + + if(empty($this->Object_group)){ + $message[] = _("Please enter a group."); + } + elseif(preg_match("/[^0-9a-z]/i",$this->Object_group)){ + $message[] = _("Please enter a valid group. Only a-Z 0-9 are allowed."); + } + return ($message); } diff --git a/plugins/admin/fai/faiPackage.tpl b/plugins/admin/fai/faiPackage.tpl index 022e16f86..bbb5b8fbc 100644 --- a/plugins/admin/fai/faiPackage.tpl +++ b/plugins/admin/fai/faiPackage.tpl @@ -70,9 +70,9 @@ {html_options options=$usedPackages}
- - - + + + diff --git a/plugins/admin/fai/faiPackageConfiguration.tpl b/plugins/admin/fai/faiPackageConfiguration.tpl index 4d0de8e8e..1bd55ddf2 100644 --- a/plugins/admin/fai/faiPackageConfiguration.tpl +++ b/plugins/admin/fai/faiPackageConfiguration.tpl @@ -4,5 +4,4 @@ - diff --git a/plugins/admin/fai/faiPackageEntry.tpl b/plugins/admin/fai/faiPackageEntry.tpl index e2edeff86..6c1a17e26 100644 --- a/plugins/admin/fai/faiPackageEntry.tpl +++ b/plugins/admin/fai/faiPackageEntry.tpl @@ -62,7 +62,7 @@
- +
diff --git a/plugins/admin/fai/faiPackageNew.tpl b/plugins/admin/fai/faiPackageNew.tpl index 258a6fd58..3458d88c1 100644 --- a/plugins/admin/fai/faiPackageNew.tpl +++ b/plugins/admin/fai/faiPackageNew.tpl @@ -65,5 +65,4 @@ - diff --git a/plugins/admin/fai/faiProfileEntry.tpl b/plugins/admin/fai/faiProfileEntry.tpl index b49352384..62c4788fb 100644 --- a/plugins/admin/fai/faiProfileEntry.tpl +++ b/plugins/admin/fai/faiProfileEntry.tpl @@ -63,7 +63,6 @@
- +
- diff --git a/plugins/admin/fai/faiScriptEntry.tpl b/plugins/admin/fai/faiScriptEntry.tpl index 7f6b7ada0..0017e6095 100644 --- a/plugins/admin/fai/faiScriptEntry.tpl +++ b/plugins/admin/fai/faiScriptEntry.tpl @@ -62,7 +62,6 @@   -
  diff --git a/plugins/admin/fai/faiTemplateEntry.tpl b/plugins/admin/fai/faiTemplateEntry.tpl index 6afe0286f..8f838e28a 100644 --- a/plugins/admin/fai/faiTemplateEntry.tpl +++ b/plugins/admin/fai/faiTemplateEntry.tpl @@ -1,63 +1,137 @@ + +

 {t}Generic{/t}

- - - + + + + +
-

 {t}Generic{/t}

- - - - - - - - - -
- {t}Name{/t}{$must}  - - -
- {t}Description{/t}  - - -
-
-   -
+ {t}Name{/t}{$must}  +    + + {t}Description{/t}  + +
+ +

 

+ + + + + + + +

 {t}Template attributes{/t}

+ + + + + + + + +
+ + + {$status} + {if $Object_FAItemplatePath} + {t}Save template{/t}... + {/if} +
+
+ +   +
+
+
+ + + +
+
+ + + + + + + + + +
+ + -

 {t}Template attributes{/t}

- - - - - - - - - -
- - - - - {$status} -
- - - -
+ +
+ + + +
+
+
{t}Access{/t}{$must}  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - -
{t}Class{/t}{t}Read{/t}{t}Write{/t}{t}Execute{/t} {t}Special{/t} 
{t}User{/t} {$u1} ({t}SUID{/t})
{t}Group{/t} ({t}GUID{/t})
{t}Others{/t} ({t}sticky{/t})
+
+ +
+ + + + +

 


 
- + + + -- 2.30.2