59 lines
1.7 KiB
PHP
59 lines
1.7 KiB
PHP
<?php
|
|
|
|
require_once 'abstract.php';
|
|
|
|
/**
|
|
* Проверка формата электронной почты
|
|
*/
|
|
class Rule_Code extends Rule_Abstract
|
|
{
|
|
public function getErrorMsg()
|
|
{
|
|
return "Неправильно указан персональный код";
|
|
}
|
|
|
|
function checkCode($code) {
|
|
foreach($code as $c) {
|
|
if (empty($c)) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public function isValid(Collection $container, $status = null)
|
|
{
|
|
if ($status == 'update') return true;
|
|
$name = $this->field;
|
|
|
|
if (is_array($_POST[$name . '_code_genre'])) {
|
|
for($n = 0; $n < count($_POST[$name . '_code_genre']); $n++) {
|
|
$code = array(
|
|
$_POST[$name . '_code_genre'][$n],
|
|
$_POST[$name . '_code_f'][$n],
|
|
$_POST[$name . '_code_i'][$n],
|
|
$_POST[$name . '_code_o'][$n],
|
|
$_POST[$name . '_code_year'][$n],
|
|
$_POST[$name . '_code_month'][$n],
|
|
$_POST[$name . '_code_day'][$n]
|
|
);
|
|
if (!$this->checkCode($code)) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
} else {
|
|
$code = array(
|
|
$_POST[$name . '_code_genre'],
|
|
$_POST[$name . '_code_f'],
|
|
$_POST[$name . '_code_i'],
|
|
$_POST[$name . '_code_o'],
|
|
$_POST[$name . '_code_year'],
|
|
$_POST[$name . '_code_month'],
|
|
$_POST[$name . '_code_day']
|
|
);
|
|
|
|
return $this->checkCode($code);
|
|
}
|
|
}
|
|
}
|