1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
|
/*
* Copyright (c) 2010 Atheme Development Group
* Rights to this code are as documented in doc/LICENSE.
*
* This file contains code for the CService CLEAR FLAGS functions.
*
*/
#include "atheme.h"
DECLARE_MODULE_V1
(
"chanserv/clear_flags", false, _modinit, _moddeinit,
PACKAGE_STRING,
VENDOR_STRING
);
static void cs_cmd_clear_flags(sourceinfo_t *si, int parc, char *parv[]);
command_t cs_clear_flags = { "FLAGS", "Clears all channel flags.", AC_NONE, 2, cs_cmd_clear_flags, { .path = "cservice/clear_flags" } };
mowgli_patricia_t **cs_clear_cmds;
void _modinit(module_t *m)
{
MODULE_TRY_REQUEST_SYMBOL(m, cs_clear_cmds, "chanserv/clear", "cs_clear_cmds");
command_add(&cs_clear_flags, *cs_clear_cmds);
}
void _moddeinit(module_unload_intent_t intent)
{
command_delete(&cs_clear_flags, *cs_clear_cmds);
}
static void cs_cmd_clear_flags(sourceinfo_t *si, int parc, char *parv[])
{
mychan_t *mc;
mowgli_node_t *n, *tn;
chanacs_t *ca;
char *name = parv[0];
int changes = 0;
if (!name)
{
command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "CLEAR FLAGS");
command_fail(si, fault_needmoreparams, "Syntax: CLEAR <#channel> FLAGS");
return;
}
if (!(mc = mychan_find(name)))
{
command_fail(si, fault_nosuch_target, "\2%s\2 is not registered.", name);
return;
}
if (metadata_find(mc, "private:close:closer"))
{
command_fail(si, fault_noprivs, "\2%s\2 is closed.", name);
return;
}
if (!mc->chan)
{
command_fail(si, fault_nosuch_target, "\2%s\2 does not exist.", name);
return;
}
if (!chanacs_source_has_flag(mc, si, CA_FOUNDER))
{
command_fail(si, fault_noprivs, "You are not authorized to perform this operation.");
return;
}
MOWGLI_ITER_FOREACH_SAFE(n, tn, mc->chanacs.head)
{
ca = n->data;
if (ca->level & CA_FOUNDER)
continue;
changes++;
object_unref(ca);
}
logcommand(si, CMDLOG_DO, "CLEAR:FLAGS: \2%s\2", mc->name);
command_success_nodata(si, _("Cleared flags in \2%s\2."), name);
if (changes > 0)
verbose(mc, _("\2%s\2 removed all %d non-founder access entries."),
get_source_name(si), changes);
}
/* vim:cinoptions=>s,e0,n0,f0,{0,}0,^0,=s,ps,t0,c3,+s,(2s,us,)20,*30,gs,hs
* vim:ts=8
* vim:sw=8
* vim:noexpandtab
*/
|