From dd99ada91794fb653974338223201e09e06ab885 Mon Sep 17 00:00:00 2001 From: hickert Date: Tue, 18 Oct 2005 08:06:36 +0000 Subject: [PATCH] Object groups will show additional tabs without saving before. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@1598 594d385d-05f5-0310-b6e9-bd551577e9d8 --- plugins/admin/ogroups/class_ogroup.inc | 55 +++++++++++--- plugins/admin/ogroups/class_phonequeue.inc | 3 +- plugins/admin/ogroups/tabs_ogroups.inc | 85 ++++++++++++++++++++++ 3 files changed, 130 insertions(+), 13 deletions(-) diff --git a/plugins/admin/ogroups/class_ogroup.inc b/plugins/admin/ogroups/class_ogroup.inc index 86c96ae95..d26f1ddbd 100644 --- a/plugins/admin/ogroups/class_ogroup.inc +++ b/plugins/admin/ogroups/class_ogroup.inc @@ -87,18 +87,8 @@ class ogroup extends plugin $this->reload(); } - function execute() - { - /* Do we represent a valid group? */ - if (!$this->is_account){ - $display= "\"\" ". - _("This 'dn' is no object group.").""; - return ($display); - } - - - - /* Delete objects from group */ + function AddDelMembership(){ + /* Delete objects from group */ if (isset($_POST['delete_membership']) && isset($_POST['members'])){ foreach ($_POST['members'] as $value){ $this->objects["$value"]= $this->memberList[$value]; @@ -121,6 +111,47 @@ class ogroup extends plugin } $this->reload(); } + } + + function execute() + { + + $this->reload(); + + /* Do we represent a valid group? */ + if (!$this->is_account){ + $display= "\"\" ". + _("This 'dn' is no object group.").""; + return ($display); + } + + /* Delete objects from group */ + if (isset($_POST['delete_membership']) && isset($_POST['members'])){ + foreach ($_POST['members'] as $value){ + if(isset($this->memberList[$value])){ + $this->objects["$value"]= $this->memberList[$value]; + unset ($this->memberList["$value"]); + unset ($this->member["$value"]); + uasort ($this->objects, 'sort_list'); + reset ($this->objects); + } + } + $this->reload(); + } + + /* Add objects to group */ + if (isset($_POST['add_object_finish']) && isset($_POST['objects'])){ + foreach ($_POST['objects'] as $value){ + if(isset($this->objects[$value])){ + $this->memberList["$value"]= $this->objects[$value]; + $this->member["$value"]= $value; + unset ($this->objects[$value]); + uasort ($this->memberList, 'sort_list'); + reset ($this->memberList); + } + } + $this->reload(); + } /* Load templating engine */ $smarty= get_smarty(); diff --git a/plugins/admin/ogroups/class_phonequeue.inc b/plugins/admin/ogroups/class_phonequeue.inc index c7f61c946..d10c3c747 100644 --- a/plugins/admin/ogroups/class_phonequeue.inc +++ b/plugins/admin/ogroups/class_phonequeue.inc @@ -110,7 +110,8 @@ class phonequeue extends plugin $display= $this->show_header(_("Remove the phone queue from this Account"), _("Phone queue is enabled for this group. You can disable it by clicking below.")); } else { - $display= $this->show_header(_("Create phone queue"), _("For this group the phone queues are disabled. You can enable them by clicking below.")); + $display= $this->show_header(_("Create phone queue"), + _("For this group the phone queues are disabled. You can enable them by clicking below.")); return ($display); } } diff --git a/plugins/admin/ogroups/tabs_ogroups.inc b/plugins/admin/ogroups/tabs_ogroups.inc index 28718e287..327b473e7 100644 --- a/plugins/admin/ogroups/tabs_ogroups.inc +++ b/plugins/admin/ogroups/tabs_ogroups.inc @@ -3,14 +3,99 @@ class ogrouptabs extends tabs { var $base= ""; + + function reload($dd){ + $objects= preg_replace('/[\[\]]/', '', $dd); + + /* If there is a phonequeue, + * but there is no user left with goPhoneAccount ... remove it. + */ + $usePhoneTab = false; + foreach($this->by_object['ogroup']->memberList as $dn => $val){ + if(isset($val['objectClass'])){ + if(in_array("goFonAccount",$val['objectClass'])){ + $usePhoneTab = true; + } + } + } + if(((!$usePhoneTab)&&(isset($this->by_object['phonequeue'])))||((!preg_match("/U/",$objects))&&(isset($this->by_object['phonequeue'])))){ + $this->by_object['phonequeue']->remove_from_parent(); + unset($this->by_object['phonequeue']); + unset($this->by_name['phonequeue']); + } + + /* Remove mail group if there is no user anymore */ + if((!preg_match("/U/",$objects))&&(isset($this->by_object['mailgroup']))){ + $this->by_object['mailgroup']->remove_from_parent(); + unset($this->by_object['mailgroup']); + unset($this->by_name['mailgroup']); + } + + /* Remove terminal group, if theres no terminal left in the object list */ + if((!preg_match("/T/",$objects))&&(isset($this->by_object['termgroup']))){ + $this->by_object['termgroup']->remove_from_parent(); + unset($this->by_object['termgroup']); + unset($this->by_name['termgroup']); + } + + /* Create goPhoneAccount if theres an user with goPhoneAccount + * but only if there is currently no queue enabled. + */ + if(!isset($this->by_object['phonequeue'])){ + foreach($this->by_object['ogroup']->memberList as $dn => $val){ + if(isset($val['objectClass'])){ + if(in_array("goFonAccount",$val['objectClass'])){ + require_once("class_phonequeue.inc"); + $this->by_name['phonequeue']= _("Phone queue"); + $this->by_object['phonequeue']= new phonequeue($this->config, $this->dn); + $this->by_object['phonequeue']->acl = "#all#"; + $this->by_object['phonequeue']->parent= &$this; + } + } + } + } + + /* Add mail group tab , if there is curerntly no mail tab defined */ + if((!preg_match("/U/",$objects))&&(!isset($this->by_object['mailogroup']))){ + if(isset($this->config->current['MAILMETHOD'])){ + if (preg_match('/kolab/i', $this->config->current['MAILMETHOD'])){ + require_once("class_mailogroup.inc"); + $this->by_name['mailogroup']= _("Mail"); + $this->by_object['mailogroup']= new mailogroup($this->config, $this->dn); + $this->by_object['mailogroup']->parent= &$this; + } + } + } + + /* Add Terminal tab */ + if((!preg_match("/T/",$objects))&&(!isset($this->by_object['termgroup']))){ + require_once("class_termgroup.inc"); + if(!isset($this->by_object['termgroup'])){ + $this->by_name['termgroup']= _("Terminals"); + $this->by_object['termgroup']= new termgroup($this->config, $this->dn); + $this->by_object['termgroup']->parent= &$this; + } + } + } + + function execute(){ + $str = ""; + $this->by_object['ogroup']->AddDelMembership(); + $this->reload($this->by_object['ogroup']->gosaGroupObjects); + $str .= tabs::execute(); + return ( $str); + } function ogrouptabs($config, $data, $dn) { + tabs::tabs($config, $data, $dn); $this->base= $this->by_object['ogroup']->base; /* Insert extra tabs for several object types - if present */ + $objects= preg_replace('/[\[\]]/', '', $this->by_object['ogroup']->gosaGroupObjects); + for ($n= 0; $n