/** * Check the ghostscript path is valid to see if the plugin should be enabled. * @return bool */ public function is_enabled() { global $CFG; static $gspathok = null; if (is_null($gspathok)) { require_once $CFG->dirroot . '/mod/assign/feedback/pdf/mypdflib.php'; $result = AssignPDFLib::test_gs_path(false); $gspathok = $result->status == AssignPDFLib::GSPATH_OK; if (!$gspathok && $this->is_visible()) { // Setting 'gspath' is invalid, so the plugin should be globally disabled. set_config('disabled', true, $this->get_subtype() . '_' . $this->get_type()); } } if (!parent::is_enabled()) { return false; } return $gspathok; }
/** * Override the default is_enabled to disable this plugin if advanced grading is active * * @return bool */ public function is_enabled() { if ($this->enabledcache === null) { $gradingmanager = get_grading_manager($this->assignment->get_context(), 'mod_assign', 'submissions'); $controller = $gradingmanager->get_active_controller(); $active = !empty($controller); if ($active) { $this->enabledcache = false; } else { $this->enabledcache = parent::is_enabled(); } } return $this->enabledcache; }
/** * Automatically disable plugin if we're on the front page. * * @return bool */ public function is_enabled() { if ($this->isonfrontpage() === true) { return false; } return parent::is_enabled(); }