From 95d1d3c23779f02f5eee4d06f3bf0c5bd1619374 Mon Sep 17 00:00:00 2001 From: hickert Date: Mon, 16 Jun 2008 09:11:21 +0000 Subject: [PATCH] Added simple key listing. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@11336 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../dak/addons/dak/class_dak_keyring.inc | 126 +++++++++++++++++- .../dak/addons/dak/class_dak_queue.inc | 19 ++- 2 files changed, 142 insertions(+), 3 deletions(-) diff --git a/gosa-plugins/dak/addons/dak/class_dak_keyring.inc b/gosa-plugins/dak/addons/dak/class_dak_keyring.inc index b867d2f1d..5b7c79f2d 100644 --- a/gosa-plugins/dak/addons/dak/class_dak_keyring.inc +++ b/gosa-plugins/dak/addons/dak/class_dak_keyring.inc @@ -22,15 +22,137 @@ class dak_keyring extends plugin { - public function __construct() + + private $Servers = array(); + private $selected_Server = array(); + + private $list = array(); + public $attributes = array("selected_Server"); + + public function __construct($config) { + plugin::plugin($config,NULL); + /* Collect release servers and store them + */ + $this->Servers = DAK::get_repositories_by_server($this->config); + if(count($this->Servers)){ + $this->selected_Server = key($this->Servers); + } } public function execute() { + if(isset($_POST['search'])){ + $this->list = DAK::get_queue_entries_for_servers($this->Servers[$this->selected_Server]['MAC']); + } + $smarty= get_smarty(); - return($smarty->fetch (get_template_path('dak_queue.tpl', TRUE, dirname(__FILE__)))); + $smarty->assign("Servers" , $this->Servers); + $smarty->assign("selected_Server" , $this->selected_Server); + $smarty->assign("list",$this->CreateList()); + return($smarty->fetch (get_template_path('dak_keyring.tpl', TRUE, dirname(__FILE__)))); + } + + + private function CreateList() + { + /* Get ring entries for the currently selected repository + */ + + $divlist = new divlist("DAK_keyring"); + + $divlist->SetWidth("100%"); + $divlist->SetEntriesPerPage(0); + $divlist->SetPluginMode(TRUE) ; + + $s1 = "style='width:100px;'"; + $s2 = "style='width:100px;'"; + $s3 = "style='width:100px;'"; + $s4 = ""; + $s5 = "style='width:100px; border-right:0px;'"; + + $h1 = array("string" => _("Key ID"), "attach" => $s1); + $h2 = array("string" => _("Length"), "attach" => $s2); + $h3 = array("string" => _("Validity"), "attach" => $s2); + $h4 = array("string" => _("UID"), "attach" => $s4); + $h5 = array("string" => _("Action"), "attach" => $s5); + + $divlist->SetHeader(array($h1,$h2,$h3,$h4,$h5)); + + foreach($this->list as $key => $entry){ + + if(!is_array($entry['UID'])){ + $entry['UID'] = array($entry['UID']); + } + $key_id = $entry['ATTRIBUTES']['UID']; + $length = $entry['ATTRIBUTES']['LENGTH']; + $valid = $entry['ATTRIBUTES']['VALID']; + + $hide = " "; + $down = " "; + + if(isset($entry['DETAILS']) && $entry['DETAILS'] == TRUE){ + $first = TRUE; + foreach($entry['UID'] as $val){ + + $f1 = array("string" => "","attach" => $s1); + $f2 = array("string" => "","attach" => $s2); + $f3 = array("string" => "","attach" => $s3); + $f4 = array("string" => htmlentities($val) ,"attach" => $s4); + $f5 = array("string" => "","attach" => $s5); + + if($first){ + $first = FALSE; + $f1 = array("string" => $key_id ,"attach" => $s1); + $f2 = array("string" => $length ,"attach" => $s2); + $f3 = array("string" => $valid ,"attach" => $s3); + $f4 = array("string" => $hide.htmlentities($val) ,"attach" => $s4); + $f5 = array("string" => "Actions" ,"attach" => $s5); + } + $divlist->AddEntry(array($f1,$f2,$f3,$f4,$f5)); + } + }else{ + $f1 = array("string" => $key_id, "attach" => $s1); + $f2 = array("string" => $length, "attach" => $s2); + $f3 = array("string" => $valid, "attach" => $s3); + $f4 = array("string" => $down.htmlentities($entry['UID'][0]), "attach" => $s4); + $f5 = array("string" => "Actions","attach" => $s5); + $divlist->AddEntry(array($f1,$f2,$f3,$f4,$f5)); + + } + } + return($divlist->DrawList()); + } + + + public function save_object() + { + plugin::save_object(); + + /* Save html posts, like the selected repository server + */ + foreach($this->attributes as $attr){ + if(isset($_POST[$attr])){ + $this->$attr = get_post($attr); + } + } + + /* Display details icon was clicked + */ + foreach($_POST as $name => $value){ + if(preg_match("/^details_/",$name)){ + $id = preg_replace("/^details_([0-9]*)_.*$/","\\1",$name); + if(isset($this->list[$id])){ + if(!isset($this->list[$id]['DETAILS']) || !$this->list[$id]['DETAILS']){ + $this->list[$id]['DETAILS'] = TRUE; + }else{ + $this->list[$id]['DETAILS'] = FALSE; + } + break; + } + } + } } } // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: diff --git a/gosa-plugins/dak/addons/dak/class_dak_queue.inc b/gosa-plugins/dak/addons/dak/class_dak_queue.inc index 8e7f377d5..bab1007d0 100644 --- a/gosa-plugins/dak/addons/dak/class_dak_queue.inc +++ b/gosa-plugins/dak/addons/dak/class_dak_queue.inc @@ -22,16 +22,33 @@ class dak_queue extends plugin { - public function __construct() + var $attributes = array("selected_Repository"); + var $selected_Repository = ""; + + public function __construct($config) { + plugin::plugin($config,NULL); } public function execute() { $smarty= get_smarty(); + $smarty->assign("Repositories" , DAK::get_repositories($this->config)); + $smarty->assign("selected_Repository" , $this->selected_Repository); return($smarty->fetch (get_template_path('dak_queue.tpl', TRUE, dirname(__FILE__)))); } + + public function save_object() + { + plugin::save_object(); + + foreach($this->attributes as $attr){ + if(isset($_POST[$attr])){ + $this->$attr = get_post($attr); + } + } + } } // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: ?> -- 2.30.2