Commit | Line | Data |
---|---|---|
34066907 CW |
1 | <?php |
2 | ||
3 | require_once 'civigrant.civix.php'; | |
4 | use 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 | */ | |
11 | function 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 | */ | |
20 | function 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 | */ | |
31 | function 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 | */ | |
40 | function civigrant_civicrm_links($context, $name, $id, &$links) { | |
41 | if ($context === 'create.new.shortcuts' && CRM_Core_Permission::check(['access CiviGrant', 'edit grants'])) { | |
42 | $links[] = [ | |
be49cd8a | 43 | 'ref' => 'new-grant', |
71d59b8d | 44 | 'name' => 'Grant', |
be49cd8a | 45 | 'title' => ts('Grant'), |
71d59b8d | 46 | 'url' => CRM_Utils_System::url('civicrm/grant/add', 'reset=1&action=add&context=standalone'), |
be49cd8a CW |
47 | ]; |
48 | } | |
49 | } | |
50 | ||
1e9cc515 CW |
51 | /** |
52 | * Implements hook_civicrm_summaryActions(). | |
53 | * | |
54 | * Add contact summary link to create new grant. | |
55 | */ | |
56 | function civigrant_civicrm_summaryActions(&$menu, $cid) { | |
57 | $menu['grant'] = [ | |
58 | 'title' => ts('Add Grant'), | |
59 | 'weight' => 26, | |
60 | 'ref' => 'new-grant', | |
61 | 'key' => 'grant', | |
62 | 'tab' => 'afsearchGrants', | |
63 | 'href' => CRM_Utils_System::url('civicrm/contact/view/grant', | |
64 | 'reset=1&action=add&context=grant' | |
65 | ), | |
66 | 'permissions' => ['edit grants'], | |
67 | ]; | |
68 | } | |
69 | ||
be49cd8a CW |
70 | /** |
71 | * Implements hook_civicrm_permission(). | |
72 | * | |
73 | * Define CiviGrant permissions. | |
74 | */ | |
75 | function civigrant_civicrm_permission(&$permissions) { | |
76 | $permissions['access CiviGrant'] = [ | |
07ab96cb | 77 | E::ts('CiviGrant:') . ' ' . E::ts('access CiviGrant'), |
be49cd8a CW |
78 | E::ts('View all grants'), |
79 | ]; | |
80 | $permissions['edit grants'] = [ | |
07ab96cb | 81 | E::ts('CiviGrant:') . ' ' . E::ts('edit grants'), |
be49cd8a CW |
82 | E::ts('Create and update grants'), |
83 | ]; | |
84 | $permissions['delete in CiviGrant'] = [ | |
07ab96cb | 85 | E::ts('CiviGrant:') . ' ' . E::ts('delete in CiviGrant'), |
be49cd8a CW |
86 | E::ts('Delete grants'), |
87 | ]; | |
88 | } | |
89 | ||
f7e18e64 CW |
90 | /** |
91 | * Implements hook_civicrm_alterAPIPermissions(). | |
92 | * | |
93 | * Set CiviGrant permissions for APIv3. | |
94 | */ | |
95 | function civigrant_civicrm_alterAPIPermissions($entity, $action, &$params, &$permissions) { | |
96 | $permissions['grant'] = [ | |
97 | 'get' => [ | |
98 | 'access CiviGrant', | |
99 | ], | |
100 | 'delete' => [ | |
101 | 'delete in CiviGrant', | |
102 | ], | |
103 | 'create' => [ | |
104 | 'edit grants', | |
105 | ], | |
106 | 'update' => [ | |
107 | 'edit grants', | |
108 | ], | |
109 | ]; | |
110 | } | |
111 | ||
adde8f5e CW |
112 | /** |
113 | * Implements hook_civicrm_queryObjects(). | |
114 | * | |
115 | * Adds query object for legacy screens like advanced search, search builder, etc. | |
116 | */ | |
117 | function civigrant_civicrm_queryObjects(&$queryObjects, $type) { | |
118 | if ($type == 'Contact') { | |
119 | $queryObjects[] = new CRM_Grant_BAO_Query(); | |
120 | } | |
121 | elseif ($type == 'Report') { | |
122 | // Do we need to do something here? | |
123 | } | |
124 | } |