Code

Multi edit
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 20 Dec 2007 09:17:16 +0000 (09:17 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 20 Dec 2007 09:17:16 +0000 (09:17 +0000)
-Aded fax account settings

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8154 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/plugins/gofax/faxaccount/class_gofaxAccount.inc
gosa-core/plugins/gofax/faxaccount/generic.tpl

index eca2228577a9cc7591826a1803e03327489faafd..8ec7e197957497103100cda393bb70e63434acb8 100644 (file)
@@ -50,6 +50,9 @@ class gofaxAccount extends plugin
 
   var $objectclasses= array("goFaxAccount");
 
+  /* Enable multiple edit support */
+  var $multiple_support = TRUE;
+
   function gofaxAccount (&$config, $dn= NULL)
   {
     /* General initialization */
@@ -86,10 +89,7 @@ class gofaxAccount extends plugin
     }
 
     /* Load printer list */
-    if (isset($this->config->data['SERVERS']['CUPS'])){
-      $this->printerList= get_printer_list ($this->config->data['SERVERS']['CUPS']);
-      asort ($this->printerList);
-    }
+    $this->printerList=get_printer_list();
 
     /* Check if the currently selected printer is still available. 
        If not, append current printer to list of available.
@@ -151,30 +151,35 @@ class gofaxAccount extends plugin
       $smarty->assign("has_mailaccount", "true");
     }
 
-    /* Do we need to flip is_account state? */
-    if (isset($_POST['modify_state'])){
-      $this->is_account= !$this->is_account;
-    }
 
-    /* Do we represent a valid account? */
-    if (!$this->is_account && $this->parent === NULL){
-      $display= "<img alt=\"\" src=\"images/stop.png\" align=\"middle\">&nbsp;<b>".
-        _("This account has no fax extensions.")."</b>";
-      $display.= back_to_main();
-      return ($display);
-    }
+    $display = "";
+    if(!$this->multiple_support_active){    
 
-    /* Show tab dialog headers */
-    $display= "";
-    if ($this->parent !== NULL){
-      if ($this->is_account){
-        $display= $this->show_disable_header(_("Remove fax account"),
-            _("This account has fax features enabled. You can disable them by clicking below."));
-      } else {
-        $display= $this->show_enable_header(_("Create fax account"),
-            _("This account has fax features disabled. You can enable them by clicking below."));
+      /* Do we need to flip is_account state? */
+      if (isset($_POST['modify_state'])){
+        $this->is_account= !$this->is_account;
+      }
+
+      /* Do we represent a valid account? */
+      if (!$this->is_account && $this->parent === NULL){
+        $display= "<img alt=\"\" src=\"images/stop.png\" align=\"middle\">&nbsp;<b>".
+          _("This account has no fax extensions.")."</b>";
+        $display.= back_to_main();
         return ($display);
       }
+
+      /* Show tab dialog headers */
+      $display= "";
+      if ($this->parent !== NULL){
+        if ($this->is_account){
+          $display= $this->show_disable_header(_("Remove fax account"),
+              _("This account has fax features enabled. You can disable them by clicking below."));
+        } else {
+          $display= $this->show_enable_header(_("Create fax account"),
+              _("This account has fax features disabled. You can enable them by clicking below."));
+          return ($display);
+        }
+      }
     }
 
     /* Trigger Add local fax alternatives dialog */
@@ -607,7 +612,22 @@ class gofaxAccount extends plugin
       $smarty->assign("faxtoprinter", "");
     }
 
-
+    foreach($this->attributes as $attr){
+      if(in_array($attr,$this->multi_boxes)) {
+        $smarty->assign("use_".$attr,TRUE);
+      }else{
+        $smarty->assign("use_".$attr,FALSE);
+      }
+    }
+    foreach(array("goFaxIsEnabled","edit_outgoing","edit_incoming","faxtomail","faxtoprinter") as $attr){
+      if(in_array($attr,$this->multi_boxes)) {
+        $smarty->assign("use_".$attr,TRUE);
+      }else{
+        $smarty->assign("use_".$attr,FALSE);
+      }
+    }
+  
+    $smarty->assign("multiple_support",$this->multiple_support_active);
     $display.= $smarty->fetch (get_template_path('generic.tpl', TRUE, dirname(__FILE__)));
     return ($display);
   }
@@ -851,6 +871,97 @@ class gofaxAccount extends plugin
             "goFaxLanguage"                     => _("Language"))
           ));
   }
