src/Plugin/User.php
final public function getCorrectUserGroups(Userinfo $userinfo)
	{
		$jname = $this->getJname();
		$group = array();

		$master = Framework::getMaster();
		if ($master) {
			if ($master->name == $jname) {
				$group = Groups::get($master->name, true);
			} else {
				$slavegroups = Groups::get($jname);

				$user = Factory::getUser($master->name);
				$index = $user->getUserGroupIndex($userinfo);

				if (isset($slavegroups[$index])) {
					$group = $slavegroups[$index];
				}

				if ($group === null && isset($slavegroups[0])) {
					$group =  $slavegroups[0];
				}
			}
		}
		
		if (!is_array($group)) {
			if ($group !==  null) {
				$group = array($group);
			} else {
				$group = array();
			}
		}
		return $group;
	}
final public function getCorrectUserGroups(Userinfo $userinfo)
	{
		$jname = $this->getJname();
		$group = array();

		$master = Framework::getMaster();
		if ($master) {
			if ($master->name == $jname) {
				$group = Groups::get($master->name, true);
			} else {
				$slavegroups = Groups::get($jname);

				$user = Factory::getUser($master->name);
				$index = $user->getUserGroupIndex($userinfo);

				if (isset($slavegroups[$index])) {
					$group = $slavegroups[$index];
				}

				if ($group === null && isset($slavegroups[0])) {
					$group =  $slavegroups[0];
				}
			}
		}
		
		if (!is_array($group)) {
			if ($group !==  null) {
				$group = array($group);
			} else {
				$group = array();
			}
		}
		return $group;
	}
final public function getCorrectUserGroups ( Userinfo $ userinfo ) { $ jname = $ this -> getJname ( ) ; $ group = array ( ) ; $ master = Framework :: getMaster ( ) ; if ( $ master ) { if ( $ master -> name == $ jname ) { $ group = Groups :: get ( $ master -> name , true ) ; } else { $ slavegroups = Groups :: get ( $ jname ) ; $ user = Factory :: getUser ( $ master -> name ) ; $ index = $ user -> getUserGroupIndex ( $ userinfo ) ; if ( isset ( $ slavegroups [ $ index ] ) ) { $ group = $ slavegroups [ $ index ] ; } if ( $ group === null && isset ( $ slavegroups [ 0 ] ) ) { $ group = $ slavegroups [ 0 ] ; } } } if ( ! is_array ( $ group ) ) { if ( $ group !== null ) { $ group = array ( $ group ) ; } else { $ group = array ( ) ; } } return $ group ; }
return the correct usergroups for a given user

@param Userinfo|null $userinfo user with correct usergroups, if null it will return the usergroup for new users

@return array
return the correct usergroups for a given user