1c2ed51d1SGreg Roach<?php 2c2ed51d1SGreg Roach 3c2ed51d1SGreg Roach/** 4c2ed51d1SGreg Roach * webtrees: online genealogy 55bfc6897SGreg Roach * Copyright (C) 2022 webtrees development team 6c2ed51d1SGreg Roach * This program is free software: you can redistribute it and/or modify 7c2ed51d1SGreg Roach * it under the terms of the GNU General Public License as published by 8c2ed51d1SGreg Roach * the Free Software Foundation, either version 3 of the License, or 9c2ed51d1SGreg Roach * (at your option) any later version. 10c2ed51d1SGreg Roach * This program is distributed in the hope that it will be useful, 11c2ed51d1SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 12c2ed51d1SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13c2ed51d1SGreg Roach * GNU General Public License for more details. 14c2ed51d1SGreg Roach * You should have received a copy of the GNU General Public License 15c2ed51d1SGreg Roach * along with this program. If not, see <https://www.gnu.org/licenses/>. 16c2ed51d1SGreg Roach */ 17c2ed51d1SGreg Roach 18c2ed51d1SGreg Roachdeclare(strict_types=1); 19c2ed51d1SGreg Roach 20c2ed51d1SGreg Roachnamespace Fisharebest\Webtrees\Elements; 21c2ed51d1SGreg Roach 22c2ed51d1SGreg Roachuse Fisharebest\Webtrees\I18N; 23c2ed51d1SGreg Roach 24*da7adf56SGreg Roachuse function strtoupper; 25c2ed51d1SGreg Roach 26c2ed51d1SGreg Roach/** 27c2ed51d1SGreg Roach * RESTRICTION_NOTICE := {Size=6:7} 28c2ed51d1SGreg Roach * [confidential | locked | privacy ] 29c2ed51d1SGreg Roach * The restriction notice is defined for Ancestral File usage. Ancestral File 30c2ed51d1SGreg Roach * download GEDCOM files may contain this data. 31c2ed51d1SGreg Roach * Where: 32c2ed51d1SGreg Roach * confidential = This data was marked as confidential by the user. In some systems data marked as 33c2ed51d1SGreg Roach * confidential will be treated differently, for example, there might be an option 34c2ed51d1SGreg Roach * that would stop confidential data from appearing on printed reports or would 35c2ed51d1SGreg Roach * prevent that information from being exported. 36c2ed51d1SGreg Roach * locked = Some records in Ancestral File have been satisfactorily proven by evidence, but 37c2ed51d1SGreg Roach * because of source conflicts or incorrect traditions, there are repeated attempts 38c2ed51d1SGreg Roach * to change this record. By arrangement, the Ancestral File Custodian can lock a 39c2ed51d1SGreg Roach * record so that it cannot be changed without an agreement from the person assigned 40c2ed51d1SGreg Roach * as the steward of such a record. The assigned steward is either the submitter 41c2ed51d1SGreg Roach * listed for the record or Family History Support when no submitter is listed. 42c2ed51d1SGreg Roach * privacy = Indicate that information concerning this record is not present due to rights of 43c2ed51d1SGreg Roach * or an approved request for privacy. For example, data from requested downloads of 44c2ed51d1SGreg Roach * the Ancestral File may have individuals marked with ‘privacy’ if they are assumed 45c2ed51d1SGreg Roach * living, that is they were born within the last 110 years and there isn’t a death 46c2ed51d1SGreg Roach * date. In certain cases family records may also be marked with the RESN tag of 47c2ed51d1SGreg Roach * privacy if either individual acting in the role of HUSB or WIFE is assumed living. 48c2ed51d1SGreg Roach */ 49c2ed51d1SGreg Roachclass RestrictionNotice extends AbstractElement 50c2ed51d1SGreg Roach{ 51*da7adf56SGreg Roach public const VALUE_NONE = 'NONE'; 52*da7adf56SGreg Roach public const VALUE_PRIVACY = 'PRIVACY'; 53*da7adf56SGreg Roach public const VALUE_CONFIDENTIAL = 'CONFIDENTIAL'; 54*da7adf56SGreg Roach public const VALUE_LOCKED = 'LOCKED'; 5529e1664cSGreg Roach 567503bfb6SGreg Roach // Store the locked value after the privacy value. 577503bfb6SGreg Roach private const CANONICAL = [ 5888a03560SGreg Roach self::VALUE_LOCKED . ', ' . self::VALUE_NONE => self::VALUE_NONE . ', ' . self::VALUE_LOCKED, 5988a03560SGreg Roach self::VALUE_LOCKED . ', ' . self::VALUE_PRIVACY => self::VALUE_PRIVACY . ', ' . self::VALUE_LOCKED, 6088a03560SGreg Roach self::VALUE_LOCKED . ', ' . self::VALUE_CONFIDENTIAL => self::VALUE_CONFIDENTIAL . ', ' . self::VALUE_LOCKED, 617503bfb6SGreg Roach ]; 627503bfb6SGreg Roach 63c2ed51d1SGreg Roach /** 64c2ed51d1SGreg Roach * Convert a value to a canonical form. 65c2ed51d1SGreg Roach * 66c2ed51d1SGreg Roach * @param string $value 67c2ed51d1SGreg Roach * 68c2ed51d1SGreg Roach * @return string 69c2ed51d1SGreg Roach */ 70c2ed51d1SGreg Roach public function canonical(string $value): string 71c2ed51d1SGreg Roach { 72*da7adf56SGreg Roach $value = strtoupper(parent::canonical($value)); 737503bfb6SGreg Roach $value = trim($value, ', '); 747503bfb6SGreg Roach $value = preg_replace('/[, ]+/', ', ', $value); 757503bfb6SGreg Roach 767503bfb6SGreg Roach return self::CANONICAL[$value] ?? $value; 77c2ed51d1SGreg Roach } 78c2ed51d1SGreg Roach 79c2ed51d1SGreg Roach /** 80c2ed51d1SGreg Roach * A list of controlled values for this element 81c2ed51d1SGreg Roach * 82c2ed51d1SGreg Roach * @return array<int|string,string> 83c2ed51d1SGreg Roach */ 84c2ed51d1SGreg Roach public function values(): array 85c2ed51d1SGreg Roach { 86c2ed51d1SGreg Roach // Note: "1 RESN none" is not valid gedcom. 87c2ed51d1SGreg Roach // However, webtrees privacy rules will interpret it as "show an otherwise private record to public". 88c2ed51d1SGreg Roach 89c2ed51d1SGreg Roach return [ 90c2ed51d1SGreg Roach '' => '', 9188a03560SGreg Roach self::VALUE_NONE => '<i class="icon-resn-none"></i> ' . I18N::translate('Show to visitors'), 92*da7adf56SGreg Roach self::VALUE_NONE . ', ' . self::VALUE_LOCKED => '<i class="icon-resn-none"><i class="icon-resn-locked"></i> ' . I18N::translate('Show to visitors') . ' — ' . I18N::translate('Only managers can edit'), 9388a03560SGreg Roach self::VALUE_PRIVACY => '<i class="icon-resn-privacy"></i> ' . I18N::translate('Show to members'), 94*da7adf56SGreg Roach self::VALUE_PRIVACY . ', ' . self::VALUE_LOCKED => '<i class="icon-resn-privacy"><i class="icon-resn-locked"></i> ' . I18N::translate('Show to members') . ' — ' . I18N::translate('Only managers can edit'), 9588a03560SGreg Roach self::VALUE_CONFIDENTIAL => '<i class="icon-resn-confidential"></i> ' . I18N::translate('Show to managers'), 96*da7adf56SGreg Roach self::VALUE_CONFIDENTIAL . ', ' . self::VALUE_LOCKED => '<i class="icon-resn-confidential"><i class="icon-resn-locked"></i> ' . I18N::translate('Show to managers') . ' — ' . I18N::translate('Only managers can edit'), 9788a03560SGreg Roach self::VALUE_LOCKED => '<i class="icon-resn-locked"></i> ' . I18N::translate('Only managers can edit'), 98c2ed51d1SGreg Roach ]; 99c2ed51d1SGreg Roach } 100c2ed51d1SGreg Roach} 101