Changeset 406
- Timestamp:
- 02/08/08 02:44:39 (22 months ago)
- Location:
- veekun/trunk
- Files:
-
- 1 removed
- 78 modified
- 3 moved
-
lib/Vee/Authorization.pm (modified) (1 diff)
-
lib/Vee/Bot.pm (modified) (2 diffs)
-
lib/Vee/Controller/Dex.pm (modified) (21 diffs)
-
lib/Vee/Controller/Dex/Search.pm (modified) (9 diffs)
-
lib/Vee/Controller/Dex/Utils.pm (modified) (6 diffs)
-
lib/Vee/Controller/Forum.pm (modified) (11 diffs)
-
lib/Vee/Controller/Forum/Create.pm (modified) (13 diffs)
-
lib/Vee/Controller/Forum/Post.pm (modified) (8 diffs)
-
lib/Vee/Controller/Index.pm (modified) (4 diffs)
-
lib/Vee/Controller/Root.pm (modified) (2 diffs)
-
lib/Vee/Controller/Shoutbox.pm (modified) (3 diffs)
-
lib/Vee/Controller/Users.pm (modified) (4 diffs)
-
lib/Vee/Controller/Users/Stats.pm (modified) (3 diffs)
-
lib/Vee/Dex.pm (modified) (3 diffs)
-
lib/Vee/Schema/Abilities.pm (modified) (1 diff)
-
lib/Vee/Schema/ContestEffects.pm (moved) (moved from veekun/trunk/lib/Vee/Schema/ContestMoves.pm) (2 diffs)
-
lib/Vee/Schema/Creators.pm (modified) (1 diff)
-
lib/Vee/Schema/Edits.pm (modified) (1 diff)
-
lib/Vee/Schema/ErrorLog.pm (modified) (1 diff)
-
lib/Vee/Schema/EvoChains.pm (moved) (moved from veekun/trunk/lib/Vee/Schema/EvChains.pm) (2 diffs)
-
lib/Vee/Schema/FlavorText.pm (modified) (1 diff)
-
lib/Vee/Schema/Forums.pm (modified) (3 diffs)
-
lib/Vee/Schema/GalleryKeywords.pm (modified) (1 diff)
-
lib/Vee/Schema/GroupPermissions.pm (modified) (1 diff)
-
lib/Vee/Schema/Groups.pm (modified) (1 diff)
-
lib/Vee/Schema/ItemKeywords.pm (modified) (1 diff)
-
lib/Vee/Schema/Items.pm (modified) (1 diff)
-
lib/Vee/Schema/Machines.pm (modified) (1 diff)
-
lib/Vee/Schema/MoveEffects.pm (modified) (1 diff)
-
lib/Vee/Schema/Moves.pm (modified) (4 diffs)
-
lib/Vee/Schema/Permissions.pm (deleted)
-
lib/Vee/Schema/Pokemon.pm (modified) (3 diffs)
-
lib/Vee/Schema/PokemonAbilities.pm (modified) (1 diff)
-
lib/Vee/Schema/PokemonBreeds.pm (modified) (1 diff)
-
lib/Vee/Schema/PokemonMoves.pm (moved) (moved from veekun/trunk/lib/Vee/Schema/PokeMoves.pm) (2 diffs)
-
lib/Vee/Schema/Posts.pm (modified) (1 diff)
-
lib/Vee/Schema/Sessions.pm (modified) (1 diff)
-
lib/Vee/Schema/Shoutbox.pm (modified) (1 diff)
-
lib/Vee/Schema/Threads.pm (modified) (3 diffs)
-
lib/Vee/Schema/Types.pm (modified) (1 diff)
-
lib/Vee/Schema/UserGroups.pm (modified) (1 diff)
-
lib/Vee/Schema/Users.pm (modified) (3 diffs)
-
lib/Vee/Utils.pm (modified) (3 diffs)
-
script/base.sql (modified) (11 diffs)
-
script/base_data.sql (modified) (2 diffs)
-
script/dump_sql.pl (modified) (1 diff)
-
script/gallery.sql (modified) (3 diffs)
-
script/pokedex.sql (modified) (19 diffs)
-
t/dex-pokemon.t (modified) (1 diff)
-
t/dex-search-moves.t (modified) (1 diff)
-
t/dex-search-pokemon.t (modified) (1 diff)
-
t/shoutbox.t (modified) (2 diffs)
-
templates/dex/common.tt (modified) (6 diffs)
-
templates/dex/list/abilities.tt (modified) (1 diff)
-
templates/dex/list/berries.tt (modified) (1 diff)
-
templates/dex/list/moves.tt (modified) (1 diff)
-
templates/dex/list/pokemon.tt (modified) (2 diffs)
-
templates/dex/page/ability.tt (modified) (1 diff)
-
templates/dex/page/item.tt (modified) (1 diff)
-
templates/dex/page/move.tt (modified) (9 diffs)
-
templates/dex/page/pokemon.tt (modified) (16 diffs)
-
templates/dex/page/tm.tt (modified) (1 diff)
-
templates/dex/page/type.tt (modified) (2 diffs)
-
templates/dex/search/moves.tt (modified) (1 diff)
-
templates/dex/search/pokemon.tt (modified) (1 diff)
-
templates/dex/utils/backtrace.tt (modified) (2 diffs)
-
templates/dex/utils/compare-results.tt (modified) (8 diffs)
-
templates/fatal.tt (modified) (1 diff)
-
templates/forum/common.tt (modified) (11 diffs)
-
templates/forum/preview.tt (modified) (3 diffs)
-
templates/forum/thread/edit.tt (modified) (4 diffs)
-
templates/forum/thread/edits.tt (modified) (2 diffs)
-
templates/forum/thread/preview.tt (modified) (1 diff)
-
templates/forum/thread/view.tt (modified) (3 diffs)
-
templates/forum/view.tt (modified) (1 diff)
-
templates/index.tt (modified) (5 diffs)
-
templates/shoutbox.tt (modified) (2 diffs)
-
templates/users/edit.tt (modified) (1 diff)
-
templates/users/info.tt (modified) (3 diffs)
-
templates/users/list.tt (modified) (2 diffs)
-
templates/wrapper.tt (modified) (1 diff)
-
vee.yml (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
veekun/trunk/lib/Vee/Authorization.pm
r385 r406 34 34 return 0 unless $c->user; 35 35 36 my @usergroups = $c->model('UserGroups')->search({ user id => [ 0, $c->user->obj->id ] })->get_column('groupid')->all;36 my @usergroups = $c->model('UserGroups')->search({ user_id => [ 0, $c->user->obj->id ] })->get_column('group_id')->all; 37 37 # my %seen; 38 38 39 39 # TODO: get group parents! 40 40 my @groupperms = $c->model('GroupPermissions')->search({ 41 group id => { -in => \@usergroups },41 group_id => { -in => \@usergroups }, 42 42 permission => [ $permission, 'splat' ], 43 43 scope => $scope, -
veekun/trunk/lib/Vee/Bot.pm
r262 r406 73 73 my $ability = $schema->resultset('Abilities')->find($hashref->{id}); 74 74 return sprintf "%s: %s", 75 $ability->name, $ability-> effect;75 $ability->name, $ability->description; 76 76 77 77 } else { … … 204 204 } 205 205 206 my @pm = $schema->resultset('Poke Moves')->search({207 poke id => $pokemon_id,208 move id=> $move_id,209 -nest => \ "FIND_IN_SET('$ver', version)",206 my @pm = $schema->resultset('PokemonMoves')->search({ 207 pokemon_id => $pokemon_id, 208 move_id => $move_id, 209 -nest => \ "FIND_IN_SET('$ver', versions)", 210 210 }); 211 211 -
veekun/trunk/lib/Vee/Controller/Dex.pm
r400 r406 281 281 group_by => 'me.id', 282 282 join => 'pokemon_abilities', 283 '+select' => 'COUNT(DISTINCT pokemon_abilities.poke id)',283 '+select' => 'COUNT(DISTINCT pokemon_abilities.pokemon_id)', 284 284 '+as' => 'pokemon_count', 285 285 }); … … 353 353 354 354 # check to see if there is only one move, ever, that corresponds to this TM 355 my %set = map { $_->move id => 1 } @tms;355 my %set = map { $_->move_id => 1 } @tms; 356 356 357 357 if (!@tms) { … … 359 359 } elsif (1 == scalar keys %set) { 360 360 # TODO: remove this? 361 $c->res->redirect( $c->uri('Dex', 'moves', lc $MoveData[ $tms[0]->move id ]->name) );361 $c->res->redirect( $c->uri('Dex', 'moves', lc $MoveData[ $tms[0]->move_id ]->name) ); 362 362 } 363 363 … … 453 453 %query, 454 454 }, { 455 join => { ev chain => 'pokemon' },455 join => { evo_chain => 'pokemon' }, 456 456 prefetch => { pokemon_abilities => 'ability' }, 457 group_by => [ 'me.id', 'pokemon_abilities.ability id' ],457 group_by => [ 'me.id', 'pokemon_abilities.ability_id' ], 458 458 order_by => [ @extra_order, "pokemon.id ASC", "FIND_IN_SET('baby', me.flags) DESC", 'me.id ASC' ], 459 459 }); … … 482 482 delete $c->session->{last_pokemon_view}; 483 483 484 $s->{page_title} = $row->name . ' - Pokémon #' . $row->real_ id;484 $s->{page_title} = $row->name . ' - Pokémon #' . $row->real_pokemon_id; 485 485 $s->{page_header} = $row->name; 486 486 $s->{extra_js} = ['dexutils']; … … 507 507 $s->{this} = $row; 508 508 $s->{pid} = Vee::Utils::pad($row->id, 3); 509 $s->{generation} = my $generation = ( grep { $Generations[$_]{maxid} >= $row->real_ id } 0 .. $#Generations )[0];509 $s->{generation} = my $generation = ( grep { $Generations[$_]{maxid} >= $row->real_pokemon_id } 0 .. $#Generations )[0]; 510 510 511 511 # alt forms … … 513 513 my @alts; 514 514 my $alt_rs = $c->model('DBIC::Pokemon')->search({ 515 real_ id => $row->real_id,515 real_pokemon_id => $row->real_pokemon_id, 516 516 }, { 517 517 columns => ['alt_form'], … … 525 525 526 526 # evolution chain 527 my @family = $row->ev chain->pokemon( \'id = real_id', { columns => [qw/id evparent evmethod evparam/] } );527 my @family = $row->evo_chain->pokemon( \'id = real_pokemon_id', { columns => [qw/id evo_parent_id evo_method evo_param/] } ); 528 528 my %evtrees; 529 $evtrees{$_->id} = { id => $_->id, parent => $_->ev parent, method => $_->evmethod, param => $_->evparam, children => [] } for @family;529 $evtrees{$_->id} = { id => $_->id, parent => $_->evo_parent_id, method => $_->evo_method, param => $_->evo_param, children => [] } for @family; 530 530 push @{ $evtrees{ $_->{parent} }{children} }, $_ for sort { $a->{id} <=> $b->{id} } grep { $_->{parent} } values %evtrees; 531 for my $node (values %evtrees) { add_evolution_desc($node, $row->ev chain) }531 for my $node (values %evtrees) { add_evolution_desc($node, $row->evo_chain) } 532 532 $s->{evtree} = ( grep { !$_->{parent} } values %evtrees )[0]; # should only be one with no parent: the root 533 533 calculate_tree_width($s->{evtree}); … … 547 547 $s->{compatibility}{all} = $compat_rs->count; 548 548 # TODO: this is actually wrong; fix when bug #88 is fixed please 549 $s->{compatibility}{base} = $compat_rs->search({ ev parent=> 0 })->count;549 $s->{compatibility}{base} = $compat_rs->search({ evo_parent_id => 0 })->count; 550 550 551 551 # held items … … 563 563 # moves from here down 564 564 # slurp everything this Pokemon can learn, complete with egg moves if necessary 565 my $moves_rs = $c->model('DBIC::PokeMoves')->search( { 566 pokeid => $row->id, 567 }, { 568 columns => [qw/moveid method level version/] 565 my $moves_rs = $c->model('DBIC::PokemonMoves')->search( { 566 pokemon_id => $row->id, 569 567 } ); 570 568 … … 578 576 while (my $move_row = $moves_rs->next) { 579 577 my $table_row = { 580 move id => $move_row->moveid,578 move_id => $move_row->move_id, 581 579 level => $move_row->level, 582 versions => { map { $_ => $move_row->level || 1 } split /,/, $move_row->version },580 versions => { map { $_ => $move_row->level || 1 } split /,/, $move_row->versions }, 583 581 }; 584 582 … … 595 593 @{ $moves{$_} } = sort { 596 594 $a->{level} <=> $b->{level} or 597 $MoveData[ $a->{move id} ]->name cmp $MoveData[ $b->{moveid} ]->name595 $MoveData[ $a->{move_id} ]->name cmp $MoveData[ $b->{move_id} ]->name 598 596 } @{ $moves{$_} } for qw/ level egg machine /; 599 597 … … 633 631 my $i = -1; 634 632 while (++$i <= $#$lev_moves) { # shouldn't use a for since the size of the array changes 635 # find the next row index with the same move id636 my $next_idx = first { $lev_moves->[$_]{move id} == $lev_moves->[$i]{moveid} } $i + 1 .. $#$lev_moves;633 # find the next row index with the same move id 634 my $next_idx = first { $lev_moves->[$_]{move_id} == $lev_moves->[$i]{move_id} } $i + 1 .. $#$lev_moves; 637 635 next if not defined $next_idx; 638 636 … … 673 671 } 674 672 if (scalar keys %{ $from->{versions} } == 0) { 675 # only move id left, so delete this row and redo to hit the next one673 # only move id left, so delete this row and redo to hit the next one 676 674 splice @$lev_moves, $from_idx, 1; 677 675 redo; … … 704 702 map { $_->generation => $_->text } $row->flavors 705 703 }; 706 $s->{generation} = ( grep { $Generations[$_]{maxid} >= $row->real_ id } 0 .. $#Generations )[0];704 $s->{generation} = ( grep { $Generations[$_]{maxid} >= $row->real_pokemon_id } 0 .. $#Generations )[0]; 707 705 708 706 $s->{page_title} = $row->name . ' - Flavor Text and Images'; … … 785 783 ? Vee::Utils::round( $c->model('DBIC::Moves')->count({ power => { '!=' => undef, '<' => $row->power } }) / $DamagingMoveCount * 100, 1 ) 786 784 :'n/a'; 787 $s->{tm_info} = { map { $_->generation => $_ } $c->model('DBIC::Machines')->search({ move id => $row->id }) };785 $s->{tm_info} = { map { $_->generation => $_ } $c->model('DBIC::Machines')->search({ move_id => $row->id }) }; 788 786 789 787 # status effect … … 805 803 806 804 # contest stuffs 807 my $contest_family_rs = $c->model('DBIC::Moves')->search({ con effect => $row->coneffect, id => { '!=', $row->id } }, { columns => [qw/id name contype/], order_by => 'name ASC' });805 my $contest_family_rs = $c->model('DBIC::Moves')->search({ contest_effect_id => $row->contest_effect_id, id => { '!=', $row->id } }, { columns => [qw/id name contest_type/], order_by => 'name ASC' }); 808 806 my %contest_family; 809 807 $s->{contest_family_count} = 0; 810 808 while (my $move = $contest_family_rs->next) { 811 push @{ $contest_family{ $move->cont ype } }, $move;809 push @{ $contest_family{ $move->contest_type } }, $move; 812 810 $s->{contest_family_count}++; 813 811 } … … 818 816 my %pokemon_count; 819 817 my %valid_methods = map { $_ => 1 } qw/level egg tutor machine/; 820 my $pokemoves_rs = $c->model('DBIC::Poke Moves')->search({ moveid => $row->id });818 my $pokemoves_rs = $c->model('DBIC::PokemonMoves')->search({ move_id => $row->id }); 821 819 my %pokemon_hash; # method => pokemon id => version => level 822 820 while (my $pm = $pokemoves_rs->next) { … … 829 827 @versions = ('all'); 830 828 } else { 831 @versions = split /,/, $pm->version ;829 @versions = split /,/, $pm->versions; 832 830 } 833 831 834 832 for my $ver (@versions) { 835 $pokemon_hash{$method}{$pm->poke id}{pokemon} ||= $pm->pokemon;836 $pokemon_hash{$method}{$pm->poke id}{$ver} = $pm->level || 1;837 } 838 $pokemon_count{ $pm->poke id } = 1;833 $pokemon_hash{$method}{$pm->pokemon_id}{pokemon} ||= $pm->pokemon; 834 $pokemon_hash{$method}{$pm->pokemon_id}{$ver} = $pm->level || 1; 835 } 836 $pokemon_count{ $pm->pokemon_id } = 1; 839 837 } 840 838 … … 903 901 $c->forward('/cache', [ $row->id ]); 904 902 905 $s->{hid} = $row->internal id + 1;903 $s->{hid} = $row->internal_id + 1; 906 904 $s->{generation} = ($row->name eq 'dark' || $row->name eq 'steel') ? 1 : 0; 907 905 … … 1190 1188 my @extra; 1191 1189 # n.b.: can ONLY prefetch one has_many here; DBIx::Class will refuse more due to cross-product effect 1192 if ($table eq 'Pokemon') { @extra = ( prefetch => [qw/ev chain pokemoves/], order_by => 'pokemoves.moveid ASC' ) }1193 elsif ($table eq 'Moves') { @extra = ( prefetch => 'pokemo ves', order_by => 'pokemoves.pokeid ASC' ) }1190 if ($table eq 'Pokemon') { @extra = ( prefetch => [qw/evo_chain pokemon_moves/], order_by => 'pokemon_moves.move_id ASC' ) } 1191 elsif ($table eq 'Moves') { @extra = ( prefetch => 'pokemon_moves', order_by => 'pokemon_moves.pokemon_id ASC' ) } 1194 1192 1195 1193 if ($id eq 'random') { -
veekun/trunk/lib/Vee/Controller/Dex/Search.pm
r348 r406 49 49 breed => { type => 'select', options => [ [ 0 => 'n/a' ], map { [ $_ => ($_ ? "$_: " : '') . $BreedingGroups[$_] ] } 1 .. $#BreedingGroups ], count => 2 }, 50 50 breed_mode => { type => 'select', options => [ [ and => 'exactly' ], [ or => 'either of' ] ], default => 'or' }, 51 gender => { type => 'select', options => [ [ any => 'anything' ], [ 255 => 'no gender' ], [ not255 => 'any gender' ], map { [ $_ => lc gender_text($_) ] } qw/0 31 63 127 191 254/ ] },51 gender_rate => { type => 'select', options => [ [ any => 'anything' ], [ 255 => 'no gender' ], [ not255 => 'any gender' ], map { [ $_ => lc gender_text($_) ] } qw/0 31 63 127 191 254/ ] }, 52 52 ability => { type => 'text', size => 20, title => 'Enter the name or number of an ability' }, 53 53 color => { type => 'select', options => [qw/any black blue brown gray green pink purple red white yellow/], title => 'I have no explanation for why this is here' }, … … 123 123 if ($ability) { 124 124 $joins{pokemon_abilities} = 1; 125 $criteria{'pokemon_abilities.ability id'} = $ability->id;125 $criteria{'pokemon_abilities.ability_id'} = $ability->id; 126 126 } 127 127 } … … 142 142 143 143 # BREEDING AND STUFF 144 if (defined $p->{gender } and $p->{gender} ne 'any') {145 if ($p->{gender } eq 'not255') {146 $criteria{'me.gender '} = { '!=' => 255 };144 if (defined $p->{gender_rate} and $p->{gender_rate} ne 'any') { 145 if ($p->{gender_rate} eq 'not255') { 146 $criteria{'me.gender_rate'} = { '!=' => 255 }; 147 147 } else { 148 $criteria{'me.gender '} = $p->{gender};148 $criteria{'me.gender_rate'} = $p->{gender_rate}; 149 149 } 150 150 } … … 154 154 $criteria{'breeds.breed'} = \@breeds; 155 155 if ($p->{breed_mode} eq 'and') { 156 $clauses{having}{'COUNT(DISTINCT breeds.poke id, breeds.breed)'} = scalar @breeds;156 $clauses{having}{'COUNT(DISTINCT breeds.pokemon_id, breeds.breed)'} = scalar @breeds; 157 157 158 158 if (@breeds == 1) { … … 192 192 for my $move (@{ $p->{move} }) { 193 193 # XXX: show some message if a move is invalid? 194 my $move id = get_move($move);195 push @moveids, $move id if defined $moveid;194 my $move_id = get_move($move); 195 push @moveids, $move_id if defined $move_id; 196 196 } 197 197 if (@moveids) { 198 $joins{pokemo ves} = 1;199 $criteria{'pokemo ves.moveid'} = \@moveids;200 $clauses{having}{'COUNT(DISTINCT pokemo ves.pokeid, pokemoves.moveid)'} = scalar @moveids;198 $joins{pokemon_moves} = 1; 199 $criteria{'pokemon_moves.move_id'} = \@moveids; 200 $clauses{having}{'COUNT(DISTINCT pokemon_moves.pokemon_id, pokemon_moves.move_id)'} = scalar @moveids; 201 201 202 202 if ($p->{move_method}) { 203 $criteria{'pokemo ves.method'} = $p->{move_method};203 $criteria{'pokemon_moves.method'} = $p->{move_method}; 204 204 } 205 205 if ($p->{move_version}) { 206 push @{$criteria{'-and'}}, { '-or', [ map { \ "FIND_IN_SET('$_', pokemo ves.version)" } Vee::Utils::array($p->{move_version}) ] };206 push @{$criteria{'-and'}}, { '-or', [ map { \ "FIND_IN_SET('$_', pokemon_moves.versions)" } Vee::Utils::array($p->{move_version}) ] }; 207 207 } 208 208 } … … 237 237 238 238 if ($evo_stages{base}) { 239 $criteria{'me.ev parent'} = 0;239 $criteria{'me.evo_parent_id'} = 0; 240 240 } 241 241 … … 308 308 }; 309 309 310 for my $col (qw/power acc pp effect_chance priority/) {310 for my $col (qw/power accuracy pp effect_chance priority/) { 311 311 for my $endpoint (keys %endpoints) { 312 312 $move_search_fields->{ $col . '_' . $endpoint } = { type => 'text', size => 4, maxlength => 3, title => "\u$endpoints{$endpoint}{english} $col" }; … … 366 366 } 367 367 if (@pokemonids) { 368 $joins{pokemo ves} = 1;369 $criteria{'pokemo ves.pokeid'} = \@pokemonids;370 $clauses{having}{'COUNT(DISTINCT pokemo ves.pokeid, pokemoves.moveid)'} = scalar @pokemonids;368 $joins{pokemon_moves} = 1; 369 $criteria{'pokemon_moves.pokemon_id'} = \@pokemonids; 370 $clauses{having}{'COUNT(DISTINCT pokemon_moves.pokemon_id, pokemon_moves.move_id)'} = scalar @pokemonids; 371 371 372 372 if ($p->{move_method}) { 373 $criteria{'pokemo ves.method'} = $p->{move_method};373 $criteria{'pokemon_moves.method'} = $p->{move_method}; 374 374 } 375 375 if ($p->{move_version}) { 376 push @{$criteria{'-and'}}, { '-or', [ map { \ "FIND_IN_SET('$_', pokemo ves.version)" } Vee::Utils::array($p->{move_version}) ] };376 push @{$criteria{'-and'}}, { '-or', [ map { \ "FIND_IN_SET('$_', pokemon_moves.versions)" } Vee::Utils::array($p->{move_version}) ] }; 377 377 } 378 378 } … … 380 380 381 381 # NUMBERS 382 for my $numbar (qw/power acc pp effect_chance priority/) {382 for my $numbar (qw/power accuracy pp effect_chance priority/) { 383 383 for my $endpoint (keys %endpoints) { 384 384 my $value = $p->{$numbar . '_' . $endpoint}; -
veekun/trunk/lib/Vee/Controller/Dex/Utils.pm
r371 r406 102 102 my @pokemon; 103 103 104 my (@rows, @pokemo ves);104 my (@rows, @pokemon_moves); 105 105 # only do this if there are actually correct Pokemon to look up! 106 106 if (@pokemon_ids) { … … 116 116 117 117 # get moves 118 my $move_rs = $c->model('DBIC::Poke Moves')->search({119 poke id => [ keys %pokemon_order ],120 method => [qw/level machine egg tutor/],121 -nest => \ "FIND_IN_SET('$version', version)",118 my $move_rs = $c->model('DBIC::PokemonMoves')->search({ 119 pokemon_id => [ keys %pokemon_order ], 120 method => [qw/level machine egg tutor/], 121 -nest => \ "FIND_IN_SET('$version', versions)", 122 122 }); 123 123 while (my $row = $move_rs->next) { 124 push @{ $pokemo ves[ $_ ]{ $row->method } }, $row for @{ $pokemon_order{$row->pokeid} }125 } 126 } 127 128 $s->{pokemon} = \@pokemon;129 $s->{pokemon_raw} = \@pokemon_raw;130 $s->{pokemo ves} = \@pokemoves;124 push @{ $pokemon_moves[ $_ ]{ $row->method } }, $row for @{ $pokemon_order{$row->pokemon_id} } 125 } 126 } 127 128 $s->{pokemon} = \@pokemon; 129 $s->{pokemon_raw} = \@pokemon_raw; 130 $s->{pokemon_moves} = \@pokemon_moves; 131 131 132 132 $s->{template} = 'dex/utils/compare-results.tt'; … … 173 173 # ensure this move is actually inheritable 174 174 # TODO: should I error if the move is learnable normally? 175 my $inheritable_ct = $c->model('DBIC::Poke Moves')->count({176 poke id => $pokemon->id,177 move id=> $move->id,178 method => [qw/ egg machine /],179 -nest => \ "FIND_IN_SET('$gen', version)",175 my $inheritable_ct = $c->model('DBIC::PokemonMoves')->count({ 176 pokemon_id => $pokemon->id, 177 move_id => $move->id, 178 method => [qw/ egg machine /], 179 -nest => \ "FIND_IN_SET('$gen', versions)", 180 180 }); 181 181 $c->vee_stop('', $pokemon->name, " can't inherit ", $move->name, '.') unless $inheritable_ct; 182 182 183 183 my $gender_restriction; 184 if ($pokemon->gender == 255) {184 if ($pokemon->gender_rate == 255) { 185 185 # must also be genderless, i.e. bred with Ditto 186 186 $gender_restriction = 255; … … 192 192 ### grab the methods by which any Pokemon learn the move 193 193 194 my $methods_rs = $c->model('DBIC::Poke Moves')->search({195 move id => $move->id,196 method => [qw[ level egg machine ]],197 -nest => \ "FIND_IN_SET('$gen', version)",198 'pokemon.gender ' => $gender_restriction,194 my $methods_rs = $c->model('DBIC::PokemonMoves')->search({ 195 move_id => $move->id, 196 method => [qw[ level egg machine ]], 197 -nest => \ "FIND_IN_SET('$gen', versions)", 198 'pokemon.gender_rate' => $gender_restriction, 199 199 }, { 200 200 join => 'pokemon', … … 208 208 $method = 'TM/HM'; 209 209 } 210 push @{ $learn_methods{ $row->poke id } }, $method;210 push @{ $learn_methods{ $row->pokemon_id } }, $method; 211 211 } 212 212 … … 259 259 my %branches; 260 260 261 while (my $poke id = shift @this_level) {262 my $this_poke = $pokemon{$poke id};261 while (my $pokemon_id = shift @this_level) { 262 my $this_poke = $pokemon{$pokemon_id}; 263 263 my $hashref = shift @this_level; 264 264 265 for my $poke id (keys %pokemon) {266 next if not $this_poke->can_breed_with( $pokemon{$poke id} );267 268 if (exists $seen{ $poke id }) {265 for my $pokemon_id (keys %pokemon) { 266 next if not $this_poke->can_breed_with( $pokemon{$pokemon_id} ); 267 268 if (exists $seen{ $pokemon_id }) { 269 269 # don't put anything if this Pokemon has been seen higher 270 270 # in the chain; needless descending is bad 271 $hashref->{ $poke id } = undef272 unless $seen{ $poke id } < $cur_level;271 $hashref->{ $pokemon_id } = undef 272 unless $seen{ $pokemon_id } < $cur_level; 273 273 } else { 274 $hashref->{ $pokeid } = ( $branches{$pokeid} ||= {} );275 $seen{ $pokeid} = $cur_level;274 $hashref->{$pokemon_id} = ( $branches{$pokemon_id} ||= {} ); 275 $seen{$pokemon_id} = $cur_level; 276 276 } 277 277 } -
veekun/trunk/lib/Vee/Controller/Forum.pm
r386 r406 58 58 59 59 $s->{announcements_rs} = $c->model('DBIC::Threads')->search_announcements; 60 $s->{forums_rs} = $c->model('DBIC::Forums')->search(undef, { prefetch => { last post => 'user' } });60 $s->{forums_rs} = $c->model('DBIC::Forums')->search(undef, { prefetch => { last_post => 'user' } }); 61 61 62 62 # Grab a list of forums with unread threads … … 97 97 $s->{skip} = $skip; 98 98 $s->{threads_rs} = $forum->search_related('threads', undef, { 99 order_by => 'FIND_IN_SET("sticky", me.flags) > 0 DESC, last post.time DESC',100 prefetch => { first post => 'user', lastpost => 'user' },99 order_by => 'FIND_IN_SET("sticky", me.flags) > 0 DESC, last_post.time DESC', 100 prefetch => { first_post => 'user', last_post => 'user' }, 101 101 offset => $skip, 102 102 rows => $perpage, … … 117 117 # form generation stuff 118 118 my $reply_fields = { 119 message=> { type => 'textarea', rows => '10', cols => '100' },119 content => { type => 'textarea', rows => '10', cols => '100' }, 120 120 id => { type => 'hidden' }, 121 121 subject => { type => 'text', maxlength => 48 }, … … 148 148 my $thread = $c->model('DBIC::Threads')->find($id, { prefetch => 'forum' }) 149 149 or $c->vee_abort('There is no thread with id ', $id, '.'); 150 $thread-> hitct( $thread->hitct + 1 ); $thread->update;150 $thread->view_count( $thread->view_count + 1 ); $thread->update; 151 151 152 152 if ($thread->flags =~ /deleted/ and not $c->can_i(override_thread_deleted => $thread->forum->id)) { … … 161 161 $filter_user = $c->model('DBIC::Users')->search({ name => $filter })->first; 162 162 if ($filter_user) { 163 my $posts_shown = $c->model('DBIC::Posts')->count({ thread id => $id, userid => $filter_user->id });163 my $posts_shown = $c->model('DBIC::Posts')->count({ thread_id => $id, user_id => $filter_user->id }); 164 164 } else { 165 165 push @{ $s->{error_msg} }, "Can't find user " . $c->vee_cleanse($filter) . " in the database."; … … 169 169 170 170 my $perpage = $c->site_opts->{page_sizes}{posts}; 171 my $lastpage = ($skip + $perpage >= $thread->post ct);171 my $lastpage = ($skip + $perpage >= $thread->post_count); 172 172 my $posts_rs = $c->model('DBIC::Posts')->search( 173 { 'me.thread id' => $id, ( $filter_user ? ( 'me.userid' => $filter_user->id ) : () ) },173 { 'me.thread_id' => $id, ( $filter_user ? ( 'me.user_id' => $filter_user->id ) : () ) }, 174 174 { prefetch => [ 'user', { 'lastedit', 'user' } ], order_by => 'me.time ASC', offset => $skip, rows => $perpage + 1 } 175 175 ); 176 my $post ct = $c->model('DBIC::Posts')->count({ 'me.threadid' => $id, ( $filter_user ? ( 'me.userid' => $filter_user->id ) : () ) });176 my $post_count = $c->model('DBIC::Posts')->count({ 'me.thread_id' => $id, ( $filter_user ? ( 'me.user_id' => $filter_user->id ) : () ) }); 177 177 my @flags = split /,/, $thread->flags; 178 178 … … 211 211 # form generation stuff 212 212 my $reply_fields = { 213 message=> { type => 'textarea', rows => '10', cols => '100' },213 content => { type => 'textarea', rows => '10', cols => '100' }, 214 214 id => { type => 'hidden' }, 215 215 }; … … 236 236 $s->{page_islast} = $lastpage; 237 237 $s->{posts_rs} = $posts_rs; 238 $s->{postct} = $postct;238 $s->{post_count} = $post_count; 239 239 $s->{skip} = $skip; 240 240 $s->{filter} = $filter; … … 257 257 # slurp up the number of (visible) posts before the requested one 258 258 my $offset = $c->model('DBIC::Posts')->count({ 259 thread id => $post->threadid,259 thread_id => $post->thread_id, 260 260 -or => [ 261 261 { time => $post->time, id => { '<', $post->id } }, … … 266 266 my $perpage = $c->site_opts->{page_sizes}{posts}; 267 267 my $skip = $offset - $offset % $perpage; 268 $c->res->redirect( $c->uri('Forum', 'thread', $post->thread id, ($skip ? { skip => $skip } : ()) ) . "#p$id" );268 $c->res->redirect( $c->uri('Forum', 'thread', $post->thread_id, ($skip ? { skip => $skip } : ()) ) . "#p$id" ); 269 269 } 270 270 … … 276 276 277 277 sub thread_flags : LocalRegex('^thread/(\d*)/(announcement|sticky|locked)') : Args(0) { 278 my ( $self, $c) = @_;279 my ( $threadid, $flag) = @{ $c->req->captures };280 281 my $thread = $c->model('DBIC::Threads')->find($thread id);278 my ($self, $c) = @_; 279 my ($thread_id, $flag) = @{ $c->req->captures }; 280 281 my $thread = $c->model('DBIC::Threads')->find($thread_id); 282 282 283 283 toggleflag($thread, $flag) 284 284 or $c->vee_abort("Whoops! Error setting flag '", $flag, "'. Not much more can be said about this."); 285 $c->res->redirect($c->uri('Forum', 'thread', $thread id));285 $c->res->redirect($c->uri('Forum', 'thread', $thread_id)); 286 286 } 287 287 -
veekun/trunk/lib/Vee/Controller/Forum/Create.pm
r384 r406 50 50 51 51 # TODO: make these redir to an actual post page when one exists 52 $c->vee_abort('Please enter a message.') unless $c->req->params->{ message} =~ /\S/;52 $c->vee_abort('Please enter a message.') unless $c->req->params->{content} =~ /\S/; 53 53 $c->vee_abort('No thread id specified. This should not happen. Sorry?') unless $c->req->params->{id}; 54 54 … … 60 60 } 61 61 62 my ($parsed_message, @bbcode_errors) = Vee::BBCode::validate_bbcode( $c->req->params->{ message} );62 my ($parsed_message, @bbcode_errors) = Vee::BBCode::validate_bbcode( $c->req->params->{content} ); 63 63 if (@bbcode_errors) { 64 64 $c->vee_abort("Your post contains invalid bbcode. Please go back and fix it."); … … 73 73 # TODO: apply this to thread creation too? not as common.. and merge as well? 74 74 my $last_post = $c->model('DBIC::Posts')->search({ 75 thread id => $thread->id,76 time => { '>=', time - $c->site_opts->{post_automerge_time} },75 thread_id => $thread->id, 76 time => { '>=', time - $c->site_opts->{post_automerge_time} }, 77 77 }, { 78 order_by => 'time DESC',78 order_by => 'time DESC', 79 79 })->single; 80 80 81 81 my $post; 82 82 # only do merging/prevention if the last post is this user's 83 if ($last_post and $last_post->user id == $c->user->obj->id and $last_post->flags !~ /deleted/) {84 if ($last_post-> messageeq $parsed_message) {83 if ($last_post and $last_post->user_id == $c->user->obj->id and $last_post->flags !~ /deleted/) { 84 if ($last_post->content eq $parsed_message) { 85 85 $c->vee_abort("You have already posted that message recently."); 86 86 } … … 90 90 $post = $c->model('DBIC')->schema->txn_do( sub { 91 91 my $edit = $c->model('DBIC::Edits')->create({ 92 post id => $last_post->id,93 user id => $c->user->obj->id,94 time => time,95 old message => $last_post->message,92 post_id => $last_post->id, 93 user_id => $c->user->obj->id, 94 time => time, 95 old_content => $last_post->content, 96 96 }); 97 $last_post-> message(98 $last_post-> message.97 $last_post->content( 98 $last_post->content . 99 99 "\n[hr][i]Automerged:[/i]\n" . 100 100 $parsed_message 101 101 ); 102 $last_post->last editid( $edit->id );102 $last_post->last_edit_id( $edit->id ); 103 103 $last_post->time( time ); 104 104 $last_post->update; 105 105 106 $thread->last postid( $last_post->id );107 $thread->last time( time );106 $thread->last_post_id( $last_post->id ); 107 $thread->last_post_time( time ); 108 108 $thread->update; 109 109 … … 114 114 $post = $c->model('DBIC')->schema->txn_do( sub { 115 115 my $post = $c->model('DBIC::Posts')->create({ 116 thread id => $thread->id,117 user id => $c->user->obj->id,118 time => time,119 format => 'bbcode',120 message=> $parsed_message,116 thread_id => $thread->id, 117 user_id => $c->user->obj->id, 118 time => time, 119 format => 'bbcode', 120 content => $parsed_message, 121 121 }); 122 122 # update thread's last-post stats 123 $thread->last postid( $post->id );124 $thread->last time( time );125 $thread->post ct( $thread->postct + 1 );123 $thread->last_post_id( $post->id ); 124 $thread->last_post_time( time ); 125 $thread->post_count( $thread->post_count + 1 ); 126 126 $thread->update; 127 127 # update forum's last-post stats 128 $thread->forum->last postid( $post->id );129 $thread->forum->post ct( $thread->forum->postct + 1 );128 $thread->forum->last_post_id( $post->id ); 129 $thread->forum->post_count( $thread->forum->post_count + 1 ); 130 130 $thread->forum->update; 131 131 # update user's postcount 132 $c->user->obj->post ct( $c->user->postct + 1 );132 $c->user->obj->post_count( $c->user->post_count + 1 ); 133 133 $c->user->obj->update; 134 134 return $post; … … 149 149 my $s = $c->stash; 150 150 151 my ($parsed_message, @bbcode_errors) = Vee::BBCode::validate_bbcode( $c->req->params->{ message} );151 my ($parsed_message, @bbcode_errors) = Vee::BBCode::validate_bbcode( $c->req->params->{content} ); 152 152 if (@bbcode_errors) { 153 153 $c->vee_abort("Your post contains invalid bbcode. Please go back and fix it."); … … 156 156 157 157 my $rows = $c->site_opts->{page_sizes}{posts_preview}; 158 my $offset = $c->model('DBIC::Posts')->count({ thread id => $thread->id }, { order_by => 'me.time ASC' } );158 my $offset = $c->model('DBIC::Posts')->count({ thread_id => $thread->id }, { order_by => 'me.time ASC' } ); 159 159 $offset = $offset - $rows; 160 160 161 my $posts_rs = $c->model('DBIC::Posts')->search({ thread id => $thread->id }, {161 my $posts_rs = $c->model('DBIC::Posts')->search({ thread_id => $thread->id }, { 162 162 order_by => 'me.time ASC', 163 163 offset => $offset, … … 167 167 # form generation stuff 168 168 my $reply_fields = { 169 message=> { type => 'textarea', rows => '10', cols => '100' },169 content => { type => 'textarea', rows => '10', cols => '100' }, 170 170 id => { type => 'hidden' }, 171 171 }; … … 207 207 208 208 # TODO: make these redir to an actual post page when one exists 209 $c->vee_abort("You must enter a message.") unless $c->req->params->{ message} =~ /\S/;209 $c->vee_abort("You must enter a message.") unless $c->req->params->{content} =~ /\S/; 210 210 $c->vee_abort("You must enter a subject.") unless $c->req->params->{subject} =~ /\S/; 211 211 212 my ($parsed_message, @bbcode_errors) = Vee::BBCode::validate_bbcode( $c->req->params->{ message} );212 my ($parsed_message, @bbcode_errors) = Vee::BBCode::validate_bbcode( $c->req->params->{content} ); 213 213 if (@bbcode_errors) { 214 214 $c->detach('thread_preview'); … … 229 229 my $thread = $c->model('DBIC')->schema->txn_do( sub { 230 230 my $thread = $c->model('DBIC::Threads')->create({ 231 forum id=> $forum->id,232 subject => $subject,233 first postid=> 0,234 last postid=> 0,235 last time=> time,236 post ct=> 1,237 blurb => $blurb,231 forum_id => $forum->id, 232 subject => $subject, 233 first_post_id => 0, 234 last_post_id => 0, 235 last_post_time => time, 236 post_count => 1, 237 blurb => $blurb, 238 238 }); 239 239 # create the post 240 240 my $post = $c->model('DBIC::Posts')->create({ 241 thread id => $thread->id,242 user id => $c->user->obj->id,243 time => time,244 format => 'bbcode',245 message=> Vee::Utils::fix_newlines( $parsed_message ),241 thread_id => $thread->id, 242 user_id => $c->user->obj->id, 243 time => time, 244 format => 'bbcode', 245 content => Vee::Utils::fix_newlines( $parsed_message ), 246 246 }); 247 247 # update thread's last-post stats 248 $thread->first postid( $post->id );249 $thread->last postid( $post->id );248 $thread->first_post_id( $post->id ); 249 $thread->last_post_id( $post->id ); 250 250 $thread->update; 251 251 # update forum's last-post stats 252 $forum->last postid( $post->id );253 $forum->post ct( $forum->postct + 1 );254 $forum->thread ct( $forum->threadct + 1 );252 $forum->last_post_id( $post->id ); 253 $forum->post_count( $forum->post_count + 1 ); 254 $forum->thread_count( $forum->thread_count + 1 ); 255 255 $forum->update; 256 256 # update user's postcount 257 $c->user->obj->post ct( $c->user->postct + 1 );257 $c->user->obj->post_count( $c->user->post_count + 1 ); 258 258 $c->user->obj->update; 259 259 return $thread; … … 275 275 my $subject = $c->req->params->{subject}; 276 276 my $blurb = $c->req->params->{blurb}; 277 my $ message = $c->req->params->{message};277 my $content = $c->req->params->{content}; 278 278 my $forum = $c->model('DBIC::Forums')->find( $c->req->params->{id} ) 279 279 or $c->vee_abort('There is no forum with an id of ', $c->req->params->{id}, '. It may have been deleted while you were typing?'); … … 283 283 } 284 284 285 my ($parsed_message, @bbcode_errors) = Vee::BBCode::validate_bbcode( $message);285 my ($parsed_message, @bbcode_errors) = Vee::BBCode::validate_bbcode($content); 286 286 if (@bbcode_errors) { 287 287 $c->vee_abort("Your post contains invalid bbcode. Please fix it."); … … 290 290 # form generation stuff 291 291 my $reply_fields = { 292 message=> { type => 'textarea', rows => '10', cols => '100' },292 content => { type => 'textarea', rows => '10', cols => '100' }, 293 293 id => { type => 'hidden' }, 294 294 subject => { type => 'text', maxlength => 48 }, -
veekun/trunk/lib/Vee/Controller/Forum/Post.pm
r327 r406 51 51 sub utils : LocalRegex('^(\d*)/(delete|undelete|nuke)') : Args(0) { 52 52 my ( $self, $c ) = @_; 53 my ($post id, $method) = @{ $c->req->captures };54 55 my $forum id = undef;53 my ($post_id, $method) = @{ $c->req->captures }; 54 55 my $forum_id = undef; 56 56 # This is the post to be deleted, as well as the entire result set of things to be modified 57 my $post = $c->model('DBIC::Posts')->find({ 'me.id' => $post id }, { prefetch => ['user', { 'thread' => 'forum' }], })58 or $c->vee_abort("There is no post with id of ", $post id, ". Perhaps another admin nuked it?");59 $c->vee_abort("The post with id of ", $post id, " has already been ", $method, "d.")57 my $post = $c->model('DBIC::Posts')->find({ 'me.id' => $post_id }, { prefetch => ['user', { 'thread' => 'forum' }], }) 58 or $c->vee_abort("There is no post with id of ", $post_id, ". Perhaps another admin nuked it?"); 59 $c->vee_abort("The post with id of ", $post_id, " has already been ", $method, "d.") 60 60 if (($post->flags =~ /deleted/ && $method eq 'delete') || ($post->flags !~ /deleted/ && $method eq 'undelete')); 61 61 $c->vee_abort("You don't have permission to ", $method, " this post.") 62 unless (($c->user->obj->id == $post->user id && $method ne 'nuke') || $c->can_i("post$method"));62 unless (($c->user->obj->id == $post->user_id && $method ne 'nuke') || $c->can_i("post$method")); 63 63 64 64 # Do everything in a transaction for rollback purposes … … 66 66 my ($thread, $forum, $user) = ($post->thread, $post->thread->forum, $post->user); 67 67 # If any of the post (or thread) counts are 0 or less, this will break. Of course, if that's the case, something is broken 68 return undef unless (($forum->post ct >= 0 || $forum->threadct >= 0 || $thread->postct >= 0 || $user->postct >= 0) || ($method eq 'undelete'));69 my $thread_postct = $c->model('DBIC::Posts')->count({ 'me.thread id' => $post->threadid, 'me.flags' => { '!=', 'deleted' } });68 return undef unless (($forum->post_count >= 0 || $forum->thread_count >= 0 || $thread->post_count >= 0 || $user->post_count >= 0) || ($method eq 'undelete')); 69 my $thread_postct = $c->model('DBIC::Posts')->count({ 'me.thread_id' => $post->thread_id, 'me.flags' => { '!=', 'deleted' } }); 70 70 # Unfortunately, this must be done here, since this needs to include deleted posts as well 71 my ($last postid, $lasttime) = ((map {($_->id)} $c->model('DBIC::Posts')->search({ 'thread.forumid' => $forum->id, 'me.threadid' => $post->threadid }, { prefetch => 'thread', columns => [qw/me.id me.threadid thread.forumid/], order_by => 'me.time DESC' })), undef);72 73 if ($method eq 'nuke') { $c->model('DBIC::Posts')->search({ 'me.id' => $post id})->delete; }71 my ($last_post_id, $last_post_time) = ((map {($_->id)} $c->model('DBIC::Posts')->search({ 'thread.forum_id' => $forum->id, 'me.thread_id' => $post->thread_id }, { prefetch => 'thread', columns => [qw/me.id me.thread_id thread.forum_id/], order_by => 'me.time DESC' })), undef); 72 73 if ($method eq 'nuke') { $c->model('DBIC::Posts')->search({ 'me.id' => $post_id })->delete; } 74 74 else { toggleflag( $post, 'deleted' ) or return undef; } 75 75 76 76 # If there's only one post left, delete the thread as well 77 if ($thread_postct > 1 && $last postid == $post->id) {78 ($last time, $lastpostid) = map {($_->time, $_->id)} $c->model('DBIC::Posts')->search({ 'thread.forumid' => $forum->id, 'me.threadid' => $post->threadid, 'me.flags' => { '!=', 'deleted' } }, { prefetch => 'thread', rows => 1, order_by => 'me.time DESC' });77 if ($thread_postct > 1 && $last_post_id == $post->id) { 78 ($last_post_time, $last_post_id) = map {($_->time, $_->id)} $c->model('DBIC::Posts')->search({ 'thread.forum_id' => $forum->id, 'me.thread_id' => $post->thread_id, 'me.flags' => { '!=', 'deleted' } }, { prefetch => 'thread', rows => 1, order_by => 'me.time DESC' }); 79 79 } elsif ($thread_postct <= 1) { 80 80 #try moving this elsewhere later, i hate it here 81 if ($method eq 'nuke') { $c->model('DBIC::Threads')->search({ 'me.id' => $post->thread id })->delete; }81 if ($method eq 'nuke') { $c->model('DBIC::Threads')->search({ 'me.id' => $post->thread_id })->delete; } 82 82 elsif (($method eq 'undelete' && $thread_postct == 0) || ($method eq 'delete' && $thread_postct <= 1)) { 83 83 toggleflag( $thread, 'deleted' ) or return undef; 84 84 } 85 ($last time, $lastpostid) = map {($_->time, $_->id)} $c->model('DBIC::Posts')->search({ 'thread.forumid' => $forum->id, 'thread.flags' => { '!=', 'deleted' }, 'me.flags' => { '!=', 'deleted' } }, { prefetch => 'thread', rows => 1, order_by => 'me.time DESC' });86 $forum id = $forum->id;87 $last postid = 0 unless $lastpostid;85 ($last_post_time, $last_post_id) = map {($_->time, $_->id)} $c->model('DBIC::Posts')->search({ 'thread.forum_id' => $forum->id, 'thread.flags' => { '!=', 'deleted' }, 'me.flags' => { '!=', 'deleted' } }, { prefetch => 'thread', rows => 1, order_by => 'me.time DESC' }); 86 $forum_id = $forum->id; 87 $last_post_id = 0 unless $last_post_id; 88 88 } 89 89 90 90 if (($method eq 'nuke' && $post->flags !~ /deleted/) || ($method eq 'delete')) { 91 $thread->post ct($thread->postct - 1);92 $forum->post ct($forum->postct - 1);93 $forum->thread ct($forum->threadct - 1) unless ($thread_postct > 1);94 $user->post ct($user->postct - 1);91 $thread->post_count($thread->post_count - 1); 92 $forum->post_count($forum->post_count - 1); 93 $forum->thread_count($forum->thread_count - 1) unless ($thread_postct > 1); 94 $user->post_count($user->post_count - 1); 95 95 } elsif ($method eq 'undelete') { 96 $thread->post ct($thread->postct + 1);97 $forum->post ct($forum->postct + 1);98 $forum->thread ct($forum->threadct + 1) unless ($thread_postct > 1);99 $user->post ct($user->postct + 1);100 } 101 # Only update last post and lasttime if this is actually the last post102 if ($last time && $post->id == $thread->lastpostid) {103 $thread->last postid($lastpostid);104 $thread->last time($lasttime);96 $thread->post_count($thread->post_count + 1); 97 $forum->post_count($forum->post_count + 1); 98 $forum->thread_count($forum->thread_count + 1) unless ($thread_postct > 1); 99 $user->post_count($user->post_count + 1); 100 } 101 # Only update last post and time if this is actually the last post 102 if ($last_post_time && $post->id == $thread->last_post_id) { 103 $thread->last_post_id($last_post_id); 104 $thread->last_post_time($last_post_time); 105 105 } 106 106 # Needs to be done here, in case the deleted post is the last post in a forum :( 107 $forum->last postid($lastpostid) if $post->id == $forum->lastpostid;107 $forum->last_post_id($last_post_id) if $post->id == $forum->last_post_id; 108 108 $thread->update if ($method ne 'nuke'); 109 109 $forum->update; … … 114 114 115 115 $c->error("This error message should never be displayed unless someone is screwing with things; sorry.") unless $action; 116 $c->res->redirect("/forum/" . (($forum id) ? "$forumid" : "post/$postid"));116 $c->res->redirect("/forum/" . (($forum_id) ? "$forum_id" : "post/$post_id")); 117 117 } 118 118 … … 125 125 sub edits : LocalRegex('^(\d*)/edits') { 126 126 my ($self, $c) = @_; 127 my ($s, $post id) = ($c->stash, $c->req->captures->[0]);127 my ($s, $post_id) = ($c->stash, $c->req->captures->[0]); 128 128 129 129 $c->vee_abort("You don't have permission to view post edits.") unless ($c->can_i('post_edits')); 130 130 131 my $post = $c->model('DBIC::Posts')->find({ 'me.id' => $post id}, { prefetch => [qw/user edits/, { thread => 'forum' }], order_by => 'edits.time DESC' });131 my $post = $c->model('DBIC::Posts')->find({ 'me.id' => $post_id}, { prefetch => [qw/user edits/, { thread => 'forum' }], order_by => 'edits.time DESC' }); 132 132 133 133 $s->{post} = $post; … … 143 143 144 144 my $reply_fields = { 145 message=> { type => 'textarea', rows => '10', cols => '100' },145 content => { type => 'textarea', rows => '10', cols => '100' }, 146 146 id => { type => 'hidden' }, 147 147 }; … … 149 149 sub edit : LocalRegex('^(\d*)/edit') : Args(0) { 150 150 my ($self, $c) = @_; 151 my ($s, $post id) = ($c->stash, $c->req->captures->[0]);152 153 my $post_rs = $c->model('DBIC::Posts')->search({ 'me.id' => $post id }, { prefetch => 'user' })->single;151 my ($s, $post_id) = ($c->stash, $c->req->captures->[0]); 152 153 my $post_rs = $c->model('DBIC::Posts')->search({ 'me.id' => $post_id }, { prefetch => 'user' })->single; 154 154 $c->vee_abort("You must be logged in to edit posts.") unless $c->user; 155 $c->vee_abort("You don't have permission to edit posts.") unless ($c->can_i('post_edit') || $c->user->obj->id == $post_rs->user id);155 $c->vee_abort("You don't have permission to edit posts.") unless ($c->can_i('post_edit') || $c->user->obj->id == $post_rs->user_id); 156 156 157 157 # Form submited stuff 158 158 if ('post' eq lc $c->req->params->{submit}) { 159 my ($parsed_message, @bbcode_errors) = Vee::BBCode::validate_bbcode( $c->req->params->{ message} );159 my ($parsed_message, @bbcode_errors) = Vee::BBCode::validate_bbcode( $c->req->params->{content} ); 160 160 if (@bbcode_errors) { 161 161 $c->vee_abort("Your post contains invalid bbcode. Please go back and fix it."); … … 164 164 165 165 # If post wasn't edited, don't do anything further; results in redirect only 166 unless ($parsed_message eq $post_rs-> message) {166 unless ($parsed_message eq $post_rs->content) { 167 167 my $post = $c->model('DBIC')->schema->txn_do( sub { 168 168 my $edit = $c->model('DBIC::Edits')->create({ 169 post id => $post_rs->id,170 user id => $c->user->obj->id,171 time => time,172 old message => $post_rs->message,169 post_id => $post_rs->id, 170 user_id => $c->user->obj->id, 171 time => time, 172 old_content => $post_rs->content, 173 173 }); 174 174 175 $post_rs->last editid( $edit->id );176 $post_rs-> message( $parsed_message);175 $post_rs->last_edit_id( $edit->id ); 176 $post_rs->content($parsed_message); 177 177 $post_rs->update; 178 178 … … 189 189 copy_params => 1, 190 190 ); 191 $form->force( id => $post_rs->thread id );192 $form->force( message => $c->req->params->{message} || $post_rs->message|| '' );191 $form->force( id => $post_rs->thread_id ); 192 $form->force( content => $c->req->params->{content} || $post_rs->content || '' ); 193 193 194 194 $s->{page_header} = "Edit Post"; -
veekun/trunk/lib/Vee/Controller/Index.pm
r386 r406 31 31 my $shoutbox_fields = { 32 32 name => { type => 'text', size => 20, maxlength => 20 }, 33 message=> { type => 'textarea', rows => 3, cols => 20 },33 content => { type => 'textarea', rows => 3, cols => 20 }, 34 34 }; 35 35 … … 45 45 my $page_sizes = $c->site_opts->{page_sizes}{index}; 46 46 47 $s->{recent_news} = $news_forum->threads( undef, { prefetch => 'first post', order_by => 'me.id DESC', rows => $page_sizes->{news} } );47 $s->{recent_news} = $news_forum->threads( undef, { prefetch => 'first_post', order_by => 'me.id DESC', rows => $page_sizes->{news} } ); 48 48 $s->{recent_news} = $s->{recent_news}->search(\ 'NOT FIND_IN_SET("deleted", me.flags)') unless $c->can_i(override_thread_deleted => $news_forum->id); 49 49 … … 55 55 $threads_rs = $threads_rs->search({ 'me.flags' => { '!=', 'deleted' } }) unless $c->can_i('override_thread_deleted'); 56 56 $s->{recent_posts} = $threads_rs->search( undef, { 57 order_by => 'last post.time DESC',57 order_by => 'last_post.time DESC', 58 58 rows => $page_sizes->{forum}, 59 prefetch => { last post => 'user' },59 prefetch => { last_post => 'user' }, 60 60 } ); 61 61 62 62 # NOT FIND_IN_SET breaks here; why? 63 $s->{recent_posts} = $s->{recent_posts}->search({ 'last post.flags' => { '!=', 'deleted' } }) unless $c->can_i('override_thread_deleted');63 $s->{recent_posts} = $s->{recent_posts}->search({ 'last_post.flags' => { '!=', 'deleted' } }) unless $c->can_i('override_thread_deleted'); 64 64 65 65 # Grab a list of unread threads … … 102 102 103 103 $s->{recent_users} = $c->model('DBIC::Users')->search( 104 { lastactive => { '>', time - $c->site_opts->{user_activity_timeout} } },105 { order_by => 'me. lastactive DESC' }104 { time_active => { '>', time - $c->site_opts->{user_activity_timeout} } }, 105 { order_by => 'me.time_active DESC' } 106 106 ); 107 107 -
veekun/trunk/lib/Vee/Controller/Root.pm
r363 r406 49 49 $storage->debug(1); 50 50 51 if ($c->user) { $c->user->obj-> lastactive(time); $c->user->obj->update; }51 if ($c->user) { $c->user->obj->time_active(time); $c->user->obj->update; } 52 52 53 53 if ($c->flash and %{$c->flash}) { … … 97 97 eval { 98 98 $c->model('DBIC::ErrorLog')->create({ 99 time => time,100 user id => $c->user ? $c->user->obj->id : 0,101 ip => Vee::Utils::inet_aton($c->req->address),102 path => $c->req->path,103 method => $c->req->method,104 query => Dumper($c->req->params),105 error => join "\n", @{$c->error},99 time => time, 100 user_id => $c->user ? $c->user->obj->id : 0, 101 ip => Vee::Utils::inet_aton($c->req->address), 102 path => $c->req->path, 103 method => $c->req->method, 104 query => Dumper($c->req->params), 105 error => join "\n", @{$c->error}, 106 106 }); 107 107 }; -
veekun/trunk/lib/Vee/Controller/Shoutbox.pm
r288 r406 59 59 my $s = $c->stash; 60 60 61 my $ message = Vee::Utils::fix_newlines( $c->req->params->{message} );61 my $content = Vee::Utils::fix_newlines( $c->req->params->{content} ); 62 62 my $name = $c->req->params->{name} 63 63 || ($c->user ? $c->user->name : 'Anonymous'); 64 64 65 if (!$ message) {65 if (!$content) { 66 66 $c->vee_abort("Sorry, no mimes allowed."); 67 67 } 68 68 69 (my $linect = $ message) =~ tr/\x0a//cd;69 (my $linect = $content) =~ tr/\x0a//cd; 70 70 if (length($linect) >= 10) { # TODO: make me a pref! 71 71 $c->vee_abort("Your shoutbox entry has too many lines, sorry."); … … 73 73 74 74 # TODO: better spamproofing of some sort later, maybe? 75 if ($ message=~ m!<a |</a>|\[url=|\[/url\]!) {75 if ($content =~ m!<a |</a>|\[url=|\[/url\]!) { 76 76 $c->vee_abort("Your shoutbox entry contains links. This usually means you are a spambot, in which case you can shove your online poker ads where the sun don't shine. If you are not, simply go back and try again without the code; HTML and bbcode don't work in the shoutbox anyway."); 77 77 } … … 79 79 $c->model('DBIC::Shoutbox')->create({ 80 80 name => $name, 81 user id => ($c->user ? $c->user->obj->id : undef),81 user_id => ($c->user ? $c->user->obj->id : undef), 82 82 ip => Vee::Utils::inet_aton($c->req->address), 83 83 time => time, 84 message => $message,84 content => $content, 85 85 }); 86 86 -
veekun/trunk/lib/Vee/Controller/Users.pm
r397 r406 104 104 name => $p->{username}, 105 105 password => sha1_hex( $p->{password}[0] ), 106 joindate=> time,107 lastactive => time,106 time_joined => time, 107 time_active => time, 108 108 signature => '', 109 109 thread_view_cutoff => time, … … 205 205 my $skip = $c->req->params->{skip} || 0; 206 206 207 unless (Vee::Utils::in($order => qw/id name lastactive joindate postct/)) { $order = 'id'; }207 unless (Vee::Utils::in($order => qw/id name time_active time_joined post_count/)) { $order = 'id'; } 208 208 unless (Vee::Utils::in($sort => qw/asc desc/)) { $sort = 'asc'; } 209 209 … … 242 242 $s->{crumbs } = [ '<a href="' . $c->uri('User') . '">Users</a>', $user->name ]; 243 243 $s->{ContactTypes} = \@ContactTypes; 244 $s->{recent_post} = $c->model('DBIC::Posts')->search({ -and => [ user id => $c->req->args->[0], \'NOT FIND_IN_SET("deleted", me.flags)' ] }, {244 $s->{recent_post} = $c->model('DBIC::Posts')->search({ -and => [ user_id => $c->req->args->[0], \'NOT FIND_IN_SET("deleted", me.flags)' ] }, { 245 245 order_by => 'me.time DESC', 246 246 rows => 1 … … 349 349 # Working with text data (sigs, title, etc) 350 350 # Title 351 if ($changes{custom title}) {351 if ($changes{custom_title}) { 352 352 # no fathomable reason this should ever be needed un-filtered, so just sanitize it now 353 $changes{custom title} =~ s:[\x0d\x0a]::g;354 $changes{custom title} = Vee::Utils::cleanse( $changes{customtitle} );355 356 if (length $query->{custom title} >= $user_limits->{customtitle}) {357 push @errors, 'Custom title is longer than the maximum of ' . $user_limits->{custom title} . ' characters.';358 delete $changes{custom title};353 $changes{custom_title} =~ s:[\x0d\x0a]::g; 354 $changes{custom_title} = Vee::Utils::cleanse( $changes{custom_title} ); 355 356 if (length $query->{custom_title} >= $user_limits->{custom_title}) { 357 push @errors, 'Custom title is longer than the maximum of ' . $user_limits->{custom_title} . ' characters.'; 358 delete $changes{custom_title}; 359 359 } else { 360 push @success, 'Updated your custom title to "' . $changes{custom title} . '".';361 } 362 } elsif (exists $changes{custom title} and $c->user->customtitle) {360 push @success, 'Updated your custom title to "' . $changes{custom_title} . '".'; 361 } 362 } elsif (exists $changes{custom_title} and $c->user->custom_title) { 363 363 push @success, 'Deleted your custom title.'; 364 364 } -
veekun/trunk/lib/Vee/Controller/Users/Stats.pm
r383 r406 53 53 54 54 my $posters_rs = $c->model('DBIC::Users')->search({ 55 post ct=> { '!=', 0 },55 post_count => { '!=', 0 }, 56 56 }, { 57 order_by => 'postct DESC',58 rows => 10,59 columns => [qw[ name postct ]],57 order_by => 'post_count DESC', 58 rows => 10, 59 columns => [qw[ name post_count ]], 60 60 }); 61 61 # TODO: when we figure out what "counts" as a post, adjust this to compensate … … 63 63 64 64 my @fields = $posters_rs->get_column('name')->all; 65 my @data = $posters_rs->get_column('post ct')->all;65 my @data = $posters_rs->get_column('post_count')->all; 66 66 my $top_total = sum @data; 67 67 if ($total_posts > $top_total) { … … 86 86 87 87 my $loudmouths_rs = $c->model('DBIC::Shoutbox')->search(undef, { 88 group_by => 'user id',88 group_by => 'user_id', 89 89 '+select' => \'COUNT(*) AS shout_count', 90 90 '+as' => 'shout_count', -
veekun/trunk/lib/Vee/Dex.pm
r362 r406 235 235 $DamagingMoveCount = $schema->resultset('Moves')->search({ power => { '!=' => undef } })->count; 236 236 237 %TypeData = map { $_->name => $_ } $schema->resultset('Types')->search({ internal id => { '!=' => -1 } });237 %TypeData = map { $_->name => $_ } $schema->resultset('Types')->search({ internal_id => { '!=' => -1 } }); 238 238 @TypeNames = sort keys %TypeData; 239 %OldTypeOrder = map { $_->internal id + 1 => $_->name } values %TypeData; # for Compat.pm239 %OldTypeOrder = map { $_->internal_id + 1 => $_->name } values %TypeData; # for Compat.pm 240 240 @NewTypeOrder = map { $_->name } sort { $a->id <=> $b->id } grep { $_->id >= 0 } values %TypeData; 241 241 … … 255 255 256 256 # machines 257 my @tms = $schema->resultset('Machines')->search(undef, { columns => ['id', 'generation', 'move id'], order_by => 'id ASC' });257 my @tms = $schema->resultset('Machines')->search(undef, { columns => ['id', 'generation', 'move_id'], order_by => 'id ASC' }); 258 258 for my $row (@tms) { 259 $TMs[ $row->generation ][ $row->id ] = $row->move id259 $TMs[ $row->generation ][ $row->id ] = $row->move_id 260 260 } 261 261 … … 558 558 my @gender_fractions = ('no', '⅛', '¼', '⅜', '½', '⅝', '¾', '⅞', 'all'); 559 559 sub gender_text { 560 my $gender code = shift;560 my $gender_rate = shift; 561 561 my $compact = shift; 562 562 563 my $gender = int($gender code / 32 + 0.5);563 my $gender = int($gender_rate / 32 + 0.5); 564 564 my ($img, $text); 565 if ($gender code == 255) {565 if ($gender_rate == 255) { 566 566 $img = 'x'; $text = 'No gender'; 567 567 } else { -
veekun/trunk/lib/Vee/Schema/Abilities.pm
r350 r406 13 13 __PACKAGE__->load_components('Core'); 14 14 __PACKAGE__->table('abilities'); 15 __PACKAGE__->add_columns(qw/ id name gameblurb effect/);15 __PACKAGE__->add_columns(qw/ id name blurb_dp description /); 16 16 __PACKAGE__->set_primary_key('id'); 17 17 18 __PACKAGE__->has_many(pokemon_abilities => 'Vee::Schema::PokemonAbilities', 'ability id');18 __PACKAGE__->has_many(pokemon_abilities => 'Vee::Schema::PokemonAbilities', 'ability_id'); 19 19 __PACKAGE__->many_to_many(pokemon => 'pokemon_abilities', 'pokemon'); 20 20 -
veekun/trunk/lib/Vee/Schema/ContestEffects.pm
r350 r406 1 package Vee::Schema::Contest Moves;1 package Vee::Schema::ContestEffects; 2 2 3 3 use strict; … … 7 7 =head1 NAME 8 8 9 Vee::Schema::Contest Moves - DBIC class for the C<contestmoves> table9 Vee::Schema::ContestEffects - DBIC class for the C<contest_effects> table 10 10 11 11 =cut 12 12 13 13 __PACKAGE__->load_components('Core'); 14 __PACKAGE__->table('contest moves');15 __PACKAGE__->add_columns(qw/ id appeal jam description effect/);14 __PACKAGE__->table('contest_effects'); 15 __PACKAGE__->add_columns(qw/ id appeal jam blurb_rusa description /); 16 16 __PACKAGE__->set_primary_key('id'); 17 17 -
veekun/trunk/lib/Vee/Schema/Creators.pm
r350 r406 13 13 __PACKAGE__->load_components('Core'); 14 14 __PACKAGE__->table('creators'); 15 __PACKAGE__->add_columns(qw/ id user id name itemct /);15 __PACKAGE__->add_columns(qw/ id user_id name item_count /); 16 16 __PACKAGE__->set_primary_key('id'); 17 __PACKAGE__->add_unique_constraint(userid => ['userid']);18 17 19 18 =head1 SEE ALSO -
veekun/trunk/lib/Vee/Schema/Edits.pm
r350 r406 13 13 __PACKAGE__->load_components('Core'); 14 14 __PACKAGE__->table('edits'); 15 __PACKAGE__->add_columns(qw/ id post id userid time oldmessage/);15 __PACKAGE__->add_columns(qw/ id post_id user_id time old_content /); 16 16 __PACKAGE__->set_primary_key('id'); 17 17 18 __PACKAGE__->might_have(post => 'Vee::Schema::Posts', { 'foreign.id' => 'self.post id' });19 __PACKAGE__->might_have(user => 'Vee::Schema::Users', { 'foreign.id' => 'self.user id' });18 __PACKAGE__->might_have(post => 'Vee::Schema::Posts', { 'foreign.id' => 'self.post_id' }); 19 __PACKAGE__->might_have(user => 'Vee::Schema::Users', { 'foreign.id' => 'self.user_id' }); 20 20 21 21 =head1 SEE ALSO -
veekun/trunk/lib/Vee/Schema/ErrorLog.pm
r350 r406 7 7 =head1 NAME 8 8 9 Vee::Schema::ErrorLog - DBIC class for the C<error log> table9 Vee::Schema::ErrorLog - DBIC class for the C<error_log> table 10 10 11 11 =cut 12 12 13 13 __PACKAGE__->load_components('Core'); 14 __PACKAGE__->table('error log');15 __PACKAGE__->add_columns(qw/ id time user id ip path method query error /);14 __PACKAGE__->table('error_log'); 15 __PACKAGE__->add_columns(qw/ id time user_id ip path method query error /); 16 16 __PACKAGE__->set_primary_key('id'); 17 17 -
veekun/trunk/lib/Vee/Schema/EvoChains.pm
r356 r406 1 package Vee::Schema::Ev Chains;1 package Vee::Schema::EvoChains; 2 2 3 3 use strict; … … 5 5 use base 'DBIx::Class'; 6 6 7 # NOTE FOR WHEN THIS IS REFACTORED:8 # I *believe* that base is not actually used anywhere except in pokemon_list,9 # but the IDEA is that it is essentially the Pokemon with the LOWEST NATIONAL10 # DEX NUMBER, thus making it the ORIGINAL FORM of the Pokemon.11 # My SOLE EXCEPTION to this is Manaphy, which is the base of its chain, but12 # only because that's not a real chain anyway.13 # NOTE AGAIN:14 # Nevermind! base is now unused. Delete to your heart's content.15 16 7 =head1 NAME 17 8 18 Vee::Schema::Ev Chains - DBIC class for the C<evchains> table9 Vee::Schema::EvoChains - DBIC class for the C<evo_chains> table 19 10 20 11 =cut 21 12 22 13 __PACKAGE__->load_components('Core'); 23 __PACKAGE__->table('ev chains');14 __PACKAGE__->table('evo_chains'); 24 15 __PACKAGE__->add_columns(qw/ 25 16 id 26 base 27 growth 28 chain 17 growth_rate 29 18 steps 30 31 babygs32 babyc33 babyrusa34 35 19 baby_item 36 20 /); 37 21 __PACKAGE__->set_primary_key('id'); 38 22 39 __PACKAGE__->has_many(pokemon => 'Vee::Schema::Pokemon', 'evid'); 40 # TODO: delete the _pokemon suffix 41 __PACKAGE__->belongs_to(base_pokemon => 'Vee::Schema::Pokemon', 'base'); 23 __PACKAGE__->has_many(pokemon => 'Vee::Schema::Pokemon', 'evo_chain_id'); 42 24 43 25 =head1 SEE ALSO -
veekun/trunk/lib/Vee/Schema/FlavorText.pm
r350 r406 7 7 =head1 NAME 8 8 9 Vee::Schema::FlavorText - DBIC class for the C<flavor text> table9 Vee::Schema::FlavorText - DBIC class for the C<flavor_text> table 10 10 11 11 =cut 12 12 13 13 __PACKAGE__->load_components('Core'); 14 __PACKAGE__->table('flavor text');15 __PACKAGE__->add_columns(qw/ poke id generation text /);14 __PACKAGE__->table('flavor_text'); 15 __PACKAGE__->add_columns(qw/ pokemon_id generation text /); 16 16 17 __PACKAGE__->belongs_to(pokemon => 'Vee::Schema::Pokemon', 'poke id');17 __PACKAGE__->belongs_to(pokemon => 'Vee::Schema::Pokemon', 'pokemon_id'); 18 18 19 19 =head1 SEE ALSO -
veekun/trunk/lib/Vee/Schema/Forums.pm
r386 r406 14 14 __PACKAGE__->table('forums'); 15 15 __PACKAGE__->add_columns(qw/ 16 id name last postid threadct postct flags accessibility blurb16 id name last_post_id thread_count post_count flags accessibility description 17 17 /); 18 18 __PACKAGE__->set_primary_key('id'); 19 19 20 __PACKAGE__->has_many(threads => 'Vee::Schema::Threads', 'forum id');21 __PACKAGE__->might_have(last post => 'Vee::Schema::Posts', { 'foreign.id' => 'self.lastpostid' });20 __PACKAGE__->has_many(threads => 'Vee::Schema::Threads', 'forum_id'); 21 __PACKAGE__->might_have(last_post => 'Vee::Schema::Posts', { 'foreign.id' => 'self.last_post_id' }); 22 22 23 23 =head2 unread_ids($user) … … 33 33 # ambiguity errors 34 34 return map { $_->id } $self->search( { 35 'threads.last time'=> { '>' => $user->thread_view_cutoff },36 'thread_views.last_viewed' => [ undef, \'< threads.last time' ],35 'threads.last_post_time' => { '>' => $user->thread_view_cutoff }, 36 'thread_views.last_viewed' => [ undef, \'< threads.last_post_time' ], 37 37 }, { 38 38 # XXX: This is very naughty, but the only way to stuff the user id in … … 53 53 ], 54 54 ], 55 { 'me.id' => 'threads.forum id' },55 { 'me.id' => 'threads.forum_id' }, 56 56 ], 57 57 ], -
veekun/trunk/lib/Vee/Schema/GalleryKeywords.pm
r350 r406 12 12 13 13 __PACKAGE__->load_components('Core'); 14 __PACKAGE__->table('gallery keywords');14 __PACKAGE__->table('gallery_keywords'); 15 15 __PACKAGE__->add_columns(qw/ id keyword category description /); 16 16 __PACKAGE__->set_primary_key('id'); 17 __PACKAGE__->add_unique_constraint("keyword", ["keyword"]);18 17 19 18 =head1 SEE ALSO -
veekun/trunk/lib/Vee/Schema/GroupPermissions.pm
r350 r406 7 7 =head1 NAME 8 8 9 Vee::Schema::GroupPermissions - DBIC class for the C<group permissions> table9 Vee::Schema::GroupPermissions - DBIC class for the C<group_permissions> table 10 10 11 11 =cut 12 12 13 13 __PACKAGE__->load_components('Core'); 14 __PACKAGE__->table('group permissions');15 __PACKAGE__->add_columns(qw/ group id permission scope polarity /);16 __PACKAGE__->set_primary_key(qw/ group id permission scope /);14 __PACKAGE__->table('group_permissions'); 15 __PACKAGE__->add_columns(qw/ group_id permission scope polarity /); 16 __PACKAGE__->set_primary_key(qw/ group_id permission scope /); 17 17 18 18 1; -
veekun/trunk/lib/Vee/Schema/Groups.pm
r350 r406 16 16 __PACKAGE__->set_primary_key('id'); 17 17 18 __PACKAGE__->has_many(user_groups => 'Vee::Schema::UserGroups', 'group id');19 __PACKAGE__->has_many(permissions => 'Vee::Schema::GroupPermissions', 'group id');18 __PACKAGE__->has_many(user_groups => 'Vee::Schema::UserGroups', 'group_id'); 19 __PACKAGE__->has_many(permissions => 'Vee::Schema::GroupPermissions', 'group_id'); 20 20 __PACKAGE__->many_to_many('users' => 'user_groups', 'user'); 21 21 -
veekun/trunk/lib/Vee/Schema/ItemKeywords.pm
r350 r406 12 12 13 13 __PACKAGE__->load_components('Core'); 14 __PACKAGE__->table('item keywords');14 __PACKAGE__->table('item_keywords'); 15 15 __PACKAGE__->add_columns(qw/ itemid keywordid /); 16 16 __PACKAGE__->set_primary_key(qw/ itemid keywordid /); -
veekun/trunk/lib/Vee/Schema/Items.pm
r350 r406 13 13 __PACKAGE__->load_components('Core'); 14 14 __PACKAGE__->table('items'); 15 __PACKAGE__->add_columns(qw/ id game_id berry_id name category cost col5 hp_plus_maybe fling_power fling_effect natural_gift_power natural_gift_type col12 col13 col14 col15 col16 col17 col18 col19 col20 col21 col22 col23 effort_hp effort_at effort_de effort_sp effort_sa effort_sd hp_restored pp_restored happiness1 happiness2 happiness3 is_underground dpblurbdescription /);15 __PACKAGE__->add_columns(qw/ id game_id berry_id name category cost col5 hp_plus_maybe fling_power fling_effect natural_gift_power natural_gift_type col12 col13 col14 col15 col16 col17 col18 col19 col20 col21 col22 col23 effort_hp effort_at effort_de effort_sp effort_sa effort_sd hp_restored pp_restored happiness1 happiness2 happiness3 is_underground blurb_dp description /); 16 16 __PACKAGE__->set_primary_key('id'); 17 17 -
veekun/trunk/lib/Vee/Schema/Machines.pm
r350 r406 13 13 __PACKAGE__->load_components('Core'); 14 14 __PACKAGE__->table('machines'); 15 __PACKAGE__->add_columns(qw/ id generation cost move id location /);15 __PACKAGE__->add_columns(qw/ id generation cost move_id location /); 16 16 __PACKAGE__->set_primary_key(qw/ id generation /); 17 17 -
veekun/trunk/lib/Vee/Schema/MoveEffects.pm
r350 r406 13 13 __PACKAGE__->load_components('Core'); 14 14 __PACKAGE__->table('move_effects'); 15 __PACKAGE__->add_columns(qw/ id priority blurbdescription /);15 __PACKAGE__->add_columns(qw/ id priority short_description description /); 16 16 __PACKAGE__->set_primary_key('id'); 17 17 -
veekun/trunk/lib/Vee/Schema/Moves.pm
r350 r406 21 21 power 22 22 pp 23 acc 23 accuracy 24 24 target 25 25 class … … 30 30 status 31 31 move_effect_id 32 gameblurb33 dpblurb34 cont ype35 con effect32 blurb_rusa 33 blurb_dp 34 contest_type 35 contest_effect_id 36 36 notes 37 37 /); 38 38 __PACKAGE__->set_primary_key('id'); 39 39 40 __PACKAGE__->belongs_to(contest => 'Vee::Schema::ContestMoves', 'coneffect');40 __PACKAGE__->belongs_to(contest_effect => 'Vee::Schema::ContestEffects', 'contest_effect_id'); 41 41 __PACKAGE__->belongs_to(effect => 'Vee::Schema::MoveEffects', 'move_effect_id'); 42 __PACKAGE__->has_many(pokemo ves => 'Vee::Schema::PokeMoves', 'moveid');42 __PACKAGE__->has_many(pokemon_moves => 'Vee::Schema::PokemonMoves', 'move_id'); 43 43 44 44 =head1 METHODS … … 88 88 } 89 89 90 =head2 blurb90 =head2 short_description 91 91 92 Returns a short blurbfor this move, suitable for putting in a move table.92 Returns a short description for this move, suitable for putting in a move table. 93 93 Applies C<_format_description> effects. 94 95 If this move's move effect has no blurb, the full description will be used96 instead. This should no longer happen, but was necessary for some degree of97 completion when the blurbs were still being written.98 94 99 95 =cut 100 96 101 sub blurb{97 sub short_description { 102 98 my ($self) = @_; 103 99 104 return $self->_format_description( 105 $self->effect->blurb || $self->effect->description 106 ); 100 return $self->_format_description( $self->effect->short_description ); 107 101 } 108 102 … … 110 104 111 105 Inserts this move's effect chance and priority into the provided string, if 112 applicable. Used by C<description> and C< blurb>.106 applicable. Used by C<description> and C<short_description>. 113 107 114 108 =cut -
veekun/trunk/lib/Vee/Schema/Pokemon.pm
r393 r406 26 26 name_romaji 27 27 28 ev id29 ev parent30 ev method31 ev param28 evo_chain_id 29 evo_parent_id 30 evo_method 31 evo_param 32 32 33 33 height … … 47 47 48 48 effort 49 oldgs 50 caprate 51 baseexp 52 gender 53 happiness 54 root 55 eventred 56 eventblue 49 gameshark_rby 50 capture_rate 51 base_exp 52 gender_rate 53 base_happiness 57 54 notes 58 55 flags 59 real_ id56 real_pokemon_id 60 57 /); 61 58 __PACKAGE__->set_primary_key('id'); 62 59 63 __PACKAGE__->belongs_to(ev chain => 'Vee::Schema::EvChains', 'evid');64 __PACKAGE__->has_many(pokemo ves => 'Vee::Schema::PokeMoves', 'pokeid');65 __PACKAGE__->has_many(flavors => 'Vee::Schema::FlavorText', 'poke id');60 __PACKAGE__->belongs_to(evo_chain => 'Vee::Schema::EvoChains', 'evo_chain_id'); 61 __PACKAGE__->has_many(pokemon_moves => 'Vee::Schema::PokemonMoves', 'pokemon_id'); 62 __PACKAGE__->has_many(flavors => 'Vee::Schema::FlavorText', 'pokemon_id'); 66 63 __PACKAGE__->has_many(encounters => 'Vee::Schema::LocationEncounters', 'pokemon_id'); 67 __PACKAGE__->has_many(breeds => 'Vee::Schema::PokemonBreeds', 'poke id');64 __PACKAGE__->has_many(breeds => 'Vee::Schema::PokemonBreeds', 'pokemon_id'); 68 65 69 __PACKAGE__->has_many(pokemon_abilities => 'Vee::Schema::PokemonAbilities', 'poke id', { order_by => 'slot ASC' });66 __PACKAGE__->has_many(pokemon_abilities => 'Vee::Schema::PokemonAbilities', 'pokemon_id', { order_by => 'slot ASC' }); 70 67 __PACKAGE__->many_to_many(abilities => 'pokemon_abilities', 'ability'); 71 68 … … 73 70 __PACKAGE__->many_to_many(items => 'pokemon_items', 'item'); 74 71 75 __PACKAGE__->might_have(parent => 'Vee::Schema::Pokemon', 'ev parent');76 __PACKAGE__->has_many(descendants => 'Vee::Schema::Pokemon', 'ev parent');72 __PACKAGE__->might_have(parent => 'Vee::Schema::Pokemon', 'evo_parent_id'); 73 __PACKAGE__->has_many(descendants => 'Vee::Schema::Pokemon', 'evo_parent_id'); 77 74 78 75 =head1 METHODS -
veekun/trunk/lib/Vee/Schema/PokemonAbilities.pm
r350 r406 13 13 __PACKAGE__->load_components('Core'); 14 14 __PACKAGE__->table('pokemon_abilities'); 15 __PACKAGE__->add_columns(qw/ poke id abilityid slot /);16 __PACKAGE__->set_primary_key(qw/ poke id abilityid /);15 __PACKAGE__->add_columns(qw/ pokemon_id ability_id slot /); 16 __PACKAGE__->set_primary_key(qw/ pokemon_id ability_id /); 17 17 18 __PACKAGE__->belongs_to(pokemon => 'Vee::Schema::Pokemon', 'poke id');19 __PACKAGE__->belongs_to(ability => 'Vee::Schema::Abilities', 'ability id');18 __PACKAGE__->belongs_to(pokemon => 'Vee::Schema::Pokemon', 'pokemon_id'); 19 __PACKAGE__->belongs_to(ability => 'Vee::Schema::Abilities', 'ability_id'); 20 20 21 21 =head1 SEE ALSO -
veekun/trunk/lib/Vee/Schema/PokemonBreeds.pm
r350 r406 13 13 __PACKAGE__->load_components('Core'); 14 14 __PACKAGE__->table('pokemon_breeds'); 15 __PACKAGE__->add_columns(qw/ poke id breed /);16 __PACKAGE__->set_primary_key(qw/ poke id breed /);15 __PACKAGE__->add_columns(qw/ pokemon_id breed /); 16 __PACKAGE__->set_primary_key(qw/ pokemon_id breed /); 17 17 18 __PACKAGE__->belongs_to(pokemon => 'Vee::Schema::Pokemon', 'poke id');18 __PACKAGE__->belongs_to(pokemon => 'Vee::Schema::Pokemon', 'pokemon_id'); 19 19 20 20 =head1 SEE ALSO -
veekun/trunk/lib/Vee/Schema/PokemonMoves.pm
r350 r406 1 package Vee::Schema::Poke Moves;1 package Vee::Schema::PokemonMoves; 2 2 3 3 use strict; … … 7 7 =head1 NAME 8 8 9 Vee::Schema::Poke Moves - DBIC class for the C<pokemoves> table9 Vee::Schema::PokemonMoves - DBIC class for the C<pokemon_moves> table 10 10 11 11 =cut 12 12 13 13 __PACKAGE__->load_components('Core'); 14 __PACKAGE__->table('pokemo ves');15 __PACKAGE__->add_columns(qw/ poke id moveid level versionmethod /);14 __PACKAGE__->table('pokemon_moves'); 15 __PACKAGE__->add_columns(qw/ pokemon_id move_id level versions method /); 16 16 17 __PACKAGE__->set_primary_key(qw/ poke id moveid level versionmethod /);17 __PACKAGE__->set_primary_key(qw/ pokemon_id move_id level versions method /); 18 18 19 __PACKAGE__->belongs_to(pokemon => 'Vee::Schema::Pokemon', 'poke id');20 __PACKAGE__->belongs_to(move => 'Vee::Schema::Moves', 'move id');19 __PACKAGE__->belongs_to(pokemon => 'Vee::Schema::Pokemon', 'pokemon_id'); 20 __PACKAGE__->belongs_to(move => 'Vee::Schema::Moves', 'move_id'); 21 21 22 22 =head1 SEE ALSO -
veekun/trunk/lib/Vee/Schema/Posts.pm
r350 r406 13 13 __PACKAGE__->load_components('Core'); 14 14 __PACKAGE__->table('posts'); 15 __PACKAGE__->add_columns(qw/ id thread id userid flags time format message lasteditid /);15 __PACKAGE__->add_columns(qw/ id thread_id user_id flags time format content last_edit_id /); 16 16 __PACKAGE__->set_primary_key('id'); 17 17 18 __PACKAGE__->belongs_to(thread => 'Vee::Schema::Threads', 'thread id');19 __PACKAGE__->might_have(user => 'Vee::Schema::Users', { 'foreign.id' => 'self.user id' });20 __PACKAGE__->has_many(edits => 'Vee::Schema::Edits', 'post id');21 __PACKAGE__->might_have(lastedit => 'Vee::Schema::Edits', { 'foreign.id' => 'self.last editid' });18 __PACKAGE__->belongs_to(thread => 'Vee::Schema::Threads', 'thread_id'); 19 __PACKAGE__->might_have(user => 'Vee::Schema::Users', { 'foreign.id' => 'self.user_id' }); 20 __PACKAGE__->has_many(edits => 'Vee::Schema::Edits', 'post_id'); 21 __PACKAGE__->might_have(lastedit => 'Vee::Schema::Edits', { 'foreign.id' => 'self.last_edit_id' }); 22 22 23 23 =head1 SEE ALSO -
veekun/trunk/lib/Vee/Schema/Sessions.pm
r404 r406 17 17 __PACKAGE__->add_columns( 18 18 'id', 19 user id=> { is_nullable => 1 },20 expires => { is_nullable => 1 },21 data => { is_nullable => 1 },19 user_id => { is_nullable => 1 }, 20 time_expires => { is_nullable => 1 }, 21 data => { is_nullable => 1 }, 22 22 ); 23 23 __PACKAGE__->set_primary_key('id'); -
veekun/trunk/lib/Vee/Schema/Shoutbox.pm
r404 r406 15 15 __PACKAGE__->add_columns( 16 16 qw/ id name /, 17 user id => { is_nullable => 1 },18 qw/ ip time message/17 user_id => { is_nullable => 1 }, 18 qw/ ip time content / 19 19 ); 20 20 __PACKAGE__->set_primary_key('id'); 21 21 22 __PACKAGE__->might_have(user => 'Vee::Schema::Users', { 'foreign.id' => 'self.user id' });22 __PACKAGE__->might_have(user => 'Vee::Schema::Users', { 'foreign.id' => 'self.user_id' }); 23 23 24 24 =head1 SEE ALSO -
veekun/trunk/lib/Vee/Schema/Threads.pm
r386 r406 14 14 __PACKAGE__->table('threads'); 15 15 __PACKAGE__->add_columns(qw/ 16 id forum id subject blurb firstpostid lastpostid lasttime postct hitct flags16 id forum_id subject blurb first_post_id last_post_id last_post_time post_count view_count flags 17 17 /); 18 18 __PACKAGE__->set_primary_key('id'); 19 19 20 __PACKAGE__->belongs_to(forum => 'Vee::Schema::Forums', 'forum id');21 __PACKAGE__->has_many(posts => 'Vee::Schema::Posts', 'thread id');22 __PACKAGE__->belongs_to(last post => 'Vee::Schema::Posts', 'lastpostid');23 __PACKAGE__->belongs_to(first post => 'Vee::Schema::Posts', 'firstpostid');20 __PACKAGE__->belongs_to(forum => 'Vee::Schema::Forums', 'forum_id'); 21 __PACKAGE__->has_many(posts => 'Vee::Schema::Posts', 'thread_id'); 22 __PACKAGE__->belongs_to(last_post => 'Vee::Schema::Posts', 'last_post_id'); 23 __PACKAGE__->belongs_to(first_post => 'Vee::Schema::Posts', 'first_post_id'); 24 24 __PACKAGE__->has_many(thread_views => 'Vee::Schema::ThreadViews', 'thread_id', { join_type => 'LEFT' }); 25 25 … … 37 37 return $self->search( 38 38 [ \ 'FIND_IN_SET("announcement", me.flags) AND NOT FIND_IN_SET("deleted", me.flags)' ], 39 { prefetch => [ 'forum', { first post => 'user', lastpost => 'user' } ] }39 { prefetch => [ 'forum', { first_post => 'user', last_post => 'user' } ] } 40 40 ); 41 41 } … … 53 53 # ambiguity errors 54 54 return map { $_->id } $self->search( { 55 'me.last time'=> { '>' => $user->thread_view_cutoff },56 'thread_views.last_viewed' => [ undef, \'< me.last time' ],55 'me.last_post_time' => { '>' => $user->thread_view_cutoff }, 56 'thread_views.last_viewed' => [ undef, \'< me.last_post_time' ], 57 57 }, { 58 # XXX: This is very naughty, but the only way to stuff the user id in58 # n.b.: This is very naughty, but the only way to stuff the user id in 59 59 # the ON clause 60 60 from => [ -
veekun/trunk/lib/Vee/Schema/Types.pm
r350 r406 14 14 __PACKAGE__->table('types'); 15 15 __PACKAGE__->add_columns(qw/ 16 name abbr color rank id internal id new_effects old_effects16 name abbr color rank id internal_id new_effects old_effects 17 17 /); 18 18 __PACKAGE__->set_primary_key('name'); -
veekun/trunk/lib/Vee/Schema/UserGroups.pm
r350 r406 7 7 =head1 NAME 8 8 9 Vee::Schema::UserGroups - DBIC class for the C<user groups> table9 Vee::Schema::UserGroups - DBIC class for the C<user_groups> table 10 10 11 11 =cut 12 12 13 13 __PACKAGE__->load_components('Core'); 14 __PACKAGE__->table('user groups');15 __PACKAGE__->add_columns(qw/ user id groupid priority /);16 __PACKAGE__->set_primary_key(qw/ user id groupid priority /);14 __PACKAGE__->table('user_groups'); 15 __PACKAGE__->add_columns(qw/ user_id group_id priority /); 16 __PACKAGE__->set_primary_key(qw/ user_id group_id priority /); 17 17 18 __PACKAGE__->belongs_to(user => 'Vee::Schema::Users', 'user id');18 __PACKAGE__->belongs_to(user => 'Vee::Schema::Users', 'user_id'); 19 19 # Temporary hack to get around problem with `` quoting 20 __PACKAGE__->belongs_to(group_hax => 'Vee::Schema::Groups', 'group id');20 __PACKAGE__->belongs_to(group_hax => 'Vee::Schema::Groups', 'group_id'); 21 21 22 22 =head1 SEE ALSO -
veekun/trunk/lib/Vee/Schema/Users.pm
r350 r406 17 17 name 18 18 password 19 joindate20 lastactive19 time_joined 20 time_active 21 21 thread_view_cutoff 22 post ct22 post_count 23 23 flags 24 news pic24 news_pic 25 25 avatar 26 26 contact_aim … … 31 31 contact_homepage 32 32 contact_email 33 pm icon34 custom title33 pm_icon 34 custom_title 35 35 signature 36 36 is_dumb … … 39 39 __PACKAGE__->add_unique_constraint(name => ['name']); 40 40 41 __PACKAGE__->has_many(posts => 'Vee::Schema::Posts', 'user id');42 __PACKAGE__->has_many(shouts => 'Vee::Schema::Shoutbox', 'user id');43 __PACKAGE__->has_many(user_groups => 'Vee::Schema::UserGroups', 'user id');41 __PACKAGE__->has_many(posts => 'Vee::Schema::Posts', 'user_id'); 42 __PACKAGE__->has_many(shouts => 'Vee::Schema::Shoutbox', 'user_id'); 43 __PACKAGE__->has_many(user_groups => 'Vee::Schema::UserGroups', 'user_id'); 44 44 __PACKAGE__->has_many(sent_messages => 'Vee::Schema::Messages', 'from_user_id'); 45 45 __PACKAGE__->has_many(received_messages => 'Vee::Schema::Messages', 'to_user_id'); -
veekun/trunk/lib/Vee/Utils.pm
r283 r406 50 50 51 51 sub postrank { 52 my ($post ct) = @_;52 my ($post_count) = @_; 53 53 for my $rank ( 54 54 sort { $b <=> $a } 55 55 keys %{ Vee->config->{site}->{post_ranks} } 56 56 ) { 57 return Vee->config->{site}->{post_ranks}->{$rank} if $rank <= $post ct;57 return Vee->config->{site}->{post_ranks}->{$rank} if $rank <= $post_count; 58 58 } 59 59 return "ERRORZ0RZ"; … … 63 63 # XXX: decide the best way to do this, preferably a smooth log curve 64 64 sub post_width { 65 my ($post ct) = @_;66 return $post ct / 1000;65 my ($post_count) = @_; 66 return $post_count / 1000; 67 67 } 68 68 … … 109 109 } 110 110 111 # URL-validation regex 112 # Inferred from the W3's BNF: http://www.w3.org/Addressing/URL/5_BNF.html 113 # n.b.: Technically, the BNF says hostname parts (as delimited by dots) 114 # should begin with a letter, but given that 'xalpha' includes dot this was 115 # a bit clumsy to pull off in practice, so I left it lazy. 116 my $url_xalphas = qr/[-$_@.&+!*"'(),a-zA-Z0-9]/; 117 our $IsValidURL = qr/ ^ 118 (?: http | https | ftp ) :\/\/ # protocol 119 (?: 120 [a-zA-Z] $url_xalphas* # hostname 121 | (?: \d{1,3} \. ){3} \d{1,3} # IP 122 ) 123 (?: : [0-9]+ )? # port 124 (?: \/ # path: leading slash 125 (?: $url_xalphas* # path: path part name 126 | %[a-fA-F][a-fA-F] )* # path: escape 127 )* # path: as many as you want 128 (?: \? $url_xalphas+ )? # query string 129 (?: \# $url_xalphas+ )? # anchor 130 $ /x; 131 132 111 133 sub pad { sprintf "%0$_[1]d", $_[0] } 112 134 sub round { $_[1] ||= 0; return int($_[0] * 10 ** $_[1] + .5) / 10 ** $_[1]; } -
veekun/trunk/script/base.sql
r330 r406 17 17 CREATE TABLE edits ( 18 18 id int(10) unsigned NOT NULL auto_increment, 19 post id int(10) unsigned NOT NULL default '0',20 user id int(10) unsigned NOT NULL default '0',21 `time` int(10) unsigned NOT NULL default '0', 22 old messagetext NOT NULL,23 PRIMARY KEY (id), 24 KEY POSTID (postid)25 ) ENGINE=MyISAM DEFAULT CHARSET=latin1; 26 27 -- 28 -- Table structure for table `error log`29 -- 30 31 DROP TABLE IF EXISTS error log;32 CREATE TABLE error log (33 id int(10) unsigned NOT NULL auto_increment, 34 `time` int(10) unsigned NOT NULL ,35 user id int(10) unsigned NOT NULL,36 ip int(10) unsigned NOT NULL ,19 post_id int(10) unsigned NOT NULL default '0', 20 user_id int(10) unsigned NOT NULL default '0', 21 `time` int(10) unsigned NOT NULL default '0', 22 old_content text NOT NULL, 23 PRIMARY KEY (id), 24 KEY POSTID USING BTREE (post_id) 25 ) ENGINE=MyISAM DEFAULT CHARSET=latin1; 26 27 -- 28 -- Table structure for table `error_log` 29 -- 30 31 DROP TABLE IF EXISTS error_log; 32 CREATE TABLE error_log ( 33 id int(10) unsigned NOT NULL auto_increment, 34 `time` int(10) unsigned NOT NULL default '0', 35 user_id int(10) unsigned NOT NULL default '0', 36 ip int(10) unsigned NOT NULL default '0', 37 37 path tinytext NOT NULL, 38 38 method enum('POST','GET') default NULL, … … 50 50 id int(10) unsigned NOT NULL auto_increment, 51 51 `name` varchar(80) NOT NULL default 'Untitled Forum', 52 last postid int(10) unsigned default NULL,53 thread ct int(10) unsigned NOT NULL default '0',54 post ct int(10) unsigned NOT NULL default '0',52 last_post_id int(10) unsigned default NULL, 53 thread_count int(10) unsigned NOT NULL default '0', 54 post_count int(10) unsigned NOT NULL default '0', 55 55 flags set('header') NOT NULL, 56 56 accessibility enum('normal','locked','archive','hidden') NOT NULL default 'normal', 57 blurb varchar(255) NOT NULL default '',58 PRIMARY KEY (id) 59 ) ENGINE=InnoDB DEFAULT CHARSET=latin1 ;60 61 -- 62 -- Table structure for table `group permissions`63 -- 64 65 DROP TABLE IF EXISTS group permissions;66 CREATE TABLE group permissions (67 group id int(10) unsigned NOT NULL,57 description varchar(255) NOT NULL, 58 PRIMARY KEY (id) 59 ) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC; 60 61 -- 62 -- Table structure for table `group_permissions` 63 -- 64 65 DROP TABLE IF EXISTS group_permissions; 66 CREATE TABLE group_permissions ( 67 group_id int(10) unsigned NOT NULL default '0', 68 68 permission varchar(64) NOT NULL default '', 69 69 scope varchar(64) NOT NULL default '', 70 70 polarity enum('allow','deny') default NULL, 71 PRIMARY KEY (groupid,permission,scope)72 ) ENGINE=MyISAM DEFAULT CHARSET= utf8;71 PRIMARY KEY USING BTREE (group_id,permission,scope) 72 ) ENGINE=MyISAM DEFAULT CHARSET=latin1; 73 73 74 74 -- … … 82 82 `name` tinytext NOT NULL, 83 83 UNIQUE KEY id (id) 84 ) ENGINE= MyISAMDEFAULT CHARSET=utf8;84 ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 85 85 86 86 -- … … 91 91 CREATE TABLE messages ( 92 92 id int(10) unsigned NOT NULL auto_increment, 93 from_user_id int(10) unsigned NOT NULL ,94 to_user_id int(10) unsigned NOT NULL ,95 `time` int(10) unsigned NOT NULL ,93 from_user_id int(10) unsigned NOT NULL default '0', 94 to_user_id int(10) unsigned NOT NULL default '0', 95 `time` int(10) unsigned NOT NULL default '0', 96 96 `subject` tinytext NOT NULL, 97 97 message text NOT NULL, … … 106 106 CREATE TABLE posts ( 107 107 id int(10) unsigned NOT NULL auto_increment, 108 thread id int(10) unsigned NOT NULL default '0',109 user id int(10) unsigned NOT NULL default '0',108 thread_id int(10) unsigned NOT NULL default '0', 109 user_id int(10) unsigned NOT NULL default '0', 110 110 flags set('deleted') NOT NULL default '', 111 111 `time` int(10) unsigned NOT NULL default '0', 112 112 format enum('bbcode','raw','html') NOT NULL default 'raw', 113 messagetext NOT NULL,114 last editid int(10) unsigned NOT NULL default '0',115 PRIMARY KEY (id), 116 KEY THREAD (threadid),117 KEY `USER` (userid)118 ) ENGINE=InnoDB DEFAULT CHARSET=latin1 ;113 content text NOT NULL, 114 last_edit_id int(10) unsigned NOT NULL default '0', 115 PRIMARY KEY (id), 116 KEY THREAD USING BTREE (thread_id), 117 KEY `USER` USING BTREE (user_id) 118 ) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=FIXED; 119 119 120 120 -- … … 124 124 DROP TABLE IF EXISTS sessions; 125 125 CREATE TABLE sessions ( 126 id char(72) NOT NULL default '',127 user id int(10) unsigned NOT NULL default '0',128 expires int(10) unsigned default NULL,126 id varchar(72) NOT NULL default '', 127 user_id int(10) unsigned NOT NULL default '0', 128 time_expires int(10) unsigned default NULL, 129 129 `data` text, 130 PRIMARY KEY (id),131 KEY USER ID (userid)130 PRIMARY KEY USING BTREE (id), 131 KEY USER_ID USING BTREE (user_id) 132 132 ) ENGINE=MyISAM DEFAULT CHARSET=latin1; 133 133 … … 140 140 id int(10) unsigned NOT NULL auto_increment, 141 141 `name` varchar(24) NOT NULL default 'Anonymous', 142 user id int(10) unsigned default NULL,142 user_id int(10) unsigned default NULL, 143 143 ip int(10) unsigned NOT NULL default '0', 144 144 `time` int(10) unsigned NOT NULL default '0', 145 messagetext NOT NULL,145 content text NOT NULL, 146 146 PRIMARY KEY (id) 147 147 ) ENGINE=MyISAM DEFAULT CHARSET=latin1; … … 154 154 CREATE TABLE threads ( 155 155 id int(10) unsigned NOT NULL auto_increment, 156 forum id int(10) unsigned NOT NULL default '0',156 forum_id int(10) unsigned NOT NULL default '0', 157 157 `subject` varchar(48) NOT NULL default 'Untitled Thread', 158 158 blurb varchar(96) NOT NULL default '', 159 first postid int(10) unsigned NOT NULL,160 last postid int(10) unsigned NOT NULL,161 last time int(10) unsigned NOT NULL default '0',162 post ct int(10) unsigned NOT NULL default '0',163 hitct int(10) unsigned NOT NULL default '0',159 first_post_id int(10) unsigned NOT NULL, 160 last_post_id int(10) unsigned NOT NULL, 161 last_post_time int(10) unsigned NOT NULL default '0', 162 post_count int(10) unsigned NOT NULL default '0', 163 view_count int(10) unsigned NOT NULL default '0', 164 164 flags set('locked','sticky','announcement','deleted') NOT NULL default '', 165 165 PRIMARY KEY (id), 166 KEY FORUMID (forumid)167 ) ENGINE=InnoDB DEFAULT CHARSET=latin1 ;166 KEY FORUMID USING BTREE (forum_id) 167 ) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC; 168 168 169 169 -- … … 180 180 181 181 -- 182 -- Table structure for table `usergroups` 183 -- 184 185 DROP TABLE IF EXISTS usergroups; 186 CREATE TABLE usergroups ( 187 userid int(10) unsigned NOT NULL, 188 groupid tinyint(3) unsigned NOT NULL, 189 priority tinyint(3) unsigned NOT NULL, 190 PRIMARY KEY (userid,groupid,priority), 191 KEY userid (userid), 192 KEY groupid (groupid) 193 ) ENGINE=MyISAM DEFAULT CHARSET=utf8; 194 195 -- 196 -- Table structure for table `userpermissions` 197 -- 198 199 DROP TABLE IF EXISTS userpermissions; 200 CREATE TABLE userpermissions ( 201 userid int(10) NOT NULL, 202 permission varchar(64) NOT NULL default '', 203 scope varchar(64) NOT NULL default '', 204 polarity enum('allow','deny') default NULL, 205 PRIMARY KEY (userid,permission,scope) 206 ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 182 -- Table structure for table `user_groups` 183 -- 184 185 DROP TABLE IF EXISTS user_groups; 186 CREATE TABLE user_groups ( 187 user_id int(10) unsigned NOT NULL default '0', 188 group_id tinyint(3) unsigned NOT NULL default '0', 189 priority tinyint(3) unsigned NOT NULL default '0', 190 PRIMARY KEY USING BTREE (user_id,group_id,priority), 191 KEY user_id USING BTREE (user_id), 192 KEY group_id USING BTREE (group_id) 193 ) ENGINE=MyISAM DEFAULT CHARSET=latin1; 207 194 208 195 -- … … 215 202 `name` varchar(20) NOT NULL default '', 216 203 `password` varchar(40) NOT NULL, 217 joindateint(10) unsigned NOT NULL default '0',218 lastactive int(10) unsigned NOT NULL default '0',204 time_joined int(10) unsigned NOT NULL default '0', 205 time_active int(10) unsigned NOT NULL default '0', 219 206 thread_view_cutoff int(10) unsigned NOT NULL, 220 post ct int(10) unsigned NOT NULL default '0',207 post_count int(10) unsigned NOT NULL default '0', 221 208 flags set('lockedsig','lockedavatar','lockedtitle') NOT NULL default '', 222 news pic varchar(64) default NULL,209 news_pic varchar(64) default NULL, 223 210 avatar varchar(64) default NULL, 224 211 contact_aim varchar(32) NOT NULL default '', … … 229 216 contact_homepage varchar(96) NOT NULL default '', 230 217 contact_email varchar(32) NOT NULL default '', 231 pm icon enum('bead','bellossom','dream','duskull','eatmail','gorgeous','letter','magnemite','pika','retro','slakoth','vee','wailmer','wingull','zigzagoon') NOT NULL default 'letter',232 custom title varchar(32) NOT NULL default '',218 pm_icon enum('bead','bellossom','dream','duskull','eatmail','gorgeous','letter','magnemite','pika','retro','slakoth','vee','wailmer','wingull','zigzagoon') NOT NULL default 'letter', 219 custom_title varchar(32) NOT NULL, 233 220 signature text NOT NULL, 234 221 is_dumb tinyint(1) NOT NULL default '0', -
veekun/trunk/script/base_data.sql
r381 r406 1 LOCK TABLES forums WRITE, group permissions WRITE, groups WRITE, usergroups WRITE, users WRITE;1 LOCK TABLES forums WRITE, group_permissions WRITE, groups WRITE, user_groups WRITE, users WRITE; 2 2 3 INSERT INTO forums (id, name, last postid, threadct, postct, flags, accessibility, blurb)3 INSERT INTO forums (id, name, last_post_id, thread_count, post_count, flags, accessibility, blurb) 4 4 VALUES (1, 'News', NULL, 0, 0, '', 'normal', 'News and updates show up here.'); 5 5 6 INSERT INTO group permissions (groupid, permission, scope, polarity)6 INSERT INTO group_permissions (group_id, permission, scope, polarity) 7 7 VALUES (1, 'splat', '', 'allow'); 8 8 … … 11 11 (2, '', 'Users'); 12 12 13 INSERT INTO user groups (userid, groupid, priority)13 INSERT INTO user_groups (user_id, group_id, priority) 14 14 VALUES (0, 2, 1), 15 15 (1, 1, 1); 16 16 17 INSERT INTO users (id, name, password, joindate, signature, thread_view_cutoff)17 INSERT INTO users (id, name, password, time_joined, signature, thread_view_cutoff) 18 18 VALUES (1, 'admin', '5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8', UNIX_TIMESTAMP(), 'Default signature', UNIX_TIMESTAMP()); 19 19 -
veekun/trunk/script/dump_sql.pl
r396 r406 11 11 12 12 my %TABLES = ( 13 base => [qw/ edits error log forums grouppermissions groups messages posts sessions shoutbox threads thread_views usergroups userpermissions users /],14 gallery => [qw/ creators gallery gallery keywords itemkeywords /],15 pokedex => [qw/ abilities berries contest moves evchains flavortext items locations location_sections location_encounters machines moves move_effects pokemon pokemon_abilities pokemon_breeds pokemon_items pokemoves types /],13 base => [qw/ edits error_log forums group_permissions groups messages posts sessions shoutbox threads thread_views user_groups users /], 14 gallery => [qw/ creators gallery gallery_keywords item_keywords /], 15 pokedex => [qw/ abilities berries contest_effects evo_chains flavor_text items locations location_sections location_encounters machines moves move_effects pokemon pokemon_abilities pokemon_breeds pokemon_items pokemon_moves types /], 16 16 ); 17 17 -
veekun/trunk/script/gallery.sql
r48 r406 17 17 CREATE TABLE creators ( 18 18 id int(10) unsigned NOT NULL auto_increment, 19 userid int(10) unsigned default NULL, 20 `name` varchar(20) default NULL, 21 itemct int(10) unsigned NOT NULL default '0', 22 PRIMARY KEY (id), 23 UNIQUE KEY userid (userid) 24 ) ENGINE=MyISAM DEFAULT CHARSET=latin1; 19 user_id int(10) unsigned NOT NULL, 20 `name` varchar(32) NOT NULL, 21 item_count tinyint(3) unsigned default NULL, 22 PRIMARY KEY (id) 23 ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 25 24 26 25 -- … … 49 48 50 49 -- 51 -- Table structure for table `gallery keywords`50 -- Table structure for table `gallery_keywords` 52 51 -- 53 52 54 DROP TABLE IF EXISTS gallery keywords;55 CREATE TABLE gallery keywords (53 DROP TABLE IF EXISTS gallery_keywords; 54 CREATE TABLE gallery_keywords ( 56 55 id int(10) unsigned NOT NULL auto_increment, 57 56 keyword varchar(48) NOT NULL default '', … … 63 62 64 63 -- 65 -- Table structure for table `item keywords`64 -- Table structure for table `item_keywords` 66 65 -- 67 66 68 DROP TABLE IF EXISTS item keywords;69 CREATE TABLE item keywords (67 DROP TABLE IF EXISTS item_keywords; 68 CREATE TABLE item_keywords ( 70 69 itemid int(10) unsigned NOT NULL default '0', 71 70 keywordid int(10) unsigned NOT NULL default '0', -
veekun/trunk/script/pokedex.sql
r399 r406 18 18 id tinyint(3) unsigned NOT NULL default '0', 19 19 `name` varchar(24) NOT NULL default '', 20 gameblurbtinytext NOT NULL,21 effecttinytext NOT NULL,20 blurb_dp tinytext NOT NULL, 21 description tinytext NOT NULL, 22 22 PRIMARY KEY (id) 23 23 ) ENGINE=MyISAM DEFAULT CHARSET=utf8; … … 251 251 252 252 -- 253 -- Table structure for table `contest moves`253 -- Table structure for table `contest_effects` 254 254 -- 255 255 256 DROP TABLE IF EXISTS contest moves;257 CREATE TABLE contest moves (256 DROP TABLE IF EXISTS contest_effects; 257 CREATE TABLE contest_effects ( 258 258 id tinyint(4) NOT NULL default '0', 259 259 appeal tinyint(4) NOT NULL default '0', 260 260 jam tinyint(4) NOT NULL default '0', 261 blurb_rusa tinytext NOT NULL, 261 262 description tinytext NOT NULL, 262 effect tinytext NOT NULL,263 263 PRIMARY KEY (id) 264 264 ) ENGINE=MyISAM DEFAULT CHARSET=utf8; 265 265 266 266 -- 267 -- Dumping data for table `contest moves`267 -- Dumping data for table `contest_effects` 268 268 -- 269 269 270 LOCK TABLES contest moves WRITE;271 /*!40000 ALTER TABLE contest moves DISABLE KEYS */;272 INSERT INTO contest moves VALUES (1,4,0,'A highly appealing move.','Gives a high number of appeal points wth no other effects.'),270 LOCK TABLES contest_effects WRITE; 271 /*!40000 ALTER TABLE contest_effects DISABLE KEYS */; 272 INSERT INTO contest_effects VALUES (1,4,0,'A highly appealing move.','Gives a high number of appeal points wth no other effects.'), 273 273 (2,3,0,'Affected by how well the appeal in front goes.','If the Pokemon that appealed before the user earned less than three appeal points, user earns six; if three, user earns three; if more than three, user earns none.'), 274 274 (3,6,0,'After this move, the user is more easily startled.','If the user is jammed this turn after using this move, it will receive twice as many jam points.'), … … 303 303 (32,1,0,'Ups the user\'s condition. Helps prevent nervousness.','User gains one star.'), 304 304 (33,3,0,'Worsens the condition of those that made appeals.','Removes all stars from all Pokemon that have appealed this turn.'); 305 /*!40000 ALTER TABLE contest moves ENABLE KEYS */;305 /*!40000 ALTER TABLE contest_effects ENABLE KEYS */; 306 306 UNLOCK TABLES; 307 307 308 308 -- 309 -- Table structure for table `ev chains`309 -- Table structure for table `evo_chains` 310 310 -- 311 311
