Large MAPS update
[clearscm.git] / maps / bin / updateprofile.cgi
1 #!/usr/bin/perl
2 ################################################################################
3 #
4 # File:         $RCSfile: updateprofile.cgi,v $
5 # Revision:     $Revision: 1.1 $
6 # Description:  Update the users profile
7 # Author:       Andrew@DeFaria.com
8 # Created:      Mon Jan 16 20:25:32 PST 2006
9 # Modified:     $Date: 2013/06/12 14:05:47 $
10 # Language:     perl
11 #
12 # (c) Copyright 2000-2006, Andrew@DeFaria.com, all rights reserved.
13 #
14 ################################################################################
15 use strict;
16 use warnings;
17
18 use FindBin;
19 $0 = $FindBin::Script;
20
21 use lib "$FindBin::Bin/../lib";
22
23 use MAPS;
24 use MAPSWeb;
25
26 use CGI qw (:standard);
27
28 my $userid;
29 my $Userid;
30 my $fullname          = param('fullname');
31 my $email             = param('email');
32 my $old_password      = param('old_password');
33 my $new_password      = param('new_password');
34 my $repeated_password = param('repeated_password');
35 my $mapspop           = param('MAPSPOP');
36 my $history           = param('history');
37 my $days              = param('days');
38 my $dates             = param('dates');
39 my $tag_and_forward   = param('tag_and_forward');
40
41 sub Body {
42   my %options = (
43     MAPSPOP       => $mapspop,
44     History       => $history,
45     Page          => $days,
46     Dates         => $dates,
47     'Tag&Forward' => $tag_and_forward,
48   );
49
50   if ($old_password && $old_password ne '') {
51     my $dbpassword             = UserExists($userid);
52     my $encrypted_old_password = Encrypt($old_password, $userid);
53
54     if ($dbpassword ne $encrypted_old_password) {
55       DisplayError 'Your old password was not correct!';
56     } # if
57   } # if
58
59   if (UpdateUser($userid, $fullname, $email, $new_password) != 0) {
60     DisplayError "Unable to update user record for user $userid";
61   } # if
62
63   if (UpdateUserOptions($userid, %options) != 0) {
64     DisplayError "Unable to update user options for user $userid";
65   } # if
66
67   print h2 {-class => 'header',
68             -align => 'center'},
69     "${Userid}'s profile has been updated";
70 } # Body
71
72 $userid = Heading (
73   'getcookie',
74   '',
75   'Update Profile',
76   "Update user's profile",
77 );
78 $Userid = ucfirst $userid;
79
80 SetContext($userid);
81 NavigationBar($userid);
82 Body();
83 Footing();