function civigrant_civicrm_links($context, $name, $id, &$links) {
if ($context === 'create.new.shortcuts' && CRM_Core_Permission::check(['access CiviGrant', 'edit grants'])) {
$links[] = [
- 'path' => 'civicrm/grant/add',
- 'query' => "reset=1&action=add&context=standalone",
'ref' => 'new-grant',
+ 'name' => 'Grant',
'title' => ts('Grant'),
+ 'url' => CRM_Utils_System::url('civicrm/grant/add', 'reset=1&action=add&context=standalone'),
];
}
}
+/**
+ * Implements hook_civicrm_summaryActions().
+ *
+ * Add contact summary link to create new grant.
+ */
+function civigrant_civicrm_summaryActions(&$menu, $cid) {
+ $menu['grant'] = [
+ 'title' => ts('Add Grant'),
+ 'weight' => 26,
+ 'ref' => 'new-grant',
+ 'key' => 'grant',
+ 'tab' => 'afsearchGrants',
+ 'href' => CRM_Utils_System::url('civicrm/contact/view/grant',
+ 'reset=1&action=add&context=grant'
+ ),
+ 'permissions' => ['edit grants'],
+ ];
+}
+
/**
* Implements hook_civicrm_permission().
*
}
/**
- * Implements hook_civicrm_tabSet().
+ * Implements hook_civicrm_alterAPIPermissions().
*
- * Add grants tab to contact summary screen.
+ * Set CiviGrant permissions for APIv3.
*/
-function civigrant_civicrm_tabSet($tabSetName, &$tabs, $context) {
- if ($tabSetName === 'civicrm/contact/view' && !empty($context['contact_id'])) {
- $cid = $context['contact_id'];
- $tabs[] = [
- 'id' => 'grant',
- 'url' => CRM_Utils_System::url("civicrm/contact/view/grant", ['reset' => 1, 'cid' => $cid]),
- 'title' => E::ts('Grants'),
- 'weight' => 60,
- 'count' => CRM_Grant_BAO_Grant::getContactGrantCount($cid),
- 'class' => 'livePage',
- 'icon' => 'crm-i fa-money',
- ];
- }
+function civigrant_civicrm_alterAPIPermissions($entity, $action, &$params, &$permissions) {
+ $permissions['grant'] = [
+ 'get' => [
+ 'access CiviGrant',
+ ],
+ 'delete' => [
+ 'delete in CiviGrant',
+ ],
+ 'create' => [
+ 'edit grants',
+ ],
+ 'update' => [
+ 'edit grants',
+ ],
+ ];
}
/**