1*8add1155SRico Sonntag<?php 2*8add1155SRico Sonntag/** 3*8add1155SRico Sonntag * webtrees: online genealogy 4*8add1155SRico Sonntag * Copyright (C) 2018 webtrees development team 5*8add1155SRico Sonntag * This program is free software: you can redistribute it and/or modify 6*8add1155SRico Sonntag * it under the terms of the GNU General Public License as published by 7*8add1155SRico Sonntag * the Free Software Foundation, either version 3 of the License, or 8*8add1155SRico Sonntag * (at your option) any later version. 9*8add1155SRico Sonntag * This program is distributed in the hope that it will be useful, 10*8add1155SRico Sonntag * but WITHOUT ANY WARRANTY; without even the implied warranty of 11*8add1155SRico Sonntag * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12*8add1155SRico Sonntag * GNU General Public License for more details. 13*8add1155SRico Sonntag * You should have received a copy of the GNU General Public License 14*8add1155SRico Sonntag * along with this program. If not, see <http://www.gnu.org/licenses/>. 15*8add1155SRico Sonntag */ 16*8add1155SRico Sonntagdeclare(strict_types=1); 17*8add1155SRico Sonntag 18*8add1155SRico Sonntagnamespace Fisharebest\Webtrees\Statistics\Repository; 19*8add1155SRico Sonntag 20*8add1155SRico Sonntaguse Fisharebest\Webtrees\Statistics\Repository\Interfaces\ContactRepositoryInterface; 21*8add1155SRico Sonntaguse Fisharebest\Webtrees\Tree; 22*8add1155SRico Sonntaguse Fisharebest\Webtrees\User; 23*8add1155SRico Sonntaguse Symfony\Component\HttpFoundation\Request; 24*8add1155SRico Sonntag 25*8add1155SRico Sonntag/** 26*8add1155SRico Sonntag * A repository providing methods for contact related statistics. 27*8add1155SRico Sonntag */ 28*8add1155SRico Sonntagclass ContactRepository implements ContactRepositoryInterface 29*8add1155SRico Sonntag{ 30*8add1155SRico Sonntag /** 31*8add1155SRico Sonntag * @var Tree 32*8add1155SRico Sonntag */ 33*8add1155SRico Sonntag private $tree; 34*8add1155SRico Sonntag 35*8add1155SRico Sonntag /** 36*8add1155SRico Sonntag * Constructor. 37*8add1155SRico Sonntag * 38*8add1155SRico Sonntag * @param Tree $tree 39*8add1155SRico Sonntag */ 40*8add1155SRico Sonntag public function __construct(Tree $tree) 41*8add1155SRico Sonntag { 42*8add1155SRico Sonntag $this->tree = $tree; 43*8add1155SRico Sonntag } 44*8add1155SRico Sonntag 45*8add1155SRico Sonntag /** 46*8add1155SRico Sonntag * @inheritDoc 47*8add1155SRico Sonntag */ 48*8add1155SRico Sonntag public function contactWebmaster(): string 49*8add1155SRico Sonntag { 50*8add1155SRico Sonntag $user_id = $this->tree->getPreference('WEBMASTER_USER_ID'); 51*8add1155SRico Sonntag $user = User::find((int) $user_id); 52*8add1155SRico Sonntag 53*8add1155SRico Sonntag if ($user instanceof User) { 54*8add1155SRico Sonntag return view('modules/contact-links/contact', [ 55*8add1155SRico Sonntag 'request' => app()->make(Request::class), 56*8add1155SRico Sonntag 'user' => $user, 57*8add1155SRico Sonntag 'tree' => $this->tree, 58*8add1155SRico Sonntag ]); 59*8add1155SRico Sonntag } 60*8add1155SRico Sonntag 61*8add1155SRico Sonntag return ''; 62*8add1155SRico Sonntag } 63*8add1155SRico Sonntag 64*8add1155SRico Sonntag /** 65*8add1155SRico Sonntag * @inheritDoc 66*8add1155SRico Sonntag */ 67*8add1155SRico Sonntag public function contactGedcom(): string 68*8add1155SRico Sonntag { 69*8add1155SRico Sonntag $user_id = $this->tree->getPreference('CONTACT_USER_ID'); 70*8add1155SRico Sonntag $user = User::find((int) $user_id); 71*8add1155SRico Sonntag 72*8add1155SRico Sonntag if ($user instanceof User) { 73*8add1155SRico Sonntag return view('modules/contact-links/contact', [ 74*8add1155SRico Sonntag 'request' => app()->make(Request::class), 75*8add1155SRico Sonntag 'user' => $user, 76*8add1155SRico Sonntag 'tree' => $this->tree, 77*8add1155SRico Sonntag ]); 78*8add1155SRico Sonntag } 79*8add1155SRico Sonntag 80*8add1155SRico Sonntag return ''; 81*8add1155SRico Sonntag } 82*8add1155SRico Sonntag} 83