| 1 |
pippijn |
1.8 |
/** |
| 2 |
|
|
* ftransfer.C: This file contains code for the ChanServ FTRANSFER function. |
| 3 |
|
|
* |
| 4 |
|
|
* Copyright © 2007 Pippijn van Steenhoven / The Ermyth Team |
| 5 |
|
|
* Rights to this code are as documented in COPYING. |
| 6 |
|
|
* |
| 7 |
|
|
* |
| 8 |
|
|
* Portions of this file were derived from sources bearing the following license: |
| 9 |
pippijn |
1.5 |
* Copyright © 2005 William Pitcock, et al. |
| 10 |
pippijn |
1.2 |
* Rights to this code are as documented in doc/pod/license.pod. |
| 11 |
pippijn |
1.1 |
* |
| 12 |
pippijn |
1.9 |
* $Id: ftransfer.C,v 1.8 2007-09-16 18:54:42 pippijn Exp $ |
| 13 |
pippijn |
1.1 |
*/ |
| 14 |
|
|
|
| 15 |
|
|
#include "atheme.h" |
| 16 |
pippijn |
1.9 |
#include <libermyth.h> |
| 17 |
pippijn |
1.5 |
#include <ermyth/module.h> |
| 18 |
pippijn |
1.1 |
#include <account/mychan.h> |
| 19 |
|
|
#include <account/myuser.h> |
| 20 |
|
|
#include <account/chanacs.h> |
| 21 |
|
|
|
| 22 |
pippijn |
1.9 |
static char const rcsid[] = "$Id: ftransfer.C,v 1.8 2007-09-16 18:54:42 pippijn Exp $"; |
| 23 |
pippijn |
1.1 |
|
| 24 |
pippijn |
1.9 |
REGISTER_MODULE ("chanserv/ftransfer", false, "The Ermyth Team <http://ermyth.xinutec.org>"); |
| 25 |
pippijn |
1.1 |
|
| 26 |
|
|
static void cs_cmd_ftransfer (sourceinfo_t *si, int parc, char *parv[]); |
| 27 |
|
|
|
| 28 |
pippijn |
1.5 |
command_t const cs_ftransfer = { "FTRANSFER", N_("Forces foundership transfer of a channel."), PRIV_CHAN_ADMIN, 2, cs_cmd_ftransfer }; |
| 29 |
pippijn |
1.1 |
|
| 30 |
pippijn |
1.5 |
E cmdvec cs_cmdtree; |
| 31 |
|
|
E helpvec cs_helptree; |
| 32 |
pippijn |
1.1 |
|
| 33 |
|
|
static void |
| 34 |
|
|
cs_cmd_ftransfer (sourceinfo_t *si, int parc, char *parv[]) |
| 35 |
|
|
{ |
| 36 |
|
|
myuser_t *tmu; |
| 37 |
|
|
mychan_t *mc; |
| 38 |
pippijn |
1.5 |
node_t *n; |
| 39 |
|
|
chanacs_t *ca; |
| 40 |
pippijn |
1.1 |
char *name = parv[0]; |
| 41 |
|
|
char *newfndr = parv[1]; |
| 42 |
pippijn |
1.5 |
char const *oldfndr; |
| 43 |
pippijn |
1.1 |
|
| 44 |
|
|
if (!name || !newfndr) |
| 45 |
|
|
{ |
| 46 |
pippijn |
1.7 |
command_fail (si, fault::needmoreparams, STR_INSUFFICIENT_PARAMS, "FTRANSFER"); |
| 47 |
|
|
command_fail (si, fault::needmoreparams, _("Syntax: FTRANSFER <#channel> <newfounder>")); |
| 48 |
pippijn |
1.1 |
return; |
| 49 |
|
|
} |
| 50 |
|
|
|
| 51 |
pippijn |
1.6 |
if (!(tmu = myuser_t::find_ext (newfndr))) |
| 52 |
pippijn |
1.1 |
{ |
| 53 |
pippijn |
1.7 |
command_fail (si, fault::nosuch_target, _("\2%s\2 is not registered."), newfndr); |
| 54 |
pippijn |
1.1 |
return; |
| 55 |
|
|
} |
| 56 |
|
|
|
| 57 |
pippijn |
1.7 |
if (!(mc = mychan_t::find (name))) |
| 58 |
pippijn |
1.1 |
{ |
| 59 |
pippijn |
1.7 |
command_fail (si, fault::nosuch_target, _("\2%s\2 is not registered."), name); |
| 60 |
pippijn |
1.1 |
return; |
| 61 |
|
|
} |
| 62 |
|
|
|
| 63 |
pippijn |
1.7 |
oldfndr = mc->founder_names (); |
| 64 |
pippijn |
1.5 |
if (!strcmp (tmu->name, oldfndr)) |
| 65 |
pippijn |
1.1 |
{ |
| 66 |
pippijn |
1.7 |
command_fail (si, fault::nochange, _("\2%s\2 is already the founder of \2%s\2."), tmu->name, name); |
| 67 |
pippijn |
1.1 |
return; |
| 68 |
|
|
} |
| 69 |
|
|
|
| 70 |
|
|
/* no maxchans check (intentional -- this is an oper command) */ |
| 71 |
pippijn |
1.5 |
|
| 72 |
|
|
snoop ("FTRANSFER: %s transferred %s from %s to %s", get_oper_name (si), name, oldfndr, tmu->name); |
| 73 |
|
|
wallops ("%s transferred foundership of %s from %s to %s", get_oper_name (si), name, oldfndr, tmu->name); |
| 74 |
|
|
logcommand (si, CMDLOG_ADMIN | LG_REGISTER, "%s FTRANSFER from %s to %s", mc->name, oldfndr, tmu->name); |
| 75 |
|
|
verbose (mc, "Foundership transfer from \2%s\2 to \2%s\2 forced by %s administration.", oldfndr, tmu->name, me.netname); |
| 76 |
|
|
command_success_nodata (si, _("Foundership of \2%s\2 has been transferred from \2%s\2 to \2%s\2."), name, oldfndr, tmu->name); |
| 77 |
|
|
|
| 78 |
|
|
LIST_FOREACH(n, mc->chanacs.head) |
| 79 |
|
|
{ |
| 80 |
|
|
ca = static_cast<chanacs_t *> (n->data); |
| 81 |
|
|
/* CA_FLAGS is always on if CA_FOUNDER is on, this just |
| 82 |
|
|
* ensures we don't crash if not -- jilles |
| 83 |
|
|
*/ |
| 84 |
|
|
if (ca->myuser != NULL && ca->level & CA_FOUNDER) |
| 85 |
|
|
chanacs_modify_simple(ca, CA_FLAGS, CA_FOUNDER); |
| 86 |
|
|
} |
| 87 |
pippijn |
1.1 |
mc->used = NOW; |
| 88 |
|
|
chanacs_change_simple (mc, tmu, NULL, CA_FOUNDER_0, 0); |
| 89 |
pippijn |
1.5 |
|
| 90 |
pippijn |
1.1 |
/* delete transfer metadata -- prevents a user from stealing it back */ |
| 91 |
|
|
mc->del_metadata ("private:verify:founderchg:newfounder"); |
| 92 |
|
|
mc->del_metadata ("private:verify:founderchg:timestamp"); |
| 93 |
|
|
} |
| 94 |
|
|
|
| 95 |
pippijn |
1.5 |
bool |
| 96 |
|
|
_modinit (module *m) |
| 97 |
|
|
{ |
| 98 |
|
|
cs_cmdtree << cs_ftransfer; |
| 99 |
|
|
help_addentry (cs_helptree, "FTRANSFER", "help/chanserv/ftransfer", NULL); |
| 100 |
|
|
|
| 101 |
|
|
return true; |
| 102 |
|
|
} |
| 103 |
|
|
|
| 104 |
|
|
void |
| 105 |
|
|
_moddeinit () |
| 106 |
|
|
{ |
| 107 |
|
|
cs_cmdtree >> cs_ftransfer; |
| 108 |
|
|
help_delentry (cs_helptree, "FTRANSFER"); |
| 109 |
|
|
} |