/** * Installs any new plugins */ public static function install_new_plugins() { global $CFG; // instantiate the assmgr db $dbc = new ilp_db(); // get all the currently installed evidence resource types $plugins = ilp_records_to_menu($dbc->get_form_element_plugins(), 'id', 'name'); $plugins_directory = $CFG->dirroot . '/blocks/ilp/classes/form_elements/plugins'; // get the folder contents of the resource plugin directory $files = scandir($plugins_directory); foreach ($files as $file) { // look for plugins if (preg_match('/^([a-z_]+)\\.php$/i', $file, $matches)) { if (!in_array($matches[1], $plugins) && substr($matches[1], -5) != 'mform') { // include the class require_once $plugins_directory . '/' . $file; // instantiate the object $class = basename($file, ".php"); $formelementobj = new $class(); // install the plugin $formelementobj->install(); // update the resource_types table $dbc->create_form_element_plugin($formelementobj->get_name(), $formelementobj->get_tablename()); } } } }