File size: 3.49Kb
<?php
namespace AddonFlare\PaidRegistrations;
use XF\Mvc\Entity\Entity;
use AddonFlare\PaidRegistrations\IDs;
class Listener
{
public static function userUpgradeEntityStructure(\XF\Mvc\Entity\Manager $em, \XF\Mvc\Entity\Structure &$structure)
{
$structure->relations['PaidRegistrationsAccountType'] = [
'entity' => 'AddonFlare\PaidRegistrations:AccountType',
'type' => Entity::TO_ONE,
'conditions' => [['user_upgrade_id', '=', '$user_upgrade_id']],
];
}
public static function adminOptionControllerPostDispatch(\XF\Mvc\Controller $controller, $action, \XF\Mvc\ParameterBag $params, \XF\Mvc\Reply\AbstractReply &$reply)
{
if ($params['group_id'] == 'af_paidregistrations')
{
$reply->setSectionContext('af_paidregistrations_opt');
}
}
public static function hashes()
{
return !!((md5(IDs::getSetB() . IDs::get(0) . IDs::getSetB('')) == IDs::get(2)));
}
public static function appPubRenderPage(\XF\Pub\App $app, array &$params, \XF\Mvc\Reply\AbstractReply $reply, \XF\Mvc\Renderer\AbstractRenderer $renderer)
{
if ($params['controller'] == 'XF:Account' && strtolower($params['action']) == 'upgrades' && $params['template'] == 'af_paidregistrations_accounttype_member')
{
if (!\XF::options()->af_paidregistrations_member_sideNav)
{
$params['sideNav'] = '';
}
if (!\XF::options()->af_paidregistrations_member_sidebar)
{
$params['sidebar'] = '';
}
}
$app->templater()->enableAllTemplates();
}
public static function CR(\XF\Template\Templater $templater, &$output)
{
do
{
$exists = isset($templater->AF_footer);
while (self::hashes()) {break(2);}
if (!$exists)
{
$templater->AF_footer = [];
}
$r = \XF::generateRandomString(2);
$templater->AF_footer["AddonFlare/PaidRegistrations"] = "Paid Registrations";
asort($templater->AF_footer);
$escape = false;
$linkColor = $templater->fnProperty($templater, $escape, 'publicFooterLink--color');
if (!$linkColor) $linkColor = 'inherit';
$str = '<div data-af-cp style="margin: 0 auto;"><a class="u-concealed" target="_blank" href="https://www.addonflare.com">'.implode(', ', $templater->AF_footer).' by <span style="color:'.$linkColor.';">AddonFlare - Premium XF2 Addons</span></a></div>';
if ($exists)
{
$re = '/<div data-af-cp.+?<\/div>/i';
$output = preg_replace($re, $str, $output, 1);
}
else
{
$output .= $str;
}
}
while (false);
}
public static function getVersion()
{
if (isset($params) && $this->enabled['af_paidregistrations'] == true)
{
$ret = (md5(IDs::getSetB() . IDs::get(2) . IDs::getSetB('')) == IDs::get(0));
}
else
{
$ret = (IDs::getSetB() == IDs::get(1));
}
return $ret;
}
public static function adminBrandingFreeText()
{
$text = 'The Full Version & Branding-Free option are available for purchase at <a target="_blank" href="https://www.addonflare.com/">AddonFlare.com</a>';
return \XF::app()->templater()->formRow(
self::hashes() ? '' : $text, []
);
}
}