From 81ba8c23375b10b76baf23f0b351fd21084eba45 Mon Sep 17 00:00:00 2001
From: Benjamin Renard <benjamin.renard@akka.eu>
Date: Wed, 14 Apr 2021 14:16:37 +0200
Subject: [PATCH] Fix time restrictions when an user is not in any group (#5768)

---
 php/classes/UserMgr.php | 25 ++++++++++++-------------
 1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/php/classes/UserMgr.php b/php/classes/UserMgr.php
index dcafb51..c6a5e9b 100644
--- a/php/classes/UserMgr.php
+++ b/php/classes/UserMgr.php
@@ -704,9 +704,6 @@ class UserMgr
 	
 	protected function updateTreeForGrpsAndTimeRestrictions($file)
 	{
-		if (!isset($this->userGrps))
-			return TRUE;
-
 		$xml = new DomDocument("1.0");
 		
 		if(!$xml->load($file)) 
@@ -714,18 +711,20 @@ class UserMgr
 		
 		$xp = new domxpath($xml);                                                                             
 	  
-		foreach ($this->userGrps as $grp) {
-			$nodes = $xp->query("//*[@group='".$grp."']");
+		if (!empty($this->userGrps)) {
+			foreach ($this->userGrps as $grp) {
+				$nodes = $xp->query("//*[@group='".$grp."']");
 			
-			if ($nodes->length > 0)
-				foreach ($nodes as $node) {
-						$node->removeAttribute('group');
-						if ($node->hasAttribute('restriction')) {
-							if ($node->getAttribute('restriction') != "plotOnly") {
-								$node->removeAttribute('restriction');
+				if ($nodes->length > 0)
+					foreach ($nodes as $node) {
+							$node->removeAttribute('group');
+							if ($node->hasAttribute('restriction')) {
+								if ($node->getAttribute('restriction') != "plotOnly") {
+									$node->removeAttribute('restriction');
+								}
 							}
-						}
-				}
+					}
+			}
 		}
 
 		if (!empty($this->datasetsTimeRestriction)) {
--
libgit2 0.21.2