From: <de...@de...> - 2010-09-28 06:19:35
|
Author: PeterThoeny Date: 2010-09-28 01:19:27 -0500 (Tue, 28 Sep 2010) New Revision: 19515 Trac url: http://develop.twiki.org/trac/changeset/19515 Modified: twiki/trunk/core/lib/TWiki/UI/Manage.pm twiki/trunk/core/lib/TWiki/Users.pm Log: Item6528: Adding logic to process form data of "edit user account" form, works as expected with save action message instead of a less user-friendly oops message. Actual save of user data is pending. This is part of TWiki:Codev.SetFlagtoChangePassword feature Modified: twiki/trunk/core/lib/TWiki/UI/Manage.pm =================================================================== --- twiki/trunk/core/lib/TWiki/UI/Manage.pm 2010-09-28 06:06:21 UTC (rev 19514) +++ twiki/trunk/core/lib/TWiki/UI/Manage.pm 2010-09-28 06:19:27 UTC (rev 19515) @@ -62,6 +62,8 @@ } elsif ($action eq 'bulkRegister') { require TWiki::UI::Register; TWiki::UI::Register::bulkRegister( $session ); + } elsif( $action eq 'saveUserData' ) { + _saveUserData( $session ); } elsif( $action eq 'deleteUserAccount' ) { _removeUser( $session ); } elsif( $action eq 'editSettings' ) { @@ -79,6 +81,33 @@ } } +sub _saveUserData { + my $session = shift; + + my $webName = $session->{webName}; + my $topic = $session->{topicName}; + my $query = $session->{request}; + my $cUID = $session->{user}; + my $user = $query->param( 'user' ) || ''; + + if( $query->request_method() !~ /^POST$/i ) { + # manage script to save user data can only be called with POST method + throw TWiki::OopsException( + 'attention', + def => 'post_method_only', + web => $webName, + topic => $topic, + params => [ 'manage' ]); + } + +# FIXME + my $saveMsg = 'FIXME: Saving of user data'; + + my $url = $session->getScriptUrl( 1, 'view', $webName, $topic, + user => $user, saveMsg => $saveMsg ); + $session->redirect( $url, 0 ); +} + # Renames the *current* user's topic (with renaming all links) and # removes user entry from passwords. CGI parameters: sub _removeUser { Modified: twiki/trunk/core/lib/TWiki/Users.pm =================================================================== --- twiki/trunk/core/lib/TWiki/Users.pm 2010-09-28 06:06:21 UTC (rev 19514) +++ twiki/trunk/core/lib/TWiki/Users.pm 2010-09-28 06:19:27 UTC (rev 19515) @@ -1041,15 +1041,33 @@ my $data = $this->getUserData( $cUID ); if( $data ) { my $canModify = 0; - $text .= "<form>\n"; + $text .= '<form name="saveuserdata" action="%SCRIPTURLPATH{"manage"}%/' + . '%BASEWEB%/%BASETOPIC%" method="post">' . "\n"; + $text .= '<input type="hidden" name="action" value="saveUserData" />' . "\n"; + $text .= '<input type="hidden" name="user" value="' . $wikiName . '" />' . "\n"; $text .= "<noautolink>\n" . '%TABLE{ sort="off" }%' . "\n"; for( my $i=0; $i < scalar @$data; $i++ ) { $canModify = 1 if( $data->[$i]->{type} ne 'label' ); $text .= $this->_renderUserDataField( $data->[$i] ); } if( $canModify ) { - $text .= $this->_renderUserDataField( { type => 'submit', value => 'Save' } ); + $text .= $this->_renderUserDataField( + { + type => 'submit', + value => 'Save' + } ); } + my $cgiQuery = $this->{session}->{request}; + if( $cgiQuery && $cgiQuery->param('saveMsg') ) { + $text .= $this->_renderUserDataField( + { + type => 'label', + name => 'savemsg', + value => '<div style="color:#A6000B; background-color:#F5F4AB;' + . ' padding: 0 3px 0 3px"> %ICON{led-orange}% ' + . $cgiQuery->param( 'saveMsg' ) . '</div>' + } ); + } $text .= "</noautolink>\n</form>\n"; } @@ -1069,16 +1087,16 @@ my $cell2 = $field->{value}; if( $field->{type} =~ /^(text|password)$/ ) { $cell2 = '<input type="' . $field->{type} - . '" name="' . $field->{name} + . '" name="ud_' . $field->{name} . '" value="' . TWiki::entityEncode( $field->{value} ) - . '" size="' . $field->{size} + . '" size="' . $field->{size} . '" class="twikiInputField" />'; } elsif( $field->{type} eq 'checkbox' ) { $cell1 = ''; my $checked = $field->{value} ? '" checked="checked' : ''; $cell2 = '<input type="checkbox' - . '" name="' . $field->{name} - . '" id="' . $field->{name} + . '" name="ud_' . $field->{name} + . '" id="' . $field->{name} . $checked . '" class="twikiCheckbox" />' . '<label for="' . $field->{name} @@ -1090,6 +1108,7 @@ } else { # 'label' } + $cell2 .= ' <br />%ICON{tip}% ' . $field->{note} if( $field->{note} ); return( "| $cell1 | $cell2 |\n" ); |