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