From: hickert Date: Mon, 4 Jan 2010 16:09:34 +0000 (+0000) Subject: Updated blocklists - not finished yet. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=0479b0a6f6f112104c835b35b7b9e0991a1e5ce3;p=gosa.git Updated blocklists - not finished yet. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@15015 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-plugins/gofax/gofax/blocklists/blocklist-filter.tpl b/gosa-plugins/gofax/gofax/blocklists/blocklist-filter.tpl new file mode 100644 index 000000000..ba7af5cde --- /dev/null +++ b/gosa-plugins/gofax/gofax/blocklists/blocklist-filter.tpl @@ -0,0 +1,33 @@ +
+

+ [F]{t}Filter{/t} +

+
+ +
+ +
+ + {$SCOPE} + + + + + + +
+ + + {$NAME} +
+ + + + + +
+ {$APPLY} +
+
diff --git a/gosa-plugins/gofax/gofax/blocklists/blocklist-filter.xml b/gosa-plugins/gofax/gofax/blocklists/blocklist-filter.xml new file mode 100644 index 000000000..df79cf0cc --- /dev/null +++ b/gosa-plugins/gofax/gofax/blocklists/blocklist-filter.xml @@ -0,0 +1,40 @@ + + + + + gofaxlist + + true + + + + + LDAP + (&(|(objectClass=goFaxSBlock)(objectClass=goFaxRBlock))$NAME) + dn + objectClass + cn + description + + auto + + + + textfield + NAME + 20 + 60 + + + (cn=*$*) + false + + LDAP + (&(|(objectClass=goFaxSBlock)(objectClass=goFaxRBlock))(cn=*$NAME*)) + cn + 0.5 + 3 + + + + diff --git a/gosa-plugins/gofax/gofax/blocklists/blocklist-list.tpl b/gosa-plugins/gofax/gofax/blocklists/blocklist-list.tpl new file mode 100644 index 000000000..b233c5874 --- /dev/null +++ b/gosa-plugins/gofax/gofax/blocklists/blocklist-list.tpl @@ -0,0 +1,31 @@ + + + + + + + +
+
+

 {$HEADLINE} {$SIZELIMIT}

