[Greater-commits] r3860 - trunk/Administration
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Mon Dec 5 15:09:51 CET 2011
Author: bricks
Date: 2011-12-05 15:09:51 +0100 (Mon, 05 Dec 2011)
New Revision: 3860
Modified:
trunk/Administration/UserDialog.cpp
trunk/Administration/UserDialog.h
Log:
Allow to set the password during user creation
Add edit fields for setting the password in user create dialog
Modified: trunk/Administration/UserDialog.cpp
===================================================================
--- trunk/Administration/UserDialog.cpp 2011-12-05 14:06:39 UTC (rev 3859)
+++ trunk/Administration/UserDialog.cpp 2011-12-05 14:09:51 UTC (rev 3860)
@@ -110,6 +110,12 @@
//Create button
buttonCreate = new wxButton(this, ID_ButtonCreate, wxT("Create"));
+ // password labels
+ stextPassword1 = new wxStaticText(this, -1, wxT("Password:"));
+ stextPassword2 = new wxStaticText(this, -1, wxT("Confirm Password:"));
+ // password fields
+ textPassword1 = new wxTextCtrl(this, -1, wxT(""), wxDefaultPosition, wxDefaultSize, wxTE_PASSWORD);
+ textPassword2 = new wxTextCtrl(this, -1, wxT(""), wxDefaultPosition, wxDefaultSize, wxTE_PASSWORD);
//Set focus on first text control
textUser->SetFocus();
@@ -202,12 +208,35 @@
sizer_level_4_fg->Add(-1, DISTANCES / 2);
sizer_level_4_fg->Add(-1, -1);
sizer_level_4_fg->Add(-1, -1);
- //4th row (Label only)
+
+ if (type == 1) {
+ //4th row password1
+ sizer_level_4_fg->Add(stextPassword1, 0, wxALIGN_LEFT
+ | wxALIGN_CENTER_VERTICAL);
+ sizer_level_4_fg->Add(DISTANCES, -1);
+ sizer_level_4_fg->Add(textPassword1, 0, wxGROW);
+ //empty row as spacer
+ sizer_level_4_fg->Add(-1, DISTANCES / 2);
+ sizer_level_4_fg->Add(-1, -1);
+ sizer_level_4_fg->Add(-1, -1);
+ //5th row password2
+ sizer_level_4_fg->Add(stextPassword2, 0, wxALIGN_LEFT
+ | wxALIGN_CENTER_VERTICAL);
+ sizer_level_4_fg->Add(DISTANCES, -1);
+ sizer_level_4_fg->Add(textPassword2, 0, wxGROW);
+ //empty row as spacer
+ sizer_level_4_fg->Add(-1, DISTANCES / 2);
+ sizer_level_4_fg->Add(-1, -1);
+ sizer_level_4_fg->Add(-1, -1);
+ }
+
+ //6th row (Label only)
sizer_level_4_fg->Add(stextRemark, 0, wxALIGN_LEFT
| wxALIGN_CENTER_VERTICAL);
sizer_level_4_fg->Add(-1, -1);
sizer_level_4_fg->Add(-1, -1);
- //5th row (multi line text control)
+
+ //7th row (multi line text control)
sizer_level_3_v->Add(ftextRemark, 0, wxGROW);
//third column is flexible in size
sizer_level_4_fg->AddGrowableCol(2);
@@ -257,17 +286,22 @@
{
DA_T_errinfo errinfo;
DA_T_user p_userData;
+ char password[255];
wxString userName;
wxString groupId;
wxString status;
wxString remark;
wxString errMessage;
+ wxString password1;
+ wxString password2;
//Read input values from text and choice controls
userName = textUser->GetValue().MakeUpper();
groupId = choiceGroupId->GetStringSelection();
status = textStatus->GetValue();
remark = ftextRemark->GetValue();
+ password1 = textPassword1->GetValue();
+ password2 = textPassword2->GetValue();
//Check if all mandatory fields are filled
if (userName.IsEmpty() == true)
@@ -292,6 +326,21 @@
return;
}
+ if (password1.IsEmpty() == true)
+ {
+
+ wxMessageBox(wxT("Please enter Password"), wxT("Info"), wxOK | wxICON_INFORMATION, this);
+ textPassword1->SetFocus();
+ return;
+ }
+
+ if (password1 != password2)
+ {
+
+ wxMessageBox(wxT("Password did not match"), wxT("Info"), wxOK | wxICON_INFORMATION, this);
+ textPassword1->SetFocus();
+ return;
+ }
//Convert values to const char*
//Copy from const char* to char[]
@@ -303,12 +352,13 @@
strcpy(p_userData.mod_date, "dummy");
strcpy(p_userData.status, status.mb_str());
strcpy(p_userData.remark, remark.mb_str());
+ strcpy(password, password1.mb_str());
//Signal user, that the application is busy
wxBeginBusyCursor();
//Call API function for insert of data
- if (!da_insert_user (&p_userData, p_userData.user_id, &errinfo))
+ if (!da_insert_user (&p_userData, (char*)&password, &errinfo))
{
//Show error
((MainWindow*) GetParent()->GetGrandParent())->OnError(wxT("Create failed"), &errinfo);
Modified: trunk/Administration/UserDialog.h
===================================================================
--- trunk/Administration/UserDialog.h 2011-12-05 14:06:39 UTC (rev 3859)
+++ trunk/Administration/UserDialog.h 2011-12-05 14:09:51 UTC (rev 3860)
@@ -77,7 +77,11 @@
wxStaticText* stextGroupId;
wxStaticText* stextStatus;
wxStaticText* stextRemark;
+ wxStaticText* stextPassword1;
+ wxStaticText* stextPassword2;
wxTextCtrl* textUser;
+ wxTextCtrl* textPassword1;
+ wxTextCtrl* textPassword2;
wxChoice* choiceGroupId;
wxTextCtrl* textStatus;
FixedTextCtrl* ftextRemark;
More information about the Greater-commits
mailing list