2018-06-29 11:04:35 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* Contains opencase_defaults.module.
|
|
|
|
*/
|
|
|
|
|
2021-08-26 16:56:44 +00:00
|
|
|
use Drupal\Core\Access\AccessResult;
|
|
|
|
use Drupal\Core\Field\BaseFieldDefinition;
|
2018-06-29 11:04:35 +00:00
|
|
|
use Drupal\Core\Routing\RouteMatchInterface;
|
2018-10-26 10:23:21 +00:00
|
|
|
use Drupal\user\Entity\Role;
|
|
|
|
use Drupal\user\RoleInterface;
|
2021-12-04 09:08:11 +00:00
|
|
|
use Drupal\opencase_defaults\EntityTypeRelationsWidget;
|
2018-10-26 10:23:21 +00:00
|
|
|
|
2018-06-29 11:04:35 +00:00
|
|
|
/**
|
|
|
|
* Implements hook_help().
|
|
|
|
*/
|
|
|
|
function opencase_defaults_help($route_name, RouteMatchInterface $route_match) {
|
|
|
|
switch ($route_name) {
|
|
|
|
// Main module help for the opencase_defaults module.
|
|
|
|
case 'help.page.opencase_defaults':
|
|
|
|
$output = '';
|
|
|
|
$output .= '<h3>' . t('About') . '</h3>';
|
|
|
|
$output .= '<p>' . t('OpenCase Default Configuration') . '</p>';
|
|
|
|
return $output;
|
|
|
|
|
|
|
|
default:
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements hook_theme().
|
|
|
|
*/
|
|
|
|
function opencase_defaults_theme() {
|
|
|
|
return [
|
|
|
|
'opencase_defaults' => [
|
|
|
|
'render element' => 'children',
|
|
|
|
],
|
|
|
|
];
|
|
|
|
}
|
2019-06-09 12:58:39 +00:00
|
|
|
|
2020-11-17 11:09:17 +00:00
|
|
|
|
2020-11-17 11:24:18 +00:00
|
|
|
function opencase_defaults_entity_base_field_info($entity_type) {
|
|
|
|
$fields = array();
|
2020-11-20 11:00:52 +00:00
|
|
|
|
|
|
|
// Add consent field to person
|
|
|
|
if ($entity_type->id() === 'oc_actor') {
|
|
|
|
$fields['consent'] = BaseFieldDefinition::create('boolean')
|
|
|
|
->setLabel(t('Consent to data storage'))
|
|
|
|
->setDescription(t('Has this person explicitly consented to having their personal data stored on this system?'))
|
|
|
|
->setRevisionable(TRUE)
|
|
|
|
->setDefaultValue(FALSE)
|
|
|
|
->setRequired(TRUE)
|
|
|
|
->setDisplayOptions('form', array(
|
|
|
|
'type' => 'boolean_checkbox',
|
|
|
|
'weight' => -6,
|
|
|
|
));
|
|
|
|
}
|
2020-11-17 11:24:18 +00:00
|
|
|
return $fields;
|
|
|
|
}
|
|
|
|
|
2020-11-20 12:04:22 +00:00
|
|
|
/**
|
|
|
|
* Implements hook_form_ID_alter
|
|
|
|
*/
|
|
|
|
function opencase_defaults_form_oc_case_type_add_form_alter(&$form, $form_state) {
|
|
|
|
$widget = new EntityTypeRelationsWidget();
|
|
|
|
$widget->setup($form);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements hook_form_ID_alter
|
|
|
|
*/
|
|
|
|
function opencase_defaults_form_oc_case_type_edit_form_alter(&$form, $form_state) {
|
|
|
|
$widget = new EntityTypeRelationsWidget();
|
|
|
|
$widget->setup($form);
|
|
|
|
$widget->populate($form);
|
|
|
|
}
|
|
|
|
|