Merge pull request #21270 from colemanw/searchKitListing
[civicrm-core.git] / ext / recaptcha / recaptcha.php
1 <?php
2
3 require_once 'recaptcha.civix.php';
4 // phpcs:disable
5 use CRM_Recaptcha_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 */
13 function recaptcha_civicrm_config(&$config) {
14 _recaptcha_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 */
22 function recaptcha_civicrm_xmlMenu(&$files) {
23 _recaptcha_civix_civicrm_xmlMenu($files);
24 }
25
26 /**
27 * Implements hook_civicrm_install().
28 *
29 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_install
30 */
31 function recaptcha_civicrm_install() {
32 _recaptcha_civix_civicrm_install();
33 }
34
35 /**
36 * Implements hook_civicrm_postInstall().
37 *
38 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_postInstall
39 */
40 function recaptcha_civicrm_postInstall() {
41 _recaptcha_civix_civicrm_postInstall();
42 }
43
44 /**
45 * Implements hook_civicrm_uninstall().
46 *
47 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_uninstall
48 */
49 function recaptcha_civicrm_uninstall() {
50 _recaptcha_civix_civicrm_uninstall();
51 }
52
53 /**
54 * Implements hook_civicrm_enable().
55 *
56 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_enable
57 */
58 function recaptcha_civicrm_enable() {
59 _recaptcha_civix_civicrm_enable();
60 }
61
62 /**
63 * Implements hook_civicrm_disable().
64 *
65 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_disable
66 */
67 function recaptcha_civicrm_disable() {
68 _recaptcha_civix_civicrm_disable();
69 }
70
71 /**
72 * Implements hook_civicrm_upgrade().
73 *
74 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_upgrade
75 */
76 function recaptcha_civicrm_upgrade($op, CRM_Queue_Queue $queue = NULL) {
77 return _recaptcha_civix_civicrm_upgrade($op, $queue);
78 }
79
80 /**
81 * Implements hook_civicrm_managed().
82 *
83 * Generate a list of entities to create/deactivate/delete when this module
84 * is installed, disabled, uninstalled.
85 *
86 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_managed
87 */
88 function recaptcha_civicrm_managed(&$entities) {
89 _recaptcha_civix_civicrm_managed($entities);
90 }
91
92 /**
93 * Implements hook_civicrm_angularModules().
94 *
95 * Generate a list of Angular modules.
96 *
97 * Note: This hook only runs in CiviCRM 4.5+. It may
98 * use features only available in v4.6+.
99 *
100 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_angularModules
101 */
102 function recaptcha_civicrm_angularModules(&$angularModules) {
103 _recaptcha_civix_civicrm_angularModules($angularModules);
104 }
105
106 /**
107 * Implements hook_civicrm_alterSettingsFolders().
108 *
109 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_alterSettingsFolders
110 */
111 function recaptcha_civicrm_alterSettingsFolders(&$metaDataFolders = NULL) {
112 _recaptcha_civix_civicrm_alterSettingsFolders($metaDataFolders);
113 }
114
115 /**
116 * Implements hook_civicrm_entityTypes().
117 *
118 * Declare entity types provided by this module.
119 *
120 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_entityTypes
121 */
122 function recaptcha_civicrm_entityTypes(&$entityTypes) {
123 _recaptcha_civix_civicrm_entityTypes($entityTypes);
124 }
125
126 /**
127 * Implements hook_civicrm_navigationMenu().
128 */
129 function recaptcha_civicrm_navigationMenu(&$menu) {
130 _recaptcha_civix_insert_navigation_menu($menu, 'Administer/System Settings', [
131 'label' => E::ts('reCAPTCHA Settings'),
132 'name' => 'recaptcha_settings',
133 'url' => 'civicrm/admin/setting/recaptcha',
134 'permission' => 'administer CiviCRM',
135 'operator' => 'OR',
136 'separator' => 0,
137 ]);
138 _recaptcha_civix_navigationMenu($menu);
139 }
140
141 /**
142 * Intercept form functions
143 */
144 function recaptcha_civicrm_buildForm($formName, &$form) {
145 switch ($formName) {
146 case 'CRM_Admin_Form_Generic':
147 if ($form->getSettingPageFilter() !== 'recaptcha') {
148 return;
149 }
150
151 $helpText = E::ts(
152 'reCAPTCHA is a free service that helps prevent automated abuse of your site. To use it on public-facing CiviCRM forms: sign up at <a href="%1" target="_blank">Google\'s reCaptcha site</a>; enter the provided public and private keys here; then enable reCAPTCHA under Advanced Settings in any Profile.',
153 [
154 1 => 'https://www.google.com/recaptcha',
155 ]
156 )
157 . '<br/><strong>' . E::ts('Only the reCAPTCHA v2 checkbox type is supported.') . '</strong>';
158 \Civi::resources()
159 ->addMarkup('<div class="help">' . $helpText . '</div>', [
160 'weight' => -1,
161 'region' => 'page-body',
162 ]);
163 }
164 }