Changeset 165
- Timestamp:
- 04/06/09 02:13:06 (15 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MANIFEST
r164 r165 27 27 lib/Vote/DB/Voting.pm 28 28 lib/Vote/DB/Ballot.pm 29 lib/Vote/DB/Choice.pm 29 30 lib/Vote/Model/Vote.pm 30 31 lib/Vote/Template/Plugin/Mail.pm -
trunk/lib/Vote/DB.pm
r161 r165 11 11 use Vote::DB::Ballot; # see ballot() 12 12 use Vote::DB::Voting; # see delete_voting() 13 use Vote::DB::Choice; 13 14 14 15 =head1 NAME … … 146 147 } 147 148 148 # Choice sub class ??149 150 149 sub choice_info { 151 150 my ($self, $chid) = @_; 152 my $sth = $self->db->prepare_cached( 153 q{select * from choice where key = ?} 154 ); 155 $sth->execute($chid); 156 my $res = $sth->fetchrow_hashref; 157 $sth->finish; 158 $res 159 } 160 161 sub modify_choice { 162 my ($self, $chid, $label) = @_; 163 164 my $sth = $self->db->prepare_cached( 165 q{update choice set label = ? where key = ?} 166 ); 167 $sth->execute($label, $chid); 151 Vote::DB::Choice->new($self->{dbstring}, $chid)->info; 168 152 } 169 153 -
trunk/lib/Vote/DB/Poll.pm
r161 r165 10 10 use Vote::DB::Ballot; 11 11 use Vote::DB::Voting; 12 use Vote::DB::Choice; 12 13 13 14 =head1 NAME … … 212 213 } 213 214 215 sub choice { 216 my ($self, $chid) = @_; 217 218 my $sth = $self->db->prepare_cached( 219 q{ 220 select key from choice where poll = ? and key = ? 221 } 222 ); 223 $sth->execute($self->voteid, $chid); 224 my $res = $sth->fetchrow_hashref; 225 $sth->finish; 226 return $res ? Vote::DB::Choice->new($self->{dbstring}, $chid) : undef; 227 } 228 214 229 sub choices { 215 230 my ($self) = @_; … … 242 257 243 258 1 259 } 260 261 sub delete_choice { 262 my ($self, $chid) = @_; 263 264 my $sth = $self->db->prepare_cached( 265 q{delete from choice where key = ?} 266 ); 267 268 $sth->execute($chid); 244 269 } 245 270 -
trunk/root/templates/includes/ballot_form.tt
r164 r165 4 4 5 5 <!-- $Id$ --> 6 [% FOREACH choice= poll.choices() %]7 [% key = vote.choice_info(choice).key%]6 [% FOREACH key = poll.choices() %] 7 [% choice = poll.choice(key) %] 8 8 <input type="checkbox" name="sbal" value="[% key %]"[% " checked" IF sbal.$key %]> 9 [% vote.choice_info(choice).label | html %]<br>9 [% choice.info.label | html %]<br> 10 10 [% END %] 11 11
Note: See TracChangeset
for help on using the changeset viewer.