Done with doxygenizing
[citadel.git] / webcit / userlist.c
1 /*
2  * $Id$
3  */
4 /**
5  * \defgroup AccDisplay Display a list of all accounts on a Citadel system.
6  *
7  */
8
9 /*@{*/
10 #include "webcit.h"
11
12 /** 
13  * \brief structure to keep namelists in
14  */
15 struct namelist {
16         struct namelist *next; /**< next item of the linked list */
17         char name[32];         /**< name of the userentry */
18 };
19
20 /**
21  * \brief display the userlist
22  */
23 void userlist(void)
24 {
25         char buf[256];
26         char fl[256];
27         char title[256];
28         struct tm tmbuf;
29         time_t lc;
30         struct namelist *bio = NULL;
31         struct namelist *bptr;
32         int has_bio;
33         int bg = 0;
34
35         serv_puts("LBIO");
36         serv_getln(buf, sizeof buf);
37         if (buf[0] == '1')
38                 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
39                         bptr = (struct namelist *) malloc(sizeof(struct namelist));
40                         bptr->next = bio;
41                         strcpy(bptr->name, buf);
42                         bio = bptr;
43                 }
44         output_headers(1, 1, 2, 0, 0, 0);
45         wprintf("<div id=\"banner\">\n"
46                 "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
47                 "<SPAN CLASS=\"titlebar\">");
48         snprintf(title, sizeof title, _("User list for %s"), serv_info.serv_humannode);
49         escputs(title);
50         wprintf("</SPAN>"
51                 "</TD></TR></TABLE>\n"
52                 "</div>\n<div id=\"content\">\n"
53         );
54
55         serv_puts("LIST");
56         serv_getln(buf, sizeof buf);
57         if (buf[0] != '1') {
58                 wprintf("<EM>%s</EM><br />\n", &buf[4]);
59                 goto DONE;
60         }
61
62         wprintf("<div class=\"fix_scrollbar_bug\">"
63                 "<table border=0 width=100%% bgcolor=\"#ffffff\"><tr><td>\n");
64         wprintf(_("<TR><TH>User Name</TH><TH>Number</TH><TH>Access Level</TH>"
65                 "<TH>Last Login</TH><TH>Total Logins</TH><TH>Total Posts</TH></TR>"));
66
67         while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
68                 extract_token(fl, buf, 0, '|', sizeof fl);
69                 has_bio = 0;
70                 for (bptr = bio; bptr != NULL; bptr = bptr->next) {
71                         if (!strcasecmp(fl, bptr->name))
72                                 has_bio = 1;
73                 }
74                 bg = 1 - bg;
75                 wprintf("<TR BGCOLOR=\"#%s\"><TD>",
76                         (bg ? "DDDDDD" : "FFFFFF")
77                 );
78                 if (has_bio) {
79                         wprintf("<a href=\"showuser&who=");
80                         urlescputs(fl);
81                         wprintf("\">");
82                         escputs(fl);
83                         wprintf("</A>");
84                 } else {
85                         escputs(fl);
86                 }
87                 wprintf("</TD><TD>%ld</TD><TD>%d</TD><TD>",
88                         extract_long(buf, 2),
89                         extract_int(buf, 1));
90                 lc = extract_long(buf, 3);
91                 localtime_r(&lc, &tmbuf);
92                 wprintf("%02d/%02d/%04d ",
93                         (tmbuf.tm_mon + 1),
94                         tmbuf.tm_mday,
95                         (tmbuf.tm_year + 1900));
96
97
98                 wprintf("</TD><TD>%ld</TD><TD>%5ld</TD></TR>\n",
99                         extract_long(buf, 4), extract_long(buf, 5));
100
101         }
102         wprintf("</table></div>\n");
103 DONE:   wDumpContent(1);
104 }
105
106
107 /**
108  * \brief Display (non confidential) information about a particular user
109  */
110 void showuser(void)
111 {
112         char who[256];
113         char buf[256];
114         int have_pic;
115
116         strcpy(who, bstr("who"));
117
118         output_headers(1, 1, 2, 0, 0, 0);
119         wprintf("<div id=\"banner\">\n"
120                 "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR>"
121                 "<TD><img src=\"static/usermanag_48x.gif\"></TD>"
122                 "<td align=left><SPAN CLASS=\"titlebar\">");
123         wprintf(_("User profile"));
124         wprintf("</SPAN>"
125                 "</TD></TR></TABLE>\n"
126                 "</div>\n<div id=\"content\">\n"
127         );
128
129         wprintf("<div class=\"fix_scrollbar_bug\">"
130                 "<table border=0 width=100%% bgcolor=\"#ffffff\"><tr><td>\n");
131
132         serv_printf("OIMG _userpic_|%s", who);
133         serv_getln(buf, sizeof buf);
134         if (buf[0] == '2') {
135                 have_pic = 1;
136                 serv_puts("CLOS");
137                 serv_getln(buf, sizeof buf);
138         } else {
139                 have_pic = 0;
140         }
141
142         wprintf("<CENTER><TABLE><TR><TD>");
143         if (have_pic == 1) {
144                 wprintf("<img src=\"image&name=_userpic_&parm=");
145                 urlescputs(who);
146                 wprintf("\">");
147         }
148         wprintf("</TD><TD><H1>%s</H1></TD></TR></TABLE></CENTER>\n", who);
149         serv_printf("RBIO %s", who);
150         serv_getln(buf, sizeof buf);
151         if (buf[0] == '1') {
152                 fmout("JUSTIFY");
153         }
154         wprintf("<br /><a href=\"display_page?recp=");
155         urlescputs(who);
156         wprintf("\">"
157                 "<img src=\"static/citadelchat_24x.gif\" "
158                 "ALIGN=MIDDLE BORDER=0>&nbsp;&nbsp;");
159         snprintf(buf, sizeof buf, _("Click here to send an instant message to %s"), who);
160         escputs(buf);
161         wprintf("</A>\n");
162
163         wprintf("</td></tr></table></div>\n");
164         wDumpContent(1);
165 }
166
167
168 /*@}*/