Skip to content

Commit

Permalink
DomainController - actions definition updated to fit SmartActions new…
Browse files Browse the repository at this point in the history
… API
  • Loading branch information
SilverFire committed Dec 2, 2015
1 parent 94c2f4c commit c5efb67
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 12 deletions.
37 changes: 27 additions & 10 deletions src/controllers/DomainController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/
namespace hipanel\modules\domain\controllers;

use hipanel\actions\Action;
use hipanel\helpers\ArrayHelper;
use hipanel\models\Ref;
use hipanel\modules\client\models\Contact;
Expand Down Expand Up @@ -166,7 +167,9 @@ public function actions()
],
'OLD-set-ns' => [
'class' => 'hipanel\actions\SwitchAction',
'beforeSave' => function ($action) {
'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) {
Expand All @@ -184,14 +187,14 @@ public function actions()
'success' => [
'class' => 'hipanel\actions\RenderJsonAction',
'return' => function ($action) {
/* @var \hipanel\actions\Action $action */
/* @var Action $action */
return $action->collection->models;
},
],
'error' => [
'class' => 'hipanel\actions\RenderJsonAction',
'return' => function ($action) {
/* @var \hipanel\actions\Action $action */
/* @var Action $action */
return $action->collection->getFirstError();
},
],
Expand All @@ -202,7 +205,9 @@ public function actions()
'class' => 'hipanel\actions\SmartPerformAction',
'scenario' => 'set-autorenewal',
'success' => Yii::t('app', 'Premium autorenewal has been changed'),
'beforeSave' => function ($action) {
'on beforeSave' => function (Event $event) {
/** @var Action $action */
$action = $event->sender;
foreach ($action->collection->models as $model) {
$model->autorenewal = 1;
}
Expand All @@ -217,7 +222,9 @@ public function actions()
'class' => 'hipanel\actions\SmartPerformAction',
'success' => Yii::t('app', 'Autorenewal has been enabled'),
'scenario' => 'set-autorenewal',
'beforeSave' => function ($action) {
'on beforeSave' => function (Event $event) {
/** @var Action $action */
$action = $event->sender;
foreach ($action->collection->models as $model) {
$model->autorenewal = 1;
}
Expand All @@ -227,7 +234,9 @@ public function actions()
'class' => 'hipanel\actions\SmartPerformAction',
'success' => Yii::t('app', 'Autorenewal has been disabled'),
'scenario' => 'set-autorenewal',
'beforeSave' => function ($action) {
'on beforeSave' => function (Event $event) {
/** @var Action $action */
$action = $event->sender;
foreach ($action->collection->models as $model) {
$model->autorenewal = 0;
}
Expand All @@ -242,7 +251,9 @@ public function actions()
'class' => 'hipanel\actions\SmartPerformAction',
'success' => Yii::t('app', 'whois protect is enabled'),
'scenario' => 'set-whois-protect',
'beforeSave' => function ($action) {
'on beforeSave' => function (Event $event) {
/** @var Action $action */
$action = $event->sender;
foreach ($action->collection->models as $model) {
$model->enable = 1;
}
Expand All @@ -252,7 +263,9 @@ public function actions()
'class' => 'hipanel\actions\SmartPerformAction',
'success' => Yii::t('app', 'whois protect is disabled'),
'scenario' => 'set-whois-protect',
'beforeSave' => function ($action) {
'on beforeSave' => function (Event $event) {
/** @var Action $action */
$action = $event->sender;
foreach ($action->collection->models as $model) {
$model->enable = 0;
}
Expand All @@ -267,7 +280,9 @@ public function actions()
'class' => 'hipanel\actions\SmartPerformAction',
'success' => Yii::t('app', 'Lock was enabled'),
'scenario' => 'set-lock',
'beforeSave' => function ($action) {
'on beforeSave' => function (Event $event) {
/** @var Action $action */
$action = $event->sender;
foreach ($action->collection->models as $model) {
$model->enable = 1;
}
Expand All @@ -277,7 +292,9 @@ public function actions()
'class' => 'hipanel\actions\SmartPerformAction',
'success' => Yii::t('app', 'Lock was disabled'),
'scenario' => 'set-lock',
'beforeSave' => function ($action) {
'on beforeSave' => function (Event $event) {
/** @var Action $action */
$action = $event->sender;
foreach ($action->collection->models as $model) {
$model->enable = 0;
}
Expand Down
5 changes: 3 additions & 2 deletions src/grid/DomainGridView.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,12 @@ public static function defaultColumns()
if ($model->is_holded) {
return '';
}

if (Yii::$app->user->can('support') && Yii::$app->user->not($model->client_id) && Yii::$app->user->not($model->seller_id)) {
return Html::a('<i class="fa fa-bomb"></i>' . Yii::t('app', 'Enable Hold'), $url);

return '';
}

return '';
},
'disable-hold' => function ($url, $model, $key) {
return ($model->is_holded && in_array($model->state, ['ok', 'expired'], true) && Yii::$app->user->can('support') && Domain::notDomainOwner($model))
Expand Down

0 comments on commit c5efb67

Please sign in to comment.