@@ -18,10 +18,12 @@ class Stats {
1818
1919 private Template $ temp ;
2020 private Login $ login ;
21+ private Share $ share ;
2122
2223 public function __construct ( Template $ temp , Login $ login ) {
2324 $ this ->login = $ login ;
2425 $ this ->temp = $ temp ;
26+ $ this ->share = new Share ($ this ->login );
2527
2628 $ this ->setUpHtml ();
2729
@@ -30,22 +32,32 @@ public function __construct( Template $temp, Login $login ) {
3032 if ( !empty ($ cmd ) ){
3133 $ data = new TTTStats ($ cmd , API ::getStorageDir ($ this ->login ->getGroup ()));
3234 $ allData = $ data ->getAllResults ();
35+
36+ // share
3337 if ( isset ($ _POST ['shares ' ]) && is_array ($ _POST ['shares ' ]) ){
38+ $ withme = $ this ->share ->getSharedWithMe ();
3439 $ shares = array ();
3540 foreach ($ _POST ['shares ' ] as $ sh ){
3641 if (is_string ($ sh )){
3742 $ sh = explode (':: ' , $ sh );
3843 $ gr = preg_replace ('/[^A-Za-z0-9]/ ' , '' , $ sh [0 ]);
3944 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 ];
4254 }
43- $ shares [$ gr ][] = $ sh [1 ];
44- }
55+ }
4556 }
4657 }
4758 $ this ->addShares ($ allData , $ cmd , $ shares );
4859 }
60+
4961 $ this ->displayContent ($ allData );
5062 }
5163 }
@@ -85,7 +97,9 @@ private function addShares( array &$allData, array $cmd, array $shares) : void {
8597 }
8698 });
8799 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+ }
89103 }
90104 }
91105 }
@@ -205,8 +219,7 @@ private function setUpHtml(){
205219 $ this ->temp ->setMultipleContent ('Devices ' , $ ds );
206220 }
207221
208- $ share = new Share ($ this ->login );
209- $ withme = $ share ->getSharedWithMe ();
222+ $ withme = $ this ->share ->getSharedWithMe ();
210223 if (!empty ($ withme )){
211224 $ this ->temp ->setContent ('SHARESDIABLE ' , '' );
212225 $ d = array ();
0 commit comments