Code

Added dilvlist for fai templates
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 28 Apr 2006 05:47:46 +0000 (05:47 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 28 Apr 2006 05:47:46 +0000 (05:47 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@3155 594d385d-05f5-0310-b6e9-bd551577e9d8

html/getFAIscript.php
plugins/admin/fai/class_faiTemplate.inc
plugins/admin/fai/faiTemplate.tpl

index a4c242e7dfb815ada0b718b5d29f453ad91b040b..e86bdcc78277a4f5bd777807aa3d7682eaf665a6 100644 (file)
@@ -26,15 +26,23 @@ restore_error_handler();
 
   $sr= $ldap->cat($id);
   $ei= ldap_first_entry($ldap->cid, $sr);
-  $tmp = ldap_get_values_len($ldap->cid, $ei,"FAIscript");
+  if(isset($_GET['is_template'])){
+    $tmp = ldap_get_values_len($ldap->cid, $ei,"FAItemplateFile");
+  }else{
+    $tmp = ldap_get_values_len($ldap->cid, $ei,"FAIscript");
+  }
   $tmp2 = $ldap->fetch();
 
+  $name= $tmp2['cn'][0];
   if(in_array("FAIhookEntry",$tmp2['objectClass'])){
-    $suff = ".FAIhook";
-  }else{
-    $suff = ".FAIscript";
+    $name.= ".FAIhook";
+  }elseif(in_array("FAIscriptEntry",$tmp2['objectClass'])){
+    $name .= ".FAIscript";
+  }elseif(isset($_GET['is_template'])){
+    if(preg_match("/\//",$name)){
+      $name = preg_replace("/^.*\//","",$name); 
+    }
   }
-  $name= $tmp2['cn'][0];
 
   if(isset($tmp[0])){
     header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
@@ -43,7 +51,7 @@ restore_error_handler();
     header("Pragma: no-cache");
     header("Cache-Control: post-check=0, pre-check=0");
     header("Content-type: application/octet-stream");
-    header("Content-Disposition: attachment; filename=".$name.$suff);
+    header("Content-Disposition: attachment; filename=".$name);
     echo $tmp[0];
   }else{
     echo sprintf("Can't query for this item '%s'",$id);
index daf503fff379e79ddd15e9e063d23b9be4dcb646..0b57d6c578e99b0cf4a8c6cf283e3fb75d3ab5cb 100644 (file)
@@ -101,6 +101,32 @@ class faiTemplate extends plugin
     $smarty= get_smarty();
     $display= "";
 
+    /* New Listhandling
+     */
+    $once = true;
+    foreach($_POST as $name => $value){
+      if(preg_match("/^editscript_/",$name)&&($once)){
+        $once = false;
+        $entry = preg_replace("/^editscript_/","",$name);
+        $entry = base64_decode(preg_replace("/_.*/","",$entry));
+        $this->dialog= new $this->subClassName($this->config,$this->dn,$this->SubObjects[$entry]);
+        $this->dialog->acl = $this->acl;
+        $_SESSION['objectinfo'] = $this->SubObjects[$entry]['dn'];
+        $this->dialog->parent = &$this;
+        $this->is_dialog=true;
+      }
+      if(preg_match("/^deletescript_/",$name)&&($once)){
+        $once = false;
+        $entry = preg_replace("/^deletescript_/","",$name);
+        $entry = base64_decode(preg_replace("/_.*/","",$entry));
+        if($this->SubObjects[$entry]['status'] == "edited"){
+          $this->SubObjects[$entry]['status']= "delete";
+        }else{
+          unset($this->SubObjects[$entry]);
+        }
+      }
+    }
+
     /* Add new sub object */
     if(isset($_POST['AddSubObject'])){
       $this->dialog= new $this->subClassName($this->config,"new");
@@ -112,29 +138,6 @@ class faiTemplate extends plugin
       $_SESSION['objectinfo']= $this->dn;
     }
 
-
-    /* Edit selected Sub Object */
-    if((isset($_POST['EditSubObject']))&&(isset($_POST['SubObject']))){
-
-      $temp = $_POST['SubObject'][0];
-    
-      $this->dialog= new $this->subClassName($this->config,$this->dn,$this->SubObjects[$temp]);
-      $this->dialog->acl = $this->acl;
-      $_SESSION['objectinfo'] = $this->SubObjects[$temp]['dn'];
-      $this->is_dialog=true;
-    }
-    
-    /* Remove Sub object */
-    if((isset($_POST['DelSubObject']))&&(isset($_POST['SubObject']))){
-      foreach($_POST['SubObject'] as $temp){
-        if($this->SubObjects[$temp]['status'] == "edited"){
-          $this->SubObjects[$temp]['status']= "delete";
-        }else{
-          unset($this->SubObjects[$temp]);
-        }
-      }
-    }
-
     /* Save Dialog */
     if(isset($_POST['SaveSubObject'])){
       $this->dialog->save_object();
@@ -188,6 +191,40 @@ class faiTemplate extends plugin
       return($display);
     }
 
+     /* Divlist            added 28.02.2006
+       Containing FAIscripts
+     */
+    $divlist = new divSelectBox("FAItemplates");
+    if((chkacl($this->acl,"cn")!="") || ($this->FAIstate == "freeze")){
+      $img_edit = "<input type='image' src='images/edit.png'      name='editscript_%s'    title='"._("edit")."' alt='"._("edit")."'>";
+      $img_remo = "";
+    }else{
+      $img_edit = "<input type='image' src='images/edit.png'      name='editscript_%s'    title='"._("edit")."' alt='"._("edit")."'>";
+      $img_remo = "<input type='image' src='images/edittrash.png' name='deletescript_%s'  title='"._("delete")."' alt='"._("delete")."'>";
+    }
+
+    foreach($this->getList(true) as $key => $name){
+
+      if(($this->SubObjects[$key]['status'] == "new") || ($this->SubObjects[$key]['dn'] == "new")){
+        $down = "";
+      }else{
+  
+        $dn = $this->SubObjects[$key]['dn'];       
+        $down = "<a href='getFAIscript.php?is_template&id=".base64_encode($dn)."' target='_blank'>
+          <img src='images/save.png' alt='"._("Download")."' title='"._("Download")."' border=0>
+          </a>";
+      }
+
+      $divlist->AddEntry(array( array("string"=>$name),
+            array("string"=>$down , "attach" => "style='width:20px;'"),
+            array("string"=>str_replace("%s",base64_encode($key),$img_edit.$img_remo),
+              "attach"=>"style='border-right: 0px;width:50px;text-align:right;'")));
+    }
+    $smarty->assign("Entry_divlist",$divlist->DrawList());
+    /* Divlist creation complete
+     */
+
     $smarty->assign("SubObjects",$this->getList());
 
      /* Magic quotes GPC, escapes every ' " \, to solve some security risks
index e7b4666b027bc9171f1e82f73ef8283d7ec6407d..11111ea035b0b377b421c94fdf8424a9c1ad6974 100644 (file)
                                                {t}List of template files{/t}
                                        </LABEL>
                                </h2>
-                               <table summary="" width="100%">
-                               <tr>
-                                       <td>
-                                               <select name="SubObject[]" multiple} 
-                                                       title="{t}Choose a template to delete or edit{/t}" style="width:100%;" size="20" id="SubObject">
-                                                       {html_options options=$SubObjects}
-                                               </select><br>
-                                               <input type="submit" name="AddSubObject"     value="{t}Add{/t}"         title="{t}Add{/t}" {$cnACL}>
-                                               <input type="submit" name="EditSubObject"    value="{t}Edit{/t}"    title="{t}Edit{/t}">
-                                               <input type="submit" name="DelSubObject"     value="{t}Delete{/t}"  title="{t}Delete{/t}" {$cnACL}>
-                                       </td>
-                               </tr>
-                               </table>
+                       {$Entry_divlist}
+                               <input type="submit" name="AddSubObject"     value="{t}Add{/t}"         title="{t}Add{/t}" {$cnACL}>
                </td>
        </tr>
 </table>