ElkArte Community

Elk Development => Bug Reports => Topic started by: Joshua Dickerson on June 29, 2014, 06:22:29 pm

Title: Profile Actions Menu / Paid subscriptions
Post by: Joshua Dickerson on June 29, 2014, 06:22:29 pm
Go to profile, click on "Actions" in the menu. It goes to paid subscriptions. Paid subscriptions aren't setup on this site. So, instead of going to paid subscriptions or even showing it, shouldn't it hide that? Also, why have paid subscriptions under "actions?" Seems like the menu title is wrong.
Title: Re: Profile Actions Menu / Paid subscriptions
Post by: emanuele on February 04, 2015, 05:07:21 pm
I was looking into that.
The main issue is that the error is shown only after all the gateways are loaded, that means to hide the menu entry we'd have to load all the gateways on each page of the admin panel (i.e. include all the files, load up all the instances of the gateways and check if they are properly configured).
A bit too much I think just for a menu.

Though, this may be a thing to fix in 1.1, following the schema I used for all the other actions, so: save the "ready" gateways in a settings entry and load only those configured. That way, it the settings entry is empty it means no gateways are properly configured and the menu can be hidden with just a !empty.

ETA: regarding the position... I don't like the entire organization of the profile menu... :-\
Title: Re: Profile Actions Menu / Paid subscriptions
Post by: Joshua Dickerson on February 04, 2015, 11:14:49 pm
Without looking, why can't it just look to see if there are any gateways setup?
Title: Re: Profile Actions Menu / Paid subscriptions
Post by: emanuele on February 05, 2015, 11:12:28 am
Yes, it can, it just have to load all the gateways every time...
The code looks something like this (personal random interpretation):
Code: [Select]
$gateways = findGateways('Gateway-*.class.php');
$available = array();
foreach ($gateways as $name)
{
    require_once(SUBSDIR . '/' . $name . '.class.php');
    $instance = new $name();
    if ($instance->isSetup())
        $available[] = $instance;
}

if (empty($available))
    fatal_lang_error('no_gateways');
So it would mean add that processing to the profile menu.
Title: Re: Profile Actions Menu / Paid subscriptions
Post by: Joshua Dickerson on February 05, 2015, 12:23:43 pm
The result of $available isn't stored in settings?
Title: Re: Profile Actions Menu / Paid subscriptions
Post by: emanuele on February 05, 2015, 12:28:13 pm
Nope, it's checked live every time.
Adding it to a setting is more or less what would be necessary.
Title: Re: Profile Actions Menu / Paid subscriptions
Post by: Joshua Dickerson on February 05, 2015, 01:42:25 pm
Seems simple enough.
Code: [Select]
if (!empty($modSettings['payment_gateways'])) { // show payment gateways }

Also, there is the issue that payment gateways is under "actions." Doesn't seem like an action. Seems like the language string is wrong.