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

// no direct access
defined('_JEXEC') or die('Restricted access');

use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Image\Image;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Uri\Uri;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Plugin\PluginHelper;
use BlackSheepResearch\Component\UserPoints\Site\UserPoints;
use BlackSheepResearch\Component\UserPoints\Site\Utils\Session;
use BlackSheepResearch\Component\UserPoints\Site\Problems\Coupon;
use BlackSheepResearch\Component\UserPoints\Site\Problems\SQL;
use BlackSheepResearch\Component\UserPoints\Site\Problems\Invitation;

$profileSlideQR = function () : string {
    if (UserPoints::checkRuleEnabled('sysplgup_invitewithsuccess', 0, '') && $this->params->get('showQRCode', 1)) {
        $refcoupon = new Coupon();
        $refcoupon->couponcode = Invitation::makeReferralLink($this->referreid);
        // $gcode_url = 'https://quickchart.io/qr?text=' . urlencode($referrer_link).'&caption=UserPoints';
        return <<<SLIDE_QR

        {$this::_(HTMLHelper::_('bootstrap.addSlide', 'mySlide', Text::_('AUP_QRCODE'), 'slide-qrcode'))}
        <div id="QRcodeInvite">
            <img src="{$refcoupon->QR()}" alt="QRCode" />
        </div>
        {$this::_(HTMLHelper::_('bootstrap.endSlide'))}

SLIDE_QR;

    }
    return '';
};

$profileSlideReferees = function () : string {
    if ($this->rowsreferrees && $this->params->get('show_tab_referrees', 1)) {
        $showname = !$this->params->get('show_name_cols', 0) ? '' :
            "<th id=\"categorylist_header_name\">{$this::Text_('AUP_NAME')}</th>";

        $refhtml = '';

        foreach ($this->rowsreferrees as $referrees) {
            if ($this->params->get('show_links_to_users', 1)) {
                $_user_info = UserPoints::getUserInfo($referrees->referreid);
                $linktoprofil = getProfileLink(ComponentHelper::getParams('com_userpoints')->get('linkToProfile', ''), $_user_info);

                $linktoprofil = "<a href=\"" . Route::_($linktoprofil) . "\">" . $referrees->username . "</a>";
            } else {
                $linktoprofil = $referrees->username;
            }
            $refhtml .= <<<REF_LINE

        <tr>
            <td headers="categorylist_header_title" class="list-title">$referrees->referreid</td>
            <td headers="categorylist_header_title" class="list-title">$linktoprofil</td>
            {$this::_("<td headers=\"categorylist_header_title\" class=\"list-title\">$referrees->name</td>", $this->params->get('show_name_cols', 0))}
        </tr>

REF_LINE;

        }

        return <<<SLIDE_REFEREES

        {$this::_(HTMLHelper::_('bootstrap.addSlide', 'mySlide', Text::_('AUP_MYREFERREES'), 'slide-referrees'))}
        <table class="category table table-striped table-bordered table-hover">
            <thead>
                <tr>
                    <th id="categorylist_header_id">ID</th>
                    <th id="categorylist_header_username">{$this::Text_('AUP_USERNAME')}</th>
                    $showname
                </tr>
            </thead>
            <tbody>
                $refhtml
            </tbody>
        </table>
        {$this::_(HTMLHelper::_('bootstrap.endSlide'))}

SLIDE_REFEREES;
    }
    return '';
};

