diff --git a/src/SidebarMenu.php b/src/SidebarMenu.php
index a52b18c3..c973ad6a 100644
--- a/src/SidebarMenu.php
+++ b/src/SidebarMenu.php
@@ -40,12 +40,18 @@ public function items()
'icon' => 'fa-globe',
'visible' => function () { return (bool)Yii::getAlias('@domain', false); },
],
+ 'mails' => [
+ 'label' => Yii::t('app', 'Mailboxes'),
+ 'url' => ['/hosting/mail/index'],
+ 'icon' => 'fa-mail',
+ 'visible' => function () { return (bool)Yii::getAlias('@mail', false); },
+ ],
'Backups' => [
'label' => Yii::t('app', 'Backups'),
'url' => ['/hosting/backup/index'],
// 'icon' => 'fa-globe',
'visible' => function () { return (bool)Yii::getAlias('@domain', false); },
- ]
+ ],
],
],
];
diff --git a/src/controllers/MailController.php b/src/controllers/MailController.php
index ba9cd475..686c292b 100644
--- a/src/controllers/MailController.php
+++ b/src/controllers/MailController.php
@@ -7,7 +7,31 @@
namespace hipanel\modules\hosting\controllers;
+use hipanel\models\Ref;
+
class MailController extends \hipanel\base\CrudController
{
+ public function actions() {
+ return [
+ 'index' => [
+ 'class' => 'hipanel\actions\IndexAction',
+ 'data' => function ($action) {
+ return [
+ 'stateData' => $action->controller->getStateData(),
+ 'typeData' => $action->controller->getTypeData(),
+ ];
+ }
+ ]
+ ];
+ }
+
+ public function getStateData()
+ {
+ return Ref::getList('state,mail');
+ }
+ public function getTypeData()
+ {
+ return Ref::getList('type,mail');
+ }
}
diff --git a/src/grid/MailGridView.php b/src/grid/MailGridView.php
index 8d581ef5..d4f86a1b 100644
--- a/src/grid/MailGridView.php
+++ b/src/grid/MailGridView.php
@@ -7,7 +7,15 @@
namespace hipanel\modules\hosting\grid;
+use hipanel\grid\ActionColumn;
use hipanel\grid\MainColumn;
+use hipanel\grid\RefColumn;
+use hipanel\modules\hosting\widgets\mail\State;
+use hipanel\modules\hosting\widgets\mail\Type;
+use hipanel\modules\server\grid\ServerColumn;
+use hipanel\widgets\ArraySpoiler;
+use Yii;
+use yii\helpers\StringHelper;
class MailGridView extends \hipanel\grid\BoxedGridView
{
@@ -15,8 +23,52 @@ static public function defaultColumns()
{
return [
'mail' => [
- 'class' => MainColumn::className(),
- 'filterAttribute' => 'mail_like',
+ 'class' => MainColumn::className(),
+ 'filterAttribute' => 'mail_like',
+ ],
+ 'state' => [
+ 'class' => RefColumn::className(),
+ 'format' => 'raw',
+ 'value' => function ($model) {
+ return State::widget(compact('model'));
+ },
+ 'gtype' => 'state,mail',
+ ],
+ 'server' => [
+ 'class' => ServerColumn::className()
+ ],
+// 'sshftp_ips' => [
+// 'attribute' => 'sshftp_ips',
+// 'format' => 'raw',
+// 'value' => function ($model) {
+// return ArraySpoiler::widget([
+// 'data' => $model->sshftp_ips,
+// 'visibleCount' => 3
+// ]);
+// }
+// ],
+ 'type' => [
+ 'format' => 'raw',
+ 'value' => function ($model) {
+ return Type::widget(compact('model'));
+ }
+ ],
+ 'forwards' => [
+ 'format' => 'raw',
+ 'value' => function ($model) {
+ return ArraySpoiler::widget([
+ 'delimiter' => '
',
+ 'data' => $model->forwards,
+ 'button' => [
+ 'label' => '+{count}',
+ 'popoverOptions' => ['html' => true]
+ ],
+ ]);
+ }
+ ],
+ 'actions' => [
+ 'class' => ActionColumn::className(),
+ 'template' => '{view} {delete}'
],
];
}
diff --git a/src/models/Mail.php b/src/models/Mail.php
index c246030e..7155c4c9 100644
--- a/src/models/Mail.php
+++ b/src/models/Mail.php
@@ -15,22 +15,27 @@ class Mail extends \hipanel\base\Model
use \hipanel\base\ModelTrait;
/** @inheritdoc */
- public function rules () {
+ public function rules()
+ {
return [
- [['id', 'hdomain_id', 'client_id', 'account_id', 'server_id'], 'integer'],
- [['mail', 'nick', 'hdomain', 'client', 'account', 'server', 'domain'], 'safe'],
- [['type', 'state', 'state_label'], 'safe'],
- [['forwards', 'spam_action', 'autoanswer', 'du_limit'], 'safe'],
+ [['id', 'hdomain_id', 'client_id', 'seller_id', 'account_id', 'server_id'], 'integer'],
+ [['mail', 'nick', 'hdomain', 'client', 'seller', 'account', 'server', 'domain'], 'safe'],
+ [['type', 'state', 'state_label'], 'safe'],
+ [['forwards', 'spam_action', 'autoanswer', 'du_limit'], 'safe'],
+ [['is_alias'], 'boolean'],
];
}
/** @inheritdoc */
- public function attributeLabels () {
+ public function attributeLabels()
+ {
return $this->mergeAttributeLabels([
- 'hdomain' => Yii::t('app', 'Domain Name'),
- 'domain' => Yii::t('app', 'Domain Name'),
- 'forwards' => Yii::t('app', 'Forwarding'),
- 'du_limit' => Yii::t('app', 'Disk usage limit'),
+ 'hdomain' => Yii::t('app', 'Domain Name'),
+ 'domain' => Yii::t('app', 'Domain Name'),
+ 'forwards' => Yii::t('app', 'Forwarding'),
+ 'du_limit' => Yii::t('app', 'Disk usage limit'),
+ 'mail' => Yii::t('app', 'E-mail'),
+ 'mail_like' => Yii::t('app', 'E-mail'),
]);
}
}
diff --git a/src/models/MailSearch.php b/src/models/MailSearch.php
index 6913fdad..2a787449 100644
--- a/src/models/MailSearch.php
+++ b/src/models/MailSearch.php
@@ -7,6 +7,7 @@
namespace hipanel\modules\hosting\models;
-class MailSearch extends Mail{
+class MailSearch extends Mail
+{
use \hipanel\base\SearchModelTrait;
}
diff --git a/src/views/mail/_search.php b/src/views/mail/_search.php
new file mode 100644
index 00000000..35972df9
--- /dev/null
+++ b/src/views/mail/_search.php
@@ -0,0 +1,44 @@
+
+
+