Skip to content

Commit

Permalink
refs #40383. Fix civicrm_pcp shortening issue and save URLs to DB
Browse files Browse the repository at this point in the history
  • Loading branch information
poliphilochu committed Apr 17, 2024
1 parent 325ca8c commit eb3dce4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CRM/Contribute/Page/ContributionPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,10 @@ function run() {
if ($shorten) {
$this->assign('shorten', $shorten);
}
$shorten_pcp = CRM_Core_OptionGroup::getValue('shorten_url', 'civicrm_pcp.'.$id, 'name', 'String', 'value');
if ($shorten_pcp) {
$this->assign('shorten_pcp', $shorten_pcp);
}

// statistics
CRM_Utils_System::setTitle(ts('Dashlets')." - ".$page['title']);
Expand Down
2 changes: 1 addition & 1 deletion CRM/Core/Page/AJAX/SaveShortenURL.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ static function run() {
$pageId = CRM_Utils_Request::retrieve('page_id', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, 'REQUEST');
$pageType = CRM_Utils_Request::retrieve('page_type', 'String', CRM_Core_DAO::$_nullObject, TRUE, NULL, 'REQUEST');
$shorten = CRM_Utils_Request::retrieve('shorten', 'String', CRM_Core_DAO::$_nullObject, TRUE, NULL, 'REQUEST');
if (in_array($pageType, array('civicrm_contribution_page', 'civicrm_event.info', 'civicrm_event.register', 'civicrm_uf_group'))) {
if (in_array($pageType, array('civicrm_contribution_page', 'civicrm_pcp', 'civicrm_event.info', 'civicrm_event.register', 'civicrm_uf_group'))) {
$exists = CRM_Core_OptionGroup::getValue('shorten_url', $pageType.'.'.$pageId, 'name', 'String', 'id');
$groupParams = array(
'name' => 'shorten_url',
Expand Down
4 changes: 2 additions & 2 deletions templates/CRM/Contribute/Page/ContributionPageEdit.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@
<a href="{crmURL a=true p='civicrm/contribute/campaign' q="action=add&reset=1&cid=0&pageId=`$id`"}" target="_blank"><i class="zmdi zmdi-plus-square"></i> {ts}New personal campaign page{/ts}</a>
<div class="description">{ts}You can provide this URL to supporters for creating new Personal Campaign Pages.{/ts}</div>
</div>
<textarea name="url_to_copy_new_personal_campaign" class="url_to_copy" cols="45" rows="1" onclick="this.select(); document.execCommand('copy');" data-url-original="{$newPersonalCampaignURL}">{if $shorten}{$shorten}{else}{$newPersonalCampaignURL}{/if}</textarea>
<textarea name="url_to_copy_new_personal_campaign" class="url_to_copy" cols="45" rows="1" onclick="this.select(); document.execCommand('copy');" data-url-original="{$newPersonalCampaignURL}">{if $shorten_pcp}{$shorten_pcp}{else}{$newPersonalCampaignURL}{/if}</textarea>
<span>
<a href="#" class="button url-copy" onclick="document.querySelector('textarea[name=url_to_copy_new_personal_campaign]').select(); document.execCommand('copy'); return false;"><i class="zmdi zmdi-link"></i> {ts}Copy{/ts}</a>
</span>
<span>
<a href="#" class="button url-shorten" data-url-shorten="url_to_copy_new_personal_campaign"><i class="zmdi zmdi-share"></i> {ts}Shorten URL{/ts}</a>
<a href="#" class="button url-shorten" data-url-shorten="url_to_copy_new_personal_campaign" data-page-id="{$id}" data-page-type="civicrm_pcp"><i class="zmdi zmdi-share"></i> {ts}Shorten URL{/ts}</a>
</span>
</div>
</td>
Expand Down

0 comments on commit eb3dce4

Please sign in to comment.