Debian Codegraph @

modules/groupserv/regnolimit.c

raw
1
2 /*
3 * Copyright (c) 2005 Atheme Development Group
4 * Rights to this code are documented in doc/LICENSE.
5 *
6 * This file contains routines to handle the GroupServ HELP command.
7 *
8 */
9
10 #include "atheme.h"
11 #include "groupserv.h"
12
13 DECLARE_MODULE_V1
14 (
15 "groupserv/regnolimit", false, _modinit, _moddeinit,
16 PACKAGE_STRING,
17 VENDOR_STRING
18 );
19
20 static void gs_cmd_regnolimit(sourceinfo_t *si, int parc, char *parv[]);
21
22 command_t gs_regnolimit = { "REGNOLIMIT", N_("Allow a group to bypass registration limits."), PRIV_GROUP_ADMIN, 2, gs_cmd_regnolimit, { .path = "groupserv/regnolimit" } };
23
24 static void gs_cmd_regnolimit(sourceinfo_t *si, int parc, char *parv[])
25 {
26 mygroup_t *mg;
27
28 if (!parv[0] || !parv[1])
29 {
30 command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "REGNOLIMIT");
31 command_fail(si, fault_needmoreparams, _("Syntax: REGNOLIMIT <!group> <ON|OFF>"));
32 return;
33 }
34
35 if ((mg = mygroup_find(parv[0])) == NULL)
36 {
37 command_fail(si, fault_nosuch_target, _("The group \2%s\2 does not exist."), parv[0]);
38 return;
39 }
40
41 if (!strcasecmp(parv[1], "ON"))
42 {
43 if (mg->flags & MG_REGNOLIMIT)
44 {
45 command_fail(si, fault_nochange, _("\2%s\2 can already bypass registration limits."), entity(mg)->name);
46 return;
47 }
48
49 mg->flags |= MG_REGNOLIMIT;
50
51 wallops("%s set the REGNOLIMIT option on the group \2%s\2.", get_oper_name(si), entity(mg)->name);
52 logcommand(si, CMDLOG_ADMIN, "REGNOLIMIT:ON: \2%s\2", entity(mg)->name);
53 command_success_nodata(si, _("\2%s\2 can now bypass registration limits."), entity(mg)->name);
54 }
55 else if (!strcasecmp(parv[1], "OFF"))
56 {
57 if (!(mg->flags & MG_REGNOLIMIT))
58 {
59 command_fail(si, fault_nochange, _("\2%s\2 cannot bypass registration limits."), entity(mg)->name);
60 return;
61 }
62
63 mg->flags &= ~MG_REGNOLIMIT;
64
65 wallops("%s removed the REGNOLIMIT option from the group \2%s\2.", get_oper_name(si), entity(mg)->name);
66 logcommand(si, CMDLOG_ADMIN, "REGNOLIMIT:OFF: \2%s\2", entity(mg)->name);
67 command_success_nodata(si, _("\2%s\2 cannot bypass registration limits anymore."), entity(mg)->name);
68 }
69 else
70 {
71 command_fail(si, fault_badparams, STR_INVALID_PARAMS, "REGNOLIMIT");
72 command_fail(si, fault_badparams, _("Syntax: REGNOLIMIT <!group> <ON|OFF>"));
73 }
74 }
75
76 void _modinit(module_t *m)
77 {
78 use_groupserv_main_symbols(m);
79
80 service_named_bind_command("groupserv", &gs_regnolimit);
81 }
82
83 void _moddeinit(module_unload_intent_t intent)
84 {
85 service_named_unbind_command("groupserv", &gs_regnolimit);
86 }
87