|
|
@ -1,5 +1,6 @@
|
|
|
|
<?php
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
use Carbon\Carbon;
|
|
|
|
use Engelsystem\Models\Question;
|
|
|
|
use Engelsystem\Models\Question;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -50,6 +51,7 @@ function admin_questions()
|
|
|
|
$unanswered_questions_table[] = [
|
|
|
|
$unanswered_questions_table[] = [
|
|
|
|
'from' => User_Nick_render($user_source) . User_Pronoun_render($user_source),
|
|
|
|
'from' => User_Nick_render($user_source) . User_Pronoun_render($user_source),
|
|
|
|
'question' => nl2br(htmlspecialchars($question->text)),
|
|
|
|
'question' => nl2br(htmlspecialchars($question->text)),
|
|
|
|
|
|
|
|
'created_at' => $question->created_at,
|
|
|
|
'answer' => form([
|
|
|
|
'answer' => form([
|
|
|
|
form_textarea('answer', '', ''),
|
|
|
|
form_textarea('answer', '', ''),
|
|
|
|
form_submit('submit', __('Send'))
|
|
|
|
form_submit('submit', __('Send'))
|
|
|
@ -70,8 +72,10 @@ function admin_questions()
|
|
|
|
$answered_questions_table[] = [
|
|
|
|
$answered_questions_table[] = [
|
|
|
|
'from' => User_Nick_render($user_source),
|
|
|
|
'from' => User_Nick_render($user_source),
|
|
|
|
'question' => nl2br(htmlspecialchars($question->text)),
|
|
|
|
'question' => nl2br(htmlspecialchars($question->text)),
|
|
|
|
|
|
|
|
'created_at' => $question->created_at,
|
|
|
|
'answered_by' => User_Nick_render($answer_user_source),
|
|
|
|
'answered_by' => User_Nick_render($answer_user_source),
|
|
|
|
'answer' => nl2br(htmlspecialchars($question->answer)),
|
|
|
|
'answer' => nl2br(htmlspecialchars($question->answer)),
|
|
|
|
|
|
|
|
'answered_at' => $question->answered_at,
|
|
|
|
'actions' => form([
|
|
|
|
'actions' => form([
|
|
|
|
form_submit('submit', __('delete'), 'btn-xs')
|
|
|
|
form_submit('submit', __('delete'), 'btn-xs')
|
|
|
|
], page_link_to('admin_questions', ['action' => 'delete', 'id' => $question->id]))
|
|
|
|
], page_link_to('admin_questions', ['action' => 'delete', 'id' => $question->id]))
|
|
|
@ -83,6 +87,7 @@ function admin_questions()
|
|
|
|
table([
|
|
|
|
table([
|
|
|
|
'from' => __('From'),
|
|
|
|
'from' => __('From'),
|
|
|
|
'question' => __('Question'),
|
|
|
|
'question' => __('Question'),
|
|
|
|
|
|
|
|
'created_at' => __('Asked at'),
|
|
|
|
'answer' => __('Answer'),
|
|
|
|
'answer' => __('Answer'),
|
|
|
|
'actions' => ''
|
|
|
|
'actions' => ''
|
|
|
|
], $unanswered_questions_table),
|
|
|
|
], $unanswered_questions_table),
|
|
|
@ -90,8 +95,10 @@ function admin_questions()
|
|
|
|
table([
|
|
|
|
table([
|
|
|
|
'from' => __('From'),
|
|
|
|
'from' => __('From'),
|
|
|
|
'question' => __('Question'),
|
|
|
|
'question' => __('Question'),
|
|
|
|
|
|
|
|
'created_at' => __('Asked at'),
|
|
|
|
'answered_by' => __('Answered by'),
|
|
|
|
'answered_by' => __('Answered by'),
|
|
|
|
'answer' => __('Answer'),
|
|
|
|
'answer' => __('Answer'),
|
|
|
|
|
|
|
|
'answered_at' => __('Answered at'),
|
|
|
|
'actions' => ''
|
|
|
|
'actions' => ''
|
|
|
|
], $answered_questions_table)
|
|
|
|
], $answered_questions_table)
|
|
|
|
]);
|
|
|
|
]);
|
|
|
@ -115,10 +122,12 @@ function admin_questions()
|
|
|
|
if (!empty($answer)) {
|
|
|
|
if (!empty($answer)) {
|
|
|
|
$question->answerer_id = $user->id;
|
|
|
|
$question->answerer_id = $user->id;
|
|
|
|
$question->answer = $answer;
|
|
|
|
$question->answer = $answer;
|
|
|
|
|
|
|
|
$question->answered_at = Carbon::now();
|
|
|
|
$question->save();
|
|
|
|
$question->save();
|
|
|
|
engelsystem_log(
|
|
|
|
engelsystem_log(
|
|
|
|
'Question '
|
|
|
|
'Question '
|
|
|
|
. $question['Question']
|
|
|
|
. $question->text
|
|
|
|
|
|
|
|
. ' (' . $question->id . ')'
|
|
|
|
. ' answered: '
|
|
|
|
. ' answered: '
|
|
|
|
. $answer
|
|
|
|
. $answer
|
|
|
|
);
|
|
|
|
);
|
|
|
@ -144,7 +153,7 @@ function admin_questions()
|
|
|
|
$question = Question::find($question_id);
|
|
|
|
$question = Question::find($question_id);
|
|
|
|
if (!empty($question)) {
|
|
|
|
if (!empty($question)) {
|
|
|
|
$question->delete();
|
|
|
|
$question->delete();
|
|
|
|
engelsystem_log('Question deleted: ' . $question['Question']);
|
|
|
|
engelsystem_log('Question deleted: ' . $question->text);
|
|
|
|
throw_redirect(page_link_to('admin_questions'));
|
|
|
|
throw_redirect(page_link_to('admin_questions'));
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
return error('No question found.', true);
|
|
|
|
return error('No question found.', true);
|
|
|
|