app/Http/Controllers/HomePageController.php
private function treeBlock(ServerRequestInterface $request, Tree $tree, UserInterface $user): ModuleBlockInterface
    {
        $block_id = (int) $request->get('block_id');

        $block = DB::table('block')
            ->where('block_id', '=', $block_id)
            ->where('gedcom_id', '=', $tree->id())
            ->whereNull('user_id')
            ->first();

        if ($block === null) {
            throw new NotFoundHttpException();
        }

        $module = $this->module_service->findByName($block->module_name);

        if (!$module instanceof ModuleBlockInterface) {
            throw new NotFoundHttpException();
        }

        if ($block->user_id !== $user->id() && !Auth::isAdmin()) {
            throw new AccessDeniedHttpException();
        }

        return $module;
    }
private function treeBlock(ServerRequestInterface $request, Tree $tree, UserInterface $user): ModuleBlockInterface
    {
        $block_id = (int) $request->get('block_id');

        $block = DB::table('block')
            ->where('block_id', '=', $block_id)
            ->where('gedcom_id', '=', $tree->id())
            ->whereNull('user_id')
            ->first();

        if ($block === null) {
            throw new NotFoundHttpException();
        }

        $module = $this->module_service->findByName($block->module_name);

        if (!$module instanceof ModuleBlockInterface) {
            throw new NotFoundHttpException();
        }

        if ($block->user_id !== $user->id() && !Auth::isAdmin()) {
            throw new AccessDeniedHttpException();
        }

        return $module;
    }
private function treeBlock ( ServerRequestInterface $ request , Tree $ tree , UserInterface $ user ) : ModuleBlockInterface { $ block_id = ( int ) $ request -> get ( 'block_id' ) ; $ block = DB :: table ( 'block' ) -> where ( 'block_id' , '=' , $ block_id ) -> where ( 'gedcom_id' , '=' , $ tree -> id ( ) ) -> whereNull ( 'user_id' ) -> first ( ) ; if ( $ block === null ) { throw new NotFoundHttpException ( ) ; } $ module = $ this -> module_service -> findByName ( $ block -> module_name ) ; if ( ! $ module instanceof ModuleBlockInterface ) { throw new NotFoundHttpException ( ) ; } if ( $ block -> user_id !== $ user -> id ( ) && ! Auth :: isAdmin ( ) ) { throw new AccessDeniedHttpException ( ) ; } return $ module ; }
Load a block and check we have permission to edit it.

@param ServerRequestInterface $request
@param Tree                   $tree
@param UserInterface          $user

@return ModuleBlockInterface
Load a block and check we have permission to edit it .