|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace SimpleSAML\Module\consentSimpleAdmin\Controller; |
|
6
|
|
|
|
|
7
|
|
|
use SimpleSAML\Configuration; |
|
8
|
|
|
use SimpleSAML\Module\consent\Store; |
|
9
|
|
|
use SimpleSAML\Session; |
|
10
|
|
|
use SimpleSAML\Utils; |
|
11
|
|
|
use SimpleSAML\XHTML\Template; |
|
12
|
|
|
use Symfony\Component\HttpFoundation\Request; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* Controller class for the consentsimpleadmin module. |
|
16
|
|
|
* |
|
17
|
|
|
* This class serves the different views available in the module. |
|
18
|
|
|
* |
|
19
|
|
|
* @package simplesamlphp/simplesamlphp-module-consentsimpleadmin |
|
20
|
|
|
*/ |
|
21
|
|
|
class Stats |
|
22
|
|
|
{ |
|
23
|
|
|
/** |
|
24
|
|
|
* Controller constructor. |
|
25
|
|
|
* |
|
26
|
|
|
* It initializes the global configuration and session for the controllers implemented here. |
|
27
|
|
|
* |
|
28
|
|
|
* @param \SimpleSAML\Configuration $config The configuration to use by the controllers. |
|
29
|
|
|
* @param \SimpleSAML\Session $session The session to use by the controllers. |
|
30
|
|
|
*/ |
|
31
|
|
|
public function __construct( |
|
32
|
|
|
protected Configuration $config, |
|
33
|
|
|
protected Session $session, |
|
34
|
|
|
) { |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
|
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @param \Symfony\Component\HttpFoundation\Request $request The current request. |
|
41
|
|
|
* |
|
42
|
|
|
* @return \SimpleSAML\XHTML\Template |
|
43
|
|
|
*/ |
|
44
|
|
|
public function stats(Request $request): Template |
|
|
|
|
|
|
45
|
|
|
{ |
|
46
|
|
|
$authUtils = new Utils\Auth(); |
|
47
|
|
|
$authUtils->requireAdmin(); |
|
48
|
|
|
|
|
49
|
|
|
// Get config object |
|
50
|
|
|
$consentconfig = $this->config::getConfig('module_consentSimpleAdmin.php'); |
|
51
|
|
|
|
|
52
|
|
|
// Parse consent config |
|
53
|
|
|
$consent_storage = Store::parseStoreConfig($consentconfig->getValue('store')); |
|
54
|
|
|
|
|
55
|
|
|
// Get all consents for user |
|
56
|
|
|
$stats = $consent_storage->getStatistics(); |
|
57
|
|
|
|
|
58
|
|
|
// Init template |
|
59
|
|
|
$t = new Template($this->config, 'consentSimpleAdmin:consentstats.twig'); |
|
60
|
|
|
$t->data['stats'] = $stats; |
|
61
|
|
|
|
|
62
|
|
|
return $t; |
|
63
|
|
|
} |
|
64
|
|
|
} |
|
65
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.