[livejournal] r17699: LJSUP-7361. dont wonrk "Recent Entries i...
Committer: gprochaev
LJSUP-7361. dont wonrk "Recent Entries in verticals"U trunk/cgi-bin/LJ/Browse.pm U trunk/htdocs/admin/browse/recent_posts.bml
Modified: trunk/cgi-bin/LJ/Browse.pm
===================================================================
--- trunk/cgi-bin/LJ/Browse.pm 2010-11-16 09:34:19 UTC (rev 17698)
+++ trunk/cgi-bin/LJ/Browse.pm 2010-11-16 09:58:28 UTC (rev 17699)
@@ -834,6 +834,18 @@
return $ret;
}
+sub delete_post {
+ my $class = shift;
+ my %args = @_;
+
+ my $post = $args{'post_id'};
+ my ($jitemid, $commid) = $post =~ m#^(\d+)-(\d+)$#; ##
+
+ my $dbh = LJ::get_db_reader ();
+ my $res = $dbh->do ("UPDATE category_recent_posts SET is_deleted = 1 WHERE journalid = ? AND jitemid = ?", undef, $commid, $jitemid);
+ return $res;
+}
+
sub search_posts {
my $class = shift;
my $comms = shift;
Modified: trunk/htdocs/admin/browse/recent_posts.bml
===================================================================
--- trunk/htdocs/admin/browse/recent_posts.bml 2010-11-16 09:34:19 UTC (rev 17698)
+++ trunk/htdocs/admin/browse/recent_posts.bml 2010-11-16 09:58:28 UTC (rev 17699)
@@ -17,8 +17,7 @@
$title = "Recent Entries in verticals";
my $ret = "";
- my $vert_id = $POST{'vert_id'};
- my $journals = $POST{'journals'};
+ my $vert_id = $POST{'vert_id'} || $GET{'vert_id'};
$ret .= "<form method='POST'>\n";
$ret .= LJ::form_auth();
@@ -42,8 +41,17 @@
$ret .= "</form>";
- if (LJ::did_post()) {
+ if (LJ::did_post() && $POST{'delete_post'}) {
my $vertical = LJ::Vertical->load_by_id($POST{'vert_id'});
+ LJ::Browse->delete_post (post_id => $POST{'rec_id'});
+ }
+
+ my $page_size = 10;
+
+ my $page = 1;
+
+ if ($vert_id) {
+ my $vertical = LJ::Vertical->load_by_id($vert_id);
my $cats = $vertical->get_categories;
$ret .= "<b><div>Recent Posts</div></p>";
my @communities = ();
@@ -54,8 +62,11 @@
if $c->{communities};
};
- my @posts = LJ::Browse->recent_posts(\@communities, 5);
+ my $skip = ($page-1) * $page_size;
+ my $last = $skip + $page_size;
+ my @posts = LJ::Browse->search_posts(\@communities, "$skip,$page_size");
+
foreach (@posts) {
my $url = $_->url;
my $subject = $_->subject_text;
@@ -64,6 +75,7 @@
$ret .= "<li><a href='".$url."'>".($subject ? $subject : '...')."</a>";
$ret .= "<form method='POST'>\n";
$ret .= LJ::form_auth();
+ $ret .= "<input type='hidden' name='vert_id' value='".$vertical->vert_id."'>";
$ret .= "<input type='hidden' name='rec_id' value='$jitemid-$commid'>";
$ret .= "<input type='submit' name='delete_post' value='Remove post'>";
$ret .= "</form>";
