]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/commands/cmd_who.cpp
Change OnHookUserIO to OnHookIO, making it usable for more than User* and less picky...
[user/henk/code/inspircd.git] / src / commands / cmd_who.cpp
index 1ce4e4c287abb093eb5e4e36f64c6fcfea8792ab..9e14ecb457ed8ec2ed98da1d4b71f1d26aac1b25 100644 (file)
@@ -2,8 +2,8 @@
  *       | Inspire Internet Relay Chat Daemon |
  *       +------------------------------------+
  *
- *  InspIRCd: (C) 2002-2008 InspIRCd Development Team
- * See: http://www.inspircd.org/wiki/index.php/Credits
+ *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
+ * See: http://wiki.inspircd.org/Credits
  *
  * This program is free but copyrighted software; see
  *         the file COPYING for details.
@@ -71,24 +71,24 @@ bool CommandWho::whomatch(User* user, const char* matchtext)
                if (opt_metadata)
                        match = user->GetExt(matchtext, dummy);
                else if (opt_realname)
-                       match = InspIRCd::Match(user->fullname, matchtext, lowermap);
+                       match = InspIRCd::Match(user->fullname, matchtext);
                else if (opt_showrealhost)
-                       match = InspIRCd::Match(user->host, matchtext, lowermap);
+                       match = InspIRCd::Match(user->host, matchtext, ascii_case_insensitive_map);
                else if (opt_ident)
-                       match = InspIRCd::Match(user->ident, matchtext, lowermap);
+                       match = InspIRCd::Match(user->ident, matchtext, ascii_case_insensitive_map);
                else if (opt_port)
                {
                        irc::portparser portrange(matchtext, false);
                        long portno = -1;
                        while ((portno = portrange.GetToken()))
-                               if (portno == user->GetPort())
+                               if (portno == user->GetServerPort())
                                {
                                        match = true;
                                        break;
                                }
                }
                else if (opt_away)
-                       match = InspIRCd::Match(user->awaymsg, matchtext, lowermap);
+                       match = InspIRCd::Match(user->awaymsg, matchtext);
                else if (opt_time)
                {
                        long seconds = ServerInstance->Duration(matchtext);
@@ -106,13 +106,13 @@ bool CommandWho::whomatch(User* user, const char* matchtext)
                 * -- w00t
                 */
                if (!match)
-                       match = InspIRCd::Match(user->dhost, matchtext, lowermap);
+                       match = InspIRCd::Match(user->dhost, matchtext, ascii_case_insensitive_map);
 
                if (!match)
-                       match = InspIRCd::Match(user->nick, matchtext, lowermap);
+                       match = InspIRCd::Match(user->nick, matchtext);
 
                if (!match)
-                       match = InspIRCd::Match(user->server, matchtext, lowermap);
+                       match = InspIRCd::Match(user->server, matchtext);
 
                return match;
        }
@@ -136,7 +136,7 @@ bool CommandWho::CanView(Channel* chan, User* user)
        if (chan->HasUser(user))
                return true;
        /* Opers see all */
-       if (IS_OPER(user))
+       if (user->HasPrivPermission("users/auspex"))
                return true;
        /* Cant see inside a +s or a +p channel unless we are a member (see above) */
        else if (!chan->IsModeSet('s') && !chan->IsModeSet('p'))
