xref: /webtrees/app/SiteUser.php (revision 4c9729fb95eef184fc375252b45de126173ab3e4)
1497ae1feSGreg Roach<?php
2497ae1feSGreg Roach/**
3497ae1feSGreg Roach * webtrees: online genealogy
4497ae1feSGreg Roach * Copyright (C) 2019 webtrees development team
5497ae1feSGreg Roach * This program is free software: you can redistribute it and/or modify
6497ae1feSGreg Roach * it under the terms of the GNU General Public License as published by
7497ae1feSGreg Roach * the Free Software Foundation, either version 3 of the License, or
8497ae1feSGreg Roach * (at your option) any later version.
9497ae1feSGreg Roach * This program is distributed in the hope that it will be useful,
10497ae1feSGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
11497ae1feSGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12497ae1feSGreg Roach * GNU General Public License for more details.
13497ae1feSGreg Roach * You should have received a copy of the GNU General Public License
14497ae1feSGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>.
15497ae1feSGreg Roach */
16497ae1feSGreg Roachdeclare(strict_types=1);
17497ae1feSGreg Roach
18497ae1feSGreg Roachnamespace Fisharebest\Webtrees;
19497ae1feSGreg Roach
20497ae1feSGreg Roachuse Fisharebest\Webtrees\Contracts\UserInterface;
21497ae1feSGreg Roach
22497ae1feSGreg Roach/**
23497ae1feSGreg Roach * The site can act as a user, for example to send email.
24*4c9729fbSGreg Roach *
25*4c9729fbSGreg Roach * Some SMTP servers insist that this is a real/validated email address.
26*4c9729fbSGreg Roach * Others are happy to accept no-reply@localhost.
27497ae1feSGreg Roach */
28497ae1feSGreg Roachclass SiteUser implements UserInterface
29497ae1feSGreg Roach{
30497ae1feSGreg Roach    /**
31497ae1feSGreg Roach     * The user‘s internal identifier.
32497ae1feSGreg Roach     *
33497ae1feSGreg Roach     * @return int
34497ae1feSGreg Roach     */
35497ae1feSGreg Roach    public function id(): int
36497ae1feSGreg Roach    {
37497ae1feSGreg Roach        return 0;
38497ae1feSGreg Roach    }
39497ae1feSGreg Roach
40497ae1feSGreg Roach    /**
41497ae1feSGreg Roach     * The users email address.
42497ae1feSGreg Roach     *
43497ae1feSGreg Roach     * @return string
44497ae1feSGreg Roach     */
45497ae1feSGreg Roach    public function email(): string
46497ae1feSGreg Roach    {
47497ae1feSGreg Roach        return Site::getPreference('SMTP_FROM_NAME', 'no-reply@localhost');
48497ae1feSGreg Roach    }
49497ae1feSGreg Roach
50497ae1feSGreg Roach    /**
51497ae1feSGreg Roach     * The user‘s real name.
52497ae1feSGreg Roach     *
53497ae1feSGreg Roach     * @return string
54497ae1feSGreg Roach     */
55497ae1feSGreg Roach    public function realName(): string
56497ae1feSGreg Roach    {
57*4c9729fbSGreg Roach        return Webtrees::NAME;
58497ae1feSGreg Roach    }
59497ae1feSGreg Roach
60497ae1feSGreg Roach    /**
61497ae1feSGreg Roach     * The user‘s login name.
62497ae1feSGreg Roach     *
63497ae1feSGreg Roach     * @return string
64497ae1feSGreg Roach     */
65497ae1feSGreg Roach    public function userName(): string
66497ae1feSGreg Roach    {
67497ae1feSGreg Roach        return '';
68497ae1feSGreg Roach    }
69497ae1feSGreg Roach
70497ae1feSGreg Roach    /**
71497ae1feSGreg Roach     * @param string $setting_name
72497ae1feSGreg Roach     * @param string $default
73497ae1feSGreg Roach     *
74497ae1feSGreg Roach     * @return string
75497ae1feSGreg Roach     */
76497ae1feSGreg Roach    public function getPreference(string $setting_name, string $default = ''): string
77497ae1feSGreg Roach    {
78497ae1feSGreg Roach        return $default;
79497ae1feSGreg Roach    }
80497ae1feSGreg Roach
81497ae1feSGreg Roach    /**
82497ae1feSGreg Roach     * @param string $setting_name
83497ae1feSGreg Roach     * @param string $setting_value
84497ae1feSGreg Roach     *
85497ae1feSGreg Roach     * @return UserInterface
86497ae1feSGreg Roach     */
87497ae1feSGreg Roach    public function setPreference(string $setting_name, string $setting_value): UserInterface
88497ae1feSGreg Roach    {
89497ae1feSGreg Roach        return $this;
90497ae1feSGreg Roach    }
91497ae1feSGreg Roach}
92