From bfd886a2a214f4de62baecdc53931177b82b5eba Mon Sep 17 00:00:00 2001 From: hickert Date: Thu, 21 Jan 2010 14:58:48 +0000 Subject: [PATCH] Updated system selection for Daemon events git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@15237 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../addons/goto/events/class_DaemonEvent.inc | 3 +- .../goto/events/class_EventTargetAddList.inc | 295 +++--------------- .../goto/events/eventTargetSystems-filter.tpl | 38 +++ .../goto/events/eventTargetSystems-filter.xml | 64 ++++ .../goto/events/eventTargetSystems-list.tpl | 31 ++ .../goto/events/eventTargetSystems-list.xml | 79 +++++ 6 files changed, 258 insertions(+), 252 deletions(-) create mode 100644 gosa-plugins/goto/addons/goto/events/eventTargetSystems-filter.tpl create mode 100644 gosa-plugins/goto/addons/goto/events/eventTargetSystems-filter.xml create mode 100644 gosa-plugins/goto/addons/goto/events/eventTargetSystems-list.tpl create mode 100644 gosa-plugins/goto/addons/goto/events/eventTargetSystems-list.xml diff --git a/gosa-plugins/goto/addons/goto/events/class_DaemonEvent.inc b/gosa-plugins/goto/addons/goto/events/class_DaemonEvent.inc index ba24adf9d..e0c0b30bd 100644 --- a/gosa-plugins/goto/addons/goto/events/class_DaemonEvent.inc +++ b/gosa-plugins/goto/addons/goto/events/class_DaemonEvent.inc @@ -272,10 +272,9 @@ class DaemonEvent if($this->target_divlist == NULL){ $this->target_divlist = new EventTargetAddList($this->config,$this); } - $this->target_divlist->execute(); $smarty = get_smarty(); - $smarty->assign("divlist",$this->target_divlist->Draw()); + $smarty->assign("divlist",$this->target_divlist->execute()); return($smarty->fetch(get_template_path('target_list.tpl', TRUE, dirname(__FILE__)))); } diff --git a/gosa-plugins/goto/addons/goto/events/class_EventTargetAddList.inc b/gosa-plugins/goto/addons/goto/events/class_EventTargetAddList.inc index fbc32992a..e0f8e6db0 100644 --- a/gosa-plugins/goto/addons/goto/events/class_EventTargetAddList.inc +++ b/gosa-plugins/goto/addons/goto/events/class_EventTargetAddList.inc @@ -20,268 +20,63 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -class EventTargetAddList extends MultiSelectWindow +class EventTargetAddList extends management { - public $display_server = TRUE; - public $display_workstation = TRUE; - public $display_ogroup = TRUE; - public $filter_iprange = FALSE; + // Tab definition + protected $skipFooter = TRUE; + protected $skipHeader = TRUE; - public $regex = "*"; - public $ipfrom = "0.0.0.0"; - public $ipto = "*"; - public $_target_list = array(); - - public $workstation_list = array(); - public $server_list = array(); - - - function __construct(&$config,$parent) + function __construct($config,$ui) { - MultiSelectWindow::MultiSelectWindow($config, "EventTargetAddList", - array("server", - "workstation", - "ogroups")); - - $this->parent = $parent; - $this->ui = get_userinfo(); - - - $this->target_divlist = new MultiSelectWindow($this->config,"EventAddTargedtList","gotomasses"); - $this->SetSummary(_("Targets")); - $this->EnableCloseButton(FALSE); - $this->EnableSaveButton(FALSE); - - $this->SetInformation(_("This dialog shows all available targets for the event. Check the targets you want to add and use the 'Apply' button.")); - - /* Toggle all selected / deselected */ - $chk = ""; - - $this->EnableAplhabet(TRUE); - - /* set Page header */ - $this->AddHeader(array("string"=> $chk, "attach"=>"style='width:20px;'")); - $this->AddHeader(array("string"=>" ","attach"=>"style='width:20px;'")); - $this->AddHeader(array("string"=>_("System / Department"))); - - //$name,$string,$value,$conn,$image="images/lists/search.png") - $this->AddRegex("regex" ,"regex" ,"*" , TRUE); - $this->AddRegex("ipfrom","ipfrom" ,"0.0.0.0" , FALSE); - $this->AddRegex("ipto" ,"ipto" ,"255.255.255.255" , FALSE); - - $this->AddCheckBox("display_server","1" ,_("Display server"),TRUE); - $this->AddCheckBox("display_workstation","1",_("Display workstation"),TRUE); - $this->AddCheckBox("display_ogroup","1" ,_("Display object groups"),TRUE); - $this->AddCheckBox("filter_iprange","1" ,_("Filter by IP range"),FALSE); - - - - /* Create a list of servers - */ - $tmp = get_sub_list("(&(macAddress=*)(objectClass=goServer))", - "server",get_ou("serverRDN"),$config->current['BASE'], - array("cn","objectClass","description","ipHostNumber","macAddress"),GL_SUBSEARCH); - foreach($tmp as $server){ - $this->server_list[$server['dn']] = $server; - } - - /* Create a list of workstations - */ - $tmp = get_sub_list("(&(macAddress=*)(objectClass=gotoWorkstation))", - "server",get_ou("workstationRDN"),$config->current['BASE'], - array("cn","objectClass","description","ipHostNumber","macAddress"),GL_SUBSEARCH); - foreach($tmp as $server){ - $this->workstation_list[$server['dn']] = $server; - } - - } - - - function execute() - { - $this->ClearElementsList(); - $this->AddDepartments($this->selectedBase,2,1); - $this->setEntries(); - $this->GenHeader(); - } - - - function GenHeader() - { - $modules = array("server","workstation"); - - /* Add base */ - $tmp = array(); - $base = $this->config->current['BASE']; - $tmp[] = array("dn"=>$this->config->current['BASE']); - $tmp= array_merge($tmp,get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $modules, $base, - array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH)); - - $deps = array(); - foreach($tmp as $tm){ - $deps[$tm['dn']] = $tm['dn']; - } - - $department = $departments = array(); - $ui= get_userinfo(); - $d = $ui->get_module_departments($modules); - foreach($d as $department){ - $departments[$department] = $department; - } - - /* Load possible departments */ - $ids = $this->config->idepartments; - $first = ""; - $found = FALSE; - $options = array(); - foreach($ids as $dep => $name){ - if(isset($deps[$dep]) && in_array_ics($dep, $departments)){ - - /* Keep first base dn in mind, we could need this - * info if no valid base was found - */ - if(empty($first)) { - $first = $dep['dn']; - } - - $value = $ids[$dep]; - if ($this->selectedBase == $dep){ - $found = TRUE; - $options.= ""; - } else { - $options.= ""; - } - } - } - - $listhead = $this->get_default_header(); - - /* Add base selection */ - $listhead .= _("Base")."  ". - "  "; - - $this->SetListHeader($listhead); - + $this->config = $config; + $this->ui = $ui; + $this->storagePoints = array( + get_ou("serverRDN"), + get_ou("workstationRDN"), + get_ou('terminalRDN')); + +# // Build filter +# if (session::global_is_set(get_class($this)."_filter")){ +# $filter= session::global_get(get_class($this)."_filter"); +# } else { + $filter = new filter(get_template_path("../../addons/goto/events/eventTargetSystems-filter.xml", TRUE)); + $filter->setObjectStorage($this->storagePoints); +# } + $this->setFilter($filter); + + // Build headpage + $headpage = new listing(get_template_path("../../addons/goto/events/eventTargetSystems-list.xml", TRUE)); + $headpage->setFilter($filter); + parent::__construct($config, $ui, "object", $headpage); } - - function get_selected_targets() - { - $a_targets = array(); - foreach($this->list_get_selected_items() as $id){ - if(in_array("gosaGroupOfNames",$this->_target_list[$id]['objectClass'])){ - foreach($this->_target_list[$id]['member'] as $mem_dn){ - if(isset($this->workstation_list[$mem_dn])){ - $a_targets[] = $this->workstation_list[$mem_dn]['macAddress'][0]; - } - if(isset($this->server_list[$mem_dn])){ - $a_targets[] = $this->server_list[$mem_dn]['macAddress'][0]; - } - } - }else{ - if(isset($this->_target_list[$id]['macAddress'][0])){ - $a_targets[] = $this->_target_list[$id]['macAddress'][0]; - } - } - } - return($a_targets); + function save_object() {} + function Draw(){ + } - - function setEntries() + function execute() { - $_target_list = array(); - if($this->display_server){ - $_target_list = array_merge($_target_list, - get_list("(&(cn=".$this->regex.")(objectClass=goServer))", - "server",get_ou("serverRDN").$this->selectedBase, - array("cn","objectClass","description","ipHostNumber","macAddress"),GL_NONE)); - } - if($this->display_workstation){ - $_target_list = array_merge($_target_list, - get_list("(&(cn=".$this->regex.")(objectClass=gotoWorkstation))", - "workstation",get_ou("workstationRDN").$this->selectedBase, - array("cn","objectClass","description","ipHostNumber","macAddress"),GL_NONE)); - } - if($this->display_ogroup){ - $_target_list = array_merge($_target_list, - get_list("(&(cn=".$this->regex.")(member=*)(objectClass=gosaGroupOfNames))", - "ogroups",get_ou("ogroupRDN").$this->selectedBase, - array("cn","objectClass","description","member"),GL_NONE)); - } - $this->_target_list = $_target_list; - - $tmp = array(); - foreach($this->_target_list as $key => $object){ - $tmp[$key] = $object['cn'][0]; - } - natcasesort($tmp); - - foreach($tmp as $key => $obj){ - - $obj = $this->_target_list[$key]; - $name = $obj['cn'][0]; - if(isset($obj['description'])){ - $name .= " [".$obj['description'][0]."]"; - } - if(isset($obj['macAddress'])){ - $name .= " - ".$obj['macAddress'][0].""; - } - if(isset($obj['ipHostNumber'])){ - $name .= " - ".$obj['ipHostNumber'][0].""; - } - - $img =""; - if(in_array("goServer",$obj['objectClass'])){ - $img = 'S'; - - if($this->filter_iprange){ - if(!isset($obj['ipHostNumber']) || !tests::is_in_ip_range($this->ipfrom,$this->ipto, $obj['ipHostNumber'][0])) { - continue; - } - } - if(!isset($this->server_list[$obj['dn']])){ - continue; - } - }elseif(in_array("gotoWorkstation",$obj['objectClass'])){ - $img = 'W'; - if($this->filter_iprange){ - if(!isset($obj['ipHostNumber']) || !tests::is_in_ip_range($this->ipfrom,$this->ipto,$obj['ipHostNumber'][0])) { - continue; - } - } - if(!isset($this->workstation_list[$obj['dn']])){ - continue; - } - }elseif(in_array("gosaGroupOfNames",$obj['objectClass'])){ - $img = 'O'; - } - - $field1 = array("string" => "", - "attach" => "style='width:20px;'"); - $field2 = array("string" => $img, - "attach" => "style='width:20px;'"); - $field3 = array("string" => $name , "attach" => "title='".$obj['dn']."'"); - $this->AddElement(array($field1,$field2,$field3)); - } + $str = management::execute(); + $str.= "

 

+

+ +   + +

"; + return($str); } - - /*! \brief Returns a set of elements selected in a MultiSelectWindow - @return Array[integer]=integer - */ - protected function list_get_selected_items() + function save() { - $ids = array(); - foreach($_POST as $name => $value){ - if(preg_match("/^item_selected_[0-9]*$/",$name)){ - $id = preg_replace("/^item_selected_/","",$name); - $ids[$id] = $id; - } + $act = $this->detectPostActions(); + $headpage = $this->getHeadpage(); + if(!isset($act['targets'])) return(array()); + $ret = array(); + foreach($act['targets'] as $dn){ + $ret[] = $headpage->getEntry($dn); } - return($ids); + return($ret); } } // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: diff --git a/gosa-plugins/goto/addons/goto/events/eventTargetSystems-filter.tpl b/gosa-plugins/goto/addons/goto/events/eventTargetSystems-filter.tpl new file mode 100644 index 000000000..2f09c5868 --- /dev/null +++ b/gosa-plugins/goto/addons/goto/events/eventTargetSystems-filter.tpl @@ -0,0 +1,38 @@ +
+

+ [F]{t}Filter{/t} +

+
+ +
+ +
+ + {$SERVER} 
+ {$WORKSTATION} 
+ {$TERMINAL} 
+ +
+ {$SCOPE} + + + + + + +
+ + + {$NAME} +
+ + + + + +
+ {$APPLY} +
+
diff --git a/gosa-plugins/goto/addons/goto/events/eventTargetSystems-filter.xml b/gosa-plugins/goto/addons/goto/events/eventTargetSystems-filter.xml new file mode 100644 index 000000000..2c635a4fb --- /dev/null +++ b/gosa-plugins/goto/addons/goto/events/eventTargetSystems-filter.xml @@ -0,0 +1,64 @@ + + + + + server + + true + + + + + LDAP + (&(|$SERVER $WORKSTATION $TERMINAL ) $NAME) + dn + objectClass + cn + description + + auto + + + + textfield + NAME + 20 + 60 + + + (cn=*$*) + true + + LDAP + (cn=*$NAME*) + cn + 0.5 + 3 + + + + + checkbox + SERVER + true + (objectClass=goServer) + + + + + checkbox + WORKSTATION + true + + (objectClass=gotoWorkstation) + + + + checkbox + TERMINAL + true + + (objectClass=gotoTerminal) + + + diff --git a/gosa-plugins/goto/addons/goto/events/eventTargetSystems-list.tpl b/gosa-plugins/goto/addons/goto/events/eventTargetSystems-list.tpl new file mode 100644 index 000000000..b233c5874 --- /dev/null +++ b/gosa-plugins/goto/addons/goto/events/eventTargetSystems-list.tpl @@ -0,0 +1,31 @@ + + + + + + + +
+
+

 {$HEADLINE} {$SIZELIMIT}

+
+ +
+
+ + +
{$ROOT} {$BACK} {$HOME} {$RELOAD} {$SEPARATOR} {t}Base{/t} {$BASE}  {$SEPARATOR}  {$ACTIONS}
+
+
+ +
+
+ + + + {$LIST} +
+ {$FILTER} +
+ + diff --git a/gosa-plugins/goto/addons/goto/events/eventTargetSystems-list.xml b/gosa-plugins/goto/addons/goto/events/eventTargetSystems-list.xml new file mode 100644 index 000000000..b863f795e --- /dev/null +++ b/gosa-plugins/goto/addons/goto/events/eventTargetSystems-list.xml @@ -0,0 +1,79 @@ + + + + + true + false + true + true + + server + + 1 + + + + goServer + server + servgeneric + plugins/systems/images/select_server.png + + + + + gotoWorkstation + workstation + workgeneric + plugins/systems/images/select_workstation.png + + + + + gotoTerminal + terminal + termgeneric + plugins/systems/images/select_terminal.png + + + + + + |20px;c|220px|| + + + %{filter:objectType(dn,objectClass)} + + + + %{filter:departmentLink(row,dn,description)} + 1 + + + + %{filter:objectType(dn,objectClass)} + + + + + cn + string + %{cn} + true + + + + + description + string + %{description} + true + + +
+ + + + + + +
-- 2.30.2