-
Notifications
You must be signed in to change notification settings - Fork 5
/
apikey.php
105 lines (94 loc) · 3.26 KB
/
apikey.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?php
// phpcs:disable
/*
+--------------------------------------------------------------------------+
| Copyright IT Bliss LLC (c) 2013 |
+--------------------------------------------------------------------------+
| This program is free software: you can redistribute it and/or modify |
| it under the terms of the GNU Affero General Public License as published |
| by the Free Software Foundation, either version 3 of the License, or |
| (at your option) any later version. |
| |
| This program is distributed in the hope that it will be useful, |
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public License |
| along with this program. If not, see <http://www.gnu.org/licenses/>. |
+--------------------------------------------------------------------------+
*/
// phpcs:enable
require_once 'apikey.civix.php';
/**
* Implements hook_civicrm_config().
*/
function apikey_civicrm_config(&$config) {
_apikey_civix_civicrm_config($config);
}
/**
* Implements hook_civicrm_xmlMenu().
*/
function apikey_civicrm_xmlMenu(&$files) {
_apikey_civix_civicrm_xmlMenu($files);
}
/**
* Implements hook_civicrm_install().
*/
function apikey_civicrm_install() {
return _apikey_civix_civicrm_install();
}
/**
* Implements hook_civicrm_uninstall().
*/
function apikey_civicrm_uninstall() {
return _apikey_civix_civicrm_uninstall();
}
/**
* Implements hook_civicrm_enable().
*/
function apikey_civicrm_enable() {
return _apikey_civix_civicrm_enable();
}
/**
* Implements hook_civicrm_disable().
*/
function apikey_civicrm_disable() {
return _apikey_civix_civicrm_disable();
}
/**
* Implements hook_civicrm_upgrade().
*/
function apikey_civicrm_upgrade($op, CRM_Queue_Queue $queue = NULL) {
return _apikey_civix_civicrm_upgrade($op, $queue);
}
/**
* Implements hook_civicrm_managed().
*
* Generate a list of entities to create/deactivate/delete when this module
* is installed, disabled, uninstalled.
*/
function apikey_civicrm_managed(&$entities) {
return _apikey_civix_civicrm_managed($entities);
}
/**
* Implements hook_civicrm_tabset().
*/
function apikey_civicrm_tabset($tabsetName, &$tabs, $context) {
if ($tabsetName == 'civicrm/contact/view' && !empty($context['contact_id'])) {
$contactID = $context['contact_id'];
$is_admin = CRM_Core_Permission::check('administer CiviCRM', 'edit all contacts');
$is_myself = ($contactID == CRM_Core_Session::getLoggedInContactID());
if ($is_admin || $is_myself) {
$url = CRM_Utils_System::url('civicrm/contact/view/apikey', "reset=1&cid={$contactID}&snippet=1");
$tabs[] = [
'id' => 'apiKey',
'url' => $url,
'title' => 'API Key',
'weight' => 300,
'icon' => 'crm-i fa-key',
'count' => CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $contactID, 'api_key') ? 1 : 0,
];
}
}
}