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'),
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'),
58 $permissions['manage my OAuth contact tokens'] = [
59 $prefix . ts('manage my OAuth contact tokens'),
60 ts("Manage user's own OAuth tokens"),
62 $permissions['manage all OAuth contact tokens'] = [
63 $prefix . ts('manage all OAuth contact tokens'),
64 ts("Manage OAuth tokens for all contacts"),
69 * Implements hook_civicrm_caseTypes().
71 * Generate a list of case-types.
73 * Note: This hook only runs in CiviCRM 4.4+.
75 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_caseTypes
77 function oauth_client_civicrm_caseTypes(&$caseTypes) {
78 _oauth_client_civix_civicrm_caseTypes($caseTypes);
82 * Implements hook_civicrm_angularModules().
84 * Generate a list of Angular modules.
86 * Note: This hook only runs in CiviCRM 4.5+. It may
87 * use features only available in v4.6+.
89 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_angularModules
91 function oauth_client_civicrm_angularModules(&$angularModules) {
92 _oauth_client_civix_civicrm_angularModules($angularModules);
96 * Implements hook_civicrm_entityTypes().
98 * Declare entity types provided by this module.
100 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_entityTypes
102 function oauth_client_civicrm_entityTypes(&$entityTypes) {
103 _oauth_client_civix_civicrm_entityTypes($entityTypes);
107 * Implements hook_civicrm_thems().
109 function oauth_client_civicrm_themes(&$themes) {
110 _oauth_client_civix_civicrm_themes($themes);
113 // --- Functions below this ship commented out. Uncomment as required. ---
116 * Implements hook_civicrm_preProcess().
118 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_preProcess
120 //function oauth_client_civicrm_preProcess($formName, &$form) {
125 * Implements hook_civicrm_navigationMenu().
127 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_navigationMenu
129 //function oauth_client_civicrm_navigationMenu(&$menu) {
130 // _oauth_client_civix_insert_navigation_menu($menu, 'Mailings', array(
131 // 'label' => E::ts('New subliminal message'),
132 // 'name' => 'mailing_subliminal_message',
133 // 'url' => 'civicrm/mailing/subliminal',
134 // 'permission' => 'access CiviMail',
135 // 'operator' => 'OR',
138 // _oauth_client_civix_navigationMenu($menu);
142 * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
144 function oauth_client_civicrm_container($container) {
145 $container->addResource(new \Symfony\Component\Config\
Resource\
FileResource(__FILE__
));
146 $container->setDefinition('oauth2.league', new \Symfony\Component\DependencyInjection\
Definition(
147 \Civi\OAuth\OAuthLeagueFacade
::class, []))->setPublic(TRUE);
148 $container->setDefinition('oauth2.token', new \Symfony\Component\DependencyInjection\
Definition(
149 \Civi\OAuth\OAuthTokenFacade
::class, []))->setPublic(TRUE);
153 * Implements hook_civicrm_oauthProviders().
155 function oauth_client_civicrm_oauthProviders(&$providers) {
156 $ingest = function($pat) use (&$providers) {
157 $files = (array) glob($pat);
158 foreach ($files as $file) {
159 if (!defined('CIVICRM_TEST') && preg_match(';\.test\.json$;', $file)) {
162 $name = preg_replace(';\.(dist\.|test\.|)json$;', '', basename($file));
163 $provider = json_decode(file_get_contents($file), 1);
164 $provider['name'] = $name;
165 $providers[$name] = $provider;
169 $ingest(__DIR__
. '/providers/*.json');
170 $localDir = Civi
::paths()->getPath('[civicrm.private]/oauth-providers');
171 if (file_exists($localDir)) {
172 $ingest($localDir . '/*.json');
177 * Implements hook_civicrm_mailSetupActions().
179 * @see CRM_Utils_Hook::mailSetupActions()
181 function oauth_client_civicrm_mailSetupActions(&$setupActions) {
182 $setupActions = array_merge($setupActions, CRM_OAuth_MailSetup
::buildSetupLinks());
186 * Implements hook_civicrm_oauthReturn().
188 function oauth_client_civicrm_oauthReturn($token, &$nextUrl) {
189 CRM_OAuth_MailSetup
::onReturn($token, $nextUrl);
193 * Implements hook_civicrm_alterMailStore().
195 * @see CRM_Utils_Hook::alterMailStore()
197 function oauth_client_civicrm_alterMailStore(&$mailSettings) {
198 CRM_OAuth_MailSetup
::alterMailStore($mailSettings);