CiviGrant - Fix 'View Grant' page
authorcolemanw <coleman@civicrm.org>
Sun, 3 Dec 2023 06:40:27 +0000 (06:40 +0000)
committercolemanw <coleman@civicrm.org>
Sun, 3 Dec 2023 06:44:10 +0000 (06:44 +0000)
Fixes https://lab.civicrm.org/dev/core/-/issues/4828

ext/civigrant/CRM/Grant/DAO/Grant.php
ext/civigrant/CRM/Grant/Form/GrantView.php
ext/civigrant/CRM/Grant/Selector/Search.php
ext/civigrant/templates/CRM/Grant/Form/Grant.tpl
ext/civigrant/xml/Menu/Grant.xml
ext/civigrant/xml/schema/CRM/Grant/Grant.xml

index fda65e11e660a15faeafa084c8301860ea058f7f..4b2fd2c19dea9bbcfb12037dbdcbe5fc16421b76 100644 (file)
@@ -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]',
   ];
index 0b640ad2d00a8c9c730f0e29a8c0fa33437bc673..9217a0ccbc49349bac306a22c66d90e2e5737255 100644 (file)
@@ -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']] . ')';
index c8252ff8e4315e14d6b85edf946b274ca961181e..0f5ad52199e6f0107b1eec2bd5eff4713168f934 100644 (file)
@@ -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,
index a5ecc12cce9bbbfb57ca96b74644a5a8f76ae6d9..22d7865e5cb621607be8d909ed07c6b90a30a03a 100644 (file)
@@ -16,8 +16,6 @@
          {ts}Are you sure you want to delete this Grant?{/ts} {ts}This action cannot be undone.{/ts}</p>
          <p>{include file="CRM/Grant/Form/Task.tpl"}</p>
      </div>
-  {elseif $action eq 4}
-      {include file="CRM/Grant/Form/GrantView.tpl"}
   {else}
      <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="top"}</div>
       <table class="form-layout-compressed">
index 624b230b2bb965ed1a5a2c4fe391fe7e6751612e..c226716a81e8917bb90a2d47b9fc4122f0b0cf24 100644 (file)
      <access_arguments>access CiviGrant</access_arguments>
      <page_type>1</page_type>
   </item>
-  <!-- Unused/deprecated path redundant with civicrm/grant/add -->
   <item>
-     <path>civicrm/contact/view/grant</path>
-     <page_callback>CRM_Grant_Form_Grant</page_callback>
+     <path>civicrm/grant/view</path>
+     <page_callback>CRM_Grant_Form_GrantView</page_callback>
      <access_arguments>access CiviGrant</access_arguments>
   </item>
 </menu>
index 843cc499e37125e5e42a4895c008927a9bfc9c44..68ca9577324ece5f192dda092a6553ed848402b9 100644 (file)
@@ -10,7 +10,7 @@
   <icon>fa-money</icon>
   <paths>
     <add>civicrm/grant/add?reset=1&amp;action=add&amp;cid=[contact_id]</add>
-    <view>civicrm/grant/add?reset=1&amp;action=view&amp;id=[id]</view>
+    <view>civicrm/grant/view?reset=1&amp;action=view&amp;id=[id]</view>
     <update>civicrm/grant/add?reset=1&amp;action=update&amp;id=[id]</update>
     <delete>civicrm/grant/add?reset=1&amp;action=delete&amp;id=[id]</delete>
   </paths>