From 8f8647769fbd0f76f152db9ac431537061913b5f Mon Sep 17 00:00:00 2001 From: eileen Date: Tue, 3 May 2016 18:55:23 +1200 Subject: [PATCH] CRM-18492 Creating a report from 'all reports' put the creator's name into the title --- CRM/Core/Session.php | 15 +++++++++++++++ CRM/Report/Form.php | 5 ++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/CRM/Core/Session.php b/CRM/Core/Session.php index 8919654be3..0cc4155290 100644 --- a/CRM/Core/Session.php +++ b/CRM/Core/Session.php @@ -546,6 +546,21 @@ class CRM_Core_Session { return $session->get('userID'); } + /** + * Get display name of the logged in user. + * + * @return string + * + * @throws CiviCRM_API3_Exception + */ + public function getLoggedInContactDisplayName() { + $userContactID = CRM_Core_Session::singleton()->getLoggedInContactID(); + if (!$userContactID) { + return ''; + } + return civicrm_api3('Contact', 'getvalue', array('id' => $userContactID, 'return' => 'display_name')); + } + /** * Check if session is empty. * diff --git a/CRM/Report/Form.php b/CRM/Report/Form.php index 4f34d60dfe..381d119570 100644 --- a/CRM/Report/Form.php +++ b/CRM/Report/Form.php @@ -562,7 +562,10 @@ class CRM_Report_Form extends CRM_Core_Form { $this->_createNew = TRUE; $this->_params = $this->_formValues; $this->_params['view_mode'] = 'criteria'; - $this->_params['title'] = ts('(copy)') . $this->getTitle(); + $this->_params['title'] = $this->getTitle() . ts(' (copy created by %1 on %2)', array( + CRM_Core_Session::singleton()->getLoggedInContactDisplayName(), + CRM_Utils_Date::customFormat(date('Y-m-d H:i')), + )); // Do not pass go. Do not collect another chance to re-run the same query. CRM_Report_Form_Instance::postProcess($this); } -- 2.25.1