abf1649b
andryeyev
Чистая установка ...
|
1
2
3
4
5
6
7
8
|
<?php
namespace backend\controllers;
use Yii;
use yii\filters\AccessControl;
use yii\web\Controller;
use common\models\LoginForm;
use yii\filters\VerbFilter;
|
b507d689
andryeyev
Итерация 1 (Терми...
|
9
10
|
use backend\models\Profile;
use common\models\User;
|
b15a9aec
Yarik
Добавил языки, ад...
|
11
12
13
14
|
use frontend\models\Option;
use yii\data\ActiveDataProvider;
use yii\validators\BooleanValidator;
use yii\validators\StringValidator;
|
abf1649b
andryeyev
Чистая установка ...
|
15
16
17
18
19
20
21
22
23
24
25
26
27
|
/**
* Site controller
*/
class SiteController extends Controller
{
/**
* @inheritdoc
*/
public function behaviors()
{
return [
'access' => [
'class' => AccessControl::className(),
|
b15a9aec
Yarik
Добавил языки, ад...
|
28
|
'except' => ['login', 'error'],
|
abf1649b
andryeyev
Чистая установка ...
|
29
30
|
'rules' => [
[
|
abf1649b
andryeyev
Чистая установка ...
|
31
|
'allow' => true,
|
b15a9aec
Yarik
Добавил языки, ад...
|
32
|
'roles' => ['@']
|
abf1649b
andryeyev
Чистая установка ...
|
33
|
],
|
abf1649b
andryeyev
Чистая установка ...
|
34
35
36
37
38
39
|
],
],
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'logout' => ['post'],
|
b15a9aec
Yarik
Добавил языки, ад...
|
40
|
'delete-req' => ['post']
|
abf1649b
andryeyev
Чистая установка ...
|
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
],
],
];
}
/**
* @inheritdoc
*/
public function actions()
{
return [
'error' => [
'class' => 'yii\web\ErrorAction',
],
];
}
public function actionIndex()
{
|
b15a9aec
Yarik
Добавил языки, ад...
|
60
|
return $this->render('index');
|
abf1649b
andryeyev
Чистая установка ...
|
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
}
public function actionLogin()
{
if (!\Yii::$app->user->isGuest) {
return $this->goHome();
}
$model = new LoginForm();
if ($model->load(Yii::$app->request->post()) && $model->login()) {
return $this->goBack();
} else {
return $this->render('login', [
'model' => $model,
]);
}
}
public function actionLogout()
{
Yii::$app->user->logout();
return $this->goHome();
}
|
b507d689
andryeyev
Итерация 1 (Терми...
|
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
/**
* Displays Profile page.
*
* @return mixed
*/
public function actionProfile()
{
$model = new Profile();
$model->saveProfile();
return $this->render('profile', [
'model' => $model,
]);
}
|
b15a9aec
Yarik
Добавил языки, ад...
|
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
public function actionRequests($id = 0) {
if($id != 0) {
Option::markOld($id);
$this->redirect(['site/requests']);
}
$query = Option::find()->where(['model' => 'Feedback', 'model_id' => 1, 'parent_id' => null]);
$provider = new ActiveDataProvider([
'query' => $query,
'pagination' => [
'pageSize' => 2,
],
'sort' => [
'defaultOrder' => [
'created_at' => SORT_DESC
]
]
]);
$data = $provider->getModels();
return $this->render('requests', [
'dataProvider' => $provider
]);
}
public function actionDeleteReq($id) {
$model = Option::findOne($id);
if(!is_null($model) && $model->delete()) {
return $this->redirect(['site/requests']);
} else{
Yii::$app->session->setFlash('post_error', $model->getFirstErrors());
return $this->redirect('[site/requests]');
}
}
|
abf1649b
andryeyev
Чистая установка ...
|
136
|
}
|