From: hickert Date: Tue, 4 Apr 2006 05:07:37 +0000 (+0000) Subject: Added release managed applications in groups .. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=e2d472579a3ef18dc848eae8eea9f1d9cd291425;p=gosa.git Added release managed applications in groups .. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2958 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/plugins/admin/groups/application.tpl b/plugins/admin/groups/application.tpl index 43e597ad8..c23bbeeaa 100644 --- a/plugins/admin/groups/application.tpl +++ b/plugins/admin/groups/application.tpl @@ -1,3 +1,14 @@ +{if $enableReleaseManagement == true} + {t}Release{/t} + {if $ReleaseSelectAble} + + {else} + {$Release} + {/if} +

 

+{/if}
diff --git a/plugins/admin/groups/class_groupApplication.inc b/plugins/admin/groups/class_groupApplication.inc index fd3500a86..95813c657 100644 --- a/plugins/admin/groups/class_groupApplication.inc +++ b/plugins/admin/groups/class_groupApplication.inc @@ -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: diff --git a/plugins/admin/groups/class_groupGeneric.inc b/plugins/admin/groups/class_groupGeneric.inc index b693f7064..f7410e9ba 100644 --- a/plugins/admin/groups/class_groupGeneric.inc +++ b/plugins/admin/groups/class_groupGeneric.inc @@ -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(); diff --git a/plugins/admin/groups/tabs_group.inc b/plugins/admin/groups/tabs_group.inc index 53031e89b..d970ec9ce 100644 --- a/plugins/admin/groups/tabs_group.inc +++ b/plugins/admin/groups/tabs_group.inc @@ -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)