]> jfr.im git - irc/atheme/atheme.git/commitdiff
Implement functionality to migrate ALL the old marks.
authorErrietta Kostala <redacted>
Thu, 20 Nov 2014 22:11:35 +0000 (22:11 +0000)
committerErrietta Kostala <redacted>
Thu, 20 Nov 2014 22:11:35 +0000 (22:11 +0000)
help/default/nickserv/multimark
modules/nickserv/multimark.c

index 5afb90edb8153ec8ee6d5b31be660d2c78ee90a0..2b2e416cb0e0e5be0920f8f6c41760f52ec053a0 100644 (file)
@@ -18,6 +18,11 @@ Syntax: MARK <nickname> LIST
 
 Shows all marks for a nickname.
 
+Syntax: MARK MIGRATE
+
+Migrates ALL the marks from the old mark module to
+this one.
+
 Examples:
     /msg &nick& MARK tomaw ADD Doesn't actually exist
     /msg &nick& MARK tomaw ADD You can add as many marks as you want
index eb5655107fee9e271bdf35cc3a4adc8e4bc0116e..b9f433f54b4d148c6d188c5dd643e5f63770f3c8 100644 (file)
@@ -418,6 +418,21 @@ static void migrate_user(myuser_t *mu)
        metadata_delete(mu, "private:mark:timestamp");
 }
 
+static void migrate_all(sourceinfo_t *si)
+{
+       myentity_iteration_state_t state;
+       myentity_t *mt;
+
+       command_success_nodata(si, _("Migrating mark data..."));
+
+       MYENTITY_FOREACH_T(mt, &state, ENT_USER)
+       {
+               myuser_t *mu = user(mt);
+               migrate_user(mu);
+       }
+
+       command_success_nodata(si, _("Mark data migrated successfully."));
+}
 
 int get_multimark_max(myuser_t *mu)
 {
@@ -817,10 +832,28 @@ static void ns_cmd_multimark(sourceinfo_t *si, int parc, char *parv[])
 
        mowgli_list_t *rl;
 
+       bool has_admin;
+
+       if (target && !strcasecmp(target, "MIGRATE") && !action)
+       {
+               has_admin = has_priv(si, PRIV_ADMIN);
+
+               if (!has_admin)
+               {
+                       command_fail(si, fault_noprivs, _("You need the %s privilege for this operation."), PRIV_ADMIN);
+               }
+               else
+               {
+                       migrate_all(si);
+               }
+
+               return;
+       }
+
        if (!target || !action)
        {
                command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "MARK");
-               command_fail(si, fault_needmoreparams, _("usage: MARK <target> <ADD|DEL|LIST> [note]"));
+               command_fail(si, fault_needmoreparams, _("usage: MARK <target> <ADD|DEL|LIST|MIGRATE> [note]"));
                return;
        }
 
@@ -1067,6 +1100,6 @@ static void ns_cmd_multimark(sourceinfo_t *si, int parc, char *parv[])
        else
        {
                command_fail(si, fault_needmoreparams, STR_INVALID_PARAMS, "MARK");
-               command_fail(si, fault_needmoreparams, _("usage: MARK <target> <ADD|DEL|LIST> [note]"));
+               command_fail(si, fault_needmoreparams, _("usage: MARK <target> <ADD|DEL|LIST|MIGRATE> [note]"));
        }
 }