EditUsers   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 17
dl 0
loc 43
rs 10
c 0
b 0
f 0
wmc 7

3 Methods

Rating   Name   Duplication   Size   Complexity  
A doActions() 0 2 1
A __invoke() 0 14 3
A addNotices() 0 9 3
1
<?php
2
/**
3
 * Edit users page controller class file
4
 *
5
 * @package    EBloodBank
6
 * @subpackage Controllers
7
 * @since      1.0
8
 */
9
namespace EBloodBank\Controllers;
10
11
use EBloodBank\Notices;
12
13
/**
14
 * Edit users page controller class
15
 *
16
 * @since 1.0
17
 */
18
class EditUsers extends ViewUsers
19
{
20
    /**
21
     * @return void
22
     * @since 1.0
23
     */
24
    public function __invoke()
25
    {
26
        if ($this->hasAuthenticatedUser() && $this->getAcl()->isUserAllowed($this->getAuthenticatedUser(), 'User', 'edit')) {
27
            $this->doActions();
28
            $this->addNotices();
29
            $view = $this->viewFactory->forgeView('edit-users', [
30
                'users'              => $this->getQueriedUsers(),
31
                'pagination.total'   => $this->getPagesTotal(),
32
                'pagination.current' => $this->getCurrentPage(),
33
            ]);
34
        } else {
35
            $view = $this->viewFactory->forgeView('error-403');
36
        }
37
        $view();
38
    }
39
40
    /**
41
     * @return void
42
     * @since 1.0
43
     */
44
    protected function doActions()
45
    {
46
    }
47
48
    /**
49
     * @return void
50
     * @since 1.0
51
     */
52
    protected function addNotices()
53
    {
54
        if (filter_has_var(INPUT_GET, 'flag-activated')) {
55
            $activated = (int) filter_input(INPUT_GET, 'flag-activated');
56
            Notices::addNotice('activated', sprintf(n__('%d user activated.', '%d users activated.', $activated), $activated), 'success');
57
        }
58
        if (filter_has_var(INPUT_GET, 'flag-deleted')) {
59
            $deleted = (int) filter_input(INPUT_GET, 'flag-deleted');
60
            Notices::addNotice('deleted', sprintf(n__('%d user permanently deleted.', '%d users permanently deleted.', $deleted), $deleted), 'success');
61
        }
62
    }
63
}
64