Code

Fixed ogroup saving
[gosa.git] / plugins / personal / samba / class_sambaAccount.inc
index 5237cc925741d216367c3e692cc4b4b8335cc627..8a7f5ab8808efb015f70cd881be772f1c3e003dc 100644 (file)
@@ -58,7 +58,7 @@ class sambaAccount extends plugin
   var $sambaLogonTime= "0";
   var $sambaLogoffTime= "2147483647";
   var $sambaKickoffTime= "2147483647";
-  var $sambaPwdCanChange= "0";
+  var $sambaPwdCanChange= "";
   var $sambaPwdMustChange= "0";
   var $sambaAcctFlags= "[UX        ]";
   var $sambaHomePath= "";
@@ -87,7 +87,11 @@ class sambaAccount extends plugin
   var $attributes= array();
   var $objectclasses= array();
 
-  function sambaAccount ($config, $dn= NULL)
+  var $uid = "";
+
+  var $CopyPasteVars = array("kickoff_time_set","logoff_time_set","logon_time_set","mungedObject","orig_sambaDomainName");
+
+  function sambaAccount ($config, $dn= NULL, $parent= NULL)
   {
     /* Load attributes depending on the samba version */
     $this->samba3= ($config->current['SAMBAVERSION'] == 3);
@@ -111,14 +115,19 @@ class sambaAccount extends plugin
       $this->objectclasses= array ("sambaAccount");
     }
 
-    plugin::plugin ($config, $dn);
+    plugin::plugin ($config, $dn, $parent);
+
+    /* set user id */    
+    if(isset($this->attrs['uid'])){
+      $this->uid = $this->attrs['uid'][0];
+    }
 
     /* Get samba Domain in case of samba 3 */
     if ($this->samba3 && $this->sambaSID != ""){
       $this->SID= preg_replace ("/-[^-]+$/", "", $this->sambaSID);
       $ldap= $this->config->get_ldap_link();
       $ldap->cd($this->config->current['BASE']);
-      $ldap->search ("(&(objectClass=sambaDomain)(sambaSID=$this->SID))");
+      $ldap->search ("(&(objectClass=sambaDomain)(sambaSID=$this->SID))",array("sambaAlgorithmicRidBase","sambaDomainName"));
       if ($ldap->count() != 0){
         $attrs= $ldap->fetch();
         $this->ridBase= $attrs['sambaAlgorithmicRidBase'][0];
@@ -320,7 +329,7 @@ class sambaAccount extends plugin
       $acl= array($this->config->current['BASE'] => ":all");
       $regex= $sambafilter['regex'];
       $filter= "(&(objectClass=sambaSAMAccount)$exclude(uid=*$)(|(uid=$regex)(cn=$regex)))";
-      $res= get_list($acl, "$filter", TRUE, $sambafilter['depselect'], array("uid"), TRUE);
+      $res= get_list($filter, $acl, $sambafilter['depselect'], array("uid"), GL_SUBSEARCH | GL_SIZELIMIT);
       $wslist= array();
       foreach ($res as $attrs){
         $wslist[]= preg_replace('/\$/', '', $attrs['uid'][0]);
@@ -475,10 +484,15 @@ class sambaAccount extends plugin
       $smarty->assign("reconnmode", $this->mungedObject->getReConn());
       $smarty->assign("reconnACL", chkacl($this->acl,"reconn"));
 
-      /* Set form elements to disabled/enable state */
-      $smarty->assign("tsloginstate", $this->mungedObject->getTsLogin()?"":"disabled");
-      $smarty->assign("inheritstate", $this->mungedObject->getInheritMode()?"disabled":"");
-      
+      if($_SESSION['js']){
+        /* Set form elements to disabled/enable state */
+        $smarty->assign("tsloginstate", $this->mungedObject->getTsLogin()?"":"disabled");
+        $smarty->assign("inheritstate", $this->mungedObject->getInheritMode()?"disabled":"");
+      }else{
+        $smarty->assign("tsloginstate", "");
+        $smarty->assign("inheritstate", "");
+      }      
+
       /* Set checkboxes to checked or unchecked state */
       $smarty->assign("tslogin", $this->mungedObject->getTsLogin()?"checked":"");
       $smarty->assign("tsloginACL", chkacl($this->acl,"tslogin"));
@@ -614,18 +628,21 @@ class sambaAccount extends plugin
     @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,
         $this->attributes, "Save");
     $ldap->cd($this->dn);
-    $ldap->modify($this->attrs);
-    show_ldap_error($ldap->get_error());
+    $this->cleanup();
+    $ldap->modify ($this->attrs); 
+
+    show_ldap_error($ldap->get_error(), _("Removing Samba account failed"));
 
     /* Optionally execute a command after we're done */
-    $this->handle_post_events("remove");
+    $this->handle_post_events("remove",array("uid"=>$this->uid));
   }
 
 
   /* Check for input problems */
   function check()
   {
-    $message= array();
+    /* Call common method to give check the hook */
+    $message= plugin::check();
 
     if ($this->samba3){
 
@@ -814,7 +831,7 @@ class sambaAccount extends plugin
   {
     /* Load uid and gid of this 'dn' */
     $ldap= $this->config->get_ldap_link();
-    $ldap->cat($this->dn);
+    $ldap->cat($this->dn, array('uidNumber', 'gidNumber'));
     $tmp= $ldap->fetch();
     $this->uidNumber= $tmp['uidNumber'][0];
     $this->gidNumber= $tmp['gidNumber'][0];
@@ -855,8 +872,7 @@ class sambaAccount extends plugin
 
         /* Check for users primary group */
         $ldap->cd($this->config->current['BASE']);
-        $ldap->search("(&(objectClass=posixGroup)(gidNumber=".$this->gidNumber."))",
-                      array("cn"));
+        $ldap->search("(&(objectClass=posixGroup)(gidNumber=".$this->gidNumber."))", array("cn"));
         if ($ldap->count() != 1){
           print_red(_("Warning: Can't identify users primary group - no conversion to a samba group possible!"));
         } else {
@@ -959,16 +975,18 @@ class sambaAccount extends plugin
 
     /* Write back to ldap */
     $ldap->cd($this->dn);
-    $ldap->modify($this->attrs);
-    show_ldap_error($ldap->get_error());
+    $this->cleanup();
+    $ldap->modify ($this->attrs); 
+
+    show_ldap_error($ldap->get_error(), _("Saving Samba account failed"));
 
     /* Optionally execute a command after we're done */
     if ($this->initially_was_account == $this->is_account){
       if ($this->is_modified){
-        $this->handle_post_events("modify");
+        $this->handle_post_events("modify",array("uid" => $this->uid));
       }
     } else {
-      $this->handle_post_events("add");
+      $this->handle_post_events("add",array("uid" => $this>uid));
     }
 
   }