app/Http/Controllers/MessageController.php
public function contactPage(ServerRequestInterface $request, Tree $tree): ResponseInterface
    {
        $referer = $request->getHeaderLine('referer');

        $body       = $request->get('body', '');
        $from_email = $request->get('from_email', '');
        $from_name  = $request->get('from_name', '');
        $subject    = $request->get('subject', '');
        $to         = $request->get('to', '');
        $url        = $request->get('url', $referer);

        $to_user = $this->user_service->findByUserName($to);

        if (!in_array($to_user, $this->validContacts($tree), false)) {
            throw new AccessDeniedHttpException('Invalid contact user id');
        }

        $to_name = $to_user->realName();

        $title = I18N::translate('Send a message');

        return $this->viewResponse('contact-page', [
            'body'       => $body,
            'from_email' => $from_email,
            'from_name'  => $from_name,
            'subject'    => $subject,
            'title'      => $title,
            'to'         => $to,
            'to_name'    => $to_name,
            'url'        => $url,
        ]);
    }
public function contactPage(ServerRequestInterface $request, Tree $tree): ResponseInterface
    {
        $referer = $request->getHeaderLine('referer');

        $body       = $request->get('body', '');
        $from_email = $request->get('from_email', '');
        $from_name  = $request->get('from_name', '');
        $subject    = $request->get('subject', '');
        $to         = $request->get('to', '');
        $url        = $request->get('url', $referer);

        $to_user = $this->user_service->findByUserName($to);

        if (!in_array($to_user, $this->validContacts($tree), false)) {
            throw new AccessDeniedHttpException('Invalid contact user id');
        }

        $to_name = $to_user->realName();

        $title = I18N::translate('Send a message');

        return $this->viewResponse('contact-page', [
            'body'       => $body,
            'from_email' => $from_email,
            'from_name'  => $from_name,
            'subject'    => $subject,
            'title'      => $title,
            'to'         => $to,
            'to_name'    => $to_name,
            'url'        => $url,
        ]);
    }
public function contactPage ( ServerRequestInterface $ request , Tree $ tree ) : ResponseInterface { $ referer = $ request -> getHeaderLine ( 'referer' ) ; $ body = $ request -> get ( 'body' , '' ) ; $ from_email = $ request -> get ( 'from_email' , '' ) ; $ from_name = $ request -> get ( 'from_name' , '' ) ; $ subject = $ request -> get ( 'subject' , '' ) ; $ to = $ request -> get ( 'to' , '' ) ; $ url = $ request -> get ( 'url' , $ referer ) ; $ to_user = $ this -> user_service -> findByUserName ( $ to ) ; if ( ! in_array ( $ to_user , $ this -> validContacts ( $ tree ) , false ) ) { throw new AccessDeniedHttpException ( 'Invalid contact user id' ) ; } $ to_name = $ to_user -> realName ( ) ; $ title = I18N :: translate ( 'Send a message' ) ; return $ this -> viewResponse ( 'contact-page' , [ 'body' => $ body , 'from_email' => $ from_email , 'from_name' => $ from_name , 'subject' => $ subject , 'title' => $ title , 'to' => $ to , 'to_name' => $ to_name , 'url' => $ url , ] ) ; }
A form to compose a message from a visitor.

@param ServerRequestInterface $request
@param Tree                   $tree

@return ResponseInterface
A form to compose a message from a visitor .