Code

Updated SambaAccount
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 7 Jul 2010 11:39:11 +0000 (11:39 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 7 Jul 2010 11:39:11 +0000 (11:39 +0000)
-Removed old and unused code
-Added force password change option

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@18950 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/samba/personal/samba/class_sambaAccount.inc
gosa-plugins/samba/personal/samba/samba3.tpl

index 47c55760be6bb67ed72c538bd0628bd3e1fc2033..59718f66a83421a19db064a93761c6155c24e348 100644 (file)
@@ -35,9 +35,6 @@ class sambaAccount extends plugin
   var $ridBase= 0;
   var $sambaSID= "";
   var $sambaPwdLastSet= "0";
-  var $sambaLogonTime= "0";
-  var $sambaLogoffTime= "2147483647";
-  var $sambaKickoffTime= "2147483647";
   var $sambaPwdCanChange= "";
   var $sambaPwdMustChange= "0";
   var $sambaAcctFlags= "[UX        ]";
@@ -59,14 +56,10 @@ class sambaAccount extends plugin
   /* Helper */
   var $cache = array();
   var $trustSelect= FALSE;
-  var $logon_time_set= 0;
-  var $logoff_time_set= 0;
-  var $kickoff_time_set= 0;
 
   /* attribute list for save action */
   var $ctxattributes= array();
-  var $attributes= array("sambaSID", "sambaPwdLastSet", "sambaLogonTime",
-        "sambaLogoffTime", "sambaKickoffTime", "sambaPwdCanChange",
+  var $attributes= array("sambaSID", "sambaPwdLastSet", "sambaPwdCanChange",
         "sambaPwdMustChange", "sambaAcctFlags", "uid", "sambaMungedDial",
         "sambaHomePath", "sambaHomeDrive", "sambaLogonScript",
         "sambaProfilePath", "sambaPrimaryGroupSID", "sambaDomainName",
@@ -76,7 +69,7 @@ class sambaAccount extends plugin
   var $objectclasses= array('sambaSamAccount');
   
   var $uid= "";
-  var $CopyPasteVars = array("kickoff_time_set","logoff_time_set","logon_time_set","mungedObject","orig_sambaDomainName");
+  var $CopyPasteVars = array("mungedObject","orig_sambaDomainName",'enforcePasswordChange');
 
   var $multiple_support = TRUE;
 
@@ -139,35 +132,10 @@ class sambaAccount extends plugin
       $this->password_expires= 1;
     }
 
-    if(isset($this->attrs['sambaLogonTime']) && ! (
-        $this->attrs['sambaLogonTime'][0] == 0 ||
-        $this->attrs['sambaLogonTime'][0] == 2147483647
-      )){
-      $this->logon_time_set= 1;
-    }
-    if(isset($this->attrs['sambaLogoffTime']) && ! (
-        $this->attrs['sambaLogoffTime'][0] == 0 ||
-        $this->attrs['sambaLogoffTime'][0] == 2147483647
-      )){
-      $this->logoff_time_set= 1;
-    }
-    
-    /* Account expiery */
-    if(isset($this->attrs['sambaKickoffTime']) && ! (
-        $this->attrs['sambaKickoffTime'][0] == 0 ||
-        $this->attrs['sambaKickoffTime'][0] == 2147483647
-      )){
-      $this->kickoff_time_set= 1;
-    }
-
     /* Save initial account state */
     $this->initially_was_account= $this->is_account;
 
-    /* Convert kickoff */
-    #TODO: use date format
-    $this->sambaKickoffTime= $this->sambaKickoffTime == 0?"":date('d.m.Y', $this->sambaKickoffTime);
     $this->sambaPwdMustChange= $this->sambaPwdMustChange == 2147483647?"":date('d.m.Y', $this->sambaPwdMustChange);
-
    
     // Enforce password change?
     // ------------------------ 
@@ -265,18 +233,6 @@ class sambaAccount extends plugin
       $smarty->assign("sambaLogonHoursACL","");
     }
 
-    if ($this->sambaLogonTime=="2147483647" || $this->sambaLogonTime=="0"){
-      $sambaLogonTime_date= getdate();
-    } else {
-      $sambaLogonTime_date= getdate($this->sambaLogonTime);
-    }
-    
-    if ($this->sambaLogoffTime=="2147483647" || $this->sambaLogoffTime=="0"){
-      $sambaLogoffTime_date= getdate();
-    } else {
-      $sambaLogoffTime_date= getdate($this->sambaLogoffTime);
-    }
-    
     /* Remove user workstations? */
     if (isset($_POST["delete_ws"]) && isset($_POST['workstation_list'])){
 
@@ -486,21 +442,6 @@ class sambaAccount extends plugin
     } else {
       $smarty->assign("flagsC", "");
     }
-    if ($this->logon_time_set=="1"){
-      $smarty->assign("flagsT", "checked");
-    } else {
-      $smarty->assign("flagsT", "");
-    }
-    if ($this->logoff_time_set=="1"){
-      $smarty->assign("flagsO", "checked");
-    } else {
-      $smarty->assign("flagsO", "");
-    }
-    if ($this->kickoff_time_set=="1"){
-      $smarty->assign("flagsK", "checked");
-    } else {
-      $smarty->assign("flagsK", "");
-    }
    
 
     /* In case of javascript, disable some fields on demand */
@@ -521,7 +462,7 @@ class sambaAccount extends plugin
           "CtxMaxDisconnectionTime","CtxMaxIdleTimeF","CtxMaxIdleTime","connectclientdrives",
           "onnectclientprinters","defaultprinter","shadow","brokenconn",
           "reconn","allow_pwchange","connectclientprinters","no_expiry","no_password_required","temporary_disable", 
-          "password_expires","logon_time_set","logoff_time_set","kickoff_time_set","SetSambaLogonHours",
+          "password_expires","SetSambaLogonHours",
           "workstation_list", "enforcePasswordChange") as $attr){
       if(in_array($attr,$this->multi_boxes)){
         $smarty->assign("use_".$attr,TRUE);
@@ -663,12 +604,8 @@ class sambaAccount extends plugin
         $sambaPwdMustChange= date('d.m.Y', $sambaPwdMustChange);
       }
     }
