18c2e8227SGreg Roach<?php 28c2e8227SGreg Roach/** 38c2e8227SGreg Roach * webtrees: online genealogy 41062a142SGreg Roach * Copyright (C) 2018 webtrees development team 58c2e8227SGreg Roach * This program is free software: you can redistribute it and/or modify 68c2e8227SGreg Roach * it under the terms of the GNU General Public License as published by 78c2e8227SGreg Roach * the Free Software Foundation, either version 3 of the License, or 88c2e8227SGreg Roach * (at your option) any later version. 98c2e8227SGreg Roach * This program is distributed in the hope that it will be useful, 108c2e8227SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 118c2e8227SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 128c2e8227SGreg Roach * GNU General Public License for more details. 138c2e8227SGreg Roach * You should have received a copy of the GNU General Public License 148c2e8227SGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>. 158c2e8227SGreg Roach */ 1676692c8bSGreg Roachnamespace Fisharebest\Webtrees\Module; 1776692c8bSGreg Roach 180e62c4b8SGreg Roachuse Fisharebest\Webtrees\Auth; 190e62c4b8SGreg Roachuse Fisharebest\Webtrees\I18N; 20a0ebf380SGreg Roachuse Fisharebest\Webtrees\Individual; 214eb71cfaSGreg Roachuse Fisharebest\Webtrees\Module; 22e490cd80SGreg Roachuse Fisharebest\Webtrees\Tree; 23*a45f9889SGreg Roachuse Symfony\Component\HttpFoundation\Request; 248c2e8227SGreg Roach 258c2e8227SGreg Roach/** 268c2e8227SGreg Roach * Class UserWelcomeModule 278c2e8227SGreg Roach */ 28c1010edaSGreg Roachclass UserWelcomeModule extends AbstractModule implements ModuleBlockInterface 29c1010edaSGreg Roach{ 308c2e8227SGreg Roach /** {@inheritdoc} */ 31c1010edaSGreg Roach public function getTitle() 32c1010edaSGreg Roach { 33bbb76c12SGreg Roach /* I18N: Name of a module */ 34bbb76c12SGreg Roach return I18N::translate('My page'); 358c2e8227SGreg Roach } 368c2e8227SGreg Roach 378c2e8227SGreg Roach /** {@inheritdoc} */ 38c1010edaSGreg Roach public function getDescription() 39c1010edaSGreg Roach { 40bbb76c12SGreg Roach /* I18N: Description of the “My page” module */ 41bbb76c12SGreg Roach return I18N::translate('A greeting message and useful links for a user.'); 428c2e8227SGreg Roach } 438c2e8227SGreg Roach 4476692c8bSGreg Roach /** 4576692c8bSGreg Roach * Generate the HTML content of this block. 4676692c8bSGreg Roach * 47e490cd80SGreg Roach * @param Tree $tree 4876692c8bSGreg Roach * @param int $block_id 4976692c8bSGreg Roach * @param bool $template 50727f238cSGreg Roach * @param string[] $cfg 5176692c8bSGreg Roach * 5276692c8bSGreg Roach * @return string 5376692c8bSGreg Roach */ 54c1010edaSGreg Roach public function getBlock(Tree $tree, int $block_id, bool $template = true, array $cfg = []): string 55c1010edaSGreg Roach { 56e490cd80SGreg Roach $gedcomid = $tree->getUserPreference(Auth::user(), 'gedcomid'); 57e490cd80SGreg Roach $individual = Individual::getInstance($gedcomid, $tree); 58a0ebf380SGreg Roach $links = []; 59a0ebf380SGreg Roach 60c2faa3efSGreg Roach if ($individual) { 61e490cd80SGreg Roach if (Module::isActiveChart($tree, 'pedigree_chart')) { 62a0ebf380SGreg Roach $links[] = [ 63c1010edaSGreg Roach 'url' => route('pedigree', [ 64c1010edaSGreg Roach 'xref' => $individual->getXref(), 65c1010edaSGreg Roach 'ged' => $individual->getTree()->getName(), 66c1010edaSGreg Roach ]), 67a0ebf380SGreg Roach 'title' => I18N::translate('Default chart'), 68a0ebf380SGreg Roach 'icon' => 'icon-pedigree', 69a0ebf380SGreg Roach ]; 703f8a84f7SDavid Drury } 71a0ebf380SGreg Roach 72a0ebf380SGreg Roach $links[] = [ 73b1f1e4efSGreg Roach 'url' => $individual->url(), 74a0ebf380SGreg Roach 'title' => I18N::translate('My individual record'), 75a0ebf380SGreg Roach 'icon' => 'icon-indis', 76a0ebf380SGreg Roach ]; 778c2e8227SGreg Roach } 78a0ebf380SGreg Roach 79a0ebf380SGreg Roach $links[] = [ 804653dc2eSGreg Roach 'url' => route('my-account', []), 81a0ebf380SGreg Roach 'title' => I18N::translate('My account'), 82a0ebf380SGreg Roach 'icon' => 'icon-mypage', 83a0ebf380SGreg Roach ]; 84147e99aaSGreg Roach $content = view('modules/user_welcome/welcome', ['links' => $links]); 858c2e8227SGreg Roach 86bbb76c12SGreg Roach /* I18N: A %s is the user’s name */ 87bbb76c12SGreg Roach $title = I18N::translate('Welcome %s', Auth::user()->getRealName()); 88bbb76c12SGreg Roach 898c2e8227SGreg Roach if ($template) { 90147e99aaSGreg Roach return view('modules/block-template', [ 91d034ca3bSGreg Roach 'block' => str_replace('_', '-', $this->getName()), 92d034ca3bSGreg Roach 'id' => $block_id, 931fa06fe3SGreg Roach 'config_url' => '', 94bbb76c12SGreg Roach 'title' => $title, 95a0ebf380SGreg Roach 'content' => $content, 96a0ebf380SGreg Roach ]); 978c2e8227SGreg Roach } else { 988c2e8227SGreg Roach return $content; 998c2e8227SGreg Roach } 1008c2e8227SGreg Roach } 1018c2e8227SGreg Roach 1028c2e8227SGreg Roach /** {@inheritdoc} */ 103c1010edaSGreg Roach public function loadAjax(): bool 104c1010edaSGreg Roach { 1058c2e8227SGreg Roach return false; 1068c2e8227SGreg Roach } 1078c2e8227SGreg Roach 1088c2e8227SGreg Roach /** {@inheritdoc} */ 109c1010edaSGreg Roach public function isUserBlock(): bool 110c1010edaSGreg Roach { 1118c2e8227SGreg Roach return true; 1128c2e8227SGreg Roach } 1138c2e8227SGreg Roach 1148c2e8227SGreg Roach /** {@inheritdoc} */ 115c1010edaSGreg Roach public function isGedcomBlock(): bool 116c1010edaSGreg Roach { 1178c2e8227SGreg Roach return false; 1188c2e8227SGreg Roach } 1198c2e8227SGreg Roach 12076692c8bSGreg Roach /** 121*a45f9889SGreg Roach * Update the configuration for a block. 122*a45f9889SGreg Roach * 123*a45f9889SGreg Roach * @param Request $request 124*a45f9889SGreg Roach * @param int $block_id 125*a45f9889SGreg Roach * 126*a45f9889SGreg Roach * @return void 127*a45f9889SGreg Roach */ 128*a45f9889SGreg Roach public function saveBlockConfiguration(Request $request, int $block_id) 129*a45f9889SGreg Roach { 130*a45f9889SGreg Roach } 131*a45f9889SGreg Roach 132*a45f9889SGreg Roach /** 13376692c8bSGreg Roach * An HTML form to edit block settings 13476692c8bSGreg Roach * 135e490cd80SGreg Roach * @param Tree $tree 13676692c8bSGreg Roach * @param int $block_id 137a9430be8SGreg Roach * 138a9430be8SGreg Roach * @return void 13976692c8bSGreg Roach */ 140*a45f9889SGreg Roach public function editBlockConfiguration(Tree $tree, int $block_id) 141c1010edaSGreg Roach { 1428c2e8227SGreg Roach } 1438c2e8227SGreg Roach} 144