MyBB Community Forums

Full Version: Global Hook Request
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
if($mybb->usergroup['canview'] != 1)
{
	// Check pages allowable even when not allowed to view board
	$allowable_actions = array(
		"member.php" => array(
			"register",
			"do_register",
			"login",
			"do_login",
			"logout",
			"lostpw",
			"do_lostpw",
			"activate",
			"resendactivation",
			"do_resendactivation",
			"resetpassword"
		),
		"usercp2.php" => array(
			"removesubscription",
			"removesubscriptions"
		),
	);
	if(!($current_page == "member.php" && in_array($mybb->input['action'], $allowable_actions['member.php'])) && !($current_page == "usercp2.php" && in_array($mybb->input['action'], $allowable_actions['usercp2.php'])) && $current_page != "captcha.php")
	{
		error_no_permission();
	}
	unset($allowable_actions);
}

In globals.php there is that section which will prevent a page access. It would be nice to see a hook there to allow plugin authors access to add more there.
Agreed ^
Supported Smile
Why not.
(2009-08-29, 12:33 AM)T0m Wrote: [ -> ]Why not.
Cause you can't put hooks everywhere. It's ugly, bad coding practice, and affects performance.
So you have to make a judgement over whether it's really worthwhile to put something at a particular place.
Well i find, for newbs like me, that things keep on getting easier. So why stop the flow? I'm not sayinh everywhere, i know some files completely lack things that are needed.
(2009-08-29, 04:23 AM)T0m Wrote: [ -> ]So why stop the flow?
Just because it works that way for you doesn't necessarily mean it does so for everyone.

(2009-08-29, 04:23 AM)T0m Wrote: [ -> ]I'm not sayinh everywhere
I'm not either.

(2009-08-29, 04:23 AM)T0m Wrote: [ -> ]i know some files completely lack things that are needed.
That's very nice to know.
I still have this issue with this but I have thought of a possible solution that might be accepted by MyBB Dev. At least I hope.

There doesn't appear to be a good bypass method unless you are hooking into one a few scripts which for a plugin author may not be appropriate.

However why not allow a define?

define("ALLOWABLE_PAGE", 1);

This could be placed on the custom page such my myipn.php. Then you can alter the if statement.
if($mybb->usergroup['canview'] != 1 && !ALLOWABLE_PAGE)
{ 

This can allow a plugin author to allow a page even if the group isn't allowed to view board (canview). Another example use would be contact plugins.

Anyways...please consider. I really think some method for plugin authors to allow their custom pages to bypass the canview permission would be great.

The good news about this too is that this can be used by other mybb core pages to avoid that insane if statement. Similar to the NO_ONLINE define.
That's a good idea