Passed
Push — Auth ( a6c03c...4ce6d9 )
by Stone
02:10
created

Home::updateUser()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace App\Controllers\Admin;
4
5
6
7
use App\Models\UserModel;
8
use Core\Container;
9
use Core\Traits\StringFunctions;
10
11
class Home extends \Core\AdminController
12
{
13
    use StringFunctions;
0 ignored issues
show
Bug introduced by
The trait Core\Traits\StringFunctions requires the property $childNodes which is not provided by App\Controllers\Admin\Home.
Loading history...
14
    protected $siteConfig;
15
16
    private $userModel;
17
18
    public function __construct(Container $container)
19
    {
20
        $this->loadModules[] = 'SiteConfig';
21
        parent::__construct($container);
22
        $this->userModel = new UserModel($this->container);
23
24
        $this->data['configs'] = $this->siteConfig->getSiteConfig();
25
    }
26
27
    /**
28
     * The front page of the admin section. We display the user info
29
     * @throws \ReflectionException
30
     * @throws \Twig_Error_Loader
31
     * @throws \Twig_Error_Runtime
32
     * @throws \Twig_Error_Syntax
33
     */
34
    public function index()
35
    {
36
        $this->onlyUser();
37
38
        $userId = $this->session->get("user_id");
39
        $this->data["user"] = $this->userModel->getUserDetailsById($userId);
40
41
        $this->renderView('Admin/Home');
42
43
    }
44
45
    /**
46
     * Administrate a user as an admin
47
     * @param int $userId
48
     * @throws \ReflectionException
49
     * @throws \Twig_Error_Loader
50
     * @throws \Twig_Error_Runtime
51
     * @throws \Twig_Error_Syntax
52
     */
53
    public function viewUser(int $userId)
54
    {
55
        $this->onlyAdmin();
56
        if(!$this->isInt($userId))
57
        {
58
            throw new \Exception("Error in passed ID");
59
        }
60
61
        $this->data["user"] = $this->userModel->getUserDetailsById($userId);
62
        $this->renderView('Admin/Home');
63
    }
64
65
    /**
66
     * Update the user info via post
67
     */
68
    public function updateUser()
69
    {
70
        $this->onlyPost();
71
72
    }
73
}