Skip to content

Commit 2c4516f

Browse files
committed
some fixes
1 parent c22cfbf commit 2c4516f

4 files changed

Lines changed: 22 additions & 20 deletions

File tree

controllers/TicketController.php

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,9 @@ public function actionView($id)
117117
$reply->id_ticket = $model->id;
118118
$reply->user_id = Yii::$app->user->id;
119119
if ($reply->load(Yii::$app->request->post()) && $reply->save()) {
120-
if (Yii::$app->user->id == $model->user_id) {
121-
$model->status = Ticket::STATUS_OPEN;
122-
$model->save();
123-
} else {
124-
$model->status = Ticket::STATUS_WAITING;
125-
$model->save();
126-
}
120+
$model->status = \Yii::$app->user->id == $model->user_id ? Ticket::STATUS_OPEN : Ticket::STATUS_WAITING;
121+
$model->save();
122+
127123
return $this->redirect([
128124
'view',
129125
'id' => $model->hash_id
@@ -164,14 +160,9 @@ public function actionCreate()
164160
$model->setScenario('create');
165161

166162
if ($model->load(Yii::$app->request->post()) && $model->save()) {
167-
return $this->redirect([
168-
'view',
169-
'id' => $model->hash_id
170-
]);
163+
return $this->redirect(['view', 'id' => $model->hash_id]);
171164
} else {
172-
return $this->render('create', [
173-
'model' => $model,
174-
]);
165+
return $this->render('create', ['model' => $model,]);
175166
}
176167
}
177168

models/Content.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ public function fields()
4343
{
4444
return [
4545
'content',
46-
'user_id',
46+
'isOwn',
47+
'Username',
4748
'created_at' => function ($model) {
4849
return date("d.m.y H:i:s", $model->created_at);//$date->format('Y-m-d H:i:s');
4950
}
@@ -91,6 +92,13 @@ public function rules()
9192
return [
9293
[['id_ticket', 'content'], 'required'],
9394
[['content'], 'string'],
95+
[
96+
'content',
97+
'filter',
98+
'filter' => function ($value) {
99+
return \yii\helpers\HtmlPurifier::process($value);
100+
}
101+
],
94102
[
95103
['user_id'],
96104
'exist',
@@ -167,13 +175,13 @@ public function getUsername()
167175
{
168176
$showUserSupport = $this->getModule()->showUsernameSupport;
169177
$username = !empty($this->user_id) ? $this->user->{$this->getModule()->userName} : $this->ticket->getNameEmail();
170-
if (!$this->isOwn() && !$showUserSupport) {
178+
if (!$this->getIsOwn() && !$showUserSupport) {
171179
$username = $this->getModule()->userNameSupport;
172180
}
173181
return $username;
174182
}
175183

176-
public function isOwn()
184+
public function getIsOwn()
177185
{
178186
return $this->user_id == $this->ticket->user_id;
179187
}

models/Ticket.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ public function rules()
184184

185185
/* custom */
186186
[['content'], 'required', 'on' => ['create']],
187+
[['user_contact', 'user_name'], 'string'],
187188
];
188189
}
189190

@@ -256,7 +257,7 @@ public function beforeSave($insert)
256257
}
257258
}
258259
}
259-
return parent::beforeSave($insert); // TODO: Change the autogenerated stub
260+
return parent::beforeSave($insert);
260261
}
261262

262263
/**
@@ -288,6 +289,8 @@ public function afterSave($insert, $changedAttributes)
288289
/**
289290
* get ticket url
290291
* @param bool $absolute
292+
* @return
293+
* @throws \yii\base\InvalidConfigException
291294
*/
292295
public function getUrl($absolute = false)
293296
{
@@ -310,7 +313,7 @@ public function close()
310313
$post = new Content();
311314
$post->id_ticket = $this->id;
312315
$post->user_id = null;
313-
$post->content = \akiraz2\support\Module::t('support',
316+
$post->content = \akiraz2\support\Module::t('support',/**/
314317
'Ticket was closed automatically due to inactivity.');
315318
if ($post->save()) {
316319
$this->status = Ticket::STATUS_CLOSED;

views/ticket/view.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
<i class="fa fa-info-circle bg-aqua"></i>
4545
<?php else: ?>
4646
<?= Html::tag('i', '',
47-
['class' => $post->isOwn() ? 'fa fa-comments bg-blue' : 'fa fa-comments bg-orange']) ?>
47+
['class' => $post->getIsOwn() ? 'fa fa-comments bg-blue' : 'fa fa-comments bg-orange']) ?>
4848
<?php endif; ?>
4949

5050
<div class="timeline-item">

0 commit comments

Comments
 (0)