summaryrefslogtreecommitdiff
path: root/modules/commands/ms_del.cpp
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2014-11-24 14:27:23 -0500
committerAdam <Adam@anope.org>2014-11-24 14:27:23 -0500
commit42238034490fb5479d787bd1695750387d508200 (patch)
treec93c62e0e1c936e656ae5b9ee1b62380ce2a194c /modules/commands/ms_del.cpp
parentd492923610d9c9146b2a2b63de38deab2cfd4ca7 (diff)
Rewrite serializable to have field level granularity
Represent serializable objects in a digraph, and as a result made most object relationships implicitly defined, and use the graph to trace references between objects to determine relationships. Edges may also be marked as having a dependency of the object they point to, which allows for automatic cleanup and deletion of most objects when no longer needed. Additionally, this allows not having to require in-memory copies of everything when using external databases. db_sql has been rewritten for this and now always requires a database to function. db_sql with MySQL now requires InnoDB to make use of transactions and foreign key constraints.
Diffstat (limited to 'modules/commands/ms_del.cpp')
-rw-r--r--modules/commands/ms_del.cpp29
1 files changed, 16 insertions, 13 deletions
diff --git a/modules/commands/ms_del.cpp b/modules/commands/ms_del.cpp
index bc612c6c1..79af11adc 100644
--- a/modules/commands/ms_del.cpp
+++ b/modules/commands/ms_del.cpp
@@ -47,14 +47,14 @@ class CommandMSDel : public Command
if (!source.AccessFor(ci).HasPriv("MEMO"))
{
- source.Reply(_("Access denied. You do not have privilege \002{0}\002 on \002{1}\002."), "MEMO", ci->name);
+ source.Reply(_("Access denied. You do not have privilege \002{0}\002 on \002{1}\002."), "MEMO", ci->GetName());
return;
}
- mi = ci->memos;
+ mi = ci->GetMemos();
}
else
- mi = source.nc->memos;
+ mi = source.nc->GetMemos();
if (numstr.empty() || (!isdigit(numstr[0]) && !numstr.equals_ci("ALL") && !numstr.equals_ci("LAST")))
{
@@ -62,7 +62,7 @@ class CommandMSDel : public Command
return;
}
- if (!mi || mi->memos->empty())
+ if (!mi || mi->GetMemos().empty())
{
if (!chan.empty())
source.Reply(_("\002{0}\002 has no memos."), chan);
@@ -71,16 +71,18 @@ class CommandMSDel : public Command
return;
}
+ auto memos = mi->GetMemos();
+
if (isdigit(numstr[0]))
{
NumberList(numstr, true,
[&](unsigned int number)
{
- if (!number || number > mi->memos->size())
+ if (!number || number > memos.size())
return;
if (MemoServ::Event::OnMemoDel)
- MemoServ::Event::OnMemoDel(&MemoServ::Event::MemoDel::OnMemoDel, ci ? ci->name : source.nc->display, mi, mi->GetMemo(number - 1));
+ MemoServ::Event::OnMemoDel(&MemoServ::Event::MemoDel::OnMemoDel, ci ? ci->GetName() : source.nc->GetDisplay(), mi, mi->GetMemo(number - 1));
mi->Del(number - 1);
source.Reply(_("Memo \002{0}\002 has been deleted."), number);
@@ -91,19 +93,20 @@ class CommandMSDel : public Command
{
/* Delete last memo. */
if (MemoServ::Event::OnMemoDel)
- MemoServ::Event::OnMemoDel(&MemoServ::Event::MemoDel::OnMemoDel, ci ? ci->name : source.nc->display, mi, mi->GetMemo(mi->memos->size() - 1));
- mi->Del(mi->memos->size() - 1);
- source.Reply(_("Memo \002{0}\002 has been deleted."), mi->memos->size() + 1);
+ MemoServ::Event::OnMemoDel(&MemoServ::Event::MemoDel::OnMemoDel, ci ? ci->GetName() : source.nc->GetDisplay(), mi, mi->GetMemo(memos.size() - 1));
+ mi->Del(memos.size() - 1);
+ source.Reply(_("Memo \002{0}\002 has been deleted."), memos.size() + 1);
}
else
{
/* Delete all memos. */
- for (unsigned i = mi->memos->size(); i > 0; --i)
+ std::for_each(memos.begin(), memos.end(),
+ [&](MemoServ::Memo *m)
{
if (MemoServ::Event::OnMemoDel)
- MemoServ::Event::OnMemoDel(&MemoServ::Event::MemoDel::OnMemoDel, ci ? ci->name : source.nc->display, mi, mi->GetMemo(i));
- mi->Del(i - 1);
- }
+ MemoServ::Event::OnMemoDel(&MemoServ::Event::MemoDel::OnMemoDel, ci ? ci->GetName() : source.nc->GetDisplay(), mi, m);
+ delete m;
+ });
if (!chan.empty())
source.Reply(_("All memos for channel \002{0}\002 have been deleted."), chan);
else