]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_check.cpp
Fix a broken distro constraint in the m_ssl_gnutls PackageInfo.
[user/henk/code/inspircd.git] / src / modules / m_check.cpp
index 17eb9d9c59d2194840645ceb75aab17dd354f46c..2cb45ad435cef3ceb688c0010f4ab8371dc82736 100644 (file)
@@ -109,6 +109,19 @@ class CommandCheck : public Command
                return ret;
        }
 
+       static std::string GetAllowedOperOnlyModes(LocalUser* user, ModeType modetype)
+       {
+               std::string ret;
+               const ModeParser::ModeHandlerMap& modes = ServerInstance->Modes.GetModes(modetype);
+               for (ModeParser::ModeHandlerMap::const_iterator i = modes.begin(); i != modes.end(); ++i)
+               {
+                       const ModeHandler* const mh = i->second;
+                       if ((mh->NeedsOper()) && (user->HasModePermission(mh)))
+                               ret.push_back(mh->GetModeChar());
+               }
+               return ret;
+       }
+
  public:
        CommandCheck(Module* parent)
                : Command(parent,"CHECK", 1)
@@ -156,7 +169,7 @@ class CommandCheck : public Command
                        context.Write("nuh", targuser->GetFullHost());
                        context.Write("realnuh", targuser->GetFullRealHost());
                        context.Write("realname", targuser->fullname);
-                       context.Write("modes", std::string("+") + targuser->FormatModes());
+                       context.Write("modes", targuser->GetModeLetters());
                        context.Write("snomasks", GetSnomasks(targuser));
                        context.Write("server", targuser->server->GetName());
                        context.Write("uid", targuser->uuid);
@@ -179,17 +192,8 @@ class CommandCheck : public Command
                                context.Write("opertype", oper->name);
                                if (loctarg)
                                {
-                                       std::string umodes;
-                                       std::string cmodes;
-                                       for(char c='A'; c <= 'z'; c++)
-                                       {
-                                               ModeHandler* mh = ServerInstance->Modes->FindMode(c, MODETYPE_USER);
-                                               if (mh && mh->NeedsOper() && loctarg->HasModePermission(c, MODETYPE_USER))
-                                                       umodes.push_back(c);
-                                               mh = ServerInstance->Modes->FindMode(c, MODETYPE_CHANNEL);
-                                               if (mh && mh->NeedsOper() && loctarg->HasModePermission(c, MODETYPE_CHANNEL))
-                                                       cmodes.push_back(c);
-                                       }
+                                       std::string umodes = GetAllowedOperOnlyModes(loctarg, MODETYPE_USER);
+                                       std::string cmodes = GetAllowedOperOnlyModes(loctarg, MODETYPE_CHANNEL);
                                        context.Write("modeperms", "user=" + umodes + " channel=" + cmodes);
 
                                        CheckContext::List opcmdlist(context, "commandperms");
@@ -260,7 +264,7 @@ class CommandCheck : public Command
                                 */
                                const UserManager::CloneCounts& clonecount = ServerInstance->Users->GetCloneCounts(i->first);
                                context.Write("member", InspIRCd::Format("%-3u %s%s (%s@%s) %s ", clonecount.global,
-                                       i->second->GetAllPrefixChars(), i->first->nick.c_str(),
+                                       i->second->GetAllPrefixChars().c_str(), i->first->nick.c_str(),
                                        i->first->ident.c_str(), i->first->dhost.c_str(), i->first->fullname.c_str()));
                        }