diff --git a/plugins/gofax/blocklists/class_blocklistManagement.inc b/plugins/gofax/blocklists/class_blocklistManagement.inc
index bd8f9a7a8359d645b0c869fb206a45e298fbb17c..0e470ae16803bf77d1c82054e0d2d96e8f12ba21 100644 (file)
/* Get global filter config */
if (!is_global("blockfilter")){
- print_a($_SESSION['blocklist']);
- $uii= get_userinfo();
- $base= get_base_from_people($ui->dn);
+ $ui= get_userinfo();
+ $this->base= get_base_from_people($ui->dn);
$blockfilter= array("sendlists" => "checked",
"receivelists" => "checked",
"entry" => "*",
- "depselect" => $base,
+ "depselect" => $this->base,
"regex" => "*");
register_global("blockfilter", $blockfilter);
}else{
$blockfilter = $_SESSION["blockfilter"];
$this->base = $blockfilter['depselect'];
}
+
+ $ui= get_userinfo();
+ $acl= get_permissions ($ui->dn, $ui->subtreeACL);
+ $this->acl= get_module_permission($acl, "blocklists", $ui->dn);
}
function execute()
{
+ /* Call parent execute */
+ plugin::execute();
+
/* Get global smarty instance */
$smarty= get_smarty();
$blockfilter = get_global("blockfilter"); // contains Filter Settings
$this->reload();
}
+ /* Cancel dialog */
+ if (isset($_POST['edit_cancel']) || isset($_POST['delete_blocklist_cancel']) ||
+ isset($_POST['delete_blocklist_confirm']) || isset($_POST['delete_lock'])){
+
+ del_lock ($this->dn);
+ $this->clear_fields();
+ unset($_SESSION['objectinfo']);
+ }
+
/* Test Posts */
foreach($_POST as $key => $val){
// Post for delete
/* Create new blocklist? */
if ($s_action=="new"){
$this->clear_fields();
- $this->acl= "#all#";
$this->dn= "new";
plugin::plugin ($this->config, $this->dn);
}
/* Edit selected blocklist? */
- if ($s_action=="edit"){
+ if (($s_action=="edit") && (empty($this->dn))){
$this->clear_fields();
$this->dn=$this->blocklists[$s_entry]['dn'];
- $this->acl= get_permissions ($this->dn, $this->ui->subtreeACL);
- $this->acl= get_module_permission($this->acl, "blocklists", $this->dn);
- plugin::plugin ($this->config, $this->dn);
+ if (($user= get_lock($this->dn)) != ""){
+ $_SESSION['dn']= $this->dn;
+ //$this->dn ="";
+ return(gen_locked_message($user, $this->dn));
+ } else {
+# Lock this dn for editing
+ add_lock ($this->dn, $this->ui->dn);
- /* Load missing lists */
- if (isset($this->attrs["goFaxSBlocklist"])){
- for ($i= 0; $i<$this->attrs["goFaxSBlocklist"]["count"]; $i++){
- $this->goFaxBlocklist[]= $this->attrs["goFaxSBlocklist"][$i];
- }
- $this->type= 0;
- } elseif (isset($this->attrs["goFaxRBlocklist"])){
- for ($i= 0; $i<$this->attrs["goFaxRBlocklist"]["count"]; $i++){
- $this->goFaxBlocklist[]= $this->attrs["goFaxRBlocklist"][$i];
+ plugin::plugin ($this->config, $this->dn);
+
+ /* Load missing lists */
+ if (in_array("goFaxSBlock",$this->attrs['objectClass'])){
+ if(isset($this->attrs["goFaxSBlocklist"])){
+ for ($i= 0; $i<$this->attrs["goFaxSBlocklist"]["count"]; $i++){
+ $this->goFaxBlocklist[]= $this->attrs["goFaxSBlocklist"][$i];
+ }
+ }
+ $this->type= 0;
+ } elseif (in_array("goFaxRBlock",$this->attrs['objectClass'])){
+ if(isset($this->attrs["goFaxRBlocklist"])){
+ for ($i= 0; $i<$this->attrs["goFaxRBlocklist"]["count"]; $i++){
+ $this->goFaxBlocklist[]= $this->attrs["goFaxRBlocklist"][$i];
+ }
+ }
+ $this->type= 1;
}
- $this->type= 1;
+ $_SESSION['objectinfo']= trim($this->dn);
}
- $_SESSION['objectinfo']= trim($this->dn);
}
/* Delete blocklist requested */
/* Finally delete blocklist */
if (isset($_POST['delete_blocklist_confirm'])){
- $acl= get_permissions ($this->dn, $this->ui->subtreeACL);
- $acl= get_module_permission($acl, "blocklists", $this->dn);
- if (chkacl($acl, "all") == ""){
+ if (chkacl($this->acl, "delete") == ""){
$this->remove_from_parent();
gosa_log ("Blocklist object'".$this->dn."' has been removed");
$this->reload ();
}
}
- /* Cancel dialog */
- if (isset($_POST['edit_cancel']) || isset($_POST['delete_blocklist_cancel']) ||
- isset($_POST['delete_blocklist_confirm']) || isset($_POST['delete_lock'])){
-
- del_lock ($this->dn);
- $this->clear_fields();
- unset($_SESSION['objectinfo']);
- }
/* Handle interactions: add */
if (isset($_POST['add_number']) && $_POST['number'] != ""){
}
/* What about finish? */
- if (isset($_POST['edit_finish'])){
+ if ((isset($_POST['edit_finish'])) && (!empty($this->dn))){
$message= $this->check();
+ $this->remove_lock();
/* No errors, save object */
if (count ($message) == 0){
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->acl= "#none#";
$this->dn= "";
del_lock ($this->ui->dn);
unset($_SESSION['objectinfo']);
/* NEW LIST MANAGMENT */
$listhead = "<div style='background:#F0F0F9;padding:5px;'>".
- " <input type='image' align='middle' src='images/list_back.png' title='"._("Go up one department")."' alt='"._("Up")."' name='dep_back'> ".
- " <input type='image' src='images/list_root.png' align='middle' title='"._("Go to root department")."' name='dep_root' alt='"._("Root")."'> ".
- " <input type='image' align='middle' src='images/list_home.png' title='"._("Go to users department")."' alt='"._("Home")."' name='dep_home'> ".
- " <img src='images/list_seperator.png' align='middle' alt='' height='16' width='1'> ".
- " <input type='image' align='middle' src='images/list_new_blocklist.png' title='"._("Create new blocklist")."' alt='"._("New Blocklist")."' name='user_new'> ".
- " <img src='images/list_seperator.png' align='middle' alt='' height='16' width='1'> "._("Current base")." <select name='depselect' onChange='mainform.submit()'>$options</select>".
- " <input type='image' src='images/list_submit.png' align='middle' title='"._("Submit department")."' name='submit_department' alt='"._("Submit")."'> ".
+ " <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='depselect' 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 type='image' src='images/edit.png' alt='"._("edit")."' name='user_edit_%KEY%' title='"._("Edit user")."'>";
- $action.= "<input type='image' src='images/editdelete.png' alt='"._("delete")."' name='user_del_%KEY%' title='"._("Delete user")."'>";
+ $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")."'>";
$divlist = new divlist("faxtabs");
$divlist->SetHeader(array(
- array("string" => " "),
- array("string" => _("Blocklist name")." / "._("Department")),
- array("string" => _("Actions"), "attach" => "style='border:none'" )));
+ 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;'" )));
$divlist->SetSummary(_("This table displays faxblocklists for the selected tree."));
- $divlist->SetEntriesPerPage(20);
+ $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){
- $field1 = array("string" => "<img src='images/folder.png' alt='department'>");
- $field2 = array("string" => sprintf($linkopen,base64_encode($key),$val));
- $field3 = array("string" => " ", "attach" => "style='border:none'");
+ 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";
+ }
+ }
+
+ $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));
}
// User and Template Images
- $blockimg = "<img src='images/list_blocklist.png' alt='User' title='%s'>";
+ $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='width:20px;align:middle;'");
- $field2 = array("string" => sprintf($editlink,$key,$display),"attach"=>"title='".$val['dn']."'");
- $field3 = array("string" => preg_replace("/%KEY%/", "$key", $action),"attach" => "style='border:none; text-align:right;width:40px'");
+ $field1 = array("string" => sprintf($blockimg,$val['dn']), "attach" => "style='text-align:center;width:20px;'");
+ $field2 = array("string" => sprintf($editlink,$key,$display), "attach" => "style='' title='".$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));
}
/* Fill templating stuff */
$smarty->assign("bases", $this->config->idepartments);
- $smarty->assign("base_select", $_SESSION['blockfilter']['depselect']);//$this->base);
+ $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", "");
$this->dn= "";
$this->description= "";
$this->cn= "";
- $this->base= "";
+ $this->base= $_SESSION['blockfilter']['depselect'];
$this->goFaxBlocklist= array();
- $this->acl= "#none#";
}
function reload()
}
/* Generate blocklists */
- $res= get_list($this->ui->subtreeACL, "(&(cn=$regex)$filter)", TRUE, $base, array("*"));
+ $res= get_list($this->ui->subtreeACL, "(&(cn=$regex)$filter)", FALSE, "ou=gofax,ou=systems,".$base, array("*"));
$this->blocklists=$res;
* We also need to search for the departments
* So we are able to navigate like in konquerer
*/
- $base2 = preg_replace("/ou=people,/i","",$base);
-
+ $peopleBase = get_people_ou();
+ if(empty($peopleBase)){
+ $base2 = $base;
+ }else{
+ $base2 = preg_replace("/".$peopleBase.",/i","",$base);
+ }
+
$res3 = get_list2($this->ui->subtreeACL, "(&(|(ou=$regex)(description=$regex))(objectClass=gosaDepartment))",
TRUE, $base2, array("ou", "description"), TRUE);
}
ksort($tmp);
foreach($tmp as $value){
- if($value["description"][0]!=".."){
+ if(isset($value["description"][0])){
$this->departments[$value['dn']]=convert_department_dn2($value['dn'])." - [".$value["description"][0]."]";
}else{
- $this->departments[$value['dn']]=$value["description"][0];
+ $this->departments[$value['dn']]=convert_department_dn2($value['dn']);//$value["description"][0];
}
}
{
plugin::save_object();
- /* Save type, needed to detect objectClass */
- if (isset($_POST['type']) && chkacl($this->acl, "cn") == ""){
- $this->type= $_POST['type'];
+ if(isset($_POST['base'])){
+ $this->base = $_POST['base'];
}
-
- /* Save base, since this is no LDAP attribute */
- if (isset($_POST['base']) && chkacl($this->acl, "create") == ""){
- $this->base= $_POST['base'];
+
+ foreach($this->attributes as $attr){
+ if(isset($_POST[$attr])){
+ $this->$attr = $_POST[$attr];
+ }
}
}
-
/* Check values */
function check()
{
$new_dn= $this->dn;
}
- $ui= get_userinfo();
- $acl= get_permissions ($new_dn, $ui->subtreeACL);
- $acl= get_module_permission($acl, "blocklist", $new_dn);
- if (chkacl($acl, "create") != ""){
+ if (chkacl($this->acl, "create") != ""){
$message[]= _("You have no permissions to create a blocklist on this 'Base'.");
}
if ($this->dn == 'new'){
$ldap= $this->config->get_ldap_link();
$ldap->cd ("ou=gofax,ou=systems,".$this->config->current["BASE"]);
- $ldap->search ("(&(|(objectClass=goFaxSBlock)(objectClass=goFaxRBlock))".
- "(cn=".$this->cn."))", array("cn"));
+ $ldap->search ("(&(|(objectClass=goFaxSBlock)(objectClass=goFaxRBlock))(cn=".$this->cn."))", array("cn"));
if ($ldap->count() != 0){
$message[]= _("Specified name is already used.");
}
function save()
{
plugin::save();
+
/* Type selection */
if ($this->type == 0){
/* Write back to ldap */
$ldap= $this->config->get_ldap_link();
- $ldap->cd($ldap->getParentDir($this->dn));
- $ldap->search("cn=$this->cn");
+ $ldap->cd($this->base);
+ $ldap->search("cn=$this->cn",array("cn"));
+ $ldap->cat($this->dn);
$a= $ldap->fetch();
+
if (count($a)){
if (!isset($this->attrs["$type"."list"])){
$this->attrs["$type"."list"]= array();
}
$ldap->cd($this->dn);
+ $this->cleanup();
$ldap->modify($this->attrs);
$this->handle_post_events("modify");
} else {