Hi! What's the best way to check in code that some plugin (say, by its shortname - the plugin directory name) is installed in system? What functions or classes should I use to do it?
General developer forum
Try look at the lib/moodlelib.php function moodle_needs_upgrading. It calls useful functions like get_plugin_list().
Thanks Rex, I'm aware of this function and some other functions which Moodle uses for installation and upgrading. I just hoped that Moodle has a brilliant function, something like plugin_is_installed($pluginname, ...) so I just write a line of code and that's it. A good reason to make it myself.
You can use moodle(M2.3) default plugin manager code.
require_once($CFG->libdir . '/pluginlib.php');
$pluginman = plugin_manager::instance();
$plugin_info = $pluginman->get_plugin_info('qtype_calculated');
plugininfo_qtype Object ( [type] => qtype [typerootdir] => /Users/jitendra/Sites/moodle_23/question/type [name] => calculated [displayname] => Calculated [source] => std [rootdir] => /Users/jitendra/Sites/moodle_23/question/type/calculated [versiondisk] => 2012061700 [versiondb] => 2012061700 [versionrequires] => 2012061700 [dependencies] => [instances] => [sortorder] => [availableupdates] => )
You can pass the plugin name is the get_plugin_info() code and It will tell you about the plugin.But the problem with this code is that you have to specify the plugin type.
Hope it will help you.