Code

Reverted Last commits, I've accidentally replaced to much.
[gosa.git] / gosa-core / plugins / admin / groups / class_group.inc
index e570f1244cd9c855929472ee1522e86aba353e06..6860f8e1a4f7997659ff28e80b0fe859510b8dee 100644 (file)
@@ -68,10 +68,17 @@ class group extends plugin
 
   var $multiple_support = TRUE;
 
+
+    // Lists 
+    private $memberList;    // Single group editing
+    private $commonList;    // (Multiple support active)
+    private $partialList;   // (Multiple support active)
+
+
   function group (&$config, $dn= NULL)
   {
      /* Set rfc2307bis flag */
-     if ($config->get_cfg_value("rfc2307bis") == "true"){
+     if ($config->get_cfg_value("core","rfc2307bis") == "true"){
        $this->rfc2307bis= TRUE;
        $this->attributes[]= "member";
        $this->objectclasses[]= "groupOfNames";
@@ -139,7 +146,7 @@ class group extends plugin
         if(isset($attrs['sambaAlgorithmicRidBase'])){  
           $this->ridBase= $attrs['sambaAlgorithmicRidBase'][0];  
         } else {  
-          $this->ridBase= $this->config->get_cfg_value("sambaRidBase");
+          $this->ridBase= $this->config->get_cfg_value("core","sambaRidBase");
         } 
 
         /* Get domain name for SID */
@@ -151,10 +158,10 @@ class group extends plugin
           }
         }
       } else {
-        if ($this->config->get_cfg_value("sambaRidBase") != ""){
+        if ($this->config->get_cfg_value("core","sambaRidBase") != ""){
           $this->sambaDomainName= "DEFAULT";
-          $this->ridBase= $this->config->get_cfg_value("sambaRidBase");
-          $this->SID= $this->config->get_cfg_value("sid");
+          $this->ridBase= $this->config->get_cfg_value("core","sambaRidBase");
+          $this->SID= $this->config->get_cfg_value("core","sid");
         } else {
           msg_dialog::display(_("Configuration error"), _("Cannot find group SID in your configuration!"), ERROR_DIALOG);
         }
@@ -191,6 +198,8 @@ class group extends plugin
     $this->baseSelector->setHeight(300);
     $this->baseSelector->update(true);
 
+
+
     // Prepare lists
     $this->memberList = new sortableListing();
     $this->memberList->setDeleteable(true);
@@ -222,16 +231,22 @@ class group extends plugin
       return ($display);
     }
 
-    /* Delete user from group */
-    $this->memberList->save_object();
-    $action = $this->memberList->getAction();
-    if($action['action'] == 'delete' && preg_match("/w/",$this->getacl("memberUid"))){
-      foreach ($action['targets'] as $id){
-        $value = $this->memberList->getKey($id);
-        unset ($this->members["$value"]);
-        $this->removeUser($value);
-      }
-      $this->reload();
+    // Act on list events 
+    foreach(array('memberList','commonList','partialList') as $list){
+
+        // Check if list is available, depends on multi- or sinlge- group editing. 
+        if($this->$list){
+            $this->$list->save_object();
+            $action = $this->$list->getAction();
+            if($action['action'] == 'delete' && preg_match("/w/",$this->getacl("memberUid"))){
+                foreach ($action['targets'] as $id){
+                    $value = $this->$list->getKey($id);
+                    unset ($this->members["$value"]);
+                    $this->removeUser($value);
+                }
+                $this->reload();
+            }
+        }
     }
 
     /* Add objects? */
@@ -272,19 +287,10 @@ class group extends plugin
     }
     $smarty->assign("trustModeDialog" , $trustModeDialog);
 
-    $smarty->assign("usePrototype", "true");
 
-    if($this->config->search("nagiosaccount", "CLASS",array('menu'))){
-      $smarty->assign("nagios",true);
-    }else{
-      $smarty->assign("nagios",false);
-    }
-    
-    if($this->config->search("phoneAccount", "CLASS",array('menu'))){
-      $smarty->assign("pickupGroup",true);
-    }else{
-      $smarty->assign("pickupGroup",false);
-    }
+
+    $smarty->assign("nagios", $this->config->pluginEnabled("nagiosAccount"));
+    $smarty->assign("pickupGroup", $this->config->pluginEnabled("phoneAccount"));
 
     /* Manage object add dialog */
     if ($this->userSelect){
@@ -315,29 +321,63 @@ class group extends plugin
     
 
     /* Members and users */
-    $this->memberList->setAcl($this->getacl("memberUid"));
-    $data = $lData = array();
-
-    foreach($this->members as $uid => $member){
-        
-        $data[$uid] = $member;
-        $givenName = $sn = _("Unknown");
-        if(isset($member['sn'][0])) $sn = $member['sn'][0];
-        if(isset($member['givenName'][0])) $givenName = $member['givenName'][0];
-        
-        $image = image('images/false.png');
-        if(isset($member['sn'])){
-            $image = image('plugins/users/images/select_user.png');
+    if(!$this->multiple_support_active){
+        $this->memberList->setAcl($this->getacl("memberUid"));
+        $data = $lData = array();
+        foreach($this->members as $uid => $member){
+            $data[$uid] = $member;
+            $givenName = $sn = _("Unknown");
+            if(isset($member['sn'][0])) $sn = $member['sn'][0];
+            if(isset($member['givenName'][0])) $givenName = $member['givenName'][0];
+            $image = image('images/false.png');
+            if(isset($member['sn'])){
+                $image = image('plugins/users/images/select_user.png');
+            }
+            $lData[$uid] = array('data' => array($image,$sn, $givenName, $uid));
         }
-
-        $lData[$uid] = array('data' => array($image,$sn, $givenName, $uid));
+        $this->memberList->setListData($data,$lData);
+        $this->memberList->update();
+        $smarty->assign("memberList", $this->memberList->render());
+    }else{
+    
+        $this->commonList->setAcl($this->getacl("memberUid"));
+        $this->partialList->setAcl($this->getacl("memberUid"));
+
+        $data = $lData = array();
+        foreach($this->memberUid as $uid => $member){
+            $member = $this->members[$member];
+            $data[$uid] = $member;
+            $givenName = $sn = _("Unknown");
+            if(isset($member['sn'][0])) $sn = $member['sn'][0];
+            if(isset($member['givenName'][0])) $givenName = $member['givenName'][0];
+            $image = image('images/false.png');
+            if(isset($member['sn'])){
+                $image = image('plugins/users/images/select_user.png');
+            }
+            $lData[$uid] = array('data' => array($image,$sn, $givenName, $uid));
+        }
+        $this->commonList->setListData($data,$lData);
+        $this->commonList->update();
+        $smarty->assign("commonList", $this->commonList->render());
+
+        $data = $lData = array();
+        foreach($this->memberUid_used_by_some as $uid => $member){
+            $member = $this->members[$member];
+            $data[$uid] = $member;
+            $givenName = $sn = _("Unknown");
+            if(isset($member['sn'][0])) $sn = $member['sn'][0];
+            if(isset($member['givenName'][0])) $givenName = $member['givenName'][0];
+            $image = image('images/false.png');
+            if(isset($member['sn'])){
+                $image = image('plugins/users/images/select_user.png');
+            }
+            $lData[$uid] = array('data' => array($image,$sn, $givenName, $uid));
+        }
+        $this->partialList->setListData($data,$lData);
+        $this->partialList->update();
+        $smarty->assign("partialList", $this->partialList->render());
     }
 
-    $this->memberList->setListData($data,$lData);
-    $this->memberList->update();
-
-    $smarty->assign("memberList", $this->memberList->render());
-
     /* Checkboxes */
     foreach (array("force_gid", "smbgroup") as $val){
       if ($this->$val == "1"){
@@ -381,8 +421,6 @@ class group extends plugin
 
     /* Multiple edit handling */
     $smarty->assign("multiple_support",$this->multiple_support_active);
-    $smarty->assign("memberUid_All",$this->memberUid);
-    $smarty->assign("memberUid_Some",$this->memberUid_used_by_some);
 
     foreach($this->attributes as $val){
       if(in_array($val,$this->multi_boxes)){
@@ -478,9 +516,16 @@ class group extends plugin
          to be prepared when adding/deleting users)
      */    
     $filter = "";
-    if ($this->config->get_cfg_value("ldapFilterNestingLimit") == "" ||
-        count($this->memberUid) < $this->config->get_cfg_value("ldapFilterNestingLimit")){
-      foreach ($this->memberUid as $value){
+
+    // Merge in partial uids in multiple edit
+    $uids = array_keys($this->memberUid);
+    if($this->multiple_support_active) {
+        $uids = array_merge($uids,  array_keys($this->memberUid_used_by_some));
+    }
+    
+    if ($this->config->get_cfg_value("core","ldapFilterNestingLimit") == "" ||
+        count($uids) < $this->config->get_cfg_value("core","ldapFilterNestingLimit")){
+      foreach ($uids as $value){
         if(!isset($this->members[$value])){
           $filter .= "(uid=".normalizeLdap($value).")";
         }
@@ -498,8 +543,8 @@ class group extends plugin
     }
   
     /* check if all uids are resolved */
-    if ($this->config->get_cfg_value("ldapFilterNestingLimit") == "" ||
-        count($this->memberUid) < $this->config->get_cfg_value("ldapFilterNestingLimit")){
+    if ($this->config->get_cfg_value("core","ldapFilterNestingLimit") == "" ||
+        count($this->memberUid) < $this->config->get_cfg_value("core","ldapFilterNestingLimit")){
       foreach ($this->memberUid as $value){
         if(!isset($this->members[$value])){
           $this->members[$value] = "";
@@ -712,7 +757,7 @@ class group extends plugin
       /* User wants me to fake the idMappings? This is useful for
          making winbind resolve the group names in a reasonable amount
          of time in combination with larger databases. */
-      if ($this->config->get_cfg_value("sambaidmapping") == "true"){
+      if ($this->config->get_cfg_value("core","sambaidmapping") == "true"){
         $this->attrs['objectClass'][]= "sambaIdmapEntry";
       }
 
@@ -773,9 +818,6 @@ class group extends plugin
       $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn));
     }
 
-    $this->trustModeDialog->dn = $this->dn;
-    $this->trustModeDialog->save();
-
     /* Check generated gidNumber, it may be used by another group. 
      */
     if($this->gidNumber != ""){
@@ -815,6 +857,9 @@ class group extends plugin
       $ret= 1;
     }
 
+    $this->trustModeDialog->dn = $this->dn;
+    $this->trustModeDialog->save();
+
     /* Remove uid lock */
     del_lock ("gidnumber");
 
@@ -900,8 +945,8 @@ class group extends plugin
       if (!tests::is_id($this->gidNumber)){
         $message[]= msgPool::invalid(_("GID"), $this->gidNumber, "/[0-9]/");
       } else {
-        if ($this->gidNumber < $this->config->get_cfg_value("minId")){
-          $message[]= msgPool::toosmall(_("GID"), $this->config->get_cfg_value("minId"));
+        if ($this->gidNumber < $this->config->get_cfg_value("core","minId")){
+          $message[]= msgPool::toosmall(_("GID"), $this->config->get_cfg_value("core","minId"));
         }
 
       }
@@ -975,6 +1020,19 @@ class group extends plugin
           "plSection"     => array("administration"),
           "plCategory"    => array("groups" => array("objectClass" => "posixGroup", "description" => _("Groups"))),
 
+          "plProperties" =>
+          array(
+              array(
+                  "name"          => "ogroupRDN",
+                  "type"          => "rdn",
+                  "default"       => "ou=groups,",
+                  "description"   => "The 'ogroupRDN' statement defines the location where new accounts will be created. The default is 'ou=groups,'.",
+                  "check"         => "gosaProperty::isRdn",
+                  "migrate"       => "",
+                  "group"         => "plugin",
+                  "mandatory"     => FALSE)),
+
+
           "plProvidedAcls"    => array(
             "cn"                => _("Name"),
             "description"       => _("Description"),
@@ -1023,7 +1081,7 @@ class group extends plugin
         }
       }
 
-      foreach (array( "smbgroup"   => "sambaGroupType" ,"nagios_group" => "nagios_group") as $val => $aclname) {
+      foreach (array( "smbgroup"   => "sambaGroupType" ,"nagios_group" => "nagiosGroup") as $val => $aclname) {
         if ($this->acl_is_writeable($aclname)){
           if(isset($_POST["$val"])){
             $this->$val=  TRUE;
@@ -1097,6 +1155,31 @@ class group extends plugin
       }
       ksort($this->memberUid_used_by_some);
     }
+
+    $this->reload(TRUE);
+
+    // We've two lists in mutliple support  
+    //  - one which represents those users which are part of ALL groups.
+    //  - ond one which represents those users which are only part of SOME groups.
+    $this->commonList = new sortableListing();
+    $this->commonList->setDeleteable(true);
+    $this->commonList->setInstantDelete(true);
+    $this->commonList->setEditable(false);
+    $this->commonList->setWidth("100%");
+    $this->commonList->setHeight("120px");
+    $this->commonList->setHeader(array('~',_("Given name"),_("Surename"),_("Uid")));
+    $this->commonList->setColspecs(array('20px','*','*','*','20px'));
+    $this->commonList->setDefaultSortColumn(1);
+
+    $this->partialList = new sortableListing();
+    $this->partialList->setDeleteable(true);
+    $this->partialList->setInstantDelete(true);
+    $this->partialList->setEditable(false);
+    $this->partialList->setWidth("100%");
+    $this->partialList->setHeight("120px");
+    $this->partialList->setHeader(array('~',_("Given name"),_("Surename"),_("Uid")));
+    $this->partialList->setColspecs(array('20px','*','*','*','20px'));
+    $this->partialList->setDefaultSortColumn(1);
   }