*/
#include "inspircd.h"
-#include "configreader.h"
-#include <algorithm>
-#include "users.h"
-#include "modules.h"
#include "wildcard.h"
#include "xline.h"
#include "socketengine.h"
{
if ((pcnt>=n->second->min_params) && (n->second->source != "<core>"))
{
- if ((!n->second->flags_needed) || (user->IsModeSet(n->second->flags_needed)))
+ if (IS_LOCAL(user) && n->second->flags_needed)
{
- if (n->second->flags_needed)
+ if (user->IsModeSet(n->second->flags_needed))
{
- return ((user->HasPermission(commandname)) || (ServerInstance->ULine(user->server)));
+ return (user->HasPermission(commandname));
}
+ }
+ else
+ {
return true;
}
}
{
if (pcnt >= n->second->min_params)
{
- if ((!n->second->flags_needed) || (user->IsModeSet(n->second->flags_needed)))
+ bool bOkay = false;
+
+ if (IS_LOCAL(user) && n->second->flags_needed)
{
- if (n->second->flags_needed)
- {
- if ((user->HasPermission(commandname)) || (!IS_LOCAL(user)))
- {
- return n->second->Handle(parameters,pcnt,user);
- }
- }
- else
+ /* if user is local, and flags are needed .. */
+
+ if (user->IsModeSet(n->second->flags_needed))
{
- return n->second->Handle(parameters,pcnt,user);
+ /* if user has the flags, and now has the permissions, go ahead */
+ if (user->HasPermission(commandname))
+ bOkay = true;
}
}
+ else
+ {
+ /* remote or no flags required anyway */
+ bOkay = true;
+ }
+
+ if (bOkay)
+ {
+ return n->second->Handle(parameters,pcnt,user);
+ }
}
}
return CMD_INVALID;
return;
/*
- * WARNING: nothing should come after this, as the user may be on a cull list to
- * be nuked next loop iteration. be sensible.
+ * WARNING: be careful, the user may be deleted soon
*/
CmdResult result = cm->second->Handle(command_p,items,user);
{
if (!user->muted)
{
- ServerInstance->Log(DEBUG,"C[%d] -> :%s %s",user->GetFd(), user->nick, buffer.c_str());
+ ServerInstance->Log(DEBUG,"C[%d] I :%s %s",user->GetFd(), user->nick, buffer.c_str());
this->ProcessCommand(user,buffer);
}
}
this->CreateCommand(new cmd_reload(ServerInstance));
}
+int CommandParser::TranslateUIDs(TranslateType to, const std::string &source, std::string &dest)
+{
+ userrec* user = NULL;
+ std::string item;
+ int translations = 0;
+
+ switch (to)
+ {
+ case TR_NICK:
+ /* Translate single nickname */
+ ServerInstance->Log(DEBUG,"TR_NICK");
+ user = ServerInstance->FindNick(source);
+ if (user)
+ {
+ ServerInstance->Log(DEBUG,"Managed UUID");
+ dest = user->uuid;
+ translations++;
+ }
+ else
+ {
+ ServerInstance->Log(DEBUG,"Had to use source.. (%s)", source.c_str());
+ dest = source;
+ }
+ break;
+ case TR_NICKLIST:
+ {
+ /* Translate comma seperated list of nicknames */
+ irc::commasepstream items(source);
+ while (items.GetToken(item))
+ {
+ user = ServerInstance->FindNick(item);
+ if (user)
+ {
+ dest.append(user->uuid);
+ translations++;
+ }
+ else
+ dest.append(source);
+ dest.append(",");
+ }
+ if (!dest.empty())
+ dest.erase(dest.end() - 1);
+ }
+ break;
+ case TR_SPACENICKLIST:
+ {
+ /* Translate space seperated list of nicknames */
+ irc::spacesepstream items(source);
+ while (items.GetToken(item))
+ {
+ user = ServerInstance->FindNick(item);
+ if (user)
+ {
+ dest.append(user->uuid);
+ translations++;
+ }
+ else
+ dest.append(source);
+ dest.append(" ");
+ }
+ if (!dest.empty())
+ dest.erase(dest.end() - 1);
+ }
+ break;
+ case TR_END:
+ case TR_TEXT:
+ default:
+ /* Do nothing */
+ dest = source;
+ break;
+ }
+
+ return translations;
+}
+