Code

Added acls to fax blocklists
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 24 Oct 2006 11:01:30 +0000 (11:01 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 24 Oct 2006 11:01:30 +0000 (11:01 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@4924 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/gofax/blocklists/class_blocklistManagement.inc
plugins/gofax/blocklists/class_divListBlocklists.inc
plugins/gofax/blocklists/generic.tpl

index 9b946ee97cce5792d6b571dd05d4f497d11cd463..a27d033196f041f34b397ce5c705fbb3058c6260 100644 (file)
@@ -177,7 +177,7 @@ class blocklist extends plugin
 
     /* Finally delete blocklist */
     if (isset($_POST['delete_blocklist_confirm'])){
-      if (chkacl($this->acl, "delete") == ""){
+      if ($this->acl_is_removeable()){
         $this->remove_from_parent();
         gosa_log ("Blocklist object'".$this->dn."' has been removed");
         $this->reload ();
@@ -250,6 +250,10 @@ class blocklist extends plugin
 
     if($this->dn){
 
+      $this->set_acl_category("gofax");
+      $this->set_acl_base($this->dn);
+
+
       /* Base select dialog */
       $once = true;
       foreach($_POST as $name => $value){
@@ -298,15 +302,24 @@ class blocklist extends plugin
         $smarty->assign("mode", "readonly");
         $smarty->assign("apply", "1");
       }
+
+      $tmp = $this->plInfo();
+      foreach($tmp['plProvidedAcls'] as $name => $translation){
+        $smarty->assign($name."ACL",$this->getacl($name));
+      }
+
       foreach(array("cn", "description", "type", "goFaxBlocklist") as $val){
         $smarty->assign("$val", $this->$val);
-        $smarty->assign("$val"."ACL", chkacl($this->acl, "$val"));
       }
 
-      /* Lock blocklist type for non new entries */
-      if ($this->dn != "new"){
-        $smarty->assign('typeACL', "disabled");
+      $baseACL = $this->getacl("base");
+      if(!$this->acl_is_moveable()) {
+        $baseACL = preg_replace("/w/","",$baseACL);
       }
+      $smarty->assign("baseACL",          $baseACL);
+
+      /* Lock blocklist type for non new entries */
+      $smarty->assign('typeACL',$this->getacl("type", ($this->dn != "new")));
 
       /* Show main page */
       return($smarty->fetch (get_template_path('generic.tpl', TRUE)));
@@ -418,15 +431,21 @@ class blocklist extends plugin
     $this->DivListBlocklist->save_object();
     plugin::save_object();
 
-    if(isset($_POST['base'])){
+    $baseACL = $this->getacl("base");
+    if(!$this->acl_is_moveable()) {
+      $baseACL = preg_replace("/w/","",$baseACL);
+    }
+
+    if(isset($_POST['base']) && preg_match("/w/",$baseACL)){
       $this->base = $_POST['base'];
     }
+    
     foreach($this->attributes as $attr){
-      if(isset($_POST[$attr])){
+      if(isset($_POST[$attr]) && $this->acl_is_writeable($attr)){
         $this->$attr = $_POST[$attr];
       }
     }
-    if(isset($_POST['type'])){
+    if(isset($_POST['type']) && $this->acl_is_writeable("type",($this->dn != "new"))){
       $this->type = $_POST['type'];
     }
   }
@@ -445,11 +464,10 @@ class blocklist extends plugin
       $new_dn= $this->dn;
     }
 
-    if (chkacl($this->acl, "create") != ""){
+    if (!$this->acl_is_createable() && $this->dn == "new"){
       $message[]= _("You have no permissions to create a blocklist on this 'Base'.");
     }
 
-
     /* check syntax: must cn */
     if ($this->cn == ""){
       $message[]= _("Required field 'Name' is not set.");
@@ -467,11 +485,6 @@ class blocklist extends plugin
       }
     }
 
-    /* Is user allowed to create in 'base'? */
-    if (chkacl($this->acl, "create") != ""){
-      $message[]= _("No permission to create a blocklist on this base.");
-    }
-
     return $message;
   }
 
@@ -565,13 +578,11 @@ class blocklist extends plugin
           "plSection"     => array("administration" => _("FAX Blocklists")),
           "plCategory"    => array("gofax"          => array("description" => _("Fax"),
                                                              "objectClass" => array("goFaxRBlock","goFaxSBlock"))),
-      
-  
-
           "plProvidedAcls" => array(
             "cn"              => _("Name"),
             "description"     => _("Description"),
             "base"            => _("Base"),
+            "goFaxBlocklist"  => _("Blocklist"),
             "type"            => _("Blocklist type"))
           ));
   }
index bada73d0aac87e83d13f2e6921256579906c42d2..bf03065b1dac0eb9d9caca2cc2659a57affccec8 100755 (executable)
@@ -69,14 +69,32 @@ class divListBlocklist extends MultiSelectWindow
        which are shown in the listbox on top of the listbox
      */
     $options= "";
-    foreach ($this->config->idepartments as $key => $value){
-      if ($this->selectedBase == $key){
-        $options.= "<option selected='selected' value='$key'>$value</option>";
-      } else {
-        $options.= "<option value='$key'>$value</option>";
+
+    /* Get all departments within this subtree */
+    $base = $this->config->current['BASE'];
+
+    $deps= get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $this->module, $base,
+                    array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH);
+
+    /* Load possible departments */
+    $ui= get_userinfo();
+    $tdeps= $ui->get_module_departments("gofax");
+
+    $ids = $this->config->idepartments;
+
+    foreach($deps as $dep){
+      if(isset($ids[$dep['dn']]) && in_array_ics($dep['dn'], $tdeps)){
+
+        $value = $ids[$dep['dn']];
+        if ($this->selectedBase == $dep['dn']){
+          $options.= "<option selected='selected' value='".$dep['dn']."'>$value</option>";
+        } else {
+          $options.= "<option value='".$dep['dn']."'>$value</option>";
+        }
       }
     }
-    
+
+
     /* NEW LIST MANAGMENT */
     $listhead = "<div style='background:#F0F0F9;padding:5px;'>".
       " <input class='center' type='image' src='images/list_root.png' align='middle' 
index c6330add19005317f667d9c07117e177c0349a00..7c3f1158abdd3c4731aa17cb86e62534d78ed3a3 100644 (file)
@@ -7,21 +7,24 @@
      <tr>
       <td><LABEL for="cn">{t}List name{/t}</LABEL>{$must}</td>
       <td>
-       <input name="cn" id="cn" size=25 maxlength=60 {$mode} {$cnACL} value="{$cn}" title="{t}Name of blocklist{/t}">
+
+{render acl=$cnACL}
+       <input name="cn" id="cn" size=25 maxlength=60 {$mode} value="{$cn}" title="{t}Name of blocklist{/t}">
+{/render}
       </td>
      </tr>
      <tr>
       <td><LABEL for="base">{t}Base{/t}</LABEL>{$must}</td>
       <td>
-       <select size="1" id="base" name="base" {$selectmode} title="{t}Select subtree to place blocklist in{/t}">
-        {html_options options=$bases selected=$base_select}
-               <option disabled>&nbsp;</option>
-       </select>
-        {if $selectmode == ""}
-            <input type="image" name="chooseBase" src="images/folder.png" class="center" title="{t}Select a base{/t}">
-        {else}
-            <img src="images/folder_gray.png" class="center" title="{t}Select a base{/t}">
-        {/if}
+{render acl=$baseACL}
+      <select id="base" size="1" name="base" title="{t}Choose subtree to place group in{/t}">
+       {html_options options=$bases selected=$base_select}
+      </select>
+{/render}
+
+{render acl=$baseACL disable_picture='images/folder_gray.png'}
+        <input type="image" name="chooseBase" src="images/folder.png" class="center" title="{t}Select a base{/t}">
+{/render}
       </td>
      </tr>
     </table>
      <tr>
        <td><LABEL for="type">{t}Type{/t}</LABEL></td>
        <td>
-        <select size="1" id="type" name="type" {$goFaxBlocklistACL} title="{t}Select wether to filter incoming or outgoing calls{/t}">
-        {html_options options=$types selected=$type}
+{render acl=$typeACL}
+        <select size="1" id="type" name="type" title="{t}Select wether to filter incoming or outgoing calls{/t}">
+               {html_options options=$types selected=$type}
                <option disabled>&nbsp;</option>
         </select>
+{/render}
         </td>
       </tr>
       <tr>
        <td><LABEL for="description">{t}Description{/t}</LABEL></td>
        <td>
-         <input name="description" id="description" size=25 maxlength=80 {$descriptionACL} value="{$description}" title="{t}Descriptive text for this blocklist{/t}">
+{render acl=$descriptionACL}
+         <input name="description" id="description" size=25 maxlength=80 value="{$description}" title="{t}Descriptive text for this blocklist{/t}">
+{/render}
        </td>
       </tr>
     </table>
  <tr>
    <td style="width:50%;">
      <h2><img class="center" alt="" align="middle" src="images/false.png"> {t}Blocked numbers{/t}</h2>
+{render acl=$goFaxBlocklistACL}
      <select style="width:100%; height:200px;" name="numbers[]" size=15 multiple>
       {html_options values=$goFaxBlocklist output=$goFaxBlocklist}
          <option disabled>&nbsp;</option>
      </select>
+{/render}
      <br>
+{render acl=$goFaxBlocklistACL}
      <input id="number" name="number" size=25 maxlength=60 {$goFaxBlocklistACL}>&nbsp;
+{/render}
+{render acl=$goFaxBlocklistACL}
      <input type=submit value="{t}Add{/t}" {$goFaxBlocklistACL} name="add_number">&nbsp;
+{/render}
+{render acl=$goFaxBlocklistACL}
      <input type=submit value="{t}Delete{/t}" {$goFaxBlocklistACL} name="delete_number">
+{/render}
    </td>
   <td style="border-left:1px solid #A0A0A0">
    &nbsp;