original_string: 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;
  	}
code: 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;
  	}
code_tokens: 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 ; }
docstring: 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
docstring_tokens: return the correct usergroups for a given user