$showTopTen = function () : string {
    if (!$this->params->get('show_top10', 1)) {
        return '';
    }

    $show_name = (bool) $this->params->get('show_name_cols', 0);
    $show_username = (bool) $this->params->get('show_username_cols', 1) || (!$this->params->get('show_name_cols', 0) && !$this->params->get('show_username_cols', 0) );

    $barwidth = function ($i, $row) {
        static $maxpoints = 0;
        if (0 == $i) {
            $maxpoints = $row->sumpoints;
            return 100;
        }
        return ($row->sumpoints > 0) ? round(($row->sumpoints * 100) / $maxpoints) : 0;
    };

    $linktoprofil = function ($referreid, $name) : string {
        $_profilelink = ComponentHelper::getParams('com_userpoints')->get('linkToProfile', '');
        return ($this->params->get('show_links_to_users', 1)) ?
        "<a href=\"" . Route::_(getProfileLink($_profilelink, UserPoints::getUserInfo($referreid))) . "\">" . $name . "</a>" : $name;
    };

    $namefield = function ($condition, $referreid, $name) use ($linktoprofil) : string {
        if ($condition) {
            return <<<NAME_FIELD

                        <td headers="categorylist_header_title" class="list-title">
                            {$linktoprofil($referreid, $name)}
                        </td>

NAME_FIELD;
        }
        return '';
    };

    $oneline = function ($row) use ($namefield, $barwidth, $show_name, $show_username) : string {
        static $i = 0;
        $line = <<<ONE_LINE

                <tr class="cat-list-row{$this::_($i % 2)}">
                    {$namefield($show_name, $row->referreid, $row->name)}
                    {$namefield($show_username, $row->referreid, $row->username)}
                    <td headers="categorylist_header_title" class="list-title">
                        <div class="progress progress-striped active">
                            <div class="bar" style="width:{$barwidth($i, $row)}%"></div>
                        </div>
                    </td>
                    <td headers="categorylist_header_title" class="list-title"><span class="badge badge-info">{$this->getFormattedPoints($row->sumpoints)}</span></td>
                </tr>

ONE_LINE;

        $i++;
        return $line;
    };

    echo <<<TOP_TEN

    <table class="category table table-striped table-bordered table-hover">
        <thead>
            <tr>
                {$this::_("<th id=\"categorylist_header_name2\" width=\"25%\">{$this::Text_('AUP_NAME')}</th>", $show_name)}
                {$this::_("<th id=\"categorylist_header_username2\" width=\"25%\">{$this::Text_('AUP_USERNAME')}</th>", $show_username)}
                <th id="categorylist_header_blank">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th>
                <th id="categorylist_header_points2" width="15%">{$this::Text_('AUP_POINTS')}</th>
            </tr>
        <thead>
        <tbody>
                {$this::_x(array_map($oneline, $this->pointsearned))}
        </tbody>
    </table>
    <?php

TOP_TEN;

};

