/** * 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; }
*/ require_once dirname(__FILE__) . '/../../../../config.php'; global $CFG, $PAGE, $OUTPUT; require_once $CFG->dirroot . '/mod/assign/feedback/pdf/mypdflib.php'; $PAGE->set_url(new moodle_url('/mod/assign/feedback/pdf/testgs.php')); $PAGE->set_context(context_system::instance()); require_login(); if (!is_siteadmin()) { die('Admin only'); } if (optional_param('sendimage', false, PARAM_BOOL)) { // Serve the generated test image. AssignPDFLib::send_test_image(); die; } $result = AssignPDFLib::test_gs_path(); switch ($result->status) { case AssignPDFLib::GSPATH_OK: $msg = get_string('test_ok', 'assignfeedback_pdf'); $msg .= html_writer::empty_tag('br'); $imgurl = new moodle_url($PAGE->url, array('sendimage' => 1)); $msg .= html_writer::empty_tag('img', array('src' => $imgurl)); break; case AssignPDFLib::GSPATH_ERROR: $msg = $result->message; break; default: $msg = get_string("test_{$result->status}", 'assignfeedback_pdf'); break; } $returl = new moodle_url('/admin/settings.php', array('section' => 'assignfeedback_pdf'));