MyBB Community Forums

Full Version: Listing active plugins
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
I am currently developing a plugin that adds a page to your forum and lists the plugins you have active, along with their description and authors details, much like what is in the ACP plugin section.

Basically how it works is for each of the active plugins it includes the plugin file and assigns the values returned by the _info function to a variable then outputs this data as a table.

I have almost finished the plugin but I have a problem, for plugins such as the akismet plugin where some of the _info values are lang variables, such as $lang->akismet, the _info function doesn't seem to be returning a value. I have tried everything I can think of and I can't see any major differences between what I have done and what is done in the ACP plugin section which works pretty much the same way. Any suggestions or advice is very welcome!

Thanks in advance Smile
Some plugins do not return the info if you try to obtain it from outside the Admin CP. My Google SEO plugin is like that, because it loads the code necessary for installing/uninstalling/etc. only if it's in the Admin CP. Otherwise it chooses not to include a >30kb blob of code that is not going to be used anyway. If you try to call the info function anyway, you'll get an error because it simply does not exist, not outside the ACP.

The only way to get around that without knowledge about the inner workings of the specific plugin would be harvesting the data exactly the same way the plugins page does it - from within the Admin CP. So you could hook into the plugins page and update a template everytime the plugins page is visited.
I'm not touching the _install, _activate, etc. functions, only the _info and all I am doing is reading those values and listing them. It works fine if the values are declared statically, for example: "name"=> "Plugin name"
Yes, exactly. There is no _info function in my plugin outside Admin CP. It's a good thing too, since in my case it displays sensitive information (detailed plugin status) in the info. It would probably be bad for that to end up on a credits page...

I think the best option for you would be to simply test if the _info function exists and call it. And then see if it returned something that's good to use (i.e. filter out empty strings). And then use what you got.

You're using plugin functions in a way they are not used by MyBB, so you can't expect every plugin to cooperate. In such a case you can contact the author and leave the decision to them, whether they want to change something to support your credits page or not.

Regarding your specific akismet problem, $lang->set_language($lang->language, "admin") before calling the info may help. It may also cause a number of other problems, though.
Thanks for your help frostschutz, I'll download GoogleSEO and take a look. With Akismet, I can access all the other _info properties, just not the two which are defined as lang variables.
You can't simply call a $lang->load as you won't be in the AdminCP (path is set differently).

I believe the paths in the $lang object are set in the set_language() call, so for your plugin, I'd suggest amending $lang->path and then restoring it after calling the _info function (haven't tested this).


But updating some sort of cache when the plugins cache is modified is probably a better idea, though perhaps more difficult to implement.
Have you tried this:
$lang->set_language("english", "admin");
$lang->load("plugincodename");
$lang->set_language("english", "user");
?
You'd probably need to change english to the default language of the site but on a test MyBB board the above should work.
Edit:
Ahh Yumi has already said this
Hmm... What about cases of plugins that you wouldn't want to show on this list anyway? Things like the fake ACP plugins, various security plugins, etc.
(2010-04-05, 02:11 PM)ladyunicornejg Wrote: [ -> ]Hmm... What about cases of plugins that you wouldn't want to show on this list anyway? Things like the fake ACP plugins, various security plugins, etc.
In this case, the administrator obviously wouldn't install this modification then.
It's really only for admins who want to show off their installed plugins, or something like that.
(2010-04-06, 12:32 AM)Yumi Wrote: [ -> ]It's really only for admins who want to show off their installed plugins, or something like that.

Exactly, and so admins can give authors more credit for their plugins.
Pages: 1 2 3