Code

Added pureftpd acls
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 26 Jul 2006 07:51:07 +0000 (07:51 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 26 Jul 2006 07:51:07 +0000 (07:51 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@4305 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/personal/connectivity/class_pureftpdAccount.inc
plugins/personal/connectivity/pureftpd.tpl

index af13efb6a384e91ecb8f6ccfa7f5257f7d10ed2c..fe66e184f6f5d1cce71cd94b2c05f5926b919a56 100644 (file)
@@ -29,9 +29,6 @@ class pureftpdAccount extends plugin
 
   function execute()
   {
-       /* Call parent execute */
-//     plugin::execute();
-
     /* Show tab dialog headers */
     $display= "";
 
@@ -41,8 +38,23 @@ class pureftpdAccount extends plugin
     /* Load attributes */
     foreach($this->attributes as $val){
       $smarty->assign("$val", $this->$val);
-      $smarty->assign($val."ACL", chkacl($this->acl, "$val"));
     }
+
+
+    $tmp = $this->plInfo();
+    $changeState = "";
+    foreach($tmp['plProvidedAcls'] as $key => $desc){
+      $smarty->assign($key."ACL", $this->getacl($key));
+      $smarty->assign($key."_W", $this->acl_is_writeable($key));
+  
+      if($this->acl_is_writeable($key)){
+        echo "JOP";
+        $changeState.= " changeState('".$key."'); \n";
+      }
+    }
+    $smarty->assign("changeState",$changeState);
+
+
     $smarty->assign("fstate", "");
     if ($this->is_account){
       $smarty->assign("pureftpdState", "checked");
@@ -57,17 +69,13 @@ class pureftpdAccount extends plugin
       }
     }
     $smarty->assign("use_FTPStatus", ($this->FTPStatus == "disabled") ? "checked" : "");
-
-    $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";
-      }
+    
+    if(($this->is_account && $this->acl_is_removeable()) || (!$this->is_account && $this->acl_is_createable())) {
+      $smarty->assign('pureftpdACL', "");
+    }else{
+      $smarty->assign('pureftpdACL', " disabled ");
     }
-    $smarty->assign("changeState",$changeState);
+
     $display.= $smarty->fetch (get_template_path('pureftpd.tpl', TRUE, dirname(__FILE__)));
     return ($display);
   }
