Code

Added profile creation from "icons".
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 9 Sep 2005 06:26:18 +0000 (06:26 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 9 Sep 2005 06:26:18 +0000 (06:26 +0000)
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
plugins/admin/FAI/class_faiProfile.inc
plugins/admin/FAI/class_faiProfileEntry.inc
plugins/admin/FAI/faiProfile.tpl

index 463deda538ccd40f2d9ddb464a3b3d3486bdfd26..0c6f27ae1ce2dc882ff0f78e92e72594577dcd94 100644 (file)
@@ -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 = 
                        "<div style='background:#F0F0F9;padding:5px;'>".
-                       " <input type='image' align='middle' src='images/list_back.png' title='"._("Go up one department")."' alt='"._("Up")."' name='dep_back'>&nbsp;".
-                       " <input type='image' src='images/list_root.png' align='middle' title='"._("Go to root department")."' name='dep_root' alt='"._("Root")."'>&nbsp;".
 
                        " <input type='image' src='images/fai_partitionTable.png' align='middle' 
-                       title='"._("New partition table")."' name='Create_partition' alt='"._("P")."'>&nbsp;".
+                       title='"._("New partition table")."' name='Create_partition' alt='"._("PT")."'>&nbsp;".
 
                        " <input type='image' src='images/fai_script.png' align='middle' 
                        title='"._("New script bundle")."' name='Create_script' alt='"._("S")."'>&nbsp;".
@@ -355,6 +366,9 @@ class faiManagement extends plugin
                        " <input type='image' src='images/fai_template.png' align='middle' 
                        title='"._("New template bundle")."' name='Create_template' alt='"._("T")."'>&nbsp;".
 
+                       " <input type='image' src='images/fai_profile.png' align='middle' 
+                       title='"._("New profile bundle")."' name='Create_profile' alt='"._("P")."'>&nbsp;".
+                       
                        "</div>";
 
                $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);
        }
 
index a4c0d49d451482aa374c5f3d0a2076318f5cd851..9b720fbf94aba2e6fa35dbac14c897e6644a5395 100644 (file)
@@ -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*/
index bf8d2033ff1e8333e09006237d3ccf2f1fb8fc6b..609eb982101fb1cb9d90b81f5631acdcaa6bde01 100644 (file)
@@ -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;
index 90bbb882413a515abddd7f2618fa71fa9352402c..11185d262daa9b6c3f5002c6371699772547e177 100644 (file)
@@ -3,11 +3,11 @@
        <tr>
                <td>
                        <LABEL for="cn">
-                       {t}Name{/t}
+                       {t}Name{/t}{$must}
                        </LABEL>
                </td>
                <td>
-                       <input value="{$cn}" disabled id="cn">
+                       <input value="{$cn}" id="cn" name="cn">
                </td>
        </tr>
        <tr>