From: hickert Date: Tue, 15 Apr 2008 10:36:06 +0000 (+0000) Subject: Updated application handling X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=bdd63c4a3a13f663caee3d9933eff175d13a2009;p=gosa.git Updated application handling -Removed Base selector git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@10458 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-plugins/goto/admin/applications/class_applicationManagement.inc b/gosa-plugins/goto/admin/applications/class_applicationManagement.inc index d144f45c3..83c870da1 100644 --- a/gosa-plugins/goto/admin/applications/class_applicationManagement.inc +++ b/gosa-plugins/goto/admin/applications/class_applicationManagement.inc @@ -33,6 +33,9 @@ class applicationManagement extends plugin var $enableReleaseManagement = false; var $start_pasting_copied_objects = FALSE; + var $app_base =""; + var $app_release =""; + function IsReleaseManagementActivated() { /* Check if we should enable the release selection */ @@ -40,9 +43,9 @@ class applicationManagement extends plugin if(!empty($tmp)){ return(true); } - return(false); } + function applicationManagement (&$config, &$ui) { /* Save configuration for internal use */ @@ -64,20 +67,40 @@ class applicationManagement extends plugin /* Hide SubSearch checkbox */ $this->DivListApplication->DisableCheckBox("SubSearch"); } + + /* Set default release */ + if(!$this->IsReleaseManagementActivated()){ + $this->app_base = get_ou("applicationou").$this->config->current['BASE']; + if(!session::is_set("app_filter")){ + session::set("app_filter",array("app_base" => $this->app_base)); + } + $app_filter = session::get("app_filter"); + $this->app_base = $app_filter['app_base']; + }else{ + $this->app_base = get_ou("applicationou").$this->config->current['BASE']; + if(!session::is_set("app_filter")){ + session::set("app_filter",array("app_base" => $this->app_base,"app_release" => $this->app_base)); + } + $app_filter = session::get("app_filter"); + $this->app_base = $app_filter['app_base']; + $this->app_release = $app_filter['app_release']; + } + $this->app_base = "ou=apps,ou=Direktorium,o=Landeshauptstadt München,c=de"; + $this->app_release= $this->app_base; } - function getReleases($base) - { - $ldap = $this->config->get_ldap_link(); - $dn = get_ou('applicationou').$base; - $ret = array(); - $ret [get_ou('applicationou').$base] = "/"; - $ldap->cd($dn); - $ldap->search("objectClass=organizationalUnit",array("ou")); + function getReleases() + { + $ldap = $this->config->get_ldap_link(); + $ret = array(); + $base = $this->app_base; + $ret[$this->app_base] = "/"; + $ldap->cd($base); + $ldap->search("(&(objectClass=organizationalUnit)(objectClass=FAIbranch))",array("ou")); while($attrs = $ldap->fetch()){ - $str = str_replace($dn,"",$attrs['dn']); + $str = str_replace($base,"",$attrs['dn']); $tmp = array_reverse( split("ou=",$str)); $str = ""; foreach($tmp as $val){ @@ -195,7 +218,8 @@ class applicationManagement extends plugin /* Create new usertab object */ $this->apptabs= new apptabs($this->config,$this->config->data['TABS']['APPSTABS'], $this->dn,"application"); - $this->apptabs->set_acl_base($this->DivListApplication->selectedBase); + $this->apptabs->parent = &$this; + $this->apptabs->set_acl_base($this->app_base); } @@ -230,7 +254,6 @@ class applicationManagement extends plugin if (count($message) == 0){ /* Save data data to ldap */ - $this->apptabs->set_release($this->DivListApplication->selectedRelease); $this->apptabs->save(); if (!isset($_POST['edit_apply'])){ @@ -273,6 +296,7 @@ class applicationManagement extends plugin /* Register apptabs to trigger edit dialog */ $this->apptabs= new apptabs($this->config,$this->config->data['TABS']['APPSTABS'], $this->dn,"application"); + $this->apptabs->parent = &$this; $this->apptabs->set_acl_base($this->dn); session::set('objectinfo',$this->dn); } @@ -326,6 +350,7 @@ class applicationManagement extends plugin /* Delete request is permitted, perform LDAP action */ $this->apptabs= new apptabs($this->config, $this->config->data['TABS']['APPSTABS'], $dn,"application"); + $this->apptabs->parent = &$this; $this->apptabs->set_acl_base($dn); $this->apptabs->delete (); unset ($this->apptabs); @@ -409,6 +434,7 @@ class applicationManagement extends plugin /* Delete request is permitted, perform LDAP action */ $this->apptabs= new apptabs($this->config, $this->config->data['TABS']['APPSTABS'], $this->dn,"application"); + $this->apptabs->parent = &$this; $this->apptabs->set_acl_base($this->dn); $this->apptabs->delete (); unset ($this->apptabs); @@ -462,15 +488,21 @@ class applicationManagement extends plugin ****************/ /* Check if there is a snapshot dialog open */ - $base = $this->DivListApplication->selectedBase; - if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases($base))){ + if($this->IsReleaseManagementActivated()){ + $base = $this->app_release; + }else{ + $base = $this->app_base; + } + if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases())){ return($str); } /* Display dialog with system list */ $this->DivListApplication->parent = $this; $this->DivListApplication->execute(); - $this->DivListApplication->AddDepartments($this->DivListApplication->selectedBase,3,1); + if(!$this->IsReleaseManagementActivated()){ + $this->DivListApplication->AddDepartments($this->DivListApplication->selectedBase,3,1); + } $this->reload(); $this->DivListApplication->setEntries($this->applications); return($this->DivListApplication->Draw()); @@ -478,11 +510,12 @@ class applicationManagement extends plugin /* Return departments, that will be included within snapshot detection */ - function get_used_snapshot_bases(){ - if($this->DivListApplication->selectedRelease == "main"){ - return(array($this->DivListApplication->selectedBase)); + function get_used_snapshot_bases() + { + if($this->IsReleaseManagementActivated()){ + return(array($this->app_release)); }else{ - return(array($this->DivListApplication->selectedRelease)); + return(array($this->app_base)); } } @@ -492,23 +525,16 @@ class applicationManagement extends plugin $this->applications= array(); /* Set base for all searches */ - $base = $this->DivListApplication->selectedBase; - $release = $this->DivListApplication->selectedRelease; $Regex = $this->DivListApplication->Regex; $SubSearch = $this->DivListApplication->SubSearch; $Flags = GL_NONE | GL_SIZELIMIT; $Filter = "(&(cn=".$Regex.")(objectClass=gosaApplication))"; $tmp = array(); - $Releases = $this->getReleases($base); - if(!$this->enableReleaseManagement){ - $use_base = get_ou('applicationou').$base; + if(!$this->IsReleaseManagementActivated()){ + $use_base = $this->app_base; }else{ - if(isset($Releases[$release])){ - $use_base = $release; - }else{ - $use_base = get_ou('applicationou').$base; - } + $use_base = $this->app_release; } if($SubSearch){ @@ -584,7 +610,8 @@ class applicationManagement extends plugin /* Get dialog */ - $this->CopyPasteHandler->SetVar("base",$this->DivListApplication->selectedBase); + $this->CopyPasteHandler->SetVar("base",$this->app_base); + $this->CopyPasteHandler->SetVar("parent",&$this); $data = $this->CopyPasteHandler->execute(); /* Return dialog data */ @@ -634,6 +661,16 @@ class applicationManagement extends plugin if(is_object($this->CopyPasteHandler)){ $this->CopyPasteHandler->save_object(); } + + if($this->IsReleaseManagementActivated() && isset($_POST['app_release'])){ + $sel_rel = get_post('app_release'); + $releases = array_flip($this->getReleases()); + if(isset($releases[$sel_rel])){ + $this->app_release = $releases[$sel_rel]; + } + }elseif(!$this->IsReleaseManagementActivated()){ + $this->app_base = get_ou("applicationou").$this->DivListApplication->selectedBase; + } } function check() {} diff --git a/gosa-plugins/goto/admin/applications/class_divListApplication.inc b/gosa-plugins/goto/admin/applications/class_divListApplication.inc index 1fc03c02a..0ffdec859 100644 --- a/gosa-plugins/goto/admin/applications/class_divListApplication.inc +++ b/gosa-plugins/goto/admin/applications/class_divListApplication.inc @@ -3,9 +3,6 @@ class divListApplication extends MultiSelectWindow { /* Current base */ - var $selectedBase = ""; - var $selectedRelease = "main"; - var $AvailableReleases = array(); var $departments = array(); var $parent ; var $ui ; @@ -15,15 +12,12 @@ class divListApplication extends MultiSelectWindow /* Subsearch checkbox */ var $SubSearch; - - var $SaveAdditionalVars = array("selectedRelease"); + var $selectedBase =""; function divListApplication (&$config,&$parent) { MultiSelectWindow::MultiSelectWindow($config,"Application", "application"); - - $this->selectedRelease = get_ou('applicationou').session::get('CurrentMainBase'); - + $this->parent = &$parent; $this->ui = get_userinfo(); @@ -64,18 +58,23 @@ class divListApplication extends MultiSelectWindow $this->AddRegex ("Regex", _("Display users matching"),"*" , true); } - function AddUserBoxToFilter($position){ + + function AddUserBoxToFilter($position) + { $str = ""; if(($position == 2) && ($this->parent->IsReleaseManagementActivated($this->config))){ $smarty = get_smarty(); - $smarty->assign("selectedRelease",$this->selectedRelease); + $releases = $this->parent->getReleases(); + $smarty->assign("app_release" , $releases[$this->parent->app_release]); + $smarty->assign("app_base" , $releases[$this->parent->app_base]); $smarty->assign("branchimage","images/branch.png"); - $smarty->assign("releases",$this->AvailableReleases); + $smarty->assign("app_releases", $releases); $str = $smarty->fetch(get_template_path('release_select.tpl', TRUE)); } return($str); } + function GenHeader() { /* Prepare departments, @@ -83,65 +82,69 @@ class divListApplication extends MultiSelectWindow */ $options= ""; - /* Get all departments within this subtree */ - $base = $this->config->current['BASE']; + /* Add default header */ + $listhead = MultiSelectWindow::get_default_header(); + + if(!$this->parent->IsReleaseManagementActivated()){ + + /* Get all departments within this subtree */ + $base = $this->config->current['BASE']; - /* Add base */ - $tmp = array(); - $tmp[] = array("dn"=>$this->config->current['BASE']); - $tmp= array_merge($tmp,get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $this->module, $base, - array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH)); + /* Add base */ + $tmp = array(); + $tmp[] = array("dn"=>$this->config->current['BASE']); + $tmp= array_merge($tmp,get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $this->module, $base, + array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH)); - $deps = array(); - foreach($tmp as $tm){ - $deps[$tm['dn']] = $tm['dn']; - } + $deps = array(); + foreach($tmp as $tm){ + $deps[$tm['dn']] = $tm['dn']; + } - /* Load possible departments */ - $ui= get_userinfo(); - $tdeps= $ui->get_module_departments("application"); - $ids = $this->config->idepartments; - $first = ""; - $found = FALSE; - foreach($ids as $dep => $name){ - if(isset($deps[$dep]) && in_array_ics($dep, $tdeps)){ - - /* Keep first base dn in mind, we could need this - * info if no valid base was found - */ - if(empty($first)) { - $first = $dep['dn']; - } + /* Load possible departments */ + $ui= get_userinfo(); + $tdeps= $ui->get_module_departments("application"); + $ids = $this->config->idepartments; + $first = ""; + $found = FALSE; + foreach($ids as $dep => $name){ + if(isset($deps[$dep]) && in_array_ics($dep, $tdeps)){ + + /* Keep first base dn in mind, we could need this + * info if no valid base was found + */ + if(empty($first)) { + $first = $dep['dn']; + } - $value = $ids[$dep]; - if ($this->selectedBase == $dep){ - $found = TRUE; - $options.= ""; - } else { - $options.= ""; + $value = $ids[$dep]; + if ($this->selectedBase == $dep){ + $found = TRUE; + $options.= ""; + } else { + $options.= ""; + } } } - } - /* The currently used base is not visible with your acl setup. - * Set base to first useable base. - */ - if(!$found){ - $this->selectedBase = $first; + /* The currently used base is not visible with your acl setup. + * Set base to first useable base. + */ + if(!$found){ + $this->selectedBase = $first; + } + + + /* And the rest, a base selection box */ + $listhead .= _("Base")." ". + "  "; } /* Get acls */ $ui = get_userinfo(); - $acl = $ui->get_permissions("cn=dummy,".$this->selectedBase,"application/application"); - $acl_all = $ui->has_complete_category_acls($this->selectedBase,"application"); - - /* Add default header */ - $listhead = MultiSelectWindow::get_default_header(); - - /* And the rest, a base selection box */ - $listhead .= _("Base")." ". - "  "; + $acl = $ui->get_permissions("cn=dummy,".$this->parent->app_base,"application/application"); + $acl_all = $ui->has_complete_category_acls($this->parent->app_base,"application"); /* Create Layers menu */ $s = ".|"._("Actions")."|\n"; @@ -184,18 +187,18 @@ class divListApplication extends MultiSelectWindow $this->SetDropDownHeaderMenu($s); $this->SetListHeader($listhead); - $this->SetListHeader($listhead); } + /* so some basic settings */ function execute() { $this->ClearElementsList(); $this->GenHeader(); - $this->AvailableReleases = $this->parent->getReleases($this->selectedBase); } + function setEntries($list) { /******************** @@ -312,9 +315,6 @@ class divListApplication extends MultiSelectWindow { /* Save automatic created POSTs like regex, checkboxes */ MultiSelectWindow::save_object(); - $appfilter = session::get('appfilter'); - $appfilter['release'] = $this->selectedRelease; - session::set('appfilter',$appfilter); } } diff --git a/gosa-plugins/goto/admin/applications/release_select.tpl b/gosa-plugins/goto/admin/applications/release_select.tpl index d864cebcf..4a8cee268 100644 --- a/gosa-plugins/goto/admin/applications/release_select.tpl +++ b/gosa-plugins/goto/admin/applications/release_select.tpl @@ -6,8 +6,8 @@ {t}Current release{/t}  - + {html_options output=$app_releases values=$app_releases selected=$app_release} diff --git a/gosa-plugins/goto/admin/applications/tabs_application.inc b/gosa-plugins/goto/admin/applications/tabs_application.inc index 5b6e82989..9636c44db 100644 --- a/gosa-plugins/goto/admin/applications/tabs_application.inc +++ b/gosa-plugins/goto/admin/applications/tabs_application.inc @@ -2,7 +2,7 @@ class apptabs extends tabs { - var $Release= ""; + var $parent = FALSE; function apptabs($config, $data, $dn,$category) { @@ -12,28 +12,14 @@ class apptabs extends tabs $this->addSpecialTabs(); } - function set_release($newRelease) - { - $this->Release= preg_replace('/,'.get_ou('applicationou').'.*$/', '', $newRelease); - if ($this->Release != ""){ - $this->Release= ",".$this->Release; - } - } - function save($ignore_account= FALSE) { $baseobject= $this->by_object['application']; /* Check for new 'dn', in order to propagate the 'dn' to all plugins */ - $tmp = $this->config->search("faiManagement", "CLASS",array('menu','tabs')); - $appfilter = session::get('appfilter'); - if((!empty($tmp)) && (isset($appfilter['release']))){ - if(!$baseobject->isReleaseApplikation){ - $new_dn= "cn=".$baseobject->cn.",".get_ou('applicationou').$baseobject->base; - }else{ - $new_dn ="cn=".$baseobject->cn.",".$appfilter['release']; - } + if($this->parent->IsReleaseManagementActivated()){ + $new_dn= "cn=".$baseobject->cn.",".$this->parent->app_release; }else{ $new_dn= "cn=".$baseobject->cn.",".get_ou('applicationou').$baseobject->base; }