1<?php 2/** 3 * webtrees: online genealogy 4 * Copyright (C) 2019 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 */ 16declare(strict_types=1); 17 18namespace Fisharebest\Webtrees\Module; 19 20use Fisharebest\Webtrees\Auth; 21use Fisharebest\Webtrees\Tree; 22use Psr\Http\Message\ServerRequestInterface; 23use function route; 24 25/** 26 * Trait ModuleBlockTrait - default implementation of ModuleBlockInterface 27 */ 28trait ModuleBlockTrait 29{ 30 /** 31 * @param Tree $tree 32 * @param string $context 33 * @param int $block_id 34 * 35 * @return string 36 */ 37 protected function configUrl(Tree $tree, string $context, int $block_id): string { 38 if ($context === self::CONTEXT_TREE_PAGE && Auth::isManager($tree)) { 39 return route('tree-page-block-edit', [ 40 'block_id' => $block_id, 41 'ged' => $tree->name(), 42 ]); 43 } 44 45 if ($context === self::CONTEXT_USER_PAGE && Auth::check()) { 46 return route('user-page-block-edit', [ 47 'block_id' => $block_id, 48 'ged' => $tree->name(), 49 ]); 50 } 51 52 return ''; 53 } 54 55 /** 56 * Update the configuration for a block. 57 * 58 * @param ServerRequestInterface $request 59 * @param int $block_id 60 * 61 * @return void 62 */ 63 public function saveBlockConfiguration(ServerRequestInterface $request, int $block_id): void 64 { 65 } 66 67 /** 68 * An HTML form to edit block settings 69 * 70 * @param Tree $tree 71 * @param int $block_id 72 * 73 * @return string 74 */ 75 public function editBlockConfiguration(Tree $tree, int $block_id): string 76 { 77 return ''; 78 } 79} 80