social_gdpr.module in Open Social 10.2.x
Same filename and directory in other branches
- 8.9 modules/custom/social_gdpr/social_gdpr.module
- 8.2 modules/custom/social_gdpr/social_gdpr.module
- 8.3 modules/custom/social_gdpr/social_gdpr.module
- 8.4 modules/custom/social_gdpr/social_gdpr.module
- 8.5 modules/custom/social_gdpr/social_gdpr.module
- 8.6 modules/custom/social_gdpr/social_gdpr.module
- 8.7 modules/custom/social_gdpr/social_gdpr.module
- 8.8 modules/custom/social_gdpr/social_gdpr.module
- 10.3.x modules/custom/social_gdpr/social_gdpr.module
- 10.0.x modules/custom/social_gdpr/social_gdpr.module
- 10.1.x modules/custom/social_gdpr/social_gdpr.module
Contains social_gdpr.module.
File
modules/custom/social_gdpr/social_gdpr.moduleView source
<?php
/**
* @file
* Contains social_gdpr.module.
*/
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Url;
use Drupal\data_policy\Entity\DataPolicy;
/**
* Implements hook_help().
*/
function social_gdpr_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
// Main module help for the social_gdpr module.
case 'help.page.social_gdpr':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('Integrate Data Policy module.') . '</p>';
return $output;
}
}
/**
* Implements hook_form_FORM_ID_alter().
*/
function social_gdpr_form_data_policy_data_policy_agreement_alter(&$form, FormStateInterface $form_state, $form_id) {
if (isset($form['not_agree'])) {
$form['not_agree']['#tag'] = 'small';
}
}
/**
* Implements hook_form_FORM_ID_alter().
*
* Move the GDPR checkbox into the account fieldset if it's available.
*/
function social_gdpr_form_user_register_form_alter(&$form, FormStateInterface $form_state) {
if (isset($form['data_policy'], $form['account'])) {
$form['account']['data_policy'] = $form['data_policy'];
unset($form['data_policy']);
// Provide it with a weight so it'll sit at the bottom relative to the other
// user registration form fields.
$form['account']['data_policy']['#weight'] = 100;
}
}
/**
* Implements hook_social_user_account_header_links().
*/
function social_gdpr_social_user_account_header_links() {
$items = [];
if (\Drupal::service('data_policy.manager')
->needConsent()) {
$items['data_policy_agreement'] = [
'title' => t('Data policy agreement'),
'url' => Url::fromRoute('data_policy.data_policy.agreement'),
'after' => 'edit_profile',
'divider' => 'before',
];
}
return $items;
}
Functions
Name | Description |
---|---|
social_gdpr_form_data_policy_data_policy_agreement_alter | Implements hook_form_FORM_ID_alter(). |
social_gdpr_form_user_register_form_alter | Implements hook_form_FORM_ID_alter(). |
social_gdpr_help | Implements hook_help(). |
social_gdpr_social_user_account_header_links | Implements hook_social_user_account_header_links(). |