From 8df5cd74fc3d610230057515dca05dea3c223d08 Mon Sep 17 00:00:00 2001 From: Julian Seidenberg Date: Tue, 10 Apr 2012 11:15:29 +1200 Subject: [PATCH] BUGFIX: SSF-168 fixing "print" and "export to CSV" button in Report Admin --- code/controllers/ReportAdmin.php | 18 ++++++++++++++++-- code/reports/Report.php | 9 +++++++-- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/code/controllers/ReportAdmin.php b/code/controllers/ReportAdmin.php index f1cb7492..7b4cafd1 100644 --- a/code/controllers/ReportAdmin.php +++ b/code/controllers/ReportAdmin.php @@ -15,7 +15,7 @@ class ReportAdmin extends LeftAndMain implements PermissionProvider { static $url_segment = 'reports'; - static $url_rule = '/$Action/$ID'; + static $url_rule = '/$ReportClass/$Action'; static $menu_title = 'Reports'; @@ -23,6 +23,10 @@ class ReportAdmin extends LeftAndMain implements PermissionProvider { static $tree_class = 'SS_Report'; + public static $url_handlers = array( + '$ReportClass/$Action' => 'handleAction' + ); + /** * Variable that describes which report we are currently viewing based on the URL (gets set in init method) * @var String @@ -35,7 +39,7 @@ class ReportAdmin extends LeftAndMain implements PermissionProvider { parent::init(); //set the report we are currently viewing from the URL - $this->reportClass = (isset($this->urlParams['ID'])) ? $this->urlParams['ID'] : null; + $this->reportClass = (isset($this->urlParams['ReportClass'])) ? $this->urlParams['ReportClass'] : null; $allReports = SS_Report::get_reports(); $this->reportObject = (isset($allReports[$this->reportClass])) ? $allReports[$this->reportClass] : null; @@ -118,6 +122,16 @@ class ReportAdmin extends LeftAndMain implements PermissionProvider { return $items; } + /** + * Returns the link to the report admin section, or the specific report that is currently displayed + * @return String + */ + public function Link($action = null) { + $link = parent::Link($action); + if ($this->reportObject) $link = $this->reportObject->getLink($action); + return $link; + } + function providePermissions() { $title = _t("ReportAdmin.MENUTITLE", LeftAndMain::menu_title_for_class($this->class)); return array( diff --git a/code/reports/Report.php b/code/reports/Report.php index 7bfbf488..2226396f 100644 --- a/code/reports/Report.php +++ b/code/reports/Report.php @@ -134,8 +134,13 @@ class SS_Report extends ViewableData { return $this->dataClass; } - function getLink() { - return 'admin/reports/show/' . $this->class; + function getLink($action = null) { + return Controller::join_links( + 'admin/reports/', + "$this->class", + '/', // trailing slash needed if $action is null! + "$action" + ); }