Skip to content

Commit

Permalink
Added Hdomain alias create form
Browse files Browse the repository at this point in the history
  • Loading branch information
SilverFire committed Sep 8, 2015
1 parent 65ea654 commit 3e28409
Show file tree
Hide file tree
Showing 13 changed files with 456 additions and 52 deletions.
25 changes: 20 additions & 5 deletions src/controllers/HdomainController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ public function actions()
return [
'index' => [
'class' => 'hipanel\actions\IndexAction',
'findOptions' => ['with_aliases' => true, 'with_vhosts' => true, 'with_request' => true],
'findOptions' => [
'with_vhosts' => true,
'with_aliases' => true,
'with_request' => true,
],
'data' => function ($action) {
return [
'stateData' => $action->controller->getStateData(),
Expand All @@ -27,17 +31,28 @@ public function actions()
],
'view' => [
'class' => 'hipanel\actions\ViewAction',
'findOptions' => ['with_aliases' => true, 'with_vhosts' => true, 'with_request' => true, 'show_deleted' => true, 'show_aliases' => true],
'findOptions' => [
'with_vhosts' => true,
'with_aliases' => true,
'with_request' => true,
'show_deleted' => true,
'show_aliases' => true,
],
],
'create' => [
'class' => 'hipanel\actions\SmartCreateAction',
'success' => Yii::t('app', 'Account create task has been created successfully'),
'error' => Yii::t('app', 'Error while creating account'),
'success' => Yii::t('app', 'Domain create task has been created successfully'),
'error' => Yii::t('app', 'Error while creating domain'),
],
'create-alias' => [
'class' => 'hipanel\actions\SmartCreateAction',
'view' => 'create-alias',
'success' => Yii::t('app', 'Domain alias create task has been created successfully'),
'error' => Yii::t('app', 'Error while creating domain'),
],
'validate-form' => [
'class' => 'hipanel\actions\ValidateFormAction',
],
// Premium Autorenewal
'enable-paid-feature-autorenewal' => [
'class' => 'hipanel\actions\SmartPerformAction',
'success' => Yii::t('app', 'Premium autorenewal has been enabled'),
Expand Down
9 changes: 8 additions & 1 deletion src/controllers/ServiceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,12 @@

class ServiceController extends \hipanel\base\CrudController
{

public function actions()
{
return [
'index' => [
'class' => 'hipanel\actions\IndexAction',
],
];
}
}
22 changes: 22 additions & 0 deletions src/controllers/VhostController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
/**
* @link http://hiqdev.com/hipanel-module-hosting
* @license http://hiqdev.com/hipanel-module-hosting/license
* @copyright Copyright (c) 2015 HiQDev
*/

namespace hipanel\modules\hosting\controllers;

use Yii;

class VhostController extends \hipanel\base\CrudController
{
public function actions()
{
return [
'index' => [
'class' => 'hipanel\actions\IndexAction',
],
];
}
}
17 changes: 4 additions & 13 deletions src/models/Db.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,17 @@ public function rules () {
[['service_ip', 'description'], 'safe'],
[['type', 'state', 'backuping_type', 'type_label', 'state_label', 'backuping_type_label'], 'safe'],
/// Create
[['server', 'account', 'service_id', 'name', 'password'], 'required', 'on' => 'create'],
[['name'], DbNameValidator::className(), 'on' => 'create'],
[['server', 'account', 'service_id', 'name', 'password'], 'required', 'on' => ['create']],
[['name'], DbNameValidator::className(), 'on' => ['create']],
[
['password'],
'match',
'pattern' => '/^[\x20-\x7f]+$/',
'message' => \Yii::t('app', '{attribute} should not contain non-latin characters'),
'on' => ['create', 'set-password']
],
[['password'], 'required', 'on' => ['set-password']]
];
}

public function scenarios () {
return [
'create' => ['client', 'server', 'account', 'service_id', 'name', 'password', 'description'],
'truncate' => ['id'],
'set-description' => ['id', 'description'],
'set-password' => ['id', 'password'],
'delete' => ['id'],
[['password'], 'required', 'on' => ['set-password']],
[['id'], 'required', 'on' => ['delete', 'set-password', 'set-description', 'truncate']]
];
}

Expand Down
50 changes: 36 additions & 14 deletions src/models/Hdomain.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use hipanel\modules\client\validators\LoginValidator as ClientLoginValidator;
use hipanel\modules\domain\validators\DomainValidator;
use hipanel\modules\hosting\validators\LoginValidator as AccountLoginValidator;
use hipanel\validators\IpValidator;
use Yii;

class Hdomain extends \hipanel\base\Model
Expand All @@ -22,7 +23,7 @@ class Hdomain extends \hipanel\base\Model
public $vhost;

/**
* @var array Stores array of aliases of hdomain
* @var array Stores array of aliases of hdomain
*/
public $aliases;

Expand All @@ -42,7 +43,8 @@ public function rules()
'state_id',
'type_id',
'vhost_id',
'device_id'
'device_id',
'dns_hdomain_id',
],
'integer'
],
Expand All @@ -57,6 +59,12 @@ public function rules()
],
'safe'
],
[['client', 'seller'], ClientLoginValidator::className()],
[['account'], AccountLoginValidator::className()],
[['dns_on', 'with_www', 'proxy_enable'], 'boolean'],
[['domain', 'alias'], DomainValidator::className()],
[['ip', 'backend_ip'], IpValidator::className()], /// TODO: replace with IP validator
[['domain', 'id'], 'safe', 'on' => ['enable-paid-feature-autorenewal', 'disable-paid-feature-autorenewal']],
[
[
'server',
Expand All @@ -67,15 +75,27 @@ public function rules()
'ip',
],
'required',
'on' => 'create'
'on' => ['create']
],
[
['sub'],
'match',
'pattern' => '/^(\*|[a-z0-9][a-z0-9-]*)$/i',
'message' => \Yii::t('app', '{attribute} does not look like a domain part'),
'on' => ['create-alias']
],
[['client','seller'], ClientLoginValidator::className()],
[['account'], AccountLoginValidator::className()],
[['dns_on', 'with_www', 'proxy_enable'], 'boolean'],
[['domain', 'alias'], DomainValidator::className()],
[['ip', 'backend_ip'], 'safe'], /// TODO: replace with IP validator

