From c190ab793a8039da1e415becf8753eb2a320eaf4 Mon Sep 17 00:00:00 2001 From: hickert Date: Thu, 8 Apr 2010 14:59:37 +0000 Subject: [PATCH] Updated PPD selection git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@17563 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../systems/ppd/class_printerPPDDialog.inc | 16 ++- .../ppd/class_printerPPDSelectionDialog.inc | 129 +++++++----------- .../admin/systems/ppd/printerPPDDialog.tpl | 89 ++++++------ .../systems/ppd/printerPPDSelectionDialog.tpl | 49 +------ .../goto/admin/systems/ppd/remove_ppd.tpl | 19 ++- 5 files changed, 112 insertions(+), 190 deletions(-) diff --git a/gosa-plugins/goto/admin/systems/ppd/class_printerPPDDialog.inc b/gosa-plugins/goto/admin/systems/ppd/class_printerPPDDialog.inc index 8133fad98..a3d7cc7ef 100644 --- a/gosa-plugins/goto/admin/systems/ppd/class_printerPPDDialog.inc +++ b/gosa-plugins/goto/admin/systems/ppd/class_printerPPDDialog.inc @@ -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 diff --git a/gosa-plugins/goto/admin/systems/ppd/class_printerPPDSelectionDialog.inc b/gosa-plugins/goto/admin/systems/ppd/class_printerPPDSelectionDialog.inc index ce3e82601..fc4c50e15 100644 --- a/gosa-plugins/goto/admin/systems/ppd/class_printerPPDSelectionDialog.inc +++ b/gosa-plugins/goto/admin/systems/ppd/class_printerPPDSelectionDialog.inc @@ -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 = " -  %s - "; - $uselink = "%s"; - $dellink = " - "._("delete")." - "; + $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(){ diff --git a/gosa-plugins/goto/admin/systems/ppd/printerPPDDialog.tpl b/gosa-plugins/goto/admin/systems/ppd/printerPPDDialog.tpl index 92e2cb389..b95d8e05d 100644 --- a/gosa-plugins/goto/admin/systems/ppd/printerPPDDialog.tpl +++ b/gosa-plugins/goto/admin/systems/ppd/printerPPDDialog.tpl @@ -1,49 +1,52 @@ -

{t}Printer driver{/t}

-{if !$path_valid} -

- {msgPool type=invalidConfigurationAttribute param=ppdPath} -

-{else} - - - - - -
- - {t}Model{/t}: {$ppdString}  - {render acl=$acl} - - {/render} - +

{t}Printer driver{/t} +

- {t}New driver{/t}  - {render acl=$acl} - - {/render} - {render acl=$acl} - - - {/render} -
- {if $showOptions eq 1} -
-

{t}Options{/t}

- {$properties} - {/if} +{if !$path_valid} +

+ + {msgPool type=invalidConfigurationAttribute param=ppdPath} +

+ {else} + + + + + +
{t}Model{/t}: + {$ppdString}  + {render acl=$acl} + + {/render} + {t}New driver{/t}  + {render acl=$acl} + + {/render} + {render acl=$acl} + + {/render} +
+ + {if $showOptions eq 1} +
+

{t}Options{/t} +

+ {$properties} + + {/if} + {/if} -
- {if $path_valid} - {render acl=$acl} - - - {/render} - {/if} - - + + {if $path_valid} + {render acl=$acl} + + {/render} + + {/if} +
- - + \ No newline at end of file diff --git a/gosa-plugins/goto/admin/systems/ppd/printerPPDSelectionDialog.tpl b/gosa-plugins/goto/admin/systems/ppd/printerPPDSelectionDialog.tpl index 0fbb6af73..2a15ff7f6 100644 --- a/gosa-plugins/goto/admin/systems/ppd/printerPPDSelectionDialog.tpl +++ b/gosa-plugins/goto/admin/systems/ppd/printerPPDSelectionDialog.tpl @@ -1,49 +1,6 @@ - - - - - - -
- -
- {t}Select objects to add{/t} -
-
- {$List} - -
-
- -
- {image path="{$launchimage}" align="right"} - {t}Filters{/t} -
-
- - {$alphabet} - - - - - -
- {image path="{$search_image}" title="{t}Display objects matching{/t}"} - - - -
- {$apply} - -
-
- +

{t}Select objects to add{/t}

+{$List}
- - +
- diff --git a/gosa-plugins/goto/admin/systems/ppd/remove_ppd.tpl b/gosa-plugins/goto/admin/systems/ppd/remove_ppd.tpl index 1ef523bf0..3da3c1378 100644 --- a/gosa-plugins/goto/admin/systems/ppd/remove_ppd.tpl +++ b/gosa-plugins/goto/admin/systems/ppd/remove_ppd.tpl @@ -1,19 +1,16 @@ -
-{image path="images/warning.png" align="top"} {t}Warning{/t} +
+ {image path="images/warning.png" align="top"} {t}Warning{/t}

{$warning}

- -

- {t}The ppd file will be removed from the server and can not be restored.{/t} +

{t}The ppd file will be removed from the server and can not be restored.{/t}

-
- - - - -
+ + +
\ No newline at end of file -- 2.30.2