/** Returns true or false if a user can set a privileged user or channel mode.
* This is done by looking up their oper type from User::oper, then referencing
* this to their oper classes, and checking the modes they can set.
- * @param mode The mode the check
- * @param type ModeType (MODETYPE_CHANNEL or MODETYPE_USER).
+ * @param mh Mode to check
* @return True if the user can set or unset this mode.
*/
- virtual bool HasModePermission(unsigned char mode, ModeType type);
+ virtual bool HasModePermission(const ModeHandler* mh) const;
/** Creates a usermask with real host.
* Takes a buffer to use and fills the given buffer with the hostmask in the format user\@host
/** Returns true or false if a user can set a privileged user or channel mode.
* This is done by looking up their oper type from User::oper, then referencing
* this to their oper classes, and checking the modes they can set.
- * @param mode The mode the check
- * @param type ModeType (MODETYPE_CHANNEL or MODETYPE_USER).
+ * @param mh Mode to check
* @return True if the user can set or unset this mode.
*/
- bool HasModePermission(unsigned char mode, ModeType type);
+ bool HasModePermission(const ModeHandler* mh) const;
};
class RemoteUser : public User
}
}
- if (adding && IS_LOCAL(user) && mh->NeedsOper() && !user->HasModePermission(modechar, type))
+ if ((adding) && (IS_LOCAL(user)) && (mh->NeedsOper()) && (!user->HasModePermission(mh)))
{
/* It's an oper only mode, and they don't have access to it. */
if (user->IsOper())
for(char c='A'; c <= 'z'; c++)
{
ModeHandler* mh = ServerInstance->Modes->FindMode(c, MODETYPE_USER);
- if (mh && mh->NeedsOper() && loctarg->HasModePermission(c, MODETYPE_USER))
+ if (mh && mh->NeedsOper() && loctarg->HasModePermission(mh))
umodes.push_back(c);
mh = ServerInstance->Modes->FindMode(c, MODETYPE_CHANNEL);
- if (mh && mh->NeedsOper() && loctarg->HasModePermission(c, MODETYPE_CHANNEL))
+ if (mh && mh->NeedsOper() && loctarg->HasModePermission(mh))
cmodes.push_back(c);
}
context.Write("modeperms", "user=" + umodes + " channel=" + cmodes);
return this->cached_fullrealhost;
}
-bool User::HasModePermission(unsigned char, ModeType)
+bool User::HasModePermission(const ModeHandler* mh) const
{
return true;
}
-bool LocalUser::HasModePermission(unsigned char mode, ModeType type)
+bool LocalUser::HasModePermission(const ModeHandler* mh) const
{
if (!this->IsOper())
return false;
+ const unsigned char mode = mh->GetModeChar();
if (mode < 'A' || mode > ('A' + 64)) return false;
- return ((type == MODETYPE_USER ? oper->AllowedUserModes : oper->AllowedChanModes))[(mode - 'A')];
+ return ((mh->GetModeType() == MODETYPE_USER ? oper->AllowedUserModes : oper->AllowedChanModes))[(mode - 'A')];
}
/*