From: hickert Date: Thu, 21 Aug 2008 11:30:08 +0000 (+0000) Subject: Renamed opsi class. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=db91c9fd217a307233a9d77630cf9c9899e54b29;p=gosa.git Renamed opsi class. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@12260 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-plugins/opsi/admin/opsi/class_opsi_generic.inc b/gosa-plugins/opsi/admin/opsi/class_opsi_generic.inc deleted file mode 100644 index a36c38846..000000000 --- a/gosa-plugins/opsi/admin/opsi/class_opsi_generic.inc +++ /dev/null @@ -1,266 +0,0 @@ -opsi = new opsi($config); - $this->is_account =TRUE; - $this->initially_was_account = TRUE; - - /* Get hostId */ - if($hostId != "new"){ - $this->hostId = preg_replace("/^opsi:=([^,]*),.*$/","\\1",$hostId); - } - - /* Try to plugin */ - $this->init(); - } - - private function init() - { - $err = FALSE; - $this->init_failed = FALSE; - - /* Get product settings */ - if(!$err){ - $this->a_availableNetbootProducts = $this->opsi->get_netboot_products(); - $err |= $this->opsi->is_error(); - } - if(!$err) { - $this->a_availableLocalProducts = $this->opsi->get_local_products(); - $err |= $this->opsi->is_error(); - } - - /* Get selected products */ - if(!$err && !empty($this->hostId)) { - $tmp = array_keys($this->opsi->get_netboot_products($this->hostId)); - $this->s_selectedNetbootProduct = $tmp[0]; - $err |= $this->opsi->is_error(); - } - if(!$err && !empty($this->hostId)) { - $tmp = $this->opsi->get_local_products($this->hostId); - $err |= $this->opsi->is_error(); - $this->a_selectedLocalProducts = $tmp; - } - - /* Load product configuration */ - if(!$err && !empty($this->hostId)) { - foreach($this->a_selectedLocalProducts as $name => $data){ - $CFG = $this->opsi->get_product_properties($name,$this->hostId); - $err |= $this->opsi->is_error(); - $this->a_selectedLocalProducts[$name]['CFG'] = $CFG; - } - } - - /* Check if everything went fine else reset everything and display a retry button - */ - if($err){ - $this->a_availableNetbootProducts = array(); - $this->s_selectedNetbootProduct = ""; - $this->s_initial_selectedNetbootProduct = ""; - $this->a_availableLocalProducts = array(); - $this->a_selectedLocalProducts = array(); - $this->a_initial_selectedLocalProducts = array(); - $this->init_failed = TRUE; - }else{ - - /* Remember initial settings */ - $this->a_initial_selectedLocalProducts = $this->a_selectedLocalProducts; - $this->s_initial_selectedNetbootProduct = $this->s_selectedNetbootProduct; - } - } - - public function execute() - { - if($this->init_failed){ - - $smarty = get_smarty(); - $smarty->assign("init_failed",TRUE); - $smarty->assign("message",$this->opsi->get_error()); - return($smarty->fetch(get_template_path("generic.tpl",TRUE,dirname(__FILE__)))); - } - - - if(is_object($this->dialog)){ - $this->dialog->save_object(); - return($this->dialog->execute()); - } - - $smarty = get_smarty(); - $smarty->assign("init_failed",FALSE); - $divSLP = new divSelectBox(); - $divALP = new divSelectBox(); - - /* Create list of available local products - */ - ksort($this->a_availableLocalProducts); - foreach($this->a_availableLocalProducts as $name => $data){ - if(isset($this->a_selectedLocalProducts[$name])) continue; - - $add_tab = array("string" => ""); - $name_tab = array("string" => $name); - $desc_tab = array("string" => "
".$data['DESC']."
", - "attach" => "title='".$data['DESC']."' style='border-right:0px;'"); - $divALP->AddEntry(array($add_tab,$name_tab,$desc_tab)); - } - - /* Create list of selected local products - */ - ksort($this->a_selectedLocalProducts); - foreach($this->a_selectedLocalProducts as $name => $data){ - - $name_tab = array("string" => $name); - $desc_tab = array( - "string" => "
".$data['DESC']."
", - "attach" => "title='".$data['DESC']."'"); - - /* Only display edit button, if there is something to edit - */ - $edit = " "; - if(count($data['CFG'])){ - $edit = ""; - } - $del = ""; - - $opt_tab = array("string" => $edit.$del, - "attach" => "style='border-right:0px; width: 40px; text-align:right;'"); - $divSLP->AddEntry(array($name_tab,$desc_tab,$opt_tab)); - } - - $smarty->assign("divSLP", $divSLP->DrawList()); - $smarty->assign("divALP", $divALP->DrawList()); - $smarty->assign("SNP", $this->s_selectedNetbootProduct); - - ksort($this->a_availableNetbootProducts); - $smarty->assign("ANP", $this->a_availableNetbootProducts); - return($smarty->fetch(get_template_path("generic.tpl",TRUE,dirname(__FILE__)))); - } - - - public function save() - { - $add = array_diff_assoc($this->a_selectedLocalProducts,$this->a_initial_selectedLocalProducts); - $del = array_diff_assoc($this->a_initial_selectedLocalProducts,$this->a_selectedLocalProducts); - - foreach($del as $name => $data){ - $this->opsi->del_product_from_client($name,$this->hostId); - } - foreach($add as $name => $data){ - $this->opsi->add_product_to_client($name,$this->hostId); - $this->opsi->set_product_properties($name,$data['CFG'],$this->hostId); - } - - foreach($this->a_selectedLocalProducts as $name => $data){ - if(isset($del[$name]) || isset($add[$name])) continue; - $diff = array_diff($data['CFG'],$this->a_initial_selectedLocalProducts[$name]['CFG']); - if(count($diff)){ - $this->opsi->set_product_properties($name,$diff,$this->hostId); - } - } - - if($this->s_selectedNetbootProduct != $this->s_initial_selectedNetbootProduct){ - if(!empty($this->s_initial_selectedNetbootProduct)){ - $this->opsi->del_product_from_client($this->s_initial_selectedNetbootProduct,$this->hostId); - $this->opsi->add_product_to_client($this->s_selectedNetbootProduct,$this->hostId); - } - } - } - - public function remove_from_parent() - {} - - - public function save_object() - { - if(isset($_POST['reinit'])){ - $this->init(); - } - - if(isset($_POST['cancel_properties']) && is_object($this->dialog)){ - $this->dialog = NULL; - } - if(isset($_POST['save_properties']) && ($this->dialog instanceof opsi_product_config)){ - $this->dialog->save_object(); - $pro = $this->dialog->get_product(); - $CFG = $this->dialog->get_cfg(); - if(isset($this->a_selectedLocalProducts[$pro])){ - $this->a_selectedLocalProducts[$pro]['CFG'] = $CFG; - } - $this->dialog = NULL; - } - - if(isset($_POST['opsigeneric'])){ - - if(isset($_POST['opsi_netboot_product'])){ - $SNP = trim($_POST['opsi_netboot_product']); - if(isset($this->a_availableNetbootProducts[$SNP])){ - $this->s_selectedNetbootProduct = $SNP; - } - } - - foreach($_POST as $name => $value){ - if(preg_match("/^add_lp_/",$name)){ - $product = preg_replace("/^add_lp_(.*)_.$/","\\1",$name); - if(isset($this->a_availableLocalProducts[$product]) && !isset($this->a_selectedLocalProducts[$product])){ - $this->a_selectedLocalProducts[$product] = $this->a_availableLocalProducts[$product]; - $CFG = $this->opsi->get_product_properties($product); - $this->a_selectedLocalProducts[$product]['CFG'] = $CFG; - } - break; - } - if(preg_match("/^del_lp_/",$name)){ - $product = preg_replace("/^del_lp_(.*)_.$/","\\1",$name); - if(isset($this->a_selectedLocalProducts[$product])){ - unset($this->a_selectedLocalProducts[$product]); - } - break; - } - if(preg_match("/^edit_lp_/",$name)){ - $product = preg_replace("/^edit_lp_(.*)_.$/","\\1",$name); - $this->dialog = new opsi_product_config($this->config, - $product,$this->a_selectedLocalProducts[$product]['CFG'],$this->hostId); - break; - } - } - } - } - - /* Return plugin informations for acl handling */ - static function plInfo() - { - return (array( - "plShortName" => _("Generic"), - "plDescription" => _("Opsi generic"), - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 1, - "plSection" => array("administration"), - "plCategory" => array("opsi" => array("description" => _("Opsi client"), - "objectClass" => "dummy_class_opsi")), - "plProvidedAcls"=> array() - )); - } - -} - - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/gosa-plugins/opsi/admin/opsi/class_opsigeneric.inc b/gosa-plugins/opsi/admin/opsi/class_opsigeneric.inc new file mode 100644 index 000000000..a36c38846 --- /dev/null +++ b/gosa-plugins/opsi/admin/opsi/class_opsigeneric.inc @@ -0,0 +1,266 @@ +opsi = new opsi($config); + $this->is_account =TRUE; + $this->initially_was_account = TRUE; + + /* Get hostId */ + if($hostId != "new"){ + $this->hostId = preg_replace("/^opsi:=([^,]*),.*$/","\\1",$hostId); + } + + /* Try to plugin */ + $this->init(); + } + + private function init() + { + $err = FALSE; + $this->init_failed = FALSE; + + /* Get product settings */ + if(!$err){ + $this->a_availableNetbootProducts = $this->opsi->get_netboot_products(); + $err |= $this->opsi->is_error(); + } + if(!$err) { + $this->a_availableLocalProducts = $this->opsi->get_local_products(); + $err |= $this->opsi->is_error(); + } + + /* Get selected products */ + if(!$err && !empty($this->hostId)) { + $tmp = array_keys($this->opsi->get_netboot_products($this->hostId)); + $this->s_selectedNetbootProduct = $tmp[0]; + $err |= $this->opsi->is_error(); + } + if(!$err && !empty($this->hostId)) { + $tmp = $this->opsi->get_local_products($this->hostId); + $err |= $this->opsi->is_error(); + $this->a_selectedLocalProducts = $tmp; + } + + /* Load product configuration */ + if(!$err && !empty($this->hostId)) { + foreach($this->a_selectedLocalProducts as $name => $data){ + $CFG = $this->opsi->get_product_properties($name,$this->hostId); + $err |= $this->opsi->is_error(); + $this->a_selectedLocalProducts[$name]['CFG'] = $CFG; + } + } + + /* Check if everything went fine else reset everything and display a retry button + */ + if($err){ + $this->a_availableNetbootProducts = array(); + $this->s_selectedNetbootProduct = ""; + $this->s_initial_selectedNetbootProduct = ""; + $this->a_availableLocalProducts = array(); + $this->a_selectedLocalProducts = array(); + $this->a_initial_selectedLocalProducts = array(); + $this->init_failed = TRUE; + }else{ + + /* Remember initial settings */ + $this->a_initial_selectedLocalProducts = $this->a_selectedLocalProducts; + $this->s_initial_selectedNetbootProduct = $this->s_selectedNetbootProduct; + } + } + + public function execute() + { + if($this->init_failed){ + + $smarty = get_smarty(); + $smarty->assign("init_failed",TRUE); + $smarty->assign("message",$this->opsi->get_error()); + return($smarty->fetch(get_template_path("generic.tpl",TRUE,dirname(__FILE__)))); + } + + + if(is_object($this->dialog)){ + $this->dialog->save_object(); + return($this->dialog->execute()); + } + + $smarty = get_smarty(); + $smarty->assign("init_failed",FALSE); + $divSLP = new divSelectBox(); + $divALP = new divSelectBox(); + + /* Create list of available local products + */ + ksort($this->a_availableLocalProducts); + foreach($this->a_availableLocalProducts as $name => $data){ + if(isset($this->a_selectedLocalProducts[$name])) continue; + + $add_tab = array("string" => ""); + $name_tab = array("string" => $name); + $desc_tab = array("string" => "
".$data['DESC']."
", + "attach" => "title='".$data['DESC']."' style='border-right:0px;'"); + $divALP->AddEntry(array($add_tab,$name_tab,$desc_tab)); + } + + /* Create list of selected local products + */ + ksort($this->a_selectedLocalProducts); + foreach($this->a_selectedLocalProducts as $name => $data){ + + $name_tab = array("string" => $name); + $desc_tab = array( + "string" => "
".$data['DESC']."
", + "attach" => "title='".$data['DESC']."'"); + + /* Only display edit button, if there is something to edit + */ + $edit = " "; + if(count($data['CFG'])){ + $edit = ""; + } + $del = ""; + + $opt_tab = array("string" => $edit.$del, + "attach" => "style='border-right:0px; width: 40px; text-align:right;'"); + $divSLP->AddEntry(array($name_tab,$desc_tab,$opt_tab)); + } + + $smarty->assign("divSLP", $divSLP->DrawList()); + $smarty->assign("divALP", $divALP->DrawList()); + $smarty->assign("SNP", $this->s_selectedNetbootProduct); + + ksort($this->a_availableNetbootProducts); + $smarty->assign("ANP", $this->a_availableNetbootProducts); + return($smarty->fetch(get_template_path("generic.tpl",TRUE,dirname(__FILE__)))); + } + + + public function save() + { + $add = array_diff_assoc($this->a_selectedLocalProducts,$this->a_initial_selectedLocalProducts); + $del = array_diff_assoc($this->a_initial_selectedLocalProducts,$this->a_selectedLocalProducts); + + foreach($del as $name => $data){ + $this->opsi->del_product_from_client($name,$this->hostId); + } + foreach($add as $name => $data){ + $this->opsi->add_product_to_client($name,$this->hostId); + $this->opsi->set_product_properties($name,$data['CFG'],$this->hostId); + } + + foreach($this->a_selectedLocalProducts as $name => $data){ + if(isset($del[$name]) || isset($add[$name])) continue; + $diff = array_diff($data['CFG'],$this->a_initial_selectedLocalProducts[$name]['CFG']); + if(count($diff)){ + $this->opsi->set_product_properties($name,$diff,$this->hostId); + } + } + + if($this->s_selectedNetbootProduct != $this->s_initial_selectedNetbootProduct){ + if(!empty($this->s_initial_selectedNetbootProduct)){ + $this->opsi->del_product_from_client($this->s_initial_selectedNetbootProduct,$this->hostId); + $this->opsi->add_product_to_client($this->s_selectedNetbootProduct,$this->hostId); + } + } + } + + public function remove_from_parent() + {} + + + public function save_object() + { + if(isset($_POST['reinit'])){ + $this->init(); + } + + if(isset($_POST['cancel_properties']) && is_object($this->dialog)){ + $this->dialog = NULL; + } + if(isset($_POST['save_properties']) && ($this->dialog instanceof opsi_product_config)){ + $this->dialog->save_object(); + $pro = $this->dialog->get_product(); + $CFG = $this->dialog->get_cfg(); + if(isset($this->a_selectedLocalProducts[$pro])){ + $this->a_selectedLocalProducts[$pro]['CFG'] = $CFG; + } + $this->dialog = NULL; + } + + if(isset($_POST['opsigeneric'])){ + + if(isset($_POST['opsi_netboot_product'])){ + $SNP = trim($_POST['opsi_netboot_product']); + if(isset($this->a_availableNetbootProducts[$SNP])){ + $this->s_selectedNetbootProduct = $SNP; + } + } + + foreach($_POST as $name => $value){ + if(preg_match("/^add_lp_/",$name)){ + $product = preg_replace("/^add_lp_(.*)_.$/","\\1",$name); + if(isset($this->a_availableLocalProducts[$product]) && !isset($this->a_selectedLocalProducts[$product])){ + $this->a_selectedLocalProducts[$product] = $this->a_availableLocalProducts[$product]; + $CFG = $this->opsi->get_product_properties($product); + $this->a_selectedLocalProducts[$product]['CFG'] = $CFG; + } + break; + } + if(preg_match("/^del_lp_/",$name)){ + $product = preg_replace("/^del_lp_(.*)_.$/","\\1",$name); + if(isset($this->a_selectedLocalProducts[$product])){ + unset($this->a_selectedLocalProducts[$product]); + } + break; + } + if(preg_match("/^edit_lp_/",$name)){ + $product = preg_replace("/^edit_lp_(.*)_.$/","\\1",$name); + $this->dialog = new opsi_product_config($this->config, + $product,$this->a_selectedLocalProducts[$product]['CFG'],$this->hostId); + break; + } + } + } + } + + /* Return plugin informations for acl handling */ + static function plInfo() + { + return (array( + "plShortName" => _("Generic"), + "plDescription" => _("Opsi generic"), + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 1, + "plSection" => array("administration"), + "plCategory" => array("opsi" => array("description" => _("Opsi client"), + "objectClass" => "dummy_class_opsi")), + "plProvidedAcls"=> array() + )); + } + +} + + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-plugins/opsi/admin/opsi/generic.tpl b/gosa-plugins/opsi/admin/opsi/generic.tpl index 6497c8e4c..17b3b1ab9 100644 --- a/gosa-plugins/opsi/admin/opsi/generic.tpl +++ b/gosa-plugins/opsi/admin/opsi/generic.tpl @@ -35,5 +35,5 @@ - + {/if}