4 use OpenILS::Application::Storage;
5 use OpenILS::Application::Storage::CDBI;
7 # I need to abstract the driver loading away...
8 use OpenILS::Application::Storage::Driver::Pg;
10 use CGI qw/:standard start_*/;
12 OpenILS::Application::Storage::CDBI->connection('dbi:Pg:host=10.0.0.2;dbname=open-ils-dev', 'postgres');
13 OpenILS::Application::Storage::CDBI->db_Main->{ AutoCommit } = 1;
17 #-------------------------------------------------------------------------------
19 #-------------------------------------------------------------------------------
22 Content-type: text/html
29 border: dashed lightgrey 1px;
30 background-color: #EEE;
31 border-collapse: collapse;
39 border: solid lightgrey 1px;
43 background-color: lightblue;
47 <body style='padding: 25px;'>
49 <h1>Superuser Setup</h1>
54 #-------------------------------------------------------------------------------
56 #-------------------------------------------------------------------------------
59 qw/id SysID active Active usrname Username profile UserProfile passwd Password prefix Prefix
60 first_given_name FirstName second_given_name MiddleName family_name LastName
61 suffix Suffix dob Birthdate email Email day_phone DayPhone evening_phone EveningPhone
62 other_phone CellPhone home_ou HomeLib ident_type IdentificationType
63 ident_value Identification_value photo_url PhotoURL/ );
65 my @col_display_order = (
66 qw/id active usrname passwd profile prefix first_given_name second_given_name
67 family_name suffix dob email day_phone evening_phone other_phone
68 home_ou ident_type ident_value photo_url/ );
70 my @required_cols = ( qw/profile usrname passwd profile ident_type ident_value
71 first_given_name family_name dob/ );
73 #-------------------------------------------------------------------------------
75 #-------------------------------------------------------------------------------
77 if (my $action = $cgi->param('action')) {
78 if ( $action eq 'Update Selected' ) {
79 for my $id ( ($cgi->param('id')) ) {
80 my $u = actor::user->retrieve($id);
81 for my $col ( @col_display_order ) {
82 $u->$col( $cgi->param($col."_$id") );
84 $u->active( 'f' ) unless ($cgi->param("active_$id"));
87 } elsif ( $action eq 'Add New' ) {
88 my $u = actor::user->create(
89 { map { defined($cgi->param($_)) ? ($_ => $cgi->param($_)) : () } keys %user_cols }
97 #-------------------------------------------------------------------------------
99 #-------------------------------------------------------------------------------
101 #-----------------------------------------------------------------------
103 #-----------------------------------------------------------------------
104 print "<form method='POST'>".
105 "<table class='table_class'><tr class='header_class'>\n";
107 for my $col ( @col_display_order ) {
108 print th($user_cols{$col});
111 print '<th>Update</th></tr>';
113 for my $row ( sort { $a->usrname cmp $b->usrname } actor::user->search( { super_user => 't' } ) ) {
115 print "<tr class='row_class".
117 if ( !$row->active ) {
124 print td("<input type='checkbox' name='active_$row' value='t' ".do{if($row->active){"checked"}}.">");
125 print td("<input type='text' name='usrname_$row' value=".$row->usrname.">");
126 print td("<input type='password' name='passwd_$row' value=".$row->passwd.">");
127 print "<td><select name='profile_$row'>";
128 for my $org ( actor::profile->retrieve_all ) {
129 print "<option value='".$org->id."' ".do{if($row->profile == $org->id){"selected"}}.">".$org->name."</option>";
131 print "</select></td>";
132 print td("<input type='text' name='prefix_$row' value=".$row->prefix.">");
133 print td("<input type='text' name='first_given_name_$row' value=".$row->first_given_name.">");
134 print td("<input type='text' name='second_given_name_$row' value=".$row->second_given_name.">");
135 print td("<input type='text' name='family_name_$row' value=".$row->family_name.">");
136 print td("<input type='text' name='suffix_$row' value=".$row->suffix.">");
137 print td("<input type='text' name='dob_$row' value=".$row->dob.">");
138 print td("<input type='text' name='email_$row' value=".$row->email.">");
139 print td("<input type='text' name='day_phone_$row' value=".$row->day_phone.">");
140 print td("<input type='text' name='evening_phone_$row' value=".$row->evening_phone.">");
141 print td("<input type='text' name='other_phone_$row' value=".$row->other_phone.">");
142 print "<td><select name='home_ou_$row'>";
143 for my $org ( sort { $a->id <=> $b->id } actor::org_unit->retrieve_all ) {
144 print "<option value='".$org->id."' ".do{if($row->home_ou == $org->id){"selected"}}.">".do{' 'x$org->ou_type->depth}.$org->name."</option>";
146 print "</select></td>";
147 print "<td><select name='ident_type_$row'>";
148 for my $org ( config::identification_type->retrieve_all ) {
149 print "<option value='".$org->id."' ".do{if($row->ident_type == $org->id){"selected"}}.">".$org->name."</option>";
151 print "</select></td>";
152 print td("<input type='text' name='ident_value_$row' value=".$row->ident_value.">");
153 print td("<input type='text' name='photo_url_$row' value=".$row->photo_url.">");
155 print "<td><input type='checkbox' value='$row' name='id'></td></tr>\n";
159 print td("<input type='checkbox' name='active' value='t' checked>");
160 print td("<input type='text' name='usrname'>");
161 print td("<input type='password' name='passwd'>");
162 print "<td><select name='profile'>";
163 for my $org ( actor::profile->retrieve_all ) {
164 print "<option value='".$org->id."'>".$org->name."</option>";
166 print "</select></td>";
167 print td("<input type='text' name='prefix'>");
168 print td("<input type='text' name='first_given_name'>");
169 print td("<input type='text' name='second_given_name'>");
170 print td("<input type='text' name='family_name'>");
171 print td("<input type='text' name='suffix'>");
172 print td("<input type='text' name='dob' value='YYYY-MM-DD'>");
173 print td("<input type='text' name='email'>");
174 print td("<input type='text' name='day_phone'>");
175 print td("<input type='text' name='evening_phone'>");
176 print td("<input type='text' name='other_phone'>");
177 print "<td><select name='home_ou'>";
178 for my $row ( sort { $a->id <=> $b->id } actor::org_unit->retrieve_all ) {
179 print "<option value='".$row->id."'>".do{' 'x$row->ou_type->depth}.$row->name."</option>";
181 print "</select></td>";
182 print "<td><select name='ident_type'>";
183 for my $org ( config::identification_type->retrieve_all ) {
184 print "<option value='".$org->id."'>".$org->name."</option>";
186 print "</select></td>";
187 print td("<input type='text' name='ident_value'>");
188 print td("<input type='text' name='photo_url'>");
191 print "<td></td></tr></table>";
192 print "<input type='submit' name='action' value='Update Selected'/> | ";
193 print "<input type='submit' name='action' value='Add New'/>";
197 print "</body></html>";