Библиотека для cis, online, cms1
This commit is contained in:
commit
3c2e614d87
269 changed files with 39854 additions and 0 deletions
59
core/validator/rule/code.php
Normal file
59
core/validator/rule/code.php
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
<?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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue