5 use OpenILS::Application::Storage;
6 use OpenILS::Application::Storage::CDBI;
8 # I need to abstract the driver loading away...
9 use OpenILS::Application::Storage::Driver::Pg;
11 use CGI qw/:standard start_*/;
14 do '##CONFIG##/live-db-setup.pl';
16 OpenILS::Application::Storage::CDBI->connection($config{dsn},$config{usr},$config{pw});
17 OpenILS::Application::Storage::CDBI->db_Main->{ AutoCommit } = 1;
21 #-------------------------------------------------------------------------------
23 #-------------------------------------------------------------------------------
26 Content-type: text/html
31 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
32 <meta http-equiv="Pragma" content="no-cache" />
33 <meta http-equiv="Expires" content="Thu, 01 Dec 2000 16:00:00 GMT" />
36 border: dashed lightgrey 1px;
37 background-color: #EEE;
38 border-collapse: collapse;
46 border: solid lightgrey 1px;
54 background-color: lightblue;
55 border: solid blue 1px;
60 <body style='padding: 25px;'>
62 <a href="$config{index}">Home</a>
64 <h1>Permission List Setup</h1>
69 #-------------------------------------------------------------------------------
71 #-------------------------------------------------------------------------------
73 my %profile_cols = ( qw/id SysID code Name description Description/ );
75 my @col_display_order = ( qw/id code description/ );
77 #-------------------------------------------------------------------------------
79 #-------------------------------------------------------------------------------
81 if (my $action = $cgi->param('action')) {
82 if ( $action eq 'Remove Selected' ) {
83 for my $id ( ($cgi->param('id')) ) {
84 permission::perm_list->retrieve($id)->delete;
86 } elsif ( $action eq 'Update Selected' ) {
87 for my $id ( ($cgi->param('id')) ) {
88 my $u = permission::perm_list->retrieve($id);
89 $u->code( $cgi->param("code_$id") );
90 $u->description( $cgi->param("description_$id") );
93 } elsif ( $action eq 'Add New' ) {
94 permission::perm_list->create(
95 { code => $cgi->param("code"),
96 description => $cgi->param("description")
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($profile_cols{$col});
117 print '<th>Action</th></tr>';
119 for my $row ( sort { $a->code cmp $b->code } (permission::perm_list->retrieve_all) ) {
122 td("<input type='text' name='code_$row' value='". $row->code() ."'>"),
123 td("<input type='text' size='50' name='description_$row' value='". $row->description() ."'>"),
124 td("<input type='checkbox' value='$row' name='id'>"),
128 print "<tr class='new_row_class'>",
130 td("<input type='text' name='code'>"),
131 td("<input type='text' size='50' name='description'>"),
135 print "<input type='submit' name='action' value='Remove Selected'/> | ";
136 print "<input type='submit' name='action' value='Update Selected'/> | ";
137 print "<input type='submit' name='action' value='Add New'/></form><hr/>";
140 print "</body></html>";