Committer: ailyin
LJSUP-8547 (Add ability to post an entry to community for identity accounts)U trunk/bin/upgrading/en.dat U trunk/cgi-bin/LJ/S2.pm U trunk/cgi-bin/LJ/Widget/EntryForm.pm U trunk/cgi-bin/ljprotocol.pl U trunk/htdocs/editjournal.bml U trunk/htdocs/update.bml
Modified: trunk/bin/upgrading/en.dat =================================================================== --- trunk/bin/upgrading/en.dat 2011-04-11 10:08:43 UTC (rev 18840) +++ trunk/bin/upgrading/en.dat 2011-04-11 10:13:52 UTC (rev 18841) @@ -1310,6 +1310,8 @@ entryform.postto=Post to: +entryform.postto.select=Select a community + entryform.preview=Preview entryform.public|staleness=1 Modified: trunk/cgi-bin/LJ/S2.pm =================================================================== --- trunk/cgi-bin/LJ/S2.pm 2011-04-11 10:08:43 UTC (rev 18840) +++ trunk/cgi-bin/LJ/S2.pm 2011-04-11 10:13:52 UTC (rev 18841) @@ -3764,8 +3764,10 @@ sub _Entry__get_link { my ($ctx, $this, $key) = @_; - my $journal = $this->{'journal'}->{'username'}; - my $poster = $this->{'poster'}->{'username'}; + my $journal = $this->{'journal'}->{'username'}; + my $journalu = $this->{'journal'}->{'_u'}; + my $poster = $this->{'poster'}->{'username'}; + my $posteru = $this->{'poster'}->{'_u'}; my $remote = LJ::get_remote(); my $null_link = { '_type' => 'Link', '_isnull' => 1 }; my $journalu = LJ::load_user($journal); @@ -3773,9 +3775,9 @@ if ($key eq "edit_entry") { return $null_link unless $remote && - ($remote->{'user'} eq $journal || - $remote->{'user'} eq $poster || - $remote->can_manage(LJ::load_user($journal)) + ( LJ::u_equals( $remote, $journalu ) || + LJ::u_equals( $remote, $posteru ) || + $remote->can_manage($journalu) ); return LJ::S2::Link("$LJ::SITEROOT/editjournal.bml?journal=$journal&itemid=$this->{'itemid'}", $ctx->[S2::PROPS]->{"text_edit_entry"}, Modified: trunk/cgi-bin/LJ/Widget/EntryForm.pm =================================================================== --- trunk/cgi-bin/LJ/Widget/EntryForm.pm 2011-04-11 10:08:43 UTC (rev 18840) +++ trunk/cgi-bin/LJ/Widget/EntryForm.pm 2011-04-11 10:13:52 UTC (rev 18841) @@ -405,6 +405,17 @@ $out .= "<label for='usejournal' class='left'>" . BML::ml('entryform.postto') . "</label>\n"; + my @choices; + + if ( $remote->is_personal ) { + push @choices, '' => $remote->username; + } else { + push @choices, + '[none]' => LJ::Lang::ml('entryform.postto.select'); + } + + push @choices, map { $_ => $_ } @{ $login_data->{'usejournals'} }; + $out .= LJ::html_select( { 'name' => 'usejournal', @@ -416,10 +427,7 @@ "getUserTags(this[this.selectedIndex].value);". "changeSecurityOptions(this[this.selectedIndex].value)" }, - ( - "" => $remote->{'user'}, - map { $_, $_ } @{$login_data->{'usejournals'}} - ) + @choices, ); $out .= "</p>\n"; } @@ -1239,6 +1247,8 @@ $$onload .= " changeSecurityOptions('$defaultjournal');"; } + my $disabled = $remote->is_identity && !$self->usejournal; + $out .= LJ::html_submit( 'action:update', BML::ml('entryform.update4'), @@ -1247,6 +1257,7 @@ 'class' => 'submit', 'id' => 'formsubmit', 'tabindex' => $self->tabindex, + 'disabled' => $disabled, } ) . " \n"; } Modified: trunk/cgi-bin/ljprotocol.pl =================================================================== --- trunk/cgi-bin/ljprotocol.pl 2011-04-11 10:08:43 UTC (rev 18840) +++ trunk/cgi-bin/ljprotocol.pl 2011-04-11 10:13:52 UTC (rev 18841) @@ -1612,9 +1612,12 @@ ## should one day be a community journal, of some form. return fail($err,150) if ($u->{'journaltype'} eq "C" || $u->{'journaltype'} eq "S" || - $u->{'journaltype'} eq "I" || $u->{'journaltype'} eq "N"); + # identity users can only post to communities + return fail( $err, 150 ) + if $u->is_identity and LJ::u_equals( $u, $uowner ); + # underage users can't do this return fail($err,310) if $u->underage; Modified: trunk/htdocs/editjournal.bml =================================================================== --- trunk/htdocs/editjournal.bml 2011-04-11 10:08:43 UTC (rev 18840) +++ trunk/htdocs/editjournal.bml 2011-04-11 10:13:52 UTC (rev 18841) @@ -32,8 +32,9 @@ my $u = LJ::get_authas_user($authas); return LJ::bad_input("You could not be authenticated as the specified user.") unless $u; + return LJ::bad_input("You must be authenticated as a person.") - unless $u->{'journaltype'} eq 'P'; + unless $u->is_personal || $u->is_identity; # are we modify a community post? my $usejournal = $GET{'usejournal'} || $POST{'usejournal'} || $GET{'journal'}; Modified: trunk/htdocs/update.bml =================================================================== --- trunk/htdocs/update.bml 2011-04-11 10:08:43 UTC (rev 18840) +++ trunk/htdocs/update.bml 2011-04-11 10:13:52 UTC (rev 18841) @@ -61,7 +61,8 @@ return if LJ::bad_password_redirect(); - if ($remote->identity) { + my @posting_access = $remote->posting_access_list; + if ( $remote->is_identity && scalar(@posting_access) == 0 ) { $$title = $ML{'Sorry'}; $$body = BML::ml('.error.nonusercantpost', {'sitename' => $LJ::SITENAME}); return; @@ -237,7 +238,7 @@ if ($altlogin_display eq 'none') { $auth.= "<p id='remotelogin' class='pkg'>\n"; $auth .= "<label for='current_username' class='left'>" . BML::ml('entryform.postas') . "</label>\n"; - $auth .= "<strong id='current_username'>" . $remote->{user} . "</strong> <a href='$LJ::SITEROOT/update.bml?altlogin=1' id='remotelogin_content' class='small'>$ML{'entryform.switchuser'}</a>\n"; + $auth .= "<strong id='current_username'>" . $remote->display_name . "</strong> <a href='$LJ::SITEROOT/update.bml?altlogin=1' id='remotelogin_content' class='small'>$ML{'entryform.switchuser'}</a>\n"; $auth .= "</p>\n\n"; } # table with username/password fields