xref: /webtrees/app/Module/RecentChangesModule.php (revision 397e599a3131684b8a335ebfddcfe63828b9f51b)
18c2e8227SGreg Roach<?php
28c2e8227SGreg Roach/**
38c2e8227SGreg Roach * webtrees: online genealogy
41062a142SGreg Roach * Copyright (C) 2018 webtrees development team
58c2e8227SGreg Roach * This program is free software: you can redistribute it and/or modify
68c2e8227SGreg Roach * it under the terms of the GNU General Public License as published by
78c2e8227SGreg Roach * the Free Software Foundation, either version 3 of the License, or
88c2e8227SGreg Roach * (at your option) any later version.
98c2e8227SGreg Roach * This program is distributed in the hope that it will be useful,
108c2e8227SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
118c2e8227SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
128c2e8227SGreg Roach * GNU General Public License for more details.
138c2e8227SGreg Roach * You should have received a copy of the GNU General Public License
148c2e8227SGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>.
158c2e8227SGreg Roach */
1676692c8bSGreg Roachnamespace Fisharebest\Webtrees\Module;
1776692c8bSGreg Roach
180e62c4b8SGreg Roachuse Fisharebest\Webtrees\Auth;
1915d603e7SGreg Roachuse Fisharebest\Webtrees\Bootstrap4;
206e45321fSGreg Roachuse Fisharebest\Webtrees\Database;
210e62c4b8SGreg Roachuse Fisharebest\Webtrees\Filter;
2215d603e7SGreg Roachuse Fisharebest\Webtrees\FontAwesome;
233d7a8a4cSGreg Roachuse Fisharebest\Webtrees\Functions\FunctionsEdit;
246e45321fSGreg Roachuse Fisharebest\Webtrees\GedcomRecord;
256e45321fSGreg Roachuse Fisharebest\Webtrees\GedcomTag;
26047f239bSGreg Roachuse Fisharebest\Webtrees\Html;
270e62c4b8SGreg Roachuse Fisharebest\Webtrees\I18N;
286e45321fSGreg Roachuse Fisharebest\Webtrees\Individual;
296e45321fSGreg Roachuse Fisharebest\Webtrees\Tree;
30577e6b29SGreg Roachuse Ramsey\Uuid\Uuid;
318c2e8227SGreg Roach
328c2e8227SGreg Roach/**
338c2e8227SGreg Roach * Class RecentChangesModule
348c2e8227SGreg Roach */
35e2a378d3SGreg Roachclass RecentChangesModule extends AbstractModule implements ModuleBlockInterface {
366e45321fSGreg Roach	const DEFAULT_BLOCK      = '1';
378c2e8227SGreg Roach	const DEFAULT_DAYS       = 7;
386e45321fSGreg Roach	const DEFAULT_HIDE_EMPTY = '0';
396e45321fSGreg Roach	const DEFAULT_SHOW_USER  = '1';
406e45321fSGreg Roach	const DEFAULT_SORT_STYLE = 'date_desc';
416e45321fSGreg Roach	const DEFAULT_INFO_STYLE = 'table';
428c2e8227SGreg Roach	const MAX_DAYS           = 90;
438c2e8227SGreg Roach
448c2e8227SGreg Roach	/** {@inheritdoc} */
458c2e8227SGreg Roach	public function getTitle() {
468c2e8227SGreg Roach		return /* I18N: Name of a module */ I18N::translate('Recent changes');
478c2e8227SGreg Roach	}
488c2e8227SGreg Roach
498c2e8227SGreg Roach	/** {@inheritdoc} */
508c2e8227SGreg Roach	public function getDescription() {
518c2e8227SGreg Roach		return /* I18N: Description of the “Recent changes” module */ I18N::translate('A list of records that have been updated recently.');
528c2e8227SGreg Roach	}
538c2e8227SGreg Roach
546e45321fSGreg Roach	/** {@inheritdoc} */
55a9430be8SGreg Roach	public function getBlock($block_id, $template = true, $cfg = []): string {
564b9ff166SGreg Roach		global $ctype, $WT_TREE;
578c2e8227SGreg Roach
58e2a378d3SGreg Roach		$days      = $this->getBlockSetting($block_id, 'days', self::DEFAULT_DAYS);
596e45321fSGreg Roach		$infoStyle = $this->getBlockSetting($block_id, 'infoStyle', self::DEFAULT_INFO_STYLE);
606e45321fSGreg Roach		$sortStyle = $this->getBlockSetting($block_id, 'sortStyle', self::DEFAULT_SORT_STYLE);
616e45321fSGreg Roach		$show_user = $this->getBlockSetting($block_id, 'show_user', self::DEFAULT_SHOW_USER);
628c2e8227SGreg Roach
6315d603e7SGreg Roach		foreach (['days', 'infoStyle', 'sortStyle', 'show_user'] as $name) {
648c2e8227SGreg Roach			if (array_key_exists($name, $cfg)) {
658c2e8227SGreg Roach				$$name = $cfg[$name];
668c2e8227SGreg Roach			}
678c2e8227SGreg Roach		}
688c2e8227SGreg Roach
6924319d9dSGreg Roach		$records = $this->getRecentChanges($WT_TREE, $days);
708c2e8227SGreg Roach
718c2e8227SGreg Roach		$content = '';
728c2e8227SGreg Roach		// Print block content
738cbbfdceSGreg Roach		if (empty($records)) {
748c2e8227SGreg Roach			$content .= I18N::plural('There have been no changes within the last %s day.', 'There have been no changes within the last %s days.', $days, I18N::number($days));
758c2e8227SGreg Roach		} else {
768c2e8227SGreg Roach			switch ($infoStyle) {
778c2e8227SGreg Roach				case 'list':
786e45321fSGreg Roach					$content .= $this->changesList($records, $sortStyle, $show_user);
798c2e8227SGreg Roach					break;
808c2e8227SGreg Roach				case 'table':
816e45321fSGreg Roach					$content .= $this->changesTable($records, $sortStyle, $show_user);
828c2e8227SGreg Roach					break;
838c2e8227SGreg Roach			}
848c2e8227SGreg Roach		}
858c2e8227SGreg Roach
868c2e8227SGreg Roach		if ($template) {
87*397e599aSGreg Roach			if ($ctype === 'gedcom' && Auth::isManager($WT_TREE)) {
88*397e599aSGreg Roach				$config_url = route('tree-page-block-edit', ['block_id' => $block_id, 'ged' => $WT_TREE->getName()]);
89*397e599aSGreg Roach			} elseif ($ctype === 'user' && Auth::check()) {
90*397e599aSGreg Roach				$config_url = route('user-page-block-edit', ['block_id' => $block_id, 'ged' => $WT_TREE->getName()]);
918cbbfdceSGreg Roach			} else {
928cbbfdceSGreg Roach				$config_url = '';
938cbbfdceSGreg Roach			}
948cbbfdceSGreg Roach
95225e381fSGreg Roach			return view('blocks/template', [
969c6524dcSGreg Roach				'block'      => str_replace('_', '-', $this->getName()),
979c6524dcSGreg Roach				'id'         => $block_id,
988cbbfdceSGreg Roach				'config_url' => $config_url,
998cbbfdceSGreg Roach				'title'      => I18N::plural('Changes in the last %s day', 'Changes in the last %s days', $days, I18N::number($days)),
1009c6524dcSGreg Roach				'content'    => $content,
1019c6524dcSGreg Roach			]);
1028c2e8227SGreg Roach		} else {
1038c2e8227SGreg Roach			return $content;
1048c2e8227SGreg Roach		}
1058c2e8227SGreg Roach	}
1068c2e8227SGreg Roach
1078c2e8227SGreg Roach	/** {@inheritdoc} */
108a9430be8SGreg Roach	public function loadAjax(): bool {
1098c2e8227SGreg Roach		return true;
1108c2e8227SGreg Roach	}
1118c2e8227SGreg Roach
1128c2e8227SGreg Roach	/** {@inheritdoc} */
113a9430be8SGreg Roach	public function isUserBlock(): bool {
1148c2e8227SGreg Roach		return true;
1158c2e8227SGreg Roach	}
1168c2e8227SGreg Roach
1178c2e8227SGreg Roach	/** {@inheritdoc} */
118a9430be8SGreg Roach	public function isGedcomBlock(): bool {
1198c2e8227SGreg Roach		return true;
1208c2e8227SGreg Roach	}
1218c2e8227SGreg Roach
1226e45321fSGreg Roach	/** {@inheritdoc} */
123be9a728cSGreg Roach	public function configureBlock($block_id) {
1248c2e8227SGreg Roach		if (Filter::postBool('save') && Filter::checkCsrf()) {
1256e45321fSGreg Roach			$this->setBlockSetting($block_id, 'days', Filter::postInteger('days', 1, self::MAX_DAYS));
1266e45321fSGreg Roach			$this->setBlockSetting($block_id, 'infoStyle', Filter::post('infoStyle', 'list|table'));
1276e45321fSGreg Roach			$this->setBlockSetting($block_id, 'sortStyle', Filter::post('sortStyle', 'name|date_asc|date_desc'));
128782f6af0SGreg Roach			$this->setBlockSetting($block_id, 'show_user', Filter::postBool('show_user'));
1298c2e8227SGreg Roach		}
1308c2e8227SGreg Roach
131e2a378d3SGreg Roach		$days      = $this->getBlockSetting($block_id, 'days', self::DEFAULT_DAYS);
1326e45321fSGreg Roach		$infoStyle = $this->getBlockSetting($block_id, 'infoStyle', self::DEFAULT_INFO_STYLE);
1336e45321fSGreg Roach		$sortStyle = $this->getBlockSetting($block_id, 'sortStyle', self::DEFAULT_SORT_STYLE);
1346e45321fSGreg Roach		$show_user = $this->getBlockSetting($block_id, 'show_user', self::DEFAULT_SHOW_USER);
1358c2e8227SGreg Roach
13615d603e7SGreg Roach		echo '<div class="form-group row"><label class="col-sm-3 col-form-label" for="days">';
1378c2e8227SGreg Roach		echo I18N::translate('Number of days to show');
13815d603e7SGreg Roach		echo '</div><div class="col-sm-9">';
1398c2e8227SGreg Roach		echo '<input type="text" name="days" size="2" value="', $days, '">';
14015d603e7SGreg Roach		echo ' ' . I18N::plural('maximum %s day', 'maximum %s days', I18N::number(self::MAX_DAYS), I18N::number(self::MAX_DAYS));
14115d603e7SGreg Roach		echo '</div></div>';
1428c2e8227SGreg Roach
14315d603e7SGreg Roach		echo '<div class="form-group row"><label class="col-sm-3 col-form-label" for="infoStyle">';
1448c2e8227SGreg Roach		echo I18N::translate('Presentation style');
14515d603e7SGreg Roach		echo '</div><div class="col-sm-9">';
14615d603e7SGreg Roach		echo Bootstrap4::select(['list' => I18N::translate('list'), 'table' => I18N::translate('table')], $infoStyle, ['id' => 'infoStyle', 'name' => 'infoStyle']);
14715d603e7SGreg Roach		echo '</div></div>';
1488c2e8227SGreg Roach
14915d603e7SGreg Roach		echo '<div class="form-group row"><label class="col-sm-3 col-form-label" for="sortStyle">';
1508c2e8227SGreg Roach		echo I18N::translate('Sort order');
15115d603e7SGreg Roach		echo '</div><div class="col-sm-9">';
15215d603e7SGreg Roach		echo Bootstrap4::select([
1538c2e8227SGreg Roach			'name'      => /* I18N: An option in a list-box */ I18N::translate('sort by name'),
1548c2e8227SGreg Roach			'date_asc'  => /* I18N: An option in a list-box */ I18N::translate('sort by date, oldest first'),
155cbc1590aSGreg Roach			'date_desc' => /* I18N: An option in a list-box */ I18N::translate('sort by date, newest first'),
15615d603e7SGreg Roach		], $sortStyle, ['id' => 'sortStyle', 'name' => 'sortStyle']);
15715d603e7SGreg Roach		echo '</div></div>';
1588c2e8227SGreg Roach
15915d603e7SGreg Roach		echo '<div class="form-group row"><label class="col-sm-3 col-form-label" for="show_usere">';
160782f6af0SGreg Roach		echo /* I18N: label for a yes/no option */ I18N::translate('Show the user who made the change');
16115d603e7SGreg Roach		echo '</div><div class="col-sm-9">';
16215d603e7SGreg Roach		echo Bootstrap4::radioButtons('show_user', FunctionsEdit::optionsNoYes(), $show_user, true);
16315d603e7SGreg Roach		echo '</div></div>';
1648c2e8227SGreg Roach	}
1658c2e8227SGreg Roach
1666e45321fSGreg Roach	/**
1676e45321fSGreg Roach	 * Find records that have changed since a given julian day
1686e45321fSGreg Roach	 *
1696e45321fSGreg Roach	 * @param Tree $tree Changes for which tree
17024319d9dSGreg Roach	 * @param int  $days Number of days
1716e45321fSGreg Roach	 *
1726e45321fSGreg Roach	 * @return GedcomRecord[] List of records with changes
1736e45321fSGreg Roach	 */
17424319d9dSGreg Roach	private function getRecentChanges(Tree $tree, $days) {
1756e45321fSGreg Roach		$sql =
17624319d9dSGreg Roach			"SELECT xref FROM `##change`" .
177b03b6f21SGreg Roach			" WHERE new_gedcom != '' AND change_time > DATE_SUB(NOW(), INTERVAL :days DAY) AND gedcom_id = :tree_id" .
17824319d9dSGreg Roach			" GROUP BY xref" .
17924319d9dSGreg Roach			" ORDER BY MAX(change_id) DESC";
1806e45321fSGreg Roach
18113abd6f3SGreg Roach		$vars = [
18224319d9dSGreg Roach			'days'    => $days,
1836e45321fSGreg Roach			'tree_id' => $tree->getTreeId(),
18413abd6f3SGreg Roach		];
1856e45321fSGreg Roach
1866e45321fSGreg Roach		$xrefs = Database::prepare($sql)->execute($vars)->fetchOneColumn();
1876e45321fSGreg Roach
18813abd6f3SGreg Roach		$records = [];
1896e45321fSGreg Roach		foreach ($xrefs as $xref) {
1906e45321fSGreg Roach			$record = GedcomRecord::getInstance($xref, $tree);
1918e8029e5SRico Sonntag			if ($record && $record->canShow()) {
1926e45321fSGreg Roach				$records[] = $record;
1936e45321fSGreg Roach			}
1946e45321fSGreg Roach		}
1956e45321fSGreg Roach
1966e45321fSGreg Roach		return $records;
1976e45321fSGreg Roach	}
1986e45321fSGreg Roach
1996e45321fSGreg Roach	/**
2006e45321fSGreg Roach	 * Format a table of events
2016e45321fSGreg Roach	 *
2026e45321fSGreg Roach	 * @param GedcomRecord[] $records
2036e45321fSGreg Roach	 * @param string         $sort
2046e45321fSGreg Roach	 * @param bool           $show_user
2056e45321fSGreg Roach	 *
2066e45321fSGreg Roach	 * @return string
2076e45321fSGreg Roach	 */
2086e45321fSGreg Roach	private function changesList(array $records, $sort, $show_user) {
2096e45321fSGreg Roach		switch ($sort) {
2106e45321fSGreg Roach			case 'name':
21113abd6f3SGreg Roach				uasort($records, ['self', 'sortByNameAndChangeDate']);
2126e45321fSGreg Roach				break;
2136e45321fSGreg Roach			case 'date_asc':
21413abd6f3SGreg Roach				uasort($records, ['self', 'sortByChangeDateAndName']);
2156e45321fSGreg Roach				$records = array_reverse($records);
2166e45321fSGreg Roach				break;
2176e45321fSGreg Roach			case 'date_desc':
21813abd6f3SGreg Roach				uasort($records, ['self', 'sortByChangeDateAndName']);
2196e45321fSGreg Roach		}
2206e45321fSGreg Roach
2216e45321fSGreg Roach		$html = '';
2226e45321fSGreg Roach		foreach ($records as $record) {
223b1f1e4efSGreg Roach			$html .= '<a href="' . e($record->url()) . '" class="list_item name2">' . $record->getFullName() . '</a>';
2246e45321fSGreg Roach			$html .= '<div class="indent" style="margin-bottom: 5px;">';
2256e45321fSGreg Roach			if ($record instanceof Individual) {
2266e45321fSGreg Roach				if ($record->getAddName()) {
227b1f1e4efSGreg Roach					$html .= '<a href="' . e($record->url()) . '" class="list_item">' . $record->getAddName() . '</a>';
2286e45321fSGreg Roach				}
2296e45321fSGreg Roach			}
23056834ce1SGreg Roach
23156834ce1SGreg Roach			// The timestamp may be missing or private.
23256834ce1SGreg Roach			$timestamp = $record->lastChangeTimestamp();
23356834ce1SGreg Roach			if ($timestamp !== '') {
2346e45321fSGreg Roach				if ($show_user) {
2356e45321fSGreg Roach					$html .= /* I18N: [a record was] Changed on <date/time> by <user> */
236d53324c9SGreg Roach						I18N::translate('Changed on %1$s by %2$s', $timestamp, e($record->lastChangeUser()));
2376e45321fSGreg Roach				} else {
2386e45321fSGreg Roach					$html .= /* I18N: [a record was] Changed on <date/time> */
23956834ce1SGreg Roach						I18N::translate('Changed on %1$s', $timestamp);
24056834ce1SGreg Roach				}
2416e45321fSGreg Roach			}
2426e45321fSGreg Roach			$html .= '</div>';
2436e45321fSGreg Roach		}
2446e45321fSGreg Roach
2456e45321fSGreg Roach		return $html;
2466e45321fSGreg Roach	}
2476e45321fSGreg Roach
2486e45321fSGreg Roach	/**
2496e45321fSGreg Roach	 * Format a table of events
2506e45321fSGreg Roach	 *
2516e45321fSGreg Roach	 * @param GedcomRecord[] $records
2526e45321fSGreg Roach	 * @param string         $sort
2536e45321fSGreg Roach	 * @param bool           $show_user
2546e45321fSGreg Roach	 *
2556e45321fSGreg Roach	 * @return string
2566e45321fSGreg Roach	 */
2576e45321fSGreg Roach	private function changesTable($records, $sort, $show_user) {
2586e45321fSGreg Roach		global $controller;
2596e45321fSGreg Roach
2606e45321fSGreg Roach		$table_id = 'table-chan-' . Uuid::uuid4(); // lists requires a unique ID in case there are multiple lists per page
2616e45321fSGreg Roach
2626e45321fSGreg Roach		switch ($sort) {
2636e45321fSGreg Roach			case 'name':
2646e45321fSGreg Roach			default:
2650c597aa6SGreg Roach				$aaSorting = "[1,'asc'], [2,'desc']";
2666e45321fSGreg Roach				break;
2676e45321fSGreg Roach			case 'date_asc':
2680c597aa6SGreg Roach				$aaSorting = "[2,'asc'], [1,'asc']";
2696e45321fSGreg Roach				break;
2706e45321fSGreg Roach			case 'date_desc':
2710c597aa6SGreg Roach				$aaSorting = "[2,'desc'], [1,'asc']";
2726e45321fSGreg Roach				break;
2736e45321fSGreg Roach		}
2746e45321fSGreg Roach
2756e45321fSGreg Roach		$html = '';
2766e45321fSGreg Roach		$controller
2776e45321fSGreg Roach			->addInlineJavascript('
27815d603e7SGreg Roach				$("#' . $table_id . '").dataTable({
2796e45321fSGreg Roach					dom: \'t\',
2806e45321fSGreg Roach					paging: false,
2816e45321fSGreg Roach					autoWidth:false,
2826e45321fSGreg Roach					lengthChange: false,
2836e45321fSGreg Roach					filter: false,
2846e45321fSGreg Roach					' . I18N::datatablesI18N() . ',
2856e45321fSGreg Roach					sorting: [' . $aaSorting . '],
2866e45321fSGreg Roach					columns: [
2870c597aa6SGreg Roach						{ sortable: false, class: "center" },
2880c597aa6SGreg Roach						null,
2890c597aa6SGreg Roach						null,
2900c597aa6SGreg Roach						{ visible: ' . ($show_user ? 'true' : 'false') . ' }
2916e45321fSGreg Roach					]
2926e45321fSGreg Roach				});
2936e45321fSGreg Roach			');
2946e45321fSGreg Roach
2956a2ec9e1Smakitso		$html .= '<table id="' . $table_id . '" class="width100">';
2966e45321fSGreg Roach		$html .= '<thead><tr>';
2976e45321fSGreg Roach		$html .= '<th></th>';
2986e45321fSGreg Roach		$html .= '<th>' . I18N::translate('Record') . '</th>';
29915d603e7SGreg Roach		$html .= '<th>' . I18N::translate('Last change') . '</th>';
3006e45321fSGreg Roach		$html .= '<th>' . GedcomTag::getLabel('_WT_USER') . '</th>';
3016e45321fSGreg Roach		$html .= '</tr></thead><tbody>';
3026e45321fSGreg Roach
3036e45321fSGreg Roach		foreach ($records as $record) {
3046e45321fSGreg Roach			$html .= '<tr><td>';
3056e45321fSGreg Roach			switch ($record::RECORD_TYPE) {
3066e45321fSGreg Roach				case 'INDI':
30715d603e7SGreg Roach					$html .= FontAwesome::semanticIcon('individual', I18N::translate('Individual'));
3086e45321fSGreg Roach					break;
3096e45321fSGreg Roach				case 'FAM':
31015d603e7SGreg Roach					$html .= FontAwesome::semanticicon('family', I18N::translate('Family'));
3116e45321fSGreg Roach					break;
3126e45321fSGreg Roach				case 'OBJE':
31315d603e7SGreg Roach					$html .= FontAwesome::semanticIcon('media', I18N::translate('Media'));
3146e45321fSGreg Roach					break;
3156e45321fSGreg Roach				case 'NOTE':
31615d603e7SGreg Roach					$html .= FontAwesome::semanticIcon('note', I18N::translate('Note'));
3176e45321fSGreg Roach					break;
3186e45321fSGreg Roach				case 'SOUR':
31915d603e7SGreg Roach					$html .= FontAwesome::semanticIcon('source', I18N::translate('Source'));
32015d603e7SGreg Roach					break;
32115d603e7SGreg Roach				case 'SUBM':
32215d603e7SGreg Roach					$html .= FontAwesome::semanticIcon('submitter', I18N::translate('Submitter'));
3236e45321fSGreg Roach					break;
3246e45321fSGreg Roach				case 'REPO':
32515d603e7SGreg Roach					$html .= FontAwesome::semanticIcon('repository', I18N::translate('Repository'));
3266e45321fSGreg Roach					break;
3276e45321fSGreg Roach			}
3286e45321fSGreg Roach			$html .= '</td>';
329d53324c9SGreg Roach			$html .= '<td data-sort="' . e($record->getSortName()) . '">';
330b1f1e4efSGreg Roach			$html .= '<a href="' . e($record->url()) . '">' . $record->getFullName() . '</a>';
3316e45321fSGreg Roach			$addname = $record->getAddName();
3326e45321fSGreg Roach			if ($addname) {
333b1f1e4efSGreg Roach				$html .= '<div class="indent"><a href="' . e($record->url()) . '">' . $addname . '</a></div>';
3346e45321fSGreg Roach			}
3356e45321fSGreg Roach			$html .= '</td>';
3360c597aa6SGreg Roach			$html .= '<td data-sort="' . $record->lastChangeTimestamp(true) . '">' . $record->lastChangeTimestamp() . '</td>';
337d53324c9SGreg Roach			$html .= '<td>' . e($record->lastChangeUser()) . '</td>';
3386e45321fSGreg Roach			$html .= '</tr>';
3396e45321fSGreg Roach		}
3406e45321fSGreg Roach
3416e45321fSGreg Roach		$html .= '</tbody></table>';
3426e45321fSGreg Roach
3436e45321fSGreg Roach		return $html;
3446e45321fSGreg Roach	}
3456e45321fSGreg Roach
3466e45321fSGreg Roach	/**
3476e45321fSGreg Roach	 * Sort the records by (1) last change date and (2) name
3486e45321fSGreg Roach	 *
3496e45321fSGreg Roach	 * @param GedcomRecord $a
3506e45321fSGreg Roach	 * @param GedcomRecord $b
3516e45321fSGreg Roach	 *
3526e45321fSGreg Roach	 * @return int
3536e45321fSGreg Roach	 */
3546e45321fSGreg Roach	private static function sortByChangeDateAndName(GedcomRecord $a, GedcomRecord $b) {
3556e45321fSGreg Roach		return $b->lastChangeTimestamp(true) - $a->lastChangeTimestamp(true) ?: GedcomRecord::compare($a, $b);
3566e45321fSGreg Roach	}
3576e45321fSGreg Roach
3586e45321fSGreg Roach	/**
3596e45321fSGreg Roach	 * Sort the records by (1) name and (2) last change date
3606e45321fSGreg Roach	 *
3616e45321fSGreg Roach	 * @param GedcomRecord $a
3626e45321fSGreg Roach	 * @param GedcomRecord $b
3636e45321fSGreg Roach	 *
3646e45321fSGreg Roach	 * @return int
3656e45321fSGreg Roach	 */
3666e45321fSGreg Roach	private static function sortByNameAndChangeDate(GedcomRecord $a, GedcomRecord $b) {
3676e45321fSGreg Roach		return GedcomRecord::compare($a, $b) ?: $b->lastChangeTimestamp(true) - $a->lastChangeTimestamp(true);
3686e45321fSGreg Roach	}
3698c2e8227SGreg Roach}
370