<?php

/*
 * @component UserPoints
 * @copyright Copyright (C) 2015-2022 Bernard Gilly - Adrien Roussel - Martin Brampton
 * @license : GNU/GPL
 * @Website : https://remository.com
 */

namespace BlackSheepResearch\Component\UserPoints\Site\Problems;

defined('_JEXEC') or die;

use Joomla\CMS\Factory;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Uri\Uri;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Component\ComponentHelper;

class Invitation extends ProblemBase {

    public static function makeReferralLink (string $referrerid='') : string {
        $link = '/index.php?option=com_userpoints&view=invite&task=referral'.($referrerid ? "&referrerid=$referrerid" : '');
        return Uri::getInstance()->toString(array('scheme', 'host', 'port')) . $link;
    }

    public static function makeRegistrationLink(): string {
        $params = ComponentHelper::getParams('com_userpoints');
        $custom = $params->get('customregistration');
        if ($custom) {
            return $custom;
        }
        switch ($params->get('systemregistration', '')) {
            case 'cb' :
                return "index.php?option=com_comprofiler&task=registers";

            case 'cbe' :
                return "index.php?option=com_cbe&task=registers";

            case 'VM' :
                return "index.php?option=com_virtuemart&page=shop.registration";

            case 'hikas' :
                return "index.php?option=com_hikashop&view=user&layout=form";

            case 'js':
                return "index.php?option=com_community&view=register";

            case 'ose':
                return "index.php?option=com_osemsc&view=register&layout=onestep";

            case 'ext': // extendedreg
                return "index.php?option=com_extendedreg&task=register";

            case 'es':
                return "index.php?option=com_easysocial&view=registration";

            case 'ep':
                return "index.php?option=com_users&view=registration";

            case 'J!' :
            case 'joomunity' :
            default :
                return "index.php?option=com_users&view=registration";
        }
    }
}
