MyBB Community Forums

Full Version: Using hyperlink to call a certain function in Admin CP ?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I want to know how can I make a hiperlink in a plugin to call a certain function in Admin CP.

My function:
function myfunction()
{
	if(/* permissions */ == true)
	{
		// run
		echo 'Hello.';
	}
	else 'Access denied !';
}
And the hiperlink:
'<a href="index.php?xxx">Click here !</a>';

What I should to put instead "xxx" to call "myfunction()" when I click on "Say Hello !" ?

-------------------
// LATER EDIT:

Before you ask me why I need that, I will give you more details.
I try to develop a plugin (for fun) called "TuneUp".
Before my plugin is installed (and/or activated) will show to admins a warning message if option "Disable All Plugins" is enabled. In this warning message, i have a link called "Click Here" like this:
[attachment=24875]
I have also this function to check if option is enabled or not:
// CHECK ACCESS
function tuneup_check_access()
{
	global $mybb, $lang, $plugins;
	if(defined("NO_PLUGINS") || ($mybb->settings["no_plugins"] == 1))
	{
		$lang->load("tuneup", false, true);
		$message = $lang->tuneup_warning_install."<br /><small><a href=\"index.php?module=config-settings&action=change&gid=7#row_setting_no_plugins\" />".$lang->tuneup_click_here."</a>&nbsp;".$lang->tuneup_warning_install_try_again."</small>";
		if(tuneup_is_installed())
		$message = $lang->tuneup_warning_activate."<br /><small><a href=\"index.php?module=config-settings&action=change&gid=7#row_setting_no_plugins\" />".$lang->tuneup_click_here."</a>&nbsp;".$lang->tuneup_warning_activate_try_again."</small>";
		flash_message($message, "error");
		admin_redirect("index.php?module=config-plugins");
	}
}

I want instead of
		$message = $lang->tuneup_warning_install."<br /><small><a href=\"index.php?module=config-settings&action=change&gid=7#row_setting_no_plugins\" />".$lang->tuneup_click_here."</a>&nbsp;".$lang->tuneup_warning_install_try_again."</small>";
to have this:
		$message = $lang->tuneup_warning_install."<br /><small><a href=\"/*CHANGE DISABLE ALL PLUGINS OPTION FROM YES TO NO WHEN I CLICK ON THIS LINK !*/" />".$lang->tuneup_click_here."</a>&nbsp;".$lang->tuneup_warning_install_try_again."</small>";

So... this is what I want: CHANGE DISABLE ALL PLUGINS OPTION FROM YES TO NO WHEN I CLICK ON THIS LINK !
(equivalent with value of $mybb->settings["no_plugins"])
After that, process requested by admin will continue (install or activate).

It is possible ? How ? Also.. it's safe ???
Bump.
if plugins are disabled, your plugin will never run to test the no_plugins setting. you would need a core edit to add the link you want.

even so, unless you are going to search init.php and global.php to the NO_PLUGINS definition and then edit those files, you may not always re-enable all plugins. you can change the setting easily, but the manual disabling is a little more difficult.
(2011-12-13, 05:04 PM)pavemen Wrote: [ -> ]if plugins are disabled, your plugin will never run to test the no_plugins setting.
Thanks for answer.
But... if plugins are disabled, my plugin will show a warning message in AdminCP (with flash_message($message, "error")Wink and redirect back to plugins page, when I try to install it.
So, in this message I have a link. What I want to know is when I click on this link can be changed the value in table "_settings" of row with name "no_plugins" from 1 to 0 (even the plugin is not installed) ???