Code

Added subdepartments for FAI objects
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 5 Oct 2005 07:16:51 +0000 (07:16 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 5 Oct 2005 07:16:51 +0000 (07:16 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@1473 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/fai/class_askClassName.inc
plugins/admin/fai/class_faiManagement.inc
plugins/admin/fai/class_faiPartitionTable.inc
plugins/admin/fai/class_faiPartitionTableEntry.inc
plugins/admin/fai/tabsHook.inc
plugins/admin/fai/tabsPackage.inc
plugins/admin/fai/tabsPartition.inc
plugins/admin/fai/tabsProfile.inc
plugins/admin/fai/tabsScript.inc
plugins/admin/fai/tabsTemplate.inc
plugins/admin/fai/tabsVariable.inc

index fa1b1ae063f8cecae916ca7def6b55a1fb741e4c..edb9d277dc404c33c9abab9b4a9de047268d0f54 100644 (file)
@@ -38,8 +38,9 @@ class askClassName extends plugin
     /* First search for every ou, in given fai base
      * With a second search detect all object that belong to the different ous. 
      */
+    $base = "ou=fai,ou=configs,ou=systems,".$faifilter['base'];
     $ldap = $this->config->get_ldap_link();
-    $res  = get_list($this->ui->subtreeACL, "(objectClass=organizationalUnit)",FALSE, $faifilter['base'], array("cn","description","objectClass"),TRUE);
+    $res  = get_list($this->ui->subtreeACL, "(objectClass=organizationalUnit)",FALSE, $base, array("cn","description","objectClass"),TRUE);
     $used = array();
 
     $delete = array();
index 9444ed8721373b3297be1efb2cb834440f96c899..7e9dab75d31f875f6353bd3f48238b0a67261f88 100644 (file)
@@ -68,7 +68,7 @@ class faiManagement extends plugin
                /* Get global filter config */
                if (!is_global("faifilter")){
                        $base   = get_base_from_people($ui->dn);
-                       $faifilter= array("base" => "ou=fai,ou=configs,ou=systems,".$base,
+                       $faifilter= array("base" => $base,
                                        "regex" => "*");
                        $faifilter['ShowProfiles']      = true;
                        $faifilter['ShowTemplates'] = true;
@@ -135,10 +135,42 @@ class faiManagement extends plugin
                                $s_entry = preg_replace("/^entry_delete_/","",$key);
                                $s_entry = preg_replace("/_.*$/","",$s_entry);
                                $s_action = "delete";
+                       }elseif(preg_match("/dep_back.*/i",$key)){
+                $s_action="back";
+            }elseif(preg_match("/dep_home.*/i",$key)){
+                $s_action="home";
+            }elseif(preg_match("/dep_root.*/i",$key)){
+                $s_action="root";
                        }
 
                }
 
+               if($s_action=="root"){
+                       $faifilter['base']=($this->config->current['BASE']);
+               }
+
+               if($s_action=="home"){
+                       $faifilter['base']=(preg_replace("/^[^,]+,/","",$this->ui->dn));
+                       $faifilter['base']=(preg_replace("/^[^,]+,/","",$faifilter['base']));
+               }
+
+               if($s_action=="back"){
+                       $base_back          = preg_replace("/^[^,]+,/","",$faifilter['base']);
+                       $base_back          = convert_department_dn($base_back);
+
+                       if(isset($this->config->departments[trim($base_back)])){
+                               $faifilter['base']= $this->config->departments[trim($base_back)];
+                       }else{
+                               $faifilter['base']= $this->config->departments["/"];
+                       }
+               }
+
+               if(isset($_GET['act'])&&($_GET['act']=="dep_open")){
+            $s_action="open";
+            $s_entry = base64_decode($_GET['dep_id']);
+            $faifilter['base']= $this->config->departments[trim($s_entry)];
+        }
+
                if(isset($_GET['edit_entry'])){
                        $s_entry = $_GET['edit_entry'];
                        $s_action = "edit";
@@ -369,6 +401,17 @@ class faiManagement extends plugin
                $faihead = 
                        "<div style='background:#F0F0F9;padding:5px;'>&nbsp;".
 
+                       "<input type='image' src='images/list_up.png' align='middle' 
+                       title='"._("Go up one department")."' name='dep_back' alt='"._("Up"). "'>&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/list_home.png' align='middle' 
+                       title='"._("Go to users home department")."' name='dep_home' alt='"._("Home")."'>&nbsp;".
+
+                       "<img src=\"images/list_seperator.png\" alt=\"\" align=\"middle\" height=\"16\" width=\"1\">&nbsp;".
+                       
                        " <input type='image' src='images/fai_new_profile.png' align='middle' 
                        title='"._("New profile")."' name='Create_profile' alt='"._("P")."'>&nbsp;".
                        
@@ -412,6 +455,32 @@ class faiManagement extends plugin
                $action .= "<input type='image' src='images/edittrash.png' alt='"._("delete")."' name='entry_delete_%KEY%' title='"._("Delete class")."'>";
 
                $editlink ="<a href='?plug=".$_GET['plug']."&edit_entry=%KEY%'>%NAME%</a>";             
+               $linkopen = "<a href='?plug=".$_GET['plug']."&amp;act=dep_open&amp;dep_id=%s'>%s</a>";
+
+               foreach($this->departments as $key => $val) {
+                       if(!isset($this->config->departments[trim($key)])){
+                               $this->config->departments[trim($key)]="";
+                       }
+
+                       $non_empty="";
+                       $keys= str_replace("/","\/",$key);
+                       foreach($this->config->departments as $keyd=>$vald ){
+                               if(preg_match("/".$keys."\/.*/",$keyd)){
+                                       $non_empty="full";
+                               }
+                       }
+
+
+                       $title = $this->config->departments[$key];
+                       $field0 = array("string" => "<img src='images/".$non_empty."folder.png' title='"._("department")."' alt='department'>",                     "attach"=>"style='width:20px;'");
+                       $field1 = array("string" => sprintf($linkopen,base64_encode($key),$val), "attach" => "title='".$title."'");
+                       $field2 = array("string" => "");
+                       $field3 = array("string" => "","attach"=>"style='text-align:right'");
+
+                       $divlist->AddEntry( array($field0,$field1,$field2,$field3));
+
+               }
+
 
                /* Attach objects */
                foreach($this->objects as $key => $value){
@@ -524,7 +593,7 @@ class faiManagement extends plugin
                // Added for dirlist function...
 
                /* Set base for all searches */
-               $base= $faifilter['base'];
+               $base= "ou=fai,ou=configs,ou=systems,".$faifilter['base'];
                $regex = $faifilter['regex'];   
 
                /* Array to save objects */
@@ -532,6 +601,33 @@ class faiManagement extends plugin
        
                $this->objects=array();
 
+               /* NEW LIST MANAGMENT
+                * We also need to search for the departments
+                * So we are able to navigate like in konquerer
+                */
+               $base2 = $faifilter['base'];
+
+               $res3 =  get_list2($this->ui->subtreeACL, "(&(|(ou=$regex)(description=$regex))(objectClass=gosaDepartment))",
+                               TRUE, $base2, array("ou", "description"), TRUE);
+
+               $this->departments= array();
+               $tmp = array();
+               foreach ($res3 as $value){
+                       $tmp[strtolower($value['dn']).$value['dn']]=$value;
+               }
+               ksort($tmp);
+               foreach($tmp as $value){
+                       if($value["description"][0]!=".."){
+                               $this->departments[$value['dn']]=convert_department_dn2($value['dn'])." - [".$value["description"][0]."]";
+                       }else{
+                               $this->departments[$value['dn']]=$value["description"][0];
+                       }
+               }
+
+               /* END NEW LIST MANAGMENT
+                */
+
+       
                $res= get_list($this->ui->subtreeACL, "(objectClass=organizationalUnit)", 
                                FALSE, $base, array("cn","description","objectClass"),TRUE);
 
index 8cedb0f1604e56be1b08225d8a8bea023510bf0c..3c83b3484c2edb7b1a5170a0cc5a2d90b755d67f 100644 (file)
@@ -370,6 +370,9 @@ class faiPartitionTable extends plugin
           }
         }
 
+        if((!isset($partition['FAImountPoint']))||(empty($partition['FAImountPoint']))){
+          $partition_attrs['FAImountPoint']="swap";
+        }
 
         if(($partition['status'] == "delete")&&($disk['status']!="new")){
           $ldap->cd($partition_dn);
index 278b498f634ce95722b27f984787f97df380397b..e8db4d5e40c54f185f090ff41f65e6991a218211 100644 (file)
@@ -311,19 +311,23 @@ class faiPartitionTableEntry extends plugin
 
     foreach($this->partitions as $key => $part){
     
-      if(in_array($part['FAImountPoint'],$alreadyUsed['FAImountPoint'])){
+      if((in_array($part['FAImountPoint'],$alreadyUsed['FAImountPoint']))&&($part['FAIfsType']!="swap")){
         $message[]=sprintf(_("please enter a unique mount point for partition %s"),($key));
       }
 
-      if((empty($part['FAImountPoint']))||(!((preg_match("/^\/.*/",$part['FAImountPoint']))||(preg_match("/^swap$/",$part['FAImountPoint']))))){
-        $message[]=sprintf(_("Please enter a valid mount point for partition %s." ),($key));
+      if($part['FAIfsType']!="swap"){
+        if((empty($part['FAImountPoint']))||(!((preg_match("/^\/.*/",$part['FAImountPoint']))||(preg_match("/^swap$/",$part['FAImountPoint']))))){
+          $message[]=sprintf(_("Please enter a valid mount point for partition %s." ),($key));
+        }
       }
-
       if($part['FAIfsType'] == "swap"){
         if(in_array($part['FAIfsType'],$alreadyUsed['FAIfsType'])){
           $message[]=sprintf(_("File system type 'swap' is already used, change file system type for partition %s."),$key);
         }
       }
+      if(($part['FAIfsType'] == "swap")&&(!empty($part['FAImountPoint']))&&($part['FAImountPoint']!="swap")){
+        $message[]=_("Please use 'swap' as mount point, if 'swap' is used as fs-type.");
+      }
 
       $tmp = split("-",$part['FAIpartitionSize']);
       switch (count($tmp)){
index f438f82362ceea95f587634387bc4e675fbc4bb4..1a434eadd88847e4470e7b3b82e6fb4e77058078 100644 (file)
@@ -19,7 +19,7 @@ class tabsHook extends tabs
   {
        $baseobject= $this->by_object['faiHook'];
 
-       $new_dn= 'cn='.$baseobject->cn.",ou=hooks,ou=fai,ou=configs,ou=systems,".$_SESSION['config']->current['BASE'];
+       $new_dn= 'cn='.$baseobject->cn.",ou=hooks,ou=fai,ou=configs,ou=systems,".$_SESSION['faifilter']['base'];
 
        if ($this->dn != $new_dn && $this->dn != "new"){
                
index fdb1cb50502042bd24950900266f470ced655415..c91455548c59eab727aa7fa49c8aec0e8f3b6e90 100644 (file)
@@ -19,7 +19,7 @@ class tabsPackage extends tabs
   {
        $baseobject= $this->by_object['faiPackage'];
 
-       $new_dn= 'cn='.$baseobject->cn.",ou=packages,ou=fai,ou=configs,ou=systems,".$_SESSION['config']->current['BASE'];
+       $new_dn= 'cn='.$baseobject->cn.",ou=packages,ou=fai,ou=configs,ou=systems,".$_SESSION['faifilter']['base'];
        
        if ($this->dn != $new_dn && $this->dn != "new"){
                
index d61396d6769029a488fd82b8aff9a593fad71511..df8327117d84469311c52fb261a5e31997fd2e38 100644 (file)
@@ -20,7 +20,7 @@ class tabsPartition extends tabs
        $baseobject= $this->by_object['faiPartitionTable'];
 
        // cn=FAIBASE,ou=disk,ou=fai,ou=configs,ou=systems,dc=gonicus,dc=de
-       $new_dn= 'cn='.$baseobject->cn.",ou=disk,ou=fai,ou=configs,ou=systems,".$_SESSION['config']->current['BASE'];
+       $new_dn= 'cn='.$baseobject->cn.",ou=disk,ou=fai,ou=configs,ou=systems,".$_SESSION['faifilter']['base'];
        
        // Old .. $new_dn= 'ou='.$baseobject->ou.','.$baseobject->base;
 
index 97dcdb0735f4f9211c2bba65e1607c1b93191f33..bb42efeb96a365cf9e1726205603ff60afa3813e 100644 (file)
@@ -19,7 +19,7 @@ class tabsProfile extends tabs
   {
        $baseobject= $this->by_object['faiProfile'];
 
-       $new_dn= 'cn='.$baseobject->cn.",ou=profiles,ou=fai,ou=configs,ou=systems,".$_SESSION['config']->current['BASE'];
+       $new_dn= 'cn='.$baseobject->cn.",ou=profiles,ou=fai,ou=configs,ou=systems,".$_SESSION['faifilter']['base'];
        
        if ($this->dn != $new_dn && $this->dn != "new"){
                
index cb6dcf3028a4d2f3b5dff77f8a7ad23d00f9a903..b9a63d34bf78265dc162219924903188022d5a6e 100644 (file)
@@ -19,7 +19,7 @@ class tabsScript extends tabs
   {
        $baseobject= $this->by_object['faiScript'];
 
-       $new_dn= 'cn='.$baseobject->cn.",ou=scripts,ou=fai,ou=configs,ou=systems,".$_SESSION['config']->current['BASE'];
+       $new_dn= 'cn='.$baseobject->cn.",ou=scripts,ou=fai,ou=configs,ou=systems,".$_SESSION['faifilter']['base'];
        
        if ($this->dn != $new_dn && $this->dn != "new"){
                
index ada68ce9139f26fb5ae1a9c491da19dad6a2df09..cc49f0ce676cbc8922246cf9a929f2ef54bc429d 100644 (file)
@@ -19,7 +19,7 @@ class tabsTemplate extends tabs
   {
        $baseobject= $this->by_object['faiTemplate'];
 
-       $new_dn= 'cn='.$baseobject->cn.",ou=templates,ou=fai,ou=configs,ou=systems,".$_SESSION['config']->current['BASE'];
+       $new_dn= 'cn='.$baseobject->cn.",ou=templates,ou=fai,ou=configs,ou=systems,".$_SESSION['faifilter']['base'];
        
        if ($this->dn != $new_dn && $this->dn != "new"){
                
index 86a8851f09fee51b69bdf82c4d7455b5dac570aa..81e2baccc73dad9a40f1a78b43adbb2b7364ce79 100644 (file)
@@ -19,7 +19,7 @@ class tabsVariable extends tabs
   {
        $baseobject= $this->by_object['faiVariable'];
 
-       $new_dn= 'cn='.$baseobject->cn.",ou=variables,ou=fai,ou=configs,ou=systems,".$_SESSION['config']->current['BASE'];
+       $new_dn= 'cn='.$baseobject->cn.",ou=variables,ou=fai,ou=configs,ou=systems,".$_SESSION['faifilter']['base'];
        
        if ($this->dn != $new_dn && $this->dn != "new"){