Code

Added acls for goFaxAccount
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 2 Aug 2006 10:42:19 +0000 (10:42 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 2 Aug 2006 10:42:19 +0000 (10:42 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@4366 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/gofax/faxaccount/class_gofaxAccount.inc
plugins/gofax/faxaccount/generic.tpl
plugins/gofax/faxaccount/lists.tpl

index d106b88cd4b4e1ad0ab477314e72078a72f3cd40..78102e8609f0edef26d7a1131f5c3f81e8ed2ca2 100644 (file)
@@ -39,7 +39,7 @@ class gofaxAccount extends plugin
   var $current_blocklist= array();
 
   /* attribute list for save action */
-  var $attributes= array("goFaxDeliveryMode", "goFaxIsEnabled","goFaxRBlockgroups","facsimileAlternateTelephoneNumber",
+  var $attributes= array("goFaxDeliveryMode", "goFaxIsEnabled","goFaxRBlockgroups","facsimileAlternateTelephoneNumber","facsimileTelephoneNumber",
       "goFaxPrinter", "goFaxDivertNumber", "goFaxLanguage", "goFaxFormat", "mail");
   var $objectclasses= array("goFaxAccount");
 
@@ -58,7 +58,7 @@ class gofaxAccount extends plugin
 
     if ($dn != "new"){
       /* Get arrays */
-      foreach (array("goFaxRBlocklist", "goFaxRBlockgroups", "goFaxSBlocklist",
+      foreach (array("goFaxRBlocklist", "goFaxRBlockgroups", "goFaxSBlocklist","facsimileTelephoneNumber",
             "goFaxSBlockgroups", "facsimileAlternateTelephoneNumber") as $val){
         $this->$val =array();
         if (isset($this->attrs["$val"]["count"])){
@@ -72,9 +72,6 @@ class gofaxAccount extends plugin
       if (in_array("gosaMailAccount", $this->attrs['objectClass'])){
         $this->has_mailAccount= TRUE;
       }
-      if (isset($this->attrs["facsimileTelephoneNumber"][0])){
-        $this->facsimileTelephoneNumber= $this->attrs["facsimileTelephoneNumber"][0];
-      }
     }
 
     /* Load printer list */
@@ -154,15 +151,15 @@ class gofaxAccount extends plugin
 
     /* Trigger Add local fax alternatives dialog */
     if (isset($_POST['add_local_alternate'])){
-      $this->locals_dialog= TRUE;      
-      $this->dialog= TRUE;     
+      if($this->acl_is_writeable("facsimileAlternateTelephoneNumber")){
+        $this->locals_dialog= TRUE;    
+        $this->dialog= TRUE;   
+      }
     }
 
     /* Add alternatives from dialog */
-    if (isset($_POST['add_locals_finish'])){
-      if (isset($_POST['local_list']) &&
-          chkacl ($this->acl, "facsimileAlternateTelephoneNumber") == ""){
-
+    if (isset($_POST['add_locals_finish']) && isset($_POST['local_list'])){
+      if($this->acl_is_writeable("facsimileAlternateTelephoneNumber")){
         foreach ($_POST['local_list'] as $val){
           $this->addAlternate($val);
           $this->is_modified= TRUE;
@@ -171,20 +168,15 @@ class gofaxAccount extends plugin
     }
 
     /* Add alternatives */
-    if (isset($_POST['add_alternate'])){
-      if ($_POST['forward_address'] != "" &&
-          is_phone_nr($_POST['forward_address']) &&
-          chkacl ($this->acl, "facsimileAlternateTelephoneNumber") == ""){
-
+    if (isset($_POST['add_alternate']) && !empty($_POST['forward_address']) && is_phone_nr($_POST['forward_address'])){ 
+      if($this->acl_is_writeable("facsimileAlternateTelephoneNumber")){
         $this->addAlternate($_POST['forward_address']);
       }
     }
 
     /* Delete alternate fax number */
-    if (isset($_POST['delete_alternate'])){
-      if (isset($_POST['alternate_list']) && count($_POST['alternate_list']) &&
-          chkacl ($this->acl, "facsimileAlternateTelephoneNumber") == ""){
-
+    if (isset($_POST['delete_alternate']) && isset($_POST['alternate_list']) && count($_POST['alternate_list'])){ 
+      if($this->acl_is_writeable("facsimileAlternateTelephoneNumber")){
         $this->delAlternate ($_POST['alternate_list']);
       }
     }
@@ -192,19 +184,19 @@ class gofaxAccount extends plugin
 
     /* Edit incoming blocklists */
     if (isset($_POST['edit_incoming'])){
-      $this->current_blocklist= array_merge($this->goFaxRBlocklist,
-          $this->goFaxRBlockgroups);
-      sort($this->current_blocklist);
-      reset($this->current_blocklist);
+      if($this->acl_is_writeable("goFaxRBlocklist"))  {
+        $this->current_blocklist= array_merge($this->goFaxRBlocklist,$this->goFaxRBlockgroups);
+        sort($this->current_blocklist);
+        reset($this->current_blocklist);
 
-      $this->in_blocklist_dialog= TRUE;
-      $this->dialog= TRUE;
+        $this->in_blocklist_dialog= TRUE;
+        $this->dialog= TRUE;
+      }
     }
 
     /* Edit outgoing blocklists */
     if (isset($_POST['edit_outgoing'])){
-      $this->current_blocklist= array_merge($this->goFaxSBlocklist,
-          $this->goFaxSBlockgroups);
+      $this->current_blocklist= array_merge($this->goFaxSBlocklist,$this->goFaxSBlockgroups);
       sort($this->current_blocklist);
       reset($this->current_blocklist);
 
@@ -294,10 +286,8 @@ class gofaxAccount extends plugin
 
 
     /* Set departments */
-    if ($this->locals_dialog ||
-        $this->in_blocklist_dialog ||
-        $this->out_blocklist_dialog){
-
+    if ($this->locals_dialog || $this->in_blocklist_dialog || $this->out_blocklist_dialog){
+      
       $list= array ();
       $ldap= $this->config->get_ldap_link();
       if (isset ($_POST['department'])){
@@ -334,7 +324,6 @@ class gofaxAccount extends plugin
         }
         $faxfilter['fuser']= $s;
       }
-      register_global("faxfilter", $faxfilter);
 
       if ($faxfilter['regex'] != '*' && $faxfilter['regex'] != ""){
         $regex= $faxfilter['regex'];
@@ -434,7 +423,7 @@ class gofaxAccount extends plugin
       /* Fetch all returned departments an add them to our divlist */
       while($value = $ldap->fetch()){
         if($value["description"][0]!=".."){
-          $this->departments[$value['dn']]=convert_department_dn($value['dn'])." - [".$value["description"][0]."]";
+          $this->departments[$value['dn']]=@LDAP::fix(convert_department_dn($value['dn'])." - [".$value["description"][0]."]");
         }else{
           $this->departments[$value['dn']]=$value["description"][0];
         }
@@ -465,7 +454,6 @@ class gofaxAccount extends plugin
 
       /* Show dialog */
       $smarty->assign("cblocklist", $this->current_blocklist);
-      $smarty->assign("goFaxBlockListACL", chkacl($this->acl, "goFaxBlockList"));
       $smarty->assign("departments", $this->config->idepartments);
       $smarty->assign("divSelectPredefined", $divSel->DrawList());
       $display.= $smarty->fetch (get_template_path('lists.tpl', TRUE, dirname(__FILE__)));
@@ -516,7 +504,7 @@ class gofaxAccount extends plugin
       /* Get all departments */
       while($value = $ldap->fetch()){
         if(isset($value["description"][0])){
-          $this->departments[$value['dn']]=convert_department_dn($value['dn'])." - [".$value["description"][0]."]";
+          $this->departments[$value['dn']]=@LDAP::fix(convert_department_dn($value['dn'])." - [".$value["description"][0]."]");
         }else{
           $this->departments[$value['dn']]=$value["description"][0];
         }
@@ -548,7 +536,6 @@ class gofaxAccount extends plugin
 
       /* Show dialog */
       $smarty->assign("cblocklist", $this->current_blocklist);
-      $smarty->assign("goFaxBlockListACL", chkacl($this->acl, "goFaxBlockList"));
       $smarty->assign("departments", $this->config->idepartments);
       $smarty->assign("divSelectPredefined", $divSel->DrawList());
       $display.= $smarty->fetch (get_template_path('lists.tpl', TRUE, dirname(__FILE__)));
@@ -567,10 +554,12 @@ class gofaxAccount extends plugin
           "facsimileAlternateTelephoneNumber", "mail") as $val){
 
       $smarty->assign("$val", $this->$val);
-      $smarty->assign($val."ACL", chkacl($this->acl, "$val"));
     }
-    $smarty->assign("goFaxRBlockgroupsACL", chkacl($this->acl, "goFaxRBlockgroups"));
-    $smarty->assign("goFaxSBlockgroupsACL", chkacl($this->acl, "goFaxSBlockgroups"));
+
+    $tmp = $this->plInfo();
+    foreach($tmp['plProvidedAcls'] as $acl => $desc){
+      $smarty->assign($acl."ACL",$this->getacl($acl));
+    }
 
     /* Load checkboxes */
     if ($this->goFaxIsEnabled == "1"){
@@ -580,14 +569,14 @@ class gofaxAccount extends plugin
     }
     /* goFaxAccount has "mail" as must! Block if no mailaddress is specified... */
     if ($this->goFaxDeliveryMode & 32) {
-      $smarty->assign("fax_to_mail", "checked");
+      $smarty->assign("faxtomail", "checked");
     } else {
-      $smarty->assign("fax_to_mail", "");
+      $smarty->assign("faxtomail", "");
     }
     if ($this->goFaxDeliveryMode & 64) {
-      $smarty->assign("fax_to_printer", "checked");
+      $smarty->assign("faxtoprinter", "checked");
     } else {
-      $smarty->assign("fax_to_printer", "");
+      $smarty->assign("faxtoprinter", "");
     }
 
 
@@ -668,15 +657,26 @@ class gofaxAccount extends plugin
     if (isset($_POST['faxTab'])){
       plugin::save_object();
 
-      /* Adapt combobox values */
-      $tmp= 0;
-      if (isset($_POST["fax_to_mail"]) && $_POST["fax_to_mail"] == 1){
-        $tmp+= 32;
+
+      $tmp = 0+$this->goFaxDeliveryMode;
+
+      if($this->acl_is_writeable("faxtomail")){
+        if (isset($_POST["faxtomail"]) && $_POST["faxtomail"] == 1){  
+          $tmp |= 32;
+        }elseif($tmp & 32){
+          $tmp &= (!32);
+        }
       }
-      if (isset($_POST["fax_to_printer"]) && $_POST["fax_to_printer"] == 1){
-        $tmp+= 64;
+      if($this->acl_is_writeable("faxtoprinter")){
+        if (isset($_POST["faxtoprinter"]) && $_POST["faxtoprinter"] == 1){  
+          $tmp |= 64;
+        }elseif($tmp & 64){
+          $tmp &= !64;
+        }
       }
-      if (chkacl ($this->acl, "goFaxIsEnabled") == ""){
+      $this->goFaxDeliveryMode = $tmp;
+
+      if($this->acl_is_writeable("goFaxIsEnabled")){
         if (isset($_POST["goFaxIsEnabled"]) && $_POST["goFaxIsEnabled"] == "1"){
           $this->goFaxIsEnabled= "0";
         } else {
@@ -684,28 +684,11 @@ class gofaxAccount extends plugin
         }
       }
 
-      if (isset($_POST['facsimileTelephoneNumber'])){
-        if ($_POST['facsimileTelephoneNumber'] != $this->facsimileTelephoneNumber){
-          $this->is_modified= TRUE;
-        }
-        $this->facsimileTelephoneNumber= $_POST['facsimileTelephoneNumber'];
-      }
-
-      if (isset($_POST['mail'])){
-        if ($this->mail != $_POST['mail']){
-          $this->is_modified= TRUE;
-        }
+    
+      if (isset($_POST['mail']) && $this->acl_is_writeable("faxtomail")){
         $this->mail= $_POST['mail'];
       }
 
-      /* Write to object */
-      if (chkacl ($this->acl, "goFaxDeliveryMode") == ""){
-        if ($tmp != $this->goFaxDeliveryMode){
-          $this->is_modified= TRUE;
-        }
-        $this->goFaxDeliveryMode= "$tmp";
-      }
-
       /* Check if mail account is active and correct the internal
          reference to represent the current status. */
       if (isset($this->parent->by_object['mailAccount']->is_account)&&($this->parent->by_object['mailAccount']->is_account)){
@@ -728,6 +711,10 @@ class gofaxAccount extends plugin
       $this->attrs[$val]= $this->$val;
     }
 
+    if(!$this->attrs['goFaxDeliveryMode']){
+      $this->attrs['goFaxDeliveryMode'] = 0;
+    }
+  
     /* Adapt mail settings if needed */
     unset($this->attrs['mail']);
     if (!$this->has_mailAccount && $this->goFaxDeliveryMode && 32){
@@ -824,7 +811,9 @@ class gofaxAccount extends plugin
             "goFaxRBlocklist"                   => _("Receive blocklist"),
             "goFaxSBlocklist"                   => _("Send blocklist"),
             "facsimileTelephoneNumber"          => _("Fax number"), // goFaxDeliveryMode
-            "goFaxPrinter"                      => _("Deliver fax to printer"),
+            "facsimileAlternateTelephoneNumber" => _("Alternate fax number"), // goFaxDeliveryMode
+            "faxtomail"                         => _("Deliver fax as mail"),
+            "faxtoprinter"                      => _("Deliver fax to printer"),
             "goFaxFormat"                       => _("Delivery format"),
             "goFaxLanguage"                     => _("Language"))
           ));
index b29402516d99c33d00ce444b5751a4116a76f2a7..93deffd4214ff97c55e31c4c99ac9d6a3c6ebdbb 100644 (file)
@@ -9,23 +9,36 @@
        <tr>
          <td><label for="facsimileTelephoneNumber">{t}Fax{/t}</label>{$must}</td>
          <td>
-           <input name="facsimileTelephoneNumber" id="facsimileTelephoneNumber" size=20 maxlength=65 {$facsimileTelephoneNumberACL} value="{$facsimileTelephoneNumber}" title="{t}Fax number for GOfax to trigger on{/t}">
+
+{render acl=$facsimileTelephoneNumberACL}
+           <input name="facsimileTelephoneNumber" id="facsimileTelephoneNumber" ze=20 maxlength=65
+               value="{$facsimileTelephoneNumber}" title="{t}Fax number for GOfax to trigger on{/t}">
+{/render}
+
          </td>
        </tr>
        <tr>
          <td><label for="goFaxLanguage">{t}Language{/t}</label></td>
         <td>
-           <select size="1" name="goFaxLanguage" id="goFaxLanguage" {$goFaxLanguageACL} title="{t}Specify the GOfax communication language for fax to mail gateway{/t}">
+
+{render acl=$goFaxLanguageACL}
+           <select size="1" name="goFaxLanguage" id="goFaxLanguage" 
+               title="{t}Specify the GOfax communication language for fax to mail gateway{/t}">
            {html_options values=$languages output=$languages selected=$goFaxLanguage}
            </select>
+{/render}
+
          </td>
        </tr>
        <tr>
          <td><label for="goFaxFormat">{t}Delivery format{/t}</label></td>
          <td>
-           <select id="goFaxFormat" size="1" name="goFaxFormat" {$goFaxFormatACL} title="{t}Specify delivery format for fax to mail gateway{/t}">
+
+{render acl=$goFaxFormatACL}
+           <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>
+{/render}
          </td>
        </tr>
      </table>
    <td style="vertical-align:top; width:100%">
      <h2><img class="center" alt="" align="middle" src="images/printer.png" />&nbsp;{t}Delivery methods{/t}</h2>
 
-     <input type=checkbox name="goFaxIsEnabled" value="1" {$goFaxIsEnabled} {$goFaxIsEnabledACL}>
+{render acl=$goFaxIsEnabledACL}
+     <input type=checkbox name="goFaxIsEnabled" value="1" {$goFaxIsEnabled}>
+{/render}
      {t}Temporary disable fax usage{/t}<br>
 
      {if $has_mailaccount eq "false"}
-     <input type=checkbox name="fax_to_mail" value="1" {$fax_to_mail} {$goFaxDeliveryModeACL}>
+{render acl=$faxtomailACL}
+     <input type=checkbox name="faxtomail" value="1" {$faxtomail}>
+{/render}
       <label for="mail">{t}Deliver fax as mail to{/t}</label>&nbsp;
-      <input name="mail" id="mail" size=25 maxlength=65 {$goFaxDeliveryModeACL} value="{$mail}">
+{render acl=$faxtomailACL}
+      <input name="mail" id="mail" size=25 maxlength=65 value="{$mail}">
+{/render}
      {else}
-     <input type=checkbox name="fax_to_mail" value="1" {$fax_to_mail} {$goFaxDeliveryModeACL}>
+{render acl=$faxtomailACL}
+     <input type=checkbox name="faxtomail" value="1" {$faxtomail}>
+{/render}
       {t}Deliver fax as mail{/t}
      {/if}
      <br>
 
-     <input type=checkbox name="fax_to_printer" value="1" {$fax_to_printer} {$goFaxDeliveryModeACL}>
+{render acl=$faxtoprinterACL}
+     <input type=checkbox name="faxtoprinter" value="1" {$faxtoprinter}>
+{/render}
      {t}Deliver fax to printer{/t}&nbsp;
-     <select size="1" name="goFaxPrinter" {$goFaxPrinterACL}>
+{render acl=$faxtoprinterACL}
+     <select size="1" name="goFaxPrinter">
       {html_options options=$printers selected=$goFaxPrinter}
                <option disabled>&nbsp;</option>
      </select>
-
+{/render}
    </td>
  </tr>
 </table>
   <tr>
     <td style="width:50%; border-right:1px solid #A0A0A0">
     <h2><img class="center" alt="" align="middle" src="images/fax_small.png">&nbsp;{t}Alternate fax numbers{/t}</h2>
-    <select style="width:100%" name="alternate_list[]" size="10" multiple {$facsimileAlternateTelephoneNumberACL}>
+{render acl=$facsimileAlternateTelephoneNumberACL}
+    <select style="width:100%" name="alternate_list[]" size="10" multiple>
                        {html_options values=$facsimileAlternateTelephoneNumber output=$facsimileAlternateTelephoneNumber}
                        <option disabled>&nbsp;</option>
     </select>
+{/render}
     <br>
-    <input name="forward_address" size=20 align="middle" maxlength=65 {$facsimileAlternateTelephoneNumberACL} value="">
-    <input type=submit value="{t}Add{/t}" name="add_alternate" {$facsimileAlternateTelephoneNumberACL}>&nbsp;
-    <input type=submit value="{t}Add local{/t}" name="add_local_alternate" {$facsimileAlternateTelephoneNumberACL}>&nbsp;
-    <input type=submit value="{t}Delete{/t}" name="delete_alternate" {$facsimileAlternateTelephoneNumberACL}>
+{render acl=$facsimileAlternateTelephoneNumberACL}
+    <input name="forward_address" size=20 align="middle" maxlength=65 value="">
+{/render}
+{render acl=$facsimileAlternateTelephoneNumberACL}
+    <input type=submit value="{t}Add{/t}" name="add_alternate">&nbsp;
+{/render}
+{render acl=$facsimileAlternateTelephoneNumberACL}
+    <input type=submit value="{t}Add local{/t}" name="add_local_alternate" >&nbsp;
+{/render}
+{render acl=$facsimileAlternateTelephoneNumberACL}
+    <input type=submit value="{t}Delete{/t}" name="delete_alternate">
+{/render}
    </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>
-            <input type=submit name="edit_incoming" {$goFaxRBlockgroupsACL} value="{t}Edit{/t}">
+{render acl=$goFaxRBlocklistACL}
+            <input type=submit name="edit_incoming" value="{t}Edit{/t}">
+{/render}
           </td>
         </tr>
         <tr>
           <td>{t}Blocklists for outgoing fax{/t}</td>
           <td>
-            <input type=submit name="edit_outgoing" {$goFaxSBlockgroupsACL} value="{t}Edit{/t}">
+{render acl=$goFaxSBlocklistACL}
+            <input type=submit name="edit_outgoing" value="{t}Edit{/t}">
+{/render}
           </td>
         </tr>
       </table>
index 8794a9c768ff088cf3006e177ef3be2a2fab9e45..5817e6c7dd26afe0fdc4531d8bb07f2224834553 100644 (file)
@@ -9,9 +9,9 @@
                <option disabled>&nbsp;</option>
    </select>
    <br>
-   <input name="block_number" size=25 align="middle" maxlength=30 {$goFaxBlockListACL} value="">
-   <input type=submit value="{t}Add{/t}" name="add_blocklist_number" {$goFaxBlockListACL}>&nbsp;
-   <input type=submit value="{t}Delete{/t}" name="delete_blocklist_number" {$goFaxBlockListACL}>
+   <input name="block_number" size=25 align="middle" maxlength=30 value="">
+   <input type=submit value="{t}Add{/t}" name="add_blocklist_number" >&nbsp;
+   <input type=submit value="{t}Delete{/t}" name="delete_blocklist_number" >
   </td>
   <td>
        <b>{t}List of predefined blocklists{/t}</b><br>
@@ -22,7 +22,7 @@
                        </td>
                </tr>
        </table>
-   <input type=submit value="{t}Add the list to the blocklists{/t}" name="add_blocklist" {$goFaxBlockListACL}><br>
+   <input type=submit value="{t}Add the list to the blocklists{/t}" name="add_blocklist"><br>
   </td>
  </tr>
 </table>