ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/ermyth/modules/chanserv/ftransfer.C
Revision: 1.7
Committed: Thu Aug 30 19:56:21 2007 UTC (19 years, 2 months ago) by pippijn
Content type: text/plain
Branch: MAIN
Changes since 1.6: +9 -9 lines
Log Message:
- put faultcodes into their own namespace
- removed old files
- limited header garbage in atheme.h
- macros to inline bools for connection_t::is_*
- put some connection_t functions into the connection_t class

File Contents

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