From 2c588e015deb5190bb4eedcee94db1f379c741b7 Mon Sep 17 00:00:00 2001 From: hickert Date: Fri, 11 Nov 2005 08:35:37 +0000 Subject: [PATCH] Added department selection and checkboxes to add predifined lists git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@1915 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../gofax/faxaccount/class_gofaxAccount.inc | 156 +++++++++++++++--- 1 file changed, 129 insertions(+), 27 deletions(-) diff --git a/plugins/gofax/faxaccount/class_gofaxAccount.inc b/plugins/gofax/faxaccount/class_gofaxAccount.inc index 69f71772d..1bf67f713 100644 --- a/plugins/gofax/faxaccount/class_gofaxAccount.inc +++ b/plugins/gofax/faxaccount/class_gofaxAccount.inc @@ -11,6 +11,8 @@ class gofaxAccount extends plugin var $cli_description= "Some longer text\nfor help"; var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser"); + var $departments; + /* Fax attributes */ var $goFaxDeliveryMode= ""; var $facsimileTelephoneNumber= ""; @@ -44,6 +46,10 @@ class gofaxAccount extends plugin /* General initialization */ plugin::plugin ($config, $dn); + if(!isset($_SESSION["Fax_Filter"])){ + $_SESSION['Fax_Filter']['depselect'] = $this->config->current['BASE']; + } + if ($dn != "new"){ /* Get arrays */ foreach (array("goFaxRBlocklist", "goFaxRBlockgroups", "goFaxSBlocklist", @@ -87,6 +93,15 @@ class gofaxAccount extends plugin /* Call parent execute */ plugin::execute(); + if((isset($_GET['act']))&&($_GET['act']=="dep_open")){ + + if(strlen(base64_decode($_GET['dep_id']))>= strlen($this->config->current['BASE'])){ + $_SESSION['Fax_Filter']['depselect']= base64_decode($_GET['dep_id']); + }else{ + $_SESSION['Fax_Filter']['depselect']= $this->config->current['BASE']; + } + } + /* Load smarty stuff */ $smarty= get_smarty(); @@ -202,12 +217,17 @@ class gofaxAccount extends plugin } /* Add list to blocklist */ - if (isset($_POST['add_blocklist']) && isset($_POST['predefined_list'])){ - $this->current_blocklist= array_merge($this->current_blocklist, - $_POST['predefined_list']); + if (isset($_POST['add_blocklist'])){ + foreach($_POST as $name => $value){ + if(preg_match("/ADDLIST_/i",$name)){ + $this->current_blocklist= array_merge($this->current_blocklist, array(base64_decode($value))); + + } + } $this->current_blocklist= array_unique($this->current_blocklist); sort($this->current_blocklist); reset($this->current_blocklist); + } /* Add list to blocklist */ @@ -329,9 +349,6 @@ class gofaxAccount extends plugin $attrs['facsimileTelephoneNumber'][0]."]"; } - - - /* Show dialog */ $smarty->assign("search_image", get_template_path('images/search.png')); $smarty->assign("usearch_image", get_template_path('images/search_user.png')); @@ -359,27 +376,72 @@ class gofaxAccount extends plugin /* Manage incoming blocklists */ if ($this->in_blocklist_dialog){ + + $base = $_SESSION['Fax_Filter']['depselect']; + $ldap->cd($base); + $ldap->search ("(objectClass=goFaxRBlock)",array("cn","description")); while ($attrs= $ldap->fetch()){ - $list[$attrs['cn'][0]]= - $attrs['description'][0]. - " [".$attrs['cn'][0]."]"; + if(isset($attrs['description'][0])){ + $list[$attrs['cn'][0]]= + $attrs['description'][0]. + " [".$attrs['cn'][0]."]"; + }else{ + $list[$attrs['cn'][0]]= $attrs['cn'][0]; + } } $divSel = new divSelectBox("divSelectPredefined"); $divSel->setHeight(300); $divSel->setWidth(350); - + + /* NEW LIST MANAGMENT + * We also need to search for the departments + * So we are able to navigate like in konquerer + */ + + $tmp = array(); + $this->departments= array(); + $base = $_SESSION['Fax_Filter']['depselect']; + $ldap->ls("(objectClass=gosaDepartment)",$base); + + $base_back = preg_replace("/^[^,]+,/","",$base); + + if(strlen($base_back)>= strlen($this->config->current['BASE'])){ + $this->departments[preg_replace("/^[^,]+,/","",$base)] = ".. - ["._("back")."]"; + } + while($value = $ldap->fetch()){ + if($value["description"][0]!=".."){ + $this->departments[$value['dn']]=convert_department_dn($value['dn'])." - [".$value["description"][0]."]"; + }else{ + $this->departments[$value['dn']]=$value["description"][0]; + } + } + /* END NEW LIST MANAGMENT + */ + + // Defining Links + $linkopen = "%s"; + + /* Insert departments in divlist*/ + foreach($this->departments as $key=> $val){ + + if(!isset($this->config->departments[trim($key)])){ + $this->config->departments[trim($key)]=""; + } + + $field1 = array("string" => "department","attach"=>"style='width:16px;text-align:center;'"); + $field2 = array("string" => sprintf($linkopen,base64_encode($key),$val),"attach"=>" colspan=2 style='border:none'"); + $divSel->AddEntry(array($field1,$field2)); + } + foreach($list as $entry => $value){ $divSel->AddEntry(array( - array("string"=>" - <"._("Add").""), + array("string"=>""), array("string"=>$entry), array("string"=>$value,"attach"=>"style='border:0px;'") )); } - - /* Show dialog */ $smarty->assign("cblocklist", $this->current_blocklist); @@ -393,20 +455,24 @@ class gofaxAccount extends plugin $smarty->assign("department", ""); } - - $display.= $smarty->fetch (get_template_path('lists.tpl', TRUE, dirname(__FILE__))); return ($display); } /* Manage outgoing blocklists */ + if ($this->out_blocklist_dialog){ - $ldap->search ("(objectClass=goFaxSBlock)"); + + $base = $_SESSION['Fax_Filter']['depselect']; + $ldap->cd($base); + + $ldap->search ("(objectClass=goFaxSBlock)",array("cn","description")); while ($attrs= $ldap->fetch()){ - if (isset($attrs['description'][0])){ - $list[$attrs['cn'][0]]= $attrs['cn'][0]. - " [".$attrs['description'][0]."]"; - } else { + if(isset($attrs['description'][0])){ + $list[$attrs['cn'][0]]= + $attrs['description'][0]. + " [".$attrs['cn'][0]."]"; + }else{ $list[$attrs['cn'][0]]= $attrs['cn'][0]; } } @@ -415,13 +481,49 @@ class gofaxAccount extends plugin $divSel->setHeight(300); $divSel->setWidth(350); + /* NEW LIST MANAGMENT + * We also need to search for the departments + * So we are able to navigate like in konquerer + */ + $tmp = array(); + $this->departments= array(); + $ldap->ls("(objectClass=gosaDepartment)",$base); + + $base_back = preg_replace("/^[^,]+,/","",$base); + + if(strlen($base_back)>= strlen($this->config->current['BASE'])){ + $this->departments[preg_replace("/^[^,]+,/","",$base)] = ".. - ["._("back")."]"; + } + while($value = $ldap->fetch()){ + if(isset($value["description"][0])){ + $this->departments[$value['dn']]=convert_department_dn($value['dn'])." - [".$value["description"][0]."]"; + }else{ + $this->departments[$value['dn']]=$value["description"][0]; + } + } + /* END NEW LIST MANAGMENT + */ + + // Defining Links + $linkopen = "%s"; + + /* Insert departments in divlist*/ + foreach($this->departments as $key=> $val){ + if(!isset($this->config->departments[trim($key)])){ + $this->config->departments[trim($key)]=""; + } + + $field1 = array("string" => "department","attach"=>"style='width:16px;text-align:center;'"); + $field2 = array("string" => sprintf($linkopen,base64_encode($key),$val),"attach"=>" colspan=2 style='border:none'"); + $divSel->AddEntry(array($field1,$field2)); + } + foreach($list as $entry => $value){ $divSel->AddEntry(array( - array("string"=>" - <"._("Add").""), - array("string"=>$entry), - array("string"=>$value,"attach"=>"style='border:0px;'") - )); + array("string"=>""), + array("string"=>$entry), + array("string"=>$value,"attach"=>"style='border:0px;'") + )); } @@ -435,7 +537,7 @@ class gofaxAccount extends plugin } else { $smarty->assign("department", ""); } - + $display.= $smarty->fetch (get_template_path('lists.tpl', TRUE, dirname(__FILE__))); return ($display); -- 2.30.2