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=demo-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;
47 background-color: lightblue;
48 border: solid blue 1px;
53 <body style='padding: 25px;'>
55 <h1>Superuser Setup</h1>
60 #-------------------------------------------------------------------------------
62 #-------------------------------------------------------------------------------
65 qw/id SysID active Active usrname Username profile UserProfile passwd Password prefix Prefix
66 first_given_name FirstName second_given_name MiddleName family_name LastName
67 suffix Suffix dob Birthdate email Email day_phone DayPhone evening_phone EveningPhone
68 other_phone CellPhone home_ou HomeLib ident_type IdentificationType
69 ident_value Identification_value photo_url PhotoURL/ );
71 my @col_display_order = (
72 qw/id active usrname passwd profile prefix first_given_name second_given_name
73 family_name suffix dob email day_phone evening_phone other_phone
74 home_ou ident_type ident_value photo_url/ );
76 my @required_cols = ( qw/profile usrname passwd profile ident_type ident_value
77 first_given_name family_name dob/ );
79 #-------------------------------------------------------------------------------
81 #-------------------------------------------------------------------------------
83 if (my $action = $cgi->param('action')) {
84 if ( $action eq 'Update Selected' ) {
85 for my $id ( ($cgi->param('id')) ) {
86 my $u = actor::user->retrieve($id);
87 for my $col ( @col_display_order ) {
88 $u->$col( $cgi->param($col."_$id") );
90 $u->active( 'f' ) unless ($cgi->param("active_$id"));
93 } elsif ( $action eq 'Add New' ) {
94 my $u = actor::user->create(
95 { map { defined($cgi->param($_)) ? ($_ => $cgi->param($_)) : () } keys %user_cols }
103 #-------------------------------------------------------------------------------
105 #-------------------------------------------------------------------------------
107 #-----------------------------------------------------------------------
109 #-----------------------------------------------------------------------
110 print "<form method='POST'>".
111 "<table class='table_class'><tr class='header_class'>\n";
113 for my $col ( @col_display_order ) {
114 print th($user_cols{$col});
117 print '<th>Update</th></tr>';
119 for my $row ( sort { $a->usrname cmp $b->usrname } actor::user->search( { super_user => 't' } ) ) {
121 print "<tr class='row_class".
123 if ( !$row->active ) {
130 print td("<input type='checkbox' name='active_$row' value='t' ".do{if($row->active){"checked"}}.">");
131 print td("<input type='text' name='usrname_$row' value=".$row->usrname.">");
132 print td("<input type='password' name='passwd_$row' value=".$row->passwd.">");
133 print "<td><select name='profile_$row'>";
134 for my $org ( actor::profile->retrieve_all ) {
135 print "<option value='".$org->id."' ".do{if($row->profile == $org->id){"selected"}}.">".$org->name."</option>";
137 print "</select></td>";
138 print td("<input type='text' name='prefix_$row' value=".$row->prefix.">");
139 print td("<input type='text' name='first_given_name_$row' value=".$row->first_given_name.">");
140 print td("<input type='text' name='second_given_name_$row' value=".$row->second_given_name.">");
141 print td("<input type='text' name='family_name_$row' value=".$row->family_name.">");
142 print td("<input type='text' name='suffix_$row' value=".$row->suffix.">");
143 print td("<input type='text' name='dob_$row' value=".$row->dob.">");
144 print td("<input type='text' name='email_$row' value=".$row->email.">");
145 print td("<input type='text' name='day_phone_$row' value=".$row->day_phone.">");
146 print td("<input type='text' name='evening_phone_$row' value=".$row->evening_phone.">");
147 print td("<input type='text' name='other_phone_$row' value=".$row->other_phone.">");
148 print "<td><select name='home_ou_$row'>";
149 for my $org ( sort { $a->id <=> $b->id } actor::org_unit->retrieve_all ) {
150 print "<option value='".$org->id."' ".do{if($row->home_ou == $org->id){"selected"}}.">".do{' 'x$org->ou_type->depth}.$org->name."</option>";
152 print "</select></td>";
153 print "<td><select name='ident_type_$row'>";
154 for my $org ( config::identification_type->retrieve_all ) {
155 print "<option value='".$org->id."' ".do{if($row->ident_type == $org->id){"selected"}}.">".$org->name."</option>";
157 print "</select></td>";
158 print td("<input type='text' name='ident_value_$row' value=".$row->ident_value.">");
159 print td("<input type='text' name='photo_url_$row' value=".$row->photo_url.">");
161 print "<td><input type='checkbox' value='$row' name='id'></td></tr>\n";
164 print "<tr class='new_row_class'>";
166 print td("<input type='checkbox' name='active' value='t' checked>");
167 print td("<input type='text' name='usrname'>");
168 print td("<input type='password' name='passwd'>");
169 print "<td><select name='profile'>";
170 for my $org ( actor::profile->retrieve_all ) {
171 print "<option value='".$org->id."'>".$org->name."</option>";
173 print "</select></td>";
174 print td("<input type='text' name='prefix'>");
175 print td("<input type='text' name='first_given_name'>");
176 print td("<input type='text' name='second_given_name'>");
177 print td("<input type='text' name='family_name'>");
178 print td("<input type='text' name='suffix'>");
179 print td("<input type='text' name='dob' value='YYYY-MM-DD'>");
180 print td("<input type='text' name='email'>");
181 print td("<input type='text' name='day_phone'>");
182 print td("<input type='text' name='evening_phone'>");
183 print td("<input type='text' name='other_phone'>");
184 print "<td><select name='home_ou'>";
185 for my $row ( sort { $a->id <=> $b->id } actor::org_unit->retrieve_all ) {
186 print "<option value='".$row->id."'>".do{' 'x$row->ou_type->depth}.$row->name."</option>";
188 print "</select></td>";
189 print "<td><select name='ident_type'>";
190 for my $org ( config::identification_type->retrieve_all ) {
191 print "<option value='".$org->id."'>".$org->name."</option>";
193 print "</select></td>";
194 print td("<input type='text' name='ident_value'>");
195 print td("<input type='text' name='photo_url'>");
198 print "<td></td></tr></table>";
199 print "<input type='submit' name='action' value='Update Selected'/> | ";
200 print "<input type='submit' name='action' value='Add New'/>";
204 print "</body></html>";