<?php
/********************************************************************************
 * (c)1337 aheadware.com - All rights reserved
 ********************************************************************************/


class TB_Server_Control_Content {

    /**
     * Send a mail to support@tbuddy from user
     *
     * @param TB_Server_Core_RequestData $params
     * @return TB_Server_Core_Response
     * @throws Exception
     */
    public static function requestSupport( TB_Server_Core_RequestData $params )
    {
        $resp = new TB_Server_Core_Response();

        $category = $params->get( 'reason', '---' );
        $message = $params->get( 'message', '---' );

        $account = TB_Server_Core_Session::get()->getAccount();
        $profile = TB_Server_Core_Session::get()->getProfile();

        if (isset($profile)) {
            $body  = "Support-Anfrage\n\r";
            $body .= "\n\r";
            $body .= "Von \n\r";
            $body .= "Name: " . $profile->getName() . "\n\r";
            $body .= "EMail: " . $account->email . "\n\r";
            $body .= "Phone: " . $profile->phone . "\n\r";
            $body .= "\n\r";
            $body .= "Account Id: " . $account->id . "\n\r";
            $body .= "Profile Id: " . $profile->id . "\n\r";
            $body .= "\n\r";
            $body .= "Kategory: " . $category . "\n\r";
            $body .= "\n\r";
            $body .= "Nachricht\n\r";
            $body .= $message;

            TB_Server_Utils_Mail::sendToSupport( "ProBuddy: Supportanfrage", $body );
        }

        return $resp;
    }
}