add report_data() to BSE::Variables
authorTony Cook <tony@develop-help.com>
Sun, 3 Aug 2014 05:02:03 +0000 (15:02 +1000)
committerTony Cook <tony@develop-help.com>
Sun, 3 Aug 2014 05:02:28 +0000 (15:02 +1000)
site/cgi-bin/modules/BSE/Variables.pm

index a7d1969f404184bea591ebd194a218e6554ba296..19333b900e6535506d88ee4979c7d37487a940b8 100644 (file)
@@ -4,7 +4,7 @@ use Scalar::Util qw(blessed);
 use BSE::TB::Site;
 use BSE::Util::HTML;
 
-our $VERSION = "1.016";
+our $VERSION = "1.017";
 
 sub _base_variables {
   my ($self, %opts) = @_;
@@ -47,6 +47,7 @@ sub _base_variables {
        require JSON;
        return JSON->new->allow_nonref->encode($_[0]);
      },
+     report_data => \&_report_data,
     );
 }
 
@@ -252,6 +253,27 @@ sub _date_now {
   return DevHelp::Date::dh_strftime($fmt, localtime);
 }
 
+sub _report_data {
+  my ($report_name, $params, $opts) = @_;
+
+  $params ||= [];
+  $opts ||= {};
+  require DevHelp::Report;
+  my $reports = DevHelp::Report->new(BSE::Cfg->single);
+  my $msg;
+  my $result = $reports->report_data
+    (
+     $report_name,
+     BSE::DB->single,
+     \$msg,
+     $params,
+     $opts
+    )
+      or return $msg;
+
+  return $result;
+}
+
 1;
 
 =head1 NAME