/// <summary> /// Gets the global user. Work just as GetUser, but only for global records /// </summary> /// <returns> /// The global user or null in case there is no match /// </returns> /// <param name='user'> /// Identification string against which the user regexes are tested, this is usually a string /// in format of 'nick!ident@hostname' /// </param> public static SystemUser GetGlobalUser(string user) { SystemUser lv = null; int level = 0; lock (globalUsers) { foreach (SystemUser b in globalUsers) { Core.RegexCheck id = new Core.RegexCheck(b.Name, user); if (id.IsMatch() == 1) { // if there is multiple records matching the regex, we need to pick that one // with highest privileges int rl = GetLevelOfRole(b.Role); if (rl > level) { level = rl; lv = b; } } } } return(lv); }
/// <summary> /// Return user object from a name /// /// Search all global and local records for matching regex, if multiple matches are existing the one with /// highest privileges is returned. /// </summary> /// <param name="user"> /// Identification string against which the user regexes are tested, this is usually a string /// in format of nick!ident@hostname (typical for IRC protocol) /// </param> /// <returns> /// This function always return an instance of SystemUser even if no such a user exists, in that case user /// with "null" role is returned, which has no privileges by default /// </returns> public SystemUser GetUser(string user) { SystemUser lv = GetGlobalUser(user); if (lv == null) { lv = new SystemUser("null", ""); } int current = GetLevelOfRole(lv.Role); lock (Users) { foreach (SystemUser b in Users) { Core.RegexCheck id = new Core.RegexCheck(b.Name, user); if (id.IsMatch() == 1) { int level = GetLevelOfRole(b.Role); if (level > current) { current = level; lv = b; } } } } return(lv); }
/// <summary> /// Return user object from a name /// /// Search all global and local records for matching regex, if multiple matches are existing the one with /// highest privileges is returned. /// </summary> /// <param name="user"> /// Identification string against which the user regexes are tested, this is usually a string /// in format of nick!ident@hostname (typical for IRC protocol) /// </param> /// <returns> /// This function always return an instance of SystemUser even if no such a user exists, in that case user /// with "null" role is returned, which has no privileges by default /// </returns> public SystemUser GetUser(string user) { SystemUser lv = GetGlobalUser(user); if (lv == null) { lv = new SystemUser("null", ""); } int current = GetLevelOfRole(lv.Role); lock (Users) { foreach (SystemUser b in Users) { Core.RegexCheck id = new Core.RegexCheck(b.Name, user); if (id.IsMatch() == 1) { int level = GetLevelOfRole(b.Role); if (level > current) { current = level; lv = b; } } } } return lv; }
/// <summary> /// Gets the global user. Work just as GetUser, but only for global records /// </summary> /// <returns> /// The global user or null in case there is no match /// </returns> /// <param name='user'> /// Identification string against which the user regexes are tested, this is usually a string /// in format of 'nick!ident@hostname' /// </param> public static SystemUser GetGlobalUser(string user) { SystemUser lv = null; int level = 0; lock (globalUsers) { foreach (SystemUser b in globalUsers) { Core.RegexCheck id = new Core.RegexCheck(b.Name, user); if (id.IsMatch() == 1) { // if there is multiple records matching the regex, we need to pick that one // with highest privileges int rl = GetLevelOfRole(b.Role); if (rl > level) { level = rl; lv = b; } } } } return lv; }
/// <summary> /// Return user object from a name /// </summary> /// <param name="user"></param> /// <returns></returns> public SystemUser GetUser(string user) { SystemUser lv = new SystemUser("null", ""); int current = 0; lock (GlobalUsers) { foreach (SystemUser b in GlobalUsers) { Core.RegexCheck id = new Core.RegexCheck(b.Name, user); if (id.IsMatch() == 1) { if (GetLevel(b.Role) > current) { current = GetLevel(b.Role); lv = b; } } } } lock (Users) { foreach (SystemUser b in Users) { Core.RegexCheck id = new Core.RegexCheck(b.Name, user); if (id.IsMatch() == 1) { if (GetLevel(b.Role) > current) { current = GetLevel(b.Role); lv = b; } } } } return lv; }