Google
Web alhem.net
Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

ForumsForm.cpp

Go to the documentation of this file.
00001 00006 /* 00007 Copyright (C) 2004 Anders Hedstrom 00008 00009 This program is free software; you can redistribute it and/or 00010 modify it under the terms of the GNU General Public License 00011 as published by the Free Software Foundation; either version 2 00012 of the License, or (at your option) any later version. 00013 00014 This program is distributed in the hope that it will be useful, 00015 but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 GNU General Public License for more details. 00018 00019 You should have received a copy of the GNU General Public License 00020 along with this program; if not, write to the Free Software 00021 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00022 */ 00023 //#include <stdio.h> 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 // Database& db = pWeb -> GetDatabase(); 00046 char action[200]; 00047 00048 // <input type="submit" name="ForumsForm" value="action" ... 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 // printf("<h3>Forums</h3>"); 00071 Navigator(); 00072 printf("</td><td align=right>"); 00073 // printf("<div align=right>"); 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 // printf("]</div>"); 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

Generated on Sat Feb 12 00:14:56 2005 for IBank by doxygen 1.3.7