@@ -111,10 +111,14 @@ public function workIntervals() {
111111 }
112112
113113
114- public function isAdminUser (){
114+ public function isThisAdminUser (){
115115 return \OC_User::isAdminUser (\OC_User::getUser ());
116116 }
117117
118+ public function isUserAdmin ($ user ){
119+ return \OC_User::isAdminUser ($ user );
120+ }
121+
118122 /**
119123 *
120124 * @NoAdminRequired
@@ -370,7 +374,7 @@ public function addProject($name) {
370374 $ p ->setClientId ($ clientId );
371375 $ this ->projectMapper ->insert ($ p );
372376 } else {
373- if ($ p ->locked && !$ this ->isAdminUser ()){
377+ if ($ p ->locked && !$ this ->isThisAdminUser ()){
374378 return new JSONResponse (["Error " => "This project is locked " ]);
375379 }
376380 }
@@ -478,7 +482,7 @@ public function getProjects(){
478482 * @NoCSRFRequired
479483 */
480484 public function getProjectsTable (){
481- if ($ this ->isAdminUser ()){
485+ if ($ this ->isThisAdminUser ()){
482486 $ projects = $ this ->projectMapper ->findAllAdmin ();
483487 } else {
484488 $ projects = $ this ->projectMapper ->findAll ($ this ->userId );
@@ -616,18 +620,20 @@ public function getReport(){
616620 }
617621
618622
619- if ($ this ->isAdminUser ()){
623+ if (! $ this ->isThisAdminUser ()){
620624 $ allowedClients = $ this ->clientMapper ->findAll ($ this ->userId );
621625 $ allowedClientsId = array_map (function ($ client ){ return $ client ->id ;}, $ allowedClients );
622626 if (empty ($ filterClientId )){
623627 $ filterClientId = $ allowedClientsId ;
628+ $ filterClientId [] = null ; // allow null clientid
624629 } else {
625630 $ filterClientId = array_intersect ($ filterClientId , $ allowedClientsId );
626631 }
627632 $ allowedProjects = $ this ->projectMapper ->findAll ($ this ->userId );
628633 $ allowedProjectsId = array_map (function ($ project ){ return $ project ->id ;}, $ allowedProjects );
629634 if (empty ($ filterProjectId )){
630635 $ filterProjectId = $ allowedProjectsId ;
636+ $ filterProjectId [] = null ; // allow null projectId
631637 } else {
632638 $ filterProjectId = array_intersect ($ filterProjectId , $ allowedProjectsId );
633639 }
@@ -637,7 +643,7 @@ public function getReport(){
637643 $ filterTagId = [];
638644 $ groupOn1 = $ this ->request ->group1 ;
639645 $ 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 );
641647 return new JSONResponse (["items " => json_decode (json_encode ($ items ), true ), 'total ' => count ($ items )]);
642648 }
643649
0 commit comments