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