1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Seb\User; |
4
|
|
|
|
5
|
|
|
use Anax\Commons\ContainerInjectableInterface; |
6
|
|
|
use Anax\Commons\ContainerInjectableTrait; |
7
|
|
|
use Seb\Questions\Questions; |
8
|
|
|
use Seb\Answers\Answers; |
9
|
|
|
use Seb\QuestionComments\QuestionComments; |
10
|
|
|
use Seb\AnswerComments\AnswerComments; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* A sample controller to show how a controller class can be implemented. |
14
|
|
|
*/ |
15
|
|
|
class UsersController implements ContainerInjectableInterface |
16
|
|
|
{ |
17
|
|
|
use ContainerInjectableTrait; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Show all items. |
21
|
|
|
* |
22
|
|
|
* @return object as a response object |
23
|
|
|
*/ |
24
|
1 |
|
public function indexActionGet() : object |
25
|
|
|
{ |
26
|
1 |
|
$page = $this->di->get("page"); |
27
|
1 |
|
$users = new User(); |
28
|
1 |
|
$users->setDb($this->di->get("dbqb")); |
29
|
|
|
|
30
|
1 |
|
$session = $this->di->get("session"); |
31
|
1 |
|
if (!$session->get("acronym")) { |
32
|
1 |
|
$page->add("user/please"); |
33
|
1 |
|
return $page->render(); |
34
|
|
|
} |
35
|
|
|
|
36
|
1 |
|
$page->add("user/users", [ |
37
|
1 |
|
"userInfo" => $users->findAll() |
38
|
|
|
]); |
39
|
|
|
|
40
|
1 |
|
return $page->render([ |
41
|
1 |
|
"title" => "Users", |
42
|
|
|
]); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Show all items. |
47
|
|
|
* |
48
|
|
|
* @return object as a response object |
49
|
|
|
*/ |
50
|
1 |
|
public function historyAction(string $user) : object |
51
|
|
|
{ |
52
|
1 |
|
$page = $this->di->get("page"); |
53
|
1 |
|
$topic = new Questions(); |
54
|
1 |
|
$topic->setDb($this->di->get("dbqb")); |
55
|
1 |
|
$answers = new Answers(); |
56
|
1 |
|
$answers->setDb($this->di->get("dbqb")); |
57
|
1 |
|
$questioncomments = new QuestionComments(); |
58
|
1 |
|
$questioncomments->setDb($this->di->get("dbqb")); |
59
|
1 |
|
$answercomments = new AnswerComments(); |
60
|
1 |
|
$answercomments->setDb($this->di->get("dbqb")); |
61
|
|
|
|
62
|
1 |
|
$page->add("user/history", [ |
63
|
1 |
|
"topic" => $topic->findAll(), |
64
|
1 |
|
"answers" => $answers->findAll(), |
65
|
1 |
|
"questioncomments" => $questioncomments->findAll(), |
66
|
1 |
|
"answercomments" => $answercomments->findAll(), |
67
|
1 |
|
"acr" => $user |
68
|
|
|
]); |
69
|
|
|
|
70
|
1 |
|
return $page->render([ |
71
|
1 |
|
"title" => "Users", |
72
|
|
|
]); |
73
|
|
|
} |
74
|
|
|
} |
75
|
|
|
|