| 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_open", false, _modinit, _moddeinit, |
| 15 |
PACKAGE_STRING, |
| 16 |
VENDOR_STRING |
| 17 |
); |
| 18 |
|
| 19 |
static void gs_cmd_set_open(sourceinfo_t *si, int parc, char *parv[]); |
| 20 |
|
| 21 |
command_t gs_set_open = { "OPEN", N_("Sets the group as open for anyone to join."), AC_AUTHENTICATED, 2, gs_cmd_set_open, { .path = "groupserv/set_open" } }; |
| 22 |
|
| 23 |
static void gs_cmd_set_open(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, "OPEN"); |
| 30 |
command_fail(si, fault_needmoreparams, _("Syntax: OPEN <!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 (!gs_config->enable_open_groups) |
| 49 |
{ |
| 50 |
command_fail(si, fault_nochange, _("Setting groups as open has been administratively disabled.")); |
| 51 |
return; |
| 52 |
} |
| 53 |
|
| 54 |
if (mg->flags & MG_OPEN) |
| 55 |
{ |
| 56 |
command_fail(si, fault_nochange, _("\2%s\2 is already open to anyone joining."), entity(mg)->name); |
| 57 |
return; |
| 58 |
} |
| 59 |
|
| 60 |
mg->flags |= MG_OPEN; |
| 61 |
|
| 62 |
logcommand(si, CMDLOG_SET, "OPEN:ON: \2%s\2", entity(mg)->name); |
| 63 |
command_success_nodata(si, _("\2%s\2 is now open to anyone joining."), entity(mg)->name); |
| 64 |
} |
| 65 |
else if (!strcasecmp(parv[1], "OFF")) |
| 66 |
{ |
| 67 |
if (!(mg->flags & MG_OPEN)) |
| 68 |
{ |
| 69 |
command_fail(si, fault_nochange, _("\2%s\2 is already not open to anyone joining."), entity(mg)->name); |
| 70 |
return; |
| 71 |
} |
| 72 |
|
| 73 |
mg->flags &= ~MG_OPEN; |
| 74 |
|
| 75 |
logcommand(si, CMDLOG_SET, "OPEN:OFF: \2%s\2", entity(mg)->name); |
| 76 |
command_success_nodata(si, _("\2%s\2 is no longer open to anyone joining."), entity(mg)->name); |
| 77 |
} |
| 78 |
else |
| 79 |
{ |
| 80 |
command_fail(si, fault_badparams, STR_INVALID_PARAMS, "OPEN"); |
| 81 |
command_fail(si, fault_badparams, _("Syntax: OPEN <!group> <ON|OFF>")); |
| 82 |
} |
| 83 |
} |
| 84 |
|
| 85 |
void _modinit(module_t *m) |
| 86 |
{ |
| 87 |
use_groupserv_main_symbols(m); |
| 88 |
use_groupserv_set_symbols(m); |
| 89 |
|
| 90 |
command_add(&gs_set_open, gs_set_cmdtree); |
| 91 |
} |
| 92 |
|
| 93 |
void _moddeinit(module_unload_intent_t intent) |
| 94 |
{ |
| 95 |
command_delete(&gs_set_open, gs_set_cmdtree); |
| 96 |
} |
| 97 |
|