From bffa34b1266d0b656a66d11b30aa3b123c4442a6 Mon Sep 17 00:00:00 2001 From: Andrey Kutejko Date: Mon, 1 Jul 2013 00:10:46 +0300 Subject: [PATCH] minor fixes --- ipf/form/model.php | 2 +- ipf/orm/validator/country.php | 3 ++- ipf/orm/validator/creditcard.php | 16 +++++++--------- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/ipf/form/model.php b/ipf/form/model.php index 9c1909f..acfa6d4 100644 --- a/ipf/form/model.php +++ b/ipf/form/model.php @@ -119,7 +119,7 @@ class IPF_Form_Model extends IPF_Form $db_field = new IPF_Form_DB_Foreignkey('',$name); $this->fields[$name] = $db_field->formField($defaults); } else if ($rt === IPF_ORM_Relation::MANY_AGGREGATE) { - $db_field = new IPF_Form_DB_ManyToMany('',$name); + $db_field = new IPF_Form_DB_Manytomany('',$name); $this->fields[$name] = $db_field->formField($defaults); } } diff --git a/ipf/orm/validator/country.php b/ipf/orm/validator/country.php index 2536f15..966ede8 100644 --- a/ipf/orm/validator/country.php +++ b/ipf/orm/validator/country.php @@ -257,4 +257,5 @@ class IPF_ORM_Validator_Country $value = strtolower($value); return isset(self::$countries[$value]); } -} \ No newline at end of file +} + diff --git a/ipf/orm/validator/creditcard.php b/ipf/orm/validator/creditcard.php index f4a59f6..62609ac 100644 --- a/ipf/orm/validator/creditcard.php +++ b/ipf/orm/validator/creditcard.php @@ -4,7 +4,6 @@ class IPF_ORM_Validator_Creditcard { public function validate($value) { - $cardType = ""; $card_regexes = array( "/^4\d{12}(\d\d\d){0,1}$/" => 'visa', "/^5[12345]\d{14}$/" => 'mastercard', @@ -13,15 +12,17 @@ class IPF_ORM_Validator_Creditcard "/^30[012345]\d{11}$/" => 'diners', "/^3[68]\d{12}$/" => 'diners', ); + + $cardType = ''; foreach ($card_regexes as $regex => $type) { if (preg_match($regex, $value)) { $cardType = $type; break; } } - if ( ! $cardType) { + if (!$cardType) return false; - } + /* mod 10 checksum algorithm */ $revcode = strrev($value); $checksum = 0; @@ -36,10 +37,7 @@ class IPF_ORM_Validator_Creditcard $checksum += 1; } } - if ($checksum % 10 == 0) { - return true; - } else { - return false; - } + return $checksum % 10 == 0; } -} \ No newline at end of file +} + -- 2.49.0