Code

Updated PPD selection
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 8 Apr 2010 14:59:37 +0000 (14:59 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 8 Apr 2010 14:59:37 +0000 (14:59 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@17563 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/goto/admin/systems/ppd/class_printerPPDDialog.inc
gosa-plugins/goto/admin/systems/ppd/class_printerPPDSelectionDialog.inc
gosa-plugins/goto/admin/systems/ppd/printerPPDDialog.tpl
gosa-plugins/goto/admin/systems/ppd/printerPPDSelectionDialog.tpl
gosa-plugins/goto/admin/systems/ppd/remove_ppd.tpl

index 8133fad98c0740dc32fa6ef920735200791f209c..a3d7cc7efe4bf2a51775868ff0ff9b65e34e9413 100644 (file)
@@ -165,17 +165,19 @@ class printerPPDDialog extends plugin
     }
 
     /* Div Selection */ 
-    if((isset($_GET['act']))&&($_GET['act']=="use")){
-      $this->SelectPPD(base64_decode($_GET['id']));
-      unset($this->dialog);
-      $this->dialog=FALSE;
-
+    if($this->dialog instanceOf printerPPDSelectionDialog){
+        $this->dialog->save_object();
+        if($this->dialog->isSelected()){
+            $this->SelectPPD($this->dialog->save());
+            unset($this->dialog);
+            $this->dialog=FALSE;
+        }
     }
 
     /* if a dialog is open, print the dialog instead of this class */
     if(is_object($this->dialog)){
-      $display = $this->dialog->execute();
-      return($display);
+        $display = $this->dialog->execute();
+        return($display);
     }
 
     // ENDE  PPD selection / upload / dialog handling 
index ce3e8260162a54f74ed95f0724f1569a86d51819..fc4c50e151bbd4fcf0b7b1b366df84f346098cbd 100644 (file)
@@ -11,6 +11,7 @@ class printerPPDSelectionDialog extends plugin
   var $header               =array();
   var $current_del_id       = "";
   var $Vendor               = "";
+  var $selectedPPD = "";
 
   function printerPPDSelectionDialog (&$config, $dn= NULL,$list=false,$headers=false,$ppd=false)
   {
@@ -18,15 +19,22 @@ class printerPPDSelectionDialog extends plugin
     $this->list       = $list;
     $this->header     = $headers;
     $this->depselect  = $this->config->current['BASE'];
-    
-    if(!session::is_set('printerPPDSelectionDialog')){
-      session::set("printerPPDSelectionDialog",array('regex'=> "*"));
-    }  
 
-    /* Order the manufacturers index */
-    ksort($this->header);
+    // Prepare lists
+    $this->ppdList = new sortableListing();
+    $this->ppdList->setDeleteable(false);
+    $this->ppdList->setEditable(true);
+    $this->ppdList->setWidth("100%");
+    $this->ppdList->setColspecs(array('*','20px'));
+    $this->ppdList->setHeight("200px");
+    $this->ppdList->setHeader(array(_("PPD")));
+    $this->ppdList->setDefaultSortColumn(0);
   }
 
+    function isSelected(){
+        return(!empty($this->selectedPPD));
+    }
+
   function execute()
   {
        /* Call parent execute */
@@ -35,24 +43,7 @@ class printerPPDSelectionDialog extends plugin
     /* Fill templating stuff */
     $smarty= get_smarty();
     $display= "";
-    $s_action = "none";
-    $printerPPDSelectionDialog = session::get('printerPPDSelectionDialog');
-    $regex = $printerPPDSelectionDialog['regex'];
-
-    if(isset($_GET['search'])){
-      $regex = $_GET['search']."*";
-    }
-  
-    if(isset($_POST['regex'])){
-      $regex= $_POST['regex'];
-    }
-    
-    $regex = str_replace("**","*",$regex);
-    $printerPPDSelectionDialog['regex'] = $regex;
-    session::set('printerPPDSelectionDialog',$printerPPDSelectionDialog);
  
-
     /* Delete requested, check if everything is ok and display confirmation dialog */
     if(isset($_GET['act']) && $_GET['act'] == "del"){
 
@@ -102,81 +93,41 @@ class printerPPDSelectionDialog extends plugin
     }
 
 
-    /** Added **/
+    // Build up ppd 
     $list = array();
     foreach($this->list as $cat => $ppds){
-      foreach($ppds as $ppd){
-       $name = $ppd['ppd']['name'];
-        if(preg_match("/^".str_replace("*",".*",$regex)."/i",$name)){
-          if(is_readable($ppd['link'])){
+        foreach($ppds as $ppd){
+            $name = $ppd['ppd']['name'];
             $list[$ppd['link']] = $ppd;
-          }
         }
-      }
-    }
-
-    /* Sort the list alphabetically */
-    asort($list);
-    if((isset($_GET['act']))&&($_GET['act']=="open"))  {
-      
-      if((!empty($_GET['id'])) && (!isset( $this->header[base64_decode($_GET['id'])]))){
-        msg_dialog::display(_("PPD error"), sprintf(_("Cannot locate vendor '%s' in available PPDs!"), base64_decode($_GET['id'])), ERROR_DIALOG);
-        $this->Vendor = ""; 
-      }else{
-        $this->Vendor = base64_decode($_GET['id']);
-      }
     }
 
-    $div = new divSelectBox("printerPPDSelectionDialog");
-    $div ->SetHeight(450);
-    $div ->SetSummary(_("Printer ppd selection."));
-    
-    $linkopen = "<a href='?plug=".$_GET['plug']."&amp;act=open&amp;id=%s'>
-                  <img src='images/lists/folder.png' class='center' alt='' border=0>&nbsp;%s
-                 </a>";
-    $uselink  = "<a href='?plug=".$_GET['plug']."&amp;act=use&amp;id=%s'>%s</a>";
-    $dellink  = "<a href='?plug=".$_GET['plug']."&amp;act=del&amp;id=%s'>
-                  <img src='images/lists/trash.png' alt='"._("delete")."' border=0>
-                 </a>"; 
 
+    $data = $lData = array();
     if(empty($this->Vendor)){
-      foreach($this-> header as $key => $entry){
-        $div ->AddEntry (array(
-                 
-              array("string"=>sprintf($linkopen,base64_encode($key),$key),"attach"=>"style='border-right:0px;'")
-              ));
-      }
+      foreach($this->header as $key => $entry){
+        $data[$key] = array('TYPE' => 'VENDOR' , 'ID' => $key);
+        $lData[$key] = array('data'=>array($key));
+      } 
+      
     }else{
-      $div ->AddEntry (array(
-            array("string"=>sprintf($linkopen,"",".. ["._("back")."]"),"attach"=>"style='border-right:0px;'")
-            ));
+      $data[] = array('TYPE' => 'VENDOR' , 'ID' => '..');
+      $lData[] = array('data'=>array(".. ["._("back")."]"));
+
       foreach($list as $key => $ppd){
        $name = $ppd['ppd']['name'];
         if(preg_match("/^".$this->Vendor."/", $name)){
-
-          if(is_writeable($ppd['link'])){
-            $del_str = sprintf($dellink,base64_encode($key));
-          }else{
-            $del_str = "";
-          }
-
-          $div ->AddEntry (array(
-                                  array("string"=>sprintf($uselink,base64_encode($key),$name)),
-                                  array("string"=>$del_str,"attach"=>"style='border-right:0px;'")
-
-                ));
+          $data[$key] = array('TYPE' => 'PPD' , 'ID' => $key);
+          $lData[$key] = array('data'=>array($name));
         }
       }
     }
-
-    $smarty->assign("List",         $div -> DrawList());
-    $smarty->assign("search_image", get_template_path('images/lists/search.png'));
-    $smarty->assign("launchimage",  get_template_path('images/lists/action.png'));
-    $smarty->assign("tree_image",   get_template_path('images/lists/search-subtree.png'));
-    $smarty->assign("alphabet",     generate_alphabet());
-    $smarty->assign("apply",        apply_filter());
-    $smarty->assign("regex",        $regex);
+   
+    $this->ppdList->setAcl('rwcdm');
+    $this->ppdList->setListData($data,$lData);
+    $this->ppdList->update();
+    
+    $smarty->assign("List",         $this->ppdList->render());
   
     $display.= $smarty->fetch(get_template_path('printerPPDSelectionDialog.tpl', TRUE,dirname(__FILE__)));
     return($display);
@@ -184,6 +135,18 @@ class printerPPDSelectionDialog extends plugin
 
   function save_object()
   {
+    $this->ppdList->save_object();
+    $action = $this->ppdList->getAction();
+    if($action['action'] == "edit"){
+        $data = $this->ppdList->getData($action['targets'][0]);
+        if($data['TYPE'] == "VENDOR"){
+            $this->Vendor = $data['ID'];
+        }
+        if($data['TYPE'] == "PPD"){
+            $this->selectedPPD = $data['ID'];
+        }
+    } 
+
   } 
 
   function check(){
index 92e2cb389e723af01b7cca9c41a11c6dd110b566..b95d8e05de371c57b229f613db3350c201c998df 100644 (file)
@@ -1,49 +1,52 @@
-<h3>{t}Printer driver{/t}</h3>
-{if !$path_valid}
-<p>
-       <b>{msgPool type=invalidConfigurationAttribute param=ppdPath}</b>
-</p>
-{else}
-       <table summary="" width="100%">
-               <tr>
-                       <td>
-
-                               {t}Model{/t}: <i>{$ppdString}</i>&nbsp;
-                               {render acl=$acl}
-                               <button type='submit' name='SelectPPD'>{t}Select{/t}</button>
 
-                               {/render}
-                       </td>
-                       <td style='padding-left:10px;' class='left-border'>
+<h3>{t}Printer driver{/t}
+</h3>
 
-                               {t}New driver{/t}&nbsp;
-                               {render acl=$acl}
-                               <input type="file" value="" name="NewPPDFile">
-                               {/render}
-                               {render acl=$acl}
-                               <button type='submit' name='SubmitNewPPDFile'>{t}Upload{/t}</button>
-
-                               {/render}
-                       </td>
-               </tr>
-       </table>
-       {if $showOptions eq 1}
-       <hr>
-       <h3>{t}Options{/t}</h3>
-       {$properties}
-       {/if}
+{if !$path_valid}
+ <p>
+  <b>
+  {msgPool type=invalidConfigurationAttribute param=ppdPath}</b>
+ </p>
+ {else}
+ <table summary="" width="100%">
+  <tr>
+   <td>{t}Model{/t}:<i>
+    {$ppdString}</i>&nbsp;
+    {render acl=$acl}
+     <button type='submit' name='SelectPPD'>{t}Select{/t}</button>
+    {/render}
+   </td>
+   <td style='padding-left:10px;' class='left-border'>{t}New driver{/t}&nbsp;
+    {render acl=$acl}
+     <input type="file" value="" name="NewPPDFile">
+    {/render}
+    {render acl=$acl}
+     <button type='submit' name='SubmitNewPPDFile'>{t}Upload{/t}</button>
+    {/render}
+   </td>
+  </tr>
+ </table>
+ {if $showOptions eq 1}
+  <hr>
+  <h3>{t}Options{/t}
+  </h3>
+  {$properties}
+  
+ {/if}
 {/if}
-
 <hr>
 <div class="plugin-actions">
-       {if $path_valid}
-         {render acl=$acl}
-           <button type='submit' name='SavePPD'>{msgPool type=applyButton}</button>
-
-         {/render}
-       {/if}
-       <button type='submit' name='ClosePPD'>{msgPool type=cancelButton}</button>
-
+ {if $path_valid}
+  {render acl=$acl}
+   <button type='submit' name='SavePPD'>
+   {msgPool type=applyButton}</button>
+  {/render}
+  
+ {/if}
+ <button type='submit' name='ClosePPD'>
+ {msgPool type=cancelButton}</button>
 </div>
-       
-<input type="hidden" name="PPDDisSubmitted" value="1">
+<input type="hidden" name="PPDDisSubmitted" value="1">
\ No newline at end of file
index 0fbb6af73f5e45278bfd9f33fc5ff5d13ae0e0fc..2a15ff7f663a967408c088c0edad360e4ec7f474 100644 (file)
@@ -1,49 +1,6 @@
-<table style='width:100%; ' summary="{t}PPD selection dialog{/t}">
-
-       <tr>
-               <td style='width=50%;'>
-
-                       <div class="contentboxh" style="height:20px;">
-                                       <b>{t}Select objects to add{/t}</b>
-                       </div>
-                       <div class="contentboxb">
-          {$List}
-                                       <input type=hidden name="edit_helper">
-                       </div>
-               </td>
-               <td>
-
-                       <div class="contentboxh" style="height:20px;">
-          {image path="{$launchimage}" align="right"}
-          <b>{t}Filters{/t}</b>
-      </div>
-      <div class="contentboxb">
-
-          {$alphabet}
-        <table style='background-color:#F8F8F8' summary="{t}Filter options{/t}" width="100%">
-          <tr>
-            <td style="width:18px">
-              {image path="{$search_image}" title="{t}Display objects matching{/t}"}
-
-            </td>
-            <td>
-              <input type='text' style="width:99%" name='regex' maxlength='20' value='{$regex}' 
-                title='{t}Regular expression for matching object names{/t}' onChange="mainform.submit();">
-            </td>
-          </tr>
-        </table>
-              {$apply}
-
-      </div>
-    </td>
-  </tr>
-</table>
-
+<h3>{t}Select objects to add{/t}</h3>
+{$List}
 <hr>
 <div class="plugin-actions">
-  <button type='submit' name='ClosePPDSelection'>{t}Close{/t}</button>
-
+ <button type='submit' name='ClosePPDSelection'>{t}Close{/t}</button>
 </div>
-<!--
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
--->
index 1ef523bf0aa88d2e5d62cc6431cc19883a42bd95..3da3c1378ef52b2114e1e1dbe7cb2ea426d05433 100644 (file)
@@ -1,19 +1,16 @@
-<div style="font-size:18px;">
-{image path="images/warning.png" align="top"}&nbsp;{t}Warning{/t}
 
+<div style="font-size:18px;">
+ {image path="images/warning.png" align="top"}&nbsp;{t}Warning{/t}
 </div>
 <p>
  {$warning}
 </p>
-
-<p>
- {t}The ppd file will be removed from the server and can not be restored.{/t}
+<p>{t}The ppd file will be removed from the server and can not be restored.{/t}
 </p>
-
 <hr>
 <div class="plugin-actions">
-  <button type='submit' name='delete_ppd_confirm'>{msgPool type=delButton}</button>
-
-  <button type='submit' name='delete_cancel'>{msgPool type=cancelButton}</button>
-
-</div>
+ <button type='submit' name='delete_ppd_confirm'>
+ {msgPool type=delButton}</button>
+ <button type='submit' name='delete_cancel'>
+ {msgPool type=cancelButton}</button>
+</div>
\ No newline at end of file