Code

Added trust stuff - not finished yet. Save and load works.
[gosa.git] / gosa-core / plugins / admin / ogroups / class_ogroup.inc
index 83d1efb7dcbf823757fc88cfe30ddfad06e16839..f64b00ba592f75491e998b4320dbee70fea985a0 100644 (file)
@@ -1,5 +1,24 @@
 <?php
-
+/*
+ * This code is part of GOsa (http://www.gosa-project.org)
+ * Copyright (C) 2003-2008 GONICUS GmbH
+ *
+ * ID: $$Id$$
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
 
 /* Sort multidimensional arrays for key 'text' */
 function sort_list($val1, $val2)
@@ -32,8 +51,14 @@ class ogroup extends plugin
   var $group_dialog= FALSE;
   var $view_logged = FALSE;
 
+  var $accessTo= array();
+  var $trustModel= "";
+  var $show_ws_dialog = FALSE;
+
+  var $was_trust_account= FALSE;
+
   /* attribute list for save action */
-  var $attributes= array("cn", "description", "gosaGroupObjects","member");
+  var $attributes= array("cn", "description", "gosaGroupObjects","member","accessTo","trustModel");
   var $objectclasses= array("top", "gosaGroupOfNames");
 
   function ogroup (&$config, $dn= NULL)
@@ -71,6 +96,7 @@ class ogroup extends plugin
           "D" => "departments",
           "S" => "servers",
           "W" => "workstations",
+          "O" => "winstations",
           "T" => "terminals",
           "F" => "phones",
           "_" => "subtrees",
@@ -92,7 +118,24 @@ class ogroup extends plugin
     if ($this->dn == "new"){
       $this->base = session::get('CurrentMainBase');
     } else {
-      $this->base= preg_replace("/^[^,]+,".get_groups_ou()."/","",$this->dn);
+      $this->base= preg_replace("/^[^,]+,".normalizePreg(get_ou("ogroupou"))."/","",$this->dn);
+
+      /* Is this account a trustAccount? */
+      if ($this->is_account && isset($this->attrs['trustModel'])){
+        $this->trustModel= $this->attrs['trustModel'][0];
+        $this->was_trust_account= TRUE;
+      } else {
+        $this->was_trust_account= FALSE;
+        $this->trustModel= "";
+      }
+
+      $this->accessTo = array();
+      if ($this->is_account && isset($this->attrs['accessTo'])){
+        for ($i= 0; $i<$this->attrs['accessTo']['count']; $i++){
+          $tmp= $this->attrs['accessTo'][$i];
+          $this->accessTo[$tmp]= $tmp;
+        }
+      }
     }
 
     /* Load member data */
@@ -126,12 +169,27 @@ class ogroup extends plugin
 
       /* Add objects to group */
       if (isset($_POST['add_object_finish']) && isset($_POST['objects'])){
+
+        $tmp = "";
+        foreach($this->memberList as $obj){
+          $tmp .= $obj['type'];
+        }
+        $skipped = FALSE;
         foreach ($_POST['objects'] as $value){
-          $this->memberList["$value"]= $this->objects[$value];
-          $this->member["$value"]= $value;
-          unset ($this->objects[$value]);
-          uasort ($this->memberList, 'sort_list');
-          reset ($this->memberList);
+          if(preg_match("/T/",$tmp) && $this->objects[$value]['type'] == "W"){
+            $skipped =TRUE;
+          }elseif(preg_match("/W/",$tmp) && $this->objects[$value]['type'] == "T"){
+            $skipped =TRUE;
+          }else{
+            $this->memberList["$value"]= $this->objects[$value];
+            $this->member["$value"]= $value;
+            unset ($this->objects[$value]);
+            uasort ($this->memberList, 'sort_list');
+            reset ($this->memberList);
+          }
+        }
+        if($skipped){
+          msg_dialog::display(_("Information"), _("You cannot combine terminals and workstations in one object group!"), INFO_DIALOG);
         }
         $this->reload();
       }
