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

NewMessageForm.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 "NewMessageForm.h" 00027 00028 00029 00030 00031 NewMessageForm::NewMessageForm(Web *w) : BaseForm(w, "NewMessageForm") 00032 { 00033 } 00034 00035 00036 NewMessageForm::~NewMessageForm() 00037 { 00038 } 00039 00040 00041 void NewMessageForm::Process() 00042 { 00043 IWeb *pWeb = static_cast<IWeb *>(GetWeb()); 00044 Database& db = pWeb -> GetDatabase(); 00045 char action[200]; 00046 00047 // <input type="submit" name="NewMessageForm" value="action" ... 00048 if (GetForm() -> getvalue( (char *)GetFormName().c_str(), action, 200) && *action) 00049 { 00050 std::string title = GetForm() -> getvalue("title"); 00051 std::string message_body = GetForm() -> getvalue("message"); 00052 long image_num = 0; 00053 char fn[1000]; 00054 00055 GetForm() -> getvalue("the_file",fn,255); 00056 if (!strncmp(fn,"/tmp/",5) && strlen(fn) > 5) 00057 { 00058 image_num = AddImage(pWeb -> GetUsernum(), fn); 00059 } 00060 db::Forum forum(db,pWeb -> GetForum()); 00061 forum.updated = GetDate(); 00062 forum.updated_by = pWeb -> GetUsernum(); 00063 forum.save(); 00064 db::Thread thread(db,pWeb -> GetThread()); 00065 thread.updated = GetDate(); 00066 thread.updated_by = pWeb -> GetUsernum(); 00067 thread.save(); 00068 db::Message message(&db); 00069 message.thread = pWeb -> GetThread(); 00070 message.posted_by = pWeb -> GetUsernum(); 00071 message.posted = GetDate(); 00072 message.title = title; 00073 message.body = message_body; 00074 message.version = 1; 00075 message.updated = GetDate(); 00076 message.save(); 00077 if (image_num > 0) 00078 { 00079 db::Linkmessageimage x(&db); 00080 x.message = message.num; 00081 x.image = image_num; 00082 x.save(); 00083 } 00084 pWeb -> SetPage( 5 ); // View Thread 00085 } 00086 } 00087 00088 00089 void NewMessageForm::Display(long) 00090 { 00091 IWeb *pWeb = static_cast<IWeb *>(GetWeb()); 00092 00093 // printf("<h3>Post message</h3>"); 00094 Navigator(pWeb -> GetForum(),pWeb -> GetThread(),-1); 00095 printf("</td><td align=right>"); 00096 // printf("<div align=right>"); 00097 printf("[ <a href=\"%s?page=2\">settings</a> ",GetCgiName().c_str()); 00098 printf("| <a href=\"%s?logout=1\">logout</a> ",GetCgiName().c_str()); 00099 // printf("]</div>"); 00100 printf("]</td></tr></table>"); 00101 printf("</div>"); 00102 00103 printf("<form action=\"%s\" method=post enctype=\"multipart/form-data\">", 00104 GetCgiName().c_str()); 00105 printf("Picture (optional)<br>"); 00106 printf("<input type=file name=the_file><br>"); 00107 printf("Title<br>"); 00108 printf("<input type=text name=title size=40><br>"); 00109 printf("Message<br>"); 00110 printf("<textarea name=message rows=10 cols=80></textarea><br>"); 00111 printf("<input type=submit name=\"%s\" value=\" Post \">",GetFormName().c_str()); 00112 printf("</form>"); 00113 } 00114 00115

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