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_*/;
15 OpenILS::Application::Storage::CDBI->connection($config{dsn},$config{usr});
16 OpenILS::Application::Storage::CDBI->db_Main->{ AutoCommit } = 1;
20 #-------------------------------------------------------------------------------
22 #-------------------------------------------------------------------------------
25 Content-type: text/html
32 border: dashed lightgrey 1px;
33 background-color: #EEE;
34 border-collapse: collapse;
42 border: solid lightgrey 1px;
50 background-color: lightblue;
51 border: solid blue 1px;
56 <body style='padding: 25px;'>
58 <a href="$config{index}">Home</a>
60 <h1>Superuser Setup</h1>
65 #-------------------------------------------------------------------------------
67 #-------------------------------------------------------------------------------
70 qw/id SysID active Active usrname Username profile UserProfile passwd Password prefix Prefix
71 first_given_name FirstName second_given_name MiddleName family_name LastName
72 suffix Suffix dob Birthdate email Email day_phone DayPhone evening_phone EveningPhone
73 other_phone CellPhone home_ou HomeLib ident_type IdentificationType
74 ident_value Identification_value photo_url PhotoURL/ );
76 my @col_display_order = (
77 qw/id active usrname passwd profile prefix first_given_name second_given_name
78 family_name suffix dob email day_phone evening_phone other_phone
79 home_ou ident_type ident_value photo_url/ );
81 my @required_cols = ( qw/profile usrname passwd profile ident_type ident_value
82 first_given_name family_name dob/ );
84 #-------------------------------------------------------------------------------
86 #-------------------------------------------------------------------------------
88 if (my $action = $cgi->param('action')) {
89 if ( $action eq 'Update Selected' ) {
90 for my $id ( ($cgi->param('id')) ) {
91 my $u = actor::user->retrieve($id);
92 for my $col ( @col_display_order ) {
93 $u->$col( $cgi->param($col."_$id") );
95 $u->active( 'f' ) unless ($cgi->param("active_$id"));
98 } elsif ( $action eq 'Add New' ) {
99 my $u = actor::user->create(
100 { map { defined($cgi->param($_)) ? ($_ => $cgi->param($_)) : () } keys %user_cols }
108 #-------------------------------------------------------------------------------
110 #-------------------------------------------------------------------------------
112 #-----------------------------------------------------------------------
114 #-----------------------------------------------------------------------
115 print "<form method='POST'>".
116 "<table class='table_class'><tr class='header_class'>\n";
118 for my $col ( @col_display_order ) {
119 print th($user_cols{$col});
122 print '<th>Update</th></tr>';
124 for my $row ( sort { $a->usrname cmp $b->usrname } actor::user->search( { super_user => 't' } ) ) {
126 print "<tr class='row_class".
128 if ( !$row->active ) {
135 print td("<input type='checkbox' name='active_$row' value='t' ".do{if($row->active){"checked"}}.">");
136 print td("<input type='text' name='usrname_$row' value=".$row->usrname.">");
137 print td("<input type='password' name='passwd_$row' value=".$row->passwd.">");
138 print "<td><select name='profile_$row'>";
139 for my $org ( actor::profile->retrieve_all ) {
140 print "<option value='".$org->id."' ".do{if($row->profile == $org->id){"selected"}}.">".$org->name."</option>";
142 print "</select></td>";
143 print td("<input type='text' name='prefix_$row' value=".$row->prefix.">");
144 print td("<input type='text' name='first_given_name_$row' value=".$row->first_given_name.">");
145 print td("<input type='text' name='second_given_name_$row' value=".$row->second_given_name.">");
146 print td("<input type='text' name='family_name_$row' value=".$row->family_name.">");
147 print td("<input type='text' name='suffix_$row' value=".$row->suffix.">");
148 print td("<input type='text' name='dob_$row' value=".$row->dob.">");
149 print td("<input type='text' name='email_$row' value=".$row->email.">");
150 print td("<input type='text' name='day_phone_$row' value=".$row->day_phone.">");
151 print td("<input type='text' name='evening_phone_$row' value=".$row->evening_phone.">");
152 print td("<input type='text' name='other_phone_$row' value=".$row->other_phone.">");
153 print "<td><select name='home_ou_$row'>";
154 for my $org ( sort { $a->id <=> $b->id } actor::org_unit->retrieve_all ) {
155 print "<option value='".$org->id."' ".do{if($row->home_ou == $org->id){"selected"}}.">".do{' 'x$org->ou_type->depth}.$org->name."</option>";
157 print "</select></td>";
158 print "<td><select name='ident_type_$row'>";
159 for my $org ( config::identification_type->retrieve_all ) {
160 print "<option value='".$org->id."' ".do{if($row->ident_type == $org->id){"selected"}}.">".$org->name."</option>";
162 print "</select></td>";
163 print td("<input type='text' name='ident_value_$row' value=".$row->ident_value.">");
164 print td("<input type='text' name='photo_url_$row' value=".$row->photo_url.">");
166 print "<td><input type='checkbox' value='$row' name='id'></td></tr>\n";
169 print "<tr class='new_row_class'>";
171 print td("<input type='checkbox' name='active' value='t' checked>");
172 print td("<input type='text' name='usrname'>");
173 print td("<input type='password' name='passwd'>");
174 print "<td><select name='profile'>";
175 for my $org ( actor::profile->retrieve_all ) {
176 print "<option value='".$org->id."'>".$org->name."</option>";
178 print "</select></td>";
179 print td("<input type='text' name='prefix'>");
180 print td("<input type='text' name='first_given_name'>");
181 print td("<input type='text' name='second_given_name'>");
182 print td("<input type='text' name='family_name'>");
183 print td("<input type='text' name='suffix'>");
184 print td("<input type='text' name='dob' value='YYYY-MM-DD'>");
185 print td("<input type='text' name='email'>");
186 print td("<input type='text' name='day_phone'>");
187 print td("<input type='text' name='evening_phone'>");
188 print td("<input type='text' name='other_phone'>");
189 print "<td><select name='home_ou'>";
190 for my $row ( sort { $a->id <=> $b->id } actor::org_unit->retrieve_all ) {
191 print "<option value='".$row->id."'>".do{' 'x$row->ou_type->depth}.$row->name."</option>";
193 print "</select></td>";
194 print "<td><select name='ident_type'>";
195 for my $org ( config::identification_type->retrieve_all ) {
196 print "<option value='".$org->id."'>".$org->name."</option>";
198 print "</select></td>";
199 print td("<input type='text' name='ident_value'>");
200 print td("<input type='text' name='photo_url'>");
203 print "<td></td></tr></table>";
204 print "<input type='submit' name='action' value='Update Selected'/> | ";
205 print "<input type='submit' name='action' value='Add New'/>";
209 print "</body></html>";