Code

Updated blocklists.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 27 Nov 2007 14:24:46 +0000 (14:24 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 27 Nov 2007 14:24:46 +0000 (14:24 +0000)
We are now able to assign acls and to take snapshots.

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

include/class_location.inc
plugins/gofax/blocklists/class_blocklistGeneric.inc
plugins/gofax/blocklists/class_blocklistManagement.inc
plugins/gofax/blocklists/class_divListBlocklists.inc
plugins/gofax/blocklists/main.inc
plugins/gofax/blocklists/tabs_blocklist.inc [new file with mode: 0644]

index 438c7fcb6c1cf9015c7639ac6a45b04719a5c8d9..acff81c88347ee0852e96e3a76884219f57e2bfc 100644 (file)
@@ -27,6 +27,7 @@ $class_mapping= array(
                 "blocklist" => "plugins/gofax/blocklists/class_blocklistManagement.inc",
                 "divListBlocklist" => "plugins/gofax/blocklists/class_divListBlocklists.inc",
                 "blocklistGeneric" => "plugins/gofax/blocklists/class_blocklistGeneric.inc",
+                "faxblocktabs" => "plugins/gofax/blocklists/tabs_blocklist.inc",
                 "gofaxAccount" => "plugins/gofax/faxaccount/class_gofaxAccount.inc",
                 "faxreport" => "plugins/gofax/faxreports/class_faxreport.inc",
                 "addressbook" => "plugins/addons/addressbook/class_addressbook.inc",
index 352fa7df1d85dc0b3c666f59f8a92b3de1350b8d..4504dfb278d7dbeb7cc29d7b73a518b6070405d1 100644 (file)
@@ -18,16 +18,15 @@ class blocklistGeneric extends plugin
   var $readonly = FALSE;
   var $view_logged = FALSE;
   var $attributes = array("cn","description");
-  
-  var $orig_dn;  
 
+  var $ignore_account = TRUE;
+  
   function __construct($config,$dn = "new")
   {
     plugin::plugin($config,$dn);
 
     /* Set default list type */
     $this->type = BLOCK_LIST_SEND;
-    $this->orig_dn = $this->dn;  
 
     /* Load defined numbers */
     if($dn != "new"){
@@ -240,14 +239,6 @@ class blocklistGeneric extends plugin
       $this->attrs[$type]= $this->goFaxBlocklist;
     }
 
-    /* Create base */
-    $this->dn = "cn=".$this->cn.",ou=gofax,ou=systems,".$this->base;
-
-    /* Move object in necessary */
-    if($this->orig_dn != "new" && $this->dn != $this->orig_dn){
-      $this->move($this->orig_dn,$this->dn);
-    }
-
     /* Write back to ldap */
     $ldap= $this->config->get_ldap_link();
     $ldap->cd($this->base);
index 4985e0fc9d19b52d7606fefcda5aec0106eceaf3..16fa5e08f9591173c8d0602125e893ff4998762e 100644 (file)
@@ -14,6 +14,8 @@ class blocklist extends plugin
   var $DivListBlocklist = NULL;
   var $CopyPasteHandler = NULL;
 
+  var $start_pasting_copied_objects = FALSE;
+  
 
   function blocklist (&$config, $ui)
   {
@@ -22,6 +24,11 @@ class blocklist extends plugin
     $this->config = &$config;
     $this->base = $_SESSION['CurrentMainBase']; 
     $this->DivListBlocklist = new divListBlocklist($this->config,$this);
+
+    /* Initialize copy&paste queue */
+    if ($this->config->boolValueIsTrue("main", "enableCopyPaste")){
+      $this->CopyPasteHandler= new CopyPasteHandler($this->config);
+    }
   }
 
 
@@ -62,9 +69,15 @@ class blocklist extends plugin
         $s_action="new";
       }elseif(preg_match("/^remove_multiple_blocklists/",$key)){
         $s_action="del_multiple";
+      }elseif(preg_match("/^copy/",$key)){
+        $s_action = "copy";
+        $s_entry= preg_replace("/^copy_/i", "", $key);
+      }elseif(preg_match("/^cut/",$key)){
+        $s_action = "cut";
+        $s_entry= preg_replace("/^cut_/i", "", $key);
       }
-    }
 
+    }
     if((isset($_GET['act']))&&($_GET['act']=="edit_entry")){
       $s_action ="edit";
       $s_entry  = $_GET['id'];
@@ -72,21 +85,17 @@ class blocklist extends plugin
 
     $s_entry  = preg_replace("/_.$/","",$s_entry);
 
-    
 
-
-    
-    
     /* handle C&P from layers menu */
-#   if(isset($_POST['menu_action']) && preg_match("/^multiple_copy_systems/",$_POST['menu_action'])){
-#     $s_action = "copy_multiple";
-#   }
-#   if(isset($_POST['menu_action']) && preg_match("/^multiple_cut_systems/",$_POST['menu_action'])){
-#     $s_action = "cut_multiple";
-#   }
-#   if(isset($_POST['menu_action']) && preg_match("/^editPaste/",$_POST['menu_action'])){
-#     $s_action = "editPaste";
-#   }
+    if(isset($_POST['menu_action']) && preg_match("/^multiple_copy_systems/",$_POST['menu_action'])){
+      $s_action = "copy_multiple";
+    }
+    if(isset($_POST['menu_action']) && preg_match("/^multiple_cut_systems/",$_POST['menu_action'])){
+      $s_action = "cut_multiple";
+    }
+    if(isset($_POST['menu_action']) && preg_match("/^editPaste/",$_POST['menu_action'])){
+      $s_action = "editPaste";
+    }
 
 
     /* Create options */
@@ -100,6 +109,16 @@ class blocklist extends plugin
     }
 
 
