rsstootalizer/RSSTootalizer/Website/Dashboard.pm

70 lines
1.7 KiB
Perl
Raw Normal View History

2017-04-21 14:56:24 +00:00
#!/usr/bin/perl -w
# vim: set foldmarker={,}:
use strict;
use HTML::Template;
2017-04-23 18:51:48 +00:00
use RSSTootalizer::DB;
use RSSTootalizer::Feed;
use RSSTootalizer::Website;
2017-04-21 14:56:24 +00:00
2017-04-23 18:51:48 +00:00
package RSSTootalizer::Website::Dashboard;
2017-04-21 14:56:24 +00:00
use Data::Dumper;
2017-04-23 18:51:48 +00:00
@RSSTootalizer::Website::Dashboard::ISA = qw(RSSTootalizer::Website);
2017-04-21 14:56:24 +00:00
sub requires_authentication {
return 1;
}
2017-04-21 19:45:58 +00:00
sub fill_content {
my $class = shift;
my $output = shift;
2017-04-22 19:28:21 +00:00
if ($main::FORM{inputURL}){
my %nf;
$nf{url} = $main::FORM{inputURL};
$nf{username} = $main::CURRENTUSER->{data}->{acct};
$nf{instance} = $main::FORM{instance};
$nf{enabled} = "n";
2017-04-23 18:51:48 +00:00
my $feed = RSSTootalizer::Feed->create_and_fetch(%nf);
2017-04-22 19:28:21 +00:00
}
2017-04-23 18:51:48 +00:00
my @feeds = RSSTootalizer::Feed->get_by_user_instance($main::CURRENTUSER->{data}->{acct}, $main::FORM{instance});
2017-04-21 19:45:58 +00:00
my @param_feeds;
my $count = 0;
2017-04-22 18:55:50 +00:00
FEED: foreach my $feed (@feeds){
if ($main::FORM{delete} and "x".$main::FORM{delete} eq "x".$feed->{data}->{ID}){
$feed->delete();
next FEED;
}
2017-04-21 19:45:58 +00:00
my %r;
$count++;
$r{"count"} = $count;
2017-04-22 19:28:21 +00:00
if ($main::FORM{enable} and "x".$main::FORM{enable} eq "x".$feed->{data}->{ID}){
$feed->{data}->{enabled} = "1";
$feed->save();
}
if ($main::FORM{disable} and "x".$main::FORM{disable} eq "x".$feed->{data}->{ID}){
$feed->{data}->{enabled} = "0";
$feed->save();
}
2017-04-21 19:45:58 +00:00
foreach my $key (keys %{$feed->{data}}){
$r{$key} = $feed->{data}->{$key};
}
push @param_feeds, \%r;
}
$output->param("FEEDS", \@param_feeds);
return 1;
}
2017-04-21 14:56:24 +00:00
sub prerender {
my $self = shift;
$self->{"template"} = "Dashboard";
$self->{"content_type"} = "html";
$self->{"params"}->{"currentmode"} = "Dashboard";
2017-04-21 19:45:58 +00:00
foreach my $key (keys %{$main::CURRENTUSER->{data}}){
$self->{"params"}->{"acct_$key"} = $main::CURRENTUSER->{data}->{$key};
}
2017-04-21 14:56:24 +00:00
}
1;