Code

Updated css und div framework.
[gosa.git] / plugins / admin / ogroups / class_ogroup.inc
index 250cce677815efb36e0dd5d6a216a52e20f11a87..39ae7ad1fce711f2fab35601a66a0407e06d98a8 100644 (file)
@@ -100,12 +100,15 @@ class ogroup extends plugin
   function AddDelMembership($NewMember = false){
 
     if($NewMember){
-      $this->memberList[$NewMember]= $this->objcache[$NewMember];
+
+      /* Add member and force reload */
       $this->member[$NewMember]= $NewMember;
+      $this->reload(); 
+
+      $this->memberList[$NewMember]= $this->objcache[$NewMember];
       unset ($this->objects[$NewMember]);
       uasort ($this->memberList, 'sort_list');
       reset ($this->memberList);
-      $this->reload();
     }else{
       /* Delete objects from group */
       if (isset($_POST['delete_membership']) && isset($_POST['members'])){
@@ -183,13 +186,6 @@ class ogroup extends plugin
       $smarty->assign($name."ACL",$this->getacl($name));
     }
 
-    /* Create base acls */
-    $baseACL = $this->getacl("base",(!is_object($this->parent) && !isset($_SESSION['edit'])));
-    if(!$this->acl_is_moveable()) {
-      $baseACL = preg_replace("/w/","",$baseACL);
-    }
-    $smarty->assign("baseACL",          $baseACL);
-
     /* Base select dialog */
     $once = true;
     foreach($_POST as $name => $value){
@@ -208,7 +204,12 @@ class ogroup extends plugin
       if($this->dialog->isClosed()){
         $this->dialog = false;
       }elseif($this->dialog->isSelected()){
-        $this->base = $this->dialog->isSelected();
+
+        /* A new base was selected, check if it is a valid one */
+        $tmp = $this->get_allowed_bases();
+        if(isset($tmp[$this->dialog->isSelected()])){
+          $this->base = $this->dialog->isSelected();
+        }
         $this->dialog= false;
       }else{
         return($this->dialog->execute());
@@ -336,8 +337,21 @@ class ogroup extends plugin
   {
     /* Save additional values for possible next step */
     if (isset($_POST['ogroupedit'])){
+
+      /* Create a base backup and reset the
+         base directly after calling plugin::save_object();
+         Base will be set seperatly a few lines below */
+      $base_tmp = $this->base;
       plugin::save_object();
-  
+      $this->base = $base_tmp;
+
+      /* Save base, since this is no LDAP attribute */
+      $tmp = $this->get_allowed_bases();
+      if(isset($_POST['base'])){
+        if(isset($tmp[$_POST['base']])){
+          $this->base= $_POST['base'];
+        }
+      }
     }
   }
 
@@ -357,7 +371,6 @@ class ogroup extends plugin
     $ogfilter               = get_global("ogfilter");
     $regex                  = $ogfilter['regex'];
 
-    /* Get ldap connection */
     $ldap= $this->config->get_ldap_link();
     $ldap->cd ($ogfilter['dselect']);
 
@@ -366,75 +379,47 @@ class ogroup extends plugin
       Generate Filter 
       ###########*/
 
-    /* Assemble filter */
-    if ($ogfilter['accounts'] == "checked"){
-      $filter.= "(objectClass=gosaAccount)";
-      $objectClasses["gosaAccount"]     = get_people_ou();
-    }
-    if ($ogfilter['groups'] == "checked"){
-      $filter.= "(objectClass=posixGroup)";
-      $objectClasses["posixGroup"]      = get_groups_ou();
-    }
-    if ($ogfilter['applications'] == "checked"){
-      $filter.= "(objectClass=gosaApplication)";
-      $objectClasses["gosaApplication"] = "ou=apps,";
-    }
-    if ($ogfilter['departments'] == "checked"){
-      $filter.= "(objectClass=gosaDepartment)";
-      $objectClasses["gosaDepartment"]  = "";
-    }
-    if ($ogfilter['servers'] == "checked"){
-      $filter.= "(objectClass=goServer)";
-      $objectClasses["goServer"]        = "ou=servers,ou=systems,";
-    }
-    if ($ogfilter['workstations'] == "checked"){
-      $filter.= "(objectClass=gotoWorkstation)";
-      $objectClasses["gotoWorkstation"] = "ou=workstations,ou=systems,";
-    }
-    if ($ogfilter['terminals'] == "checked"){
-      $filter.= "(objectClass=gotoTerminal)";
-      $objectClasses["gotoTerminal"]    = "ou=terminals,ou=systems,";
-    }
-    if ($ogfilter['printers'] == "checked"){
-      $filter.= "(objectClass=gotoPrinter)";
-
-      $objectClasses["gotoPrinter"]     = "ou=printers,ou=systems,";
-    }
-    if ($ogfilter['phones'] == "checked"){
-      $filter.= "(objectClass=goFonHardware)";
-      $objectClasses["goFonHardware"]   = "ou=phones,ou=systems,";
-    }
+    $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"=> "ou=apps,"                       ,"ACL" => "application"), 
+                "departments"     => array("CLASS"=>"gosaDepartment" ,"DN"=> ""                               ,"ACL" => "department"), 
+                "servers"         => array("CLASS"=>"goServer"       ,"DN"=> "ou=servers,ou=systems,"         ,"ACL" => "server"),
+                "workstations"    => array("CLASS"=>"gotoWorkstation","DN"=> "ou=workstations,ou=systems,"    ,"ACL" => "workstation"),
+                "terminals"       => array("CLASS"=>"gotoTerminal"   ,"DN"=> "ou=terminals,ou=systems,"       ,"ACL" => "terminal"),
+                "printers"        => array("CLASS"=>"gotoPrinter"    ,"DN"=> "ou=printers,ou=systems,"        ,"ACL" => "printer"),
+                "phones"          => array("CLASS"=>"goFonHardware"  ,"DN"=> "ou=phones,ou=systems,"          ,"ACL" => "phone"));
 
 
     /*###########
       Perform search for selected objectClasses & regex to fill list with objects   
       ###########*/
 
-    /* Perform search for selected objectClasses */
-    foreach($objectClasses as $class=> $basedn){
+    $Get_list_flags = 0;
+    if($ogfilter['subtrees'] == "checked"){
+      $Get_list_flags |= GL_SUBSEARCH;
+    }    
 
-      if($ogfilter['subtrees'] == "checked"){
-        $ldap->cd($ogfilter['dselect']);
-        $ldap->search("(&(objectClass=".$class.")(|(uid=$regex)(cn=$regex)(ou=$regex)))",
-            array("dn", "cn", "description", "objectClass", "sn", "givenName", "uid","ou"));
-      }else{
-        $ldap->ls("(&(objectClass=".$class.")(|(uid=$regex)(cn=$regex)(ou=$regex)))",$basedn.$ogfilter['dselect'] ,
-            array("dn", "cn", "description", "objectClass", "sn", "givenName", "uid","ou"));
-      }
-      
-      /* fetch results and append them to the list */
-      while($attrs = $ldap->fetch()){
+    foreach($p_f as $post_name => $data){
 
-        $type= $this->getObjectType($attrs);
-        $name= $this->getObjectName($attrs);
+      if($ogfilter[$post_name] == "checked"){
+        $filter = "(&(objectClass=".$data['CLASS'].")(|(uid=$regex)(cn=$regex)(ou=$regex)))";
+        $res    = get_list($filter, $data['ACL']  , $data['DN'].$ogfilter['dselect'], 
+                    array("description", "objectClass", "sn", "givenName", "uid","ou","cn"));
 
-        /* Fill array */
-        if (isset($attrs["description"][0])){
-          $this->objects[$attrs["dn"]]= array("text" => "$name [".$attrs["description"][0]."]", "type" => "$type");
-        } elseif (isset($attrs["uid"][0])) {
-          $this->objects[$attrs["dn"]]= array("text" => "$name [".$attrs["uid"][0]."]", "type" => "$type");
-        } else {
-          $this->objects[$attrs["dn"]]= array("text" => "$name", "type" => "$type");
+        /* fetch results and append them to the list */
+        foreach($res as $attrs){
+
+          $type= $this->getObjectType($attrs);
+          $name= $this->getObjectName($attrs);
+
+          /* Fill array */
+          if (isset($attrs["description"][0])){
+            $this->objects[$attrs["dn"]]= array("text" => "$name [".$attrs["description"][0]."]", "type" => "$type");
+          } elseif (isset($attrs["uid"][0])) {
+            $this->objects[$attrs["dn"]]= array("text" => "$name [".$attrs["uid"][0]."]", "type" => "$type");
+          } else {
+            $this->objects[$attrs["dn"]]= array("text" => "$name", "type" => "$type");
+          }
         }
       }
     }
@@ -530,7 +515,7 @@ class ogroup extends plugin
 
     foreach ($input as $key => $value){
       /* Generate output */
-      $temp.= "<option 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("images/".$conv[$value['type']])."');\">".$value['text']."</option>\n";
     }
 
     return ($temp);
@@ -604,12 +589,13 @@ class ogroup extends plugin
       $message[]= _("There is already an object with this cn.");
     } 
 
-    if ($this->orig_dn == "new" && !$this->acl_is_createable()){
-      $message[]= _("You have no permissions to create a group on this 'Base'.");
+    /* Set new acl base */
+    if($this->dn == "new") {
+      $this->set_acl_base($this->base);
     }
 
     /* must: cn */
-    if ($this->cn == "" && $this->acl_is_writeable("cn")){
+    if ($this->cn == ""){
       $message[]= "The required field 'Name' is not set.";
     }
 
@@ -710,7 +696,7 @@ class ogroup extends plugin
           "plDescription" => _("Object group generic"),
           "plSelfModify"  => FALSE,
           "plDepends"     => array(),
-          "plPriority"    => 0,
+          "plPriority"    => 1,
           "plSection"     => array("administration"),
           "plCategory"    => array("ogroups" => array("description"  => _("Object groups"),
                                                       "objectClass"  => "gosaGroupOfNames")),