Merge branch 'MDL-42671-master' of git://github.com/damyon/moodle

This commit is contained in:
Eloy Lafuente (stronk7) 2013-11-05 17:27:04 +01:00
commit 233db99d65
4 changed files with 80 additions and 2 deletions

View File

@ -8553,3 +8553,68 @@ class admin_setting_configmultiselect_modules extends admin_setting_configmultis
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;
}
}

View File

@ -89,3 +89,5 @@ $string['unsavedchanges'] = 'Unsaved changes';
$string['viewfeedbackonline'] = 'View annotated pdf...';
$string['white'] = 'White';
$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.';

View File

@ -266,6 +266,9 @@ class assign_feedback_editpdf extends assign_feedback_plugin {
*/
public function is_enabled() {
$testpath = assignfeedback_editpdf\pdf::test_gs_path();
if (!extension_loaded('zlib')) {
return false;
}
if ($testpath->status == assignfeedback_editpdf\pdf::GSPATH_OK) {
return true;
}

View File

@ -35,8 +35,16 @@ $settings->add($setting);
// Ghostscript setting.
$settings->add(new admin_setting_configexecutable('assignfeedback_editpdf/gspath',
get_string('gspath', 'assignfeedback_editpdf'),
get_string('gspath_help', 'assignfeedback_editpdf'), '/usr/bin/gs'));
get_string('gspath', 'assignfeedback_editpdf'),
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');
$link = html_writer::link($url, get_string('testgs', 'assignfeedback_editpdf'));