From 8e2fa60f9d3d32d399f0a2c4a1c65da567e9dfb1 Mon Sep 17 00:00:00 2001 From: hickert Date: Wed, 3 Dec 2008 09:05:08 +0000 Subject: [PATCH] Added FAI edit selection git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@13134 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../fai/admin/fai/class_faiGroupHandle.inc | 31 ++++++++++++++----- .../fai/admin/fai/class_faiManagement.inc | 19 ++++++++++-- gosa-plugins/fai/admin/fai/faiGroupHandle.tpl | 3 ++ 3 files changed, 43 insertions(+), 10 deletions(-) diff --git a/gosa-plugins/fai/admin/fai/class_faiGroupHandle.inc b/gosa-plugins/fai/admin/fai/class_faiGroupHandle.inc index 7b4454cfa..2ae27825e 100644 --- a/gosa-plugins/fai/admin/fai/class_faiGroupHandle.inc +++ b/gosa-plugins/fai/admin/fai/class_faiGroupHandle.inc @@ -12,12 +12,21 @@ class faiGroupHandle{ { if(in_array($Action,array("edit","remove"))){ $this->mode = $Action; + }else{ + trigger_error("Wrong action type '".$Action."'."); + exit(); } /* Preset required values */ foreach($FAI_group as $type => $data){ $FAI_group[$type]['selected'] = FALSE; } + + /* Select first entry in edit mode */ + if($this->mode == "edit"){ + reset($FAI_group); + $FAI_group[key($FAI_group)]['selected'] = TRUE; + } $this->FAI_group = $FAI_group; } @@ -33,20 +42,28 @@ class faiGroupHandle{ function save_object() { if(isset($_POST['faiGroupHandle'])){ - foreach($this->FAI_group as $key => $group){ - if(isset($_POST[$this->mode."_".$key])){ - $this->FAI_group[$key]['selected'] = TRUE; - }else{ - $this->FAI_group[$key]['selected'] = FALSE; + if($this->mode == "remove"){ + foreach($this->FAI_group as $key => $group){ + if(isset($_POST[$this->mode."_".$key])){ + $this->FAI_group[$key]['selected'] = TRUE; + }else{ + $this->FAI_group[$key]['selected'] = FALSE; + } + } + }else{ + if(isset($_POST['edit_selected']) && isset($this->FAI_group[get_post('edit_selected')])){ + foreach($this->FAI_group as $key => $obj){ + $this->FAI_group[$key]['selected'] = FALSE; + } + $this->FAI_group[get_post('edit_selected')]['selected'] = TRUE; } - } + } if(isset($_POST['faiGroupHandle_apply']) || isset($_POST['faiGroupHandle_cancel'])){ $this->open = FALSE; } if(isset($_POST['faiGroupHandle_cancel'])){ $this->canceled = TRUE; } - } } diff --git a/gosa-plugins/fai/admin/fai/class_faiManagement.inc b/gosa-plugins/fai/admin/fai/class_faiManagement.inc index 3266af679..bf3308523 100644 --- a/gosa-plugins/fai/admin/fai/class_faiManagement.inc +++ b/gosa-plugins/fai/admin/fai/class_faiManagement.inc @@ -295,6 +295,11 @@ class faiManagement extends plugin $this->dialog = new faiGroupHandle($group,"remove"); } + }elseif($s_action == "group_edit"){ + if(isset($this->objects[$s_entry])){ + $group = $this->objects[$s_entry]; + $this->dialog = new faiGroupHandle($group,"edit"); + } } if($this->dialog instanceOf faiGroupHandle){ $this->dialog->save_object(); @@ -490,9 +495,17 @@ class faiManagement extends plugin Edit entry ****************/ - if(($s_action == "edit") && (!isset($this->dialog->config))){ - if(isset($this->objects[$i_entryID][$s_entryType])){ - $entry = $this->objects[$i_entryID][$s_entryType]; + if(($s_action == "edit") || $this->dialog instanceOf faiGroupHandle && $this->dialog->get_mode() == "edit"){ + + $entry = array(); + if($this->dialog instanceOf faiGroupHandle){ + $entries = $this->dialog->get_selected(); + $entry = array_pop($entries); + }elseif(isset($this->objects[$i_entryID][$s_entryType])){ + $entry = $this->objects[$i_entryID][$s_entryType]; + } + + if(count($entry)){ $a_setup = $this->get_type($entry); $this->dn = $entry['dn']; diff --git a/gosa-plugins/fai/admin/fai/faiGroupHandle.tpl b/gosa-plugins/fai/admin/fai/faiGroupHandle.tpl index 4bc7c8745..3ebd95878 100644 --- a/gosa-plugins/fai/admin/fai/faiGroupHandle.tpl +++ b/gosa-plugins/fai/admin/fai/faiGroupHandle.tpl @@ -9,6 +9,9 @@ {if $mode == "remove"} + {elseif $mode == "edit"} + {/if} -- 2.30.2