Updated the validation of position x and position y for customcert elements

This commit is contained in:
Mark Nelson 2013-04-24 18:07:56 +08:00
parent 16056f076f
commit dfbb864ac9

View file

@ -161,17 +161,15 @@ class customcert_element_base {
// Get position X. // Get position X.
$posx = 'posx_' . $id; $posx = 'posx_' . $id;
$posxdata = $data[$posx]; // Check if posx is not set, or not numeric or less than 0.
// Check if posx is not numeric or less than 0. if ((!isset($data[$posx])) || (!is_numeric($data[$posx])) || ($data[$posx] <= 0)) {
if (empty($posxdata) || (!is_numeric($posxdata)) || ($posxdata < 0)) {
$errors[$posx] = get_string('invalidposition', 'customcert', 'X'); $errors[$posx] = get_string('invalidposition', 'customcert', 'X');
} }
// Get position Y. // Get position Y.
$posy = 'posy_' . $id; $posy = 'posy_' . $id;
$posydata = $data[$posy]; // Check if posy is not set, or not numeric or less than 0.
// Check if posy is not numeric or less than 0. if ((!isset($data[$posy])) || (!is_numeric($data[$posy])) || ($data[$posy] <= 0)) {
if (empty($posydata) || (!is_numeric($posydata)) || ($posydata < 0)) {
$errors[$posy] = get_string('invalidposition', 'customcert', 'Y'); $errors[$posy] = get_string('invalidposition', 'customcert', 'Y');
} }