+
+ +
+
+ + +
{$ROOT} {$BACK} {$HOME} {$RELOAD} {$SEPARATOR} {t}Base{/t} {$BASE}  {$SEPARATOR}  {$ACTIONS}
+
+
+ +
+
+ + + + {$LIST} +
+ {$FILTER} +
+ + diff --git a/gosa-plugins/gofax/gofax/blocklists/blocklist-list.xml b/gosa-plugins/gofax/gofax/blocklists/blocklist-list.xml new file mode 100644 index 000000000..f50623f3f --- /dev/null +++ b/gosa-plugins/gofax/gofax/blocklists/blocklist-list.xml @@ -0,0 +1,151 @@ + + + + + true + false + true + true + + gofaxlist + + 1 + + + + goFaxSBlock + gofaxlist + blocklistGeneric + plugins/gofax/images/list_blocklist.png + + + + + goFaxSBlock + gofaxlist + blocklistGeneric + plugins/gofax/images/list_blocklist.png + + + + + + |16px||250px|170px;r| + + + %{filter:objectType(dn,objectClass)} + + + + %{filter:departmentLink(row,dn,description)} + 2 + + + + %{filter:objectType(dn,objectClass)} + + + + + cn + string + %{filter:link(row,dn,"%s",cn)} + true + + + + + description + string + %{filter:link(row,dn,"%s",description)} + true + + + + + %{filter:actions(dn,row,objectClass)} + + +
+ + + + + sub + images/lists/new.png + + + + new + entry + plugins/gofax/images/list_new_blocklist.png + + + + + + separator + + + + edit + entry + images/lists/edit.png + + + + + remove + entry + images/lists/trash.png + + + + + exporter + + + + separator + + + + copypaste + + + + snapshot + + + + + + + + cp + copypaste + + + + edit + entry + images/lists/edit.png + + + + + snapshot + snapshot + + + + remove + entry + images/lists/trash.png + gofaxlist/blocklistGeneric[d] + + + + + +
diff --git a/gosa-plugins/gofax/gofax/blocklists/class_blocklistManagement.inc b/gosa-plugins/gofax/gofax/blocklists/class_blocklistManagement.inc index 99afef0db..d04958a42 100644 --- a/gosa-plugins/gofax/gofax/blocklists/class_blocklistManagement.inc +++ b/gosa-plugins/gofax/gofax/blocklists/class_blocklistManagement.inc @@ -1,513 +1,67 @@ ui = $ui; - $this->dn = ""; - $this->config = &$config; - $this->base = session::get('CurrentMainBase'); - $this->DivListBlocklist = new divListBlocklist($this->config,$this); - - /* Initialize copy&paste queue */ - if ($this->config->boolValueIsTrue("main", "copyPaste")){ - $this->CopyPasteHandler= new CopyPasteHandler($this->config); - } - } - - - function execute() + var $plHeadline = "Blocklists"; + var $plDescription = "Blocklist management"; + var $plIcon = "plugins/gofax/images/blocklists.png"; + + // Tab definition + protected $tabClass = "faxblocktabs"; + protected $tabType = "FAXBLOCKTABS"; + protected $aclCategory = "gofaxlist"; + protected $aclPlugin = "blocklistGeneric"; + protected $objectName = "blocklist"; + + function __construct($config,$ui) { - /* Call parent execute */ - plugin::execute(); - - session::set('LOCK_VARS_TO_USE',array("/^menu_action/","/^goFaxBlocklist_/","/^act$/","/^id$/","/^remove_multiple_blocklists/","/^item_selected/")); - - /*************** - Init vars - ***************/ - - /* Get global smarty instance */ - $smarty = get_smarty(); - $s_action = ""; // Contains the action to proceed - $s_entry = ""; // The value for s_action - $base_back = ""; // The Link for Backbutton - - - /*************** - Fetch posts - ***************/ - - /* Test Posts */ - foreach($_POST as $key => $val){ - // Post for delete - if(preg_match("/^goFaxBlocklist_del.*/",$key)){ - $s_action = "del"; - $s_entry = preg_replace("/^goFaxBlocklist_del_/i","",$key); - // Post for edit - }elseif(preg_match("/^goFaxBlocklist_edit_.*/",$key)){ - $s_action="edit"; - $s_entry = preg_replace("/^goFaxBlocklist_edit_/i","",$key); - // Post for new - }elseif(preg_match("/^goFaxBlocklist_new.*/",$key)){ - $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']; - } - - $s_entry = preg_replace("/_.$/","",$s_entry); + $this->config = $config; + $this->ui = $ui; + $this->storagePoints = array(get_ou("faxBlocklistRDN")); - /* 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"; - } - - - /* Create options */ - if(isset($_POST['menu_action']) && $_POST['menu_action'] == "goFaxBlocklist_new"){ - $s_action = "new"; - } - - /* handle remove from layers menu */ - if(isset($_POST['menu_action']) && preg_match("/^remove_multiple/",$_POST['menu_action'])){ - $s_action = "del_multiple"; - } - - - /*************** - Handle copy & paste - ***************/ - - $ret = $this->copyPasteHandling_from_queue($s_action,$s_entry); - if($ret){ - return($ret); - } - - - /*************** - Cancel some dialogs - ***************/ - - /* Cancel dialog */ - if (isset($_POST['edit_cancel']) || - isset($_POST['delete_blocklist_cancel']) || - isset($_POST['delete_lock'])){ - - $this->remove_lock(); - $this->dialog = NULL; - set_object_info(); - } - - - /*************** - Save blocklist - ***************/ - - /* What about finish? */ - if (isset($_POST['edit_finish']) || isset($_POST['edit_apply'])){ - - /* No errors, save object */ - $this->dialog->save_object(); - $message= $this->check(); - if (count ($message) == 0){ - - $this->dialog->save (); - - if (!isset($_POST['edit_apply'])){ - $this->remove_lock(); - $this->dn= ""; - $this->dialog = NULL; - set_object_info(); - }else{ - - /* Reinitialize tab */ - if($this->dialog instanceof tabs){ - $this->dialog->re_init(); - } - } - } else { - /* Errors found, show message */ - msg_dialog::displayChecks($message); - } - } - - - /*************** - Create a new blocklist (dialog) - ***************/ - - /* Create new blocklist? */ - if ($s_action=="new"){ - $this->dn= "new"; - $this->dialog = new faxblocktabs($this->config,$this->config->data['TABS']['FAXBLOCKTABS'],$this->dn); - $this->dialog->set_acl_base($this->base); - } - - - /*************** - Edit blocklist - ***************/ - - if ($s_action=="edit" && !is_object($this->dialog)){ - - $this->dn=$this->blocklists[$s_entry]['dn']; - - if (($user= get_lock($this->dn)) != ""){ - return(gen_locked_message($user, $this->dn,TRUE)); - }else{ - add_lock ($this->dn, $this->ui->dn); - } - set_object_info(trim($this->dn)); - $this->dialog = new faxblocktabs($this->config,$this->config->data['TABS']['FAXBLOCKTABS'],$this->dn); - $this->dialog->set_acl_base($this->dn); - } - - - /*************** - Display dialog - ***************/ - - if(is_object($this->dialog) && ($this->dialog instanceof faxblocktabs)){ - $this->dialog->save_object(); - return($this->dialog->execute()); - } - - - /******************** - Delete MULTIPLE entries requested, display confirm dialog - ********************/ - - if ($s_action=="del_multiple"){ - - $this->dns = array(); - $ids = $this->list_get_selected_items(); - - if(count($ids)){ - $disallowed = array(); - foreach($ids as $id){ - $dn = $this->blocklists[$id]['dn']; - $acl = $this->ui->get_permissions($dn, "gofaxlist/blocklistGeneric"); - if(preg_match("/d/",$acl)){ - $this->dns[$id] = $dn; - }else{ - $disallowed[] = $dn; - } - } - - if(count($disallowed)){ - msg_dialog::display(_("Permission"),msgPool::permDelete($disallowed),INFO_DIALOG); - } - - if(count($this->dns)){ - - if ($user= get_multiple_locks($this->dns)){ - return(gen_locked_message($user,$this->dns)); - } - - $dns_names = array(); - foreach($this->dns as $dn){ - $dns_names[]=LDAP::fix( $dn); - } - add_lock ($this->dns, $this->ui->dn); - - /* Lock the current entry, so nobody will edit it during deletion */ - $smarty->assign("info", msgPool::deleteInfo($dns_names,_("blocklist"))); - $smarty->assign("multiple", true); - return($smarty->fetch(get_template_path('remove.tpl', TRUE))); - } - } - } - - - /******************** - Delete MULTIPLE entries confirmed - ********************/ - - /* Confirmation for deletion has been passed. */ - if (isset($_POST['delete_multiple_blocklist_confirm'])){ - - /* Remove user by user and check acls before removeing them */ - foreach($this->dns as $key => $dn){ - $this->dn = $dn; - 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; - } else { - msg_dialog::display(_("Permission error"), msgPool::permDelete($dn), ERROR_DIALOG); - } - /* Remove lock file after successfull deletion */ - } - $this->remove_lock(); - $this->dns = array(); - $this->reload(); - } +# // Build filter +# if (session::global_is_set(get_class($this)."_filter")){ +# $filter= session::global_get(get_class($this)."_filter"); +# } else { + $filter = new filter(get_template_path("blocklist-filter.xml", true)); + $filter->setObjectStorage($this->storagePoints); +# } + $this->setFilter($filter); + // Build headpage + $headpage = new listing(get_template_path("blocklist-list.xml", true)); + $headpage->setFilter($filter); - /******************** - Delete MULTIPLE entries Canceled - ********************/ - - /* Remove lock */ - if(isset($_POST['delete_multiple_blocklist_cancel'])){ - foreach($this->dns as $key => $dn){ - $this->remove_lock(); - unset($this->dns[$key]); - } - } - - - /*************** - Remove blocklist - ***************/ - - /* Delete blocklist requested */ - if ($s_action=="del"){ - $this->dn=$this->blocklists[$s_entry]['dn']; - - /* Check locking */ - if (($user= get_lock($this->dn)) != ""){ - return(gen_locked_message($user, $this->dn)); - } else { - - // Lock this dn for editing - add_lock ($this->dn, $this->ui->dn); - $smarty->assign("info", msgPool::deleteInfo(LDAP::fix($this->dn),_("blocklist"))); - $smarty->assign("multiple", false); - return($smarty->fetch(get_template_path('remove.tpl', TRUE))); - } - } - - - /*************** - Remove blocklist confirmed - ***************/ - - /* Finally delete blocklist */ - if (isset($_POST['delete_blocklist_confirm'])){ - 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; - $this->remove_lock(); - } else { - msg_dialog::display(_("Permission error"), msgPool::permDelete(), ERROR_DIALOG); - } - } - - /*************** - Divlist dialog - ***************/ - - /* Check if there is a snapshot dialog open */ - $base = $this->DivListBlocklist->selectedBase; - if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases(),$this)){ - return($str); - } - - /* Display dialog with system list */ - $this->DivListBlocklist->parent = $this; - $this->DivListBlocklist->execute(); - - /* Add departments if subsearch is disabled */ - if(!$this->DivListBlocklist->SubSearch){ - $this->DivListBlocklist->AddDepartments($this->DivListBlocklist->selectedBase,3,1); - } - $this->reload(); - $this->DivListBlocklist->setEntries($this->blocklists); - return($this->DivListBlocklist->Draw()); - } - - - function list_get_selected_items() - { - $ids = array(); - foreach($_POST as $name => $value){ - if(preg_match("/^item_selected_[0-9]*$/",$name)){ - $id = preg_replace("/^item_selected_/","",$name); - $ids[$id] = $id; - } - } - return($ids); - } - - - /* Return departments, that will be included within snapshot detection */ - function get_used_snapshot_bases() - { - return(array(get_ou('faxBlocklistRDN').$this->DivListBlocklist->selectedBase)); - } - - - /* Reload the list of known blocklists */ - function reload() - { - /* Init some vars */ - $filter = $filter2 = ""; - $base = $this->DivListBlocklist->selectedBase; - $Regex = $this->DivListBlocklist->Regex; - $SubSearch = $this->DivListBlocklist->SubSearch; - $ShowSendBocklists = $this->DivListBlocklist->ShowSendBocklists; - $ShowReceiveBlocklists = $this->DivListBlocklist->ShowReceiveBlocklists; - $Flags = GL_SIZELIMIT; - $res = $res2 = array(); - - /* Append subsearch to Flags */ - if($SubSearch){ - $Flags |= GL_SUBSEARCH; - }else{ - $base = get_ou('faxBlocklistRDN').$base; - } - - /* Create filter */ - if ($ShowSendBocklists){ - $filter = "(&(objectClass=goFaxSBlock)(|(cn=".$Regex.")(goFaxSBlocklist=".$Regex.")))"; - $res= get_list($filter, "gofaxlist", $base,array("*"), $Flags); - } - if ($ShowReceiveBlocklists){ - $filter2= "(&(objectClass=goFaxRBlock)(|(cn=".$Regex.")(goFaxRBlocklist=".$Regex.")))"; - $res2= get_list($filter2, "gofaxlist", $base,array("*"), $Flags); - } - - $this->blocklists = array_merge($res,$res2); - - /* appen && sort */ - $tmp=array(); - foreach($this->blocklists as $tkey => $val ){ - - $acl = $this->ui ->get_permissions($base,"gofaxlist/blocklistGeneric"); - if(preg_match("/r/",$acl)){ - $tmp[strtolower($val['cn'][0]).$val['cn'][0]]=$val; - } - } - ksort($tmp); - $this->blocklists=array(); - foreach($tmp as $val){ - $this->blocklists[]=$val; - } - reset ($this->blocklists); - } - - - /* Save data to object */ - function save_object() - { - $this->DivListBlocklist->save_object(); - if(is_object($this->CopyPasteHandler)){ - $this->CopyPasteHandler->save_object(); - } - } - - - - - - function copyPasteHandling_from_queue($s_action,$s_entry) - { - /* Check if Copy & Paste is disabled */ - if(!is_object($this->CopyPasteHandler)){ - return(""); - } - - $ui = get_userinfo(); - - /* 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']; - if($s_action == "copy" && $ui->is_copyable($dn,"gofaxlist","blocklistGeneric")){ - $this->CopyPasteHandler->add_to_queue($dn,$s_action,"faxblocktabs","FAXBLOCKTABS","gofaxlist"); - } - if($s_action == "cut" && $ui->is_cutable($dn,"gofaxlist","blocklistGeneric")){ - $this->CopyPasteHandler->add_to_queue($dn,$s_action,"faxblocktabs","FAXBLOCKTABS","gofaxlist"); - } - } - - /* 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" && $ui->is_copyable($dn,"gofaxlist","blocklistGeneric")){ - $this->CopyPasteHandler->add_to_queue($dn,"copy","faxblocktabs","FAXBLOCKTABS","gofaxlist"); - } - if($s_action == "cut_multiple" && $ui->is_cutable($dn,"gofaxlist","blocklistGeneric")){ - $this->CopyPasteHandler->add_to_queue($dn,"cut","faxblocktabs","FAXBLOCKTABS","gofaxlist"); - } - } - } - - /* 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()){ - - /* Get dialog */ - $this->CopyPasteHandler->SetVar("base",$this->DivListBlocklist->selectedBase); - $data = $this->CopyPasteHandler->execute(); - - /* Return dialog data */ - if(!empty($data)){ - return($data); - } + // Add copy&paste and snapshot handler. + if ($this->config->boolValueIsTrue("main", "copyPaste")){ + $this->cpHandler = new CopyPasteHandler($this->config); } - - /* Automatically disable status for pasting */ - if(!$this->CopyPasteHandler->entries_queued()){ - $this->start_pasting_copied_objects = FALSE; + if($this->config->get_cfg_value("enableSnapshots") == "true"){ + $this->snapHandler = new SnapshotHandler($this->config); } - return(""); - } - - - /*! \brief Remove entry locks if the plugin was aborted. - */ - function remove_lock() - { - if($this->dn) del_lock($this->dn); - if(is_array($this->dns) && count($this->dns)) del_lock($this->dns); + parent::__construct($config, $ui, "blocklists", $headpage); } -} +} // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: ?> diff --git a/gosa-plugins/gofax/gofax/blocklists/main.inc b/gosa-plugins/gofax/gofax/blocklists/main.inc index 602d617a8..17dc229d6 100644 --- a/gosa-plugins/gofax/gofax/blocklists/main.inc +++ b/gosa-plugins/gofax/gofax/blocklists/main.inc @@ -1,10 +1,30 @@ remove_lock(); } } @@ -12,32 +32,25 @@ if ($remove_lock){ /* Remove this plugin from session */ if ( $cleanup ){ - session::un_set('blocklist'); + session::un_set('blocklistManagement'); }else{ - /* Create blocklist object on demand */ - if (!session::is_set('blocklist')){ - $blocklist= new blocklist($config, $ui); - $blocklist->set_acl_category("gofaxlist"); - session::set('blocklist',$blocklist); - } - $blocklist = session::get('blocklist'); - $blocklist->save_object(); - $output= $blocklist->execute(); - - /* Reset requested? */ - if (isset($_GET['reset']) && $_GET['reset'] == 1){ - session::un_set ('blocklist'); - } + /* Create blocklistManagement object on demand */ + if (!session::is_set('blocklistManagement')){ + $blocklistManagement= new blocklistManagement ($config, $ui); + session::set('blocklistManagement',$blocklistManagement); + } + $blocklistManagement = session::get('blocklistManagement'); + $display= $blocklistManagement->execute(); - /* Page header*/ - if (get_object_info() != ""){ - $display= print_header(get_template_path($blocklist->plIcon), _("Blocklist management"), "\"\"align=\"middle\" ".LDAP::fix(get_object_info())); - } else { - $display= print_header(get_template_path($blocklist->plIcon), _("Blocklist management")); - } - $display.= $output; + /* Reset requested? */ + if (isset($_GET['reset']) && $_GET['reset'] == 1){ + session::un_set ('blocklistManagement'); + } - session::set('blocklist',$blocklist); + /* Show and save dialog */ + session::set('blocklistManagement',$blocklistManagement); } + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: ?>