1<?php 2namespace Fisharebest\Webtrees\Module; 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 */ 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 /** {@inheritdoc} */ 37 public function getBlock($block_id, $template = true, $cfg = null) { 38 global $WT_TREE; 39 40 $id = $this->getName() . $block_id; 41 $class = $this->getName() . '_block'; 42 $title = '<span dir="auto">' . /* I18N: A greeting; %s is the user’s name */ I18N::translate('Welcome %s', Auth::user()->getRealNameHtml()) . '</span>'; 43 $content = '<table><tr>'; 44 $content .= '<td><a href="edituser.php"><i class="icon-mypage"></i><br>' . I18N::translate('My account') . '</a></td>'; 45 46 $gedcomid = $WT_TREE->getUserPreference(Auth::user(), 'gedcomid'); 47 if ($gedcomid) { 48 $content .= '<td><a href="pedigree.php?rootid=' . $gedcomid . '&ged=' . $WT_TREE->getNameUrl() . '"><i class="icon-pedigree"></i><br>' . I18N::translate('My pedigree') . '</a></td>'; 49 $content .= '<td><a href="individual.php?pid=' . $gedcomid . '&ged=' . $WT_TREE->getNameUrl() . '"><i class="icon-indis"></i><br>' . I18N::translate('My individual record') . '</a></td>'; 50 } 51 $content .= '</tr></table>'; 52 53 if ($template) { 54 return Theme::theme()->formatBlock($id, $title, $class, $content); 55 } else { 56 return $content; 57 } 58 } 59 60 /** {@inheritdoc} */ 61 public function loadAjax() { 62 return false; 63 } 64 65 /** {@inheritdoc} */ 66 public function isUserBlock() { 67 return true; 68 } 69 70 /** {@inheritdoc} */ 71 public function isGedcomBlock() { 72 return false; 73 } 74 75 /** {@inheritdoc} */ 76 public function configureBlock($block_id) { 77 } 78} 79