Code

Fixed generic/connectivity kolabAccount
[gosa.git] / plugins / personal / connectivity / class_pureftpdAccount.inc
index 66dc9faa6b119dfdd30de6998aaff2e99d0f9be0..1b189109b701482e074b92755341b53a96a730e6 100644 (file)
@@ -48,24 +48,31 @@ class pureftpdAccount extends plugin
       $smarty->assign("$val", $this->$val);
       $smarty->assign($val."ACL", chkacl($this->acl, "$val"));
     }
+    $smarty->assign("fstate", "");
     if ($this->is_account){
       $smarty->assign("pureftpdState", "checked");
       $smarty->assign("fstate", "");
     } else {
       $smarty->assign("pureftpdState", "");
-      $smarty->assign("fstate", "disabled");
+      if($_SESSION['js']==1){
+        if($this->acl!="#none#")
+        $smarty->assign("fstate", "disabled");
+      }else{
+        $smarty->assign("fstate", "");
+      }
     }
     $smarty->assign("use_FTPStatus", ($this->FTPStatus == "disabled") ? "checked" : "");
 
-    # Hickert, Added Else. Smarty have to know the variable in both cases
-    if ($this->parent != NULL){
-      $smarty->assign("tabbed", 1);
-    }else {
-      $smarty->assign("tabbed", 0);
-    }
-    
     $smarty->assign("pureftpdACL", chkacl($this->acl, 'pureftpd'));
 
+    $changeState = "";
+    foreach($this->attributes as $attr){
+      $smarty->assign($attr."ACL",chkacl($this->acl,$attr));
+      if(chkacl($this->acl,$attr)==""){
+        $changeState .= "changeState('".$attr."');\n";
+      }
+    }
+    $smarty->assign("changeState",$changeState);
     $display.= $smarty->fetch (get_template_path('pureftpd.tpl', TRUE, dirname(__FILE__)));
     return ($display);
   }
@@ -83,8 +90,10 @@ class pureftpdAccount extends plugin
     $ldap->cd($this->dn);
     @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,
         $this->attributes, "Save");
-    $ldap->modify($this->attrs);
-    show_ldap_error($ldap->get_error());
+    $this->cleanup();
+    $ldap->modify ($this->attrs); 
+
+    show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/pureftpd account with dn '%s' failed."),$this->dn));
 
     /* Optionally execute a command after we're done */
     $this->handle_post_events('remove');
@@ -120,23 +129,24 @@ class pureftpdAccount extends plugin
   /* Check values */
   function check()
   {
-    $message= array();
+    /* Call common method to give check the hook */
+    $message= plugin::check();
 
     /* Check for positive integer values */
     if ($this->is_account){
-      if (!is_id($this->FTPUploadBandwidth)){
+      if ((!is_id($this->FTPUploadBandwidth))&&(chkacl($this->acl,"FTPUploadBandwidth")=="")){
         $message[]= _("Value specified as 'Upload bandwidth' is not valid.");
       }
-      if (!is_id($this->FTPDownloadBandwidth)){
+      if ((!is_id($this->FTPDownloadBandwidth))&&(chkacl($this->acl,"FTPDownloadBandwidth")=="")){
         $message[]= _("Value specified as 'Download bandwidth' is not valid.");
       }
-      if (!is_id($this->FTPQuotaFiles)){
+      if ((!is_id($this->FTPQuotaFiles))&&(chkacl($this->acl,"FTPQuotaFiles")=="")){
         $message[]= _("Value specified as 'Files' is not valid.");
       }
-      if (!is_id($this->FTPQuotaMBytes)){
+      if ((!is_id($this->FTPQuotaMBytes))&&(chkacl($this->acl,"FTPQuotaMBytes")=="")){
         $message[]= _("Value specified as 'Size' is not valid.");
       }
-      if (!is_id($this->FTPUploadRatio) || !is_id($this->FTPDownloadRatio)){
+      if ((!is_id($this->FTPUploadRatio) || !is_id($this->FTPDownloadRatio))&&(chkacl($this->acl,"FTPUploadRatio")=="")&&(chkacl($this->acl,"FTPDownloadRatio")=="")){
         $message[]= _("Value specified as 'Ratio' is not valid.");
       }
     }
@@ -150,11 +160,19 @@ class pureftpdAccount extends plugin
   {
     plugin::save();
 
+    foreach($this->attributes as $attr){
+      if(chkacl($this->acl,$attr)!=""){
+        unset($this->attrs[$attr]);
+      }
+    }
+
     /* Write back to ldap */
     $ldap= $this->config->get_ldap_link();
     $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(), sprintf(_("Saving of user/pureftpd account with dn '%s' failed."),$this->dn));
 
     /* Optionally execute a command after we're done */
     if ($this->initially_was_account == $this->is_account){