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[] = [ | |
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 | */ | |
56 | function 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 | ||
71 | /** | |
72 | * Implements hook_civicrm_tabSet(). | |
73 | * | |
74 | * Add grants tab to contact summary screen. | |
75 | */ | |
76 | function civigrant_civicrm_tabSet($tabSetName, &$tabs, $context) { | |
77 | if ($tabSetName === 'civicrm/contact/view' && !empty($context['contact_id'])) { | |
78 | $cid = $context['contact_id']; | |
79 | $tabs[] = [ | |
80 | 'id' => 'grant', | |
81 | 'url' => CRM_Utils_System::url("civicrm/contact/view/grant", ['reset' => 1, 'cid' => $cid]), | |
82 | 'title' => E::ts('Grants'), | |
83 | 'weight' => 60, | |
84 | 'count' => CRM_Grant_BAO_Grant::getContactGrantCount($cid), | |
85 | 'class' => 'livePage', | |
86 | 'icon' => 'crm-i fa-money', | |
87 | ]; | |
88 | } | |
89 | } |