예제 #1
0
 /** {@inheritdoc} */
 public function rules()
 {
     return [[['id', 'zone_id', 'seller_id', 'client_id', 'remoteid', 'daysleft', 'prem_daysleft'], 'integer'], [['domain', 'statuses', 'name', 'zone', 'state', 'lastop', 'state_label'], 'safe'], [['seller', 'seller_name', 'client', 'client_name'], 'safe'], [['created_date', 'updated_date', 'transfer_date', 'expiration_date', 'expires', 'since', 'prem_expires'], 'date'], [['registered', 'operated'], 'date'], [['is_expired', 'is_served', 'is_holded', 'is_premium', 'is_secured', 'is_freezed', 'wp_freezed'], 'boolean'], [['premium_autorenewal', 'expires_soon', 'autorenewal', 'whois_protected'], 'boolean'], [['foa_sent_to'], 'email'], [['url_fwval', 'mailval', 'parkval', 'soa', 'dns', 'counters'], 'safe'], [['block', 'epp_client_id', 'nameservers', 'nsips'], 'safe'], [['note'], 'safe', 'on' => ['set-note', 'default']], [['enable'], 'safe', 'on' => ['set-lock', 'set-whois-protect']], [['domain', 'autorenewal'], 'safe', 'on' => 'set-autorenewal'], [['domain', 'whois_protected'], 'safe', 'on' => 'set-whois-protect'], [['domain', 'is_secured'], 'safe', 'on' => 'set-lock'], [['domain'], 'safe', 'on' => ['sync', 'only-object']], [['id'], 'required', 'on' => ['enable-freeze', 'disable-freeze', 'sync', 'regen-password', 'set-note', 'set-autorenewal', 'set-whois-protect', 'set-lock', 'push-with-pincode', 'enable-hold', 'disable-hold', 'enable-w-p-freeze', 'disable-w-p-freeze']], [['domain'], DomainPartValidator::className(), 'message' => Yii::t('hipanel:domain', '\'{value}\' is not valid domain name'), 'on' => ['check-domain']], [['domain'], 'filter', 'filter' => function ($value) {
         if (strpos($value, '.') !== false) {
             return substr($value, 0, strpos($value, '.'));
         } else {
             return $value;
         }
     }, 'on' => 'check-domain'], [['domain'], 'required', 'on' => ['check-domain']], [['zone'], 'safe', 'on' => ['check-domain']], [['zone'], 'trim', 'on' => ['check-domain']], [['zone'], 'default', 'value' => static::DEFAULT_ZONE, 'on' => ['check-domain']], [['is_available'], 'boolean', 'on' => ['check-domain']], [['resource'], 'safe', 'on' => ['check-domain']], [['domain', 'password'], 'required', 'when' => function ($model) {
         return empty($model->domains);
     }, 'on' => ['transfer']], [['domains'], 'required', 'when' => function ($model) {
         return empty($model->domain) && empty($model->password);
     }, 'on' => ['transfer']], [['domain'], DomainValidator::class, 'on' => ['transfer']], [['domain', 'password'], 'trim', 'on' => ['transfer']], [['domain', 'nameservers', 'nsips'], 'safe', 'on' => 'set-nss'], [['nameservers', 'nsips'], 'filter', 'filter' => function ($value) {
         return !is_array($value) ? StringHelper::mexplode($value) : $value;
     }, 'on' => 'OLD-set-ns'], [['nameservers'], 'each', 'rule' => [DomainValidator::class], 'on' => 'OLD-set-ns'], [['nsips'], 'each', 'rule' => [NsValidator::class], 'on' => 'OLD-set-ns'], [['dumb'], 'safe', 'on' => ['get-zones']], [['receiver'], 'required', 'on' => ['push', 'push-with-pincode']], [['pincode'], 'required', 'on' => ['push-with-pincode']], [['pincode'], function ($attribute, $params) {
         try {
             $response = Client::perform('CheckPincode', [$attribute => $this->{$attribute}, 'id' => Yii::$app->user->id]);
         } catch (Exception $e) {
             $this->addError($attribute, Yii::t('hipanel:client', 'Wrong pincode'));
         }
     }, 'on' => ['push-with-pincode']], [['domain', 'sender', 'pincode'], 'safe', 'on' => ['push', 'push-with-pincode']], [['id', 'domain'], 'safe', 'on' => ['bulk-set-contacts']]];
 }
