mirror of
https://github.com/anope/anope.git
synced 2026-06-12 19:14:47 +02:00
Allow access list entries to have a description.
This is useful when adding glob matches to the access list as a reminder of who they actually match. Resolves https://bugs.anope.org/view.php?id=1613
This commit is contained in:
@@ -84,6 +84,7 @@ class CoreExport ChanAccess : public Serializable
|
||||
/* Channel this access entry is on */
|
||||
Serialize::Reference<ChannelInfo> ci;
|
||||
Anope::string creator;
|
||||
Anope::string description;
|
||||
time_t last_seen;
|
||||
time_t created;
|
||||
|
||||
|
||||
@@ -214,6 +214,7 @@ class CommandCSAccess : public Command
|
||||
access->level = level;
|
||||
access->last_seen = 0;
|
||||
access->created = Anope::CurTime;
|
||||
access->description = params.size() > 4 ? params[4] : "";
|
||||
ci->AddAccess(access);
|
||||
|
||||
FOREACH_MOD(OnAccessAdd, (ci, source, access));
|
||||
@@ -388,6 +389,7 @@ class CommandCSAccess : public Command
|
||||
entry["Mask"] = access->Mask();
|
||||
entry["By"] = access->creator;
|
||||
entry["Last seen"] = timebuf;
|
||||
entry["Description"] = access->description;
|
||||
this->list.AddEntry(entry);
|
||||
}
|
||||
}
|
||||
@@ -425,6 +427,7 @@ class CommandCSAccess : public Command
|
||||
entry["Mask"] = access->Mask();
|
||||
entry["By"] = access->creator;
|
||||
entry["Last seen"] = timebuf;
|
||||
entry["Description"] = access->description;
|
||||
list.AddEntry(entry);
|
||||
}
|
||||
}
|
||||
@@ -456,7 +459,7 @@ class CommandCSAccess : public Command
|
||||
}
|
||||
|
||||
ListFormatter list(source.GetAccount());
|
||||
list.AddColumn(_("Number")).AddColumn(_("Level")).AddColumn(_("Mask"));
|
||||
list.AddColumn(_("Number")).AddColumn(_("Level")).AddColumn(_("Mask")).AddColumn(_("Description"));
|
||||
this->ProcessList(source, ci, params, list);
|
||||
}
|
||||
|
||||
@@ -469,7 +472,7 @@ class CommandCSAccess : public Command
|
||||
}
|
||||
|
||||
ListFormatter list(source.GetAccount());
|
||||
list.AddColumn(_("Number")).AddColumn(_("Level")).AddColumn(_("Mask")).AddColumn(_("By")).AddColumn(_("Last seen"));
|
||||
list.AddColumn(_("Number")).AddColumn(_("Level")).AddColumn(_("Mask")).AddColumn(_("By")).AddColumn(_("Last seen")).AddColumn(_("Description"));
|
||||
this->ProcessList(source, ci, params, list);
|
||||
}
|
||||
|
||||
@@ -493,10 +496,10 @@ class CommandCSAccess : public Command
|
||||
}
|
||||
|
||||
public:
|
||||
CommandCSAccess(Module *creator) : Command(creator, "chanserv/access", 2, 4)
|
||||
CommandCSAccess(Module *creator) : Command(creator, "chanserv/access", 2, 5)
|
||||
{
|
||||
this->SetDesc(_("Modify the list of privileged users"));
|
||||
this->SetSyntax(_("\037channel\037 ADD \037mask\037 \037level\037"));
|
||||
this->SetSyntax(_("\037channel\037 ADD \037mask\037 \037level\037 [\037description\037]"));
|
||||
this->SetSyntax(_("\037channel\037 DEL {\037mask\037 | \037entry-num\037 | \037list\037}"));
|
||||
this->SetSyntax(_("\037channel\037 LIST [\037mask\037 | \037list\037]"));
|
||||
this->SetSyntax(_("\037channel\037 VIEW [\037mask\037 | \037list\037]"));
|
||||
|
||||
@@ -44,6 +44,7 @@ class CommandCSClone : public Command
|
||||
ChanAccess *newaccess = provider->Create();
|
||||
newaccess->SetMask(taccess->Mask(), target_ci);
|
||||
newaccess->creator = taccess->creator;
|
||||
newaccess->description = taccess->description;
|
||||
newaccess->last_seen = taccess->last_seen;
|
||||
newaccess->created = taccess->created;
|
||||
newaccess->AccessUnserialize(taccess->AccessSerialize());
|
||||
|
||||
@@ -78,7 +78,7 @@ FlagsAccessProvider* FlagsAccessProvider::ap;
|
||||
|
||||
class CommandCSFlags : public Command
|
||||
{
|
||||
void DoModify(CommandSource &source, ChannelInfo *ci, Anope::string mask, const Anope::string &flags)
|
||||
void DoModify(CommandSource &source, ChannelInfo *ci, Anope::string mask, const Anope::string &flags, const Anope::string &description)
|
||||
{
|
||||
if (flags.empty())
|
||||
{
|
||||
@@ -262,7 +262,8 @@ class CommandCSFlags : public Command
|
||||
return;
|
||||
FlagsChanAccess *access = anope_dynamic_static_cast<FlagsChanAccess *>(provider->Create());
|
||||
access->SetMask(mask, ci);
|
||||
access->creator = source.GetNick();
|
||||
access->creator = source.GetNick();
|
||||
access->description = current ? current->description : description;
|
||||
access->last_seen = current ? current->last_seen : 0;
|
||||
access->created = Anope::CurTime;
|
||||
access->flags = current_flags;
|
||||
@@ -298,7 +299,7 @@ class CommandCSFlags : public Command
|
||||
|
||||
ListFormatter list(source.GetAccount());
|
||||
|
||||
list.AddColumn(_("Number")).AddColumn(_("Mask")).AddColumn(_("Flags")).AddColumn(_("Creator")).AddColumn(_("Created"));
|
||||
list.AddColumn(_("Number")).AddColumn(_("Mask")).AddColumn(_("Flags")).AddColumn(_("Creator")).AddColumn(_("Created")).AddColumn(_("Description"));
|
||||
|
||||
unsigned count = 0;
|
||||
for (unsigned i = 0, end = ci->GetAccessCount(); i < end; ++i)
|
||||
@@ -328,6 +329,7 @@ class CommandCSFlags : public Command
|
||||
entry["Flags"] = flags;
|
||||
entry["Creator"] = access->creator;
|
||||
entry["Created"] = Anope::strftime(access->created, source.nc, true);
|
||||
entry["Description"] = access->description;
|
||||
list.AddEntry(entry);
|
||||
}
|
||||
|
||||
@@ -368,10 +370,10 @@ class CommandCSFlags : public Command
|
||||
}
|
||||
|
||||
public:
|
||||
CommandCSFlags(Module *creator) : Command(creator, "chanserv/flags", 1, 4)
|
||||
CommandCSFlags(Module *creator) : Command(creator, "chanserv/flags", 1, 5)
|
||||
{
|
||||
this->SetDesc(_("Modify the list of privileged users"));
|
||||
this->SetSyntax(_("\037channel\037 [MODIFY] \037mask\037 \037changes\037"));
|
||||
this->SetSyntax(_("\037channel\037 [MODIFY] \037mask\037 \037changes\037 [\037description\037]"));
|
||||
this->SetSyntax(_("\037channel\037 LIST [\037mask\037 | +\037flags\037]"));
|
||||
this->SetSyntax(_("\037channel\037 CLEAR"));
|
||||
}
|
||||
@@ -409,19 +411,21 @@ class CommandCSFlags : public Command
|
||||
this->DoClear(source, ci);
|
||||
else
|
||||
{
|
||||
Anope::string mask, flags;
|
||||
Anope::string mask, flags, description;
|
||||
if (cmd.equals_ci("MODIFY"))
|
||||
{
|
||||
mask = params.size() > 2 ? params[2] : "";
|
||||
flags = params.size() > 3 ? params[3] : "";
|
||||
description = params.size() > 4 ? params[4] : "";
|
||||
}
|
||||
else
|
||||
{
|
||||
mask = cmd;
|
||||
flags = params.size() > 2 ? params[2] : "";
|
||||
description = params.size() > 3 ? params[3] : "";
|
||||
}
|
||||
|
||||
this->DoModify(source, ci, mask, flags);
|
||||
this->DoModify(source, ci, mask, flags, description);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -100,6 +100,7 @@ class CommandCSXOP : public Command
|
||||
void DoAdd(CommandSource &source, ChannelInfo *ci, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
Anope::string mask = params.size() > 2 ? params[2] : "";
|
||||
Anope::string description = params.size() > 3 ? params[3] : "";
|
||||
|
||||
if (mask.empty())
|
||||
{
|
||||
@@ -208,6 +209,7 @@ class CommandCSXOP : public Command
|
||||
XOPChanAccess *acc = anope_dynamic_static_cast<XOPChanAccess *>(provider->Create());
|
||||
acc->SetMask(mask, ci);
|
||||
acc->creator = source.GetNick();
|
||||
acc->description = description;
|
||||
acc->type = source.command.upper();
|
||||
acc->last_seen = 0;
|
||||
acc->created = Anope::CurTime;
|
||||
@@ -374,7 +376,7 @@ class CommandCSXOP : public Command
|
||||
}
|
||||
|
||||
ListFormatter list(source.GetAccount());
|
||||
list.AddColumn(_("Number")).AddColumn(_("Mask"));
|
||||
list.AddColumn(_("Number")).AddColumn(_("Mask")).AddColumn(_("Description"));
|
||||
|
||||
if (!nick.empty() && nick.find_first_not_of("1234567890,-") == Anope::string::npos)
|
||||
{
|
||||
@@ -401,6 +403,7 @@ class CommandCSXOP : public Command
|
||||
ListFormatter::ListEntry entry;
|
||||
entry["Number"] = stringify(Number);
|
||||
entry["Mask"] = a->Mask();
|
||||
entry["Description"] = a->description;
|
||||
this->list.AddEntry(entry);
|
||||
}
|
||||
} nl_list(list, ci, nick, source);
|
||||
@@ -420,6 +423,7 @@ class CommandCSXOP : public Command
|
||||
ListFormatter::ListEntry entry;
|
||||
entry["Number"] = stringify(i + 1);
|
||||
entry["Mask"] = a->Mask();
|
||||
entry["Description"] = a->description;
|
||||
list.AddEntry(entry);
|
||||
}
|
||||
}
|
||||
@@ -478,7 +482,7 @@ class CommandCSXOP : public Command
|
||||
public:
|
||||
CommandCSXOP(Module *modname) : Command(modname, "chanserv/xop", 2, 4)
|
||||
{
|
||||
this->SetSyntax(_("\037channel\037 ADD \037mask\037"));
|
||||
this->SetSyntax(_("\037channel\037 ADD \037mask\037 [\037description\037]"));
|
||||
this->SetSyntax(_("\037channel\037 DEL {\037mask\037 | \037entry-num\037 | \037list\037}"));
|
||||
this->SetSyntax(_("\037channel\037 LIST [\037mask\037 | \037list\037]"));
|
||||
this->SetSyntax(_("\037channel\037 CLEAR"));
|
||||
|
||||
@@ -211,6 +211,7 @@ void ChanAccess::Serialize(Serialize::Data &data) const
|
||||
data["ci"] << this->ci->name;
|
||||
data["mask"] << this->Mask();
|
||||
data["creator"] << this->creator;
|
||||
data["description"] << this->description;
|
||||
data.SetType("last_seen", Serialize::Data::DT_INT); data["last_seen"] << this->last_seen;
|
||||
data.SetType("created", Serialize::Data::DT_INT); data["created"] << this->created;
|
||||
data["data"] << this->AccessSerialize();
|
||||
@@ -238,6 +239,7 @@ Serializable* ChanAccess::Unserialize(Serializable *obj, Serialize::Data &data)
|
||||
data["mask"] >> m;
|
||||
access->SetMask(m, ci);
|
||||
data["creator"] >> access->creator;
|
||||
data["description"] >> access->description;
|
||||
data["last_seen"] >> access->last_seen;
|
||||
data["created"] >> access->created;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user