Do not allow '0' as a value for width or height in QR code (#321)

This commit is contained in:
Mark Nelson 2020-03-09 14:48:24 +01:00
parent 01bfe2f660
commit 2f8bb1eb29

View file

@ -72,8 +72,12 @@ class element extends \mod_customcert\element {
$errors = [];
// Check if height is not set, or not numeric or less than 0.
if ((!isset($data['height'])) || (!is_numeric($data['height'])) || ($data['height'] < 0)) {
$errors['height'] = get_string('invalidheight', 'customcertelement_qrcode');
if ((!isset($data['height'])) || (!is_numeric($data['height'])) || ($data['height'] <= 0)) {
$errors['height'] = get_string('invalidheight', 'mod_customcert');
}
if ((!isset($data['width'])) || (!is_numeric($data['width'])) || ($data['width'] <= 0)) {
$errors['width'] = get_string('invalidwidth', 'mod_customcert');
}
if ($this->showposxy) {