@@ -18,10 +18,12 @@ class Stats {
18
18
19
19
private Template $ temp ;
20
20
private Login $ login ;
21
+ private Share $ share ;
21
22
22
23
public function __construct ( Template $ temp , Login $ login ) {
23
24
$ this ->login = $ login ;
24
25
$ this ->temp = $ temp ;
26
+ $ this ->share = new Share ($ this ->login );
25
27
26
28
$ this ->setUpHtml ();
27
29
@@ -30,22 +32,32 @@ public function __construct( Template $temp, Login $login ) {
30
32
if ( !empty ($ cmd ) ){
31
33
$ data = new TTTStats ($ cmd , API ::getStorageDir ($ this ->login ->getGroup ()));
32
34
$ allData = $ data ->getAllResults ();
35
+
36
+ // share
33
37
if ( isset ($ _POST ['shares ' ]) && is_array ($ _POST ['shares ' ]) ){
38
+ $ withme = $ this ->share ->getSharedWithMe ();
34
39
$ shares = array ();
35
40
foreach ($ _POST ['shares ' ] as $ sh ){
36
41
if (is_string ($ sh )){
37
42
$ sh = explode (':: ' , $ sh );
38
43
$ gr = preg_replace ('/[^A-Za-z0-9]/ ' , '' , $ sh [0 ]);
39
44
if (InputParser::checkCategoryInput ($ sh [1 ]) && !empty ($ gr ) ){
40
- if (!isset ($ shares [$ gr ])){
41
- $ shares [$ gr ] = array ();
45
+ if ( in_array ( array (
46
+ 'category ' => $ sh [1 ],
47
+ 'group ' => $ gr
48
+ ) , $ withme )
49
+ ){
50
+ if (!isset ($ shares [$ gr ])){
51
+ $ shares [$ gr ] = array ();
52
+ }
53
+ $ shares [$ gr ][] = $ sh [1 ];
42
54
}
43
- $ shares [$ gr ][] = $ sh [1 ];
44
- }
55
+ }
45
56
}
46
57
}
47
58
$ this ->addShares ($ allData , $ cmd , $ shares );
48
59
}
60
+
49
61
$ this ->displayContent ($ allData );
50
62
}
51
63
}
@@ -85,7 +97,9 @@ private function addShares( array &$allData, array $cmd, array $shares) : void {
85
97
}
86
98
});
87
99
foreach (['table ' ,'plain ' ,'combi ' ,'today ' ] as $ key ){
88
- $ allData [$ key ] = array_merge ($ allData [$ key ], $ data [$ key ]);
100
+ if (isset ($ allData [$ key ]) && isset ($ data [$ key ]) ){
101
+ $ allData [$ key ] = array_merge ($ allData [$ key ], $ data [$ key ]);
102
+ }
89
103
}
90
104
}
91
105
}
@@ -205,8 +219,7 @@ private function setUpHtml(){
205
219
$ this ->temp ->setMultipleContent ('Devices ' , $ ds );
206
220
}
207
221
208
- $ share = new Share ($ this ->login );
209
- $ withme = $ share ->getSharedWithMe ();
222
+ $ withme = $ this ->share ->getSharedWithMe ();
210
223
if (!empty ($ withme )){
211
224
$ this ->temp ->setContent ('SHARESDIABLE ' , '' );
212
225
$ d = array ();
0 commit comments