@@ -111,10 +111,14 @@ public function workIntervals() {
111
111
}
112
112
113
113
114
- public function isAdminUser (){
114
+ public function isThisAdminUser (){
115
115
return \OC_User::isAdminUser (\OC_User::getUser ());
116
116
}
117
117
118
+ public function isUserAdmin ($ user ){
119
+ return \OC_User::isAdminUser ($ user );
120
+ }
121
+
118
122
/**
119
123
*
120
124
* @NoAdminRequired
@@ -370,7 +374,7 @@ public function addProject($name) {
370
374
$ p ->setClientId ($ clientId );
371
375
$ this ->projectMapper ->insert ($ p );
372
376
} else {
373
- if ($ p ->locked && !$ this ->isAdminUser ()){
377
+ if ($ p ->locked && !$ this ->isThisAdminUser ()){
374
378
return new JSONResponse (["Error " => "This project is locked " ]);
375
379
}
376
380
}
@@ -478,7 +482,7 @@ public function getProjects(){
478
482
* @NoCSRFRequired
479
483
*/
480
484
public function getProjectsTable (){
481
- if ($ this ->isAdminUser ()){
485
+ if ($ this ->isThisAdminUser ()){
482
486
$ projects = $ this ->projectMapper ->findAllAdmin ();
483
487
} else {
484
488
$ projects = $ this ->projectMapper ->findAll ($ this ->userId );
@@ -616,18 +620,20 @@ public function getReport(){
616
620
}
617
621
618
622
619
- if ($ this ->isAdminUser ()){
623
+ if (! $ this ->isThisAdminUser ()){
620
624
$ allowedClients = $ this ->clientMapper ->findAll ($ this ->userId );
621
625
$ allowedClientsId = array_map (function ($ client ){ return $ client ->id ;}, $ allowedClients );
622
626
if (empty ($ filterClientId )){
623
627
$ filterClientId = $ allowedClientsId ;
628
+ $ filterClientId [] = null ; // allow null clientid
624
629
} else {
625
630
$ filterClientId = array_intersect ($ filterClientId , $ allowedClientsId );
626
631
}
627
632
$ allowedProjects = $ this ->projectMapper ->findAll ($ this ->userId );
628
633
$ allowedProjectsId = array_map (function ($ project ){ return $ project ->id ;}, $ allowedProjects );
629
634
if (empty ($ filterProjectId )){
630
635
$ filterProjectId = $ allowedProjectsId ;
636
+ $ filterProjectId [] = null ; // allow null projectId
631
637
} else {
632
638
$ filterProjectId = array_intersect ($ filterProjectId , $ allowedProjectsId );
633
639
}
@@ -637,7 +643,7 @@ public function getReport(){
637
643
$ filterTagId = [];
638
644
$ groupOn1 = $ this ->request ->group1 ;
639
645
$ groupOn2 = $ this ->request ->group2 ;
640
- $ items = $ this ->reportItemMapper ->report ($ name , $ from , $ to , $ filterProjectId , $ filterClientId , $ filterTagId , $ timegroup , $ groupOn1 , $ groupOn2 , 0 , 1000 );
646
+ $ items = $ this ->reportItemMapper ->report ($ name , $ from , $ to , $ filterProjectId , $ filterClientId , $ filterTagId , $ timegroup , $ groupOn1 , $ groupOn2 , $ this -> isThisAdminUser (), 0 , 1000 );
641
647
return new JSONResponse (["items " => json_decode (json_encode ($ items ), true ), 'total ' => count ($ items )]);
642
648
}
643
649
0 commit comments