From c20cd6ffc39fa5eefbc50b35fa421b049d42b4c8 Mon Sep 17 00:00:00 2001
From: colemanw
Date: Sun, 3 Dec 2023 06:40:27 +0000
Subject: [PATCH] CiviGrant - Fix 'View Grant' page
Fixes https://lab.civicrm.org/dev/core/-/issues/4828
---
ext/civigrant/CRM/Grant/DAO/Grant.php | 4 ++--
ext/civigrant/CRM/Grant/Form/GrantView.php | 9 +++++----
ext/civigrant/CRM/Grant/Selector/Search.php | 2 +-
ext/civigrant/templates/CRM/Grant/Form/Grant.tpl | 2 --
ext/civigrant/xml/Menu/Grant.xml | 5 ++---
ext/civigrant/xml/schema/CRM/Grant/Grant.xml | 2 +-
6 files changed, 11 insertions(+), 13 deletions(-)
diff --git a/ext/civigrant/CRM/Grant/DAO/Grant.php b/ext/civigrant/CRM/Grant/DAO/Grant.php
index fda65e11e6..4b2fd2c19d 100644
--- a/ext/civigrant/CRM/Grant/DAO/Grant.php
+++ b/ext/civigrant/CRM/Grant/DAO/Grant.php
@@ -6,7 +6,7 @@
*
* Generated from civigrant/xml/schema/CRM/Grant/Grant.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:35a957c6b295a38c1fc0881e57ab1ec4)
+ * (GenCodeChecksum:8c32dd9b0de6a449d6ee2358a2b043fc)
*/
use CRM_Grant_ExtensionUtil as E;
@@ -45,7 +45,7 @@ class CRM_Grant_DAO_Grant extends CRM_Core_DAO {
*/
protected static $_paths = [
'add' => 'civicrm/grant/add?reset=1&action=add&cid=[contact_id]',
- 'view' => 'civicrm/grant/add?reset=1&action=view&id=[id]',
+ 'view' => 'civicrm/grant/view?reset=1&action=view&id=[id]',
'update' => 'civicrm/grant/add?reset=1&action=update&id=[id]',
'delete' => 'civicrm/grant/add?reset=1&action=delete&id=[id]',
];
diff --git a/ext/civigrant/CRM/Grant/Form/GrantView.php b/ext/civigrant/CRM/Grant/Form/GrantView.php
index 0b640ad2d0..9217a0ccbc 100644
--- a/ext/civigrant/CRM/Grant/Form/GrantView.php
+++ b/ext/civigrant/CRM/Grant/Form/GrantView.php
@@ -27,7 +27,6 @@ class CRM_Grant_Form_GrantView extends CRM_Core_Form {
* @return void
*/
public function preProcess() {
- $this->_contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
$context = CRM_Utils_Request::retrieve('context', 'Alphanumeric', $this);
$this->assign('context', $context);
@@ -52,8 +51,10 @@ class CRM_Grant_Form_GrantView extends CRM_Core_Form {
];
foreach ($grantTokens as $token) {
- $this->assign($token, CRM_Utils_Array::value($token, $values));
+ $this->assign($token, $values[$token] ?? NULL);
}
+ $displayName = CRM_Contact_BAO_Contact::displayName($values['contact_id']);
+ $this->assign('displayName', $displayName);
if (isset($this->_id)) {
$noteDAO = new CRM_Core_BAO_Note();
@@ -69,8 +70,8 @@ class CRM_Grant_Form_GrantView extends CRM_Core_Form {
}
// add Grant to Recent Items
- $url = CRM_Utils_System::url('civicrm/grant/add',
- "action=view&reset=1&id={$values['id']}&cid={$values['contact_id']}"
+ $url = CRM_Utils_System::url('civicrm/grant/view',
+ "action=view&reset=1&id={$values['id']}"
);
$title = CRM_Contact_BAO_Contact::displayName($values['contact_id']) . ' - ' . ts('Grant') . ': ' . CRM_Utils_Money::format($values['amount_total']) . ' (' . $grantType[$values['grant_type_id']] . ')';
diff --git a/ext/civigrant/CRM/Grant/Selector/Search.php b/ext/civigrant/CRM/Grant/Selector/Search.php
index c8252ff8e4..0f5ad52199 100644
--- a/ext/civigrant/CRM/Grant/Selector/Search.php
+++ b/ext/civigrant/CRM/Grant/Selector/Search.php
@@ -171,7 +171,7 @@ class CRM_Grant_Selector_Search extends CRM_Core_Selector_Base implements CRM_Co
self::$_links = [
CRM_Core_Action::VIEW => [
'name' => ts('View'),
- 'url' => 'civicrm/grant/add',
+ 'url' => 'civicrm/grant/view',
'qs' => 'reset=1&id=%%id%%&cid=%%cid%%&action=view&' . $extraParams,
'title' => ts('View Grant'),
'weight' => -20,
diff --git a/ext/civigrant/templates/CRM/Grant/Form/Grant.tpl b/ext/civigrant/templates/CRM/Grant/Form/Grant.tpl
index a5ecc12cce..22d7865e5c 100644
--- a/ext/civigrant/templates/CRM/Grant/Form/Grant.tpl
+++ b/ext/civigrant/templates/CRM/Grant/Form/Grant.tpl
@@ -16,8 +16,6 @@
{ts}Are you sure you want to delete this Grant?{/ts} {ts}This action cannot be undone.{/ts}
{include file="CRM/Grant/Form/Task.tpl"}
- {elseif $action eq 4}
- {include file="CRM/Grant/Form/GrantView.tpl"}
{else}
{include file="CRM/common/formButtons.tpl" location="top"}