Skip to content

Commit

Permalink
GP-814 hide edit button
Browse files Browse the repository at this point in the history
  • Loading branch information
bjendres committed Aug 31, 2017
1 parent 135ef00 commit 5409d9d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
6 changes: 6 additions & 0 deletions contract.php
Expand Up @@ -146,6 +146,12 @@ function contract_civicrm_buildForm($formName, &$form) {
$membershipId = CRM_Utils_Request::retrieve('id', 'Positive', $form);
// removed: $formUtils->showPaymentContractDetails();
$formUtils->addMembershipContractFileDownloadLink($membershipId);

// GP-814 - hide 'edit' button if 'delete in CiviMember' is not granted
if (!CRM_Core_Permission::check('delete in CiviMember')) {
CRM_Core_Resources::singleton()->addScriptFile('de.systopia.contract', 'js/membership_view_hide_edit.js');
}

break;

// Membership form in add mode
Expand Down
19 changes: 19 additions & 0 deletions js/membership_view_hide_edit.js
@@ -0,0 +1,19 @@
/*-------------------------------------------------------------+
| SYSTOPIA Contract Extension |
| Copyright (C) 2017 SYSTOPIA |
| Author: B. Endres (endres -at- systopia.de) |
| http://www.systopia.de/ |
+--------------------------------------------------------------*/

// REGEX to identifiy the edit button
const edit_button_sentinel = /civicrm\/contact\/view\/membership.*action=update/;

/**
* remove the "EDIT" button
*/
cj(document).bind("ajaxComplete", function() {
cj("button.ui-button").filter(function() {
var data_identifier = cj(this).attr('data-identifier');
return edit_button_sentinel.exec(data_identifier) !== null;
}).hide();
});

0 comments on commit 5409d9d

Please sign in to comment.