Code

Added release managed applications in groups ..
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 4 Apr 2006 05:07:37 +0000 (05:07 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 4 Apr 2006 05:07:37 +0000 (05:07 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2958 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/groups/application.tpl
plugins/admin/groups/class_groupApplication.inc
plugins/admin/groups/class_groupGeneric.inc
plugins/admin/groups/tabs_group.inc

index 43e597ad88fbc0acebdf0ff6e7e9c1a5d4c80799..c23bbeeaa744c57666fd9842579d58dd2832b88a 100644 (file)
@@ -1,3 +1,14 @@
+{if $enableReleaseManagement == true}
+       {t}Release{/t}
+       {if $ReleaseSelectAble}
+               <select name="Release" title="{t}Select release name{/t}" onChange="javascript: document.mainform.submit();">
+                       {html_options output=$Releases values=$Releases selected=$Release}
+               </select>
+       {else}
+               {$Release}
+       {/if}
+       <p class="seperator">&nbsp;</p>
+{/if}
 <table summary="" style="width:100%;">
  <tr>
   <td style="width:48%; vertical-align:top;">
index fd3500a8602dd1a970fe3544ac4df108a91b6bee..95813c65769c1216cf38b217bc0736427c2b5cfe 100644 (file)
@@ -14,18 +14,21 @@ class appgroup extends plugin
   var $apps               = array();  // All available applications
   var $used_apps          = array();  // Specifies which applications are currently assigned 
 
-  var $option_name  = array();
-  var $option_value = array();
-  var $appoption    = array();
+  var $option_name          = array();
+  var $option_value         = array();
+  var $appoption            = array();
 
-  var $table          = "";
-  var $curbase        = "";
-  var $curCatDir      ;
-  var $curCatDepth    =0;         //
+  var $table                  = "";
+  var $curbase                = "";
+  var $curCatDir                  ;
+  var $curCatDepth              =0;         //
 
   /* attribute list for save action */
-  var $attributes= array("gosaMemberApplication");
-  var $objectclasses= array("gosaApplicationGroup");
+  var $attributes               = array("gosaMemberApplication");
+  var $objectclasses            = array("gosaApplicationGroup");
+
+  var $Release                  = "/";
+  var $enableReleaseManagement  = false;
 
 
   function appgroup ($config, $dn= NULL)
@@ -109,6 +112,14 @@ class appgroup extends plugin
     }
     $this->gosaMemberApplication = $tmp;
     $this->curbase = $this->config->current['BASE'];
+    
+    /* Check if we should enable the release selection 
+     */
+    $tmp = search_config($config->data,"faiManagement","CLASS");
+    if(!empty($tmp)){
+      $this->enableReleaseManagement = true;
+      $this->Release = $this->getReleaseName();
+    }
   }
 
 
@@ -385,10 +396,32 @@ class appgroup extends plugin
         $appname = $value;
         $appname = preg_replace("/EdiApp_/","",$name);  
         $appname = preg_replace("/_.*$/","",$appname);
-        /* We've got the appname, get parameters from ldap */
+
+        /* We've got the appname, get parameters from ldap 
+         */
         $ldap= $this->config->get_ldap_link();