예제 #2
0
 public function rules()
 {
     return [[['id', 'service_id', 'server_id'], 'integer'], [['name', 'domain', 'idn', 'type', 'fqdn', 'idn_fqdn', 'value', 'service', 'server'], 'safe'], [['is_system'], 'boolean'], [['ttl'], 'integer', 'min' => 60, 'max' => 86400, 'on' => ['create', 'update']], [['name'], DomainPartValidator::className(), 'when' => $this->buildRuleWhen(['srv', 'txt', 'cname'], true), 'whenClient' => $this->buildRuleWhenClient(['srv', 'txt', 'cname'], true), 'on' => ['create', 'update', 'delete']], [['name'], DomainPartValidator::className(), 'extended' => true, 'when' => $this->buildRuleWhen(['srv', 'txt', 'cname']), 'whenClient' => $this->buildRuleWhenClient(['srv', 'txt', 'cname']), 'on' => ['create', 'update', 'delete']], [['type'], 'in', 'range' => array_keys($this->getTypes()), 'on' => ['create', 'update']], [['value'], 'ip', 'ipv6' => false, 'when' => $this->buildRuleWhen('a'), 'whenClient' => $this->buildRuleWhenClient('a'), 'on' => ['create', 'update'], 'message' => Yii::t('hipanel:dns', '{attribute} must be a valid IP address.'), 'ipv6NotAllowed' => Yii::t('hipanel:dns', '{attribute} must not be an IPv6 address.')], [['value'], 'ip', 'ipv4' => false, 'when' => $this->buildRuleWhen('aaaa'), 'whenClient' => $this->buildRuleWhenClient('aaaa'), 'on' => ['create', 'update'], 'message' => Yii::t('hipanel:dns', '{attribute} must be a valid IP address.'), 'ipv4NotAllowed' => Yii::t('hipanel:dns', '{attribute} must be a valid IPv6 address.')], [['value'], 'email', 'when' => $this->buildRuleWhen('soa'), 'whenClient' => $this->buildRuleWhenClient('soa'), 'on' => ['create', 'update'], 'message' => Yii::t('hipanel:dns', '{attribute} is not a valid email address.')], [['value'], TxtValueValidator::className(), 'when' => $this->buildRuleWhen('txt'), 'whenClient' => $this->buildRuleWhenClient('txt'), 'on' => ['create', 'update']], [['value'], 'string', 'max' => 255, 'when' => $this->buildRuleWhen('txt'), 'whenClient' => $this->buildRuleWhenClient('txt'), 'on' => ['create', 'update']], [['value'], MxValueValidator::className(), 'when' => $this->buildRuleWhen('mx'), 'whenClient' => $this->buildRuleWhenClient('mx'), 'on' => ['create', 'update']], [['value'], FqdnValueValidator::className(), 'trimTrailingDot' => true, 'when' => $this->buildRuleWhen(['ns', 'cname']), 'whenClient' => $this->buildRuleWhenClient(['ns', 'cname']), 'on' => ['create', 'update']], [['value'], 'match', 'pattern' => '/[a-z]/i', 'message' => Yii::t('hipanel:dns', '{attribute} is not a valid domain name'), 'when' => $this->buildRuleWhen(['ns', 'mx', 'cname']), 'whenClient' => $this->buildRuleWhenClient(['ns', 'mx', 'cname']), 'on' => ['create', 'update']], [['value'], SrvValueValidator::className(), 'when' => $this->buildRuleWhen('srv'), 'whenClient' => $this->buildRuleWhenClient('srv'), 'on' => ['create', 'update'], 'message' => Yii::t('hipanel:dns', '{attribute} is invalid.')], [['no'], 'integer', 'on' => ['create', 'update']], [['value', 'type', 'ttl'], 'required', 'on' => ['create', 'update']], [['id'], 'required', 'on' => ['update', 'delete']], [['hdomain_id'], 'required', 'on' => ['create', 'update', 'delete']], [['status'], 'default', 'value' => 'deleted', 'when' => function ($model) {
         return $model->scenario === 'delete';
     }]];
 }