18c2e8227SGreg Roach<?php 28c2e8227SGreg Roach/** 38c2e8227SGreg Roach * webtrees: online genealogy 4*8fcd0d32SGreg Roach * Copyright (C) 2019 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 */ 16e7f56f2aSGreg Roachdeclare(strict_types=1); 17e7f56f2aSGreg Roach 1876692c8bSGreg Roachnamespace Fisharebest\Webtrees\Module; 1976692c8bSGreg Roach 200e62c4b8SGreg Roachuse Fisharebest\Webtrees\Auth; 210e62c4b8SGreg Roachuse Fisharebest\Webtrees\I18N; 22a0ebf380SGreg Roachuse Fisharebest\Webtrees\Individual; 234eb71cfaSGreg Roachuse Fisharebest\Webtrees\Module; 24e490cd80SGreg Roachuse Fisharebest\Webtrees\Tree; 25a45f9889SGreg Roachuse Symfony\Component\HttpFoundation\Request; 268c2e8227SGreg Roach 278c2e8227SGreg Roach/** 288c2e8227SGreg Roach * Class UserWelcomeModule 298c2e8227SGreg Roach */ 30c1010edaSGreg Roachclass UserWelcomeModule extends AbstractModule implements ModuleBlockInterface 31c1010edaSGreg Roach{ 328c2e8227SGreg Roach /** {@inheritdoc} */ 338f53f488SRico Sonntag public function getTitle(): string 34c1010edaSGreg Roach { 35bbb76c12SGreg Roach /* I18N: Name of a module */ 36bbb76c12SGreg Roach return I18N::translate('My page'); 378c2e8227SGreg Roach } 388c2e8227SGreg Roach 398c2e8227SGreg Roach /** {@inheritdoc} */ 408f53f488SRico Sonntag public function getDescription(): string 41c1010edaSGreg Roach { 42bbb76c12SGreg Roach /* I18N: Description of the “My page” module */ 43bbb76c12SGreg Roach return I18N::translate('A greeting message and useful links for a user.'); 448c2e8227SGreg Roach } 458c2e8227SGreg Roach 4676692c8bSGreg Roach /** 4776692c8bSGreg Roach * Generate the HTML content of this block. 4876692c8bSGreg Roach * 49e490cd80SGreg Roach * @param Tree $tree 5076692c8bSGreg Roach * @param int $block_id 515f2ae573SGreg Roach * @param string $ctype 52727f238cSGreg Roach * @param string[] $cfg 5376692c8bSGreg Roach * 5476692c8bSGreg Roach * @return string 5576692c8bSGreg Roach */ 565f2ae573SGreg Roach public function getBlock(Tree $tree, int $block_id, string $ctype = '', array $cfg = []): string 57c1010edaSGreg Roach { 58e490cd80SGreg Roach $gedcomid = $tree->getUserPreference(Auth::user(), 'gedcomid'); 59e490cd80SGreg Roach $individual = Individual::getInstance($gedcomid, $tree); 60a0ebf380SGreg Roach $links = []; 61a0ebf380SGreg Roach 62c2faa3efSGreg Roach if ($individual) { 63e490cd80SGreg Roach if (Module::isActiveChart($tree, 'pedigree_chart')) { 64a0ebf380SGreg Roach $links[] = [ 65c1010edaSGreg Roach 'url' => route('pedigree', [ 66c0935879SGreg Roach 'xref' => $individual->xref(), 67f4afa648SGreg Roach 'ged' => $individual->tree()->name(), 68c1010edaSGreg Roach ]), 69a0ebf380SGreg Roach 'title' => I18N::translate('Default chart'), 70a0ebf380SGreg Roach 'icon' => 'icon-pedigree', 71a0ebf380SGreg Roach ]; 723f8a84f7SDavid Drury } 73a0ebf380SGreg Roach 74a0ebf380SGreg Roach $links[] = [ 75b1f1e4efSGreg Roach 'url' => $individual->url(), 76a0ebf380SGreg Roach 'title' => I18N::translate('My individual record'), 77a0ebf380SGreg Roach 'icon' => 'icon-indis', 78a0ebf380SGreg Roach ]; 798c2e8227SGreg Roach } 80a0ebf380SGreg Roach 81a0ebf380SGreg Roach $links[] = [ 824653dc2eSGreg Roach 'url' => route('my-account', []), 83a0ebf380SGreg Roach 'title' => I18N::translate('My account'), 84a0ebf380SGreg Roach 'icon' => 'icon-mypage', 85a0ebf380SGreg Roach ]; 86147e99aaSGreg Roach $content = view('modules/user_welcome/welcome', ['links' => $links]); 878c2e8227SGreg Roach 88bbb76c12SGreg Roach /* I18N: A %s is the user’s name */ 89bbb76c12SGreg Roach $title = I18N::translate('Welcome %s', Auth::user()->getRealName()); 90bbb76c12SGreg Roach 916a8879feSGreg Roach if ($ctype !== '') { 92147e99aaSGreg Roach return view('modules/block-template', [ 93d034ca3bSGreg Roach 'block' => str_replace('_', '-', $this->getName()), 94d034ca3bSGreg Roach 'id' => $block_id, 951fa06fe3SGreg Roach 'config_url' => '', 96bbb76c12SGreg Roach 'title' => $title, 97a0ebf380SGreg Roach 'content' => $content, 98a0ebf380SGreg Roach ]); 998c2e8227SGreg Roach } 100b2ce94c6SRico Sonntag 101b2ce94c6SRico Sonntag return $content; 1028c2e8227SGreg Roach } 1038c2e8227SGreg Roach 1048c2e8227SGreg Roach /** {@inheritdoc} */ 105c1010edaSGreg Roach public function loadAjax(): bool 106c1010edaSGreg Roach { 1078c2e8227SGreg Roach return false; 1088c2e8227SGreg Roach } 1098c2e8227SGreg Roach 1108c2e8227SGreg Roach /** {@inheritdoc} */ 111c1010edaSGreg Roach public function isUserBlock(): bool 112c1010edaSGreg Roach { 1138c2e8227SGreg Roach return true; 1148c2e8227SGreg Roach } 1158c2e8227SGreg Roach 1168c2e8227SGreg Roach /** {@inheritdoc} */ 117c1010edaSGreg Roach public function isGedcomBlock(): bool 118c1010edaSGreg Roach { 1198c2e8227SGreg Roach return false; 1208c2e8227SGreg Roach } 1218c2e8227SGreg Roach 12276692c8bSGreg Roach /** 123a45f9889SGreg Roach * Update the configuration for a block. 124a45f9889SGreg Roach * 125a45f9889SGreg Roach * @param Request $request 126a45f9889SGreg Roach * @param int $block_id 127a45f9889SGreg Roach * 128a45f9889SGreg Roach * @return void 129a45f9889SGreg Roach */ 130a45f9889SGreg Roach public function saveBlockConfiguration(Request $request, int $block_id) 131a45f9889SGreg Roach { 132a45f9889SGreg Roach } 133a45f9889SGreg Roach 134a45f9889SGreg Roach /** 13576692c8bSGreg Roach * An HTML form to edit block settings 13676692c8bSGreg Roach * 137e490cd80SGreg Roach * @param Tree $tree 13876692c8bSGreg Roach * @param int $block_id 139a9430be8SGreg Roach * 140a9430be8SGreg Roach * @return void 14176692c8bSGreg Roach */ 142a45f9889SGreg Roach public function editBlockConfiguration(Tree $tree, int $block_id) 143c1010edaSGreg Roach { 1448c2e8227SGreg Roach } 1458c2e8227SGreg Roach} 146