[['domain', 'id'], 'safe', 'on' => ['enable-paid-feature-autorenewal', 'disable-paid-feature-autorenewal']],
[
[
'server',
'account',
'vhost_id',
'domain',
'with_www',
],
'required',
'on' => ['create-alias']
],
];
}

Expand All @@ -88,12 +108,13 @@ function getIsProxied()
public function attributeLabels()
{
return $this->mergeAttributeLabels([
'domain' => Yii::t('app', 'Domain Name'),
'backend_ip' => Yii::t('app', 'Backend IP'),
'with_www' => Yii::t('app', 'Create www alias'),
'proxy_enable' => Yii::t('app', 'Enable proxy (NEED MANUAL)'),
'domain' => Yii::t('app', 'Domain Name'),
'backend_ip' => Yii::t('app', 'Backend IP'),
'with_www' => Yii::t('app', 'Create www alias'),
'proxy_enable' => Yii::t('app', 'Enable proxy (NEED MANUAL)'),
'backuping_type' => Yii::t('app', 'Backup periodicity'),
'dns_on' => Yii::t('app', 'DNS'),
'dns_on' => Yii::t('app', 'DNS'),
'vhost_id' => Yii::t('app', 'Alias for')
]);
}

Expand All @@ -104,6 +125,7 @@ public function scenarioCommands()
if (in_array($this->scenario, ['create', 'update'])) {
$result['create'] = ['vhosts', ucfirst($this->scenario)]; // Create should be send to vhost module
}
$result['create-alias'] = 'create';
return $result;
}
}
90 changes: 90 additions & 0 deletions src/models/Vhost.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<?php
/**
* @link http://hiqdev.com/hipanel-module-hosting
* @license http://hiqdev.com/hipanel-module-hosting/license
* @copyright Copyright (c) 2015 HiQDev
*/

namespace hipanel\modules\hosting\models;

use hipanel\helpers\StringHelper;
use hipanel\modules\client\validators\LoginValidator;
use hipanel\validators\IpValidator;
use Yii;

class Vhost extends \hipanel\base\Model
{

use \hipanel\base\ModelTrait;


public function rules()
{
return [
[
[
'domain',
'ip',
'port',
'path',
'client',
'device',
'account',
'service',
'server',
'soft',
'type',
'state',
'state_label',
'backuping_type',
'backuping_type_label',
'cgibin_postfix',
'domain_prefix',
'docroot_postfix',
'apache_conf',
'nginx_conf',
'docroot',
'cgibin',
'fullpath',
],
'safe'
],
[
[
'id',
'ip_id',
'frontend_id',
'client_id',
'device_id',
'server_id',
'account_id',
'soft_id',
'service_id',
],
'integer'
],
[
[
'enable_ssi',
'enable_suexec',
'enable_accesslog',
'enable_errorslog',
'enable_scripts',
'dns_on',

],
'boolean'
],
];
}

/**
* @inheritdoc
*/
public function attributeLabels()
{
return $this->mergeAttributeLabels([

]);
}
}
14 changes: 14 additions & 0 deletions src/models/VhostSearch.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php
/**
* @link http://hiqdev.com/hipanel-module-hosting
* @license http://hiqdev.com/hipanel-module-hosting/license
* @copyright Copyright (c) 2015 HiQDev
*/

namespace hipanel\modules\hosting\models;

use hipanel\base\SearchModelTrait;

class VhostSearch extends Vhost {
use SearchModelTrait;
}
Loading

0 comments on commit 3e28409

Please sign in to comment.