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

NewThreadForm Class Reference

#include <NewThreadForm.h>

Inheritance diagram for NewThreadForm:

Inheritance graph
[legend]
Collaboration diagram for NewThreadForm:

Collaboration graph
[legend]
List of all members.

Public Member Functions

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

Private Attributes

bool m_bImageMissing
std::string m_title
std::string m_body
std::string m_filename

Detailed Description

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

Definition at line 31 of file NewThreadForm.h.


Constructor & Destructor Documentation

NewThreadForm::NewThreadForm Web *  w  ) 
 

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

Definition at line 32 of file NewThreadForm.cpp.

References NewThreadForm().

Referenced by NewThreadForm().

00032 : BaseForm(w, "NewThreadForm") 00033 ,m_bImageMissing(false) 00034 { 00035 }

NewThreadForm::~NewThreadForm  ) 
 

Definition at line 38 of file NewThreadForm.cpp.

00039 { 00040 }


Member Function Documentation

void NewThreadForm::Display long   ) 
 

Definition at line 100 of file NewThreadForm.cpp.

References Display(), m_bImageMissing, m_body, m_filename, and m_title.

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

00101 { 00102 IWeb *pWeb = static_cast<IWeb *>(GetWeb()); 00103 00104 // printf("<h3>New thread</h3>"); 00105 Navigator(pWeb -> GetForum(),-1); 00106 printf("</td><td align=right>"); 00107 // printf("<div align=right>"); 00108 printf("[ <a href=\"%s?page=2\">settings</a> ",GetCgiName().c_str()); 00109 printf("| <a href=\"%s?logout=1\">logout</a> ",GetCgiName().c_str()); 00110 // printf("]</div>"); 00111 printf("]</td></tr></table>"); 00112 printf("</div>"); 00113 00114 if (m_bImageMissing) 00115 { 00116 if (m_filename.size()) 00117 printf("<font class=error size=\"+2\">Image upload failed</font><br>"); 00118 else 00119 printf("<font class=error size=\"+2\">Image missing</font><br>"); 00120 } 00121 printf("<form action=\"%s\" method=post enctype=\"multipart/form-data\">", 00122 GetCgiName().c_str()); 00123 printf("Picture<br>"); 00124 printf("<input type=file name=the_file><br>"); 00125 printf("Title<br>"); 00126 printf("<input type=text name=title size=40 value=\"%s\"><br>",m_title.c_str()); 00127 printf("Message<br>"); 00128 printf("<textarea name=message rows=10 cols=80>%s</textarea><br>",m_body.c_str()); 00129 printf("<input type=submit name=\"%s\" value=\" Create topic \">",GetFormName().c_str()); 00130 printf("</form>"); 00131 }

void NewThreadForm::List  )  [inline]
 

Definition at line 40 of file NewThreadForm.h.

00040 {}

void NewThreadForm::Process  ) 
 

Definition at line 43 of file NewThreadForm.cpp.

References m_bImageMissing, m_body, m_filename, and m_title.

00044 { 00045 IWeb *pWeb = static_cast<IWeb *>(GetWeb()); 00046 Database& db = pWeb -> GetDatabase(); 00047 char action[200]; 00048 00049 // <input type="submit" name="NewThreadForm" value="action" ... 00050 if (GetForm() -> getvalue( (char *)GetFormName().c_str(), action, 200) && *action) 00051 { 00052 m_title = GetForm() -> getvalue("title"); 00053 m_body = GetForm() -> getvalue("message"); 00054 long image_num = 0; 00055 char fn[1000]; 00056 00057 GetForm() -> getvalue("the_file",fn,255); 00058 m_filename = fn; 00059 if (!strncmp(fn,"/tmp/",5) && strlen(fn) > 5) 00060 { 00061 image_num = AddImage(pWeb -> GetUsernum(), fn); 00062 } 00063 if (!image_num) 00064 { 00065 m_bImageMissing = true; 00066 return; 00067 } 00068 db::Forum forum(db,pWeb -> GetForum()); 00069 forum.updated = GetDate(); 00070 forum.updated_by = pWeb -> GetUsernum(); 00071 forum.save(); 00072 db::Thread thread(&db); 00073 thread.started_by = pWeb -> GetUsernum(); 00074 thread.started = GetDate(); 00075 thread.image = image_num; 00076 thread.forum = pWeb -> GetForum(); 00077 thread.title = m_title; 00078 thread.updated = GetDate(); 00079 thread.updated_by = pWeb -> GetUsernum(); 00080 thread.save(); 00081 db::Message message(&db); 00082 message.thread = thread.num; 00083 message.posted_by = pWeb -> GetUsernum(); 00084 message.posted = GetDate(); 00085 message.title = m_title; 00086 message.body = m_body; 00087 message.version = 1; 00088 message.updated = GetDate(); 00089 message.save(); 00090 db::Linkmessageimage x(&db); 00091 x.message = message.num; 00092 x.image = image_num; 00093 x.save(); 00094 pWeb -> SetThread( thread.num ); 00095 pWeb -> SetPage( 5 ); // View Thread 00096 } 00097 }

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

Definition at line 39 of file NewThreadForm.h.

References Select().

Referenced by Select().

00039 {}


Member Data Documentation

bool NewThreadForm::m_bImageMissing [private]
 

Definition at line 43 of file NewThreadForm.h.

Referenced by Display(), and Process().

std::string NewThreadForm::m_body [private]
 

Definition at line 45 of file NewThreadForm.h.

Referenced by Display(), and Process().

std::string NewThreadForm::m_filename [private]
 

Definition at line 46 of file NewThreadForm.h.

Referenced by Display(), and Process().

std::string NewThreadForm::m_title [private]
 

Definition at line 44 of file NewThreadForm.h.

Referenced by Display(), and Process().


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