Whilst the contact image tooltip is set to preventDefault, it is still possible to copy the URL or open in new tab.
This change ensures that the correct URL is set in these situations.
Backwards compatiability is retained for third parties using the crm-tooltip class without the new data attribute.
* Contact id.
* @param bool $addProfileOverlay
* If profile overlay class should be added.
+ * @param string $contactUrl
+ * URL to the contact page. Defaults to civicrm/contact/view
*
* @return string
* @throws \CRM_Core_Exception
*/
- public static function getImage($contactType, $urlOnly = FALSE, $contactId = NULL, $addProfileOverlay = TRUE) {
+ public static function getImage($contactType, $urlOnly = FALSE, $contactId = NULL, $addProfileOverlay = TRUE, $contactUrl = NULL) {
+
static $imageInfo = [];
$contactType = CRM_Utils_Array::explodePadded($contactType);
$summaryOverlayProfileId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', 'summary_overlay', 'id', 'name');
}
+ $contactURL = $contactUrl ?: CRM_Utils_System::url('civicrm/contact/view',
+ "reset=1&cid={$contactId}"
+ );
$profileURL = CRM_Utils_System::url('civicrm/profile/view',
"reset=1&gid={$summaryOverlayProfileId}&id={$contactId}&snippet=4&is_show_email_task=1"
);
- $imageInfo[$contactType]['summary-link'] = '<a href="' . $profileURL . '" class="crm-summary-link">' . $imageInfo[$contactType]['image'] . '</a>';
+ $imageInfo[$contactType]['summary-link'] = '<a href="' . $contactURL . '" data-tooltip-url="' . $profileURL . '" class="crm-summary-link">' . $imageInfo[$contactType]['image'] . '</a>';
}
else {
$imageInfo[$contactType]['summary-link'] = $imageInfo[$contactType]['image'];
// allow components to add more actions
CRM_Core_Component::searchAction($row, $result->contact_id);
+ $contactUrl = CRM_Utils_System::url('civicrm/contact/view',
+ "reset=1&cid={$result->contact_id}&key={$this->_key}&context={$this->_context}"
+ );
$row['contact_type'] = CRM_Contact_BAO_Contact_Utils::getImage($result->contact_sub_type ? $result->contact_sub_type : $result->contact_type,
FALSE,
- $result->contact_id
+ $result->contact_id,
+ TRUE,
+ $contactUrl
);
$row['contact_type_orig'] = $result->contact_sub_type ? $result->contact_sub_type : $result->contact_type;
CRM_Core_Component::searchAction($row, $row['contact_id']);
if (!empty($row['contact_type_orig'])) {
+ $contactUrl = CRM_Utils_System::url('civicrm/contact/view',
+ "reset=1&cid={$row['contact_id']}&key={$this->_key}&context={$this->_context}"
+ );
$row['contact_type'] = CRM_Contact_BAO_Contact_Utils::getImage($row['contact_type_orig'],
- FALSE, $row['contact_id']);
+ FALSE,
+ $row['contact_id'],
+ TRUE,
+ $contactUrl
+ );
}
}
}
$(this).addClass('crm-tooltip-down');
}
if (!$(this).children('.crm-tooltip-wrapper').length) {
+ var tooltipContents = $(this)[0].hasAttribute('data-tooltip-url') ? $(this).attr('data-tooltip-url') : this.href;
$(this).append('<div class="crm-tooltip-wrapper"><div class="crm-tooltip"></div></div>');
$(this).children().children('.crm-tooltip')
.html('<div class="crm-loading-element"></div>')
- .load(this.href);
+ .load(tooltipContents);
}
})
.on('mouseleave', 'a.crm-summary-link', function () {
$this->assertEquals([
[
'contact_id' => '3',
- 'contact_type' => '<a href="/index.php?q=civicrm/profile/view&reset=1&gid=7&id=3&snippet=4&is_show_email_task=1" class="crm-summary-link"><div class="icon crm-icon Individual-icon"></div></a>',
+ 'contact_type' => '<a href="/index.php?q=civicrm/contact/view&reset=1&cid=3" data-tooltip-url="/index.php?q=civicrm/profile/view&reset=1&gid=7&id=3&snippet=4&is_show_email_task=1" class="crm-summary-link"><div class="icon crm-icon Individual-icon"></div></a>',
'sort_name' => 'Anderson, Anthony',
'display_name' => 'Mr. Anthony Anderson II',
'activity_id' => '1',
$_REQUEST['return'] = TRUE;
$json = CRM_Financial_Page_AJAX::getFinancialTransactionsList();
$json = str_replace(rtrim(CIVICRM_UF_BASEURL, '/'), 'http://FIX ME', $json);
- $this->assertEquals('{"sEcho": 1, "iTotalRecords": 1, "iTotalDisplayRecords": 1, "aaData": [ ["","<a href=\"/index.php?q=civicrm/profile/view&reset=1&gid=7&id=3&snippet=4&is_show_email_task=1\" class=\"crm-summary-link\"><div'
+ $this->assertEquals('{"sEcho": 1, "iTotalRecords": 1, "iTotalDisplayRecords": 1, "aaData": [ ["","<a href=\"/index.php?q=civicrm/contact/view&reset=1&cid=3\" data-tooltip-url=\"/index.php?q=civicrm/profile/view&reset=1&gid=7&id=3&snippet=4&is_show_email_task=1\" class=\"crm-summary-link\"><div'
. ' class=\"icon crm-icon Individual-icon\"></div></a>","<a href=/index.php?q=civicrm/contact/view&reset=1&cid=3>Anderson, Anthony</a>","$ 100.00","12345","' . CRM_Utils_Date::customFormat(date('Ymd')) . ' 12:00 AM","' . CRM_Utils_Date::customFormat(date('Ymd')) . ' 12:00 AM",'
. '"Credit Card","Completed","Donation","<span><a href=\"/index.php?q=civicrm/contact/view/contribution&reset=1&id=1&cid=3&action=view&context=contribution&'
. 'selectedChild=contribute\" class=\"action-item crm-hover-button\" title=\'View Contribution\' >View</a></span>"]] }', $json);
$_REQUEST['return'] = TRUE;
$json = CRM_Financial_Page_AJAX::getFinancialTransactionsList();
$json = str_replace(rtrim(CIVICRM_UF_BASEURL, '/'), 'http://FIX ME', $json);
- $this->assertEquals('{"sEcho": 1, "iTotalRecords": 1, "iTotalDisplayRecords": 1, "aaData": [ ["<input type=\'checkbox\' id=\'mark_x_2\' name=\'mark_x_2\' value=\'1\' onclick=enableActions(\'x\')></input>","<a href=\"/index.php?q=civicrm/profile/view&reset=1&gid=7&id=3&snippet=4&is_show_email_task=1\" class=\"crm-summary-link\"><div'
+ $this->assertEquals('{"sEcho": 1, "iTotalRecords": 1, "iTotalDisplayRecords": 1, "aaData": [ ["<input type=\'checkbox\' id=\'mark_x_2\' name=\'mark_x_2\' value=\'1\' onclick=enableActions(\'x\')></input>","<a href=\"/index.php?q=civicrm/contact/view&reset=1&cid=3\" data-tooltip-url=\"/index.php?q=civicrm/profile/view&reset=1&gid=7&id=3&snippet=4&is_show_email_task=1\" class=\"crm-summary-link\"><div'
. ' class=\"icon crm-icon Individual-icon\"></div></a>","<a href=/index.php?q=civicrm/contact/view&reset=1&cid=3>Anderson, Anthony</a>","$ 5.00","12345","' . CRM_Utils_Date::customFormat(date('Ymd')) . ' 12:00 AM","' . CRM_Utils_Date::customFormat(date('Ymd')) . ' 12:00 AM",'
. '"Credit Card","Completed","Donation","<span><a href=\"/index.php?q=civicrm/contact/view/contribution&reset=1&id=1&cid=3&action=view&context=contribution&'
. 'selectedChild=contribute\" class=\"action-item crm-hover-button\" title=\'View Contribution\' >View</a><a href=\"#\" class=\"action-item crm-hover-button disable-action\" title=\'Assign Transaction\' onclick = \"assignRemove( 2,\'assign\' );\">Assign</a></span>"]] }', $json);
$this->assertEquals([
'contact_id' => $this->_contactID,
'membership_id' => $membershipID,
- 'contact_type' => '<a href="/index.php?q=civicrm/profile/view&reset=1&gid=7&id=' . $this->_contactID . '&snippet=4&is_show_email_task=1" class="crm-summary-link"><div class="icon crm-icon Individual-icon"></div></a>',
+ 'contact_type' => '<a href="/index.php?q=civicrm/contact/view&reset=1&cid=' . $this->_contactID . '" data-tooltip-url="/index.php?q=civicrm/profile/view&reset=1&gid=7&id=' . $this->_contactID . '&snippet=4&is_show_email_task=1" class="crm-summary-link"><div class="icon crm-icon Individual-icon"></div></a>',
'sort_name' => 'Anderson, Anthony',
'membership_type' => 'General',
'membership_join_date' => date('Y-m-d'),
'pledge_status_name' => 'Pending Label**',
'checkbox' => 'mark_x_1',
'action' => '<span><a href="/index.php?q=civicrm/contact/view/pledge&reset=1&id=1&cid=3&action=view&context=search&selectedChild=pledge&key=' . $qfKey . '" class="action-item crm-hover-button" title=' . "'" . 'View Pledge' . "'" . ' >View</a><a href="/index.php?q=civicrm/contact/view/pledge&reset=1&action=update&id=1&cid=3&context=search&key=' . $qfKey . '" class="action-item crm-hover-button" title=' . "'" . 'Edit Pledge' . "'" . ' >Edit</a></span><span class=' . "'" . 'btn-slide crm-hover-button' . "'" . '>more<ul class=' . "'" . 'panel' . "'" . '><li><a href="/index.php?q=civicrm/contact/view/pledge&reset=1&action=detach&id=1&cid=3&context=search&key=' . $qfKey . '" class="action-item crm-hover-button" title=' . "'" . 'Cancel Pledge' . "'" . ' onclick = "return confirm(' . "'" . 'Cancelling this pledge will also cancel any scheduled (and not completed) pledge payments. This action cannot be undone. Do you want to continue?' . "'" . ');">Cancel</a></li><li><a href="/index.php?q=civicrm/contact/view/pledge&reset=1&action=delete&id=1&cid=3&context=search&key=' . $qfKey . '" class="action-item crm-hover-button small-popup" title=' . "'" . 'Delete Pledge' . "'" . ' >Delete</a></li></ul></span>',
- 'contact_type' => '<a href="/index.php?q=civicrm/profile/view&reset=1&gid=7&id=3&snippet=4&is_show_email_task=1" class="crm-summary-link"><div class="icon crm-icon Individual-icon"></div></a>',
+ 'contact_type' => '<a href="/index.php?q=civicrm/contact/view&reset=1&cid=3" data-tooltip-url="/index.php?q=civicrm/profile/view&reset=1&gid=7&id=3&snippet=4&is_show_email_task=1" class="crm-summary-link"><div class="icon crm-icon Individual-icon"></div></a>',
], $rows[0]);
}