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

ViewThreadForm Class Reference

#include <ViewThreadForm.h>

Inheritance diagram for ViewThreadForm:

Inheritance graph
[legend]
Collaboration diagram for ViewThreadForm:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ViewThreadForm (Web *)
 ~ViewThreadForm ()
void Process ()
void Display (long)
void Select (const std::string &)
void List ()

Detailed Description

File ......... ViewThreadForm.h Published .... 2004-07-09 Author ....... grymse@alhem.net

Definition at line 31 of file ViewThreadForm.h.


Constructor & Destructor Documentation

ViewThreadForm::ViewThreadForm Web *  w  ) 
 

File ......... ViewThreadForm.cpp Published .... 2004-07-09 Author ....... grymse@alhem.net

Definition at line 33 of file ViewThreadForm.cpp.

References ViewThreadForm().

Referenced by ViewThreadForm().

00033 : BaseForm(w, "ViewThreadForm") 00034 { 00035 }

ViewThreadForm::~ViewThreadForm  ) 
 

Definition at line 38 of file ViewThreadForm.cpp.

00039 { 00040 }


Member Function Documentation

void ViewThreadForm::Display long   ) 
 

Definition at line 75 of file ViewThreadForm.cpp.

References Display().

Referenced by Display(), and IWeb::GenerateDocument().

00076 { 00077 IWeb *pWeb = static_cast<IWeb *>(GetWeb()); 00078 Database& db = pWeb -> GetDatabase(); 00079 Query q(db); 00080 Query q2(db); 00081 char sql[1000]; 00082 std::map<long,long> mmap; 00083 db::Thread thread(db, pWeb -> GetThread()); 00084 00085 // printf("<h3>View thread</h3>"); 00086 Navigator(pWeb -> GetForum(),pWeb -> GetThread()); 00087 printf("</td><td align=center>"); 00088 printf("[ <a href=\"%s?page=7\">post message</a> ",GetCgiName().c_str()); 00089 if (thread.started_by == pWeb -> GetUsernum()) 00090 { 00091 printf("| <a href=\"%s?ViewThreadForm=delete\">remove topic</a> ",GetCgiName().c_str()); 00092 } 00093 printf("]</td><td align=right>"); 00094 // printf("<div align=right>"); 00095 printf("[ <a href=\"%s?page=2\">settings</a> ",GetCgiName().c_str()); 00096 printf("| <a href=\"%s?logout=1\">logout</a> ",GetCgiName().c_str()); 00097 // printf("]</div>"); 00098 printf("]</td></tr></table>"); 00099 printf("</div>"); 00100 00101 00102 sprintf(sql,"select num,version from message where thread=%ld",pWeb -> GetThread()); 00103 q.get_result(sql); 00104 while (q.fetch_row()) 00105 { 00106 long num = q.getval(); 00107 long version = q.getval(); 00108 mmap[num] = (version > mmap[num]) ? version : mmap[num]; 00109 } 00110 q.free_result(); 00111 00112 sprintf(sql,"select * from message where thread=%ld and deleted=0 order by posted",pWeb -> GetThread()); 00113 q.get_result(sql); 00114 printf("<table cellpadding=\"0\" cellspacing=\"0\" class=viewthread width=\"100%%\">"); 00115 while (q.fetch_row()) 00116 { 00117 db::Message message(&db,&q); 00118 if (message.version == mmap[message.num]) 00119 { 00120 db::Account account(db,message.posted_by); 00121 printf("<tr>"); 00122 printf("<th class=viewthread width=\"1%%\" align=left>"); 00123 printf("%s<br>",GetAccountName(account).c_str()); 00124 nbprintf("%s",message.posted.c_str()); 00125 if (message.version > 1) 00126 { 00127 printf("<br><span class=updated>Version: %d<br>",message.version); 00128 nbprintf("%s</span>",message.updated.c_str()); 00129 } 00130 printf("</th>"); 00131 printf("<td class=viewthread><b>%s</b>",message.title.c_str()); 00132 if (message.posted_by == pWeb -> GetUsernum()) 00133 { 00134 printf(" [ <a href=\"%s?ViewThreadForm=edit&message=%ld\">edit message</a> ]",GetCgiName().c_str(),message.num); 00135 } 00136 printf("<br>"); 00137 viewtext(message.body); 00138 sprintf(sql,"select * from linkmessageimage where message=%ld and deleted=0",message.num); 00139 q2.get_result(sql); 00140 if (q2.num_rows() > 0) 00141 { 00142 printf("<hr>"); 00143 } 00144 while (q2.fetch_row()) 00145 { 00146 db::Linkmessageimage x(&db,&q2); 00147 printf("&nbsp;&nbsp;"); 00148 viewtn( x.image ); 00149 // printf("<a href=\"%s?img=%ld\">",GetCgiName().c_str(),x.image); 00150 // printf("<img alt=\"Thumbnail\" border=\"0\" src=\"%s?imgtn=%ld\"></a> ",GetCgiName().c_str(),x.image); 00151 } 00152 q2.free_result(); 00153 printf("</tr>"); 00154 } 00155 } 00156 printf("</table>"); 00157 q.free_result(); 00158 }

void ViewThreadForm::List  )  [inline]
 

Definition at line 40 of file ViewThreadForm.h.

00040 {}

void ViewThreadForm::Process  ) 
 

Definition at line 43 of file ViewThreadForm.cpp.

00044 { 00045 IWeb *pWeb = static_cast<IWeb *>(GetWeb()); 00046 Database& db = pWeb -> GetDatabase(); 00047 char action[200]; 00048 00049 // <input type="submit" name="ViewThreadForm" value="action" ... 00050 if (!GetForm() -> getvalue( (char *)GetFormName().c_str(), action, 200) || !*action) 00051 { 00052 return; 00053 } 00054 if (!strcmp(action,"edit")) 00055 { 00056 std::string message = GetForm() -> getvalue("message"); 00057 long num = atol(message.c_str()); 00058 pWeb -> SetMessage(num); 00059 pWeb -> SetPage( 8 ); 00060 } 00061 else 00062 if (!strcmp(action,"delete")) 00063 { 00064 db::Thread thread(db, pWeb -> GetThread()); 00065 if (thread.started_by == pWeb -> GetUsernum()) 00066 { 00067 thread.deleted++; 00068 thread.save(); 00069 } 00070 pWeb -> SetPage( 4 ); 00071 } 00072 }

void ViewThreadForm::Select const std::string &   )  [inline]
 

Definition at line 39 of file ViewThreadForm.h.

References Select().

Referenced by Select().

00039 {}


The documentation for this class was generated from the following files:
Generated on Sat Feb 12 00:14:57 2005 for IBank by doxygen 1.3.7