summaryrefslogtreecommitdiff
path: root/lib/VNDB/Handler/Affiliates.pm
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2019-08-26 13:31:03 +0200
committerYorhel <git@yorhel.nl>2019-08-26 13:31:36 +0200
commit27ff73213928994e7e1117293c4a751fe99b215b (patch)
tree23ef55a51d44c91eae6d6da83410ff5bac6e80e0 /lib/VNDB/Handler/Affiliates.pm
parentf4cbd0c722a92ce249a2a4a74bc153868553847c (diff)
Display shop+price info on VN pages + delete old affiliate code
The current affiliate links format doesn't display as much information as before but it's also a lot less messy.
Diffstat (limited to 'lib/VNDB/Handler/Affiliates.pm')
-rw-r--r--lib/VNDB/Handler/Affiliates.pm152
1 files changed, 0 insertions, 152 deletions
diff --git a/lib/VNDB/Handler/Affiliates.pm b/lib/VNDB/Handler/Affiliates.pm
deleted file mode 100644
index efba6b18..00000000
--- a/lib/VNDB/Handler/Affiliates.pm
+++ /dev/null
@@ -1,152 +0,0 @@
-
-package VNDB::Handler::Affiliates;
-
-use strict;
-use warnings;
-use TUWF ':html';
-use VNDB::Func;
-
-
-TUWF::register(
- qr{affiliates} => \&list,
- qr{affiliates/del/([1-9]\d*)} => \&linkdel,
- qr{affiliates/edit/([1-9]\d*)} => \&edit,
- qr{affiliates/new} => \&edit,
-);
-
-
-sub list {
- my $self = shift;
-
- return $self->htmlDenied if !$self->authCan('affiliate');
- my $f = $self->formValidate(
- { get => 'a', required => 0, enum => [ 0..$#{$self->{affiliates}} ] },
- { get => 'h', required => 0, default => 0, enum => [ -1..1 ] },
- { get => 'o', required => 0, default => 'a', enum => ['a', 'd'] },
- { get => 's', required => 0, default => 'rel', enum => [qw|rel prio url lastfetch|] },
- );
- return $self->resNotFound if $f->{_err};
-
- $self->htmlHeader(title => 'Affiliate administration interface');
- div class => 'mainbox';
- h1 'Affiliate administration interface';
- p class => 'browseopts';
- a defined($f->{a}) && $f->{a} == $_ ? (class => 'optselected') : (), href => "/affiliates?a=$_", $self->{affiliates}[$_]{name}
- for (grep $self->{affiliates}[$_], 0..$#{$self->{affiliates}});
- end;
- if(defined $f->{a}) {
- p class => 'browseopts';
- a $f->{h} == -1 ? (class => 'optselected') : (), href => "/affiliates?a=$f->{a};h=-1",'all';
- a $f->{h} == 1 ? (class => 'optselected') : (), href => "/affiliates?a=$f->{a};h=1", 'hidden';
- a $f->{h} == 0 ? (class => 'optselected') : (), href => "/affiliates?a=$f->{a};h=0", 'non-hidden';
- end;
- }
- end;
-
- if(defined $f->{a}) {
- my $list = $self->dbAffiliateGet(
- affiliate => $f->{a}, hidden => $f->{h}==-1?undef:$f->{h},
- what => 'release',
- sort => $f->{s}, reverse => $f->{o} eq 'd'
- );
- $self->htmlBrowse(
- items => $list,
- nextpage => 0,
- options => {p=>0, %$f},
- pageurl => '',
- sorturl => "/affiliates?a=$f->{a};h=$f->{h}",
- header => [
- ['Release', 'rel'],
- ['Version'],
- ['Hid'],
- ['Prio', 'prio'],
- ['Price / Lastfetch', 'lastfetch'],
- ['', 'url' ]
- ],
- row => sub {
- my($s, $n, $l) = @_;
- Tr;
- td class => 'tc1'; a href => "/r$l->{rid}", shorten $l->{title}, 50; end;
- td class => 'tc2', $l->{version} || '<default>';
- td class => 'tc3', $l->{hidden} ? 'YES' : 'no';
- td class => 'tc4', $l->{priority};
- td class => 'tc5', sprintf '%s / %s', $l->{price}, $l->{lastfetch} ? fmtage($l->{lastfetch}) : '-';
- td class => 'tc6';
- a href => $l->{url}, 'link';
- txt ' | ';
- a href => "/affiliates/edit/$l->{id}", 'edit';
- txt ' | ';
- a href => "/affiliates/del/$l->{id}?formcode=".$self->authGetCode("/affiliates/del/$l->{id}"), 'del';
- end;
- end;
- },
- );
- }
- $self->htmlFooter;
-}
-
-
-sub linkdel {
- my($self, $id) = @_;
- return $self->htmlDenied if !$self->authCan('affiliate');
- return if !$self->authCheckCode;
- my $l = $self->dbAffiliateGet(id => $id)->[0];
- return $self->resNotFound if !$l;
- $self->dbAffiliateDel($id);
- $self->resRedirect("/affiliates?a=$l->{affiliate}");
-}
-
-
-sub edit {
- my($self, $id) = @_;
- return $self->htmlDenied if !$self->authCan('affiliate');
-
- my $r = $id && $self->dbAffiliateGet(id => $id)->[0];
- return $self->resNotFound if $id && !$r;
-
- my $frm;
- if($self->reqMethod eq 'POST') {
- return if !$self->authCheckCode;
- $frm = $self->formValidate(
- { post => 'rid', required => 1, template => 'id' },
- { post => 'priority', required => 0, default => 0, template => 'int' },
- { post => 'hidden', required => 0, default => 0, enum => [0,1] },
- { post => 'affiliate',required => 1, enum => [0..$#{$self->{affiliates}}] },
- { post => 'url', required => 1 },
- { post => 'version', required => 0, default => '' },
- { post => 'price', required => 0, default => '' },
- { post => 'lastfetch',required => 0, template => 'uint' },
- { post => 'data', required => 0, default => '' },
- );
- if(!$frm->{_err}) {
- $self->dbAffiliateEdit($id, %$frm) if $id;
- $self->dbAffiliateAdd(%$frm) if !$id;
- return $self->resRedirect("/affiliates?a=$frm->{affiliate}", 'post');
- }
- }
-
- if($id) {
- $frm->{$_} = $r->{$_} for(qw|rid priority hidden affiliate url version price lastfetch data|);
- } else {
- $frm->{rid} = $self->reqGet('rid');
- }
-
- $self->htmlHeader(title => 'Edit affiliate link');
- $self->htmlForm({ frm => $frm, action => $id ? "/affiliates/edit/$id" : '/affiliates/new' }, 'blah' => [ 'Edit affiliate link',
- [ input => short => 'rid', name => 'Release ID', width => 100 ],
- [ input => short => 'priority', name => 'Priority', width => 50 ],
- [ check => short => 'hidden', name => 'Hidden' ],
- [ select => short => 'affiliate', name => 'Affiliate', options => [ map
- [ $_, $self->{affiliates}[$_]{name} ], grep $self->{affiliates}[$_], 0..$#{$self->{affiliates}} ] ],
- [ input => short => 'url', name => 'URL', width => 400 ],
- [ input => short => 'version', name => 'Version', width => 400 ],
- [ input => short => 'price', name => 'Price' ],
- [ input => short => 'lastfetch', name => 'Lastfetch', post => ' UNIX timestamp' ],
- [ input => short => 'data', name => 'Data', width => 400 ],
- ]);
- $self->htmlFooter;
-}
-
-
-1;
-