Skip to content

Commit

Permalink
Merge pull request #10 from jaapjansma/settings_page
Browse files Browse the repository at this point in the history
Added settings page
  • Loading branch information
bjendres authored Jun 7, 2022
2 parents 2c2f24a + 7d051b6 commit 31d7e42
Show file tree
Hide file tree
Showing 4 changed files with 173 additions and 9 deletions.
17 changes: 8 additions & 9 deletions CRM/Anonymiser/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function __construct() {
* otherwise they will remain unchanged
*/
public function deleteTags() {
return FALSE;
return \Civi::settings()->get('anonymiser_tags');
}

/**
Expand All @@ -42,7 +42,7 @@ public function deleteTags() {
* to be deleted, otherwise they will remain unchanged
*/
public function deleteGroups() {
return FALSE;
return \Civi::settings()->get('anonymiser_groups');
}

/**
Expand All @@ -51,8 +51,7 @@ public function deleteGroups() {
* they should be anonymised
*/
public function deleteMemberships() {
return FALSE;

return \Civi::settings()->get('anonymiser_memberships');
}

/**
Expand All @@ -61,8 +60,7 @@ public function deleteMemberships() {
* otherwise they should be anonymised
*/
public function deleteParticipations() {
return FALSE;

return \Civi::settings()->get('anonymiser_participants');
}

/**
Expand All @@ -71,15 +69,16 @@ public function deleteParticipations() {
* they should be anonymised
*/
public function deleteContributions() {
return FALSE;

return \Civi::settings()->get('anonymiser_contributions');
}

/**
* looks into the settings, if certain key should be deleted/reset
*/
public function shouldDeleteAttribute($key) {
// TODO: look into config
if (\Civi::settings()->hasExplict('anonymiser_'.$key)) {
return \Civi::settings()->get('anonymiser_'.$key);
}
return TRUE;
}

Expand Down
21 changes: 21 additions & 0 deletions anonymiser.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

require_once 'anonymiser.civix.php';

use CRM_Anonymiser_ExtensionUtil as E;

/**
* Implements hook_civicrm_config().
*
Expand Down Expand Up @@ -159,3 +161,22 @@ function anonymiser_civicrm_alterAPIPermissions($entity, $action, &$params, &$pe
$permissions['contact']['anonymise'] = array('administer CiviCRM');
}

/**
* Implements hook_civicrm_navigationMenu().
*
* @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_navigationMenu
*/
function anonymiser_civicrm_navigationMenu(&$menu) {
_anonymiser_civix_insert_navigation_menu($menu, 'Administer', [
'label' => E::ts('Anonymiser Settings'),
'name' => 'anonymiser',
'permission' => 'administer CiviCRM',
'child' => [],
'operator' => 'AND',
'separator' => 0,
'url' => CRM_Utils_System::url('civicrm/admin/setting/anonymiser', 'reset=1', TRUE),
]);
_anonymiser_civix_navigationMenu($menu);
}


137 changes: 137 additions & 0 deletions settings/anonymiser.setting.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
<?php
/**
* Copyright (C) 2022 Jaap Jansma ([email protected])
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

use CRM_Anonymiser_ExtensionUtil as E;

return [
'anonymiser_groups' => [
'settings_pages' => ['anonymiser' => ['weight' => 1]],
'group_name' => E::ts('Anonymiser'),
'group' => 'anonymiser',
'name' => 'anonymiser_groups',
'type' => 'String',
'options' => [
'0' => E::ts('Keep group membership state'),
'1' => E::ts('Remove group state from contact'),
],
'default' => '0',
'html_type' => 'select',
'html_attributes' => [
'class' => 'crm-select2 huge',
],
'is_domain' => 1,
'is_contact' => 0,
'title' => E::ts('Groups'),
],
'anonymiser_tags' => [
'settings_pages' => ['anonymiser' => ['weight' => 1]],
'group_name' => E::ts('Anonymiser'),
'group' => 'anonymiser',
'name' => 'anonymiser_tags',
'type' => 'String',
'options' => [
'0' => E::ts('Keep tags'),
'1' => E::ts('Remove tags from contact'),
],
'default' => '0',
'html_type' => 'select',
'html_attributes' => [
'class' => 'crm-select2 huge',
],
'is_domain' => 1,
'is_contact' => 0,
'title' => E::ts('Tags'),
],
'anonymiser_contact_dates' => [
'settings_pages' => ['anonymiser' => ['weight' => 1]],
'group_name' => E::ts('Anonymiser'),
'group' => 'anonymiser',
'name' => 'anonymiser_contact_dates',
'type' => 'String',
'options' => [
'0' => E::ts('Keep contact dates'),
'1' => E::ts('Remove dates'),
],
'default' => '1',
'html_type' => 'select',
'html_attributes' => [
'class' => 'crm-select2 huge',
],
'is_domain' => 1,
'is_contact' => 0,
'title' => E::ts('Contact dates'),
'description' => E::ts('Contact dates are birth date, deceased date and created date. When you keep the dates they will be set to the 1st of January of that year.'),
],
'anonymiser_contributions' => [
'settings_pages' => ['anonymiser' => ['weight' => 1]],
'group_name' => E::ts('Anonymiser'),
'group' => 'anonymiser',
'name' => 'anonymiser_contributions',
'type' => 'String',
'options' => [
'0' => E::ts('Keep contributions and anonymise them'),
'1' => E::ts('Delete contribution records'),
],
'default' => '0',
'html_type' => 'select',
'html_attributes' => [
'class' => 'crm-select2 huge',
],
'is_domain' => 1,
'is_contact' => 0,
'title' => E::ts('Contributions'),
],
'anonymiser_participants' => [
'settings_pages' => ['anonymiser' => ['weight' => 1]],
'group_name' => E::ts('Anonymiser'),
'group' => 'anonymiser',
'name' => 'anonymiser_participants',
'type' => 'String',
'options' => [
'0' => E::ts('Keep participant records and anonymise them'),
'1' => E::ts('Delete participant records'),
],
'default' => '0',
'html_type' => 'select',
'html_attributes' => [
'class' => 'crm-select2 huge',
],
'is_domain' => 1,
'is_contact' => 0,
'title' => E::ts('Participants'),
],
'anonymiser_memberships' => [
'settings_pages' => ['anonymiser' => ['weight' => 1]],
'group_name' => E::ts('Anonymiser'),
'group' => 'anonymiser',
'name' => 'anonymiser_memberships',
'type' => 'String',
'options' => [
'0' => E::ts('Keep memberships and anonymise them'),
'1' => E::ts('Delete membership records'),
],
'default' => '0',
'html_type' => 'select',
'html_attributes' => [
'class' => 'crm-select2 huge',
],
'is_domain' => 1,
'is_contact' => 0,
'title' => E::ts('Memberships'),
],
];
7 changes: 7 additions & 0 deletions xml/Menu/anonymiser.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,11 @@
<title>Anonymise</title>
<access_arguments>administer CiviCRM</access_arguments>
</item>
<item>
<path>civicrm/admin/setting/anonymiser</path>
<title>Anonymiser Settings</title>
<page_callback>CRM_Admin_Form_Generic</page_callback>
<access_arguments>administer CiviCRM</access_arguments>
<weight>100</weight>
</item>
</menu>

0 comments on commit 31d7e42

Please sign in to comment.