Debian Codegraph @

modules/groupserv/set_public.c

raw
1 /*
2 * Copyright (c) 2005 Atheme Development Group
3 * Rights to this code are documented in doc/LICENSE.
4 *
5 * This file contains routines to handle the GroupServ HELP command.
6 *
7 */
8
9 #include "atheme.h"
10 #include "groupserv.h"
11
12 DECLARE_MODULE_V1
13 (
14 "groupserv/set_public", false, _modinit, _moddeinit,
15 PACKAGE_STRING,
16 VENDOR_STRING
17 );
18
19 static void gs_cmd_set_public(sourceinfo_t *si, int parc, char *parv[]);
20
21 command_t gs_set_public = { "PUBLIC", N_("Sets the group as public."), AC_AUTHENTICATED, 2, gs_cmd_set_public, { .path = "groupserv/set_public" } };
22
23 static void gs_cmd_set_public(sourceinfo_t *si, int parc, char *parv[])
24 {
25 mygroup_t *mg;
26
27 if (!parv[0] || !parv[1])
28 {
29 command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "PUBLIC");
30 command_fail(si, fault_needmoreparams, _("Syntax: PUBLIC <!group> <ON|OFF>"));
31 return;
32 }
33
34 if ((mg = mygroup_find(parv[0])) == NULL)
35 {
36 command_fail(si, fault_nosuch_target, _("The group \2%s\2 does not exist."), parv[0]);
37 return;
38 }
39
40 if (!groupacs_sourceinfo_has_flag(mg, si, GA_FOUNDER))
41 {
42 command_fail(si, fault_noprivs, _("You are not authorized to execute this command."));
43 return;
44 }
45
46 if (!strcasecmp(parv[1], "ON"))
47 {
48 if (mg->flags & MG_PUBLIC)
49 {
50 command_fail(si, fault_nochange, _("\2%s\2 is already public."), entity(mg)->name);
51 return;
52 }
53
54 mg->flags |= MG_PUBLIC;
55
56 logcommand(si, CMDLOG_SET, "PUBLIC:ON: \2%s\2", entity(mg)->name);
57 command_success_nodata(si, _("\2%s\2 is now public."), entity(mg)->name);
58 }
59 else if (!strcasecmp(parv[1], "OFF"))
60 {
61 if (!(mg->flags & MG_PUBLIC))
62 {
63 command_fail(si, fault_nochange, _("\2%s\2 is not public already."), entity(mg)->name);
64 return;
65 }
66
67 mg->flags &= ~MG_PUBLIC;
68
69 logcommand(si, CMDLOG_SET, "PUBLIC:OFF: \2%s\2", entity(mg)->name);
70 command_success_nodata(si, _("\2%s\2 is no longer public."), entity(mg)->name);
71 }
72 else
73 {
74 command_fail(si, fault_badparams, STR_INVALID_PARAMS, "PUBLIC");
75 command_fail(si, fault_badparams, _("Syntax: PUBLIC <!group> <ON|OFF>"));
76 }
77 }
78
79 void _modinit(module_t *m)
80 {
81 use_groupserv_main_symbols(m);
82 use_groupserv_set_symbols(m);
83
84 command_add(&gs_set_public, gs_set_cmdtree);
85 }
86
87 void _moddeinit(module_unload_intent_t intent)
88 {
89 command_delete(&gs_set_public, gs_set_cmdtree);
90 }
91