(NFC) MessageTemplate - Add "INTERNAL" disclaimers for messageTemplate and tokenContext
[civicrm-core.git] / ext / oauth-client / oauth_client.php
CommitLineData
ed463944
TO
1<?php
2
3require_once 'oauth_client.civix.php';
4// phpcs:disable
5use CRM_OauthClient_ExtensionUtil as E;
6// phpcs:enable
7
8/**
9 * Implements hook_civicrm_config().
10 *
11 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_config/
12 */
13function oauth_client_civicrm_config(&$config) {
14 _oauth_client_civix_civicrm_config($config);
15}
16
17/**
18 * Implements hook_civicrm_xmlMenu().
19 *
20 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_xmlMenu
21 */
22function oauth_client_civicrm_xmlMenu(&$files) {
23 _oauth_client_civix_civicrm_xmlMenu($files);
24}
ed463944
TO
25
26/**
27 * Implements hook_civicrm_managed().
28 *
29 * Generate a list of entities to create/deactivate/delete when this module
30 * is installed, disabled, uninstalled.
31 *
32 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_managed
33 */
34function oauth_client_civicrm_managed(&$entities) {
35 _oauth_client_civix_civicrm_managed($entities);
36}
37
9959dad1
TO
38/**
39 * Implements hook_civicrm_permission().
40 *
41 * @see CRM_Utils_Hook::permission()
42 * @see CRM_Core_Permission::getCorePermissions()
43 */
44function oauth_client_civicrm_permission(&$permissions) {
45 $prefix = ts('CiviCRM') . ': ';
46 $permissions['manage OAuth client'] = [
47 $prefix . ts('manage OAuth client'),
48 ts('Create and delete OAuth client connections'),
49 ];
50 $permissions['manage OAuth client secrets'] = [
51 $prefix . ts('manage OAuth client secrets'),
52 ts('Access OAuth secrets'),
53 ];
d55f710f
NM
54 $permissions['create OAuth tokens via auth code flow'] = [
55 $prefix . ts('create OAuth tokens via auth code flow'),
56 ts('Create OAuth tokens via the authorization code flow'),
57 ];
58 $permissions['manage my OAuth contact tokens'] = [
59 $prefix . ts('manage my OAuth contact tokens'),
60 ts("Manage user's own OAuth tokens"),
61 ];
62 $permissions['manage all OAuth contact tokens'] = [
63 $prefix . ts('manage all OAuth contact tokens'),
64 ts("Manage OAuth tokens for all contacts"),
65 ];
9959dad1
TO
66}
67
ed463944
TO
68/**
69 * Implements hook_civicrm_caseTypes().
70 *
71 * Generate a list of case-types.
72 *
73 * Note: This hook only runs in CiviCRM 4.4+.
74 *
75 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_caseTypes
76 */
77function oauth_client_civicrm_caseTypes(&$caseTypes) {
78 _oauth_client_civix_civicrm_caseTypes($caseTypes);
79}
80
81/**
82 * Implements hook_civicrm_angularModules().
83 *
84 * Generate a list of Angular modules.
85 *
86 * Note: This hook only runs in CiviCRM 4.5+. It may
87 * use features only available in v4.6+.
88 *
89 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_angularModules
90 */
91function oauth_client_civicrm_angularModules(&$angularModules) {
92 _oauth_client_civix_civicrm_angularModules($angularModules);
93}
94
95/**
96 * Implements hook_civicrm_alterSettingsFolders().
97 *
98 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_alterSettingsFolders
99 */
100function oauth_client_civicrm_alterSettingsFolders(&$metaDataFolders = NULL) {
101 _oauth_client_civix_civicrm_alterSettingsFolders($metaDataFolders);
102}
103
104/**
105 * Implements hook_civicrm_entityTypes().
106 *
107 * Declare entity types provided by this module.
108 *
109 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_entityTypes
110 */
111function oauth_client_civicrm_entityTypes(&$entityTypes) {
112 _oauth_client_civix_civicrm_entityTypes($entityTypes);
113}
114
115/**
116 * Implements hook_civicrm_thems().
117 */
118function oauth_client_civicrm_themes(&$themes) {
119 _oauth_client_civix_civicrm_themes($themes);
120}
121
122// --- Functions below this ship commented out. Uncomment as required. ---
123
124/**
125 * Implements hook_civicrm_preProcess().
126 *
127 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_preProcess
128 */
129//function oauth_client_civicrm_preProcess($formName, &$form) {
130//
131//}
132
133/**
134 * Implements hook_civicrm_navigationMenu().
135 *
136 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_navigationMenu
137 */
138//function oauth_client_civicrm_navigationMenu(&$menu) {
139// _oauth_client_civix_insert_navigation_menu($menu, 'Mailings', array(
140// 'label' => E::ts('New subliminal message'),
141// 'name' => 'mailing_subliminal_message',
142// 'url' => 'civicrm/mailing/subliminal',
143// 'permission' => 'access CiviMail',
144// 'operator' => 'OR',
145// 'separator' => 0,
146// ));
147// _oauth_client_civix_navigationMenu($menu);
148//}
3ee128fb 149
a17b2d8a
TO
150/**
151 * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
152 */
153function oauth_client_civicrm_container($container) {
154 $container->addResource(new \Symfony\Component\Config\Resource\FileResource(__FILE__));
155 $container->setDefinition('oauth2.league', new \Symfony\Component\DependencyInjection\Definition(
156 \Civi\OAuth\OAuthLeagueFacade::class, []))->setPublic(TRUE);
157 $container->setDefinition('oauth2.token', new \Symfony\Component\DependencyInjection\Definition(
158 \Civi\OAuth\OAuthTokenFacade::class, []))->setPublic(TRUE);
159}
160
3ee128fb
TO
161/**
162 * Implements hook_civicrm_oauthProviders().
163 */
164function oauth_client_civicrm_oauthProviders(&$providers) {
2752428e
TO
165 $ingest = function($pat) use (&$providers) {
166 $files = (array) glob($pat);
167 foreach ($files as $file) {
168 if (!defined('CIVICRM_TEST') && preg_match(';\.test\.json$;', $file)) {
169 continue;
170 }
171 $name = preg_replace(';\.(dist\.|test\.|)json$;', '', basename($file));
172 $provider = json_decode(file_get_contents($file), 1);
173 $provider['name'] = $name;
174 $providers[$name] = $provider;
3ee128fb
TO
175 }
176 };
177
2752428e
TO
178 $ingest(__DIR__ . '/providers/*.json');
179 $localDir = Civi::paths()->getPath('[civicrm.private]/oauth-providers');
180 if (file_exists($localDir)) {
181 $ingest($localDir . '/*.json');
3ee128fb
TO
182 }
183}
7be4bff1
TO
184
185/**
186 * Implements hook_civicrm_mailSetupActions().
187 *
188 * @see CRM_Utils_Hook::mailSetupActions()
189 */
190function oauth_client_civicrm_mailSetupActions(&$setupActions) {
191 $setupActions = array_merge($setupActions, CRM_OAuth_MailSetup::buildSetupLinks());
192}
193
194/**
195 * Implements hook_civicrm_oauthReturn().
196 */
197function oauth_client_civicrm_oauthReturn($token, &$nextUrl) {
198 CRM_OAuth_MailSetup::onReturn($token, $nextUrl);
199}
7dfe9078
TO
200
201/**
202 * Implements hook_civicrm_alterMailStore().
203 *
204 * @see CRM_Utils_Hook::alterMailStore()
205 */
206function oauth_client_civicrm_alterMailStore(&$mailSettings) {
207 CRM_OAuth_MailSetup::alterMailStore($mailSettings);
208}