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 | ||
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 | ||
dbf9e1e6 MW |
92 | /** |
93 | * Implements hook_civicrm_entityTypes(). | |
94 | * | |
95 | * Declare entity types provided by this module. | |
96 | * | |
97 | * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_entityTypes | |
98 | */ | |
99 | function recaptcha_civicrm_entityTypes(&$entityTypes) { | |
100 | _recaptcha_civix_civicrm_entityTypes($entityTypes); | |
101 | } | |
102 | ||
103 | /** | |
104 | * Implements hook_civicrm_navigationMenu(). | |
105 | */ | |
106 | function recaptcha_civicrm_navigationMenu(&$menu) { | |
5a224484 | 107 | _recaptcha_civix_insert_navigation_menu($menu, 'Administer/System Settings', [ |
dbf9e1e6 MW |
108 | 'label' => E::ts('reCAPTCHA Settings'), |
109 | 'name' => 'recaptcha_settings', | |
110 | 'url' => 'civicrm/admin/setting/recaptcha', | |
111 | 'permission' => 'administer CiviCRM', | |
112 | 'operator' => 'OR', | |
113 | 'separator' => 0, | |
114 | ]); | |
115 | _recaptcha_civix_navigationMenu($menu); | |
116 | } | |
117 | ||
118 | /** | |
119 | * Intercept form functions | |
120 | */ | |
121 | function recaptcha_civicrm_buildForm($formName, &$form) { | |
122 | switch ($formName) { | |
123 | case 'CRM_Admin_Form_Generic': | |
124 | if ($form->getSettingPageFilter() !== 'recaptcha') { | |
125 | return; | |
126 | } | |
127 | ||
128 | $helpText = E::ts( | |
129 | '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.', | |
130 | [ | |
131 | 1 => 'https://www.google.com/recaptcha', | |
132 | ] | |
133 | ) | |
134 | . '<br/><strong>' . E::ts('Only the reCAPTCHA v2 checkbox type is supported.') . '</strong>'; | |
135 | \Civi::resources() | |
136 | ->addMarkup('<div class="help">' . $helpText . '</div>', [ | |
137 | 'weight' => -1, | |
138 | 'region' => 'page-body', | |
139 | ]); | |
140 | } | |
141 | } |