|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Hosting Plugin for HiPanel |
|
4
|
|
|
* |
|
5
|
|
|
* @link https://github.com/hiqdev/hipanel-module-hosting |
|
6
|
|
|
* @package hipanel-module-hosting |
|
7
|
|
|
* @license BSD-3-Clause |
|
8
|
|
|
* @copyright Copyright (c) 2015-2017, HiQDev (http://hiqdev.com/) |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace hipanel\modules\hosting\controllers; |
|
12
|
|
|
|
|
13
|
|
|
use hipanel\actions\IndexAction; |
|
14
|
|
|
use hipanel\actions\RedirectAction; |
|
15
|
|
|
use hipanel\actions\SmartDeleteAction; |
|
16
|
|
|
use hipanel\actions\ViewAction; |
|
17
|
|
|
use hipanel\base\CrudController; |
|
18
|
|
|
use hipanel\filters\EasyAccessControl; |
|
19
|
|
|
use Yii; |
|
20
|
|
|
|
|
21
|
|
|
class BackupController extends CrudController |
|
22
|
|
|
{ |
|
23
|
|
|
public function behaviors() |
|
24
|
|
|
{ |
|
25
|
|
|
return array_merge(parent::behaviors(), [ |
|
26
|
|
|
[ |
|
27
|
|
|
'class' => EasyAccessControl::class, |
|
28
|
|
|
'actions' => [ |
|
29
|
|
|
'delete' => 'account.delete', |
|
30
|
|
|
'*' => 'account.read', |
|
31
|
|
|
], |
|
32
|
|
|
], |
|
33
|
|
|
]); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
public function actions() |
|
37
|
|
|
{ |
|
38
|
|
|
return array_merge(parent::actions(), [ |
|
39
|
|
|
'index' => [ |
|
40
|
|
|
'class' => IndexAction::class, |
|
41
|
|
|
'data' => function ($action) { |
|
42
|
|
|
return [ |
|
43
|
|
|
'objectOptions' => $action->controller->getObjectOptions(), |
|
44
|
|
|
]; |
|
45
|
|
|
}, |
|
46
|
|
|
'filterStorageMap' => [ |
|
47
|
|
|
'name_like' => 'hosting.backup.name_like', |
|
48
|
|
|
'type' => 'hosting.backup.type', |
|
49
|
|
|
'state' => 'hosting.backup.state', |
|
50
|
|
|
'server' => 'server.server.name', |
|
51
|
|
|
'account' => 'hosting.account.login', |
|
52
|
|
|
'client_id' => 'client.client.id', |
|
53
|
|
|
], |
|
54
|
|
|
], |
|
55
|
|
|
'view' => [ |
|
56
|
|
|
'class' => ViewAction::class, |
|
57
|
|
|
], |
|
58
|
|
|
'delete' => [ |
|
59
|
|
|
'class' => SmartDeleteAction::class, |
|
60
|
|
|
'success' => Yii::t('hipanel:hosting', 'Backup deleting task has been added to queue'), |
|
61
|
|
|
'error' => Yii::t('hipanel:hosting', 'An error occurred when trying to delete backup'), |
|
62
|
|
|
'POST html | POST pjax' => [ |
|
63
|
|
|
'save' => true, |
|
64
|
|
|
'success' => [ |
|
65
|
|
|
'class' => RedirectAction::class, |
|
66
|
|
|
], |
|
67
|
|
|
], |
|
68
|
|
|
], |
|
69
|
|
|
]); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
public function getObjectOptions() |
|
73
|
|
|
{ |
|
74
|
|
|
return [ |
|
75
|
|
|
'hdomain' => Yii::t('hipanel:hosting', 'Domain'), |
|
76
|
|
|
'db' => Yii::t('hipanel:hosting', 'Data Bases'), |
|
77
|
|
|
]; |
|
78
|
|
|
} |
|
79
|
|
|
} |
|
80
|
|
|
|