-    if($this->kickoff_time_set){
-      $sambaKickoffTime = $this->sambaKickoffTime;
-    } else {
-      if (is_numeric($sambaKickoffTime)) {
-        $sambaKickoffTime= date('d.m.Y', $sambaKickoffTime);
-      }
+    if($this->attrs['sambaKickoffTime']){
+      $sambaKickoffTime = date('d.m.Y', $this->attrs['sambaKickoffTime'][0]);
     }
     $sambaPwdCanChange = $this->sambaPwdCanChange;
 
@@ -936,10 +873,6 @@ class sambaAccount extends plugin
       }
     }
 
-    /* Check dates */
-    if (!tests::is_date($this->sambaKickoffTime)){
-      $message[]= msgPool::invalid(_("Account expires after"), $this->sambaKickoffTime,"" ,"23.02.2009");
-    }
     if (!tests::is_date($this->sambaPwdMustChange)){
       $message[]= msgPool::invalid(_("Password expires on"), $this->sambaPwdMustChange,"" ,"23.02.2009");
     }
@@ -1017,27 +950,6 @@ class sambaAccount extends plugin
           }
         }
       }
-      if (isset($_POST["logon_time_set"])){
-        if ($_POST["logon_time_set"] == 1){
-          $this->logon_time_set= 1;
-        }
-      } else {
-        $this->logon_time_set= 0;
-      }
-      if (isset($_POST["logoff_time_set"])){
-        if ($_POST["logoff_time_set"] == 1){
-          $this->logoff_time_set= 1;
-        }
-      } else {
-        $this->logoff_time_set= 0;
-      }
-      if (isset($_POST["kickoff_time_set"])){
-        if ($_POST["kickoff_time_set"] == 1){
-          $this->kickoff_time_set= 1;
-        }
-      } else {
-        $this->kickoff_time_set= 0;
-      }
       
       $fill= "";
       for ($i= strlen($tmp); $i<12; $i++){
@@ -1212,29 +1124,6 @@ class sambaAccount extends plugin
     } else {
       $this->attrs['sambaPwdMustChange']= array();
     }
-    /* Account expiery */
-    if ($this->logon_time_set == "1"){
-      $this->attrs['sambaLogonTime']= $this->sambaLogonTime;
-    } else {
-      $this->attrs['sambaLogonTime']= array();
-    }
-    if ($this->logoff_time_set == "1"){
-      $this->attrs['sambaLogoffTime']= $this->sambaLogoffTime;
-    } else {
-      $this->attrs['sambaLogoffTime']= array();
-    }
-    if ($this->kickoff_time_set == "1"){
-      /* Adapt values to be timestamps */
-      #TODO: check for date format
-      if ($this->attrs['sambaKickoffTime'] == ""){
-        $this->attrs['sambaKickoffTime']= 2147483647;
-      } else {
-        list($day, $month, $year)= explode('.', $this->sambaKickoffTime);
-        $this->attrs['sambaKickoffTime']= mktime(0,0,0,$month, $day, $year);
-      }
-    } else {
-      $this->attrs['sambaKickoffTime']= array();
-    }
 
     /* Write back to ldap */
     $ldap->cd($this->dn);
