From 7b791be83b3876226ecbe9b6eb4d51f7317b3508 Mon Sep 17 00:00:00 2001 From: hickert Date: Fri, 9 Sep 2005 06:26:18 +0000 Subject: [PATCH] Added profile creation from "icons". Editing and renaming of profiles work now git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@1336 594d385d-05f5-0310-b6e9-bd551577e9d8 --- plugins/admin/FAI/class_faiManagement.inc | 25 ++++++++++++---- plugins/admin/FAI/class_faiProfile.inc | 33 ++++++++++++++++++--- plugins/admin/FAI/class_faiProfileEntry.inc | 2 +- plugins/admin/FAI/faiProfile.tpl | 4 +-- 4 files changed, 52 insertions(+), 12 deletions(-) diff --git a/plugins/admin/FAI/class_faiManagement.inc b/plugins/admin/FAI/class_faiManagement.inc index 463deda53..0c6f27ae1 100644 --- a/plugins/admin/FAI/class_faiManagement.inc +++ b/plugins/admin/FAI/class_faiManagement.inc @@ -120,6 +120,8 @@ class faiManagement extends plugin $s_action = "new_variable"; }elseif(preg_match("/create_template/i",$key)){ $s_action = "new_template"; + }elseif(preg_match("/create_profile/i",$key)){ + $s_action = "new_profile"; }elseif(preg_match("/UseNewClass/",$key)){ $s_action = "select_class_name_finished"; }elseif(preg_match("/UseSelectedClass/",$key)){ @@ -244,6 +246,17 @@ class faiManagement extends plugin $this->dialog = new askClassName($this->config,$this->dn,$this->ui,"FAItemplate"); } + /* New Profile */ + if($s_action == "new_profile"){ + $this->dn = "new" ; + $a_setup= $this->get_type(array("objectClass"=>array("FAIprofile"))); + + $this->dialog = new $a_setup[0]($this->config, + $this->config->data['TABS'][$a_setup[2]],$this->dn); + $this->is_dialog = true; + + } + if($s_action == "select_class_name_finished"){ $this->dialog->save_object(); if(count($this->dialog->check())!=0){ @@ -337,11 +350,9 @@ class faiManagement extends plugin */ $faihead = "
". - "  ". - "  ". "  ". + title='"._("New partition table")."' name='Create_partition' alt='"._("PT")."'> ". "  ". @@ -355,6 +366,9 @@ class faiManagement extends plugin "  ". + "  ". + "
"; $this->reload(); @@ -527,11 +541,12 @@ class faiManagement extends plugin }elseif(in_array("FAItemplate",$obj['objectClass'])){ $type = "FAItemplate"; } - $this->objects[$obj['cn'].$type] = $obj; - $this->objects[$obj['cn'].$type]['type']=$type; + $this->objects[strtolower($obj['cn']).$obj['cn'].$type] = $obj; + $this->objects[strtolower($obj['cn']).$obj['cn'].$type]['type']=$type; } } + ksort($this->objects); reset ($this->objects); } diff --git a/plugins/admin/FAI/class_faiProfile.inc b/plugins/admin/FAI/class_faiProfile.inc index a4c0d49d4..9b720fbf9 100644 --- a/plugins/admin/FAI/class_faiProfile.inc +++ b/plugins/admin/FAI/class_faiProfile.inc @@ -21,6 +21,7 @@ class faiProfile extends plugin var $subClasses = array("top","FAIclass","FAIscriptEntry"); /* Specific attributes */ + var $old_cn = ""; 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 @@ -36,9 +37,11 @@ class faiProfile extends plugin $ldap=$this->config->get_ldap_link(); $tmp = split(" ",$this->FAIclass); - + foreach($tmp as $class){ - $this->FAIclasses[trim($class)] = trim($class); + if(!empty($class)){ + $this->FAIclasses[trim($class)] = trim($class); + } } $categories = array("FAIscript","FAItemplate","FAIhook","FAIvariable","FAIpartitionTAble","FAIpackage"); @@ -57,6 +60,7 @@ class faiProfile extends plugin if($dn != "new"){ $this->dn =$dn; } + $this->old_cn = $this->cn; } function execute() @@ -190,9 +194,30 @@ class faiProfile extends plugin { $message= array(); $str = utf8_encode("üöä"); - if((empty($this->description))||(preg_match("/[^a-z0-9".$str."\.,;:-_\? ]/i",$this->description))){ + if((empty($this->description))){ + $message[] =_("Please specify a description for this profile."); + } + + if((preg_match("/[^a-z0-9".$str."\.,;:-_\? ]/i",$this->description))){ $message[]=_("Please enter a valid description."); } + + if((empty($this->cn))||(preg_match("/[^a-z0-9]/i",$this->cn))){ + $message[]=_("Please enter a valid name. Only 0-9 a-Z are allowed here."); + } + + if(count($this->FAIclasses) == 0){ + $message[]=_("Please assign at least one class to this profile."); + } + + $ldap = $this->config->get_ldap_link(); + $ldap->cd($_SESSION['faifilter']['base']); + $ldap->search("(&(objectClass=FAIprofile)(cn=".$this->cn.")(!cn=".$this->old_cn."))",array("*")); + + if($ldap->count()){ + $message[]=_("There is already a profile with this class name defined."); + } + return ($message); } @@ -210,7 +235,7 @@ class faiProfile extends plugin } $this->attrs['FAIclass']=trim($this->FAIclass); - + $ldap->cat($this->dn); if($ldap->count()!=0){ /* Write FAIscript to ldap*/ diff --git a/plugins/admin/FAI/class_faiProfileEntry.inc b/plugins/admin/FAI/class_faiProfileEntry.inc index bf8d2033f..609eb9821 100644 --- a/plugins/admin/FAI/class_faiProfileEntry.inc +++ b/plugins/admin/FAI/class_faiProfileEntry.inc @@ -47,7 +47,7 @@ class faiProfileEntry extends plugin } } /* If no search filter is set, create one */ - if (is_global("SUBfaifilter")){ + if (!is_global("SUBfaifilter")){ $SUBfaifilter= array("base" => "ou=fai,ou=configs,ou=systems,".$base, "Sregex" => "*"); $SUBfaifilter['SShowTemplates'] = false; $SUBfaifilter['SShowScripts'] = false; diff --git a/plugins/admin/FAI/faiProfile.tpl b/plugins/admin/FAI/faiProfile.tpl index 90bbb8824..11185d262 100644 --- a/plugins/admin/FAI/faiProfile.tpl +++ b/plugins/admin/FAI/faiProfile.tpl @@ -3,11 +3,11 @@ - + -- 2.30.2