Code

Added package dialog
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 9 Sep 2005 07:02:11 +0000 (07:02 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 9 Sep 2005 07:02:11 +0000 (07:02 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@1338 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/FAI/class_faiManagement.inc
plugins/admin/FAI/class_faiPackage.inc [new file with mode: 0644]
plugins/admin/FAI/faiPackage.tpl [new file with mode: 0644]
plugins/admin/FAI/tabsPackage.inc [new file with mode: 0644]

index 0c6f27ae1ce2dc882ff0f78e92e72594577dcd94..03fb54f7249712ccfe7c96e851b913ea4008c0c7 100644 (file)
@@ -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
                        " <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_packages.png' align='middle' 
+                       title='"._("New package bundle")."' name='Create_package' alt='"._("PK")."'>&nbsp;".
+                       
                        " <input type='image' src='images/fai_profile.png' align='middle' 
                        title='"._("New profile bundle")."' name='Create_profile' alt='"._("P")."'>&nbsp;".
                        
@@ -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 (file)
index 0000000..e956944
--- /dev/null
@@ -0,0 +1,140 @@
+<?php
+
+class faiPackage extends plugin
+{
+  /* CLI vars */
+  var $cli_summary      = "Manage server basic objects";
+  var $cli_description  = "Some longer text\nfor help";
+  var $cli_parameters   = array("eins" => "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 (file)
index 0000000..d72310d
--- /dev/null
@@ -0,0 +1,29 @@
+<table width="100%">
+       <tr>
+               <td width="50%" valign="top">
+                               <h2><img alt="" src="images/house.png" align="middle" title="{t}Generic{/t}">&nbsp;{t}Generic{/t}</h2><br>
+                               <table summary="" cellspacing="4">
+                                       <tr>
+                                               <td>
+                                                       <LABEL for="cn">
+                                                       {t}Name{/t}
+                                                       </LABEL>
+                                               </td>
+                                               <td>
+                                                       <input value="{$cn}" disabled id="cn">
+                                               </td>
+                                       </tr>
+                                       <tr>
+                                               <td>
+                                                       <LABEL for="description">
+                                                       {t}Description{/t}{$must}
+                                                       </LABEL>
+                                               </td>
+                                               <td>
+                                                       <input value="{$description}" {$description} name="description" id="description">
+                                               </td>
+                                       </tr>
+                               </table>
+               </td>
+       </tr>
+</table>
diff --git a/plugins/admin/FAI/tabsPackage.inc b/plugins/admin/FAI/tabsPackage.inc
new file mode 100644 (file)
index 0000000..fdb1cb5
--- /dev/null
@@ -0,0 +1,42 @@
+<?php
+
+class tabsPackage extends tabs
+{
+  var $base= "";
+
+  function tabsPackage($config, $data, $dn)
+  {
+       tabs::tabs($config, $data, $dn);
+  }
+
+  function check()
+  {
+       return (tabs::check(TRUE));
+  }
+  
+
+  function save()
+  {
+       $baseobject= $this->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);
+  }
+
+}
+
+?>