Code

Include personal title in cn/dn
[gosa.git] / plugins / personal / connectivity / class_pureftpdAccount.inc
index e2457b6651e2b3a501954a3f6683762f3d8b0d82..03f60b432c29d9b7285c610556468dba2ace041b 100644 (file)
@@ -22,18 +22,29 @@ class pureftpdAccount extends plugin
   var $FTPuid = "";
   var $FTPgid = "";
 
+  var $uid = "";
+
   /* attribute list for save action */
   var $attributes= array("FTPQuotaFiles","FTPQuotaMBytes","FTPUploadRatio","FTPDownloadRatio",
       "FTPUploadBandwidth","FTPDownloadBandwidth","FTPStatus","FTPuid","FTPgid");
   var $objectclasses= array("PureFTPdUser");
 
-  function pureftpdAccount ($config, $dn= NULL)
+  function pureftpdAccount ($config, $dn= NULL, $parent= NULL)
   {
-    plugin::plugin ($config, $dn);
+    plugin::plugin ($config, $dn, $parent);
+    
+    /* Setting uid to default */
+    if(isset($this->attrs['uid'][0])){
+      $this->uid = $this->attrs['uid'][0];
+    }
+
   }
 
   function execute()
   {
+         /* Call parent execute */
+       plugin::execute();
+
     /* Show tab dialog headers */
     $display= "";
 
@@ -45,19 +56,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" : "");
 
-    if ($this->parent != NULL){
-      $smarty->assign("tabbed", 1);
-    }
     $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);
   }
@@ -75,11 +98,13 @@ 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(), _("Removing pureftpd account failed"));
 
     /* Optionally execute a command after we're done */
-    $this->handle_post_events('remove');
+    $this->handle_post_events('remove',array("uid" => $this->uid));
   }
 
 
@@ -112,23 +137,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.");
       }
     }
@@ -142,19 +168,27 @@ 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(), _("Saving pureftpd 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("mofify");
+        $this->handle_post_events("modify",array("uid" => $this->uid));
       }
     } else {
-      $this->handle_post_events("add");
+      $this->handle_post_events("add",array("uid" => $this->uid));
     }
 
   }