ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/ermyth/modules/nickserv/taxonomy.C
Revision: 1.9
Committed: Sat Sep 22 14:27:28 2007 UTC (16 years, 8 months ago) by pippijn
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.8: +3 -3 lines
Log Message:
split up ermyth into ermyth-modules, libermyth (currently just ermyth-util) and ermyth-core

File Contents

# Content
1 /**
2 * taxonomy.C: Lists object properties via their metadata table.
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 * Copyright © 2005 William Pitcock, et al.
10 * Rights to this code are as documented in doc/pod/license.pod.
11 *
12 * $Id: taxonomy.C,v 1.8 2007-09-16 18:54:43 pippijn Exp $
13 */
14
15 #include "atheme.h"
16 #include <ermyth/module.h>
17 #include <account/myuser.h>
18
19 static char const rcsid[] = "$Id: taxonomy.C,v 1.8 2007-09-16 18:54:43 pippijn Exp $";
20
21 REGISTER_MODULE ("nickserv/taxonomy", false, "The Ermyth Team <http://ermyth.xinutec.org>");
22
23 static void ns_cmd_taxonomy (sourceinfo_t *si, int parc, char *parv[]);
24
25 command_t const ns_taxonomy = { "TAXONOMY", N_("Displays a user's metadata."), AC_NONE, 1, ns_cmd_taxonomy };
26
27 E cmdvec ns_cmdtree;
28 E helpvec ns_helptree;
29
30 bool
31 _modinit (module *m)
32 {
33 ns_cmdtree << ns_taxonomy;
34 help_addentry (ns_helptree, "TAXONOMY", "help/nickserv/taxonomy", NULL);
35
36 return true;
37 }
38
39 void
40 _moddeinit ()
41 {
42 ns_cmdtree >> ns_taxonomy;
43 help_delentry (ns_helptree, "TAXONOMY");
44 }
45
46 static void
47 ns_cmd_taxonomy (sourceinfo_t *si, int parc, char *parv[])
48 {
49 char *target = parv[0];
50 myuser_t *mu;
51 bool isoper;
52 metadata::map_type::iterator mumdit, mumdit_end;
53
54 if (!target)
55 {
56 command_fail (si, fault::needmoreparams, STR_INSUFFICIENT_PARAMS, "TAXONOMY");
57 command_fail (si, fault::needmoreparams, _("Syntax: TAXONOMY <nick>"));
58 return;
59 }
60
61 if (!(mu = myuser_t::find_ext (target)))
62 {
63 command_fail (si, fault::badparams, _("\2%s\2 is not registered."), target);
64 return;
65 }
66
67 isoper = has_priv (si, PRIV_USER_AUSPEX);
68 if (isoper)
69 logcommand (si, CMDLOG_ADMIN, "TAXONOMY %s (oper)", target);
70 else
71 logcommand (si, CMDLOG_GET, "TAXONOMY %s", target);
72
73 command_success_nodata (si, _("Taxonomy for \2%s\2:"), target);
74
75 for (mumdit = mu->mdmap.begin (), mumdit_end = mu->mdmap.end (); mumdit != mumdit_end; ++mumdit)
76 {
77 metadata *md = mumdit->second;
78 if (md->is_private == true && !isoper)
79 continue;
80
81 command_success_nodata (si, "%-32s: %s", md->key, md->value);
82 }
83
84 command_success_nodata (si, _("End of \2%s\2 taxonomy."), target);
85 }