-        $ldap->cd($this->config->current['BASE']);
-        $ldap->search("(&(objectClass=gosaApplication)(cn=$appname))",array("gosaApplicationParameter"));
+
+        $tmp = search_config($this->config->data,"faiManagement","CLASS");
+        if(!empty($tmp)){
+          $tmp  = array_flip($this->getReleases());
+          $base = $tmp[$this->Release];
+
+          $ldap->cd($this->config->current['BASE']);
+          $ldap->search("(&(objectClass=gosaApplication)(cn=$appname))",array("gosaApplicationParameter"));
+          $found = "";
+          while($attrs = $ldap->fetch()) {
+            if(preg_match("/cn=".$appname.",".$base."/",$attrs['dn'])){
+              $found = $attrs['dn'];
+            }
+          }
+          $ldap->cat($found);
+        }else{
+          $ldap->cd($this->config->current['BASE']);
+          $ldap->search("(&(objectClass=gosaApplication)(cn=$appname))",array("gosaApplicationParameter"));
+
+        }
+
+
         if ($ldap->count() != 1){
           print_red (_("The selected application name is not uniq. Please check your LDAP."));
         } else {
@@ -611,6 +644,22 @@ class appgroup extends plugin
     $smarty->assign("UsedApps", $div2->DrawList());
     $smarty->assign("List", $div->DrawList());
     $smarty->assign("apps", $apps);
+   
+    $smarty->assign("enableReleaseManagement",$this->enableReleaseManagement);
+    if($this->enableReleaseManagement){
+      $smarty->assign("Release", $this->Release);
+
+      $tmp = $this->getReleases();
+
+      $smarty->assign("Releases",   $tmp);
+
+      if(count($this->used_apps)){
+        $smarty->assign("ReleaseSelectAble", false);
+      }else{
+        $smarty->assign("ReleaseSelectAble", true);
+      }
+    }
 
     /* Show main page */
     if ($this->dialog){
@@ -622,6 +671,48 @@ class appgroup extends plugin
     return ($display);
   }
 
+  function getReleases()
+  {
+  
+    if(isset($this->base)){
+      $base = $this->base;
+    }else{
+      $base = $this->parent->by_object['group']->base;
+    }
+
+    $dn   = "ou=apps,".$base;
+    $ret  = array();
+
+    $ret ["ou=apps,".$base] = "/";
+
+    $ldap = $this->config->get_ldap_link();
+    $ldap->cd($dn);
+
+    $ldap->search("objectClass=organizationalUnit",array("ou"));
+
+    while($attrs = $ldap->fetch()){
+      $str = str_replace($dn,"",$attrs['dn']);
+      $tmp = array_reverse( split("ou=",$str));
+      $str = "";
+      foreach($tmp as $val){
+        $val = trim(preg_replace("/,/","",$val));
+        if(empty($val)) break;
+        $str .= "/".$val;
+      }
+      if(!empty($str)){
+        $ret[$attrs['dn']]= preg_replace("/^\//","",$str);
+      }
+    }
+    return($ret);
+  }
+  function save_object()
+  {
+    if(isset($_POST ['Release'])){
+      $this->Release = $_POST['Release'];
+    }
+  }
 
   function remove_from_parent()
   {
@@ -702,10 +793,27 @@ $ldap->modify ($this->attrs);
   {
     /* Generate applist */
     $this->apps= array();
-    $ldap= $this->config->get_ldap_link();
-    $ldap->cd ("ou=apps,".$this->curbase);
 
-    $ldap->ls ("(objectClass=gosaApplication)","ou=apps,".$this->curbase);
+    /* Special handling for release managed apps 
+     */
+    $tmp = search_config($this->config->data,"faiManagement","CLASS");
+    if(!empty($tmp)){
+      $this->enableReleaseManagement = true;
+
+      $tmp = array_flip($this->getReleases());
+      $base =  $tmp[$this->Release];
+
+      $base = preg_replace("/ou=apps,.*$/","ou=apps,".$this->curbase,$base);
+    
+      $ldap   = $this->config->get_ldap_link();
+      $ldap->cd ($base);
+      $ldap->ls ("(objectClass=gosaApplication)",$base);
+    }else{
+      $ldap   = $this->config->get_ldap_link();
+      $ldap->cd ("ou=apps,".$this->curbase);
+      $ldap->ls ("(objectClass=gosaApplication)","ou=apps,".$this->curbase);
+    }
+    
     while ($attrs= $ldap->fetch()){
       if (isset($attrs["description"][0])){    
         $this->apps[$attrs["cn"][0]]=
@@ -781,6 +889,33 @@ $ldap->modify ($this->attrs);
   return($ret);
   }
 
+
+  /* Get selected release name.
+   *  it is written in the description tag 
+   *  within ... (.*)$
+   */
+  function getReleaseName()
+  {
+  
+    if(isset($this->parent)){
+      $base = $this->parent->by_object['group'];
+    }else{
+      $base = $this;
+    }
+
+    if(isset($base->attrs['description'][0])){
+      $desc = $base->attrs['description'][0];
+    }else{
+      $desc = "";
+    }
+    if(preg_match("/\(.*\)$/",$desc)){
+      $str = preg_replace("/^.*\((.*)\)$/","\\1",$desc);
+    }else{
+      $str = "/";
+    }
+    return($str);  
+  }
 }
 
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
index b693f7064ca554ff3d3ab658004e34ab287e18f4..f7410e9bad1f79ad680f143ef40dfb4cf361425c 100644 (file)
@@ -48,6 +48,13 @@ class group extends plugin
   {
     plugin::plugin ($config, $dn);
 
+    /* remove Release Tag if we have release management enabled 
+     */
+    $tmp = search_config($config->data,"faiManagement","CLASS");
+    if(!empty($tmp)){
+      $this->description = preg_replace("/\(.*\)$/","",$this->description);
+    }
+  
     /* Load attributes depending on the samba version */
     $this->samba3= ($config->current['SAMBAVERSION'] == 3);
     $this->orig_dn= $dn;
@@ -510,7 +517,6 @@ class group extends plugin
     /* Save additional values for possible next step */
     if (isset($_POST['groupedit'])){
 
-      
       plugin::save_object();
 
       $this->force_gid= 0;
@@ -551,6 +557,7 @@ class group extends plugin
   /* Save to LDAP */
   function save()
   {
+
     /* ID handling */
     if ($this->force_gid == 0){
       if ($this->saved_gidNumber != ""){
@@ -570,6 +577,22 @@ class group extends plugin
         $this->gidNumber= $this->get_next_id("gidNumber");
       }
     }
+  
+    /* If release management is enabled .... 
+        Append release name to description tag ..
+       #FIXME release name within description is a very bad solution, use ldap attribute instead
+     */
+    $tmp = search_config($this->config->data,"faiManagement","CLASS");
+    if(!empty($tmp)){
+      if(isset($this->parent->by_object['appgroup'])){
+        $baseObj = $this->parent->by_object['appgroup'];
+        if($baseObj->is_account){
+          if(isset($baseObj->Release)){
+            $this->description .= " (".trim($baseObj->Release).")";
+          }
+        }
+      }
+    }
 
     plugin::save(); 
 
index 53031e89b3162f71e42a6081c321a39c774aa2db..d970ec9ce0b5295909645287e950a8ede665978b 100644 (file)
@@ -6,6 +6,12 @@ class grouptabs extends tabs
        function grouptabs($config, $data, $dn)
        {
                tabs::tabs($config, $data, $dn);
+               $baseobject= $this->by_object['group'];
+               foreach ($this->by_object as $name => $obj){
+                       if(isset($obj->parent)){
+                               $this->by_object[$name]->parent  = $this;
+                       }
+               }
        }
 
        function save_object($save_current= FALSE)