<?php

use \ModulesGarden\OpenXchangeAddon\Core\App\AppContext;

if (!defined("WHMCS"))
{
    die("This file cannot be accessed directly");
}

if (!defined('DS'))
{
    define('DS', DIRECTORY_SEPARATOR);
}

require_once __DIR__ . DIRECTORY_SEPARATOR . 'core' . DIRECTORY_SEPARATOR . 'WhmcsErrorIntegration.php';


#MGLICENSE_FUNCTIONS#


function OpenXchangeAddon_config()
{
    require_once __DIR__ . DIRECTORY_SEPARATOR . 'core' . DIRECTORY_SEPARATOR . 'App' . DIRECTORY_SEPARATOR . 'AppContext.php';
    $appContext = new AppContext();

    return $appContext->runApp(__FUNCTION__);
}

function OpenXchangeAddon_activate()
{
    require_once __DIR__ . DIRECTORY_SEPARATOR . 'core' . DIRECTORY_SEPARATOR . 'App' . DIRECTORY_SEPARATOR . 'AppContext.php';
    $appContext = new AppContext();

    return $appContext->runApp(__FUNCTION__);
}

function OpenXchangeAddon_deactivate()
{
    require_once __DIR__ . DIRECTORY_SEPARATOR . 'core' . DIRECTORY_SEPARATOR . 'App' . DIRECTORY_SEPARATOR . 'AppContext.php';
    $appContext = new AppContext();

    return $appContext->runApp(__FUNCTION__);
}

function OpenXchangeAddon_upgrade($params)
{
    require_once __DIR__ . DIRECTORY_SEPARATOR . 'core' . DIRECTORY_SEPARATOR . 'App' . DIRECTORY_SEPARATOR . 'AppContext.php';
    $appContext = new AppContext();

    return $appContext->runApp(__FUNCTION__, $params);
}

function OpenXchangeAddon_output($params)
{
    require_once __DIR__ . DIRECTORY_SEPARATOR . 'core' . DIRECTORY_SEPARATOR . 'App' . DIRECTORY_SEPARATOR . 'AppContext.php';
    $appContext = new AppContext();

    #MGLICENSE_CHECK_ECHO_AND_RETURN_MESSAGE#

    $html = $appContext->runApp(__FUNCTION__, $params);

    if ($html)
    {
        echo $html;
    }
}

function OpenXchangeAddon_clientarea($params)
{
    require_once __DIR__ . DIRECTORY_SEPARATOR . 'core' . DIRECTORY_SEPARATOR . 'App' . DIRECTORY_SEPARATOR . 'AppContext.php';
    $appContext = new AppContext();

    #MGLICENSE_CHECK_ECHO_AND_RETURN_MESSAGE#

    return $appContext->runApp(__FUNCTION__, $params);
}
