Debian Codegraph @

modules/groupserv/set_description.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_description", false, _modinit, _moddeinit,
15 PACKAGE_STRING,
16 VENDOR_STRING
17 );
18
19 static void gs_cmd_set_description(sourceinfo_t *si, int parc, char *parv[]);
20
21 command_t gs_set_description = { "DESCRIPTION", N_("Sets the group description."), AC_AUTHENTICATED, 2, gs_cmd_set_description, { .path = "groupserv/set_description" } };
22
23 static void gs_cmd_set_description(sourceinfo_t *si, int parc, char *parv[])
24 {
25 mygroup_t *mg;
26 char *desc = parv[1];
27
28 if (!(mg = mygroup_find(parv[0])))
29 {
30 command_fail(si, fault_nosuch_target, _("Group \2%s\2 does not exist."), parv[0]);
31 return;
32 }
33
34 if (!groupacs_sourceinfo_has_flag(mg, si, GA_SET))
35 {
36 command_fail(si, fault_noprivs, _("You are not authorized to execute this command."));
37 return;
38 }
39
40 if (!desc || !strcasecmp("OFF", desc) || !strcasecmp("NONE", desc))
41 {
42 /* not in a namespace to allow more natural use of SET PROPERTY.
43 * they may be able to introduce spaces, though. c'est la vie.
44 */
45 if (metadata_find(mg, "description"))
46 {
47 metadata_delete(mg, "description");
48 logcommand(si, CMDLOG_SET, "SET:DESCRIPTION:NONE: \2%s\2", entity(mg)->name);
49 command_success_nodata(si, _("The description for \2%s\2 has been cleared."), parv[0]);
50 return;
51 }
52
53 command_fail(si, fault_nochange, _("A description for \2%s\2 was not set."), parv[0]);
54 return;
55 }
56
57 /* we'll overwrite any existing metadata */
58 metadata_add(mg, "description", desc);
59
60 logcommand(si, CMDLOG_SET, "SET:DESCRIPTION: \2%s\2 \2%s\2", entity(mg)->name, desc);
61 command_success_nodata(si, _("The description of \2%s\2 has been set to \2%s\2."), parv[0], desc);
62 }
63
64 void _modinit(module_t *m)
65 {
66 use_groupserv_main_symbols(m);
67 use_groupserv_set_symbols(m);
68
69 command_add(&gs_set_description, gs_set_cmdtree);
70 }
71
72 void _moddeinit(module_unload_intent_t intent)
73 {
74 command_delete(&gs_set_description, gs_set_cmdtree);
75 }
76