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

SettingsForm.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 "SettingsForm.h" 00027 00028 00029 00030 00031 SettingsForm::SettingsForm(Web *w) : BaseForm(w, "SettingsForm") 00032 { 00033 } 00034 00035 00036 SettingsForm::~SettingsForm() 00037 { 00038 } 00039 00040 00041 void SettingsForm::Process() 00042 { 00043 IWeb *pWeb = static_cast<IWeb *>(GetWeb()); 00044 Database& db = pWeb -> GetDatabase(); 00045 char action[200]; 00046 00047 // <input type="submit" name="SettingsForm" value="action" ... 00048 if (!GetForm() -> getvalue( (char *)GetFormName().c_str(), action, 200) || !*action) 00049 { 00050 return; 00051 } 00052 if (!strcmp(action," Save changes ")) 00053 { 00054 db::Account account(db, pWeb -> GetUsernum()); 00055 account.show_email = atoi(GetForm() -> getvalue("show_email").c_str()); 00056 std::string old = GetForm() -> getvalue("old"); 00057 std::string new_password = GetForm() -> getvalue("new_password"); 00058 std::string new_password2 = GetForm() -> getvalue("new_password2"); 00059 if (!strcmp(old.c_str(),account.secret.c_str())) 00060 { 00061 if (new_password.size() >= 4 && !strcmp(new_password.c_str(),new_password2.c_str())) 00062 { 00063 account.secret = new_password; 00064 } 00065 } 00066 account.save(); 00067 } 00068 if (!strcmp(action," Return to forums ")) 00069 { 00070 pWeb -> SetPage( 3 ); 00071 } 00072 } 00073 00074 00075 void SettingsForm::Display(long) 00076 { 00077 IWeb *pWeb = static_cast<IWeb *>(GetWeb()); 00078 Database& db = pWeb -> GetDatabase(); 00079 db::Account account(db, pWeb -> GetUsernum()); 00080 00081 // printf("<h3>User settings</h3>"); 00082 printf("<div class=navigator>"); 00083 printf("<table cellpadding=0 cellspacing=0 width=\"100%%\"><tr><td>"); 00084 printf("<b>Settings</b>"); 00085 printf("</td><td align=right>"); 00086 // printf("<div align=right>"); 00087 printf("[ <a href=\"%s?page=3\">forums</a> ",GetCgiName().c_str()); 00088 printf("| <a href=\"%s?logout=1\">logout</a> ",GetCgiName().c_str()); 00089 // printf("]</div>"); 00090 printf("]</td></tr></table>"); 00091 printf("</div>"); 00092 00093 printf("<form action=\"%s\" method=post>",GetCgiName().c_str()); 00094 00095 printf("<p><b>Email</b>: %s</p>",account.email.c_str()); 00096 printf("<p><b>Name</b>: %s</p>",account.name.c_str()); 00097 printf("<p>"); 00098 printf("<input type=checkbox name=show_email value=1%s> Show email when posting<br>", 00099 account.show_email ? " CHECKED" : ""); 00100 printf("</p><p>"); 00101 printf("Enter old password to change<br>"); 00102 printf("<input type=password name=old><br>"); 00103 printf("</p><p>"); 00104 printf("Enter new password<br>"); 00105 printf("<input type=new_password><br>"); 00106 printf("</p><p>"); 00107 printf("Repeat new password<br>"); 00108 printf("<input type=new_password2><br>"); 00109 printf("</p>"); 00110 printf("&nbsp;&nbsp;&nbsp;&nbsp;"); 00111 printf("<input type=submit name=\"%s\" value=\" Save changes \">",GetFormName().c_str()); 00112 printf("&nbsp;&nbsp;&nbsp;&nbsp;"); 00113 printf("<input type=submit name=\"%s\" value=\" Return to forums \">",GetFormName().c_str()); 00114 printf("</form>"); 00115 } 00116 00117

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