18e0e1b25SGreg Roach<?php 28e0e1b25SGreg Roach 38e0e1b25SGreg Roach/** 48e0e1b25SGreg Roach * webtrees: online genealogy 58e0e1b25SGreg Roach * Copyright (C) 2019 webtrees development team 68e0e1b25SGreg Roach * This program is free software: you can redistribute it and/or modify 78e0e1b25SGreg Roach * it under the terms of the GNU General Public License as published by 88e0e1b25SGreg Roach * the Free Software Foundation, either version 3 of the License, or 98e0e1b25SGreg Roach * (at your option) any later version. 108e0e1b25SGreg Roach * This program is distributed in the hope that it will be useful, 118e0e1b25SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 128e0e1b25SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 138e0e1b25SGreg Roach * GNU General Public License for more details. 148e0e1b25SGreg Roach * You should have received a copy of the GNU General Public License 158e0e1b25SGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>. 168e0e1b25SGreg Roach */ 178e0e1b25SGreg Roach 188e0e1b25SGreg Roachdeclare(strict_types=1); 198e0e1b25SGreg Roach 208e0e1b25SGreg Roachnamespace Fisharebest\Webtrees\Http\RequestHandlers; 218e0e1b25SGreg Roach 228e0e1b25SGreg Roachuse Fisharebest\Webtrees\Http\ViewResponseTrait; 238e0e1b25SGreg Roachuse Fisharebest\Webtrees\I18N; 248e0e1b25SGreg Roachuse Fisharebest\Webtrees\Module\ModuleBlockInterface; 258e0e1b25SGreg Roachuse Fisharebest\Webtrees\Services\HomePageService; 26f6924bc8SGreg Roachuse Fisharebest\Webtrees\Tree; 277adbde9eSGreg Roachuse Fisharebest\Webtrees\User; 288e0e1b25SGreg Roachuse Psr\Http\Message\ResponseInterface; 298e0e1b25SGreg Roachuse Psr\Http\Message\ServerRequestInterface; 308e0e1b25SGreg Roachuse Psr\Http\Server\RequestHandlerInterface; 318e0e1b25SGreg Roach 328e0e1b25SGreg Roachuse function route; 338e0e1b25SGreg Roach 348e0e1b25SGreg Roach/** 35fceda430SGreg Roach * Show a form to edit the default blocks for new users. 368e0e1b25SGreg Roach */ 378e0e1b25SGreg Roachclass UserPageDefaultEdit implements RequestHandlerInterface 388e0e1b25SGreg Roach{ 398e0e1b25SGreg Roach use ViewResponseTrait; 408e0e1b25SGreg Roach 418e0e1b25SGreg Roach /** @var HomePageService */ 428e0e1b25SGreg Roach private $home_page_service; 438e0e1b25SGreg Roach 448e0e1b25SGreg Roach /** 458e0e1b25SGreg Roach * @param HomePageService $home_page_service 468e0e1b25SGreg Roach */ 478e0e1b25SGreg Roach public function __construct(HomePageService $home_page_service) 488e0e1b25SGreg Roach { 498e0e1b25SGreg Roach $this->home_page_service = $home_page_service; 508e0e1b25SGreg Roach } 518e0e1b25SGreg Roach 528e0e1b25SGreg Roach /** 538e0e1b25SGreg Roach * @param ServerRequestInterface $request 548e0e1b25SGreg Roach * 558e0e1b25SGreg Roach * @return ResponseInterface 568e0e1b25SGreg Roach */ 578e0e1b25SGreg Roach public function handle(ServerRequestInterface $request): ResponseInterface 588e0e1b25SGreg Roach { 598e0e1b25SGreg Roach $this->layout = 'layouts/administration'; 608e0e1b25SGreg Roach 618e0e1b25SGreg Roach $this->home_page_service->checkDefaultUserBlocksExist(); 628e0e1b25SGreg Roach 63f6924bc8SGreg Roach $default_tree = new Tree(-1, 'DEFAULT', 'DEFAULT'); 647adbde9eSGreg Roach $default_user = new User(-1, 'DEFAULT', 'DEFAULT', 'DEFAULT'); 65f6924bc8SGreg Roach 667adbde9eSGreg Roach $main_blocks = $this->home_page_service->userBlocks($default_tree, $default_user, ModuleBlockInterface::MAIN_BLOCKS); 677adbde9eSGreg Roach $side_blocks = $this->home_page_service->userBlocks($default_tree, $default_user, ModuleBlockInterface::SIDE_BLOCKS); 687adbde9eSGreg Roach $all_blocks = $this->home_page_service->availableUserBlocks($default_tree, $default_user); 698e0e1b25SGreg Roach $title = I18N::translate('Set the default blocks for new users'); 70*4c3563c0SGreg Roach $url_cancel = route(UserListPage::class); 718e0e1b25SGreg Roach $url_save = route(UserPageDefaultUpdate::class); 728e0e1b25SGreg Roach 738e0e1b25SGreg Roach return $this->viewResponse('edit-blocks-page', [ 748e0e1b25SGreg Roach 'all_blocks' => $all_blocks, 758e0e1b25SGreg Roach 'can_reset' => false, 768e0e1b25SGreg Roach 'main_blocks' => $main_blocks, 778e0e1b25SGreg Roach 'side_blocks' => $side_blocks, 788e0e1b25SGreg Roach 'title' => $title, 798e0e1b25SGreg Roach 'url_cancel' => $url_cancel, 808e0e1b25SGreg Roach 'url_save' => $url_save, 818e0e1b25SGreg Roach ]); 828e0e1b25SGreg Roach } 838e0e1b25SGreg Roach} 84