From f1b3946093c166155b88c0ba7882fddd0040c9f4 Mon Sep 17 00:00:00 2001 From: hickert Date: Thu, 1 Dec 2005 09:34:25 +0000 Subject: [PATCH] Fixed fax reports git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2169 594d385d-05f5-0310-b6e9-bd551577e9d8 --- plugins/gofax/faxreports/class_faxreport.inc | 45 ++++++++++++-------- plugins/gofax/faxreports/main.inc | 18 +++++--- 2 files changed, 39 insertions(+), 24 deletions(-) diff --git a/plugins/gofax/faxreports/class_faxreport.inc b/plugins/gofax/faxreports/class_faxreport.inc index 32e98614f..9d1adcf07 100644 --- a/plugins/gofax/faxreports/class_faxreport.inc +++ b/plugins/gofax/faxreports/class_faxreport.inc @@ -28,7 +28,7 @@ class faxreport extends plugin var $fields= array("uid", "queuing_time", "status", "sender_id", "receiver_id", "pages"); /* attribute list for save action */ - var $attributes= array(); + var $attributes= array("search_for","search_base","month","year"); var $objectclasses= array(); function faxreport ($config, $ui) @@ -55,7 +55,16 @@ class faxreport extends plugin "search_base" => $base, "search_for" => "*"); register_global("faxreportfilter", $faxfilter); - } + $this->year = date("Y"); + $this->month = date("m"); + $this->search_base = $base; + $this->search_for = "*"; + }else{ + $this->year = $_SESSION['faxreportfilter']['year']; + $this->month = $_SESSION['faxreportfilter']['month']; + $this->search_base = $_SESSION['faxreportfilter']['search_base']; + $this->search_for = $_SESSION['faxreportfilter']['search_for']; + } } function execute() @@ -74,6 +83,15 @@ class faxreport extends plugin $years[]= $y; } + /* Get template engine */ + $faxfilter= get_global("faxreportfilter"); + foreach( array("year", "month", "search_for", "search_base") as $type){ + if (isset($_POST[$type])){ + $faxfilter[$type]= $_POST[$type]; + } + $this->$type= $faxfilter[$type]; + } + register_global("faxreportfilter", $faxfilter); $smarty= get_smarty(); $smarty->assign("launchimage" , get_template_path('images/launch.png')); $smarty->assign("search_image" , get_template_path('images/search.png')); @@ -105,21 +123,17 @@ class faxreport extends plugin print_red(_("Can't select fax database for report generation!")); return($smarty->fetch(get_template_path('contents.tpl', TRUE))); } + + if (! mysql_query("SELECT * FROM faxlog;")){ + print_red(_("Can't select fax database for report generation!")); + return($smarty->fetch(get_template_path('contents.tpl', TRUE))); + } } if(isset($_POST['EntriesPerPage'])){ $this->range = $_POST['EntriesPerPage']; } - /* Get template engine */ - $faxfilter= get_global("faxreportfilter"); - foreach( array("year", "month", "search_for", "search_base") as $type){ - if (isset($_POST[$type])){ - $faxfilter[$type]= $_POST[$type]; - } - $this->$type= $faxfilter[$type]; - } - register_global("faxreportfilter", $faxfilter); /* Adapt sorting */ if (isset($_GET['sort'])){ @@ -169,7 +183,7 @@ class faxreport extends plugin if (!preg_match ("/'".$line["uid"]."'/", $this->userfilter)){ print_red (_("You have no permission to retrieve informations about this fax id!")); - return; + return($smarty->fetch(get_template_path('contents.tpl', TRUE))); } $parts= array( "id", "uid", "queuing_time", "status", "sender_id", "sender_msn", @@ -221,10 +235,8 @@ class faxreport extends plugin $fax_users= array(); while ($attrs= $ldap->fetch()){ - $acl= get_permissions ($ldap->getDN(), $this->ui->subtreeACL); - $acl= get_module_permission($acl, "fax", $ldap->getDN()); - if (chkacl ($acl, "faxReport") == ""){ + if (chkacl ($this->acl, "faxreport") == ""){ $fax_users[]= $attrs["uid"][0]; } } @@ -237,7 +249,6 @@ class faxreport extends plugin $this->userfilter= preg_replace("/OR $/", "", $this->userfilter); } - /* Perform SQL query */ if ($this->userfilter){ if ($this->sort_direction == "down"){ @@ -344,5 +355,5 @@ class faxreport extends plugin } } - +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: ?> diff --git a/plugins/gofax/faxreports/main.inc b/plugins/gofax/faxreports/main.inc index cfa7de073..24beb48aa 100644 --- a/plugins/gofax/faxreports/main.inc +++ b/plugins/gofax/faxreports/main.inc @@ -2,15 +2,19 @@ if (!$remove_lock){ /* Page header*/ - $display= print_header(get_template_path('images/reports.png'), _("FAX reports")); + $display= print_header(get_template_path('images/reports.png'), _("FAX reports")); - /* Create faxreport object on demand */ - if (!isset($_SESSION['faxreport']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){ - $_SESSION['faxreport']= new faxreport ($config, $ui); - } - $faxreport= $_SESSION['faxreport']; + /* Create faxreport object on demand */ + if (!isset($_SESSION['faxreport']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){ + $_SESSION['faxreport']= new faxreport ($config, $ui); + } + $faxreport= $_SESSION['faxreport']; - /* Execute formular */ + /* set permissions */ + $acl= get_permissions ($ui->dn, $ui->subtreeACL); + $faxreport->acl= get_module_permission($acl, "faxreport", $ui->dn); + + /* Execute formular */ $display.= $faxreport->execute (); $display.= "\n"; -- 2.30.2