$profileSlideStatistics = function () : string {
    if ($this->params->get('show_tab_statistics', 1)) {
        $percent = (float)$this->totalpoints != 0 ? (($this->currenttotalpoints) / ($this->totalpoints)) * 100 : 0;
        $showpercent = abs($percent) > 1.0 ? number_format($percent, 1, '.', '') . "%" : number_format($percent, 3, '.', '') . "%";
        $points_color = $this->currenttotalpoints ? ($this->currenttotalpoints > 0 ? 'badge badge-info' : 'badge badge_warning') : 'badge';

        return <<<SLIDE_STATS

        {$this::_(HTMLHelper::_('bootstrap.addSlide', 'mySlide', Text::_('AUP_STATISTICS'), 'slide-statistics'))}
        <table class="category table table-striped table-bordered table-hover">
            {$this::_(
                "<tr>
                <td>{$this::Text_('AUP_TOTAL_COMMUNITY_POINTS')}</td>
                <td><span class=\"badge badge-info\">{$this->getFormattedPoints($this->totalpoints)}</span></td>
            </tr>",
                $this->params->get('show_community_points', 1))}
            <tr>
                <td>{$this::Text_('AUP_MYPOINTS')}</td>
                <td><span class="$points_color">{$this->getFormattedPoints($this->currenttotalpoints)}</span></td>
            </tr>
            {$this::_(
                "<tr>
                    <td>{$this::Text_('AUP_MY_PERCENTAGE_OF_POINTS')}</td>
                    <td><span class=\"badge badge-info\">$showpercent</span>
                    </td>
                </tr>", $this->params->get('show_percentage', 1))}
        </table>
        <table class="category table table-striped table-bordered table-hover">
            <thead>
                <tr>
                    <th id="categorylist_header_mystatistics">{$this::Text_('AUP_MY_STATISTICS')}</th>
                    <th id="categorylist_header_pointsearned">{$this::Text_('AUP_POINTS_EARNED')}</th>
                    <th id="categorylist_header_pointsspent">{$this::Text_('AUP_POINTS_SPENT')}</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td>{$this::Text_('AUP_SINCE_THE_BEGENNING')}</td>
                    <td><span class="badge badge-info">{$this->getFormattedPoints($this->mypointsearned)}</span></td>
                    <td><span class="badge badge-warning">{$this->getFormattedPoints($this->mypointsspent)}</span></td>
                </tr>
                <tr>
                    <td>{$this::Text_('AUP_THIS_MONTH')}</td>
                    <td><span class="badge badge-info">{$this->getFormattedPoints($this->mypointsearnedthismonth)}</span></td>
                    <td><span class="badge badge-warning">{$this->getFormattedPoints($this->mypointsspentthismonth)}</span></td>
                </tr>
                <tr>
                    <td>{$this::Text_('AUP_THIS_DAY')}</td>
                    <td><span class="badge badge-info">{$this->getFormattedPoints($this->mypointsearnedthisday)}</span></td>
                    <td><span class="badge badge-warning">{$this->getFormattedPoints($this->mypointsspentthisday)}</span></td>
                </tr>
            </tbody>
        </table>

        {$this::_(HTMLHelper::_('bootstrap.endSlide'))}

SLIDE_STATS;

    }
    return '';
};

$profileSlideReviews = function () : string {
    return <<<SLIDE_REVIEWS
    
        {$this->showtext(HTMLHelper::_('bootstrap.addSlide', 'mySlide', Text::_('AUP_MY_REVIEWS'), 'slide-reviews'))}
        {$this::_x(Factory::getApplication()->triggerEvent('onGetMyReviews'))}
        {$this->showtext(HTMLHelper::_('bootstrap.endSlide'))}
    
SLIDE_REVIEWS;
    
};

$profileSlideCoupons = function () : string {
    return <<<SLIDE_COUPONS
    
        {$this->showtext(HTMLHelper::_('bootstrap.addSlide', 'mySlide', Text::_('AUP_MYCOUPONS'), 'slide-coupons'))}
        {$this::_x(Factory::getApplication()->triggerEvent('onGetMyCoupons'))}
        {$this->showtext(HTMLHelper::_('bootstrap.endSlide'))}

SLIDE_COUPONS;
    
};

$profileMedalsTab = function () : string {
    if (!($this->medalslistuser && $this->params->get('show_tab_medals', 0))) {
        return '';
    }

    $medal_line = function ($medaluser) : string {
        static $i = 0;
        $pathimage = Uri::root() . 'components/com_userpoints/assets/images/awards/large/';
        $line = <<<MEDAL_LINE

                <tr class="cat-list-row{$this::_($i % 2)}" >
                    <td headers="categorylist_header_title" class="list-title">
                        {$this::_("<img src=\"$pathimage{$medaluser->image}\" alt=\"\"" , $medaluser->image)}
                    </td>
                    <td headers="categorylist_header_title" class="list-title">
                        {$this::_($this->presentDate('date', $medaluser->medaldate, Text::_('DATE_FORMAT_LC')))}
                    </td>
                    <td headers="categorylist_header_title" class="list-title">
                        {$this::Text_($medaluser->rank)}
                    </td>
                    <td headers="categorylist_header_title" class="list-title">
                        {$this::Text_($medaluser->reason)}
                    </td>
                </tr>

MEDAL_LINE;

        $i++;
        return $line;
    };

    return <<<MEDALS_LIST

    {$this::_(HTMLHelper::_('bootstrap.addTab', 'myTab', 'page-medals', Text::_('AUP_MEDALS', true)))}
    <table class="category table table-striped table-bordered table-hover">
        <thead>
            <tr>
                <th id="icon_header_blank">&nbsp;
                </th>
                <th id="icon_header_date">
                    {$this::Text_('AUP_DATE')}
                </th>
                <th id="icon_header_medals">
                    {$this::Text_('AUP_MEDALS')}
                </th>
                <th id="icon_header_reason">
                    {$this::Text_('AUP_REASON_FOR_AWARD')}
                </th>
            </tr>
        </thead>
        <tbody>
            {$this::_x(array_map($medal_line, $this->medalslistuser))}
        </tbody>
    </table>
    {$this::_(HTMLHelper::_('bootstrap.endTab'))}

MEDALS_LIST;

};

$profileCouponsTab = function () : string {
    if (!($this->mycouponscode AND $this->referreid == Session::get('referrerid') AND UserPoints::getUser()->id == $this->userinfo->userid)) {
        return '';
    }

    $coupon_line = function ($coupon) : string {
        static $i = 0;
        $pos = strpos($coupon->keyreference, '##');
        $realcoupontitle = false === $pos ? $coupon->keyreference : substr($coupon->keyreference, 0, $pos);
        $line = <<<COUPON_LINE

                <tr class="cat-list-row<?php echo $i % 2; ?>" >
                    <td headers="categorylist_header_title" class="list-title">{$this::_($this->presentDate('date', $coupon->insert_date, Text::_('DATE_FORMAT_LC2')))}</td>
                    <td headers="categorylist_header_title" class="list-title">$realcoupontitle</td>
                    <td headers="categorylist_header_title" class="list-title">$coupon->datareference</td>
                    <td headers="categorylist_header_title" class="list-title">{$this->getFormattedPoints($coupon->points)}</td>
                </tr>

COUPON_LINE;

        $i++;
        return $line;
    };

    return <<<COUPON_LIST

    {$this::_(HTMLHelper::_('bootstrap.addTab', 'myTab', 'page-mycoupons', Text::_('AUP_MYCOUPONS', true)))}
    <table class="category table table-striped table-bordered table-hover">
        <thead>
            <tr>
                <th id="coupon_header_date">{$this::Text_('AUP_DATE')}</th>
                <th id="coupon_header_couponcode">{$this::Text_('AUP_COUPONSCODE')}</th>
                <th id="coupon_header_detail">{$this::Text_('AUP_DETAIL')}</th>
                <th id="coupon_header_points">{$this::Text_('AUP_POINTS')}</th>
            </tr>
        </thead>
        <tbody>
            {$this::_x(array_map($coupon_line, $this->mycouponscode))}
        </tbody>
    </table>
    <?php
    echo HTMLHelper::_('bootstrap.endTab');

COUPON_LIST;

};

$profileActivitiesTab = function () : string {
    if (!($this->params->get('num_item_activities', 0) != '0' && $this->rowslastpoints)) {
        return '';
    }

    $activity_line = function ($lastpoints) : string {
        static $k = 0;
        $points_color = (0 == $lastpoints->points) ? 'badge' : ($lastpoints->points > 0 ? 'badge badge-info' : 'badge badge-warning');
                            switch ($lastpoints->plugin_function) {
                                case 'sysplgup_dailylogin':
                                    $ref = $this->presentDate('date', $lastpoints->datareference, Text::_('DATE_FORMAT_LC1'));
                                    break;
                                case 'plgaup_getcouponcode_vm':
                                case 'plgaup_alphagetcouponcode_vm':
                                case 'sysplgup_buypointswithpaypal':
                                    if ($this->referreid != Session::get('referrerid')) {
                                        $ref = '';
                                    } else {
                                        $ref = $lastpoints->datareference;
                                    }
                                    break;
                                default:
                                    $ref = $lastpoints->datareference;
                            }
        $png = ( $lastpoints->approved ) ? 'tick.png' : 'publish_x.png';
        $textalt = Text::_(( $lastpoints->approved ) ? 'AUP_APPROVED' : 'AUP_PENDINGAPPROVAL');

        return <<<POINTS_LINE

                    <tr class="cat-list-row<{$this::_($k % 2)}" >
                        <td headers="categorylist_header_title" class="list-title">
                            {$this->presentDate('date', $lastpoints->insert_date, Text::_('DATE_FORMAT_LC2'))}
                        </td>
                        <td headers="categorylist_header_title" class="list-title">
                            {$this::Text_($lastpoints->rule_name)}
                        </td>
                        <td headers="categorylist_header_title" class="list-title">
                            <span class="$points_color">{$this->getFormattedPoints($lastpoints->points)}</span>
                        </td>
                        <td headers="categorylist_header_title" class="list-title">
                            <?php
                                {$this->displayDateTime($lastpoints->expire_date)}
                            ?>
                        </td>
                        <td headers="categorylist_header_title" class="list-title">
                            $ref
                        </td>
                        <td headers="categorylist_header_title" class="list-title">
                            <img src="components/com_userpoints/assets/images/$png" border="0" title="$textalt" alt="$textalt" />
                        </td>
                    </tr>

POINTS_LINE;

                    $k++;

    };

    /*
    $pagination = ($this->params->get('num_item_activities', 0) != 'all') ? '' : <<<PAGINATION

            <div class="pagination">
                {$this->pagination->getPagesLinks()}
                <br />{$this->pagination->getPagesCounter()}
            </div>

PAGINATION;

    */

    $userid = UserPoints::getUser()->id;
    if ($this->rowslastpoints AND $this->referreid == Session::get('referrerid') AND $userid == $this->userinfo->userid) {
        $rawlink = "index.php?option=com_userpoints&amp;view=account&amp;task=downloadactivity&amp;userid=" . $userid;
        $linktodownloadactivity = "<br /><img src=\"components/com_userpoints/assets/images/icon_csv.gif\" alt=\"\" />&nbsp;&nbsp;<a href=\"" . Route::_($rawlink) . "\">" . Text::_('AUP_DOWNLOAD_MY_FULL_ACTIVITY') . "</a>";
    }

    return <<<ACTIVITIES

    {$this::_(HTMLHelper::_('bootstrap.addTab', 'myTab', 'page-activities', Text::_('AUP_LASTACTIVITY', true)))}
    <table class="category table table-striped table-bordered table-hover">
        <thead>
            <tr>
                <th id="activity_date_header_title">
                    {$this::Text_('AUP_DATE')}
                </th>
                <th id="activity_action_header_title">
                    {$this::Text_('AUP_ACTION')}
                </th>
                <th id="activity_points_header_title">
                    {$this::Text_('AUP_POINTS')}
                </th>
                <th id="activity_expire_header_title">
                    {$this::Text_('AUP_EXPIRE')}
                </th>
                <th id="activity_detail_header_title">
                    {$this::Text_('AUP_DETAIL')}
                </th>
                <th id="activity_approved_header_title">
                    {$this::Text_('AUP_APPROVED')}
                </th>
            </tr>
        </thead>
        <tbody>
            {$this::_x(array_map($activity_line, $this->rowslastpoints))}
        </tbody>
    </table>
    $linktodownloadactivity

    {$this::_(HTMLHelper::_('bootstrap.endTab'))}

ACTIVITIES;

};

if (!defined("_AUP_IMAGE_LIVE_PATH")) {
    define('_AUP_IMAGE_LIVE_PATH', Uri::base(true) . '/components/com_userpoints/assets/images/');
}

$_profilelink = ComponentHelper::getParams('com_userpoints')->get('linkToProfile', '');

// update profile views counter
if ($this->referreid != Session::get('referrerid')) {
    _updateProfileViews($this->referreid);
    $profilviews = $this->userinfo->profileviews + 1;
} else {
    $profilviews = $this->userinfo->profileviews;
}

$page_heading = <<<PAGE_HEADING

    <div class="page-header">
        <h1>{$this->showtext($this->params->get('page_heading', ''))}</h1>
    </div>

PAGE_HEADING;

$my_avatar = <<<AVATAR

    <div style="float:right;padding: 0 10px 0 10px;">
        $this->avatar
    </div>

AVATAR;

$points_color = $this->currenttotalpoints ? ($this->currenttotalpoints > 0 ? 'badge badge-info' : 'badge badge_warning') : 'badge';

$userrank_image = ($this->userrankinfo && $this->userrankinfo->image) ?
    (new Image(JPATH_COMPONENT . '/assets/images/awards/large/' . $this->userrankinfo->image))->createThumbs(
        array('16x16'),
        Image::CROP_RESIZE,
        JPATH_COMPONENT . '/assets/images/awards/large/thumbs'
    ) : null;
$userrank_image_html = $userrank_image ? '<img src="' . myImage::getLivePathImage($userrank_image) . '" alt="" />' : '';

$linktoprofilreferrer = $this->referraluser == '' ? '' :
    ($this->params->get('show_links_to_users', 1) ? "<a href=\"" . Route::_(getProfileLink($_profilelink, UserPoints::getUserInfo($this->referraluser))) . "\">" . $this->referralname . "</a>" :
    $this->referralname);

$invite_html = !UserPoints::checkRuleEnabled('sysplgup_invitewithsuccess', 0, '') ? '' :
    <<<INVITE_HTML
    <br />
    <br />
    <div class="alert alert-info"><span aria-hidden="true" class="icon-info-circle"></span>&nbsp;&nbsp;{$this::Text_('AUP_INVITATION_LINK')}
        <br /><input type="text"  name="referrer_link" id="referrer_link" onfocus="select();" readonly="readonly" class="inputbox"
        value="{$this->showtext(Invitation::makeReferralLink($this->referreid))}" /></div>
INVITE_HTML;

PluginHelper::importPlugin('eshop');

echo <<<PROFILE_PAGE

        {$this->showtext($page_heading, $this->params->get('show_page_heading', 0))}
        {$this->showtext(HTMLHelper::_('bootstrap.startTabSet', 'myTab', array('active' => 'page-profile')))}
        {$this->showtext(HTMLHelper::_('bootstrap.addTab', 'myTab', 'page-profile', Text::_('AUP_PROFILE', true)))}
        {$this->showtext($my_avatar, $this->avatar)}
        <h1>$this->myname</h1>
        <b>{$this::_(Text::_('AUP_USERNAME') . " : " . $this->myusername)}</b><br />
        <b>ID</b> : $this->referreid <br />
        {$this::Text_('AUP_MYPOINTS')}</b> :
                <span class="$points_color">{$this->getFormattedPoints($this->currenttotalpoints)}</span>
        {$this->showtext($this->showtext($userrank_image_html) . ($this->userrankinfo ? ' (' . $this->userrankinfo->rank . ')' : ''))}
        <br />
        <b>{$this::Text_('AUP_LASTUPDATE')}</b> :
            {$this::_($this->presentDate('date', $this->lastupdate, Text::_('DATE_FORMAT_LC2')))}
        <br />
        <b>{$this::Text_('AUP_MEMBER_SINCE')}</b> :
            {$this::_($this->presentDate('date', $this->userinfo->registerDate, Text::_('DATE_FORMAT_LC3')))}
        <br />
        <b>{$this::Text_('AUP_LAST_ONLINE')}</b> :
            {$this::_(SQL::nicetime($this->userinfo->lastvisitDate))}
        <br />
        {$this::_('<b>' . Text::_('AUP_MYREFRERRALUSER') . '</b>', $this->referraluser != '')}
        $invite_html
        {$this::_(HTMLHelper::_('bootstrap.startAccordion', 'mySlide', array()) .
    $profileSlideQR() .
    $profileSlideReferees() .
    $profileSlideStatistics() .
    $profileSlideCoupons() .
    $profileSlideReviews() .
    HTMLHelper::_('bootstrap.endAccordion'),
    $_profilelink == ''
)}
        {$this::_(HTMLHelper::_('bootstrap.endTab'))}
        {$profileMedalsTab()}
        {$profileCouponsTab()}
        {$profileActivitiesTab()}

        {$this::_(Factory::getDocument()->loadRenderer('modules')->render('UserPoints Profile Tab', array('style' => 'none'), null))}

        {$this::_(HTMLHelper::_('bootstrap.endTabSet'))}

PROFILE_PAGE;

echo $this->getCopyrightNotice();

// Integration Uddeim
// ******************
if ($this->referreid == Session::get('referrerid') AND $this->enabledUDDEIM && UserPoints::getUser()->id == $this->userinfo->userid) {
    require_once JPATH_SITE . '/components/com_uddeim/uddeim.api.php';
    require_once JPATH_COMPONENT . '/helpers/uddeim_alert.php';
    require_once JPATH_COMPONENT . '/helpers/uddeim_mailbox.php';
}
// end integration Uddeim

/**
 *
 *  Provide copyright on frontend
 *  If you remove or hide this line below,
 *  please make a donation if you find UserPoints useful
 *  and want to support its continued development.
 *  Your donations help by hardware, hosting services and other expenses that come up as we develop,
 *  protect and promote UserPoints and other free components.
 *
 */


