Initial Commit

This commit is contained in:
GiacomoHome
2021-09-17 12:41:45 +02:00
commit 9001e4656e
570 changed files with 31013 additions and 0 deletions
+35
View File
@@ -0,0 +1,35 @@
<?php
class App_Form_Validators_EmailPec extends Zend_Validate_Abstract
{
const EMAIL_NULL='is_empty';
const EMAIL_ISPEC='is_pec';
private $_PEC_DOMAINS = array('pec.it','arubapec.it','legalmail.it');
protected $_messageTemplates = array(
self::EMAIL_NULL=>'Valore non presente ',
self::EMAIL_ISPEC=>"L'Email inserita sembra essere una PEC, si prega di inserire un email privata"
);
public function isValid($value)
{
$this->_setValue($value);
$isValid = true;
if ($value === ''){
$this->_error(self::EMAIL_NULL);
$isValid = false;
}
$domain = explode('@',$value);
$domain = $domain[1];
if(in_array($domain,$this->_PEC_DOMAINS)){
$this->_error(self::EMAIL_ISPEC);
$isValid = false;
}
return $isValid;
}
}
+49
View File
@@ -0,0 +1,49 @@
<?php
class App_Form_Validators_InDomain extends Zend_Validate_Abstract
{
const DOMAIN_NULL = 'no_domain';
const DOMAIN_NO_VALUE = 'no_domain_value';
protected $_messageTemplates = array(
self::DOMAIN_NULL => 'Dominio non specificato',
self::DOMAIN_NO_VALUE => "Il valore non è compreso nel dominio specificato"
);
protected $_domain;
protected $_domainName;
public function __construct($domainName)
{
$this->_domainName = $domainName;
$this->setDomain($domainName);
}
public function isValid($value)
{
$this->_setValue($value);
$isValid = true;
if (!in_array($value, $this->_domain)) {
$this->_error(self::DOMAIN_NO_VALUE);
$isValid = false;
}
return $isValid;
}
private function setDomain($domainName)
{
if (!$domainName) {
throw new Zend_Validate_Exception('Nome di dominio non specificato');
}
$this->_domain = array_keys(App_Constants_Domains::DOMAINS[$domainName]);
if(!$this->_domain){
throw new Zend_Validate_Exception('Nome di dominio non trovato');
}
}
}
@@ -0,0 +1,23 @@
<?php
class App_Form_Validators_MongoBooleanRequired extends Zend_Validate_Abstract
{
const REQUIRED_VALUE = 'required_mongo_boolean_value';
protected $_messageTemplates = array(
self::REQUIRED_VALUE=> "Il campo deve essere di true o false"
);
public function isValid($value)
{
$this->_setValue($value);
$isValid = true;
if($value !== true && $value !== false){
$this->_error(self::REQUIRED_VALUE);
$isValid = false;
}
return $isValid;
}
}
+24
View File
@@ -0,0 +1,24 @@
<?php
class App_Form_Validators_MyData extends Zend_Validate_Abstract
{
const INVALID_DATA_FORMAT = 'invalid_data_format';
protected $_messageTemplates = array(
self::INVALID_DATA_FORMAT=>'Formato data non valido'
);
public function isValid($value)
{
$this->_setValue($value);
$isValid = true;
$dateValidatorTrattino = new Zend_Validate_Date(array('format' => 'yyyy-mm-dd'));
if(!$dateValidatorTrattino->isValid($value)){
$this->_error(self::INVALID_DATA_FORMAT);
$isValid = false;
}
return $isValid;
}
}
+70
View File
@@ -0,0 +1,70 @@
<?php
class App_Form_Validators_Piva extends Zend_Validate_Abstract
{
const PIVA_NULL='is_empty';
const PIVA_LENGHT='min_lenght';
const PIVA_MATCH='preg_match';
const PIVA_INVALID='invalid';
const PIVA_INVALID_ME='invalid_me';
const PIVA_INVALID_ZERO='invalid_zero';
protected $_messageTemplates = array(
self::PIVA_NULL=>'Valore non presente ',
self::PIVA_LENGHT=>'La lunghezza della partita iva "%value%" non &egrave corretta: la partita IVA dovrebbe essere lunga esattamente 11 caratteri',
self::PIVA_MATCH=>'La partita iva "%value%" contiene dei caratteri non ammessi: la partita IVA dovrebbe contenere solo cifre',
self::PIVA_INVALID=>'La partita iva "%value%" non &egrave; valida',
self::PIVA_INVALID_ME=>'La partita iva "%value%" non &egrave; valida: non puoi inserire la nostra p.iva',
self::PIVA_INVALID_ZERO=>'Sei sicuro che "%value%" sia la tua partita iva?',
);
public function isValid($value,$checkPivaInterna = true)
{
$this->_setValue($value);
$isValid = true;
if ($value === ''){
$this->_error(self::PIVA_NULL);
$isValid = false;
}
if(strlen($value) != 11){
$this->_error(self::PIVA_LENGHT);
$isValid = false;
}
/*Controllo personalizzato sulla propria partita iva */
if ($value === '01999590688' && $checkPivaInterna){
$this->_error(self::PIVA_INVALID_ME);
$isValid = false;
}
if ($value === '00000000000'){
$this->_error(self::PIVA_INVALID_ZERO);
$isValid = false;
}
if(preg_match("/^[0-9]+\$/", $value) != 1){
$this->_error(self::PIVA_MATCH);
$isValid = false;
}
$s = 0;
for ($i = 0; $i <= 9; $i += 2)
$s += ord($value[$i]) - ord('0');
for ($i = 1; $i <= 9; $i += 2) {
$c = 2 * (ord($value[$i]) - ord('0'));
if ($c > 9)
$c = $c - 9;
$s += $c;
}
if ((10 - $s % 10) % 10 != ord($value[10]) - ord('0')){
$this->_error(self::PIVA_INVALID);
$isValid = false;
}
return $isValid;
}
}