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_alterAPIPermissions().
+ *
+ * Set CiviGrant permissions for APIv3.
+ */
+function civigrant_civicrm_alterAPIPermissions($entity, $action, &$params, &$permissions) {
+ $permissions['grant'] = [
+ 'get' => [
+ 'access CiviGrant',
+ ],
+ 'delete' => [
+ 'delete in CiviGrant',
+ ],
+ 'create' => [
+ 'edit grants',
+ ],
+ 'update' => [
+ 'edit grants',
+ ],
+ ];
+}
+
/**
* Implements hook_civicrm_queryObjects().
*