From 977ba784efece325ded2b64f5e4b33f3367d56ca Mon Sep 17 00:00:00 2001 From: hickert Date: Thu, 1 Dec 2005 08:15:20 +0000 Subject: [PATCH] Added acls for phonereports git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2167 594d385d-05f5-0310-b6e9-bd551577e9d8 --- plugins/admin/groups/acl_definition.inc | 2 +- plugins/gofon/fonreports/class_fonreport.inc | 46 ++++++++++++++------ plugins/gofon/fonreports/contents.tpl | 12 ++--- plugins/gofon/fonreports/main.inc | 19 +++++--- 4 files changed, 51 insertions(+), 28 deletions(-) diff --git a/plugins/admin/groups/acl_definition.inc b/plugins/admin/groups/acl_definition.inc index 7336581d1..3c7323c8e 100644 --- a/plugins/admin/groups/acl_definition.inc +++ b/plugins/admin/groups/acl_definition.inc @@ -287,6 +287,6 @@ $ACLD['addressbook']= array("addressbook","add", "delete", "homePhone", "mobile", "o", "postalAddress", "l", "postalCode", "st", "ou", "telephoneNumber", "facsimileTelephoneNumber", "pager"); -$ACLD['fonreport'] = array("fonreport"); +$ACLD['fonreport'] = array("fonreport", "src", "dst", "channel", "lastapp", "disposition", "duration"); $ACLD['faxreport'] = array("faxreport"); ?> diff --git a/plugins/gofon/fonreports/class_fonreport.inc b/plugins/gofon/fonreports/class_fonreport.inc index 893112c57..5b810f60b 100644 --- a/plugins/gofon/fonreports/class_fonreport.inc +++ b/plugins/gofon/fonreports/class_fonreport.inc @@ -56,9 +56,17 @@ class fonreport extends plugin /* Call parent execute */ plugin::execute(); - /* Get template engine */ + /* GVet template engine */ $smarty= get_smarty(); + foreach($this->fields as $field){ + if(chkacl($this->acl,$field)==""){ + $smarty->assign($field."ACL",""); + }else{ + $smarty->assign($field."ACL"," disabled "); + } + } + $months= array(); $months[1]= _("January"); $months[2]= _("February"); $months[3]= _("March"); $months[4]= _("April"); $months[5]= _("May"); $months[6]= _("June"); $months[7]= _("July"); $months[8]= _("August"); @@ -171,9 +179,17 @@ class fonreport extends plugin $this->userfilter= preg_replace("/OR $/", "", $this->userfilter); } - /* Perform SQL query */ -##### FIXME ACL, FILTER ###### -# if ($this->userfilter){ + $fields_str = "calldate, "; + + foreach($this->fields as $field){ + if($field == "calldate") continue; + if(chkacl($this->acl,$field)==""){ + $fields_str .= $field.", "; + } + } + + $fields_str = preg_replace("/, $/","",$fields_str); + if ($this->sort_direction == "down"){ $desc= "DESC"; } else { @@ -181,8 +197,7 @@ class fonreport extends plugin } $start= date ("YmdHis", mktime(0,0,0,$this->month,1,$this->year)); $end= date ("YmdHis", mktime(23,59,59,$this->month+1,0,$this->year)); - $query = "SELECT calldate, channel, src, clid, lastapp, lastdata, dst, ". - "disposition, duration FROM cdr ". + $query = "SELECT ".$fields_str." FROM cdr ". "WHERE calldate <= $end AND ". "calldate >= $start ORDER BY ".$this->fields[$this->sort]." $desc;"; @@ -199,20 +214,23 @@ class fonreport extends plugin } $report_list= array(); while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { + $append_str = ""; $hour= substr($line["calldate"], 11, 2); $minute=substr($line["calldate"], 14, 2); $format= _("Y-M-D"); $date= preg_replace("/Y/", substr($line["calldate"], 0, 4), $format); $date= preg_replace("/M/", substr($line["calldate"], 5, 2), $date); $date= preg_replace("/D/", substr($line["calldate"], 8, 2), $date); - - $report_list[]= "$date $hour:$minute". - "".$line["src"]."". - "".$line["dst"]."". - "".$line["channel"]."". - "".$line["lastapp"]."". - "".$line["disposition"]."". - "".$this->gen_duration($line["duration"]).""; + $append_str .= "$date $hour:$minute"; + foreach(array("src","dst","channel","lastapp","disposition") as $atr){ + if(isset($line[$atr])){ + $append_str .= "".$line[$atr].""; + } + } + if(isset($line['duration'])){ + $append_str .= "".$this->gen_duration($line["duration"]).""; + } + $report_list[] = $append_str; } $this->report_list= $report_list; diff --git a/plugins/gofon/fonreports/contents.tpl b/plugins/gofon/fonreports/contents.tpl index 3a780cac1..7a07cde8a 100644 --- a/plugins/gofon/fonreports/contents.tpl +++ b/plugins/gofon/fonreports/contents.tpl @@ -28,12 +28,12 @@ - - - - - - + {if $srcACL == ""} {/if} + {if $dstACL == ""} {/if} + {if $channelACL == ""} {/if} + {if $lastappACL == ""} {/if} + {if $dispositionACL == ""} {/if} + {if $durationACL == ""} {/if} {$search_result}
{t}Date{/t} {$mode0}{t}Source{/t} {$mode1}{t}Destination{/t} {$mode2}{t}Channel{/t} {$mode3}{t}Application{/t} {$mode4}{t}Status{/t} {$mode5}{t}Duration{/t} {$mode6}{t}Source{/t} {$mode1}{t}Destination{/t} {$mode2}{t}Channel{/t} {$mode3}{t}Application{/t} {$mode4}{t}Status{/t} {$mode5}{t}Duration{/t} {$mode6}
diff --git a/plugins/gofon/fonreports/main.inc b/plugins/gofon/fonreports/main.inc index f79641b3d..329fc1526 100644 --- a/plugins/gofon/fonreports/main.inc +++ b/plugins/gofon/fonreports/main.inc @@ -2,15 +2,20 @@ if (!$remove_lock){ /* Page header*/ - $display= print_header(get_template_path('images/phonereport.png'), _("Phone reports")); + $display= print_header(get_template_path('images/phonereport.png'), _("Phone reports")); - /* Create fonreport object on demand */ - if (!isset($_SESSION['fonreport']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){ - $_SESSION['fonreport']= new fonreport ($config, $ui); - } - $fonreport= $_SESSION['fonreport']; + /* Create fonreport object on demand */ + if (!isset($_SESSION['fonreport']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){ + $_SESSION['fonreport']= new fonreport ($config, $ui); + } + $fonreport= $_SESSION['fonreport']; - /* Execute formular */ + /* set permissions */ + $acl= get_permissions ($ui->dn, $ui->subtreeACL); + $fonreport->acl= get_module_permission($acl, "fonreport", $ui->dn); + + + /* Execute formular */ $display.= $fonreport->execute (); $display.= "\n"; -- 2.30.2