Code

Made connectivity kolabAccount compatible with new acls
[gosa.git] / plugins / personal / connectivity / class_pureftpdAccount.inc
index 66dc9faa6b119dfdd30de6998aaff2e99d0f9be0..af13efb6a384e91ecb8f6ccfa7f5257f7d10ed2c 100644 (file)
@@ -6,11 +6,6 @@ class pureftpdAccount extends plugin
   var $plHeadline= "FTP";
   var $plDescription= "This does something";
 
-  /* CLI vars */
-  var $cli_summary= "Manage users ftp account";
-  var $cli_description= "Some longer text\nfor help";
-  var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
-
   /* FTP attributes */
   var $FTPQuotaFiles = 0;
   var $FTPQuotaMBytes = 0;
@@ -48,24 +43,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 +85,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 +124,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 +155,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){
@@ -167,6 +180,31 @@ class pureftpdAccount extends plugin
 
   }
 
+
+  /* Return plugin informations for acl handling
+  #FIME There possibly some attributes that can be combined to one acl. */
+  function plInfo()
+  {
+    return (array(
+          "plShortName"     => _("Ftp"),
+          "plDescription"   => _("Pure ftp account"),
+          "plSelfModify"    => TRUE,
+          "plDepends"       => array("connectivity"),
+          "plPriority"      => 8,                                 // Position in tabs
+          "plSection"       => "personal",                        // This belongs to personal
+          "plCategory"      => array("gosaAccount"),
+          "plOptions"       => array(),
+
+          "plProvidedAcls"  => array(
+            "FTPQuotaFiles"         => "!!! FIXME "._("Quota files"),
+            "FTPUploadRatio"        => _("Upload ratio"),
+            "FTPQuotaMBytes"        => _("Quota MBytes"),
+            "FTPDownloadRatio"      => _("Download ratio"),
+            "FTPUploadBandwidth"    => _("Upload bandwith"),
+            "FTPDownloadBandwidth"  => _("Download bandwith"),
+            "FTPStatus"             => _("Status"))
+          ));
+  }
 }
 
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: