/** * Get all message processors, validate corresponding plugin existance and * system configuration * * @param bool $ready only return ready-to-use processors * @param bool $reset Reset list of message processors (used in unit tests) * @param bool $resetonly Just reset, then exit * @return mixed $processors array of objects containing information on message processors */ function get_message_processors($ready = false, $reset = false, $resetonly = false) { global $DB, $CFG; static $processors; if ($reset) { $processors = array(); if ($resetonly) { return $processors; } } if (empty($processors)) { // Get all processors, ensure the name column is the first so it will be the array key $processors = $DB->get_records('message_processors', null, 'name DESC', 'name, id, enabled'); foreach ($processors as &$processor){ $processor = \core_message\api::get_processed_processor_object($processor); } } if ($ready) { // Filter out enabled and system_configured processors $readyprocessors = $processors; foreach ($readyprocessors as $readyprocessor) { if (!($readyprocessor->enabled && $readyprocessor->configured)) { unset($readyprocessors[$readyprocessor->name]); } } return $readyprocessors; } return $processors; }