/[H9]/trunk/tntnet/dynamic/adm_user_list.ecpp
ViewVC logotype

Contents of /trunk/tntnet/dynamic/adm_user_list.ecpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 101 - (show annotations) (download)
Thu Nov 29 13:59:21 2007 UTC (16 years, 5 months ago) by torben
File size: 1187 byte(s)
Finished administration module (?)

1 <%pre>
2 #include <tntdb/connect.h>
3 #include <tntdb/connection.h>
4 #include <tntdb/result.h>
5 #include <tntdb/row.h>
6 </%pre>
7
8 <%config>
9 dburl;
10 </%config>
11
12 <%session scope="global">
13 std::string userName;
14 bool isAdmin;
15 </%session>
16
17 <{
18 if (userName.size() == 0)
19 {
20 reply.setHeader("Location", "index");
21 return HTTP_MOVED_TEMPORARILY;
22 }
23 if (!isAdmin)
24 {
25 reply.setHeader("Location", "index");
26 return HTTP_MOVED_TEMPORARILY;
27 }
28 }>
29
30 <&header title="User administration">
31 </&header>
32 <h2>User administration</h2>
33
34 <a href="adm_user_edit?id=-1">Create new user</a><br>
35
36
37 <{
38 tntdb::Connection conn = tntdb::connect(dburl);
39
40 std::string query = "SELECT id, realname, username FROM users ORDER BY username ASC";
41
42 tntdb::Result res = conn.select(query);
43
44 std::ostream& out = reply.out();
45 if (res.size() > 0)
46 {
47 out << "<ul>";
48 for (int i=0; i<res.size(); ++i)
49 {
50 int id = res[i].getInt(0);
51 std::string realname = res[i].getString(1);
52 std::string username = res[i].getString(2);
53 out << "<li>";
54 out << "<a href='adm_user_edit?id=" << id << "'>" << username << "</a> - " << realname;
55 out << "</li>";
56 }
57 out << "</ul>";
58 }
59 else
60 {
61 out << "<i>No customers found!</i>";
62 }
63 }>
64
65 <&footer>
66 </&footer>

  ViewVC Help
Powered by ViewVC 1.1.20