ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/ermyth/modules/chanserv/ftransfer.C
Revision: 1.5
Committed: Tue Aug 28 17:08:07 2007 UTC (19 years, 1 month ago) by pippijn
Content type: text/plain
Branch: MAIN
Changes since 1.4: +46 -48 lines
Log Message:
- changed name
- updated the example config to the new system
- added more documentation
- enhanced documentation generators
- added a link to the pdf to the website
- added an RSS feed generator
- transitioned hooks to c++ callbacks
- did various merges with upstream along the way
- added const where appropriate
- removed the old block allocator
- fixed most memory leaks
- transitioned some dictionaries to std::map
- transitioned some lists to std::vector
- made some free functions members where appropriate
- renamed string to dynstr and added a static string ststr
- use NOW instead of time (NULL) if possible
- completely reworked database backends, crypto handlers and protocol handlers
  to use an object factory
- removed the old module system. ermyth does not do any dynamic loading anymore
- fixed most of the build system
- reworked how protocol commands work

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.5 * $Id: ftransfer.C,v 1.4 2007-07-22 18:38:42 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.5 static char const rcsid[] = "$Id: ftransfer.C,v 1.4 2007-07-22 18:38:42 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     command_fail (si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "FTRANSFER");
41     command_fail (si, fault_needmoreparams, _("Syntax: FTRANSFER <#channel> <newfounder>"));
42     return;
43     }
44    
45     if (!(tmu = myuser_find_ext (newfndr)))
46     {
47     command_fail (si, fault_nosuch_target, _("\2%s\2 is not registered."), newfndr);
48     return;
49     }
50    
51     if (!(mc = mychan_find (name)))
52     {
53     command_fail (si, fault_nosuch_target, _("\2%s\2 is not registered."), name);
54     return;
55     }
56    
57 pippijn 1.5 oldfndr = mychan_founder_names (mc);
58     if (!strcmp (tmu->name, oldfndr))
59 pippijn 1.1 {
60     command_fail (si, fault_nochange, _("\2%s\2 is already the founder of \2%s\2."), tmu->name, name);
61     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     }