From 0729a3cfe0b96deac8e6b3f9ccd45200255f47c1 Mon Sep 17 00:00:00 2001 From: hickert Date: Wed, 3 Dec 2008 08:50:44 +0000 Subject: [PATCH] Updated FAI management view. -Remove method git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@13132 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../fai/admin/fai/class_divListFai.inc | 5 + .../fai/admin/fai/class_faiGroupHandle.inc | 110 +++++++++++ .../fai/admin/fai/class_faiManagement.inc | 181 +++++++++--------- gosa-plugins/fai/admin/fai/faiGroupHandle.tpl | 33 ++++ 4 files changed, 240 insertions(+), 89 deletions(-) create mode 100644 gosa-plugins/fai/admin/fai/class_faiGroupHandle.inc create mode 100644 gosa-plugins/fai/admin/fai/faiGroupHandle.tpl diff --git a/gosa-plugins/fai/admin/fai/class_divListFai.inc b/gosa-plugins/fai/admin/fai/class_divListFai.inc index 458ba09ef..8f3a594ce 100644 --- a/gosa-plugins/fai/admin/fai/class_divListFai.inc +++ b/gosa-plugins/fai/admin/fai/class_divListFai.inc @@ -261,6 +261,11 @@ class divListFai extends MultiSelectWindow */ $actions = ""; + $actions.= ""; + $actions.= ""; + /* Create list */ diff --git a/gosa-plugins/fai/admin/fai/class_faiGroupHandle.inc b/gosa-plugins/fai/admin/fai/class_faiGroupHandle.inc new file mode 100644 index 000000000..7b4454cfa --- /dev/null +++ b/gosa-plugins/fai/admin/fai/class_faiGroupHandle.inc @@ -0,0 +1,110 @@ +mode = $Action; + } + + /* Preset required values */ + foreach($FAI_group as $type => $data){ + $FAI_group[$type]['selected'] = FALSE; + } + $this->FAI_group = $FAI_group; + } + + function execute() + { + $smarty = get_smarty(); + $smarty->assign("FAI_group",$this->FAI_group); + $smarty->assign("types",$this->get_types()); + $smarty->assign("mode",$this->mode); + return($smarty->fetch(get_template_path("faiGroupHandle.tpl",TRUE,dirname(__FILE__)))); + } + + 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(isset($_POST['faiGroupHandle_apply']) || isset($_POST['faiGroupHandle_cancel'])){ + $this->open = FALSE; + } + if(isset($_POST['faiGroupHandle_cancel'])){ + $this->canceled = TRUE; + } + + } + } + + function is_open() + { + return($this->open); + } + + function is_canceled() + { + return($this->canceled); + } + + function get_mode() + { + return($this->mode); + } + + function get_selected() + { + $ret= array(); + foreach($this->FAI_group as $key => $obj){ + if($obj['selected']){ + $ret[$key] = $obj; + } + } + return($ret); + } + + function get_types() + { + $objects = array( + "FAIpartitionTable" => array("IMG"=> "plugins/fai/images/fai_partitionTable.png", + "NAME"=>_("Partition table"),"KZL"=> "PT", "VAR"=>"ShowPartitions"), + "FAIpackageList" => array("IMG"=> "plugins/fai/images/fai_packages.png", + "NAME"=>_("Package list") , "KZL"=> "PL", "VAR"=>"ShowPackages"), + "FAIscript" => array("IMG"=> "plugins/fai/images/fai_script.png", + "NAME"=>_("Scripts") , "KZL"=> "S", "VAR"=>"ShowScripts"), + "FAIvariable" => array("IMG"=> "plugins/fai/images/fai_variable.png", + "NAME"=>_("Variables") , "KZL"=> "V", "VAR"=>"ShowVariables"), + "FAIhook" => array("IMG"=> "plugins/fai/images/fai_hook.png", + "NAME"=>_("Hooks"), "KZL"=> "H", "VAR"=>"ShowHooks"), + "FAIprofile" => array("IMG"=> "plugins/fai/images/fai_profile.png", + "NAME"=>_("Profile") , "KZL"=> "P", "VAR"=>"ShowProfiles"), + "FAItemplate" => array("IMG"=> "plugins/fai/images/fai_template.png", + "NAME"=>_("Templates") , "KZL"=> "T", "VAR"=>"ShowTemplates"), + "opsi_netboot" => array("IMG"=> "plugins/opsi/images/netboot_package.png", + "NAME"=>_("OPSI netboot product") , "KZL"=> "ON", "VAR"=>"ShowOpsiNetboot"), + "opsi_local" => array("IMG"=> "plugins/opsi/images/local_package.png", + "NAME"=>_("OPSI local product") , "KZL"=> "OL", "VAR"=>"ShowOpsiLocal")); + return($objects); + } +} + + + + + + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-plugins/fai/admin/fai/class_faiManagement.inc b/gosa-plugins/fai/admin/fai/class_faiManagement.inc index 8148eb65b..3266af679 100644 --- a/gosa-plugins/fai/admin/fai/class_faiManagement.inc +++ b/gosa-plugins/fai/admin/fai/class_faiManagement.inc @@ -49,14 +49,11 @@ class faiManagement extends plugin /* Allow inserting of new elements if freezed releases */ var $allow_freeze_object_attach = TRUE; - var $no_save; var $acl_base =""; var $fai_base =""; var $fai_release =""; - var $acl_module = array("fai"); - var $opsi = NULL; /* construction/reconstruction @@ -121,8 +118,7 @@ class faiManagement extends plugin $no_save = FALSE; // hide Apply / Save buttons /* If an entry was locked, these vars will be stored in a session to allow direct edit */ - session::set('LOCK_VARS_TO_USE',array("/^edit_freeze_entry$/","/^edit_entry$/","/^id$/","/^entry_edit_/","/^entry_delete_/","/^item_selected/","/^remove_multiple_fai_objects/","/^menu_action/")); - + session::set('LOCK_VARS_TO_USE',array("/^edit_freeze_entry$/","/^edit_entry$/","/^id$/","/^entry_edit_/","/^entry_delete_/","/^item_selected/","/^remove_multiple_fai_objects/","/^menu_action/","/^faiGroupHandle_apply$/")); /**************** Handle posts @@ -131,17 +127,22 @@ class faiManagement extends plugin /* Check ImageButton posts * Create new tab ich new_xx is posted */ - $posts = array( "/remove_branch/"=>"remove_branch", "/branch_branch/"=>"branch_branch", - "/freeze_branch/"=>"freeze_branch", "/create_partition/i"=>"new_partition", - "/create_script/i"=>"new_script", "/create_hook/i"=>"new_hook", - "/create_variable/i"=>"new_variable", "/create_template/i"=>"new_template", - "/create_package/i"=>"new_package", "/create_profile/i"=>"new_profile", - "/edit_continue/"=>"select_class_name_finished", - "/^multiple_copy_fai/" => "copy_multiple", - "/^multiple_cut_fai/" => "cut_multiple", - "/^copy/" => "copy", - "/^remove_multiple_fai_objects/" => "del_multiple"); - + $posts = array( "/^remove_branch/" =>"remove_branch", + "/^branch_branch/" =>"branch_branch", + "/^freeze_branch/" =>"freeze_branch", + + "/^create_partition/i" =>"new_partition", + "/^create_script/i" =>"new_script", + "/^create_hook/i" =>"new_hook", + "/^create_variable/i" =>"new_variable", + "/^create_template/i" =>"new_template", + "/^create_package/i" =>"new_package", + "/^create_profile/i" =>"new_profile", + + "/^edit_continue$/" => "select_class_name_finished", + + "/^group_edit/" => "group_edit", + "/^group_remove/" => "group_remove"); foreach($_POST as $name => $value){ foreach($posts as $reg => $act ){ if(preg_match($reg,$name)){ @@ -152,11 +153,9 @@ class faiManagement extends plugin } } if(preg_match("/^edit_[0-9]*_.*$/",$name)){ - $i_entryID = preg_replace("/^edit_([0-9]*)_.*$/i","\\1",$name); $s_entryType= preg_replace("/^edit_[0-9]*_([^_]*)_.*$/i","\\1",$name); $s_action = "edit"; - break; }elseif(preg_match("/^entry_delete_.*/",$name)){ $s_entry = preg_replace("/^entry_delete_/","",$name); @@ -286,79 +285,24 @@ class faiManagement extends plugin /**************** - Delete confirme dialog + Delete a group of FAI objects + (Group = same name & different classes) ****************/ - if ($s_action=="delete"){ - - /* Get 'dn' from posted termlinst */ - $this->dn= $this->objects[$s_entry]['dn']; - - /* Load permissions for selected 'dn' and check if - we're allowed to remove this 'dn' */ - $acl = $this->ui->get_permissions($this->dn,"fai/".$type_acl_mapping[$this->objects[$s_entry]['type']]); - if(preg_match("/d/",$acl)){ - - /* Check locking, save current plugin in 'back_plugin', so the dialog knows where to return. */ - if (($user= get_lock($this->dn)) != ""){ - return(gen_locked_message ($user, $this->dn)); - } - - /* Lock the current entry, so nobody will edit it during deletion */ - add_lock ($this->dn, $this->ui->dn); - $smarty->assign("warning",msgPool::deleteInfo(LDAP::fix($this->dn),_("FAI object"))); - $smarty->assign("multiple", false); - return($smarty->fetch(get_template_path('remove.tpl', TRUE))); - } else { - - /* Obviously the user isn't allowed to delete. Show message and clean session. */ - msg_dialog::display(_("Permission error"), msgPool::permDelete(),ERROR_DIALOG); - } - } - - - /******************** - Delete MULTIPLE entries requested, display confirm dialog - ********************/ - - if ($s_action=="del_multiple"){ - $this->dns = array(); - $ids = $this->list_get_selected_items(); + if($s_action == "group_remove"){ + if(isset($this->objects[$s_entry])){ + $group = $this->objects[$s_entry]; + $this->dialog = new faiGroupHandle($group,"remove"); - if(count($ids)){ - - $errors = ""; - foreach($ids as $id){ - $dn = $this->objects[$id]['dn']; - $cn = $this->objects[$id]['cn']; - if(!preg_match('/^freeze/', $this->objects[$id]['FAIstate'])){ - $this->dns[$id] = $dn; - }else{ - $errors .= $cn.", "; - } - } - if ($user= get_multiple_locks($this->dns)){ - return(gen_locked_message($user,$this->dns)); - } - - if($errors != ""){ - msg_dialog::display(_("Branch locked"),sprintf(_("The following entries are locked, you can't remove them %s."), - "

".trim($errors,", ")),INFO_DIALOG); - } - - if(count($this->dns)){ - - $dns_names = array(); - foreach($this->dns as $dn){ - add_lock ($dn, $this->ui->dn); - $dns_names[] = LDAP::fix($dn); - } - - /* Lock the current entry, so nobody will edit it during deletion */ - $smarty->assign("warning",msgPool::deleteInfo($dns_names,_("FAI object"))); - $smarty->assign("multiple", true); - return($smarty->fetch(get_template_path('remove.tpl', TRUE))); - } + } + } + if($this->dialog instanceOf faiGroupHandle){ + $this->dialog->save_object(); + if($this->dialog->is_open()){ + return($this->dialog->execute()); + } + if($this->dialog->is_canceled() || isset($_POST['cancel_lock'])){ + $this->dialog = FALSE; } } @@ -408,17 +352,76 @@ class faiManagement extends plugin /* Remove lock file after successfull deletion */ $this->remove_lock(); $this->dns = array(); + $this->dialog = FALSE; } + /**************** + Delete confirme dialog + ****************/ + + if ($s_action=="del_multiple" || + $this->dialog instanceOf faiGroupHandle && $this->dialog->get_mode() == "remove"){ + + /* Collect objects to delete and check if object is freezed + */ + $dns = array(); + $errors = ""; + $this->dns = array(); + if($this->dialog instanceOf faiGroupHandle){ + $to_delete = $this->dialog->get_selected(); + foreach($to_delete as $obj){ + if(!preg_match('/^freeze/', $obj['FAIstate'])){ + $this->dns[] = $obj['dn']; + }else{ + $errors .= $obj['cn'].", "; + } + } + }else{ + $ids = $this->list_get_selected_items(); + foreach($ids as $id){ + foreach($this->objects[$id] as $obj){ + if(!preg_match('/^freeze/', $obj['FAIstate'])){ + $this->dns[] = $obj['dn']; + }else{ + $errors .= $obj['cn'].", "; + } + } + } + } + if($errors != ""){ + msg_dialog::display(_("Branch locked"),sprintf(_("The following entries are locked, you can't remove them %s."), + "

".trim($errors,", ")),INFO_DIALOG); + } + + if(count($this->dns)){ + if ($user= get_multiple_locks($this->dns)){ + return(gen_locked_message($user,$this->dns)); + } + if(count($this->dns)){ + $dns_names = array(); + foreach($this->dns as $dn){ + add_lock ($dn, $this->ui->dn); + $dns_names[] = LDAP::fix($dn); + } + /* Lock the current entry, so nobody will edit it during deletion */ + $smarty->assign("warning",msgPool::deleteInfo($dns_names,_("FAI object"))); + $smarty->assign("multiple", true); + return($smarty->fetch(get_template_path('remove.tpl', TRUE))); + } + } + } + + + /******************** Delete MULTIPLE entries Canceled ********************/ /* Remove lock */ if(isset($_POST['delete_multiple_fai_object_cancel'])){ - $this->dns = array(); $this->remove_lock(); + $this->dns = array(); } diff --git a/gosa-plugins/fai/admin/fai/faiGroupHandle.tpl b/gosa-plugins/fai/admin/fai/faiGroupHandle.tpl new file mode 100644 index 000000000..4bc7c8745 --- /dev/null +++ b/gosa-plugins/fai/admin/fai/faiGroupHandle.tpl @@ -0,0 +1,33 @@ + + + + + +{foreach from=$FAI_group item=item key=key} + + + + + + +{/foreach} +
+ {if $mode == "remove"} + + {/if} + + {$types.$key.KZL} + {$types.$key.NAME}{$item.description} +
+ + + + +

+

+ +   + +
-- 2.30.2