Code

Added download button for Scripts/Hooks
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 28 Feb 2006 06:04:43 +0000 (06:04 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 28 Feb 2006 06:04:43 +0000 (06:04 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2755 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/fai/class_faiHook.inc
plugins/admin/fai/class_faiHookEntry.inc
plugins/admin/fai/class_faiScriptEntry.inc
plugins/admin/fai/faiHook.tpl
plugins/admin/fai/faiHookEntry.tpl
plugins/admin/fai/faiScriptEntry.tpl

index 4dbff3b898e37c1444c83e2d89c6b71f53d5f0aa..eef163f8828b8e304e712cbf6bcfe14fc8037b49 100644 (file)
@@ -100,6 +100,32 @@ class faiHook 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]);
+        $_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]);
+        }
+      }
+    }
+    ///// Ende new list handling
+
     /* Add new sub object */
     if(isset($_POST['AddSubObject'])){
       $this->dialog= new $this->subClassName($this->config,"new");
@@ -194,6 +220,37 @@ class faiHook extends plugin
       return($display);
     }
 
+
+    
+    /* Divlist            added 28.02.2006
+       Containing FAIscripts
+     */
+    $divlist = new divSelectBox("FAIhooks");
+    $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{
+        $down = "<a href='getFAIscript.php?id=".base64_encode($name['dn'])."' target='_blank'>
+                      <img src='images/save.png' alt='"._("Download")."' title='"._("Download")."' border=0>
+                 </a>";
+      }
+
+      $divlist->AddEntry(array( array("string"=>$name['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());
     $smarty->assign("SubObjectKeys",array_flip($this->getList()));
 
@@ -214,20 +271,30 @@ class faiHook extends plugin
 
   /* Generate listbox friendly SubObject list
   */
-  function getList(){
+  function getList($use_dns=false){
     $a_return=array();
     foreach($this->SubObjects as $obj){
       if($obj['status'] != "delete"){
-        if((isset($obj['description']))&&(!empty($obj['description']))){
-          $a_return[$obj['cn']]= $obj['cn']." [".$obj['description']."]";
+        if($use_dns){
+          if((isset($obj['description']))&&(!empty($obj['description']))){
+            $a_return[$obj['cn']]['name']= $obj['cn']." [".$obj['description']."]";
+          }else{
+            $a_return[$obj['cn']]['name']= $obj['cn'];
+          }
+          $a_return[$obj['cn']]['dn']= $obj['dn'];
         }else{
-          $a_return[$obj['cn']]= $obj['cn'];
+          if((isset($obj['description']))&&(!empty($obj['description']))){
+            $a_return[$obj['cn']]= $obj['cn']." [".$obj['description']."]";
+          }else{
+            $a_return[$obj['cn']]= $obj['cn'];
+          }
         }
       }
     }
     return($a_return);
   }
 
+
   /* Delete me, and all my subtrees
    */
   function remove_from_parent()
index 3a7e455e04ec40b4096785692bfde0700b3bdde4..83396e99214b69922e0ca0744cb0c14042d09b3c 100644 (file)
@@ -71,6 +71,15 @@ class faiHookEntry extends plugin
       }
     }
 
+    /* Create download button*/
+    if($this->dn != "new"){
+      $smarty->assign("DownMe","<a href='getFAIscript.php?id=".base64_encode($this->dn)."' target='_blank'>
+        <input type='button' value='"._("Download")."'>
+        </a>");
+    }else{
+      $smarty->assign("DownMe","");  
+    }
+
     $used_tasks = $this->parent->getUsedFAItask($this->cn);
     $tasks = $this->tasks;
     foreach($this->tasks as $id => $task){
index bc7e26f192f38b12524c58e075940f0546a12647..f52c123c5671ace45eb057bb540b64450f2ce0f8 100644 (file)
@@ -77,6 +77,15 @@ class faiScriptEntry extends plugin
       } 
     }
 
+     /* Create download button*/
+    if($this->dn != "new"){
+      $smarty->assign("DownMe","<a href='getFAIscript.php?id=".base64_encode($this->dn)."' target='_blank'>
+        <input type='button' value='"._("Download")."'>
+        </a>");
+    }else{
+      $smarty->assign("DownMe","");
+    }
+
     for($i =0 ; $i < 100 ; $i++){
       $FAIprioritys[$i]=$i;
     }
index eb9ea7f6a561b017156467aff0245c7d02cdd03b..68f2c913277a5322c94f75f2f8154e55299d0500 100644 (file)
                                <table width="100%" summary=''>
                                <tr>
                                        <td>
+                                               {$Entry_divlist}
+                                               <!--
                                                <select name="SubObject[]" title="{t}Choose a hook to delete or edit{/t}" style="width:100%" size="20" id="SubObject" multiple>
                                                        {html_options values=$SubObjectKeys output=$SubObjects}
                                                </select><br>
-                                               <input type="submit" name="AddSubObject"     value="{t}Add{/t}"         title="{t}Add{/t}">
                                                <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}">
+                                               -->
+                                               <input type="submit" name="AddSubObject"     value="{t}Add{/t}"         title="{t}Add{/t}">
                                        </td>
                                </tr>
                                </table>
index 8ec11bd47eecfad358f2a2c964e53609081c461e..699528a40c147219d780276fddfe124eabaa7d99 100644 (file)
@@ -61,6 +61,7 @@
 <div>
     <input type="file" name="ImportFile">&nbsp;
     <input type="submit" name="ImportUpload" value="{t}Import script{/t}">
+       {$DownMe}
 </div>
 
 <p class="seperator">&nbsp;</p>
index 96a16034697c72de621d657a7cf05bc10c23c185..cc1eee23c77314c8e872ec9295e3792e4a40968f 100644 (file)
@@ -61,6 +61,7 @@
 <div>
        <input type="file" name="ImportFile">&nbsp;
        <input type="submit" name="ImportUpload" value="{t}Import script{/t}">
+       {$DownMe}
 </div>
 <br>
 <div style="align:right;" align="right">