@@ -155,7 +155,7 @@ void CommandWho::SendWhoLine(User* user, const std::string &initial, Channel* ch
        Channel* chlast = ServerInstance->FindChan(lcn);
 
        std::string wholine =   initial + (ch ? ch->name : lcn) + " " + u->ident + " " + (opt_showrealhost ? u->host : u->dhost) + " " +
-                               ((*ServerInstance->Config->HideWhoisServer && !IS_OPER(user)) ? ServerInstance->Config->HideWhoisServer : u->server) +
+                               ((*ServerInstance->Config->HideWhoisServer && !user->HasPrivPermission("servers/auspex")) ? ServerInstance->Config->HideWhoisServer : u->server) +
                                " " + u->nick + " ";
 
        /* away? */
@@ -239,36 +239,41 @@ CmdResult CommandWho::Handle (const std::vector<std::string>& parameters, User *
                                        opt_viewopersonly = true;
                                        break;
                                case 'h':
-                                       if (IS_OPER(user))
+                                       if (user->HasPrivPermission("users/auspex"))
                                                opt_showrealhost = true;
                                        break;
                                case 'u':
-                                       if (IS_OPER(user))
+                                       if (user->HasPrivPermission("users/auspex"))
                                                opt_unlimit = true;
                                        break;
                                case 'r':
                                        opt_realname = true;
                                        break;
                                case 'm':
-                                       opt_mode = true;
+                                       if (user->HasPrivPermission("users/auspex"))
+                                               opt_mode = true;
                                        break;
                                case 'M':
-                                       opt_metadata = true;
+                                       if (user->HasPrivPermission("users/auspex"))
+                                               opt_metadata = true;
                                        break;
                                case 'i':
                                        opt_ident = true;
                                        break;
                                case 'p':
-                                       opt_port = true;
+                                       if (user->HasPrivPermission("users/auspex"))
+                                               opt_port = true;
                                        break;
                                case 'a':
                                        opt_away = true;
                                        break;
                                case 'l':
-                                       opt_local = true;
+                                       if (user->HasPrivPermission("users/auspex") || !*ServerInstance->Config->HideWhoisServer)
+                                               opt_local = true;
                                        break;
                                case 'f':
-                                       opt_far = true;
+                                       if (user->HasPrivPermission("users/auspex") || !*ServerInstance->Config->HideWhoisServer)
+                                               opt_far = true;
                                        break;
                                case 't':
                                        opt_time = true;
@@ -286,10 +291,10 @@ CmdResult CommandWho::Handle (const std::vector<std::string>& parameters, User *
                if (CanView(ch,user))
                {
                        bool inside = ch->HasUser(user);
-       
+
                        /* who on a channel. */
                        CUList *cu = ch->GetUsers();
-       
+
                        for (CUList::iterator i = cu->begin(); i != cu->end(); i++)
                        {
                                /* None of this applies if we WHO ourselves */
@@ -298,12 +303,12 @@ CmdResult CommandWho::Handle (const std::vector<std::string>& parameters, User *
                                        /* opers only, please */
                                        if (opt_viewopersonly && !IS_OPER(i->first))
                                                continue;
-       
+
                                        /* If we're not inside the channel, hide +i users */
-                                       if (i->first->IsModeSet('i') && !inside && !IS_OPER(user))
+                                       if (i->first->IsModeSet('i') && !inside && !user->HasPrivPermission("users/auspex"))
                                                continue;
                                }
-       
+
                                SendWhoLine(user, initial, ch, i->first, whoresults);
                        }
                }
@@ -322,7 +327,7 @@ CmdResult CommandWho::Handle (const std::vector<std::string>& parameters, User *
                                {
                                        if (!user->SharesChannelWith(oper))
                                        {
-                                               if (usingwildcards && (!oper->IsModeSet('i')) && (!IS_OPER(user)))
+                                               if (usingwildcards && (!oper->IsModeSet('i')) && (!user->HasPrivPermission("users/auspex")))
                                                        continue;
                                        }
 
@@ -338,7 +343,7 @@ CmdResult CommandWho::Handle (const std::vector<std::string>& parameters, User *
                                {
                                        if (!user->SharesChannelWith(i->second))
                                        {
-                                               if (usingwildcards && (i->second->IsModeSet('i')) && (!IS_OPER(user)))
+                                               if (usingwildcards && (i->second->IsModeSet('i')) && (!user->HasPrivPermission("users/auspex")))
                                                        continue;
                                        }
 
@@ -362,4 +367,3 @@ CmdResult CommandWho::Handle (const std::vector<std::string>& parameters, User *
                return CMD_FAILURE;
        }
 }
-