From b2f6d534f84421373db8584cb70fac8f910b1bfd Mon Sep 17 00:00:00 2001 From: demeritcowboy Date: Thu, 20 Apr 2023 10:24:59 -0400 Subject: [PATCH] fix missing usage table --- CRM/Price/Page/Field.php | 6 +----- templates/CRM/Price/Page/Field.tpl | 6 ++---- templates/CRM/Price/Page/Set.tpl | 4 +--- templates/CRM/Price/Page/table.tpl | 6 ++++++ 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/CRM/Price/Page/Field.php b/CRM/Price/Page/Field.php index c1a70040fdef..bfa6feab97b3 100644 --- a/CRM/Price/Page/Field.php +++ b/CRM/Price/Page/Field.php @@ -230,12 +230,8 @@ public function run() { ); if ($this->_sid) { - $usedByDefaults = [ - 'civicrm_event' => FALSE, - 'civicrm_contribution_page' => FALSE, - ]; $usedBy = CRM_Price_BAO_PriceSet::getUsedBy($this->_sid); - $this->assign('usedBy', array_intersect_key($usedByDefaults, $usedBy)); + $this->assign('usedBy', $usedBy); $this->_isSetReserved = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_sid, 'is_reserved'); $this->assign('isReserved', $this->_isSetReserved); diff --git a/templates/CRM/Price/Page/Field.tpl b/templates/CRM/Price/Page/Field.tpl index ff98309a5c1f..bfe4393eaefb 100644 --- a/templates/CRM/Price/Page/Field.tpl +++ b/templates/CRM/Price/Page/Field.tpl @@ -13,16 +13,14 @@ {include file="CRM/Price/Form/DeleteField.tpl"} {elseif $action eq 1024 } {include file="CRM/Price/Form/Preview.tpl"} -{elseif ($usedBy and $action eq 8) or $usedBy.civicrm_event or $usedBy.civicrm_contribution_page} +{elseif $usedBy}
{icon icon="fa-info-circle"}{/icon} {if $action eq 8} {ts 1=$usedPriceSetTitle}Unable to delete the '%1' Price Field - it is currently in use by one or more active events or contribution pages or contributions or event templates.{/ts} {/if} - {if $usedBy.civicrm_event or $usedBy.civicrm_contribution_page or $usedBy.civicrm_event_template} - {include file="CRM/Price/Page/table.tpl"} - {/if} + {include file="CRM/Price/Page/table.tpl"}
{/if} diff --git a/templates/CRM/Price/Page/Set.tpl b/templates/CRM/Price/Page/Set.tpl index bdd496f32b8d..4e4e9e5b96ac 100644 --- a/templates/CRM/Price/Page/Set.tpl +++ b/templates/CRM/Price/Page/Set.tpl @@ -26,9 +26,7 @@ {ts 1=$usedPriceSetTitle}Unable to delete the '%1' price set - it is currently in use by one or more active events or contribution pages or contributions or event templates.{/ts} {/if} - {if $usedBy.civicrm_event or $usedBy.civicrm_contribution_page or $usedBy.civicrm_event_template} - {include file="CRM/Price/Page/table.tpl"} - {/if} + {include file="CRM/Price/Page/table.tpl"} {/if} diff --git a/templates/CRM/Price/Page/table.tpl b/templates/CRM/Price/Page/table.tpl index c7e514886ffe..a56233c6b482 100644 --- a/templates/CRM/Price/Page/table.tpl +++ b/templates/CRM/Price/Page/table.tpl @@ -23,6 +23,7 @@ {ts}Date(s){/ts} + {if array_key_exists('civicrm_event', $usedBy)} {foreach from=$usedBy.civicrm_event item=event key=id} {$event.title} @@ -31,6 +32,7 @@ {$event.startDate|crmDate}{if $event.endDate} to {$event.endDate|crmDate}{/if} {/foreach} + {/if} {/if} {if $context EQ "Contribution"} @@ -47,6 +49,7 @@ {ts}Date(s){/ts} + {if array_key_exists('civicrm_contribution_page', $usedBy)} {foreach from=$usedBy.civicrm_contribution_page item=contributionPage key=id} {$contributionPage.title} @@ -54,6 +57,7 @@ {$contributionPage.startDate|truncate:10:''|crmDate}{if $contributionPage.endDate} to {$contributionPage.endDate|truncate:10:''|crmDate}{/if} {/foreach} + {/if} {/if} {if $context EQ "EventTemplate"} @@ -69,6 +73,7 @@ {ts}Type{/ts} {ts}Public{/ts} + {if array_key_exists('civicrm_event_template', $usedBy)} {foreach from=$usedBy.civicrm_event_template item=eventTemplate key=id} {$eventTemplate.title} @@ -76,6 +81,7 @@ {if $eventTemplate.isPublic}{ts}Yes{/ts}{else}{ts}No{/ts}{/if} {/foreach} + {/if} {/if} {/foreach}