CRM-18492 Creating a report from 'all reports' put the creator's name into the title
authoreileen <emcnaughton@wikimedia.org>
Tue, 3 May 2016 06:55:23 +0000 (18:55 +1200)
committereileen <emcnaughton@wikimedia.org>
Wed, 18 May 2016 06:26:05 +0000 (18:26 +1200)
CRM/Core/Session.php
CRM/Report/Form.php

index 8919654be315bbe2b34f786f8feb2bedd5240e08..0cc415529084e4fc1fcfdd797e68a49fb6a2ba8b 100644 (file)
@@ -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.
    *
index 4f34d60dfe52ba3b622fc813fce59bd9a0a27138..381d1195706001d06927500327360b97a1925450 100644 (file)
@@ -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);
       }