Debian Codegraph @

modules/groupserv/set_url.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_url", false, _modinit, _moddeinit,
15 PACKAGE_STRING,
16 VENDOR_STRING
17 );
18
19 static void gs_cmd_set_url(sourceinfo_t *si, int parc, char *parv[]);
20
21 command_t gs_set_url = { "URL", N_("Sets the group URL."), AC_AUTHENTICATED, 2, gs_cmd_set_url, { .path = "groupserv/set_url" } };
22
23 static void gs_cmd_set_url(sourceinfo_t *si, int parc, char *parv[])
24 {
25 mygroup_t *mg;
26 char *url = 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 (!url || !strcasecmp("OFF", url) || !strcasecmp("NONE", url))
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, "url"))
46 {
47 metadata_delete(mg, "url");
48 logcommand(si, CMDLOG_SET, "SET:URL:NONE: \2%s\2", entity(mg)->name);
49 command_success_nodata(si, _("The URL for \2%s\2 has been cleared."), parv[0]);
50 return;
51 }
52
53 command_fail(si, fault_nochange, _("The URL for \2%s\2 was not set."), parv[0]);
54 return;
55 }
56
57 /* we'll overwrite any existing metadata */
58 metadata_add(mg, "url", url);
59
60 logcommand(si, CMDLOG_SET, "SET:URL: \2%s\2 \2%s\2", entity(mg)->name, url);
61 command_success_nodata(si, _("The URL of \2%s\2 has been set to \2%s\2."), parv[0], url);
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_url, gs_set_cmdtree);
70 }
71
72 void _moddeinit(module_unload_intent_t intent)
73 {
74 command_delete(&gs_set_url, gs_set_cmdtree);
75 }
76