Commit | Line | Data |
---|---|---|
dbf9e1e6 MW |
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 | ||
dbf9e1e6 MW |
17 | /** |
18 | * Implements hook_civicrm_install(). | |
19 | * | |
20 | * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_install | |
21 | */ | |
22 | function recaptcha_civicrm_install() { | |
23 | _recaptcha_civix_civicrm_install(); | |
24 | } | |
25 | ||
26 | /** | |
27 | * Implements hook_civicrm_postInstall(). | |
28 | * | |
29 | * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_postInstall | |
30 | */ | |
31 | function recaptcha_civicrm_postInstall() { | |
32 | _recaptcha_civix_civicrm_postInstall(); | |
33 | } | |
34 | ||
35 | /** | |
36 | * Implements hook_civicrm_uninstall(). | |
37 | * | |
38 | * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_uninstall | |
39 | */ | |
40 | function recaptcha_civicrm_uninstall() { | |
41 | _recaptcha_civix_civicrm_uninstall(); | |
42 | } | |
43 | ||
44 | /** | |
45 | * Implements hook_civicrm_enable(). | |
46 | * | |
47 | * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_enable | |
48 | */ | |
49 | function recaptcha_civicrm_enable() { | |
50 | _recaptcha_civix_civicrm_enable(); | |
51 | } | |
52 | ||
53 | /** | |
54 | * Implements hook_civicrm_disable(). | |
55 | * | |
56 | * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_disable | |
57 | */ | |
58 | function recaptcha_civicrm_disable() { | |
59 | _recaptcha_civix_civicrm_disable(); | |
60 | } | |
61 | ||
62 | /** | |
63 | * Implements hook_civicrm_upgrade(). | |
64 | * | |
65 | * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_upgrade | |
66 | */ | |
67 | function recaptcha_civicrm_upgrade($op, CRM_Queue_Queue $queue = NULL) { | |
68 | return _recaptcha_civix_civicrm_upgrade($op, $queue); | |
69 | } | |
70 | ||
dbf9e1e6 MW |
71 | /** |
72 | * Implements hook_civicrm_entityTypes(). | |
73 | * | |
74 | * Declare entity types provided by this module. | |
75 | * | |
76 | * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_entityTypes | |
77 | */ | |
78 | function recaptcha_civicrm_entityTypes(&$entityTypes) { | |
79 | _recaptcha_civix_civicrm_entityTypes($entityTypes); | |
80 | } | |
81 | ||
82 | /** | |
83 | * Implements hook_civicrm_navigationMenu(). | |
84 | */ | |
85 | function recaptcha_civicrm_navigationMenu(&$menu) { | |
5a224484 | 86 | _recaptcha_civix_insert_navigation_menu($menu, 'Administer/System Settings', [ |
dbf9e1e6 MW |
87 | 'label' => E::ts('reCAPTCHA Settings'), |
88 | 'name' => 'recaptcha_settings', | |
89 | 'url' => 'civicrm/admin/setting/recaptcha', | |
90 | 'permission' => 'administer CiviCRM', | |
91 | 'operator' => 'OR', | |
92 | 'separator' => 0, | |
93 | ]); | |
94 | _recaptcha_civix_navigationMenu($menu); | |
95 | } | |
96 | ||
97 | /** | |
98 | * Intercept form functions | |
99 | */ | |
100 | function recaptcha_civicrm_buildForm($formName, &$form) { | |
101 | switch ($formName) { | |
102 | case 'CRM_Admin_Form_Generic': | |
103 | if ($form->getSettingPageFilter() !== 'recaptcha') { | |
104 | return; | |
105 | } | |
106 | ||
107 | $helpText = E::ts( | |
108 | '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.', | |
109 | [ | |
110 | 1 => 'https://www.google.com/recaptcha', | |
111 | ] | |
112 | ) | |
113 | . '<br/><strong>' . E::ts('Only the reCAPTCHA v2 checkbox type is supported.') . '</strong>'; | |
114 | \Civi::resources() | |
115 | ->addMarkup('<div class="help">' . $helpText . '</div>', [ | |
116 | 'weight' => -1, | |
117 | 'region' => 'page-body', | |
118 | ]); | |
119 | } | |
120 | } |