summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6c1cd5c)
raw | patch | inline | side by side (parent: 6c1cd5c)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 16 May 2006 10:40:09 +0000 (10:40 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 16 May 2006 10:40:09 +0000 (10:40 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@3364 594d385d-05f5-0310-b6e9-bd551577e9d8
plugins/gofax/blocklists/class_blocklistManagement.inc | patch | blob | history |
diff --git a/plugins/gofax/blocklists/class_blocklistManagement.inc b/plugins/gofax/blocklists/class_blocklistManagement.inc
index e76415709d735899253c12e98182891a522e64d2..63f2dbb77d1af2113f53ec0a2532b2ff3838b067 100644 (file)
var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
/* blocklist attributes */
- var $cn= "";
- var $description= "";
- var $type= "";
- var $goFaxBlocklist= array();
- var $base= "";
+ var $cn = "";
+ var $description = "";
+ var $type = "";
+ var $base = "";
- /* Headpage attributes */
- var $blocklists= array();
-
- /* attribute list for save action */
- var $attributes= array("cn", "description");
- var $objectclasses= array();
+ var $goFaxBlocklist = array();
+ var $blocklists = array();
+ var $attributes = array("cn", "description");
+ var $objectclasses = array();
+ var $DivListBlocklist = NULL;
function blocklist ($config, $ui)
{
- $this->ui= $ui;
- $this->dn= "";
- $this->config= $config;
-
- if(!isset($_SESSION['CurrentMainBase'])){
- $_SESSION['CurrentMainBase'] = $this->base;
- }else{
- $this->base = $_SESSION['CurrentMainBase'];
- }
+ /* Init class */
+ $this->ui = $ui;
+ $this->dn = "";
+ $this->config = $config;
- /* Get global filter config */
- if (!is_global("blockfilter")){
- $ui= get_userinfo();
- $this->base= get_base_from_people($ui->dn);
- $blockfilter= array("sendlists" => "checked",
- "receivelists" => "checked",
- "entry" => "*",
- "regex" => "*");
- register_global("blockfilter", $blockfilter);
- }else{
- $blockfilter = $_SESSION["blockfilter"];
- }
+ $ui = get_userinfo();
+ $acl = get_permissions ($ui->dn, $ui->subtreeACL);
+ $this->acl = get_module_permission($acl, "blocklists", $ui->dn);
- $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);
}
function execute()
{
- /* Call parent execute */
- plugin::execute();
+ /* Call parent execute */
+ plugin::execute();
+
+ /***************
+ Init vars
+ ***************/
/* Get global smarty instance */
- $smarty= get_smarty();
- $blockfilter = get_global("blockfilter"); // contains Filter Settings
+ $smarty = get_smarty();
$s_action = ""; // Contains the action to proceed
$s_entry = ""; // The value for s_action
$base_back = ""; // The Link for Backbutton
- /* Start for New List Managment */
- if(isset($_GET['act'])&&($_GET['act']=="dep_open")){
- $s_action="open";
- $s_entry = base64_decode($_GET['dep_id']);
- $_SESSION['CurrentMainBase']= $this->config->departments[trim($s_entry)];
- $this->reload();
- }
- /* Cancel dialog */
- if (isset($_POST['edit_cancel']) || isset($_POST['delete_blocklist_cancel']) ||
- isset($_POST['delete_blocklist_confirm']) || isset($_POST['delete_lock'])){
-
- if(!isset($_POST['delete_blocklist_confirm'])){
- $this->clear_fields();
- }
- del_lock ($this->dn);
- unset($_SESSION['objectinfo']);
- }
+ /***************
+ Fetch posts
+ ***************/
/* Test Posts */
foreach($_POST as $key => $val){
$s_action="edit";
$s_entry = preg_replace("/user_".$s_action."_/i","",$key);
// Post for new
- }elseif(preg_match("/dep_back.*/i",$key)){
- $s_action="back";
}elseif(preg_match("/user_new.*/",$key)){
$s_action="new";
- }elseif(preg_match("/dep_home.*/i",$key)){
- $s_action="home";
}elseif(preg_match("/user_tplnew.*/i",$key)){
$s_action="new_tpl";
}elseif(preg_match("/user_chgpw.*/i",$key)){
$s_action="change_pw";
$s_entry = preg_replace("/user_chgpw_/i","",$key);
- }elseif(preg_match("/dep_root.*/i",$key)){
- $s_action="root";
}
}
-
-
if((isset($_GET['act']))&&($_GET['act']=="edit_entry")){
$s_action ="edit";
$s_entry = $_GET['id'];
$s_entry = preg_replace("/_.$/","",$s_entry);
- /* Department changed? */
- if(isset($_POST['CurrentMainBase']) && $_POST['CurrentMainBase']){
- $_SESSION['CurrentMainBase'] = $_POST['CurrentMainBase'];
- $this->reload();
- }
- /* Homebutton is posted */
- if($s_action=="home"){
- $_SESSION['CurrentMainBase'] =preg_replace("/^[^,]+,/","",$this->ui->dn);
- $_SESSION['CurrentMainBase'] =preg_replace("/^[^,]+,/","",$_SESSION['CurrentMainBase']);
- $this->reload();
- }
+ /***************
+ Cancel some dialogs
+ ***************/
- if($s_action=="root"){
- $_SESSION['CurrentMainBase'] =$this->config->current['BASE'];
- $this->reload();
- }
-
- /* If Backbutton is Posted */
- if($s_action=="back"){
- $base_back = preg_replace("/^[^,]+,/","", $_SESSION['CurrentMainBase']);
- $base_back = convert_department_dn($base_back);
-
- if(isset($this->config->departments[trim($base_back)])){
- $_SESSION['CurrentMainBase'] = $this->config->departments[trim($base_back)];
- }else{
- $_SESSION['CurrentMainBase'] = $this->config->departments["/"];
- }
- $this->reload();
- }
-
- register_global("blockfilter", $blockfilter);
+ /* Cancel dialog */
+ if (isset($_POST['edit_cancel']) ||
+ isset($_POST['delete_blocklist_cancel']) ||
+ isset($_POST['delete_blocklist_confirm']) ||
+ isset($_POST['delete_lock'])){
- /* Save data */
- $blockfilter= get_global("blockfilter");
- foreach( array( "entry", "regex") as $type){
- if (isset($_POST[$type])){
- $blockfilter[$type]= $_POST[$type];
+ if(!isset($_POST['delete_blocklist_confirm'])){
+ $this->clear_fields();
}
+ del_lock ($this->dn);
+ unset($_SESSION['objectinfo']);
}
- if (isset($_POST['CurrentMainBase'])){
- foreach( array("sendlists", "receivelists") as $type){
- if (isset($_POST[$type])) {
- $blockfilter[$type]= "checked";
- } else {
- $blockfilter[$type]= "";
- }
- }
- }
- if (isset($_GET['search'])){
- $s= mb_substr($_GET['search'], 0, 1, "UTF8")."*";
- if ($s == "**"){
- $s= "*";
- }
- $blockfilter['regex']= $s;
- }
- register_global("blockfilter", $blockfilter);
+
+ /***************
+ Cancel some dialogs
+ ***************/
/* Create new blocklist? */
if ($s_action=="new"){
plugin::plugin ($this->config, $this->dn);
}
+
+ /***************
+ Edit blocklist
+ ***************/
+
/* Edit selected blocklist? */
if (($s_action=="edit") && (empty($this->dn))){
$this->clear_fields();
}
}
+
+ /***************
+ Remove blocklist
+ ***************/
+
/* Delete blocklist requested */
if ($s_action=="del"){
$this->dn=$this->blocklists[$s_entry]['dn'];
}
}
+
+ /***************
+ Remove blocklist confirmed
+ ***************/
+
/* Finally delete blocklist */
if (isset($_POST['delete_blocklist_confirm'])){
if (chkacl($this->acl, "delete") == ""){
}
+ /***************
+ Add numer to blocklist
+ ***************/
+
+
/* Handle interactions: add */
if (isset($_POST['add_number']) && $_POST['number'] != ""){
if (is_phone_nr($_POST['number'])){
}
}
+
+ /***************
+ Delete number from list
+ ***************/
+
/* Handle interactions: delete */
if (isset($_POST['delete_number']) && count($_POST['numbers']) > 0){
$this->delNumber ($_POST['numbers']);
}
+
+ /***************
+ Edit finished
+ ***************/
+
/* What about finish? */
if ((isset($_POST['edit_finish'])) && (!empty($this->dn))){
$message= $this->check();
if ($this->dn == "new"){
$this->dn= "cn=$this->cn,ou=gofax,ou=systems,".$this->base;
}
-
+
$this->save ();
gosa_log ("Blocklist object'".$this->dn."' has been saved");
$this->dn= "";
}
}
- /* Headpage or normal plugin screen? */
- if ($this->dn == ""){
- /* Check sorting variable */
- $this->reload();
-
- /* Check for exeeded sizelimit */
- if (($message= check_sizelimit()) != ""){
- return($message);
- }
-
- $options= "";
- foreach ($this->config->idepartments as $key => $value){
- if ($_SESSION['CurrentMainBase'] == $key){
- $options.= "<option selected value='$key'>$value</option>";
- } else {
- $options.= "<option value='$key'>$value</option>";
- }
- }
-
-
-
- /* NEW LIST MANAGMENT */
- $listhead = "<div style='background:#F0F0F9;padding:5px;'>".
- " <input class='center' type='image' src='images/list_root.png' align='middle' title='"._("Go to root department")."' name='dep_root' alt='"._("Root")."'> ".
- " <input class='center' type='image' align='middle' src='images/list_back.png' title='"._("Go up one department")."' alt='"._("Up")."' name='dep_back'> ".
- " <input class='center' type='image' align='middle' src='images/list_home.png' title='"._("Go to users department")."' alt='"._("Home")."' name='dep_home'> ".
- " <input class='center' type='image' src='images/list_reload.png' align='middle' title='"._("Reload list")."' name='submit_department' alt='"._("Submit")."'> ".
- " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'> ".
- " <input class='center' type='image' align='middle' src='images/list_new_blocklist.png' title='"._("Create new blocklist")."' alt='"._("New Blocklist")."' name='user_new'> ".
- " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'> "._("Base")." <select name='CurrentMainBase' onChange='mainform.submit()' class='center'>$options</select>".
- " <input class='center' type='image' src='images/list_submit.png' align='middle' title='"._("Submit department")."' name='submit_department' alt='"._("Submit")."'> ".
- "</div>";
-
- $action= "<input class='center' type='image' src='images/edit.png' alt='"._("edit")."' name='user_edit_%KEY%' title='"._("Edit user")."'>";
- $action.= "<input class='center' type='image' src='images/edittrash.png' alt='"._("delete")."' name='user_del_%KEY%' title='"._("Delete user")."'>";
+ /***************
+ Object currently in edit
+ ***************/
- $divlist = new divlist("faxtabs");
- $divlist->SetHeader(array(
- array("string" => " ", "attach" => "style='text-align:center;width:20px;'"),
- array("string" => _("Blocklist name")." / "._("Department"), "attach" => "style=''"),
- array("string" => _("Actions"), "attach" => "style='width:60px;border-right:0px;text-align:right;'" )));
+ if($this->dn){
-
- $divlist->SetSummary(_("This table displays faxblocklists for the selected tree."));
- $divlist->SetEntriesPerPage(0);
-
- // Defining Links
- $linkopen = "<a href='?plug=".$_GET['plug']."&act=dep_open&dep_id=%s'>%s</a>";
- foreach($this->departments as $key=> $val){
- if(!isset($this->config->departments[trim($key)])){
- $this->config->departments[trim($key)]="";
- }
-
- $non_empty="";
- $keys= str_replace("/","\/",$key);
- foreach($this->config->departments as $keyd=>$vald ){
- if(preg_match("/".$keys."\/.*/",$keyd)){
- $non_empty="full";
- }
+ /* Set base */
+ if ($this->base == ""){
+ if ($this->dn == "new"){
+ $ui= get_userinfo();
+ $this->base= dn2base($ui->dn);
+ } else {
+ $this->base= preg_replace ("/^[^,]+,[^,]+,[^,]+,/", "", $this->dn);
}
+ }
- $field1 = array("string" => "<img src='images/".$non_empty."folder.png' alt='department'>", "attach" => "style='text-align:center;width:20px;'");
- $field2 = array("string" => sprintf($linkopen,base64_encode($key),$val), "attach" => "style=''");
- $field3 = array("string" => " ", "attach" => "style='width:60px;border-right:0px;text-align:right;'");
- $divlist->AddEntry(array($field1,$field2,$field3));
+ /* Fill templating stuff */
+ $smarty->assign("bases", $this->config->idepartments);
+ $smarty->assign("base_select", $this->base);
+ $smarty->assign("types", array(0 => _("send"), 1 => _("receive")));
+ if ($this->dn == "new" || preg_match ("/,ou=incoming,/", $this->dn)){
+ $smarty->assign("selectmode", "");
+ $smarty->assign("mode", "");
+ } else {
+ $smarty->assign("selectmode", "disabled");
+ $smarty->assign("mode", "readonly");
+ }
+ foreach(array("cn", "description", "type", "goFaxBlocklist") as $val){
+ $smarty->assign("$val", $this->$val);
+ $smarty->assign("$val"."ACL", chkacl($this->acl, "$val"));
}
- // User and Template Images
- $blockimg = "<img class='center' src='images/list_blocklist.png' alt='User' title='%s'>";
- $editlink = "<a href='?plug=".$_GET['plug']."&id=%s&act=edit_entry'>%s</a>";
-
- foreach($this->blocklists as $key => $val){
- // Generate Array to Add
- $display= "[".$val["cn"][0]."]";
- $field1 = array("string" => sprintf($blockimg,$val['dn']), "attach" => "style='text-align:center;width:20px;'");
- $field2 = array("string" => sprintf($editlink,$key,$display), "attach" => "style='' title='dn: ".@LDAP::fix($val['dn'])."'");
- $field3 = array("string" => preg_replace("/%KEY%/", "$key", $action), "attach" => "style='width:60px;border-right:0px;text-align:right;'");
- $divlist->AddEntry( array($field1,$field2,$field3));
+ /* Lock blocklist type for non new entries */
+ if ($this->dn != "new"){
+ $smarty->assign('typeACL', "disabled");
}
/* Show main page */
- $smarty->assign("blocklistshead", $listhead);
- $smarty->assign("blocklists", $divlist->DrawList());
- $smarty->assign("search_image", get_template_path('images/search.png'));
- $smarty->assign("tree_image", get_template_path('images/tree.png'));
- $smarty->assign("infoimage", get_template_path('images/info.png'));
- $smarty->assign("launchimage", get_template_path('images/launch.png'));
- $smarty->assign("apply", apply_filter());
- foreach( array( "entry", "regex", "sendlists", "receivelists") as $type){
- $smarty->assign("$type", $blockfilter[$type]);
- }
- $smarty->assign("deplist", $this->config->idepartments);
- $smarty->assign("alphabet", generate_alphabet());
- $smarty->assign("hint", print_sizelimit_warning());
- $smarty->assign("CurrentMainBase",$_SESSION['CurrentMainBase']);
- return($smarty->fetch(get_template_path('headpage.tpl', TRUE)));
- }
+ return($smarty->fetch (get_template_path('generic.tpl', TRUE)));
- /* Set base */
- if ($this->base == ""){
- if ($this->dn == "new"){
- $ui= get_userinfo();
- $this->base= dn2base($ui->dn);
- } else {
- $this->base= preg_replace ("/^[^,]+,[^,]+,[^,]+,/", "", $this->dn);
- }
- }
+ }else{
- /* Fill templating stuff */
- $smarty->assign("bases", $this->config->idepartments);
- $smarty->assign("base_select", $this->base);
- $smarty->assign("types", array(0 => _("send"), 1 => _("receive")));
- if ($this->dn == "new" || preg_match ("/,ou=incoming,/", $this->dn)){
- $smarty->assign("selectmode", "");
- $smarty->assign("mode", "");
- } else {
- $smarty->assign("selectmode", "disabled");
- $smarty->assign("mode", "readonly");
- }
- foreach(array("cn", "description", "type", "goFaxBlocklist") as $val){
- $smarty->assign("$val", $this->$val);
- $smarty->assign("$val"."ACL", chkacl($this->acl, "$val"));
- }
+ /***************
+ Divlist dialog
+ ***************/
- /* Lock blocklist type for non new entries */
- if ($this->dn != "new"){
- $smarty->assign('typeACL', "disabled");
- }
+ /* Display dialog with system list */
+ $this->DivListBlocklist->execute();
- /* Show main page */
- return($smarty->fetch (get_template_path('generic.tpl', TRUE)));
+ /* Add departments if subsearch is disabled */
+ if(!$this->DivListBlocklist->SubSearch){
+ $this->DivListBlocklist->AddDepartments($this->DivListBlocklist->selectedBase);
+ }
+ $this->reload();
+ $this->DivListBlocklist->setEntries($this->blocklists);
+ return($this->DivListBlocklist->Draw());
+ }
}
+
+ /* Clear garbage from edited lists */
function clear_fields()
{
$this->dn= "";
$this->goFaxBlocklist= array();
}
+
+ /* Reload the list of known blocklists */
function reload()
{
- /* Get config */
- $blockfilter= get_global('blockfilter');
-
- /* Set base for all searches */
- $base= $_SESSION['CurrentMainBase'];
- $filter= "";
-
- /* Regex filter? */
- if ($blockfilter['regex'] != ""){
- $regex= $blockfilter['regex'];
- } else {
- $regex= "*";
- }
-
- /* Entry filter? */
- /* Get list of blocklists to be shown */
- if ($blockfilter['sendlists'] == "checked"){
- $filter.= "(objectClass=goFaxSBlock)";
- }
- if ($blockfilter['receivelists'] == "checked"){
- $filter.= "(objectClass=goFaxRBlock)";
- }
- if ($filter != ""){
- $filter= "(|$filter)";
- }
-
- if ($blockfilter['entry'] != "" && $blockfilter['entry'] != "*"){
- $filter.= "(|(goFaxSBlocklist=".$blockfilter['entry'].")(goFaxRBlocklist=".$blockfilter['entry']."))";
- }
-
- /* Generate blocklists */
- //FIXME: No GL_SIZELIMIT?
- $res= get_list("(&(cn=$regex)$filter)", $this->ui->subtreeACL, "ou=gofax,ou=systems,".$base,
- array("*"), GL_NONE);
-
- $this->blocklists=$res;
-
- /* NEW LIST MANAGMENT
- * We also need to search for the departments
- * So we are able to navigate like in konquerer
- */
- $peopleBase = get_people_ou();
- if(empty($peopleBase)){
- $base2 = $base;
+ /* 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{
- $base2 = preg_replace("/".$peopleBase.",/i","",$base);
- }
-
- $res3= get_list("(&(|(ou=$regex)(description=$regex))(objectClass=gosaDepartment))", $this->ui->subtreeACL,
- $base2, array("ou", "description"), GL_SIZELIMIT | GL_CONVERT);
+ $base = "ou=gofax,ou=systems,".$base;
+ }
- $this->departments= array();
- $tmp = array();
- foreach ($res3 as $value){
- $tmp[strtolower($value['dn']).$value['dn']]=$value;
+ /* Create filter */
+ if ($ShowSendBocklists){
+ $filter = "(&(objectClass=goFaxSBlock)(|(cn=".$Regex.")(goFaxSBlocklist=".$Regex.")))";
+ $res= get_list($filter, $this->ui->subtreeACL, $base,array("*"), $Flags);
}
- ksort($tmp);
- foreach($tmp as $value){
- if(isset($value["description"][0])){
- $this->departments[$value['dn']]= get_sub_department($value['dn'])." - [".$value["description"][0]."]";
- }else{
- $this->departments[$value['dn']]= get_sub_department($value['dn']);//$value["description"][0];
- }
+ if ($ShowReceiveBlocklists){
+ $filter2= "(&(objectClass=goFaxRBlock)(|(cn=".$Regex.")(goFaxRBlocklist=".$Regex.")))";
+ $res2= get_list($filter2, $this->ui->subtreeACL, $base,array("*"), $Flags);
}
+
+ $this->blocklists = array_merge($res,$res2);
- /* END NEW LIST MANAGMENT
- */
+ /* appen && sort */
$tmp=array();
foreach($this->blocklists as $tkey => $val ){
$tmp[strtolower($val['cn'][0]).$val['cn'][0]]=$val;
reset ($this->blocklists);
}
+
function remove_from_parent()
{
$ldap= $this->config->get_ldap_link();
/* Save data to object */
function save_object()
{
+ $this->DivListBlocklist->save_object();
plugin::save_object();
if(isset($_POST['base'])){
$this->base = $_POST['base'];
}
-
foreach($this->attributes as $attr){
if(isset($_POST[$attr])){
$this->$attr = $_POST[$attr];
}
}
+
/* Check values */
function check()
{
function save()
{
plugin::save();
-
+
/* Type selection */
if ($this->type == 0){
$ldap->search("cn=$this->cn",array("cn"));
$ldap->cat($this->dn, array('dn'));
$a= $ldap->fetch();
-
+
if (count($a)){
if (!isset($this->attrs["$type"."list"])){
$this->attrs["$type"."list"]= array();
}
+ /* Add number */
function addNumber($number)
{
if (!in_array($number, $this->goFaxBlocklist)){
}
}
+
+ /* Remove number from list */
function delNumber($numbers)
{
$tmp= array();
$this->goFaxBlocklist= $tmp;
}
+
+ /* Delete lock */
function remove_lock()
{
if (isset($this->dn)){