madeon (madeon) wrote in changelog,
madeon
madeon
changelog

[livejournal] r21083: LJSUP-11121: scheduled entries use flags...

Committer: sbelyaev
LJSUP-11121: scheduled entries use flags viewall and viewsme
U   trunk/cgi-bin/LJ/DelayedEntry.pm
U   trunk/htdocs/manage/scheduled_posts.bml
Modified: trunk/cgi-bin/LJ/DelayedEntry.pm
===================================================================
--- trunk/cgi-bin/LJ/DelayedEntry.pm	2012-02-03 08:55:19 UTC (rev 21082)
+++ trunk/cgi-bin/LJ/DelayedEntry.pm	2012-02-03 10:04:08 UTC (rev 21083)
@@ -395,7 +395,6 @@
 
 sub visible_to {
     my ($self, $remote, $opts) = @_;
-    return 0 unless $self->valid;
 
     # can see anything with viewall
     return 1 if $opts->{'viewall'};
@@ -638,26 +637,35 @@
 
 sub get_entry_by_id {
     my ($class, $journal, $delayedid, $options) = @_;
-    __assert($journal, "no journal");    
+    __assert($journal, "no journal");
     return undef unless $delayedid;
 
     my $journalid = $journal->userid;
     my $userid    = $options->{userid} || 0;
     my $user      = LJ::get_remote() || LJ::want_user($userid);
+    if ($LJ::IS_DEV_SERVER) {
+        __assert($user, "no user");
+    }
     return undef unless $user;
 
-    my $dbcr = LJ::get_cluster_def_reader($journal)
-        or die "get cluster for journal failed";
+    # can view entry (with content)
+    my $viewall  = $options->{'viewall'} || 0;
 
-    my $delayed_visibility = $options->{'delayed_visibility'} || 0;
+    # can view entry (with content)
+    my $viewsome  = $options->{'viewsome'} || 0;
 
+    # delayed entries visibility
+    my $can_see  = __delayed_entry_can_see( $journal, $user );
+
     my $sql_poster = '';
-    my $can_see = __delayed_entry_can_see( $journal, $user );
 
-    if ( !$delayed_visibility && !$can_see ) {
+    if ( !($can_see || $viewsome || $viewall) ) {
         $sql_poster = 'AND posterid = ' . $user->userid . " "; 
     }
 
+    my $dbcr = LJ::get_cluster_def_reader($journal)
+        or die "get cluster for journal failed";
+
     my $opts = $dbcr->selectrow_arrayref( "SELECT journalid, delayedid, posterid, posttime, logtime " .
                                           "FROM delayedlog2 ".
                                           "WHERE journalid=$journalid AND ".
@@ -687,11 +695,15 @@
     $self->{taglist}            = __extract_tag_list( \$self->prop("taglist") );
     $self->{default_dateformat} = $options->{'dateformat'} || 'S2';
 
-    if (!$can_see && ($delayed_visibility != VIEW_ALL)) {
-        if ($self->security ne "public") {
-            $self->data->{'subject'} = "*private content: subject*";
-            $self->data->{'event'}   = "*private content: event*";
-        }
+    # is entry visible to user
+    my $visible = $self->visible_to($user, $options);
+
+    # Does conent need to be hidden?
+    my $hide_content = !($can_see || $viewall) && !$visible;
+
+    if ($hide_content) {
+        $self->data->{'subject'} = "*private content: subject*";
+        $self->data->{'event'}   = "*private content: event*";
     }
 
     __assert( $self->{poster},  "no poster" );
@@ -800,8 +812,12 @@
     my $only_my       = $opts->{'only_my'};
     my $sticky_on_top = $opts->{'sticky_on_top'};
 
-    my $delayed_visibility = $opts->{'delayed_visibility'} || 0;
+    # can view entry (with content)
+    my $viewall  = $opts->{'viewall'} || 0;
 
+    # can view entry (with content)
+    my $viewsome = $opts->{'viewsome'} || 0;
+
     my $dbcr = LJ::get_cluster_def_reader($journal) 
         or die "get cluster for journal failed";
 
@@ -818,7 +834,7 @@
 
     my $sql_poster = ''; 
     if ( !__delayed_entry_can_see( $journal, $u ) || $only_my ) {
-        if (!$delayed_visibility || $only_my) {
+        if ( !($viewall || $viewsome) || $only_my) {
             $sql_poster = 'AND posterid = ' . $u->userid . " ";
         }
     }

Modified: trunk/htdocs/manage/scheduled_posts.bml
===================================================================
--- trunk/htdocs/manage/scheduled_posts.bml	2012-02-03 08:55:19 UTC (rev 21082)
+++ trunk/htdocs/manage/scheduled_posts.bml	2012-02-03 10:04:08 UTC (rev 21083)
@@ -41,15 +41,13 @@
     my $is_admin = LJ::check_priv($remote, "canview", "scheduled");
     my $can_viewall = LJ::check_priv($remote, "canview", "*");
 
-    my $visibility = $is_admin;
-    if ($can_viewall && $GET{'viewall'} == 1) {
-        $visibility = LJ::DelayedEntry::VIEW_ALL;
+    my $viewsome = !!$is_admin;
+    my $viewall  = ($can_viewall && $GET{'viewall'} == 1);
 
-        LJ::statushistory_add( $usejournal_u->userid,
-                               $remote->userid,
-                               "viewall",
-                               "scheduled: username: $usejournal_u->{'user'}, statusvis: $usejournal_u->{'statusvis'}");
-    }
+    LJ::statushistory_add( $usejournal_u->userid,
+                           $remote->userid,
+                           "viewall",
+                           "scheduled: username: $usejournal_u->{'user'}, statusvis: $usejournal_u->{'statusvis'}");
 
     my $entry_chooser = sub {
         my $ref = shift;
@@ -108,7 +106,8 @@
         foreach my $ditem (@$delayed_entries) {
             my $entry = LJ::DelayedEntry->get_entry_by_id( $u,
                                                            $ditem,
-                                                           { 'delayed_visibility' => $visibility } );
+                                                           { 'viewsome'=> $viewsome,
+                                                             'viewall' => $viewall, });
 
             push @ordered, {
                             'alldatepart'        => $entry->alldatepart ,
@@ -128,7 +127,8 @@
                                                                    { 'skip'    => $skip,
                                                                      'show'    => $items_per_page + 1,
                                                                      'only_my' => $only_me_checked,
-                                                                     'delayed_visibility' => $visibility });
+                                                                     'viewsome'=> $viewsome,
+                                                                     'viewall' => $viewall, });
 
     my $have_next_page =  scalar @$delayed_entries > $items_per_page;
     if ($have_next_page) {

Tags: bml, livejournal, madeon, pm, sbelyaev
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments