Code

Fixed Blocklist handling
[gosa.git] / gosa-plugins / gofax / gofax / blocklists / class_blocklistGeneric.inc
index edd51c29d9e50a713748ab26eb697781bf771a29..c1701053bf4f01be2880dc2de6c0550649db166d 100644 (file)
@@ -17,12 +17,15 @@ class blocklistGeneric extends plugin
   var $goFaxBlocklist = array();
   var $readonly = FALSE;
   var $view_logged = FALSE;
-  var $attributes = array("cn","description");
+  var $attributes = array("cn","description","goFaxSBlocklist","goFaxRBlocklist");
 
   var $ignore_account = TRUE;
 
-   var $orig_base = "";
-   var $orig_dn = "";
+  var $orig_base = "";
+  var $orig_dn = "";
+
+  var $goFaxSBlocklist = array();
+  var $goFaxRBlocklist = array();
 
   
   function __construct($config,$dn = "new")
@@ -65,7 +68,7 @@ class blocklistGeneric extends plugin
         $this->base= dn2base($ui->dn);
       }
     } else {
-      $this->base =preg_replace ("/^[^,]+,[^,]+,[^,]+,/","",$this->dn);
+      $this->base= preg_replace ("/^[^,]+,".preg_quote(get_ou("faxBlocklistRDN"), '/')."/i", "", $this->dn);
     }
     
     $this->orig_base = $this->base;
@@ -161,6 +164,7 @@ class blocklistGeneric extends plugin
     $smarty->assign("types", array(BLOCK_LIST_SEND => _("send"), BLOCK_LIST_RECEIVE => _("receive")));
     $smarty->assign("type", $this->type);
     $smarty->assign("dn", $this->dn);
+    $smarty->assign("read_only",$this->read_only);
     return($smarty->fetch(get_template_path('generic.tpl', TRUE)));
   }
 
@@ -253,19 +257,16 @@ class blocklistGeneric extends plugin
 
     plugin::save();
 
-    /* Add list */
-    if (count($this->goFaxBlocklist)){
-      $this->attrs[$type]= $this->goFaxBlocklist;
-    }
+    /* Let clenaup() know what attributes to handle 
+     */ 
+    $this->attrs[$type] = $this->goFaxBlocklist;
+    $this->attributes [] = $type;
 
     /* Write back to ldap */
     $ldap= $this->config->get_ldap_link();
     $ldap->cd($this->base);
     $ldap->cat($this->dn, array('dn'));
     if ($ldap->count()){
-      if (!isset($this->attrs[$type])){
-        $this->attrs[$type]= array();
-      }
       $ldap->cd($this->dn);
       $this->cleanup();
       $ldap->modify($this->attrs);
@@ -275,6 +276,7 @@ class blocklistGeneric extends plugin
       $ldap->cd($this->config->current['BASE']);
       $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn));
       $ldap->cd($this->dn);
+      $this->cleanup();
       $ldap->add($this->attrs);
       new log("create","gofaxlist/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
       $this->handle_post_events("add");