+
+  /* Multiple edit support 
+   */
+  
+  /* Execute */
+  function multiple_execute()
+  {
+    return($this->execute());
+  }
+
+  function multiple_save_object()
+  {
+    if (isset($_POST['faxTab'])){
+      plugin::multiple_save_object();
+      foreach(array("goFaxIsEnabled","edit_outgoing","edit_incoming","faxtomail","faxtoprinter") as $attr){
+        if(isset($_POST["use_".$attr])){
+          $this->multi_boxes[] = $attr;
+        }
+      }
+
+      $tmp = 0+$this->goFaxDeliveryMode;
+      if(in_array("faxtomail",$this->multi_boxes)){
+        if (isset($_POST["faxtomail"]) && $_POST["faxtomail"] == 1){
+          $tmp |= 32;
+        }elseif($tmp & 32){
+          $tmp &= (!32);
+        }
+      }
+      if(in_array("faxtoprinter",$this->multi_boxes)){
+        if (isset($_POST["faxtoprinter"]) && $_POST["faxtoprinter"] == 1){
+          $tmp |= 64;
+        }elseif($tmp & 64){
+          $tmp &= !64;
+        }
+      }
+      $this->goFaxDeliveryMode = $tmp;
+
+        if (isset($_POST["goFaxIsEnabled"]) && $_POST["goFaxIsEnabled"] == "1"){
+          $this->goFaxIsEnabled= "0";
+        } else {
+          $this->goFaxIsEnabled= "1";
+        }
+      if (isset($_POST['mail']) && in_array("mail",$this->multi_boxes)){
+        $this->mail= $_POST['mail'];
+      }
+    }
+  }
+
+  function get_multi_edit_values()
+  {
+    $ret = plugin::get_multi_edit_values();
+    if(in_array("goFaxIsEnabled",$this->multi_boxes)){
+      $ret['goFaxIsEnabled'] = $this->goFaxIsEnabled;
+    }
+    if(in_array("faxtoprinter",$this->multi_boxes)){
+      $ret['faxtoprinter'] = $this->goFaxDeliveryMode & 64;
+    }
+    if(in_array("faxtomail",$this->multi_boxes)){
+      $ret['faxtomail'] = $this->goFaxDeliveryMode & 32;
+    }
+
+    if(in_array("edit_incoming",$this->multi_boxes)){
+      $ret['goFaxRBlocklist'] = $this->goFaxRBlocklist;
+      $ret['goFaxRBlockgroups'] = $this->goFaxRBlockgroups;
+    }
+    if(in_array("edit_outgoing",$this->multi_boxes)){
+      $ret['goFaxSBlocklist'] = $this->goFaxSBlocklist;
+      $ret['goFaxSBlockgroups'] = $this->goFaxSBlockgroups;
+    }
+    return($ret);
+  }
+
+  function set_multi_edit_values($values)
+  {
+    plugin::set_multi_edit_values($values);
+
+    if(isset($values['faxtoprinter'])){
+      if($values['faxtoprinter']){
+        $this->goFaxDeliveryMode |= 64;
+      }else{
+        $this->goFaxDeliveryMode &= !64;
+      }
+    }
+    if(isset($values['faxtomail'])){
+      if($values['faxtomail']){
+        $this->goFaxDeliveryMode |= 32;
+      }else{
+        $this->goFaxDeliveryMode &= !32;
+      }
+    }
+  }
 }
 
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
index cb56a6c11690a8cf69caaf99031ee56b4f316792..eb98dbbeeab5bfb54ce7a62dce8fd1f12fd10cfe 100644 (file)
@@ -9,11 +9,14 @@
        <tr>
          <td><label for="facsimileTelephoneNumber">{t}Fax{/t}</label>{$must}</td>
          <td>
-
+{if $multiple_support}
+       <input name="dummy1" value="{t}Multiple edit{/t}" disabled id="facsimileTelephoneNumber">
+{else}
 {render acl=$facsimileTelephoneNumberACL}
            <input name="facsimileTelephoneNumber" id="facsimileTelephoneNumber" size=20 maxlength=65
                value="{$facsimileTelephoneNumber}" title="{t}Fax number for GOfax to trigger on{/t}">
 {/render}
+{/if}
 
          </td>
        </tr>
@@ -21,7 +24,7 @@
          <td><label for="goFaxLanguage">{t}Language{/t}</label></td>
         <td>
 
-{render acl=$goFaxLanguageACL}
+{render acl=$goFaxLanguageACL checkbox=$multiple_support checked=$use_goFaxLanguage}
            <select size="1" name="goFaxLanguage" id="goFaxLanguage" 
                title="{t}Specify the GOfax communication language for fax to mail gateway{/t}">
                        {html_options options=$languages selected=$goFaxLanguage}
@@ -34,7 +37,7 @@
          <td><label for="goFaxFormat">{t}Delivery format{/t}</label></td>
          <td>
 
