@@ -111,6 +111,10 @@ public function workIntervals() {
111111 }
112112
113113
114+ public function isAdminUser (){
115+ return \OC_User::isAdminUser (\OC_User::getUser ());
116+ }
117+
114118 /**
115119 *
116120 * @NoAdminRequired
@@ -366,7 +370,7 @@ public function addProject($name) {
366370 $ p ->setClientId ($ clientId );
367371 $ this ->projectMapper ->insert ($ p );
368372 } else {
369- if ($ p ->locked && $ this ->userId != ' admin ' ){
373+ if ($ p ->locked && ! $ this ->isAdminUser () ){
370374 return new JSONResponse (["Error " => "This project is locked " ]);
371375 }
372376 }
@@ -474,7 +478,7 @@ public function getProjects(){
474478 * @NoCSRFRequired
475479 */
476480 public function getProjectsTable (){
477- if ($ this ->userId == ' admin ' ){
481+ if ($ this ->isAdminUser () ){
478482 $ projects = $ this ->projectMapper ->findAllAdmin ();
479483 } else {
480484 $ projects = $ this ->projectMapper ->findAll ($ this ->userId );
@@ -519,8 +523,7 @@ public function addTag($name) {
519523 $ c ->setUserUid ($ this ->userId );
520524 $ c ->setCreatedAt (time ());
521525 $ this ->tagMapper ->insert ($ c );
522- }
523- if ($ c != null ){
526+ } else if ($ c != null ){
524527 return new JSONResponse (["Error " => "This tag name already exists " ]);
525528 }
526529
@@ -612,7 +615,8 @@ public function getReport(){
612615 $ name = $ this ->userId ;
613616 }
614617
615- if ($ this ->userId != 'admin ' ){
618+
619+ if ($ this ->isAdminUser ()){
616620 $ allowedClients = $ this ->clientMapper ->findAll ($ this ->userId );
617621 $ allowedClientsId = array_map (function ($ client ){ return $ client ->id ;}, $ allowedClients );
618622 if (empty ($ filterClientId )){
0 commit comments