Code

Object groups will show additional tabs without saving before.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 18 Oct 2005 08:06:36 +0000 (08:06 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 18 Oct 2005 08:06:36 +0000 (08:06 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@1598 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/ogroups/class_ogroup.inc
plugins/admin/ogroups/class_phonequeue.inc
plugins/admin/ogroups/tabs_ogroups.inc

index 86c96ae95abf749cd163644350b7e4dee8b98b4a..d26f1ddbd6b31e82f1d3bc1ca8373db8b60437bc 100644 (file)
@@ -87,18 +87,8 @@ class ogroup extends plugin
     $this->reload();
   }
 
-  function execute()
-  {
-    /* Do we represent a valid group? */
-    if (!$this->is_account){
-      $display= "<img alt=\"\" src=\"images/stop.png\" align=\"middle\">&nbsp;<b>".
-        _("This 'dn' is no object group.")."</b>";
-      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= "<img alt=\"\" src=\"images/stop.png\" align=\"middle\">&nbsp;<b>".
+        _("This 'dn' is no object group.")."</b>";
+      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();
index c7f61c946901f3b32fd880e1f93226eba7fe698c..d10c3c747a58281d89d7002026ed1af54647306b 100644 (file)
@@ -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);
       }
     }
index 28718e287df44087423be6231d7c7df9ac75e91c..327b473e75c78e06a7ea677fb048cb1fe7d7ac6b 100644 (file)
@@ -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<strlen($objects); $n++){
       switch ($objects[$n]){
         case "T":