Code

Added inherit all checkbox for ogroups with workstations
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 1 Oct 2009 12:53:25 +0000 (12:53 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 1 Oct 2009 12:53:25 +0000 (12:53 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14445 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/goto/admin/ogroups/goto/class_termgroup.inc
gosa-plugins/goto/admin/ogroups/goto/termgroup.tpl

index 53556ea08e0c5cec0c48f6e9849b4b3d06f0cb81..26175895ad85a0bc18173759e7ca20d966de96e4 100644 (file)
@@ -5,6 +5,9 @@ class termgroup extends plugin
   /* attribute list for save action */
   var $members= array();
 
+  /* Stores a list of the member dn's */
+  var $member_dn = array();
+
   var $gotoMode           = "locked";
   var $gotoSyslogServer   = "";
   var $gotoNtpServer      = array();
@@ -33,7 +36,7 @@ class termgroup extends plugin
   var $nfsservers     = array();
   var $swapservers    = array();
   var $member_of_ogroup= false;
-
+  var $members_inherit_from_group = false;
 
   function termgroup (&$config, $dn= NULL, $parent= NULL)
   {
@@ -61,6 +64,7 @@ class termgroup extends plugin
     if(isset($this->attrs['member'])){
       for ($i= 0; $i<$this->attrs['member']['count']; $i++){
         $member= $this->attrs['member'][$i];
+        array_push($this->member_dn, $member);
         $ldap->cat($member, array('objectClass', 'macAddress', 'cn'));
         if ($ldap->success()){
           $attrs = $ldap->fetch();
@@ -288,6 +292,7 @@ class termgroup extends plugin
 
 
     /* Show main page */
+    $smarty->assign("members_inherit_from_group", $this->members_inherit_from_group);
     return ($smarty->fetch (get_template_path('termgroup.tpl', TRUE, dirname(__FILE__))));
   }
 
@@ -297,6 +302,10 @@ class termgroup extends plugin
     plugin::save_object();  
     /* Set inherit mode */
     if(isset($_POST['workgeneric_posted'])){
+
+      /* Handle the inherit to members button */
+      $this->members_inherit_from_group = isset($_POST['members_inherit_from_group']);
+
       if(isset($_POST["inheritTimeServer"])){
         $this->inheritTimeServer = true;
       }else{
@@ -316,6 +325,9 @@ class termgroup extends plugin
 
     plugin::save();
 
+    /* Tell members to inherit all attributes if the flag is set  */
+    $this->inherit_attributes_to_members();
+
     /***************
       Prepare special vars 
      ***************/
@@ -384,6 +396,17 @@ class termgroup extends plugin
           ));
   }
 
+  function inherit_attributes_to_members()
+  {
+    if ($this->members_inherit_from_group) {
+      foreach ($this->member_dn as $dn) {
+        $member_obj = new worktabs($this->config, $this->config->data['TABS']['WORKTABS'], $dn);
+        $member_obj->by_object['workgeneric']->set_everything_to_inherited();
+        $member_obj->save();
+      }
+    }
+  }
+
   function PrepareForCopyPaste($source)
   {
     /* Create used ntp server array */
index af2d0a5d7484722fca129037fa7546633c838b27..dd103f91808eafe3f89af870de8015c0e12840d7 100644 (file)
 
                </td>
                <td style="vertical-align:top;border-left:1px solid #A0A0A0;">
-               <!-- Bottom right -->                   
+               <!-- Bottom right -->           
+
+    <input type='checkbox' value='1' {if $members_inherit_from_group} checked {/if} name='members_inherit_from_group'>&nbsp;
+{t}Inherit all values to group members{/t}
                </td>
        </tr>
 </table>