@@ -75,7 +83,7 @@ class pureftpdAccount extends plugin
   function remove_from_parent()
   {
     /* Cancel if there's nothing to do here */
-    if (!$this->initially_was_account){
+    if ((!$this->initially_was_account) || (!$this->acl_is_removeable())){
       return;
     }
 
@@ -129,20 +137,25 @@ class pureftpdAccount extends plugin
 
     /* Check for positive integer values */
     if ($this->is_account){
-      if ((!is_id($this->FTPUploadBandwidth))&&(chkacl($this->acl,"FTPUploadBandwidth")=="")){
+
+      if($this->acl_is_writeable("FTPUploadBandwidth") && !is_id($this->FTPUploadBandwidth)){
         $message[]= _("Value specified as 'Upload bandwidth' is not valid.");
       }
-      if ((!is_id($this->FTPDownloadBandwidth))&&(chkacl($this->acl,"FTPDownloadBandwidth")=="")){
+      if($this->acl_is_writeable("FTPDownloadBandwidth") && !is_id($this->FTPDownloadBandwidth)){
         $message[]= _("Value specified as 'Download bandwidth' is not valid.");
       }
-      if ((!is_id($this->FTPQuotaFiles))&&(chkacl($this->acl,"FTPQuotaFiles")=="")){
+
+      if($this->acl_is_writeable("FTPQuotaFiles") && !is_id($this->FTPQuotaFiles)){
         $message[]= _("Value specified as 'Files' is not valid.");
       }
-      if ((!is_id($this->FTPQuotaMBytes))&&(chkacl($this->acl,"FTPQuotaMBytes")=="")){
+      if($this->acl_is_writeable("FTPQuotaMBytes") && !is_id($this->FTPQuotaMBytes)){
         $message[]= _("Value specified as 'Size' is not valid.");
       }
-      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.");
+      if($this->acl_is_writeable("FTPUploadRatio") && !is_id($this->FTPUploadRatio)){
+        $message[]= _("Value specified as 'Upload ratio' is not valid.");
+      }
+      if($this->acl_is_writeable("FTPDownloadRatio") && !is_id($this->FTPDownloadRatio)){
+        $message[]= _("Value specified as 'Download ratio' is not valid.");
       }
     }
 
@@ -155,9 +168,10 @@ class pureftpdAccount extends plugin
   {
     plugin::save();
 
-    foreach($this->attributes as $attr){
-      if(chkacl($this->acl,$attr)!=""){
-        unset($this->attrs[$attr]);
+    $tmp = $this->plInfo();
+    foreach($tmp['plProvidedAcls'] as $key => $desc){
+      if(!$this->acl_is_writeable($key)){
+        unset($this->attrs[$key]);
       }
     }
 
@@ -189,10 +203,10 @@ class pureftpdAccount extends plugin
           "plShortName"     => _("Ftp"),
           "plDescription"   => _("Pure ftp account"),
           "plSelfModify"    => TRUE,
-          "plDepends"       => array("connectivity"),
+          "plDepends"       => array("user"),
           "plPriority"      => 8,                                 // Position in tabs
           "plSection"       => "personal",                        // This belongs to personal
-          "plCategory"      => array("gosaAccount"),
+          "plCategory"      => array("users"),
           "plOptions"       => array(),
 
           "plProvidedAcls"  => array(
index 2dc1ca313cfa8170b5ff50125498f2e5867b61c6..4fed279f39e72b6b80a809203dfdbad49e4ef38c 100644 (file)
        </tr>
        <tr>
          <td>{t}Upload bandwidth{/t}</td>
-        <td><input name="FTPUploadBandwidth" id="FTPUploadBandwidth" size=7 maxlength=7 {$FTPUploadBandwidthACL} value="{$FTPUploadBandwidth}" {$fstate}> {t}kb/s{/t}</td>
+        <td>
+{render acl=$FTPUploadBandwidthACL}
+<input name="FTPUploadBandwidth" id="FTPUploadBandwidth" size=7 maxlength=7 value="{$FTPUploadBandwidth}" {$fstate}>
+{/render}
+        {t}kb/s{/t}</td>
        </tr>
        <tr>
          <td>{t}Download bandwidth{/t}</td>
-        <td><input name="FTPDownloadBandwidth" id="FTPDownloadBandwidth" size=7 maxlength=7 {$FTPDownloadBandwidthACL} value="{$FTPDownloadBandwidth}" {$fstate}> {t}kb/s{/t}</td>
+        <td>
+{render acl=$FTPDownloadBandwidthACL}
+<input name="FTPDownloadBandwidth" id="FTPDownloadBandwidth" size=7 maxlength=7 value="{$FTPDownloadBandwidth}" {$fstate}>
+{/render}
+        {t}kb/s{/t}</td>
        </tr>
      </table>
    </td>
        </tr>
        <tr>
          <td>{t}Files{/t}</td>
-        <td><input name="FTPQuotaFiles" id="FTPQuotaFiles" size=7 maxlength=10 {$FTPQuotaFilesACL} value="{$FTPQuotaFiles}" {$fstate}></td>
+        <td>
+{render acl=$FTPQuotaFilesACL}
+<input name="FTPQuotaFiles" id="FTPQuotaFiles" size=7 maxlength=10 value="{$FTPQuotaFiles}" {$fstate}>
+{/render}
+       </td>
        </tr>
        <tr>
          <td>{t}Size{/t}</td>
-        <td><input name="FTPQuotaMBytes" id="FTPQuotaMBytes" size=7 maxlength=10 {$FTPQuotaMBytesACL} value="{$FTPQuotaMBytes}" {$fstate}> {t}MB{/t}</td>
+        <td>
+{render acl=$FTPQuotaMBytesACL}
+<input name="FTPQuotaMBytes" id="FTPQuotaMBytes" size=7 maxlength=10 value="{$FTPQuotaMBytes}" {$fstate}> 
+{/render}
+       {t}MB{/t}
+       </td>
        </tr>
      </table>
    </td>
        </tr>
        <tr>
          <td>{t}Uploaded / downloaded files{/t}</td>
-        <td><input name="FTPUploadRatio" id="FTPUploadRatio" size=5 maxlength=20 {$FTPUploadRatioACL} value="{$FTPUploadRatio}" {$fstate}>
-        / <input name="FTPDownloadRatio" id="FTPDownloadRatio" size=5 maxlength=20 {$FTPDownloadRatioACL} value="{$FTPDownloadRatio}" {$fstate}></td>
+        <td>
+
+{render acl=$FTPUploadRatioACL}
+<input name="FTPUploadRatio" id="FTPUploadRatio" size=5 maxlength=20 value="{$FTPUploadRatio}" {$fstate}>
+{/render}
+        / 
+{render acl=$FTPDownloadRatioACL}
+<input name="FTPDownloadRatio" id="FTPDownloadRatio" size=5 maxlength=20 value="{$FTPDownloadRatio}" {$fstate}>
+{/render}
+       </td>
        </tr>
      </table>
    </td>
            <b>{t}Miscellaneous{/t}</b>
          </td>
        <tr>
-         <td><input type=checkbox name="FTPStatus" id="FTPStatus" value="disabled" {$use_FTPStatus} {$FTPStatusACL} title="{t}Check to disable FTP Access{/t}" {$fstate}>{t}Temporary disable FTP access{/t}</td>
+         <td>
+{render acl=$FTPStatusACL}
+<input type=checkbox name="FTPStatus" id="FTPStatus" value="disabled" {$use_FTPStatus} title="{t}Check to disable FTP Access{/t}" {$fstate}>
+{/render}
+{t}Temporary disable FTP access{/t}</td>
        </tr>
      </table>
    </td>