13bfb94b0SGreg Roach<?php 23bfb94b0SGreg Roach/** 33bfb94b0SGreg Roach * webtrees: online genealogy 43bfb94b0SGreg Roach * Copyright (C) 2015 webtrees development team 53bfb94b0SGreg Roach * This program is free software: you can redistribute it and/or modify 63bfb94b0SGreg Roach * it under the terms of the GNU General Public License as published by 73bfb94b0SGreg Roach * the Free Software Foundation, either version 3 of the License, or 83bfb94b0SGreg Roach * (at your option) any later version. 93bfb94b0SGreg Roach * This program is distributed in the hope that it will be useful, 103bfb94b0SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 113bfb94b0SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 123bfb94b0SGreg Roach * GNU General Public License for more details. 133bfb94b0SGreg Roach * You should have received a copy of the GNU General Public License 143bfb94b0SGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>. 153bfb94b0SGreg Roach */ 16*76692c8bSGreg Roachnamespace Fisharebest\Webtrees\Schema; 17*76692c8bSGreg Roach 183bfb94b0SGreg Roachuse Fisharebest\Webtrees\Database; 193bfb94b0SGreg Roachuse Fisharebest\Webtrees\Tree; 203bfb94b0SGreg Roach 213bfb94b0SGreg Roach/** 22*76692c8bSGreg Roach * Upgrade the database schema from version 5 to version 5. 233bfb94b0SGreg Roach */ 243bfb94b0SGreg Roachclass Migration5 implements MigrationInterface { 253bfb94b0SGreg Roach /** 26*76692c8bSGreg Roach * Upgrade to to the next version 273bfb94b0SGreg Roach */ 283bfb94b0SGreg Roach public function upgrade() { 293bfb94b0SGreg Roach// - changes to the values for the gedcom setting SHOW_RELATIVES_EVENTS 303bfb94b0SGreg Roach 313bfb94b0SGreg Roach $settings = Database::prepare( 323bfb94b0SGreg Roach "SELECT gedcom_id, setting_value FROM `##gedcom_setting` WHERE setting_name='SHOW_RELATIVES_EVENTS'" 333bfb94b0SGreg Roach )->fetchAssoc(); 343bfb94b0SGreg Roach 353bfb94b0SGreg Roach foreach ($settings as $gedcom_id => $setting) { 363bfb94b0SGreg Roach // Delete old settings 373bfb94b0SGreg Roach $setting = preg_replace('/_(BIRT|MARR|DEAT)_(COUS|MSIB|FSIB|GGCH|NEPH|GGPA)/', '', $setting); 383bfb94b0SGreg Roach $setting = preg_replace('/_FAMC_(RESI_EMIG)/', '', $setting); 393bfb94b0SGreg Roach // Rename settings 403bfb94b0SGreg Roach $setting = preg_replace('/_MARR_(MOTH|FATH|FAMC)/', '_MARR_PARE', $setting); 413bfb94b0SGreg Roach $setting = preg_replace('/_DEAT_(MOTH|FATH)/', '_DEAT_PARE', $setting); 423bfb94b0SGreg Roach // Remove duplicates 433bfb94b0SGreg Roach preg_match_all('/[_A-Z]+/', $setting, $match); 443bfb94b0SGreg Roach // And save 453bfb94b0SGreg Roach Tree::findById($gedcom_id)->setPreference('SHOW_RELATIVES_EVENTS', implode(',', array_unique($match[0]))); 463bfb94b0SGreg Roach } 473bfb94b0SGreg Roach } 483bfb94b0SGreg Roach} 49