@@ -1308,35 +1197,6 @@ class sambaAccount extends plugin
         $this->attrs['sambaPwdMustChange'][0] != 0 && !in_array('sambaPwdMustChange', $skip)){
       $this->password_expires= 1;
     }
-
-    if(isset($this->attrs['sambaLogonTime']) && ! (
-        $this->attrs['sambaLogonTime'][0] == 0 ||
-        $this->attrs['sambaLogonTime'][0] == 2147483647
-      ) && !in_array('sambaLogonTime', $skip)){
-      $this->logon_time_set= 1;
-    }
-    if(isset($this->attrs['sambaLogoffTime']) && ! (
-        $this->attrs['sambaLogoffTime'][0] == 0 ||
-        $this->attrs['sambaLogoffTime'][0] == 2147483647
-      ) && !in_array('sambaLogonTime', $skip)){
-      $this->logoff_time_set= 1;
-    }
-
-    /* Account expiery */
-    if(isset($this->attrs['sambaKickoffTime']) && ! (
-        $this->attrs['sambaKickoffTime'][0] == 0 ||
-        $this->attrs['sambaKickoffTime'][0] == 2147483647
-      ) && !in_array('sambaKickoffTime', $skip)){
-      $this->kickoff_time_set= 1;
-    }
-
-    /* Get global filter config */
-    if (!session::is_set("sambafilter")){
-      $ui= get_userinfo();
-      $base= get_base_from_people($ui->dn);
-      $sambafilter= array( "depselect" => $base, "regex" => "*");
-      session::set("sambafilter", $sambafilter);
-    }
   }
 
   
@@ -1371,10 +1231,6 @@ class sambaAccount extends plugin
             "sambaAcctFlagsX"             => _("Password never expires"),
             "enforcePasswordChange"       => _("Enforce password change"),
             "sambaAcctFlagsL"             => _("Lock samba account"),
-            "sambaKickoffTime"            => _("Account expires") ,
-            "sambaPwdMustChange"          => _("Password expires") ,
-            "sambaLogonTime"              => _("Limit Logon Time") ,
-            "sambaLogoffTime"             => _("Limit Logoff Time") ,
             "sambaLogonHours"             => _("Logon hours") ,
             "sambaUserWorkstations"       => _("Allow connection from"))
           ));
@@ -1396,7 +1252,7 @@ class sambaAccount extends plugin
             "CtxMaxDisconnectionTime","CtxMaxIdleTimeF","CtxMaxIdleTime","connectclientdrives",
             "onnectclientprinters","defaultprinter","shadow","brokenconn",
             "reconn","allow_pwchange","connectclientprinters","no_expiry","no_password_required","temporary_disable",
