Merge pull request #22665 from colemanw/memberCleanup
[civicrm-core.git] / ext / civigrant / civigrant.php
CommitLineData
34066907
CW
1<?php
2
3require_once 'civigrant.civix.php';
4use CRM_Grant_ExtensionUtil as E;
5
6/**
7 * Implements hook_civicrm_config().
8 *
9 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_config/
10 */
11function civigrant_civicrm_config(&$config) {
12 _civigrant_civix_civicrm_config($config);
13}
14
15/**
16 * Implements hook_civicrm_alterSettingsFolders().
17 *
18 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_alterSettingsFolders
19 */
20function civigrant_civicrm_alterSettingsFolders(&$metaDataFolders = NULL) {
21 _civigrant_civix_civicrm_alterSettingsFolders($metaDataFolders);
22}
23
24/**
25 * Implements hook_civicrm_entityTypes().
26 *
27 * Declare entity types provided by this module.
28 *
29 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_entityTypes
30 */
31function civigrant_civicrm_entityTypes(&$entityTypes) {
32 _civigrant_civix_civicrm_entityTypes($entityTypes);
33}
be49cd8a
CW
34
35/**
36 * Implements hook_civicrm_links().
37 *
38 * Add shortcut link to create new grant.
39 */
40function civigrant_civicrm_links($context, $name, $id, &$links) {
41 if ($context === 'create.new.shortcuts' && CRM_Core_Permission::check(['access CiviGrant', 'edit grants'])) {
42 $links[] = [
43 'path' => 'civicrm/grant/add',
44 'query' => "reset=1&action=add&context=standalone",
45 'ref' => 'new-grant',
46 'title' => ts('Grant'),
47 ];
48 }
49}
50
51/**
52 * Implements hook_civicrm_permission().
53 *
54 * Define CiviGrant permissions.
55 */
56function civigrant_civicrm_permission(&$permissions) {
57 $permissions['access CiviGrant'] = [
58 E::ts('access CiviGrant'),
59 E::ts('View all grants'),
60 ];
61 $permissions['edit grants'] = [
62 E::ts('edit grants'),
63 E::ts('Create and update grants'),
64 ];
65 $permissions['delete in CiviGrant'] = [
66 E::ts('delete in CiviGrant'),
67 E::ts('Delete grants'),
68 ];
69}
70
f7e18e64
CW
71/**
72 * Implements hook_civicrm_alterAPIPermissions().
73 *
74 * Set CiviGrant permissions for APIv3.
75 */
76function civigrant_civicrm_alterAPIPermissions($entity, $action, &$params, &$permissions) {
77 $permissions['grant'] = [
78 'get' => [
79 'access CiviGrant',
80 ],
81 'delete' => [
82 'delete in CiviGrant',
83 ],
84 'create' => [
85 'edit grants',
86 ],
87 'update' => [
88 'edit grants',
89 ],
90 ];
91}
92
adde8f5e
CW
93/**
94 * Implements hook_civicrm_queryObjects().
95 *
96 * Adds query object for legacy screens like advanced search, search builder, etc.
97 */
98function civigrant_civicrm_queryObjects(&$queryObjects, $type) {
99 if ($type == 'Contact') {
100 $queryObjects[] = new CRM_Grant_BAO_Query();
101 }
102 elseif ($type == 'Report') {
103 // Do we need to do something here?
104 }
105}