public final function getUserIdentifier(Userinfo &$userinfo, $username_col, $email_col, $userid_col, $lowerEmail = true)
    {
	    $login_identifier = $this->params->get('login_identifier', 1);

	    if ($this->getJname() == $userinfo->getJname() && $userinfo->userid != null) {
		    $login_identifier = 4;
	    } elseif ($username_col == null) {
		    $login_identifier = 2;
	    }
        switch ($login_identifier) {
            default:
            case 1:
                // username
	            $identifier = $userinfo->username;
                $identifier_type = $username_col;
                break;
            case 2:
                // email
	            $identifier = $userinfo->email;
                $identifier_type = $email_col;
                break;
            case 3:
                // username or email
	            $pattern = '/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i';
	            if (preg_match($pattern, $userinfo->username)) {
		            $identifier_type = $email_col;
		            $identifier = $userinfo->email;
	            } else {
		            $identifier_type = $username_col;
		            $identifier = $userinfo->username;
	            }
                break;
	        case 4:
		        // userid
		        $identifier_type = $userid_col;
		        $identifier = $userinfo->userid;
		        break;
        }
        if ($lowerEmail && $identifier_type == $email_col) {
            $identifier_type = 'LOWER(' . $identifier_type . ')';
            $identifier = strtolower($identifier);
        }
        return array($identifier_type, $identifier);
    }