-{render acl=$goFaxFormatACL}
+{render acl=$goFaxFormatACL checkbox=$multiple_support checked=$use_goFaxFormat}
            <select id="goFaxFormat" size="1" name="goFaxFormat" title="{t}Specify delivery format for fax to mail gateway{/t}">
            {html_options values=$formats output=$formats selected=$goFaxFormat}
            </select>
    <td style="vertical-align:top; width:100%">
      <h2><img class="center" alt="" align="middle" src="images/printer.png" />&nbsp;{t}Delivery methods{/t}</h2>
 
-{render acl=$goFaxIsEnabledACL}
-     <input type=checkbox name="goFaxIsEnabled" value="1" {$goFaxIsEnabled}>
+{render acl=$goFaxIsEnabledACL checkbox=$multiple_support checked=$use_goFaxIsEnabled}
+     <input type=checkbox name="goFaxIsEnabled" value="1" {$goFaxIsEnabled} class="center">
 {/render}
      {t}Temporary disable fax usage{/t}<br>
 
      {if $has_mailaccount eq "false"}
-{render acl=$faxtomailACL}
-     <input type=checkbox name="faxtomail" value="1" {$faxtomail}>
+{render acl=$faxtomailACL checkbox=$multiple_support checked=$use_faxtomail}
+     <input type=checkbox name="faxtomail" value="1" {$faxtomail} class="center">
 {/render}
       <label for="mail">{t}Deliver fax as mail to{/t}</label>&nbsp;
-{render acl=$faxtomailACL}
-      <input name="mail" id="mail" size=25 maxlength=65 value="{$mail}">
+{render acl=$faxtomailACL checkbox=$multiple_support checked=$use_mail}
+      <input name="mail" id="mail" size=25 maxlength=65 value="{$mail}" class="center">
 {/render}
      {else}
-{render acl=$faxtomailACL}
-     <input type=checkbox name="faxtomail" value="1" {$faxtomail}>
+{render acl=$faxtomailACL checkbox=$multiple_support checked=$use_faxtomail}
+     <input type=checkbox name="faxtomail" value="1" {$faxtomail} class="center">
 {/render}
       {t}Deliver fax as mail{/t}
      {/if}
      <br>
 
-{render acl=$faxtoprinterACL}
-     <input type=checkbox name="faxtoprinter" value="1" {$faxtoprinter}>
+{render acl=$faxtoprinterACL checkbox=$multiple_support checked=$use_faxtoprinter}
+     <input type=checkbox name="faxtoprinter" value="1" {$faxtoprinter} class="center">
 {/render}
      {t}Deliver fax to printer{/t}&nbsp;
-{render acl=$faxtoprinterACL}
+{render acl=$faxtoprinterACL checkbox=$multiple_support checked=$use_goFaxPrinter}
      <select size="1" name="goFaxPrinter">
       {html_options options=$printers selected=$goFaxPrinter}
                <option disabled>&nbsp;</option>
@@ -90,6 +93,9 @@
 <table summary="" style="width:100%; vertical-align:top; text-align:left;" cellpadding=4 border=0>
   <tr>
     <td style="width:50%; border-right:1px solid #A0A0A0">
+
+       {if !$multiple_support}
+
     <h2><img class="center" alt="" align="middle" src="images/fax_small.png">&nbsp;{t}Alternate fax numbers{/t}</h2>
 {render acl=$facsimileAlternateTelephoneNumberACL}
     <select style="width:100%" name="alternate_list[]" size="10" multiple>
 {render acl=$facsimileAlternateTelephoneNumberACL}
     <input type=submit value="{t}Delete{/t}" name="delete_alternate">
 {/render}
+       {/if}
    </td>
    <td style="vertical-align:top; width:50%">
       <h2><img class="center" alt="" align="middle" src="images/false.png" />&nbsp;{t}Blocklists{/t}</h2>
         <tr>
           <td>{t}Blocklists for incoming fax{/t}</td>
           <td>
-{render acl=$goFaxRBlocklistACL}
+{render acl=$goFaxRBlocklistACL checkbox=$multiple_support checked=$use_edit_incoming}
             <input type=submit name="edit_incoming" value="{t}Edit{/t}">
 {/render}
           </td>
         <tr>
           <td>{t}Blocklists for outgoing fax{/t}</td>
           <td>
-{render acl=$goFaxSBlocklistACL}
+{render acl=$goFaxSBlocklistACL checkbox=$multiple_support checked=$use_edit_outgoing}
             <input type=submit name="edit_outgoing" value="{t}Edit{/t}">
 {/render}
           </td>