add cross autocomplete works for vector constructs
[sgn.git] / cgi-bin / solpeople / admin / quick_create_account.pl
blob063f1f712338c0008b51c27b1ea94c6531e15256
1 #!/usr/bin/perl -w
2 use strict;
3 use CXGN::DB::Connection;
4 use CXGN::Page;
5 use CXGN::Login;
6 use CXGN::People;
7 use HTML::Entities;
9 my $page=CXGN::Page->new("Create Account","john");
10 my $dbh = CXGN::DB::Connection->new();
12 my $logged_in_person_id=CXGN::Login->new($dbh)->verify_session();
13 my $logged_in_user=CXGN::People::Person->new($dbh, $logged_in_person_id);
14 my $logged_in_person_id=$logged_in_user->get_sp_person_id();
15 my $logged_in_username=$logged_in_user->get_first_name()." ".$logged_in_user->get_last_name();
16 my $logged_in_user_type=$logged_in_user->get_user_type();
17 if($logged_in_user_type eq 'curator') {
18 my($username,$password,$confirm_password,$email_address,$new_user_type,$first_name,$last_name)=$page->get_arguments(qw(username password confirm_password email_address user_type first_name last_name));
19 my $new_user_login=CXGN::People::Login->new($dbh);
20 if($username) {
21 my @fail=();
22 if(length($username)<7){push @fail,"Username is too short. Username must be 7 or more characters";}
23 my $existing_login=CXGN::People::Login->get_login($dbh, $username);
24 if($existing_login->get_username()){push @fail,"Username \"$username\" is already in use. Please pick a different username.";}
25 if(length($password)<7){push @fail,"Password is too short. Password must be 7 or more characters";}
26 if("$password" ne "$confirm_password"){push @fail,"Password and confirm password do not match.";}
27 if($password eq $username){push @fail,"Password must not be the same as your username.";}
28 if($new_user_type ne 'user' and $new_user_type ne 'sequencer' and $new_user_type ne 'submitter'){push @fail,"Sorry, but you cannot create user of type \"$new_user_type\" with web interface.";}
29 if(@fail)
31 my $fail_str="";
32 foreach(@fail)
34 $fail_str .= "<li>$_</li>\n"
36 $page->header();
37 print <<END_HTML;
39 <table width=80% align=center>
40 <tr><td>
41 <p>Your account could not be created for the following reasons</p>
42 <ul>
43 $fail_str
44 </ul>
45 <p>Please use your browser\'s back button to try again.</p>
46 </td></tr>
47 <tr><td><br /></td></tr>
48 </table>
49 END_HTML
50 $page->footer();
52 else {
53 $new_user_login->set_username(encode_entities($username));
54 $new_user_login->set_password($password);
55 $new_user_login->set_private_email(encode_entities($email_address));
56 $new_user_login->set_user_type(encode_entities($new_user_type));
57 $new_user_login->store();
58 my $new_user_person_id=$new_user_login->get_sp_person_id();
59 my $new_user_person=CXGN::People::Person->new($dbh, $new_user_person_id);
60 $new_user_person->set_first_name(encode_entities($first_name));
61 $new_user_person->set_last_name(encode_entities($last_name));
62 ##removed. This was causing problems with creating new accounts for people,
63 ##and then not finding it in the people search.
64 #$new_user_person->set_censor(1);#censor by default, since we are creating this account, not the person whose info might be displayed, and they might not want it to be displayed
65 $new_user_person->store();
66 $page->header();
67 print <<END_HTML;
69 <table width=80% align=center>
70 <tr><td><p>Account was created with username "$username".</p></td></tr>
71 <tr><td><br /></td></tr>
72 </table>
74 END_HTML
75 $page->footer();
78 else
80 $page->header();
81 print <<END_HTML;
83 <form method="post" action="quick_create_account.pl">
84 <table cellpadding="2" cellspacing="2" width="100%" align="center">
85 <tr><td colspan="2"><b>Curators may use this form to create accounts for new users.<br />&nbsp;</b></td></tr>
86 <tr><td>First Name</td><td><input type="text" name="first_name" size="20" value=""></td></tr>
87 <tr><td>Last Name</td><td><input type="text" name="last_name" size="20" value=""></td></tr>
88 <tr><td>Username (at least 7 characters)</td><td><input type="text" name="username" size="12" value=""></td></tr>
89 <tr><td>Password (at least 7 characters)</td><td><input type="password" name="password" size="12" value=""></td></tr>
90 <tr><td>Confirm Password</td><td><input type="password" name="confirm_password" size="12" value=""></td></tr>
91 <tr><td>Private Email Address</td><td><input type="text" name="confirm_email" size="40" value=""></td></tr>
92 <tr><td>User Type</td><td><input type="text" name="user_type" size="10" value=""></td></tr>
93 <tr><td>&nbsp;</td></tr>
94 <tr><td colspan="2" align="center"><input type="submit" name="create_account" value="Create Account"></td></tr>
95 </table>
96 <br />
98 END_HTML
100 $page->footer();
103 else
105 $page->client_redirect('/solpeople/login.pl');