00001
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
#include "IWeb.h"
00026
#include <libibank.h>
00027
#include "ForumsForm.h"
00028
00029
00030
00031
00032 ForumsForm::ForumsForm(Web *w) :
BaseForm(w, "
ForumsForm")
00033 {
00034 }
00035
00036
00037 ForumsForm::~ForumsForm()
00038 {
00039 }
00040
00041
00042 void ForumsForm::Process()
00043 {
00044
IWeb *pWeb = static_cast<IWeb *>(GetWeb());
00045
00046
char action[200];
00047
00048
00049
if (GetForm() -> getvalue( (
char *)GetFormName().c_str(), action, 200) && *action)
00050 {
00051
if (!strcmp(action,
"select"))
00052 {
00053
long nr = atol(GetForm() -> getvalue(
"forum").c_str());
00054 pWeb -> SetForum( nr );
00055 pWeb -> SetPage( 4 );
00056 }
00057 }
00058 }
00059
00060
00061 void ForumsForm::Display(
long)
00062 {
00063
IWeb *pWeb = static_cast<IWeb *>(GetWeb());
00064 Database& db = pWeb -> GetDatabase();
00065 Query q(db);
00066 Query q2(db);
00067 Query q3(db);
00068
char sql[1000];
00069
00070
00071 Navigator();
00072 printf(
"</td><td align=right>");
00073
00074 printf(
"[ <a href=\"%s?page=2\">settings</a> ",GetCgiName().c_str());
00075 printf(
"| <a href=\"%s?logout=1\">logout</a> ",GetCgiName().c_str());
00076
00077 printf(
"]</td></tr></table>");
00078 printf(
"</div>");
00079
00080 q.get_result(
"select * from forum where deleted=0 order by updated desc");
00081 printf(
"<table cellpadding=\"0\" cellspacing=\"0\" class=forums width=\"100%%\">");
00082 printf(
"<tr>");
00083 printf(
"<th class=forums align=left>Forum</th>");
00084 printf(
"<th class=forums align=left>Topics</th>");
00085 printf(
"<th class=forums align=left>Messages</th>");
00086 printf(
"<th class=forums align=left>Last</th>");
00087 printf(
"</tr>");
00088
while (q.fetch_row())
00089 {
00090 db::Forum x(&db, &q);
00091 db::Account account(db, x.updated_by);
00092
long qthreads = 0;
00093
long qmessages = 0;
00094
00095 sprintf(sql,
"select num from thread where forum=%ld and deleted=0",x.num);
00096 q2.get_result(sql);
00097
while (q2.fetch_row())
00098 {
00099
long num = q2.getval();
00100 sprintf(sql,
"select count(*) from message where thread=%ld and deleted=0",num);
00101 qmessages += q3.get_count(sql);
00102 qthreads++;
00103 }
00104 q2.free_result();
00105
00106 printf(
"<tr>");
00107 printf(
"<td class=forums><a href=\"%s?ForumsForm=select&forum=%ld\">%s</a></td>",
00108 GetCgiName().c_str(),x.num,x.name.c_str());
00109 printf(
"<td class=forums align=right width=\"1%%\">%ld</td>",qthreads);
00110 printf(
"<td class=forums align=right width=\"1%%\">%ld</td>",qmessages);
00111 printf(
"<td class=forums width=\"1%%\">");
00112 printf(
"%s<br>",GetAccountName(account).c_str());
00113 nbprintf(
"%s</td>", x.updated.c_str());
00114 printf(
"</tr>");
00115 }
00116 printf(
"</table>");
00117 q.free_result();
00118 }
00119
00120