Code

Reverted global session changes. Too time consuming.
[gosa.git] / gosa-core / plugins / admin / ogroups / class_ogroup.inc
index dd4f7146e1cc22950415d4ebde4c23703eac5009..9aeff56552c9c0c10c6fe64e51e05f8474a5b59d 100644 (file)
@@ -124,7 +124,7 @@ class ogroup extends plugin
     if ($this->dn == "new"){
       $this->base = session::get('CurrentMainBase');
     } else {
-      $this->base= preg_replace("/^[^,]+,".normalizePreg(get_ou("ogroupou"))."/","",$this->dn);
+      $this->base= preg_replace("/^[^,]+,".preg_quote(get_ou("ogroupRDN"), '/')."/","",$this->dn);
 
       /* Is this account a trustAccount? */
       if ($this->is_account && isset($this->attrs['trustModel'])){
@@ -149,19 +149,19 @@ class ogroup extends plugin
         - Check() will complain if such a system is assigned to this object group.
      */ 
     $base = $this->config->current['BASE'];
-    $res    = get_list("(objectClass=gotoWorkstation)","none" , 
+    $res    = get_list("(|(objectClass=gotoWorkstation)(objectClass=gotoTerminal))","none" , 
         $base, array("dn"),GL_NO_ACL_CHECK|GL_SUBSEARCH);
     $ws_dns = array();
     foreach($res as $data){
       $ws_dns[] = $data['dn'];
     }
     $res=get_list("(&(member=*)(objectClass=gosaGroupOfNames))","none",
-        $base, array("dn","member"),GL_NO_ACL_CHECK|GL_SUBSEARCH);
+        $base, array("dn","member", "gosaGroupObjects"),GL_NO_ACL_CHECK|GL_SUBSEARCH);
     $this->used_workstations = array();
     foreach($res as $og){
       if($og['dn'] == $this->dn) continue;
       $test = array_intersect($ws_dns,$og['member']);
-      if(count($test)){
+      if(($og['gosaGroupObjects'] == "[W]" || $og['gosaGroupObjects'] == "[T]") && count($test)){
         $this->used_workstations = array_merge($this->used_workstations,$test);
       }
     }
@@ -429,8 +429,14 @@ class ogroup extends plugin
       session::set("ogfilter", $ogfilter);
       $this->reload();
 
-      /* Calculate actual groups */
-      $smarty->assign("objects", $this->convert_list($this->objects));
+      /* Calculate actual groups / remove entries that are already inside... */
+      $strippedObjects= array();
+      foreach ($this->objects as $key => $value){
+        if (!isset($this->member[$key])){
+          $strippedObjects[$key]= $value;
+        }
+      }
+      $smarty->assign("objects", $this->convert_list($strippedObjects));
 
       /* Show dialog */
       $smarty->assign("search_image", get_template_path('images/lists/search.png'));
@@ -652,7 +658,7 @@ class ogroup extends plugin
     $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"), 
+          "DN"=> get_groups_ou('ogroupRDN') ,"ACL" => "groups"), 
         "departments"     => array("OBJ"=>"department", "CLASS"=>"gosaDepartment" ,
           "DN"=> ""                        ,"ACL" => "department"), 
         "servers"         => array("OBJ"=>"servgeneric", "CLASS"=>"goServer"       ,
@@ -673,7 +679,7 @@ class ogroup extends plugin
       */
     if(!$this->IsReleaseManagementActivated()){
       $p_f[      "applications"]    = array("OBJ"=>"application", "CLASS"=>"gosaApplication",
-          "DN"=> get_ou('applicationou')   ,"ACL" => "application"); 
+          "DN"=> get_ou('applicationRDN')   ,"ACL" => "application"); 
     }
            
     /*###########
@@ -705,8 +711,10 @@ class ogroup extends plugin
 
           /* Skip workstations which are already assigned to an object group.
            */
-          if(in_array($attrs['dn'],$this->used_workstations)){
-            continue;
+          if ($this->gosaGroupObjects == "[W]" || $this->gosaGroupObjects == "[T]"){
+            if(in_array($attrs['dn'],$this->used_workstations)){
+              continue;
+            }
           }
 
           $type= $this->getObjectType($attrs);
@@ -744,7 +752,7 @@ class ogroup extends plugin
 
       /* It has failed, add entry with type flag I (Invalid)*/
       if (!$ldap->success()){
-        $this->memberList[$dn]= array('text' => _("Non existing dn:")." ".@LDAP::fix($dn),"type" => "I");
+        $this->memberList[$dn]= array('text' => _("Non existing dn:")." ".LDAP::fix($dn),"type" => "I");
 
       } else {
 
@@ -819,8 +827,8 @@ class ogroup extends plugin
         "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");
+        "P" => "plugins/ogroups/images/printer.png",
+        "I" => "images/false.png");
 
     foreach ($input as $key => $value){
       /* Generate output */
@@ -884,27 +892,22 @@ class ogroup extends plugin
 
     /* Permissions for that base? */
     if ($this->base != ""){
-      $new_dn= 'cn='.$this->cn.','.get_ou('ogroupou').$this->base;
+      $new_dn= 'cn='.$this->cn.','.get_ou('ogroupRDN').$this->base;
     } else {
       $new_dn= $this->dn;
     }
 
     /* Check if we have workstations assigned, that are already assigned to
-        another object group.
-     */
-    $test =array_intersect($this->used_workstations,$this->member); 
-    if(count($test)){
-      $str = "";
-      $cnt = 0;
-      foreach($test as $dn){
-        $str .= $dn.",  ";
-        $cnt ++;
-        if($cnt > 2){
-          $str .= "...";
-          break;
+        another object group.  */
+    if ($this->gosaGroupObjects == "[W]" || $this->gosaGroupObjects == "[T]" ) {
+      $test =array_intersect($this->used_workstations,$this->member); 
+      if(count($test)){
+        $str = "";
+        foreach($test as $dn){
+          $str .= "<li>".$dn."</li>";
         }
+        $message[] = sprintf(_("These systems are already configured by other object groups and cannot be added:")."<br><ul>%s</ul>",$str);
       }
-#      $message[] = sprintf(_("The following workstations are already member in another object group and can not be added: '%s'"),$str);
     }
 
     $ldap = $this->config->get_ldap_link();
@@ -951,14 +954,14 @@ class ogroup extends plugin
     /* Move members to target array */
     $this->attrs['member'] =array();
     foreach ($this->member as $key => $desc){
-      $this->attrs['member'][]= @LDAP::fix($key);
+      $this->attrs['member'][]= LDAP::fix($key);
     }
 
     $ldap= $this->config->get_ldap_link();
 
     /* New accounts need proper 'dn', propagate it to remaining objects */
     if ($this->dn == 'new'){
-      $this->dn= 'cn='.$this->cn.','.get_ou('ogroupou').$this->base;
+      $this->dn= 'cn='.$this->cn.','.get_ou('ogroupRDN').$this->base;
     }
 
     /* Save data. Using 'modify' implies that the entry is already present, use 'add' for