3 require_once 'oauth_client.civix.php';
5 use CRM_OauthClient_ExtensionUtil
as E
;
9 * Implements hook_civicrm_config().
11 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_config/
13 function oauth_client_civicrm_config(&$config) {
14 _oauth_client_civix_civicrm_config($config);
18 * Implements hook_civicrm_xmlMenu().
20 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_xmlMenu
22 function oauth_client_civicrm_xmlMenu(&$files) {
23 _oauth_client_civix_civicrm_xmlMenu($files);
27 * Implements hook_civicrm_managed().
29 * Generate a list of entities to create/deactivate/delete when this module
30 * is installed, disabled, uninstalled.
32 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_managed
34 function oauth_client_civicrm_managed(&$entities) {
35 _oauth_client_civix_civicrm_managed($entities);
39 * Implements hook_civicrm_permission().
41 * @see CRM_Utils_Hook::permission()
42 * @see CRM_Core_Permission::getCorePermissions()
44 function 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'),
50 $permissions['manage OAuth client secrets'] = [
51 $prefix . ts('manage OAuth client secrets'),
52 ts('Access OAuth secrets'),
57 * Implements hook_civicrm_caseTypes().
59 * Generate a list of case-types.
61 * Note: This hook only runs in CiviCRM 4.4+.
63 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_caseTypes
65 function oauth_client_civicrm_caseTypes(&$caseTypes) {
66 _oauth_client_civix_civicrm_caseTypes($caseTypes);
70 * Implements hook_civicrm_angularModules().
72 * Generate a list of Angular modules.
74 * Note: This hook only runs in CiviCRM 4.5+. It may
75 * use features only available in v4.6+.
77 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_angularModules
79 function oauth_client_civicrm_angularModules(&$angularModules) {
80 _oauth_client_civix_civicrm_angularModules($angularModules);
84 * Implements hook_civicrm_alterSettingsFolders().
86 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_alterSettingsFolders
88 function oauth_client_civicrm_alterSettingsFolders(&$metaDataFolders = NULL) {
89 _oauth_client_civix_civicrm_alterSettingsFolders($metaDataFolders);
93 * Implements hook_civicrm_entityTypes().
95 * Declare entity types provided by this module.
97 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_entityTypes
99 function oauth_client_civicrm_entityTypes(&$entityTypes) {
100 _oauth_client_civix_civicrm_entityTypes($entityTypes);
104 * Implements hook_civicrm_thems().
106 function oauth_client_civicrm_themes(&$themes) {
107 _oauth_client_civix_civicrm_themes($themes);
110 // --- Functions below this ship commented out. Uncomment as required. ---
113 * Implements hook_civicrm_preProcess().
115 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_preProcess
117 //function oauth_client_civicrm_preProcess($formName, &$form) {
122 * Implements hook_civicrm_navigationMenu().
124 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_navigationMenu
126 //function oauth_client_civicrm_navigationMenu(&$menu) {
127 // _oauth_client_civix_insert_navigation_menu($menu, 'Mailings', array(
128 // 'label' => E::ts('New subliminal message'),
129 // 'name' => 'mailing_subliminal_message',
130 // 'url' => 'civicrm/mailing/subliminal',
131 // 'permission' => 'access CiviMail',
132 // 'operator' => 'OR',
135 // _oauth_client_civix_navigationMenu($menu);
139 * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
141 function oauth_client_civicrm_container($container) {
142 $container->addResource(new \Symfony\Component\Config\
Resource\
FileResource(__FILE__
));
143 $container->setDefinition('oauth2.league', new \Symfony\Component\DependencyInjection\
Definition(
144 \Civi\OAuth\OAuthLeagueFacade
::class, []))->setPublic(TRUE);
145 $container->setDefinition('oauth2.token', new \Symfony\Component\DependencyInjection\
Definition(
146 \Civi\OAuth\OAuthTokenFacade
::class, []))->setPublic(TRUE);
150 * Implements hook_civicrm_oauthProviders().
152 function oauth_client_civicrm_oauthProviders(&$providers) {
153 $ingest = function($pat) use (&$providers) {
154 $files = (array) glob($pat);
155 foreach ($files as $file) {
156 if (!defined('CIVICRM_TEST') && preg_match(';\.test\.json$;', $file)) {
159 $name = preg_replace(';\.(dist\.|test\.|)json$;', '', basename($file));
160 $provider = json_decode(file_get_contents($file), 1);
161 $provider['name'] = $name;
162 $providers[$name] = $provider;
166 $ingest(__DIR__
. '/providers/*.json');
167 $localDir = Civi
::paths()->getPath('[civicrm.private]/oauth-providers');
168 if (file_exists($localDir)) {
169 $ingest($localDir . '/*.json');
174 * Implements hook_civicrm_mailSetupActions().
176 * @see CRM_Utils_Hook::mailSetupActions()
178 function oauth_client_civicrm_mailSetupActions(&$setupActions) {
179 $setupActions = array_merge($setupActions, CRM_OAuth_MailSetup
::buildSetupLinks());
183 * Implements hook_civicrm_oauthReturn().
185 function oauth_client_civicrm_oauthReturn($token, &$nextUrl) {
186 CRM_OAuth_MailSetup
::onReturn($token, $nextUrl);
190 * Implements hook_civicrm_alterMailStore().
192 * @see CRM_Utils_Hook::alterMailStore()
194 function oauth_client_civicrm_alterMailStore(&$mailSettings) {
195 CRM_OAuth_MailSetup
::alterMailStore($mailSettings);