From e2277b936c0d84fa98627b6f95ea56ed6c468b1b Mon Sep 17 00:00:00 2001 From: hickert Date: Thu, 28 Aug 2008 12:31:25 +0000 Subject: [PATCH] Updated opsi -Allow edit of opsi products out of the FAI management git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@12296 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../fai/admin/fai/class_divListFai.inc | 113 ++++++++++++------ .../fai/admin/fai/class_faiManagement.inc | 107 +++++++++++++++-- 2 files changed, 178 insertions(+), 42 deletions(-) diff --git a/gosa-plugins/fai/admin/fai/class_divListFai.inc b/gosa-plugins/fai/admin/fai/class_divListFai.inc index d019c57cc..f31cd2920 100644 --- a/gosa-plugins/fai/admin/fai/class_divListFai.inc +++ b/gosa-plugins/fai/admin/fai/class_divListFai.inc @@ -18,6 +18,9 @@ class divListFai extends MultiSelectWindow var $parent ; var $ui ; + var $ShowOpsiLocal; + var $ShowOpsiNetboot; + function divListFai (&$config,$parent) { MultiSelectWindow::MultiSelectWindow($config, "Fai", "fai"); @@ -52,13 +55,29 @@ class divListFai extends MultiSelectWindow $this->AddHeader(array("string" => _("Class type"), "attach" => "style='width:200px;'")); $this->AddHeader(array("string" => _("Actions"), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'")); - $this->AddCheckBox("ShowProfiles" , sprintf(_("Display objects of type '%s'."),_("Profile")) ,_("Show profiles") ,true); - $this->AddCheckBox("ShowTemplates" , sprintf(_("Display objects of type '%s'."),_("Variable")) ,_("Show templates") ,true); - $this->AddCheckBox("ShowScripts" , sprintf(_("Display objects of type '%s'."),_("Script")) ,_("Show scripts") ,true); - $this->AddCheckBox("ShowHooks" , sprintf(_("Display objects of type '%s'."),_("Hook")) ,_("Show hooks") ,true); - $this->AddCheckBox("ShowVariables" , sprintf(_("Display objects of type '%s'."),_("Variable")) ,_("Show variables") ,true); - $this->AddCheckBox("ShowPackages" , sprintf(_("Display objects of type '%s'."),_("Package")) ,_("Show packages") ,true); - $this->AddCheckBox("ShowPartitions" , sprintf(_("Display objects of type '%s'."),_("Partition")),_("Show partitions") ,true); + $this->AddCheckBox("ShowProfiles" , sprintf(_("Display objects of type '%s'."), + _("Profile")) ,_("Show profiles") ,true); + $this->AddCheckBox("ShowTemplates" , sprintf(_("Display objects of type '%s'."), + _("Variable")) ,_("Show templates") ,true); + $this->AddCheckBox("ShowScripts" , sprintf(_("Display objects of type '%s'."), + _("Script")) ,_("Show scripts") ,true); + $this->AddCheckBox("ShowHooks" , sprintf(_("Display objects of type '%s'."), + _("Hook")) ,_("Show hooks") ,true); + $this->AddCheckBox("ShowVariables" , sprintf(_("Display objects of type '%s'."), + _("Variable")) ,_("Show variables") ,true); + $this->AddCheckBox("ShowPackages" , sprintf(_("Display objects of type '%s'."), + _("Package")) ,_("Show packages") ,true); + $this->AddCheckBox("ShowPartitions" , sprintf(_("Display objects of type '%s'."), + _("Partition")),_("Show partitions") ,true); + + /* Add opsi checkboxes if opsi is enabled + */ + if($this->parent->opsi instanceof opsi && $this->parent->opsi->enabled()){ + $this->AddCheckBox("ShowOpsiNetboot" , sprintf(_("Display objects of type '%s'."), + _("Opsi netboot product")),_("Show opsi netboot pruducts") ,true); + $this->AddCheckBox("ShowOpsiLocal" , sprintf(_("Display objects of type '%s'."), + _("Opsi local product")),_("Show opsi locale pruducts") ,true); + } /* Add SubSearch checkbox */ //$this->AddCheckBox(SEPERATOR); @@ -136,12 +155,18 @@ class divListFai extends MultiSelectWindow /* Append create icons for each fai component */ $arr = array( - array("plugins/fai/images/fai_new_partitionTable.png" , _("Partition table") ,"Create_partition" , _("PT") , "faiPartitionTable"), - array("plugins/fai/images/fai_new_script.png" , _("Scripts") ,"Create_script" , _("S") , "faiScript"), - array("plugins/fai/images/fai_new_hook.png" , _("Hooks") ,"Create_hook" , _("H") , "faiHook"), - array("plugins/fai/images/fai_new_variable.png" , _("Variables") ,"Create_variable" , _("V") , "faiVariable"), - array("plugins/fai/images/fai_new_template.png" , _("Templates ") ,"Create_template" , _("I") , "faiTemplate"), - array("plugins/fai/images/fai_new_packages.png" , _("Package list") ,"Create_package" , _("PK") , "faiPackage")); + array("plugins/fai/images/fai_new_partitionTable.png" , _("Partition table") , + "Create_partition" , _("PT") , "faiPartitionTable"), + array("plugins/fai/images/fai_new_script.png" , _("Scripts") , + "Create_script" , _("S") , "faiScript"), + array("plugins/fai/images/fai_new_hook.png" , _("Hooks") , + "Create_hook" , _("H") , "faiHook"), + array("plugins/fai/images/fai_new_variable.png" , _("Variables") , + "Create_variable" , _("V") , "faiVariable"), + array("plugins/fai/images/fai_new_template.png" , _("Templates ") , + "Create_template" , _("I") , "faiTemplate"), + array("plugins/fai/images/fai_new_packages.png" , _("Package list") , + "Create_package" , _("PK") , "faiPackage")); foreach($arr as $ar){ $acl = $ui->get_permissions($this->parent->fai_base,"fai/".$ar[4]); @@ -181,14 +206,25 @@ class divListFai extends MultiSelectWindow Variable init ********************/ - $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")); + $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 package") , "KZL"=> "ON", "VAR"=>"ShowOpsiNetboot"), + "opsi_local" => array("IMG"=> "plugins/opsi/images/local_package.png", + "NAME"=>_("Opsi local package") , "KZL"=> "OL", "VAR"=>"ShowOpsiLocal")); /* Dynamic action col, depending on snapshot icons */ @@ -235,21 +271,28 @@ class divListFai extends MultiSelectWindow $action =""; $acl_all = $ui->has_complete_category_acls($this->parent->fai_base,$this->module); - /* Add copy & cut functionality */ - $action.= $this->parent->get_copypaste_action($value['dn'],"fai",$value['class'],TRUE,FALSE); - - if(preg_match("/^freeze/", $value['FAIstate'])){ - $editlink ="%NAME%"; + if(preg_match("/^opsi_/",$type)){ + $editlink ="%NAME%"; $action.= ""; - $action.= "F"; + name='entry_opsi_edit_%KEY%' title='"._("Edit product")."'> "; }else{ - $editlink ="%NAME%"; - $action.= ""; - if(preg_match("/d/",$value['acl'])){ - $action.= ""; + + /* Add copy & cut functionality */ + $action.= $this->parent->get_copypaste_action($value['dn'],"fai",$value['class'],TRUE,FALSE); + + if(preg_match("/^freeze/", $value['FAIstate'])){ + $editlink ="%NAME%"; + $action.= ""; + $action.= "F"; + }else{ + $editlink ="%NAME%"; + $action.= ""; + if(preg_match("/d/",$value['acl'])){ + $action.= ""; + } } } @@ -268,6 +311,8 @@ class divListFai extends MultiSelectWindow $edi = $editlink; $acti = $action; + $display = "
".$display."
"; + /* Create each field */ $field0 = array("string" => "" , "attach" => "style='width:20px;'"); diff --git a/gosa-plugins/fai/admin/fai/class_faiManagement.inc b/gosa-plugins/fai/admin/fai/class_faiManagement.inc index a80b4b93c..84a47931c 100644 --- a/gosa-plugins/fai/admin/fai/class_faiManagement.inc +++ b/gosa-plugins/fai/admin/fai/class_faiManagement.inc @@ -56,6 +56,8 @@ class faiManagement extends plugin var $acl_module = array("fai"); + var $opsi = NULL; + /* construction/reconstruction */ function faiManagement (&$config, $ui) @@ -64,6 +66,12 @@ class faiManagement extends plugin $this->dn = ""; $this->config = $config; $this->ui = $ui; + + /* Check if the opsi plugin is installed. + */ + if(class_available("opsi")){ + $this->opsi = new opsi($this->config);; + } /* Creat dialog object */ $this->DivListFai = new divListFai($this->config,$this); @@ -131,30 +139,53 @@ class faiManagement extends plugin "/^copy/" => "copy", "/^remove_multiple_fai_objects/" => "del_multiple"); + print_a($_POST); + foreach($_POST as $name => $value){ foreach($posts as $reg => $act ){ if(preg_match($reg,$name)){ $s_action = $act; $s_entry = ltrim(preg_replace($reg,"",$name),"_"); $s_entry = preg_replace("/_.*$/","",$s_entry); + break; } } if(preg_match("/^entry_edit_.*/",$name)){ $s_entry = preg_replace("/^entry_edit_/","",$name); $s_entry = preg_replace("/_.*$/","",$s_entry); - $s_action = "edit"; - }elseif(preg_match("/^entry_freeze_edit_.*/",$name)){ - $s_entry = preg_replace("/^entry_freeze_edit_/","",$name); - $s_entry = preg_replace("/_.*$/","",$s_entry); - $s_action = "edit"; + $s_action = "edit"; + break; + }elseif(preg_match("/^entry_freeze_edit_.*/",$name)){ + $s_entry = preg_replace("/^entry_freeze_edit_/","",$name); + $s_entry = preg_replace("/_.*$/","",$s_entry); + $s_action = "edit"; $no_save = TRUE; - }elseif(preg_match("/^entry_delete_.*/",$name)){ - $s_entry = preg_replace("/^entry_delete_/","",$name); - $s_entry = preg_replace("/_.*$/","",$s_entry); + break; + }elseif(preg_match("/^entry_delete_.*/",$name)){ + $s_entry = preg_replace("/^entry_delete_/","",$name); + $s_entry = preg_replace("/_.*$/","",$s_entry); $s_action = "delete"; + break; + } + + /* Get posts from opsi onjects + */ + if($this->opsi instanceof opsi && $this->opsi->enabled()){ + if(preg_match("/^entry_opsi_edit_/",$name)){ + $s_entry = preg_replace("/^entry_opsi_edit_([0-9]*).*$/","\\1",$name); + $s_action = "opsi_edit"; + break; + } } } + /* Get posts from opsi objects + */ + if($this->opsi instanceof opsi && $this->opsi->enabled() && isset($_GET['edit_opsi_entry'])){ + $s_entry = $_GET['edit_opsi_entry']; + $s_action = "opsi_edit"; + } + if(isset($_GET['edit_entry'])){ $s_entry = $_GET['edit_entry']; $s_action = "edit"; @@ -230,6 +261,36 @@ class faiManagement extends plugin } + /******************* + Opsi extension + *******************/ + + if($this->opsi instanceof opsi && $this->opsi->enabled()){ + if($s_action == "opsi_edit"){ + $name = $this->objects[$s_entry]['cn']; + $cfg = $this->opsi->get_product_properties($name); + $this->dialog = new opsi_product_config($this->config, $name,$cfg); + } + if($this->dialog instanceof opsi_product_config && isset($_POST['cancel_properties'])){ + $this->dialog = NULL; + } + if($this->dialog instanceof opsi_product_config && isset($_POST['save_properties'])){ + $this->dialog->save_object(); + $name = $this->dialog->get_product(); + $cfg = $this->dialog->get_cfg(); + for($i = 0 ; $i < 10 ; $i ++){ + $cfg["name$i"] = microtime(1); + } + $this->opsi->set_product_properties($name,$cfg); + $this->dialog = NULL; + } + if($this->dialog instanceof opsi_product_config){ + $this->dialog->save_object(); + return($this->dialog->execute()); + } + } + + /**************** Delete confirme dialog ****************/ @@ -1129,6 +1190,36 @@ class faiManagement extends plugin } } + /* Append opsi objects, if opsi is available and if we are on the fai_base + */ + if($this->opsi instanceof opsi && $this->opsi->enabled()){ + + $err = FALSE; + if(!$err && $this->DivListFai->ShowOpsiNetboot){ + $n_pro = $this->opsi->get_netboot_products(); + $err |= $this->opsi->is_error(); + foreach($n_pro as $name => $data){ + $entry = array("cn" => $name, + "description" => $data['DESC'], + "type" => "opsi_netboot"); + $this->objects[$name."_opsi_netboot"] = $entry; + } + } + if(!$err && $this->DivListFai->ShowOpsiLocal){ + $l_pro = $this->opsi->get_local_products(); + $err |= $this->opsi->is_error(); + foreach($l_pro as $name => $data){ + $entry = array("cn" => $name, + "description" => $data['DESC'], + "type" => "opsi_local"); + $this->objects[$name."_opsi_local"] = $entry; + } + } + if($err){ + msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG); + } + } + ksort($this->objects); reset ($this->objects); -- 2.30.2