Code

Added pureftpd multiple edit
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 20 Dec 2007 13:55:43 +0000 (13:55 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 20 Dec 2007 13:55:43 +0000 (13:55 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8159 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/include/class_plugin.inc
gosa-core/plugins/personal/connectivity/class_pureftpdAccount.inc
gosa-core/plugins/personal/connectivity/pureftpd.tpl

index ceb49f2bf1b56ab94df65b0e4b74b94b21d2739d..fea28591a191eb8a638346544e88869678138171 100644 (file)
@@ -1775,11 +1775,13 @@ class plugin
     /* Save values to object */
     $this->multi_boxes = array();
     foreach ($this->attributes as $val){
-      if ($this->acl_is_writeable($val) && isset ($_POST["$val"])){
+  
+      /* Get selected checkboxes from multiple edit */
+      if(isset($_POST["use_".$val])){
+        $this->multi_boxes[] = $val;
+      }
 
-        if(isset($_POST["use_".$val])){
-          $this->multi_boxes[] = $val;
-        }
+      if ($this->acl_is_writeable($val) && isset ($_POST["$val"])){
 
         /* Check for modifications */
         if (get_magic_quotes_gpc()) {
index 68de2e881ddc885b734204660a79472a92888c7e..04474ae70c2a14552ec19d0bd6eb8d2e138284ce 100644 (file)
@@ -26,6 +26,8 @@ class pureftpdAccount extends plugin
   var $ReadOnly;
   var $view_logged = FALSE;
 
+  var $multiple_support=TRUE;
+
   function pureftpdAccount (&$config, $dn= NULL, $parent= NULL)
   {
     plugin::plugin ($config, $dn, $parent);
@@ -58,38 +60,58 @@ class pureftpdAccount extends plugin
 
     $tmp = $this->plInfo();
     $changeState = "";
-    foreach($tmp['plProvidedAcls'] as $key => $desc){
-      $smarty->assign($key."ACL", $this->getacl($key,$this->ReadOnly));
-      $smarty->assign($key."_W", $this->acl_is_writeable($key,$this->ReadOnly));
-  
-      if($this->acl_is_writeable($key)){
-        $changeState.= " changeState('".$key."'); \n";
+    if($this->multiple_support_active){
+
+      /* We do not need the attribute grey out in multiple edit */
+      foreach($tmp['plProvidedAcls'] as $key => $desc){
+        $smarty->assign($key."ACL", $this->getacl($key,$this->ReadOnly));
       }
-    }
-    $smarty->assign("changeState",$changeState);
+      if ($this->is_account){
+        $smarty->assign("pureftpdState", "checked");
+      }else{
+        $smarty->assign("pureftpdState", "");
+      }
+      $smarty->assign("fstate", "");
+      $smarty->assign("changeState","");
+
+    }else{
+      foreach($tmp['plProvidedAcls'] as $key => $desc){
+        $smarty->assign($key."ACL", $this->getacl($key,$this->ReadOnly));
+        $smarty->assign($key."_W", $this->acl_is_writeable($key,$this->ReadOnly));
+
+        if($this->acl_is_writeable($key)){
+          $changeState.= " changeState('".$key."'); \n";
+        }
+      }
+      $smarty->assign("changeState",$changeState);
 
 
-    $smarty->assign("fstate", "");
-    if ($this->is_account){
-      $smarty->assign("pureftpdState", "checked");
       $smarty->assign("fstate", "");
-    } else {
-      $smarty->assign("pureftpdState", "");
-      if($_SESSION['js']==1){
-        if($this->acl!="#none#")
-        $smarty->assign("fstate", "disabled");
-      }else{
+      if ($this->is_account){
+        $smarty->assign("pureftpdState", "checked");
         $smarty->assign("fstate", "");
+      } else {
+        $smarty->assign("pureftpdState", "");
+        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->ReadOnly)&&(($this->is_account && $this->acl_is_removeable()) || (!$this->is_account && $this->acl_is_createable())) ){
-      $smarty->assign('pureftpdACL', "");
-    }else{
-      $smarty->assign('pureftpdACL', " disabled ");
-    }
 
+    foreach($this->attributes as $attr){
+      if(in_array($attr,$this->multi_boxes)){
+        $smarty->assign("use_".$attr,TRUE);
+      }else{
+        $smarty->assign("use_".$attr,FALSE);
+      }
+    }
+    $smarty->assign("use_pureftpd",in_array("pureftpd",$this->multi_boxes)); 
+    $smarty->assign("multiple_support",$this->multiple_support_active);
+    $smarty->assign("FTPStatus", ($this->FTPStatus == "disabled") ? "checked" : "");
+    $smarty->assign('pureftpdACL', $this->getacl("",$this->ReadOnly));
     $display.= $smarty->fetch (get_template_path('pureftpd.tpl', TRUE, dirname(__FILE__)));
     return ($display);
   }
@@ -250,6 +272,51 @@ class pureftpdAccount extends plugin
             "FTPStatus"             => _("Status"))
           ));
   }
+
+  function multiple_save_object()
+  {
+    if (isset($_POST['connectivityTab'])){
+      plugin::multiple_save_object();
+      if(isset($_POST['use_pureftpd'])){
+        $this->multi_boxes[] = "pureftpd";
+      }
+      $this->save_object();
+    }
+  }
+
+  function get_multi_init_values()
+  {
+    $ret = plugin::get_multi_init_values();
+    $ret['is_account'] = $this->is_account;
+    return($ret);
+  }
+
+  function init_multiple_support($attrs,$attr)
+  {
+    plugin::init_multiple_support($attrs,$attr);
+
+    if(isset($attrs['is_account'])){
+      $this->is_account = $attrs['is_account'];
+    }
+  }
+
+  function get_multi_edit_values()
+  {
+    $ret = plugin::get_multi_edit_values();
+    if(in_array("pureftpd",$this->multi_boxes)){
+      $ret['is_account'] = $this->is_account;
+    }
+    return($ret);
+  }
+
+  function set_multi_edit_values($values)
+  {
+    plugin::set_multi_edit_values($values);
+    if(isset($values['is_account'])){
+      $this->is_account = $values['is_account'];
+    }
+  }
+
 }
 
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
index 714ef787bb390fea1d40e9a8cfb32a1d005cfd33..5558f54addf26275fc5a25d0da44f9f86b596a63 100644 (file)
@@ -1,6 +1,8 @@
 <h2>
-       <input type="checkbox" name="pureftpd" value="B" {$pureftpdState} {$pureftpdACL} 
-               onclick="{$changeState}" >
+       {render acl=$pureftpdACL checkbox=$multiple_support checked=$use_pureftpd}
+       <input type="checkbox" name="pureftpd" value="B" {$pureftpdState} 
+               onclick="{$changeState}" class="center">
+       {/render}
        {t}FTP account{/t}
 </h2>
 
@@ -18,7 +20,7 @@
        <tr>
          <td>{t}Upload bandwidth{/t}</td>
         <td>
-{render acl=$FTPUploadBandwidthACL}
+{render acl=$FTPUploadBandwidthACL checkbox=$multiple_support checked=$use_FTPUploadBandwidth}
 <input name="FTPUploadBandwidth" id="FTPUploadBandwidth" size=7 maxlength=7 value="{$FTPUploadBandwidth}" {$fstate} >
 {/render}
         {t}kb/s{/t}</td>
@@ -26,7 +28,7 @@
        <tr>
          <td>{t}Download bandwidth{/t}</td>
         <td>
-{render acl=$FTPDownloadBandwidthACL}
+{render acl=$FTPDownloadBandwidthACL  checkbox=$multiple_support checked=$use_FTPDownloadBandwidth}
 <input name="FTPDownloadBandwidth" id="FTPDownloadBandwidth" size=7 maxlength=7 value="{$FTPDownloadBandwidth}" {$fstate} >
 {/render}
         {t}kb/s{/t}</td>
@@ -46,7 +48,7 @@
        <tr>
          <td>{t}Files{/t}</td>
         <td>
-{render acl=$FTPQuotaFilesACL}
+{render acl=$FTPQuotaFilesACL checkbox=$multiple_support checked=$use_FTPQuotaFiles}
 <input name="FTPQuotaFiles" id="FTPQuotaFiles" size=7 maxlength=10 value="{$FTPQuotaFiles}" {$fstate} >
 {/render}
        </td>
@@ -54,7 +56,7 @@
        <tr>
          <td>{t}Size{/t}</td>
         <td>
-{render acl=$FTPQuotaMBytesACL}
+{render acl=$FTPQuotaMBytesACL checkbox=$multiple_support checked=$use_FTPQuotaMBytes}
 <input name="FTPQuotaMBytes" id="FTPQuotaMBytes" size=7 maxlength=10 value="{$FTPQuotaMBytes}" {$fstate} > 
 {/render}
        {t}MB{/t}
          <td>{t}Uploaded / downloaded files{/t}</td>
         <td>
 
-{render acl=$FTPUploadRatioACL}
+{render acl=$FTPUploadRatioACL checkbox=$multiple_support checked=$use_FTPUploadRatio}
 <input name="FTPUploadRatio" id="FTPUploadRatio" size=5 maxlength=20 value="{$FTPUploadRatio}" {$fstate} >
 {/render}
         / 
-{render acl=$FTPDownloadRatioACL}
+{render acl=$FTPDownloadRatioACL checkbox=$multiple_support checked=$use_FTPDownloadRatio}
 <input name="FTPDownloadRatio" id="FTPDownloadRatio" size=5 maxlength=20 value="{$FTPDownloadRatio}" {$fstate} >
 {/render}
        </td>
@@ -94,8 +96,8 @@
          </td>
        <tr>
          <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 acl=$FTPStatusACL checkbox=$multiple_support checked=$use_FTPStatus}
+<input type=checkbox name="FTPStatus" id="FTPStatus" value="disabled" {$FTPStatus} title="{t}Check to disable FTP Access{/t}" {$fstate} class="center">
 {/render}
 {t}Temporary disable FTP access{/t}</td>
        </tr>