-            "password_expires","logon_time_set","logoff_time_set","kickoff_time_set","SetSambaLogonHours",
+            "password_expires", "SetSambaLogonHours",
             "workstation_list", "enforcePasswordChange") as $attr){
         if(isset($_POST["use_".$attr])){
           $this->multi_boxes[] = $attr;
@@ -1567,18 +1423,6 @@ class sambaAccount extends plugin
       $ret['password_expires']  = $this->password_expires;
       $ret['sambaPwdMustChange']= $this->sambaPwdMustChange;
     }
-    if(in_array("logon_time_set",$this->multi_boxes)){
-      $ret['logon_time_set'] = $this->logon_time_set;
-      $ret['sambaLogonTime'] = $this->sambaLogonTime;
-    }
-    if(in_array("logoff_time_set",$this->multi_boxes)){
-      $ret['logoff_time_set'] = $this->logoff_time_set;
-      $ret['sambaLogoffTime'] = $this->sambaLogoffTime;
-    }
-    if(in_array("kickoff_time_set",$this->multi_boxes)){
-      $ret['kickoff_time_set'] = $this->kickoff_time_set;
-      $ret['sambaKickoffTime'] = $this->sambaKickoffTime;
-    }
 
     if(in_array("no_password_required",$this->multi_boxes)){
       $ret['no_password_required'] = $this->no_password_required;
@@ -1682,18 +1526,6 @@ class sambaAccount extends plugin
       $this->password_expires = $values['password_expires'];
       $this->sambaPwdMustChange = $values['sambaPwdMustChange'];
     }
-    if(isset($values['logon_time_set'])){
-      $this->logon_time_set = $values['logon_time_set'];
-      $this->sambaLogonTime = $values['sambaLogonTime'];
-    }
-    if(isset($values['logoff_time_set'])){
-      $this->logoff_time_set = $values['logoff_time_set'];
-      $this->sambaLogoffTime = $values['sambaLogoffTime'];
-    }
-    if(isset($values['kickoff_time_set'])){
-      $this->kickoff_time_set = $values['kickoff_time_set'];
-      $this->sambaKickoffTime = $values['sambaKickoffTime'];
-    }
 
     if(isset($values['no_password_required'])){
       if($values['no_password_required']){
@@ -1746,34 +1578,7 @@ class sambaAccount extends plugin
             $source['sambaPwdMustChange'][0] != 0){
         $this->password_expires= 1;
     }
-
-    if(isset($source['sambaLogonTime']) && ! (
-                $source['sambaLogonTime'][0] == 0 ||
-                $source['sambaLogonTime'][0] == 2147483647
-                )){
-        $this->logon_time_set= 1;
-    }
-    if(isset($source['sambaLogoffTime']) && ! (
-                $source['sambaLogoffTime'][0] == 0 ||
-                $source['sambaLogoffTime'][0] == 2147483647
-                )){
-        $this->logoff_time_set= 1;
-    }
-
-    /* Account expiery */
-    if(isset($source['sambaKickoffTime']) && ! (
-                $source['sambaKickoffTime'][0] == 0 ||
-                $source['sambaKickoffTime'][0] == 2147483647
-                )){
-        $this->kickoff_time_set= 1;
-    }
-
-
-    if(isset($source['sambaKickoffTime'][0])){
-        $this->sambaKickoffTime = date('d.m.Y', $source['sambaKickoffTime'][0]); 
-    }
   }
-
 }
 
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
index 8e7f862809362e1b55fb227db96fe0213fb9bcba..c54159016f9084106e5e61bd4d809a5ce7df55b7 100644 (file)
         </tr>
         <tr>
             <td>
-                
+                {render acl=$sambaAcctFlagsXACL  checkbox=$multiple_support checked=$use_no_expiry}
+                 <input id="no_expiry" type=checkbox name="no_expiry" value="1" {$flagsX} class="center">
+                {/render}
+            </td>
+            <td>
+                <label for="no_expiry">{t}The password never expires{/t}</label>
+            </td>
+        </tr>            
+        <tr>
+            <td>
+                {render acl=$sambaAcctFlagsNACL  checkbox=$multiple_support checked=$use_no_password_required}
+                 <input id="no_password_required" type=checkbox name="no_password_required" value="1" {$flagsN} class="center">
+                {/render}
+            </td>
+            <td>
+                <label for="no_password_required">{t}Login from windows client requires no password{/t}</label>
+            </td>
+        </tr>            
+        <tr>
+            <td>
+                {render acl=$sambaAcctFlagsLACL  checkbox=$multiple_support checked=$use_temporary_disable}
+                 <input id="temporary_disable" type=checkbox name="temporary_disable" value="1" {$flagsD} class="center">
+                {/render}
+            </td>
+            <td>
+                <label for="temporary_disable">{t}Lock samba account{/t}</label>
+            </td>
+        </tr>            
+        <tr>
+            <td>
+            </td>
+            <td>
+                {if $additional_info_PwdMustChange}
+                    <i>({$additional_info_PwdMustChange})</i>
+                {/if}
+            </td>
+        </tr>            
     </table>
 
+    <hr>
 
