Code

Commented out options in template
[gosa.git] / gosa-plugins / samba / personal / samba / class_sambaAccount.inc
index a7928ba6a1c2c4b894e480c523b11b30d6fcd841..f4bc82270023471aab8ec8ee9e769d0d7c4bb5d3 100644 (file)
@@ -24,28 +24,13 @@ class sambaAccount extends plugin
   var $plHeadline= "Samba";
   var $plDescription= "This does something";
   var $view_logged = FALSE;
+  var $password_expires= 0;
 
   /* Switch for Samba version */
   var $uidNumber= 65535;
   var $gidNumber= 65535;
 
-  /* Samba 2 attributes */
-  var $pwdLastSet= "0";
-  var $logonTime= "0";
-  var $logoffTime= "2147483647";
-  var $kickoffTime= "2147483647";
-  var $pwdCanChange= "0";
-  var $pwdMustChange= "0";
-  var $password_expires= 0;
-  var $acctFlags= "[UX        ]";
-  var $smbHome= "";
-  var $homeDrive= "";
-  var $scriptPath= "";
-  var $profilePath= "";
-  var $rid= "";
-  var $primaryGroupID= "";
-
-  /* Samba 3 attributes */
+  /* Samba attributes */
   var $SID= "";
   var $ridBase= 0;
   var $sambaSID= "";
@@ -73,7 +58,7 @@ class sambaAccount extends plugin
 
   /* Helper */
   var $cache = array();
-  var $show_ws_dialog= FALSE;
+  var $trustSelect= FALSE;
   var $logon_time_set= 0;
   var $logoff_time_set= 0;
   var $kickoff_time_set= 0;
@@ -322,102 +307,53 @@ class sambaAccount extends plugin
     /* Add user workstation? */
     if (isset($_POST["add_ws"])){
       if($this->acl_is_writeable("sambaUserWorkstations",$SkipWrite)){
-        $this->show_ws_dialog= TRUE;
+        $this->trustSelect= new trustSelect($this->config,get_userinfo());
         $this->dialog= TRUE;
       }
     }
 
     /* Add user workstation finished? */
     if (isset($_POST["add_ws_cancel"])){
-      $this->show_ws_dialog= FALSE;
+      $this->trustSelect= FALSE;
       $this->dialog= FALSE;
     }
 
