xref: /webtrees/app/Module/UserWelcomeModule.php (revision 309092efc56540a95d8117fad7180fe470aadff6)
1<?php
2namespace Fisharebest\Webtrees;
3
4/**
5 * webtrees: online genealogy
6 * Copyright (C) 2015 webtrees development team
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19/**
20 * Class UserWelcomeModule
21 */
22class UserWelcomeModule extends AbstractModule implements ModuleBlockInterface {
23	/** {@inheritdoc} */
24	public function getTitle() {
25		return /* I18N: Name of a module */ I18N::translate('My page');
26	}
27
28	/** {@inheritdoc} */
29	public function getDescription() {
30		return /* I18N: Description of the “My page” module */ I18N::translate('A greeting message and useful links for a user.');
31	}
32
33	/** {@inheritdoc} */
34	public function getBlock($block_id, $template = true, $cfg = null) {
35		global $WT_TREE;
36
37		$id = $this->getName() . $block_id;
38		$class = $this->getName() . '_block';
39		$title = '<span dir="auto">' . /* I18N: A greeting; %s is the user’s name */ I18N::translate('Welcome %s', Auth::user()->getRealNameHtml()) . '</span>';
40		$content = '<table><tr>';
41		$content .= '<td><a href="edituser.php"><i class="icon-mypage"></i><br>' . I18N::translate('My account') . '</a></td>';
42
43		$gedcomid = $WT_TREE->getUserPreference(Auth::user(), 'gedcomid');
44		if ($gedcomid) {
45			$content .= '<td><a href="pedigree.php?rootid=' . $gedcomid . '&amp;ged=' . $WT_TREE->getNameUrl() . '"><i class="icon-pedigree"></i><br>' . I18N::translate('My pedigree') . '</a></td>';
46			$content .= '<td><a href="individual.php?pid=' . $gedcomid . '&amp;ged=' . $WT_TREE->getNameUrl() . '"><i class="icon-indis"></i><br>' . I18N::translate('My individual record') . '</a></td>';
47		}
48		$content .= '</tr></table>';
49
50		if ($template) {
51			return Theme::theme()->formatBlock($id, $title, $class, $content);
52		} else {
53			return $content;
54		}
55	}
56
57	/** {@inheritdoc} */
58	public function loadAjax() {
59		return false;
60	}
61
62	/** {@inheritdoc} */
63	public function isUserBlock() {
64		return true;
65	}
66
67	/** {@inheritdoc} */
68	public function isGedcomBlock() {
69		return false;
70	}
71
72	/** {@inheritdoc} */
73	public function configureBlock($block_id) {
74	}
75}
76