$link) { if (in_array($link['name'], ['Delete', 'Disable'])) { unset($links[$key]); } } } } } /** * Implements hook_civicrm_pre(). * * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_pre */ function deleterelationshipperm_civicrm_pre($op, $objectName, $id, &$params) { if ($op == 'delete' && $objectName == 'Relationship') { _deleterelationshipperm_civicrm_check_permission(); } } /** * Implements hook_civicrm_apiWrappers(). * * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_apiWrappers */ function deleterelationshipperm_civicrm_apiWrappers(&$wrappers, $apiRequest) { if ($apiRequest['entity'] == 'Relationship' && $apiRequest['action'] == 'delete') { _deleterelationshipperm_civicrm_check_permission('exception'); } } /** * Check if user has permission to delete relationship. * * @param string $errorType */ function _deleterelationshipperm_civicrm_check_permission($errorType = NULL) { if (CRM_Core_Permission::check('delete relationships')) { return FALSE; } $message = ts('You do not have permission to delete relationships. Please speak to an administrator..'); if ($errorType == 'exception') { throw new API_Exception($message); } else { CRM_Core_Error::statusBounce($message); } }