Code

Prepared group Generic & Template for new acls .... not tested & not complete
[gosa.git] / plugins / gofax / blocklists / class_blocklistManagement.inc
index f5f523e8e4d4cc6bc365305703fef5d4701ac5a8..9b946ee97cce5792d6b571dd05d4f497d11cd463 100644 (file)
@@ -29,10 +29,6 @@ class blocklist extends plugin
     $this->dn     = "";
     $this->config = $config;
 
-    $ui           = get_userinfo();
-    $acl          = get_permissions ($ui->dn, $ui->subtreeACL);
-    $this->acl    = get_module_permission($acl, "blocklists", $ui->dn);
-
     $this->DivListBlocklist = new divListBlocklist($this->config,$this);
   }
 
@@ -221,7 +217,7 @@ class blocklist extends plugin
      ***************/
 
     /* What about finish? */
-    if ((isset($_POST['edit_finish'])) && (!empty($this->dn))){
+    if ((isset($_POST['edit_finish']) || isset($_POST['edit_apply'])) && (!empty($this->dn))){
       $message= $this->check();
       $this->remove_lock();
 
@@ -235,9 +231,12 @@ class blocklist extends plugin
 
         $this->save ();
         gosa_log ("Blocklist object'".$this->dn."' has been saved");
-        $this->dn= "";
-        del_lock ($this->ui->dn);
-        unset($_SESSION['objectinfo']);
+      
+        if (!isset($_POST['edit_apply'])){
+          $this->dn= "";
+          del_lock ($this->ui->dn);
+          unset($_SESSION['objectinfo']);
+        }
       } else {
         /* Errors found, show message */
         show_errors ($message);
@@ -256,7 +255,7 @@ class blocklist extends plugin
       foreach($_POST as $name => $value){
         if(preg_match("/^chooseBase/",$name) && $once){
           $once = false;
-          $this->dialog = new baseSelectDialog($this->config);
+          $this->dialog = new baseSelectDialog($this->config,$this);
           $this->dialog->setCurrentBase($this->base);
         }
       }
@@ -293,9 +292,11 @@ class blocklist extends plugin
       if ($this->dn == "new" || preg_match ("/,ou=incoming,/", $this->dn)){
         $smarty->assign("selectmode", "");
         $smarty->assign("mode", "");
+        $smarty->assign("apply", "0");
       } else {
         $smarty->assign("selectmode", "disabled");
         $smarty->assign("mode", "readonly");
+        $smarty->assign("apply", "1");
       }
       foreach(array("cn", "description", "type", "goFaxBlocklist") as $val){
         $smarty->assign("$val", $this->$val);
@@ -316,6 +317,12 @@ class blocklist extends plugin
         Divlist dialog 
        ***************/
 
+      /* Check if there is a snapshot dialog open */
+      $base = $this->DivListBlocklist->selectedBase;
+      if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases())){
+        return($str);
+      }
+
       /* Display dialog with system list */
       $this->DivListBlocklist->parent = $this;
       $this->DivListBlocklist->execute();
@@ -331,6 +338,13 @@ class blocklist extends plugin
   }
 
 
+  /* Return departments, that will be included within snapshot detection */
+  function get_used_snapshot_bases()
+  {
+    return(array("ou=gofax,ou=systems,". $this->DivListBlocklist->selectedBase));
+  }
+
+
   /* Clear garbage from edited lists */
   function clear_fields()
   {
@@ -365,11 +379,11 @@ class blocklist extends plugin
     /* Create filter */
     if ($ShowSendBocklists){
       $filter = "(&(objectClass=goFaxSBlock)(|(cn=".$Regex.")(goFaxSBlocklist=".$Regex.")))";
-      $res= get_list($filter, $this->ui->subtreeACL, $base,array("*"), $Flags);
+      $res= get_list($filter, "gofax", $base,array("*"), $Flags);
     }
     if ($ShowReceiveBlocklists){
       $filter2= "(&(objectClass=goFaxRBlock)(|(cn=".$Regex.")(goFaxRBlocklist=".$Regex.")))";
-      $res2= get_list($filter2, $this->ui->subtreeACL, $base,array("*"), $Flags);
+      $res2= get_list($filter2, "gofax", $base,array("*"), $Flags);
     }
    
     $this->blocklists = array_merge($res,$res2);
@@ -392,7 +406,7 @@ class blocklist extends plugin
   {
     $ldap= $this->config->get_ldap_link();
     $ldap->rmDir($this->dn);
-    show_ldap_error($ldap->get_error(), _("Removing blocklist object failed"));
+    show_ldap_error($ldap->get_error(), sprintf(_("Removing of blocklist with dn '%s' failed."),$this->dn));
     $this->clear_fields();
     $this->handle_post_events("remove");
   }
@@ -412,6 +426,9 @@ class blocklist extends plugin
         $this->$attr = $_POST[$attr];
       }
     }
+    if(isset($_POST['type'])){
+      $this->type = $_POST['type'];
+    }
   }
 
 
@@ -500,7 +517,7 @@ class blocklist extends plugin
       $ldap->add($this->attrs);
       $this->handle_post_events("add");
     }
-    show_ldap_error($ldap->get_error(), _("Saving blocklist object failed"));
+    show_ldap_error($ldap->get_error(), sprintf(_("Saving of blocklist with dn '%s' failed."),$this->dn));
   }
 
 
@@ -535,6 +552,30 @@ class blocklist extends plugin
     }
   }
 
+  /* Return plugin informations for acl handling */
+  function plInfo()
+  {
+    return (array(  
+          "plShortName"       => _("Fax"),
+          "plDescription"     => _("Fax Blocklists"),
+          "plSelfModify"      => TRUE,
+          "plDepends"         => array(),
+
+          "plPriority"    => 0,
+          "plSection"     => array("administration" => _("FAX Blocklists")),
+          "plCategory"    => array("gofax"          => array("description" => _("Fax"),
+                                                             "objectClass" => array("goFaxRBlock","goFaxSBlock"))),
+      
+  
+
+          "plProvidedAcls" => array(
+            "cn"              => _("Name"),
+            "description"     => _("Description"),
+            "base"            => _("Base"),
+            "type"            => _("Blocklist type"))
+          ));
+  }
+
 }
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
 ?>