From 704dab2d8067e111def9f9be294815df6eaf2e2b Mon Sep 17 00:00:00 2001 From: hickert Date: Fri, 9 Sep 2005 07:02:11 +0000 Subject: [PATCH] Added package dialog git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@1338 594d385d-05f5-0310-b6e9-bd551577e9d8 --- plugins/admin/FAI/class_faiManagement.inc | 17 ++- plugins/admin/FAI/class_faiPackage.inc | 140 ++++++++++++++++++++++ plugins/admin/FAI/faiPackage.tpl | 29 +++++ plugins/admin/FAI/tabsPackage.inc | 42 +++++++ 4 files changed, 227 insertions(+), 1 deletion(-) create mode 100644 plugins/admin/FAI/class_faiPackage.inc create mode 100644 plugins/admin/FAI/faiPackage.tpl create mode 100644 plugins/admin/FAI/tabsPackage.inc diff --git a/plugins/admin/FAI/class_faiManagement.inc b/plugins/admin/FAI/class_faiManagement.inc index 0c6f27ae1..03fb54f72 100644 --- a/plugins/admin/FAI/class_faiManagement.inc +++ b/plugins/admin/FAI/class_faiManagement.inc @@ -23,6 +23,7 @@ require "tabsHook.inc"; require "tabsTemplate.inc"; require "tabsScript.inc"; require "tabsProfile.inc"; +require "tabsPackage.inc"; class faiManagement extends plugin { @@ -120,6 +121,8 @@ class faiManagement extends plugin $s_action = "new_variable"; }elseif(preg_match("/create_template/i",$key)){ $s_action = "new_template"; + }elseif(preg_match("/create_package/i",$key)){ + $s_action = "new_package"; }elseif(preg_match("/create_profile/i",$key)){ $s_action = "new_profile"; }elseif(preg_match("/UseNewClass/",$key)){ @@ -211,7 +214,7 @@ class faiManagement extends plugin if($s_action == "edit"){ $entry = $this->objects[$s_entry]; - $a_setup = ( $this->get_type($entry)); + $a_setup = ($this->get_type($entry)); $this->dn = $entry['dn']; @@ -246,6 +249,11 @@ class faiManagement extends plugin $this->dialog = new askClassName($this->config,$this->dn,$this->ui,"FAItemplate"); } + /* Dialog handling */ + if($s_action == "new_package"){ + $this->dialog = new askClassName($this->config,$this->dn,$this->ui,"FAIpackageList"); + } + /* New Profile */ if($s_action == "new_profile"){ $this->dn = "new" ; @@ -366,6 +374,9 @@ class faiManagement extends plugin "  ". + "  ". + "  ". @@ -576,6 +587,10 @@ class faiManagement extends plugin if(in_array("FAIprofile",$array['objectClass'])){ return(array("tabsProfile","faiProfile","FAIPROFILETABS")); } + + if(in_array("FAIpackageList",$array['objectClass'])){ + return(array("tabsPackage","faiPackage","FAIPACKAGETABS")); + } } } diff --git a/plugins/admin/FAI/class_faiPackage.inc b/plugins/admin/FAI/class_faiPackage.inc new file mode 100644 index 000000000..e956944c1 --- /dev/null +++ b/plugins/admin/FAI/class_faiPackage.inc @@ -0,0 +1,140 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* attribute list for save action */ + var $ignore_account = TRUE; + + /* Attributes for this Object */ + var $attributes = array("cn","description","FAIpackage"); + + /* ObjectClasses for this Object*/ + var $objectclasses = array("top","FAIclass","FAIpackageList"); + + /* Class name of the Ldap ObjectClass for the Sub Object */ + var $subClass = ""; + var $subClasses = array("top","FAIclass","FAIscriptEntry"); + + /* Class name of the php class which allows us to edit a Sub Object */ + var $subClassName = ""; + + /* Attributes to initialise for each subObject */ + var $subAttributes = array("cn","description"); + var $sub64coded = array(); + + /* Specific attributes */ + var $cn = ""; // The class name for this object + var $description = ""; // The description for this set of partitions + var $is_dialog = false; // specifies which buttons will be shown to save or abort + var $dialog = NULL; // a dialog, e.g. new disk dialog + var $SubObjects = array(); // All leafobjects of this object + + function faiPackage ($config, $dn= NULL) + { + /* Load Attributes */ + plugin::plugin ($config, $dn); + + /* If "dn==new" we try to create a new entry + * Else we must read all objects from ldap which belong to this entry. + * First read SubObjects from ldap ... and then the partition definitions for the SubObjects. + */ + if($dn != "new"){ + $this->dn =$dn; + } + + $this->FAIpackage = "test"; + } + + function execute() + { + /* Fill templating stuff */ + $smarty= get_smarty(); + $display= ""; + + /* Assign variables */ + foreach($this->attributes as $attrs){ + $smarty->assign($attrs,$this->$attrs); + } + + $display.= $smarty->fetch(get_template_path('faiPackage.tpl', TRUE)); + return($display); + } + + /* Generate listbox friendly SubObject list + */ + function getList(){ + $a_return=array(); + foreach($this->SubObjects as $obj){ + if($obj['status'] != "delete"){ + $a_return[$obj['cn']]= $obj['cn']." [".$obj['description']."]"; + } + } + return($a_return); + } + + /* Delete me, and all my subtrees + */ + function remove_from_parent() + { + $ldap = $this->config->get_ldap_link(); + $ldap->cd ($this->dn); + $ldap->rmdir_recursive($this->dn); + $this->handle_post_events("remove"); + } + + + /* Save data to object + */ + function save_object() + { + plugin::save_object(); + foreach($this->attributes as $attrs){ + if(isset($_POST[$attrs])){ + $this->$attrs = $_POST[$attrs]; + } + } + } + + + /* Check supplied data */ + function check() + { + $message= array(); + $str = utf8_encode("üöä"); + if((empty($this->description))||(preg_match("/[^a-z0-9".$str."\.,;:-_\? ]/i",$this->description))){ + $message[]=_("Please enter a valid description."); + } + return ($message); + } + + + /* Save to LDAP */ + function save() + { + plugin::save(); + + $ldap = $this->config->get_ldap_link(); + + $ldap->cat($this->dn); + if($ldap->count()!=0){ + /* Write FAIscript to ldap*/ + $ldap->cd($this->dn); + $ldap->modify($this->attrs); + }else{ + /* Write FAIscript to ldap*/ + $ldap->cd($this->dn); + $ldap->create_missing_trees($this->dn); + $ldap->cd($this->dn); + $ldap->add($this->attrs); + } + show_ldap_error($ldap->get_error()); + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/plugins/admin/FAI/faiPackage.tpl b/plugins/admin/FAI/faiPackage.tpl new file mode 100644 index 000000000..d72310d6d --- /dev/null +++ b/plugins/admin/FAI/faiPackage.tpl @@ -0,0 +1,29 @@ + + + + +
+

 {t}Generic{/t}


+ + + + + + + + + +
+ + + +
+ + + +
+
diff --git a/plugins/admin/FAI/tabsPackage.inc b/plugins/admin/FAI/tabsPackage.inc new file mode 100644 index 000000000..fdb1cb505 --- /dev/null +++ b/plugins/admin/FAI/tabsPackage.inc @@ -0,0 +1,42 @@ +by_object['faiPackage']; + + $new_dn= 'cn='.$baseobject->cn.",ou=packages,ou=fai,ou=configs,ou=systems,".$_SESSION['config']->current['BASE']; + + if ($this->dn != $new_dn && $this->dn != "new"){ + + /* if( new_dn is subtree of this->dn ) */ + $cnt1 = count(split(",",$this->dn)); + $cnt2 = count(split(",",$new_dn)); + if((strstr($new_dn,$this->dn))&&($cnt1<$cnt2)){ + print_red(_("Try to move tree failed. Destination tree is subtree of source tree.")); + }else{ + $baseobject->recursive_move($this->dn, $new_dn); + } + } + $this->dn= $new_dn; + + tabs::save(TRUE); + } + +} + +?> -- 2.30.2