+    /***************
+      Handle copy & paste  
+     ***************/
+
+    $ret = $this->copyPasteHandling_from_queue($s_action,$s_entry);
+    if($ret){
+      return($ret);
+    }
+
+
     /***************
       Cancel some dialogs  
      ***************/
@@ -128,7 +147,7 @@ class blocklist extends plugin
       if (count ($message) == 0){
 
         $this->dialog->save ();
-      
+
         if (!isset($_POST['edit_apply'])){
           del_lock ($this->dn);
           $this->dn= "";
@@ -140,8 +159,8 @@ class blocklist extends plugin
         show_errors ($message);
       }
     }
-   
+
+
     /***************
       Create a new blocklist (dialog)
      ***************/
@@ -149,7 +168,7 @@ class blocklist extends plugin
     /* Create new blocklist? */
     if ($s_action=="new"){
       $this->dn= "new";
-      $this->dialog = new blocklistGeneric($this->config,$this->dn);
+      $this->dialog = new faxblocktabs($this->config,$this->config->data['TABS']['FAXBLOCKTABS'],$this->dn);
       $this->dialog->set_acl_base($this->base);
     }
 
@@ -168,7 +187,7 @@ class blocklist extends plugin
         add_lock ($this->dn, $this->ui->dn);
       }
       $_SESSION['objectinfo']= trim($this->dn);
-      $this->dialog = new blocklistGeneric($this->config,$this->dn);
+      $this->dialog = new faxblocktabs($this->config,$this->config->data['TABS']['FAXBLOCKTABS'],$this->dn);
       $this->dialog->set_acl_base($this->dn);
     }    
 
@@ -177,7 +196,7 @@ class blocklist extends plugin
       Display dialog  
      ***************/
 
