Code

Do not remove classes/plugin from session if a lock was removed
[gosa.git] / gosa-core / plugins / admin / ogroups / class_ogroup.inc
index 2a540857c3985fd34c71c835bb9825dbdd7703be..b038bf6611c88396200e9dfa5ca750a9aeddb115 100644 (file)
@@ -86,14 +86,14 @@ class ogroup extends plugin
     $this->is_account= TRUE;
 
     /* Get global filter config */
-    if (!session::is_set("ogfilter")){
+    if (!session::global_is_set("ogfilter")){
       $ui= get_userinfo();
       $base= get_base_from_people($ui->dn);
       $ogfilter= array( "dselect"       => $base,
           "regex"           => "*");
-      session::set("ogfilter", $ogfilter);
+      session::global_set("ogfilter", $ogfilter);
     }
-    $ogfilter= session::get('ogfilter');
+    $ogfilter= session::global_get('ogfilter');
 
     /* Adjust flags */
     foreach( array(   "U" => "accounts",
@@ -114,15 +114,15 @@ class ogroup extends plugin
         $ogfilter[$val]= "";
       }
     }
-    session::set("ogfilter", $ogfilter);
+    session::global_set("ogfilter", $ogfilter);
   
-    if(session::is_set('CurrentMainBase')){
-     $this->base  = session::get('CurrentMainBase');
+    if(session::global_is_set('CurrentMainBase')){
+     $this->base  = global_session::get('CurrentMainBase');
     }
 
     /* Set base */
     if ($this->dn == "new"){
-      $this->base = session::get('CurrentMainBase');
+      $this->base = session::global_get('CurrentMainBase');
     } else {
       $this->base= preg_replace("/^[^,]+,".preg_quote(get_ou("ogroupRDN"), '/')."/","",$this->dn);
 
@@ -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);
       }
     }
@@ -170,12 +170,12 @@ class ogroup extends plugin
     $this->orig_base = $this->base;
 
     /* Get global filter config */
-    if (!session::is_set("sysfilter")){
+    if (!session::global_is_set("sysfilter")){
       $ui= get_userinfo();
       $base= get_base_from_people($ui->dn);
       $sysfilter= array( "depselect"       => $base,
           "regex"           => "*");
-      session::set("sysfilter", $sysfilter);
+      session::global_set("sysfilter", $sysfilter);
     }
 
     /* Load member data */
@@ -309,7 +309,7 @@ class ogroup extends plugin
     /* Show ws dialog */
     if ($this->show_ws_dialog){
       /* Save data */
-      $sysfilter= session::get("sysfilter");
+      $sysfilter= session::global_get("sysfilter");
       foreach( array("depselect", "regex") as $type){
         if (isset($_POST[$type])){
           $sysfilter[$type]= $_POST[$type];
@@ -322,7 +322,7 @@ class ogroup extends plugin
         }
         $sysfilter['regex']= $s;
       }
-      session::set("sysfilter", $sysfilter);
+      session::global_set("sysfilter", $sysfilter);
 
       /* Get workstation list */
       $exclude= "";
@@ -401,7 +401,7 @@ class ogroup extends plugin
     if ($this->group_dialog){
 
       /* Save data */
-      $ogfilter= session::get("ogfilter");
+      $ogfilter= session::global_get("ogfilter");
       foreach( array("dselect", "regex") as $type){
         if (isset($_POST[$type])){
           $ogfilter[$type]= $_POST[$type];
@@ -426,11 +426,17 @@ class ogroup extends plugin
         }
         $ogfilter['regex']= $s;
       }
-      session::set("ogfilter", $ogfilter);
+      session::global_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'));
@@ -638,7 +644,7 @@ class ogroup extends plugin
     $filter                       = "";
     $objectClasses                = array();
     
-    $ogfilter               = session::get("ogfilter");
+    $ogfilter               = session::global_get("ogfilter");
     $regex                  = $ogfilter['regex'];
 
     $ldap= $this->config->get_ldap_link();
@@ -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);
@@ -890,21 +898,16 @@ class ogroup extends plugin
     }
 
     /* 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();