-    /* Add user workstation? */
-    if (isset($_POST["add_ws_finish"])){
+    // Add selected machines to trusted ones.
+    if (isset($_POST["add_ws_finish"]) &&  $this->trustSelect){
+      $trusts = $this->trustSelect->detectPostActions();
+      if(isset($trusts['targets'])){
 
-      if (isset($_POST['wslist'])){
+        $headpage = $this->trustSelect->getHeadpage();
         if($this->multiple_support_active){
-          foreach($_POST['wslist'] as $ws){
+          foreach($trusts['targets'] as $id){
+            $attrs = $headpage->getEntry($id);
+            $we =$attrs['cn'][0];
             $this->multiple_sambaUserWorkstations[trim($we)] = array("Name" => trim($ws), "UsedByAllUsers" => TRUE);
           }
         }else{
+
           $tmp= $this->sambaUserWorkstations;
-          foreach($_POST['wslist'] as $ws){
-            $tmp.= ",$ws";
+          foreach($trusts['targets'] as $id){
+            $attrs = $headpage->getEntry($id);
+            $we =$attrs['cn'][0];
+            $tmp.= ",$we";
           }
           $tmp= preg_replace('/,+/', ',', $tmp);
           $this->sambaUserWorkstations= trim($tmp, ',');
         }
-        $this->is_modified= TRUE;
 
-        $this->show_ws_dialog= FALSE;
-        $this->dialog= FALSE;
-      } else {
-        msg_dialog::display(_("Error"), _("Please select an entry!"), ERROR_DIALOG);
+        $this->is_modified= TRUE;
       }
+      $this->trustSelect= NULL;
+      $this->dialog= FALSE;
     }
 
     /* Show ws dialog */
-    if ($this->show_ws_dialog){
-
-      /* Save data */
-      $sambafilter= session::get("sambafilter");
-      foreach( array("depselect", "regex") as $type){
-        if (isset($_POST[$type])){
-          $sambafilter[$type]= $_POST[$type];
-        }
-      }
-      if (isset($_GET['search'])){
-        $s= mb_substr($_GET['search'], 0, 1, "UTF8")."*";
-        if ($s == "**"){
-          $s= "*";
-        }
-        $sambafilter['regex']= $s;
-      }
-      session::set("sambafilter", $sambafilter);
+    if ($this->trustSelect){
 
-      /* Get workstation list */
-      $exclude= "";
-
-      if($this->multiple_support_active){
-        foreach($this->multiple_sambaUserWorkstations as $ws){
-          if($ws['UsedByAllUsers']){
-            $exclude.= "(cn=".$ws['Name']."$)";
-          }
-        }
-      }else{
-        foreach(split(',', $this->sambaUserWorkstations) as $ws){
-          $exclude.= "(cn=$ws$)";
-        }
-      }
-      if ($exclude != ""){
-        $exclude= "(!(|$exclude))";
-      }
-      $regex= $sambafilter['regex'];
-      $filter= "(&(objectClass=sambaSAMAccount)$exclude(uid=*$)(|(uid=$regex)(cn=$regex)))";
-      $res= get_list($filter, "winworkstation", $sambafilter['depselect'], array("uid"), GL_SUBSEARCH | GL_SIZELIMIT);
-        
-      $wslist= array();
-      foreach ($res as $attrs){
-        $wslist[]= preg_replace('/\$/', '', $attrs['uid'][0]);
-      }
-      asort($wslist);
-
-      $smarty->assign("search_image", get_template_path('images/lists/search.png'));
-      $smarty->assign("launchimage", get_template_path('images/lists/action.png'));
-      $smarty->assign("tree_image", get_template_path('images/lists/search-subtree.png'));
-      $smarty->assign("deplist", $this->config->idepartments);
-      $smarty->assign("alphabet", generate_alphabet());
-      foreach( array("depselect", "regex") as $type){
-        $smarty->assign("$type", $sambafilter[$type]);
-      }
-      $smarty->assign("hint", print_sizelimit_warning());
-      $smarty->assign("wslist", $wslist);
-      $smarty->assign("apply", apply_filter());
-      $display= $smarty->fetch (get_template_path('samba3_workstations.tpl', TRUE,
-                                dirname(__FILE__)));
-      return ($display);
+      // Build up blocklist
+      session::set('filterBlacklist', array('cn' => preg_split('/,/',$this->sambaUserWorkstations)));
+      return($this->trustSelect->execute());
     }
 
     /* Fill boxes */
@@ -502,7 +438,7 @@ class sambaAccount extends plugin
 
     
     /* Fill sambaUserWorkstations */
-    $ws= split(",", $this->sambaUserWorkstations);
+    $ws= explode(",", $this->sambaUserWorkstations);
     sort($ws);
     
     /* Tidy checks for empty option, and smarty will produce one if array[0]="" */
@@ -995,6 +931,14 @@ 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");
+    }
+
     /* Too many workstations? Windows usrmgr only supports eight */
     if (substr_count($this->sambaUserWorkstations, ",") >= 8){
       $message[]= _("The windows usermanager allows eight clients at maximum!");
@@ -1031,7 +975,6 @@ class sambaAccount extends plugin
         if ($this->$attrname != $tmp){
           $this->is_modified= TRUE;
         }
-        $this->pwdCanChange= $tmp;
         $this->sambaPwdCanChange= $tmp;
       }
       $tmp= "U";
@@ -1247,7 +1190,7 @@ class sambaAccount extends plugin
       if ($this->attrs['sambaPwdMustChange'] == ""){
         $this->attrs['sambaPwdMustChange']= 0;
       } else {
-        list($day, $month, $year)= split('\.', $this->sambaPwdMustChange);
+        list($day, $month, $year)= explode('.', $this->sambaPwdMustChange);
         $this->attrs['sambaPwdMustChange']= mktime(0,0,0,$month, $day, $year);
       }
     } else {
@@ -1276,7 +1219,7 @@ class sambaAccount extends plugin
       if ($this->attrs['sambaKickoffTime'] == ""){
         $this->attrs['sambaKickoffTime']= 2147483647;
       } else {
-        list($day, $month, $year)= split('\.', $this->sambaKickoffTime);
+        list($day, $month, $year)= explode('.', $this->sambaKickoffTime);
         $this->attrs['sambaKickoffTime']= mktime(0,0,0,$month, $day, $year);
       }
     } else {
@@ -1487,7 +1430,7 @@ class sambaAccount extends plugin
      *  Those workstations will be displayed in light grey.
      */
     $tmp2 = array("count" => 0);
-    $tmp = split(",", $this->sambaUserWorkstations);
+    $tmp = explode(",", $this->sambaUserWorkstations);
     foreach($tmp as $station){
       $station = trim($station);
       if(!empty($station)){
@@ -1598,7 +1541,6 @@ class sambaAccount extends plugin
     /* Flags */
     if(in_array("allow_pwchange",$this->multi_boxes)){
       $ret['sambaPwdCanChange'] = $this->sambaPwdCanChange;
-      $ret['pwdCanChange']      = $this->pwdCanChange;
     }
   
     if(in_array("password_expires",$this->multi_boxes)){
@@ -1653,7 +1595,7 @@ class sambaAccount extends plugin
 
       /* Prepare current settings to be merged */
       if(isset($this->sambaUserWorkstations)){
-        $ttmp = split(",",$this->sambaUserWorkstations);
+        $ttmp = explode(",",$this->sambaUserWorkstations);
         foreach($ttmp as $station){
           $station = trim($station);
           if(!empty($station)){
@@ -1712,7 +1654,6 @@ class sambaAccount extends plugin
 
   
     if(isset($values['sambaPwdCanChange']))  $this->sambaPwdCanChange  = $values['sambaPwdCanChange'];
-    if(isset($values['pwdCanChange']))       $this->pwdCanChange       = $values['pwdCanChange'];