-    if(is_object($this->dialog) && ($this->dialog instanceof blocklistGeneric)){
+    if(is_object($this->dialog) && ($this->dialog instanceof faxblocktabs)){
       $this->dialog->save_object();
       return($this->dialog->execute());
     }
@@ -225,11 +244,10 @@ class blocklist extends plugin
 
       /* Remove user by user and check acls before removeing them */
       foreach($this->dns as $key => $dn){
-        $acl = $this->ui->get_permissions($dn, "blocklist/blocklist");
-        if (preg_match('/d/', $acl)){
+        if (preg_match("/d/",$this->ui->get_permissions($this->dn,"gofaxlist/blocklistGeneric"))){
           $this->dn = $dn;
-          $this->dialog = new blocklistGeneric($this->config,$this->dn);
-          $this->dialog->remove_from_parent();
+          $this->dialog = new faxblocktabs($this->config,$this->config->data['TABS']['FAXBLOCKTABS'],$this->dn);
+          $this->dialog->delete();
           $this->dialog = NULL;
         } else {
           print_red (sprintf(_("You are not allowed to delete the blocklist '%s'!"),$dn));
@@ -284,10 +302,11 @@ class blocklist extends plugin
 
     /* Finally delete blocklist */
     if (isset($_POST['delete_blocklist_confirm'])){
-      if ($this->acl_is_removeable()){
-        $this->dialog = new blocklistGeneric($this->config,$this->dn);
-        $this->dialog->remove_from_parent();
+      if (preg_match("/d/",$this->ui->get_permissions($this->dn,"gofaxlist/blocklistGeneric"))){
+        $this->dialog = new faxblocktabs($this->config,$this->config->data['TABS']['FAXBLOCKTABS'],$this->dn);
+        $this->dialog->delete();
         $this->dialog = NULL;
+        del_lock ($this->dn);
       } else {
         print_red (_("You have no permission to remove this blocklist."));
       }
@@ -366,7 +385,7 @@ class blocklist extends plugin
       $filter2= "(&(objectClass=goFaxRBlock)(|(cn=".$Regex.")(goFaxRBlocklist=".$Regex.")))";
       $res2= get_list($filter2, "gofaxlist", $base,array("*"), $Flags);
     }
-   
+
     $this->blocklists = array_merge($res,$res2);
 
     /* appen && sort */
@@ -392,6 +411,84 @@ class blocklist extends plugin
   {
     $this->DivListBlocklist->save_object();
   }
+
+
+
+
+
+  function copyPasteHandling_from_queue($s_action,$s_entry)
+  {
+    /* Check if Copy & Paste is disabled */
+    if(!is_object($this->CopyPasteHandler)){
+      return("");
+    }
+
+    /* Add a single entry to queue */
+    if($s_action == "cut" || $s_action == "copy"){
+      /* Cleanup object queue */
+      $this->CopyPasteHandler->cleanup_queue();
+      $dn = $this->blocklists[$s_entry]['dn'];
+      $this->CopyPasteHandler->add_to_queue($dn,$s_action,"blocklistGeneric","","users");
+    }
+
+    /* Add entries to queue */
+    if($s_action == "copy_multiple" || $s_action == "cut_multiple"){
+
+      /* Cleanup object queue */
+      $this->CopyPasteHandler->cleanup_queue();
+
+      /* Add new entries to CP queue */
+      foreach($this->list_get_selected_items() as $id){
+        $dn = $this->blocklists[$id]['dn'];
+
+        if($s_action == "copy_multiple"){
+          $this->CopyPasteHandler->add_to_queue($dn,"copy","usertabs","USERTABS","users");
+        }
+        if($s_action == "cut_multiple"){
+          $this->CopyPasteHandler->add_to_queue($dn,"cut","usertabs","USERTABS","users");
+        }
+      }
+    }
+
+    /* Start pasting entries */
+    if($s_action == "editPaste"){
+      $this->start_pasting_copied_objects = TRUE;
+    }
+
+    /* Return C&P dialog */
+    if($this->start_pasting_copied_objects && $this->CopyPasteHandler->entries_queued()){
+
+      /* Load entry from queue and set base */
+      $this->CopyPasteHandler->load_entry_from_queue();
+      $this->CopyPasteHandler->SetVar("base",$this->DivListUsers->selectedBase);
+
+      /* Get dialog */
+      $data = $this->CopyPasteHandler->execute();
+
+      /* Set CPPasswordChange to s_entry which indicates that this entry requires a new password. */
+      if(isset($_POST['passwordTodo']) && ($_POST['passwordTodo'] == "new")){
+        $s_entry = $this->CopyPasteHandler->last_entry();
+        $this->reload();
+        foreach($this->blocklists as $key => $entry){
+          if($entry['dn'] == $s_entry){
+            $this->CPPasswordChange = $key;
+          }
+        }
+      }
+
+      /* Return dialog data */
+      if(!empty($data) && $this->CPPasswordChange == ""){
+        return($data);
+      }
+    }
+
+    /* Automatically disable status for pasting */
+    if(!$this->CopyPasteHandler->entries_queued()){
+      $this->start_pasting_copied_objects = FALSE;
+    }
+    return("");
+  }
+
 }
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
 ?>
index f3812ff68730085072141f387629a1bb2ffa5cd9..8b8a505a650a03510581009465d3c2d35146903a 100755 (executable)
@@ -42,7 +42,7 @@ class divListBlocklist extends MultiSelectWindow
     $this->EnableSaveButton (false);
 
     /* Dynamic action col, depending on snapshot icons */
-    $action_col_size = 60;
+    $action_col_size = 100;
     if($this->parent->snapshotEnabled()){
       $action_col_size += 20;
     }
@@ -193,7 +193,7 @@ class divListBlocklist extends MultiSelectWindow
     $editlink = "<a href='?plug=".$_GET['plug']."&amp;id=%s&amp;act=edit_entry'>%s</a>";
 
     /* Dynamic action col, depending on snapshot icons */
-    $action_col_size = 60;
+    $action_col_size = 100;
     if($this->parent->snapshotEnabled()){
       $action_col_size += 20;
     }
@@ -215,7 +215,16 @@ class divListBlocklist extends MultiSelectWindow
       if(preg_match("/w/",$acl) && preg_match("/c/",$acl)){
         $action.= $this->GetSnapShotActions($val['dn']);
       }
-      
+     
+      /* Add copy & cut icons */
+      if(preg_match("/(c.*w|w.*c)/",$acl) && $this->parent->CopyPasteHandler){
+        $action .= "<input class='center' type='image'
+          src='images/editcut.png' alt='"._("cut")."' name='cut_%KEY%' title='"._("Cut this entry")."'>&nbsp;";
+        $action.= "<input class='center' type='image'
+          src='images/editcopy.png' alt='"._("copy")."' name='copy_%KEY%' title='"._("Copy this entry")."'>&nbsp;";
+      }
+
       /* Delete entry ; requires remove access */
       if(preg_match("/d/",$acl)){
         $action.= "<input class='center' type='image' src='images/edittrash.png' alt='"._("delete")."' name='goFaxBlocklist_del_%KEY%' title='"._("Delete user")."'>";
@@ -231,7 +240,7 @@ class divListBlocklist extends MultiSelectWindow
       /* Cutted objects should be displayed in light grey */
       if(isset($this->parent->CopyPasteHandler->queue) && is_array($this->parent->CopyPasteHandler->queue)){
         foreach($this->parent->CopyPasteHandler->queue as $queue_key => $queue_data){
-          if($queue_data['dn'] == $acl_entry['dn']) {
+          if($queue_data['dn'] == $val['dn']) {
             $display = "<font color='#999999'>".$display."</font>";
             break;
           }
index c42cc55e3d0eb0170b0caaacb9e99d419e4e7fc3..71c0b81a36e0942401a2c00f8b6af48cda1526b4 100644 (file)
@@ -2,7 +2,6 @@
 if ($remove_lock){
         if(isset($_SESSION['blocklist'])){
                 $blocklist= $_SESSION['blocklist'];
-                $blocklist->remove_lock();
                 del_lock ($ui->dn);
                 sess_del ('blocklist');
         }
diff --git a/plugins/gofax/blocklists/tabs_blocklist.inc b/plugins/gofax/blocklists/tabs_blocklist.inc
new file mode 100644 (file)
index 0000000..9293903
--- /dev/null
@@ -0,0 +1,38 @@
+<?php
+
+class faxblocktabs extends tabs
+{
+  function faxblocktabs($config, $data, $dn)
+  {
+    tabs::tabs($config, $data, $dn, 'gofaxlist');
+
+    /* Add references/acls/snapshots */
+    $this->addSpecialTabs();
+  }
+
+  function save($ignore_account= FALSE)
+  {
+    $baseobject= $this->by_object['blocklistGeneric'];
+
+    /* Check for new 'dn', in order to propagate the 'dn' to all plugins */
+    $new_dn= "cn=".$baseobject->cn.",ou=gofax,ou=systems,".$baseobject->base;
+
+    /* Move group? */
+    if ($this->dn != $new_dn){
+
+      /* Write entry on new 'dn' */
+      if ($this->dn != "new"){
+        $baseobject->move($this->dn, $new_dn);
+        $this->by_object['blocklistGeneric']= $baseobject;
+      }
+
+      /* Happen to use the new one */
+      $this->dn= $new_dn;
+    }
+
+    tabs::save();
+  }
+
+}
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>