From ac356f1881d3413ff55d3795059da502ac44da8f Mon Sep 17 00:00:00 2001 From: hickert Date: Tue, 27 Nov 2007 14:24:46 +0000 Subject: [PATCH] Updated blocklists. 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 | 1 + .../blocklists/class_blocklistGeneric.inc | 13 +- .../blocklists/class_blocklistManagement.inc | 153 ++++++++++++++---- .../blocklists/class_divListBlocklists.inc | 17 +- plugins/gofax/blocklists/main.inc | 1 - plugins/gofax/blocklists/tabs_blocklist.inc | 38 +++++ 6 files changed, 179 insertions(+), 44 deletions(-) create mode 100644 plugins/gofax/blocklists/tabs_blocklist.inc diff --git a/include/class_location.inc b/include/class_location.inc index 438c7fcb6..acff81c88 100644 --- a/include/class_location.inc +++ b/include/class_location.inc @@ -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", diff --git a/plugins/gofax/blocklists/class_blocklistGeneric.inc b/plugins/gofax/blocklists/class_blocklistGeneric.inc index 352fa7df1..4504dfb27 100644 --- a/plugins/gofax/blocklists/class_blocklistGeneric.inc +++ b/plugins/gofax/blocklists/class_blocklistGeneric.inc @@ -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); diff --git a/plugins/gofax/blocklists/class_blocklistManagement.inc b/plugins/gofax/blocklists/class_blocklistManagement.inc index 4985e0fc9..16fa5e08f 100644 --- a/plugins/gofax/blocklists/class_blocklistManagement.inc +++ b/plugins/gofax/blocklists/class_blocklistManagement.inc @@ -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: ?> diff --git a/plugins/gofax/blocklists/class_divListBlocklists.inc b/plugins/gofax/blocklists/class_divListBlocklists.inc index f3812ff68..8b8a505a6 100755 --- a/plugins/gofax/blocklists/class_divListBlocklists.inc +++ b/plugins/gofax/blocklists/class_divListBlocklists.inc @@ -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 = "%s"; /* 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 .= " "; + $action.= " "; + } + + /* Delete entry ; requires remove access */ if(preg_match("/d/",$acl)){ $action.= ""; @@ -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 = "".$display.""; break; } diff --git a/plugins/gofax/blocklists/main.inc b/plugins/gofax/blocklists/main.inc index c42cc55e3..71c0b81a3 100644 --- a/plugins/gofax/blocklists/main.inc +++ b/plugins/gofax/blocklists/main.inc @@ -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 index 000000000..9293903e1 --- /dev/null +++ b/plugins/gofax/blocklists/tabs_blocklist.inc @@ -0,0 +1,38 @@ +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: +?> -- 2.30.2