@@ -111,6 +111,10 @@ public function workIntervals() {
111
111
}
112
112
113
113
114
+ public function isAdminUser (){
115
+ return \OC_User::isAdminUser (\OC_User::getUser ());
116
+ }
117
+
114
118
/**
115
119
*
116
120
* @NoAdminRequired
@@ -366,7 +370,7 @@ public function addProject($name) {
366
370
$ p ->setClientId ($ clientId );
367
371
$ this ->projectMapper ->insert ($ p );
368
372
} else {
369
- if ($ p ->locked && $ this ->userId != ' admin ' ){
373
+ if ($ p ->locked && ! $ this ->isAdminUser () ){
370
374
return new JSONResponse (["Error " => "This project is locked " ]);
371
375
}
372
376
}
@@ -474,7 +478,7 @@ public function getProjects(){
474
478
* @NoCSRFRequired
475
479
*/
476
480
public function getProjectsTable (){
477
- if ($ this ->userId == ' admin ' ){
481
+ if ($ this ->isAdminUser () ){
478
482
$ projects = $ this ->projectMapper ->findAllAdmin ();
479
483
} else {
480
484
$ projects = $ this ->projectMapper ->findAll ($ this ->userId );
@@ -519,8 +523,7 @@ public function addTag($name) {
519
523
$ c ->setUserUid ($ this ->userId );
520
524
$ c ->setCreatedAt (time ());
521
525
$ this ->tagMapper ->insert ($ c );
522
- }
523
- if ($ c != null ){
526
+ } else if ($ c != null ){
524
527
return new JSONResponse (["Error " => "This tag name already exists " ]);
525
528
}
526
529
@@ -612,7 +615,8 @@ public function getReport(){
612
615
$ name = $ this ->userId ;
613
616
}
614
617
615
- if ($ this ->userId != 'admin ' ){
618
+
619
+ if ($ this ->isAdminUser ()){
616
620
$ allowedClients = $ this ->clientMapper ->findAll ($ this ->userId );
617
621
$ allowedClientsId = array_map (function ($ client ){ return $ client ->id ;}, $ allowedClients );
618
622
if (empty ($ filterClientId )){
0 commit comments