@@ -151,38 +209,11 @@ class ogroup extends plugin
 
     /* 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>";
+      $display= "<img alt=\"\" src=\"images/small-error.png\" align=\"middle\">&nbsp;<b>".
+        msgPool::noValidExtension("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();
@@ -202,6 +233,98 @@ class ogroup extends plugin
       }
     }
 
+    /***********
+     * Trusts 
+     ***********/
+
+    /* Add user workstation? */
+    if (isset($_POST["add_ws"])){
+      $this->show_ws_dialog= TRUE;
+      $this->dialog= TRUE;
+    }
+
+    /* Add user workstation? */
+    if (isset($_POST["add_ws_finish"]) && isset($_POST['wslist'])){
+      foreach($_POST['wslist'] as $ws){
+        $this->accessTo[$ws]= $ws;
+      }
+      ksort($this->accessTo);
+      $this->is_modified= TRUE;
+    }
+
+    /* Remove user workstations? */
+    if (isset($_POST["delete_ws"]) && isset($_POST['workstation_list'])){
+      foreach($_POST['workstation_list'] as $name){
+        unset ($this->accessTo[$name]);
+      }
+      $this->is_modified= TRUE;
+    }
+
+    /* Add user workstation finished? */
+    if (isset($_POST["add_ws_finish"]) || isset($_POST["add_ws_cancel"])){
+      $this->show_ws_dialog= FALSE;
+      $this->dialog= FALSE;
+    }
+
+    /* Show ws dialog */
+    if ($this->show_ws_dialog){
+      /* Save data */
+      $sysfilter= session::get("sysfilter");
+      foreach( array("depselect", "regex") as $type){
+        if (isset($_POST[$type])){
+          $sysfilter[$type]= $_POST[$type];
+        }
+      }
+      if (isset($_GET['search'])){
+        $s= mb_substr($_GET['search'], 0, 1, "UTF8")."*";
+        if ($s == "**"){
+          $s= "*";
+        }
+        $sysfilter['regex']= $s;
+      }
+      session::set("sysfilter", $sysfilter);
+
+      /* Get workstation list */
+      $exclude= "";
+      foreach($this->accessTo as $ws){
+        $exclude.= "(cn=$ws)";
+      }
+      if ($exclude != ""){
+        $exclude= "(!(|$exclude))";
+      }
+      $regex= $sysfilter['regex'];
+      $filter= "(&(|(objectClass=goServer)(objectClass=gotoWorkstation)(objectClass=gotoTerminal))$exclude(cn=*)(cn=$regex))";
+
+      $deps_a = array(get_ou("serverou"),
+          get_ou("terminalou"),
+          get_ou("workstationou"));
+      $res= get_sub_list($filter, array("terminal","server","workstation"), $deps_a, get_ou("systemsou").$sysfilter['depselect'],
+          array("cn"), GL_SUBSEARCH | GL_SIZELIMIT);
+      $wslist= array();
+      foreach ($res as $attrs){
+        $wslist[]= preg_replace('/\$/', '', $attrs['cn'][0]);
+      }
+      asort($wslist);
+      $smarty->assign("search_image", get_template_path('images/lists/search.png'));
+      $smarty->assign("launchimage", get_template_path('images/lists/action.png'));
+      $smarty->assign("tree_image", get_template_path('images/lists/search-subtree.png'));
+      $smarty->assign("deplist", $this->config->idepartments);
+      $smarty->assign("alphabet", generate_alphabet());
+      foreach( array("depselect", "regex") as $type){
+        $smarty->assign("$type", $sysfilter[$type]);
+      }
+      $smarty->assign("hint", print_sizelimit_warning());
+      $smarty->assign("wslist", $wslist);
+      $smarty->assign("apply", apply_filter());
+      $display= $smarty->fetch (get_template_path('trust_machines.tpl', TRUE, dirname(__FILE__)));
+      return ($display);
+    }
+
+    /***********
+     * Ende - Trusts 
+     ***********/
+
+
     /* Dialog handling */
     if(is_object($this->dialog) && $this->acl_is_moveable()){
       /* Must be called before save_object */
@@ -246,7 +369,7 @@ class ogroup extends plugin
       }
       if (isset($_POST['dselect'])){
         foreach( array("accounts", "groups", "applications", "departments",
-              "servers", "workstations", "terminals", "printers","subtrees",
+              "servers", "workstations", "winstations", "terminals", "printers","subtrees",
               "phones") as $type){
 
           if (isset($_POST[$type])) {
@@ -270,19 +393,63 @@ class ogroup extends plugin
       $smarty->assign("objects", $this->convert_list($this->objects));
 
       /* Show dialog */
-      $smarty->assign("search_image", get_template_path('images/search.png'));
-      $smarty->assign("launchimage", get_template_path('images/small_filter.png'));
-      $smarty->assign("tree_image", get_template_path('images/tree.png'));
+      $smarty->assign("search_image", get_template_path('images/lists/search.png'));
+      $smarty->assign("launchimage", get_template_path('images/lists/action.png'));
+      $smarty->assign("tree_image", get_template_path('images/lists/search-subtree.png'));
       $smarty->assign("deplist", $this->config->idepartments);
       $smarty->assign("alphabet", generate_alphabet());
-      foreach( array("dselect", "regex", "accounts", "groups", "applications",
-            "departments", "servers", "workstations", "terminals","subtrees",
-            "printers", "phones") as $type){
+      foreach( array("dselect", "regex", "subtrees") as $type){
         $smarty->assign("$type", $ogfilter[$type]);
       }
       $smarty->assign("hint", print_sizelimit_warning());
       $smarty->assign("apply", apply_filter());
 
+      /* Build up checkboxes 
+       */
+      $ar = array(
+          "departments" => array(
+            "T" => msgPool::selectToView(_("departments")),
+            "C" => (isset($ogfilter['departments']) && ($ogfilter['departments'])),
+            "L" => sprintf(_("Show %s"),_("departments"))),
+          "accounts" => array(
+            "T" => msgPool::selectToView(_("people")),
+            "C" => (isset($ogfilter['accounts']) && ($ogfilter['accounts'])),
+            "L" => sprintf(_("Show %s"),_("people"))),
+          "groups"=> array(
+            "T" => msgPool::selectToView(_("groups")),
+            "C" => (isset($ogfilter['groups']) && ($ogfilter['groups'])),
+            "L" => sprintf(_("Show %s"),_("groups"))),
+          "servers"=> array(
+            "T" => msgPool::selectToView(_("servers")),
+            "C" => (isset($ogfilter['servers']) && ($ogfilter['servers'])),
+            "L" => sprintf(_("Show %s"),_("servers"))),
+          "workstations"=> array(
+            "T" => msgPool::selectToView(_("workstations")),
+            "C" => (isset($ogfilter['workstations']) && ($ogfilter['workstations'])),
+            "L" => sprintf(_("Show %s"),_("workstations"))),
+          "terminals"=> array(
+            "T" => msgPool::selectToView(_("terminals")),
+            "C" => (isset($ogfilter['terminals']) && ($ogfilter['terminals'])),
+            "L" => sprintf(_("Show %s"),_("terminals"))),
+          "printers"=> array(
+            "T" => msgPool::selectToView(_("printer")),
+            "C" => (isset($ogfilter['printers']) && ($ogfilter['printers'])),
+            "L" => sprintf(_("Show %s"),_("printers"))),
+          "phones"=> array(
+            "T" => msgPool::selectToView(_("phones")),
+            "C" => (isset($ogfilter['phones']) && ($ogfilter['phones'])),
+            "L" => sprintf(_("Show %s"),_("phones"))));
+      /* Allow selecting applications if we are having a non 
+          release managed application storage */ 
+      if(!$this->IsReleaseManagementActivated()){
+        $ar["applications"] = array(
+            "T" => msgPool::selectToView(_("applications")),
+            "C" => (isset($ogfilter['applications']) && ($ogfilter['applications'])),
+            "L" => sprintf(_("Show %s"),_("applications")));
+      }
+
+      $smarty->assign("checkboxes",$ar);
       $display= $smarty->fetch (get_template_path('ogroup_objects.tpl', TRUE, dirname(__FILE__)));
       return ($display);
     }
@@ -304,6 +471,7 @@ class ogroup extends plugin
           "D" => _("departments"),
           "S" => _("servers"),
           "W" => _("workstations"),
+          "O" => _("winstations"),
           "T" => _("terminals"),
           "F" => _("phones"),
           "P" => _("printers"));
@@ -311,9 +479,9 @@ class ogroup extends plugin
       $type= preg_replace('/[\[\]]/', '', $this->gosaGroupObjects);
       $p1= $conv[$type[0]];
       error_reporting(0);
-      if (isset($type[1]) && preg_match('/[UGADSFWTP]/', $type[1])){
+      if (isset($type[1]) && preg_match('/[UGADSFOWTP]/', $type[1])){
         $p2= $conv[$type[1]];
-        $smarty->assign("combinedObjects", "$p1 "._("and")." $p2");
+        $smarty->assign("combinedObjects", sprintf("'%s' and '%s'", $p1, $p2));
       } else {
         $smarty->assign("combinedObjects", "$p1");
       }
@@ -334,6 +502,39 @@ class ogroup extends plugin
       $smarty->assign("$val", $this->$val);
     }
 
+    /******
+      Trust account
+     ******/
+    $smarty->assign("trusthide", " disabled ");
+    $smarty->assign("trustmodeACL",  $this->getacl("trustModel"));
+    if ($this->trustModel == "fullaccess"){
+      $trustmode= 1;
+      // pervent double disable tag in html code, this will disturb our clean w3c html
+      $smarty->assign("trustmode",  $this->getacl("trustModel"));
+
+    } elseif ($this->trustModel == "byhost"){
+      $trustmode= 2;
+      $smarty->assign("trusthide", "");
+    } else {
+      // pervent double disable tag in html code, this will disturb our clean w3c html
+      $smarty->assign("trustmode",  $this->getacl("trustModel"));
+      $trustmode= 0;
+    }
+    $smarty->assign("trustmode", $trustmode);
+    $smarty->assign("trustmodes", array( 0 => _("disabled"), 1 => _("full access"),
+          2 => _("allow access to these hosts")));
+
+    $smarty->assign("workstations", $this->accessTo);
+
+    if((count($this->accessTo))==0){
+      $smarty->assign("emptyArrAccess",true);
+    }else{
+      $smarty->assign("emptyArrAccess",false);
+    }
+    /******
+      Ende - Trust account
+     ******/
+
     return ($smarty->fetch (get_template_path('generic.tpl', TRUE)));
   }
 
@@ -344,6 +545,29 @@ class ogroup extends plugin
     /* Save additional values for possible next step */
     if (isset($_POST['ogroupedit'])){
 
+      /******
+        Trust account 
+       ******/
+
+      if($this->acl_is_writeable("trustModel")){
+        if (isset($_POST['trustmode'])){
+          $saved= $this->trustModel;
+          if ($_POST['trustmode'] == "1"){
+            $this->trustModel= "fullaccess";
+          } elseif ($_POST['trustmode'] == "2"){
+            $this->trustModel= "byhost";
+          } else {
+            $this->trustModel= "";
+          }
+          if ($this->trustModel != $saved){
+            $this->is_modified= TRUE;
+          }
+        }
+      }
+      /******
+        Ende Trust account
+       ******/
+
       /* Create a base backup and reset the
          base directly after calling plugin::save_object();
          Base will be set seperatly a few lines below */
@@ -385,17 +609,33 @@ class ogroup extends plugin
       Generate Filter 
       ###########*/
 
-    $p_f= array("accounts"        => array("CLASS"=>"gosaAccount"    ,"DN"=> get_people_ou()           ,"ACL" => "users"), 
-                "groups"          => array("CLASS"=>"posixGroup"     ,"DN"=> get_groups_ou()           ,"ACL" => "groups"), 
-                "applications"    => array("CLASS"=>"gosaApplication","DN"=> get_ou('applicationou')   ,"ACL" => "application"), 
-                "departments"     => array("CLASS"=>"gosaDepartment" ,"DN"=> ""                        ,"ACL" => "department"), 
-                "servers"         => array("CLASS"=>"goServer"       ,"DN"=> get_ou('serverou')        ,"ACL" => "server"),
-                "workstations"    => array("CLASS"=>"gotoWorkstation","DN"=> get_ou('workstationou')   ,"ACL" => "workstation"),
-                "terminals"       => array("CLASS"=>"gotoTerminal"   ,"DN"=> get_ou('terminalou')      ,"ACL" => "terminal"),
-                "printers"        => array("CLASS"=>"gotoPrinter"    ,"DN"=> get_ou('printerou')       ,"ACL" => "printer"),
-                "phones"          => array("CLASS"=>"goFonHardware"  ,"DN"=> get_ou('phoneou')         ,"ACL" => "phone"));
-
-
+    $p_f= array("accounts"=> array("OBJ"=>"user", "CLASS"=>"gosaAccount"    ,
+          "DN"=> get_people_ou()           ,"ACL" => "users"), 
+        "groups"          => array("OBJ"=>"group", "CLASS"=>"posixGroup"     ,
+          "DN"=> get_groups_ou('ogroupou') ,"ACL" => "groups"), 
+        "departments"     => array("OBJ"=>"department", "CLASS"=>"gosaDepartment" ,
+          "DN"=> ""                        ,"ACL" => "department"), 
+        "servers"         => array("OBJ"=>"servgeneric", "CLASS"=>"goServer"       ,
+          "DN"=> get_ou('serverou')        ,"ACL" => "server"),
+        "workstations"    => array("OBJ"=>"workgeneric", "CLASS"=>"gotoWorkstation",
+          "DN"=> get_ou('workstationou')   ,"ACL" => "workstation"),
+        "winstations"     => array("OBJ"=>"wingeneric", "CLASS"=>"opsiClient",        
+          "DN"=> get_ou('WINSTATIONS')     ,"ACL" => "winstation"),
+        "terminals"       => array("OBJ"=>"termgeneric", "CLASS"=>"gotoTerminal"   ,
+          "DN"=> get_ou('terminalou')      ,"ACL" => "terminal"),
+        "printers"        => array("OBJ"=>"printgeneric", "CLASS"=>"gotoPrinter"    ,
+          "DN"=> get_ou('printerou')       ,"ACL" => "printer"),
+        "phones"          => array("OBJ"=>"phoneGeneric", "CLASS"=>"goFonHardware"  ,
+          "DN"=> get_ou('phoneou')         ,"ACL" => "phone"));
+
+
+    /* Allow searching for applications, if we are not using release managed applications 
+      */
+    if(!$this->IsReleaseManagementActivated()){
+      $p_f[      "applications"]    = array("OBJ"=>"application", "CLASS"=>"gosaApplication",
+          "DN"=> get_ou('applicationou')   ,"ACL" => "application"); 
+    }
+           
     /*###########
       Perform search for selected objectClasses & regex to fill list with objects   
       ###########*/
@@ -407,14 +647,15 @@ class ogroup extends plugin
 
     foreach($p_f as $post_name => $data){
 
-      if($ogfilter[$post_name] == "checked"){
+      if($ogfilter[$post_name] == "checked" && class_available($data['OBJ'])){
 
         if($ogfilter['subtrees']){
           $base =  $ogfilter['dselect'];
         }else{
           $base =  $data['DN'].$ogfilter['dselect'];
         }
-    
+   
+         
         $filter = "(&(objectClass=".$data['CLASS'].")(|(uid=$regex)(cn=$regex)(ou=$regex)))";
         $res    = get_list($filter, $data['ACL']  , $base, 
                     array("description", "objectClass", "sn", "givenName", "uid","ou","cn"),$Get_list_flags);
@@ -453,10 +694,10 @@ class ogroup extends plugin
          it seams that this entry was removed 
        */ 
       /* Try to resolv the entry again, if it still fails, display error msg */
-      $ldap->cat($dn, array("cn", "sn", "givenName", "ou", "description", "objectClass"));
+      $ldap->cat($dn, array("cn", "sn", "givenName", "ou", "description", "objectClass", "macAddress"));
 
       /* It has failed, add entry with type flag I (Invalid)*/
-      if ($ldap->error != "Success"){
+      if (!$ldap->success()){
         $this->memberList[$dn]= array('text' => _("Non existing dn:")." ".@LDAP::fix($dn),"type" => "I");
 
       } else {
@@ -477,6 +718,13 @@ class ogroup extends plugin
           $this->objcache[$attrs["dn"]]= array("text" => "$name", "type" => "$type");
         }
         $this->objcache[$attrs["dn"]]['objectClass']  = $attrs['objectClass'];
+
+        if(isset($attrs['macAddress'][0])){
+          $this->objcache[$attrs["dn"]]['macAddress']  = $attrs['macAddress'][0];
+        }else{
+          $this->objcache[$attrs["dn"]]['macAddress']  = "";
+        }
+
         if(isset($attrs['uid'])){
           $this->objcache[$attrs["dn"]]['uid']          = $attrs['uid'];
         }
@@ -516,19 +764,20 @@ class ogroup extends plugin
   {
     $temp= "";
     $conv= array(  "U" => "select_user.png",
-        "G" => "select_groups.png",
-        "A" => "select_application.png",
-        "D" => "select_department.png",
-        "S" => "select_server.png",
-        "W" => "select_workstation.png",
-        "T" => "select_terminal.png",
-        "F" => "select_phone.png",
-        "I" => "flag.png",
-        "P" => "select_printer.png");
+        "G" => "plugins/groups/images/groups.png",
+        "A" => "plugins/ogroups/images/application.png",
+        "D" => "plugins/departments/images/department.png",
+        "S" => "plugins/ogroups/images/server.png",
+        "W" => "plugins/ogroups/images/workstation.png",
+        "O" => "plugins/ogroups/images/winstation.png",
+        "T" => "plugins/ogroups/images/terminal.png",
+        "F" => "plugins/ogroups/images/phone.png",
+        "I" => "images/lists/flag.png",
+        "P" => "plugins/ogroups/images/printer.png");
 
     foreach ($input as $key => $value){
       /* Generate output */
-      $temp.= "<option title='".addslashes( $key)."' value=\"$key\" class=\"select\" style=\"background-image:url('".get_template_path("images/".$conv[$value['type']])."');\">".$value['text']."</option>\n";
+      $temp.= "<option title='".addslashes( $key)."' value=\"$key\" class=\"select\" style=\"background-image:url('".get_template_path($conv[$value['type']])."');\">".$value['text']."</option>\n";
     }
 
     return ($temp);
@@ -545,6 +794,7 @@ class ogroup extends plugin
           "D" => "gosaDepartment",
           "S" => "goServer",
           "W" => "gotoWorkstation",
+          "O" => "opsiClient",
           "T" => "gotoTerminal",
           "F" => "goFonHardware",
           "P" => "gotoPrinter") as $index => $class){
@@ -587,7 +837,7 @@ class ogroup extends plugin
 
     /* Permissions for that base? */
     if ($this->base != ""){
-      $new_dn= 'cn='.$this->cn.','.get_groups_ou().$this->base;
+      $new_dn= 'cn='.$this->cn.','.get_ou('ogroupou').$this->base;
     } else {
       $new_dn= $this->dn;
     }
@@ -599,7 +849,7 @@ class ogroup extends plugin
     }
     
     if($ldap->count() !=0){
-      $message[]= _("There is already an object with this cn.");
+      $message[]= msgPool::duplicated(_("Name"));
     } 
 
     /* Set new acl base */
@@ -609,12 +859,12 @@ class ogroup extends plugin
 
     /* must: cn */
     if ($this->cn == ""){
-      $message[]= "The required field 'Name' is not set.";
+      $message[]= msgPool::required(_("Name"));
     }
 
     /* To many different object types? */
     if (strlen($this->gosaGroupObjects) > 4){
-      $message[]= _("You can combine two different object types at maximum only!");
+      $message[]= _("You can combine two different object types at maximum, only!");
     }
 
     return ($message);
@@ -636,7 +886,7 @@ class ogroup extends plugin
 
     /* New accounts need proper 'dn', propagate it to remaining objects */
     if ($this->dn == 'new'){
-      $this->dn= 'cn='.$this->cn.','.get_groups_ou().$this->base;
+      $this->dn= 'cn='.$this->cn.','.get_ou('ogroupou').$this->base;
     }
 
     /* Save data. Using 'modify' implies that the entry is already present, use 'add' for
@@ -655,6 +905,37 @@ class ogroup extends plugin
       $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn));
     }
 
+    /******
+      Trust accounts 
+     ******/
+    $objectclasses= array();
+    foreach ($this->attrs['objectClass'] as $key => $class){
+      if (preg_match('/trustAccount/i', $class)){
+        continue;
+      }
+      $objectclasses[]= $this->attrs['objectClass'][$key];
+    }
+    $this->attrs['objectClass']= $objectclasses;
+    if ($this->trustModel != ""){
+      $this->attrs['objectClass'][]= "trustAccount";
+      $this->attrs['trustModel']= $this->trustModel;
+      $this->attrs['accessTo']= array();
+      if ($this->trustModel == "byhost"){
+        foreach ($this->accessTo as $host){
+          $this->attrs['accessTo'][]= $host;
+        }
+      }
+    } else {
+      if ($this->was_trust_account){
+        $this->attrs['accessTo']= array();
+        $this->attrs['trustModel']= array();
+      }
+    }
+
+    /******
+      Ende - Trust accounts 
+     ******/
+
     /* Write back to ldap */
     $ldap->cd($this->dn);
     $this->cleanup();
@@ -670,7 +951,8 @@ class ogroup extends plugin
     $this->handle_post_events($mode);
 
     $ret= 0;
-    if (show_ldap_error($ldap->get_error(), sprintf(_("Saving of object group/generic with dn '%s' failed."),$this->dn))){
+    if (!$ldap->success()){
+      msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, 0, get_class()));
       $ret= 1;
     }
 
@@ -683,7 +965,9 @@ class ogroup extends plugin
 
     $ldap= $this->config->get_ldap_link();
     $ldap->rmdir($this->dn);
-    show_ldap_error($ldap->get_error(), sprintf(_("Removing of object group/generic with dn '%s' failed."),$this->dn));
+    if (!$ldap->success()){
+      msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, 0, get_class()));
+    }
 
     new log("remove","ogroups/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
 
@@ -741,6 +1025,17 @@ class ogroup extends plugin
   }
 
 
+  function IsReleaseManagementActivated()
+  {
+    /* Check if we should enable the release selection */
+    $tmp = $this->config->search("faiManagement", "CLASS",array('menu','tabs'));
+    if(!empty($tmp)){
+      return(true);
+    }
+    return(false);
+  }
+
+
   static function plInfo()
   {
     return (array(