-   <div>
-    <div style='float:left;'>
-      {render acl=$sambaAcctFlagsXACL  checkbox=$multiple_support checked=$use_no_expiry}
-       <input id="no_expiry" type=checkbox name="no_expiry" value="1" {$flagsX} class="center">
-      {/render}
-    </div>
-    <div style='margin-left:25px;'>
-      <label for="no_expiry">{t}The password never expires{/t}</label>
-    </div>
-   </div>
-   <div class='clear'></div> 
-
-   <div>
-    <div style='float:left;'>
-      {render acl=$sambaAcctFlagsNACL  checkbox=$multiple_support checked=$use_no_password_required}
-       <input id="no_password_required" type=checkbox name="no_password_required" value="1" {$flagsN} class="center">
-      {/render}
-    </div>
-    <div style='margin-left:25px;'>
-      <label for="no_password_required">{t}Login from windows client requires no password{/t}</label>
-    </div>
-   </div>
-   <div class='clear'></div> 
-
-   <div>
-    <div style='float:left;'>
-      {render acl=$sambaAcctFlagsLACL  checkbox=$multiple_support checked=$use_temporary_disable}
-       <input id="temporary_disable" type=checkbox name="temporary_disable" value="1" {$flagsD} class="center">
-      {/render}
-    </div>
-    <div style='margin-left:25px;'>
-      <label for="temporary_disable">{t}Lock samba account{/t}</label>
-    </div>
-   </div>
-   <div class='clear'></div> 
-
-<!--
-    <tr>
-     <td>
-      {render acl=$sambaPwdMustChangeACL  checkbox=$multiple_support checked=$use_password_expires}
-      <input id="password_expires" type=checkbox name="password_expires" value="1" {$flagsC} class="center"
-               onClick="document.mainform.submit();">
-      {/render}
-      <label for="password_expires">{t}Password expires on{/t}</label>
-     </td>
-     <td style='width:55%'>
-      {render acl=$sambaPwdMustChangeACL}
-        <input type="text" id="sambaPwdMustChange" name="sambaPwdMustChange" class="date" style='width:100px' value="{$sambaPwdMustChange}">
-        {if $sambaPwdMustChangeACL|regex_replace:"/[cdmr]/":"" == "w"}
-        <script type="text/javascript">
-          {literal}
-          var datepicker  = new DatePicker({ relative : 'sambaPwdMustChange', language : '{/literal}{$lang}{literal}', keepFieldEmpty : true, enableCloseEffect : false, enableShowEffect : false });
-          {/literal}
-        </script>
-        {/if}
-      {/render}
-     </td>
-    </tr>
-  -->
-
-   <div>
-    <div style='float:left;'>
-    </div>
-    <div style='margin-left:25px;'>
-      {if $additional_info_PwdMustChange}
-        <i>({$additional_info_PwdMustChange})</i>
-      {/if}
-    </div>
-   </div>
-   <div class='clear'></div> 
-
-   <div>
-    <div style='float:left;'>
-      {render acl=$sambaKickoffTimeACL  checkbox=$multiple_support checked=$use_kickoff_time_set}
-       <input id="kickoff_time_set" type=checkbox name="kickoff_time_set" value="1" {$flagsK} class="center">
-      {/render}
-    </div>
-    <div style='margin-left:25px;'>
-
-      <table summary="{t}Account expiration settings{/t}"><tr><td>
-      <label for="kickoff_time_set">{t}Account expires after{/t}</label>
-      </td><td style='width:200px'>
-      {render acl=$sambaKickoffTimeACL}
-        <input type="text" id="sambaKickoffTime" name="sambaKickoffTime" class="date" style='width:100px' value="{$sambaKickoffTime}">
-        {if $sambaKickoffTimeACL|regex_replace:"/[cdmr]/":"" == "w"}
-        <script type="text/javascript">
-          {literal}
-          var datepicker2 = new DatePicker({ relative : 'sambaKickoffTime', language : '{/literal}{$lang}{literal}', keepFieldEmpty : true, enableCloseEffect : false, enableShowEffect : false });
-          {/literal}
-        </script>
-        {/if}
-      {/render}
-      </td></tr></table>  
-    </div>
-   </div>
-   <div class='clear'></div> 
-
-      {render acl=$sambaLogonHoursACL mode=read_active  checkbox=$multiple_support checked=$use_SetSambaLogonHours}
-       {t}Samba logon times{/t}&nbsp;<button type='submit' name='SetSambaLogonHours'>{t}Edit settings...{/t}</button>
-
-      {/render}
-   <!-- /Samba policies -->
+    {render acl=$sambaLogonHoursACL mode=read_active  checkbox=$multiple_support checked=$use_SetSambaLogonHours}
+        {t}Samba logon times{/t}&nbsp;<button type='submit' name='SetSambaLogonHours'>{t}Edit settings...{/t}</button>
+    {/render}
+    <!-- /Samba policies -->
 
   </td>
   <td class='left-border'>