-
-
Notifications
You must be signed in to change notification settings - Fork 824
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generate button links in PHP instead of smarty for ContributionView form #22588
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,6 +46,7 @@ public function preProcess() { | |
} | ||
$this->assign('is_template', $values['is_template']); | ||
|
||
$noACL = FALSE; | ||
if (CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus() && $this->_action & CRM_Core_Action::VIEW) { | ||
$financialTypeID = CRM_Contribute_PseudoConstant::financialType($values['financial_type_id']); | ||
CRM_Financial_BAO_FinancialType::checkPermissionedLineItems($id, 'view'); | ||
|
@@ -60,7 +61,7 @@ public function preProcess() { | |
} | ||
} | ||
elseif ($this->_action & CRM_Core_Action::VIEW) { | ||
$this->assign('noACL', TRUE); | ||
$noACL = TRUE; | ||
} | ||
CRM_Contribute_BAO_Contribution::resolveDefaults($values); | ||
|
||
|
@@ -221,6 +222,77 @@ public function preProcess() { | |
$this->assign('component', 'contribution'); | ||
} | ||
$this->assignPaymentInfoBlock($id); | ||
|
||
$searchKey = NULL; | ||
if ($this->controller->_key) { | ||
$searchKey = $this->controller->_key; | ||
} | ||
if (( | ||
CRM_Core_Permission::check('edit_contributions') | ||
&& CRM_Core_Permission::check('edit contributions of type ' . $financialTypeID) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this will simplify down to that api |
||
&& !empty($canEdit) | ||
) || (CRM_Core_Permission::check('edit contributions') && $noACL)) { | ||
$urlParams = "reset=1&id={$id}&cid={$values['contact_id']}&action=update&context={$context}"; | ||
if (($context === 'fulltext' || $context === 'search') && $searchKey) { | ||
$urlParams = "reset=1&id={$id}&cid={$values['contact_id']}&action=update&context={$context}&key={$searchKey}"; | ||
} | ||
$linkButtons[] = [ | ||
'title' => ts('Edit'), | ||
'url' => 'civicrm/contact/view/contribution', | ||
'qs' => $urlParams, | ||
'icon' => 'fa-pencil', | ||
'accesskey' => 'e', | ||
]; | ||
if (!empty($paymentButtonName)) { | ||
$linkButtons[] = [ | ||
'title' => $paymentButtonName, | ||
'url' => 'civicrm/payment', | ||
'qs' => "action=add&reset=1&component=contribution&id={$id}&cid={$values['contact_id']}", | ||
'icon' => 'fa-plus-circle', | ||
]; | ||
} | ||
} | ||
|
||
if (( | ||
CRM_Core_Permission::check('delete in CiviContribute') | ||
&& CRM_Core_Permission::check('delete contributions of type ' . CRM_Contribute_PseudoConstant::financialType($financialTypeID)) | ||
&& !empty($canDelete) | ||
) || (CRM_Core_Permission::check('delete in CiviContribute') && $noACL)) { | ||
$urlParams = "reset=1&id={$id}&cid={$values['contact_id']}&action=delete&context={$context}"; | ||
if (($context === 'fulltext' || $context === 'search') && $searchKey) { | ||
$urlParams = "reset=1&id={$id}&cid={$values['contact_id']}&action=delete&context={$context}&key={$searchKey}"; | ||
} | ||
$linkButtons[] = [ | ||
'title' => ts('Delete'), | ||
'url' => 'civicrm/contact/view/contribution', | ||
'qs' => $urlParams, | ||
'icon' => 'fa-trash', | ||
]; | ||
} | ||
|
||
$pdfUrlParams = "reset=1&id={$id}&cid={$values['contact_id']}"; | ||
$emailUrlParams = "reset=1&id={$id}&cid={$values['contact_id']}&select=email"; | ||
if ($invoicing && empty($is_template)) { | ||
if (($values['contribution_status'] != 'Refunded') && ($values['contribution_status'] != 'Cancelled')) { | ||
$invoiceButtonText = ts('Download Invoice'); | ||
} | ||
else { | ||
$invoiceButtonText = ts('Download Invoice and Credit Note'); | ||
} | ||
$linkButtons[] = [ | ||
'title' => $invoiceButtonText, | ||
'url' => 'civicrm/contribute/invoice', | ||
'qs' => $pdfUrlParams, | ||
'icon' => 'fa-download', | ||
]; | ||
$linkButtons[] = [ | ||
'title' => ts('Email Invoice'), | ||
'url' => 'civicrm/contribute/invoice/email', | ||
'qs' => $emailUrlParams, | ||
'icon' => 'fa-paper-plane', | ||
]; | ||
} | ||
$this->assign('linkButtons', $linkButtons ?? []); | ||
} | ||
|
||
/** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,44 +10,6 @@ | |
<div class="crm-block crm-content-block crm-contribution-view-form-block"> | ||
<div class="action-link"> | ||
<div class="crm-submit-buttons"> | ||
{if (call_user_func(array('CRM_Core_Permission','check'), 'edit contributions') && call_user_func(array('CRM_Core_Permission', 'check'), "edit contributions of type $financial_type") && !empty($canEdit)) || | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just yay |
||
(call_user_func(array('CRM_Core_Permission','check'), 'edit contributions') && $noACL)} | ||
{assign var='urlParams' value="reset=1&id=$id&cid=$contact_id&action=update&context=$context"} | ||
{if ( $context eq 'fulltext' || $context eq 'search' ) && $searchKey} | ||
{assign var='urlParams' value="reset=1&id=$id&cid=$contact_id&action=update&context=$context&key=$searchKey"} | ||
{/if} | ||
<a class="button" href="{crmURL p='civicrm/contact/view/contribution' q=$urlParams}" accesskey="e"><span> | ||
<i class="crm-i fa-pencil" aria-hidden="true"></i> {ts}Edit{/ts}</span> | ||
</a> | ||
{if !empty($paymentButtonName)} | ||
<a class="button" href='{crmURL p="civicrm/payment" q="action=add&reset=1&component=`$component`&id=`$id`&cid=`$contact_id`"}'><i class="crm-i fa-plus-circle" aria-hidden="true"></i> {ts}{$paymentButtonName}{/ts}</a> | ||
{/if} | ||
{/if} | ||
{if (call_user_func(array('CRM_Core_Permission','check'), 'delete in CiviContribute') && call_user_func(array('CRM_Core_Permission', 'check'), "delete contributions of type $financial_type") && !empty($canDelete)) || (call_user_func(array('CRM_Core_Permission','check'), 'delete in CiviContribute') && $noACL)} | ||
{assign var='urlParams' value="reset=1&id=$id&cid=$contact_id&action=delete&context=$context"} | ||
{if ( $context eq 'fulltext' || $context eq 'search' ) && $searchKey} | ||
{assign var='urlParams' value="reset=1&id=$id&cid=$contact_id&action=delete&context=$context&key=$searchKey"} | ||
{/if} | ||
<a class="button" href="{crmURL p='civicrm/contact/view/contribution' q=$urlParams}"><span> | ||
<i class="crm-i fa-trash" aria-hidden="true"></i> {ts}Delete{/ts}</span> | ||
</a> | ||
{/if} | ||
{assign var='pdfUrlParams' value="reset=1&id=$id&cid=$contact_id"} | ||
{assign var='emailUrlParams' value="reset=1&id=$id&cid=$contact_id&select=email"} | ||
{if $invoicing && empty($is_template)} | ||
<div class="css_right"> | ||
<a class="button no-popup" href="{crmURL p='civicrm/contribute/invoice' q=$pdfUrlParams}"> | ||
<i class="crm-i fa-download" aria-hidden="true"></i> | ||
{if $contribution_status != 'Refunded' && $contribution_status != 'Cancelled' } | ||
{ts}Download Invoice{/ts}</a> | ||
{else} | ||
{ts}Download Invoice and Credit Note{/ts}</a> | ||
{/if} | ||
<a class="button" href="{crmURL p='civicrm/contribute/invoice/email' q=$emailUrlParams}"> | ||
<i class="crm-i fa-paper-plane" aria-hidden="true"></i> | ||
{ts}Email Invoice{/ts}</a> | ||
</div> | ||
{/if} | ||
{include file="CRM/common/formButtons.tpl" location="top"} | ||
</div> | ||
</div> | ||
|
@@ -328,24 +290,6 @@ | |
{/if} | ||
|
||
<div class="crm-submit-buttons"> | ||
{if (call_user_func(array('CRM_Core_Permission','check'), 'edit contributions') && call_user_func(array('CRM_Core_Permission', 'check'), "edit contributions of type $financial_type") && $canEdit) || | ||
(call_user_func(array('CRM_Core_Permission','check'), 'edit contributions') && $noACL)} | ||
{assign var='urlParams' value="reset=1&id=$id&cid=$contact_id&action=update&context=$context"} | ||
{if ( $context eq 'fulltext' || $context eq 'search' ) && $searchKey} | ||
{assign var='urlParams' value="reset=1&id=$id&cid=$contact_id&action=update&context=$context&key=$searchKey"} | ||
{/if} | ||
<a class="button" href="{crmURL p='civicrm/contact/view/contribution' q=$urlParams}" accesskey="e"><span><i class="crm-i fa-pencil" aria-hidden="true"></i> {ts}Edit{/ts}</span></a> | ||
{if $paymentButtonName} | ||
<a class="button" href='{crmURL p="civicrm/payment" q="action=add&reset=1&component=`$component`&id=`$id`&cid=`$contact_id`"}'><i class="crm-i fa-plus-circle" aria-hidden="true"></i> {ts}{$paymentButtonName}{/ts}</a> | ||
{/if} | ||
{/if} | ||
{if (call_user_func(array('CRM_Core_Permission','check'), 'delete in CiviContribute') && call_user_func(array('CRM_Core_Permission', 'check'), "delete contributions of type $financial_type") && $canDelete) || (call_user_func(array('CRM_Core_Permission','check'), 'delete in CiviContribute') && $noACL)} | ||
{assign var='urlParams' value="reset=1&id=$id&cid=$contact_id&action=delete&context=$context"} | ||
{if ( $context eq 'fulltext' || $context eq 'search' ) && $searchKey} | ||
{assign var='urlParams' value="reset=1&id=$id&cid=$contact_id&action=delete&context=$context&key=$searchKey"} | ||
{/if} | ||
<a class="button" href="{crmURL p='civicrm/contact/view/contribution' q=$urlParams}"><span><i class="crm-i fa-trash" aria-hidden="true"></i> {ts}Delete{/ts}</span></a> | ||
{/if} | ||
{include file="CRM/common/formButtons.tpl" location="bottom"} | ||
</div> | ||
</div> | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This section should wind up removable with the view bounce being done here and then all the other checks can be done with the
checkAccess
being used further down