mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
MDL-42671 EditPDF: Disable EditPDF is zlib is not available
Also put a warning on the admin page if this is the case.
This commit is contained in:
parent
61bac37cf1
commit
237f484188
4 changed files with 80 additions and 2 deletions
|
@ -8553,3 +8553,68 @@ class admin_setting_configmultiselect_modules extends admin_setting_configmultis
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Admin setting to show if a php extension is enabled or not.
|
||||||
|
*
|
||||||
|
* @copyright 2013 Damyon Wiese
|
||||||
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||||
|
*/
|
||||||
|
class admin_setting_php_extension_enabled extends admin_setting {
|
||||||
|
|
||||||
|
/** @var string The name of the extension to check for */
|
||||||
|
private $extension;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calls parent::__construct with specific arguments
|
||||||
|
*/
|
||||||
|
public function __construct($name, $visiblename, $description, $extension) {
|
||||||
|
$this->extension = $extension;
|
||||||
|
$this->nosave = true;
|
||||||
|
parent::__construct($name, $visiblename, $description, '');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Always returns true, does nothing
|
||||||
|
*
|
||||||
|
* @return true
|
||||||
|
*/
|
||||||
|
public function get_setting() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Always returns true, does nothing
|
||||||
|
*
|
||||||
|
* @return true
|
||||||
|
*/
|
||||||
|
public function get_defaultsetting() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Always returns '', does not write anything
|
||||||
|
*
|
||||||
|
* @return string Always returns ''
|
||||||
|
*/
|
||||||
|
public function write_setting($data) {
|
||||||
|
// Do not write any setting.
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Outputs the html for this setting.
|
||||||
|
* @return string Returns an XHTML string
|
||||||
|
*/
|
||||||
|
public function output_html($data, $query='') {
|
||||||
|
global $OUTPUT;
|
||||||
|
|
||||||
|
$o = '';
|
||||||
|
if (!extension_loaded($this->extension)) {
|
||||||
|
$warning = $OUTPUT->pix_icon('i/warning', '', '', array('role' => 'presentation')) . ' ' . $this->description;
|
||||||
|
|
||||||
|
$o .= format_admin_setting($this, $this->visiblename, $warning);
|
||||||
|
}
|
||||||
|
return $o;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -89,3 +89,5 @@ $string['unsavedchanges'] = 'Unsaved changes';
|
||||||
$string['viewfeedbackonline'] = 'View annotated pdf...';
|
$string['viewfeedbackonline'] = 'View annotated pdf...';
|
||||||
$string['white'] = 'White';
|
$string['white'] = 'White';
|
||||||
$string['yellow'] = 'Yellow';
|
$string['yellow'] = 'Yellow';
|
||||||
|
$string['zlibenabled'] = 'zlib enabled';
|
||||||
|
$string['zlibnotavailable'] = 'Php extension "zlib" is not available. The annotate PDF feature relies on this php extension and will be disabled until zlib is installed and enabled.';
|
||||||
|
|
|
@ -266,6 +266,9 @@ class assign_feedback_editpdf extends assign_feedback_plugin {
|
||||||
*/
|
*/
|
||||||
public function is_enabled() {
|
public function is_enabled() {
|
||||||
$testpath = assignfeedback_editpdf\pdf::test_gs_path();
|
$testpath = assignfeedback_editpdf\pdf::test_gs_path();
|
||||||
|
if (!extension_loaded('zlib')) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if ($testpath->status == assignfeedback_editpdf\pdf::GSPATH_OK) {
|
if ($testpath->status == assignfeedback_editpdf\pdf::GSPATH_OK) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,15 @@ $settings->add($setting);
|
||||||
// Ghostscript setting.
|
// Ghostscript setting.
|
||||||
$settings->add(new admin_setting_configexecutable('assignfeedback_editpdf/gspath',
|
$settings->add(new admin_setting_configexecutable('assignfeedback_editpdf/gspath',
|
||||||
get_string('gspath', 'assignfeedback_editpdf'),
|
get_string('gspath', 'assignfeedback_editpdf'),
|
||||||
get_string('gspath_help', 'assignfeedback_editpdf'), '/usr/bin/gs'));
|
get_string('gspath_help', 'assignfeedback_editpdf'),
|
||||||
|
'/usr/bin/gs'));
|
||||||
|
|
||||||
|
$setting = new admin_setting_php_extension_enabled('assignfeedback_editpdf/zlibenabled',
|
||||||
|
get_string('zlibenabled', 'assignfeedback_editpdf'),
|
||||||
|
get_string('zlibnotavailable', 'assignfeedback_editpdf'),
|
||||||
|
'zlib');
|
||||||
|
|
||||||
|
$settings->add($setting);
|
||||||
|
|
||||||
$url = new moodle_url('/mod/assign/feedback/editpdf/testgs.php');
|
$url = new moodle_url('/mod/assign/feedback/editpdf/testgs.php');
|
||||||
$link = html_writer::link($url, get_string('testgs', 'assignfeedback_editpdf'));
|
$link = html_writer::link($url, get_string('testgs', 'assignfeedback_editpdf'));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue