public function actionChangeContact($contactId = null, $contactType = null, $domainId = null, $domainName = null)
 {
     if (!Yii::$app->request->isPost) {
         $model = $this->findModel($contactId);
         $model->scenario = 'change-contact';
         return $this->render('changeContact', ['countries' => $this->getRefs('country_code', 'hipanel'), 'askPincode' => Client::perform('HasPincode'), 'model' => $model, 'domainId' => $domainId, 'domainName' => $domainName, 'contactType' => $contactType]);
     } else {
         $model = new Contact(['scenario' => 'create']);
         if ($model->load(Yii::$app->request->post())) {
             $domainContactInfo = Domain::perform('GetContactsInfo', ['id' => $model->domainId]);
             $setContactOptions = ['domain' => $model->domainName, 'id' => $model->domainId];
             if ($model->save()) {
                 foreach (Domain::$contactOptions as $contact) {
                     $setContactOptions[$contact] = $contact === $model->contactType ? $model->id : $domainContactInfo[$contact]['id'];
                 }
                 Domain::perform('SetContacts', $setContactOptions);
                 $this->redirect(['@domain/view', 'id' => $model->domainId]);
             }
         }
     }
 }
示例#2
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']]];
 }
 public function actions()
 {
     return ['set-orientation' => ['class' => OrientationAction::class, 'allowedRoutes' => ['@domain/index']], 'add-to-cart-renewal' => ['class' => AddToCartAction::class, 'productClass' => DomainRenewalProduct::class, 'redirectToCart' => true], 'bulk-renewal' => ['class' => AddToCartAction::class, 'productClass' => DomainRenewalProduct::class, 'bulkLoad' => true], 'add-to-cart-registration' => ['class' => AddToCartAction::class, 'redirectToCart' => true, 'productClass' => DomainRegistrationProduct::class], 'add-to-cart-transfer' => ['class' => AddToCartAction::class, 'productClass' => DomainTransferProduct::class, 'bulkLoad' => true], 'bulk-set-contacts-modal' => ['class' => PrepareBulkAction::class, 'scenario' => 'bulk-set-contacts', 'view' => '_bulkSetContacts'], 'domain-push-modal' => ['class' => PrepareBulkAction::class, 'view' => '_modalPush', 'on beforePerform' => function ($event) {
         /** @var Action $action */
         $action = $event->sender;
         $pincodeData = Client::perform('HasPincode', ['id' => Yii::$app->user->id]);
         $hasPincode = $pincodeData['pincode_enabled'];
         $action->data['hasPincode'] = $hasPincode;
         $action->setScenario($hasPincode ? 'push-with-pincode' : 'push');
     }], 'validate-set-contacts-form' => ['class' => ValidateFormAction::class, 'collectionLoader' => function ($action) {
         /** @var SmartPerformAction $action */
         $request = Yii::$app->request;
         $action->collection->load([['registrant' => $request->post('registrant'), 'admin' => $request->post('admin'), 'tech' => $request->post('tech'), 'billing' => $request->post('billing')]]);
     }, 'validatedInputId' => function ($action, $model, $id, $attribute, $errors) {
         return 'domain-' . $attribute;
     }], 'bulk-set-contacts' => ['class' => SmartPerformAction::class, 'scenario' => 'set-contacts', 'collectionLoader' => function ($action) {
         /** @var SmartPerformAction $action */
         $request = Yii::$app->request;
         $contactOptions = Domain::$contactOptions;
         $data = $request->post($action->collection->getModel()->formName());
         foreach ($data as $k => &$item) {
             foreach ($contactOptions as $contact) {
                 $item[$contact] = $request->post($contact);
             }
         }
         $action->collection->load($data);
     }], 'push' => ['class' => SmartPerformAction::class, 'collectionLoader' => function ($action) {
         /** @var SmartPerformAction $action */
         $data = Yii::$app->request->post($action->collection->getModel()->formName());
         $pincode = $data['pincode'];
         $receiver = $data['receiver'];
         unset($data['pincode'], $data['receiver']);
         foreach ($data as &$item) {
             $item['pincode'] = $pincode;
             $item['receiver'] = $receiver;
         }
         $action->collection->load($data);
     }, 'POST' => ['save' => true, 'success' => ['class' => RedirectAction::class, 'url' => function ($action) {
         if (Yii::$app->user->can('support')) {
             return null;
         }
         return ['@domain'];
     }], 'error' => ['class' => RedirectAction::class]], 'success' => Yii::t('hipanel:domain', 'Domain was successfully pushed'), 'error' => Yii::t('hipanel:domain', 'Failed to push the domain')], 'index' => ['class' => IndexAction::class, 'data' => function ($action) {
         return ['stateData' => $action->controller->getStateData()];
     }, 'filterStorageMap' => ['domain_like' => 'domain.domain.domain_like', 'ips' => 'hosting.ip.ip_in', 'state' => 'domain.domain.state', 'client_id' => 'client.client.id', 'seller_id' => 'client.client.seller_id']], 'view' => ['class' => ViewAction::class, 'on beforePerform' => function ($event) {
         $action = $event->sender;
         $action->getDataProvider()->query->addSelect(['nsips', 'contacts'])->joinWith('registrant')->joinWith('admin')->joinWith('tech')->joinWith('billing');
     }, 'data' => function ($action) {
         return ['pincodeModel' => new DynamicModel(['pincode'])];
     }], 'validate-form' => ['class' => ValidateFormAction::class], 'validate-nss' => ['class' => ValidateFormAction::class, 'model' => Ns::class, 'scenario' => 'default', 'allowDynamicScenario' => false], 'validate-push-form' => ['class' => ValidateFormAction::class, 'collectionLoader' => function ($action) {
         /** @var SmartPerformAction $action */
         $request = Yii::$app->request;
         $action->collection->load([['pincode' => $request->post('pincode'), 'receiver' => $request->post('receiver')]]);
     }, 'validatedInputId' => function ($action, $model, $id, $attribute, $errors) {
         return 'push-' . $attribute;
     }], 'set-note' => ['class' => SmartUpdateAction::class, 'success' => Yii::t('hipanel', 'Note changed'), 'error' => Yii::t('hipanel', 'Failed change note'), 'POST html' => ['save' => true, 'success' => ['class' => RedirectAction::class]], 'on beforeSave' => function (Event $event) {
         /** @var \hipanel\actions\Action $action */
         $action = $event->sender;
         $bulkNote = Yii::$app->request->post('bulk_note');
         if (!empty($bulkNote)) {
             foreach ($action->collection->models as $model) {
                 $model->note = $bulkNote;
             }
         }
     }], 'bulk-set-note' => ['class' => PrepareBulkAction::class, 'scenario' => 'set-note', 'view' => '_bulkSetNote'], 'set-nss' => ['class' => SmartUpdateAction::class, 'success' => Yii::t('hipanel:domain', 'Name servers changed'), 'POST html' => ['save' => true, 'success' => ['class' => RedirectAction::class, 'url' => function ($action) {
         return $action->controller->redirect(Yii::$app->request->referrer);
     }]]], 'bulk-set-nss' => ['class' => SmartUpdateAction::class, 'scenario' => 'set-nss', 'view' => '_bulkSetNs', 'success' => Yii::t('hipanel:domain', 'Name servers changed'), 'POST pjax' => ['save' => true, 'success' => ['class' => ProxyAction::class, 'action' => 'index']], 'on beforeFetch' => function (Event $event) {
         /** @var \hipanel\actions\SearchAction $action */
         $action = $event->sender;
         $dataProvider = $action->getDataProvider();
         $dataProvider->query->andWhere(['with_nsips' => 1]);
     }, 'on beforeSave' => function (Event $event) {
         /** @var \hipanel\actions\Action $action */
         $action = $event->sender;
         $bulkNsIps = Yii::$app->request->post('nsips');
         if ($bulkNsIps !== null) {
             foreach ($action->collection->models as $model) {
                 $model->nsips = $bulkNsIps;
             }
         }
     }], 'delete' => ['class' => SmartDeleteAction::class, 'success' => Yii::t('hipanel:domain', 'Domain deleted'), 'error' => Yii::t('hipanel:domain', 'Failed delete domain')], 'delete-agp' => ['class' => SmartPerformAction::class, 'success' => Yii::t('hipanel:domain', 'Domain deleted'), 'error' => Yii::t('hipanel:domain', 'Failed delete domain')], 'cancel-transfer' => ['class' => SmartPerformAction::class, 'success' => Yii::t('hipanel:domain', 'Domain transfer was canceled'), 'error' => Yii::t('hipanel:domain', 'Failed cancel domain transfer')], 'reject-transfer' => ['class' => SmartPerformAction::class, 'success' => Yii::t('hipanel:domain', 'Domain transfer was cancelled'), 'error' => Yii::t('hipanel:domain', 'Failed cancel domain transfer')], 'approve-transfer' => ['class' => SmartPerformAction::class, 'success' => Yii::t('hipanel:domain', 'Domain transfer was approved'), 'error' => Yii::t('hipanel:domain', 'Failed approve domain transfer')], 'notify-transfer-in' => ['class' => SmartPerformAction::class, 'success' => Yii::t('hipanel:domain', 'FOA was sent'), 'error' => Yii::t('hipanel:domain', 'Failed send FOA')], 'enable-hold' => ['class' => SmartPerformAction::class, 'scenario' => 'enable-hold', 'success' => Yii::t('hipanel:domain', 'Hold was enabled'), 'error' => Yii::t('hipanel:domain', 'Failed enabling Hold')], 'disable-hold' => ['class' => SmartPerformAction::class, 'scenario' => 'disable-hold', 'success' => Yii::t('hipanel:domain', 'Hold was disabled'), 'error' => Yii::t('hipanel:domain', 'Failed disabling Hold')], 'enable-freeze' => ['class' => SmartPerformAction::class, 'success' => Yii::t('hipanel:domain', 'Freeze was enabled')], 'disable-freeze' => ['class' => SmartPerformAction::class, 'success' => Yii::t('hipanel:domain', 'Freeze was disabled')], 'enable-w-p-freeze' => ['class' => SmartPerformAction::class, 'success' => Yii::t('hipanel:domain', 'WP Freeze Enabled')], 'disable-w-p-freeze' => ['class' => SmartPerformAction::class, 'success' => Yii::t('hipanel:domain', 'WP Freeze Disabled')], 'OLD-set-ns' => ['class' => RenderAction::class, 'on beforeSave' => function (Event $event) {
         /** @var Action $action */
         $action = $event->sender;
         $templateModel = null;
         $template = Yii::$app->request->post('check');
         foreach ($action->collection->models as $model) {
             if ($model->id === $template) {
                 $templateModel = $model;
             }
         }
         foreach ($action->collection->models as $model) {
             $model->nameservers = $templateModel->nameservers;
         }
     }, 'POST' => ['save' => true, 'success' => ['class' => RenderJsonAction::class, 'return' => function ($action) {
         /* @var Action $action */
         return $action->collection->models;
     }], 'error' => ['class' => RenderJsonAction::class, 'return' => function ($action) {
         /* @var Action $action */
         return $action->collection->getFirstError();
     }]]], 'set-paid-feature-autorenewal' => ['class' => SmartPerformAction::class, 'scenario' => 'set-autorenewal', 'success' => Yii::t('hipanel:domain', 'Premium autorenewal has been changed'), 'on beforeSave' => function (Event $event) {
         /** @var Action $action */
         $action = $event->sender;
         foreach ($action->collection->models as $model) {
             $model->autorenewal = 1;
         }
     }], 'set-autorenewal' => ['class' => DomainOptionSwitcherAction::class, 'success' => Yii::t('hipanel:domain', 'Autorenewal has been changed')], 'enable-autorenewal' => ['class' => SmartPerformAction::class, 'success' => Yii::t('hipanel:domain', 'Autorenewal has been enabled'), 'scenario' => 'set-autorenewal', 'on beforeSave' => function (Event $event) {
         /** @var Action $action */
         $action = $event->sender;
         foreach ($action->collection->models as $model) {
             $model->autorenewal = 1;
         }
     }], 'disable-autorenewal' => ['class' => SmartPerformAction::class, 'success' => Yii::t('hipanel:domain', 'Autorenewal has been disabled'), 'scenario' => 'set-autorenewal', 'on beforeSave' => function (Event $event) {
         /** @var Action $action */
         $action = $event->sender;
         foreach ($action->collection->models as $model) {
             $model->autorenewal = 0;
         }
     }], 'set-whois-protect' => ['class' => DomainOptionSwitcherAction::class, 'success' => Yii::t('hipanel:domain', 'WHOIS protect is changed')], 'enable-whois-protect' => ['class' => SmartPerformAction::class, 'success' => Yii::t('hipanel:domain', 'WHOIS protect is enabled'), 'scenario' => 'set-whois-protect', 'on beforeSave' => function (Event $event) {
         /** @var Action $action */
         $action = $event->sender;
         foreach ($action->collection->models as $model) {
             $model->enable = 1;
         }
     }], 'disable-whois-protect' => ['class' => SmartPerformAction::class, 'success' => Yii::t('hipanel:domain', 'WHOIS protect is disabled'), 'scenario' => 'set-whois-protect', 'on beforeSave' => function (Event $event) {
         /** @var Action $action */
         $action = $event->sender;
         foreach ($action->collection->models as $model) {
             $model->enable = 0;
         }
     }], 'set-lock' => ['class' => DomainOptionSwitcherAction::class, 'success' => Yii::t('hipanel:domain', 'Lock was changed')], 'enable-lock' => ['class' => SmartPerformAction::class, 'success' => Yii::t('hipanel:domain', 'Lock was enabled'), 'scenario' => 'set-lock', 'on beforeSave' => function (Event $event) {
         /** @var Action $action */
         $action = $event->sender;
         foreach ($action->collection->models as $model) {
             $model->enable = 1;
         }
     }], 'disable-lock' => ['class' => SmartPerformAction::class, 'success' => Yii::t('hipanel:domain', 'Lock was disabled'), 'scenario' => 'set-lock', 'on beforeSave' => function (Event $event) {
         /** @var Action $action */
         $action = $event->sender;
         foreach ($action->collection->models as $model) {
             $model->enable = 0;
         }
     }], 'regen-password' => ['class' => SmartPerformAction::class, 'success' => Yii::t('hipanel:domain', 'The password has been changed')], 'sync' => ['class' => SmartPerformAction::class, 'success' => Yii::t('hipanel:domain', 'Contacts synced')], 'buy' => ['class' => RedirectAction::class, 'url' => Yii::$app->params['orgUrl']]];
 }
 /**
  * Set form data to API.
  */
 public function setFormData()
 {
     Client::perform('SetClassValues', ['class' => 'client,ticket_settings', 'values' => ['ticket_emails' => $this->ticket_emails, 'send_message_text' => $this->send_message_text, 'new_messages_first' => $this->new_messages_first]]);
 }