Property, setting interface, logic.
Patch by denise.
diffs (189 lines):
diff -r c2ddf1cae0c9 -r d497a58c35e5 bin/upgrading/en.dat
--- a/bin/upgrading/en.dat Thu Jul 02 04:18:21 2009 +0000
+++ b/bin/upgrading/en.dat Thu Jul 02 04:38:46 2009 +0000
@@ -2863,6 +2863,16 @@ setting.xpost.option.delete=Delete
setting.xpost.option.disablecomments=Disable comments on crossposts made to
other sites
+setting.xpost.option.footer=Text of the footer to add on other sites. If you
leave it blank, the default will display. To include a link to the post
locally, use "%%url%%".
+
+setting.xpost.option.footer.when=Add the footer to the post on the other site:
+
+setting.xpost.option.footer.when.always=Always
+
+setting.xpost.option.footer.when.disabled=When Comments Disabled
+
+setting.xpost.option.footer.when.never=Never
+
setting.xpost.option.password=Password
setting.xpost.option.server=Server
diff -r c2ddf1cae0c9 -r d497a58c35e5 bin/upgrading/proplists.dat
--- a/bin/upgrading/proplists.dat Thu Jul 02 04:18:21 2009 +0000
+++ b/bin/upgrading/proplists.dat Thu Jul 02 04:38:46 2009 +0000
@@ -109,6 +109,22 @@ userproplist.country:
indexed: 1
multihomed: 0
prettyname: Country
+
+userproplist.crosspost_footer_append:
+ cldversion: 4
+ datatype: char
+ des: N: never, A: always add to remote, D: only add when comments disabled
on remote site
+ indexed: 0
+ multihomed: 0
+ prettyname: When and where to add the crossposted text footer
+
+userproplist.crosspost_footer_text:
+ cldversion: 4
+ datatype: char
+ des: Custom footer for crossposted entries
+ indexed: 0
+ multihomed: 0
+ prettyname: Custom footer for crossposted entries
userproplist.delicious:
cldversion: 4
diff -r c2ddf1cae0c9 -r d497a58c35e5
cgi-bin/DW/External/XPostProtocol/LJXMLRPC.pm
--- a/cgi-bin/DW/External/XPostProtocol/LJXMLRPC.pm Thu Jul 02 04:18:21
2009 +0000
+++ b/cgi-bin/DW/External/XPostProtocol/LJXMLRPC.pm Thu Jul 02 04:38:46
2009 +0000
@@ -136,6 +136,7 @@ sub call_xmlrpc {
# with success => 1 and url => the new url on success, or success => 0
# and error => the error message on failure.
sub crosspost {
+
my ($self, $extacct, $auth, $entry, $itemid, $delete) = @_;
# get the xml-rpc proxy and start the connection.
@@ -149,17 +150,57 @@ sub crosspost {
} else {
# if it's a post or edit, fully populate the request.
$req = $self->entry_to_req($entry, $extacct, $auth);
- # handle disable comments
- if ($extacct->owner->prop('opt_xpost_disable_comments')) {
- if ($req->{props}->{opt_nocomments}) {
- $req->{event} = $req->{event} . "\n\n" .
LJ::Lang::ml("xpost.redirect", { postlink => $entry->url });
+
+ # are we disabling comments?
+ my $disabling_comments = $extacct->owner->prop(
'opt_xpost_disable_comments' ) ? 1 : 0;
+ $req->{props}->{opt_nocomments} = 1 if $disabling_comments;
+
+ # are we adding a footer?
+ my ( $adding_footer, $footer_text );
+ $footer_text = $extacct->owner->prop( 'crosspost_footer_text' );
+
+ if ( $extacct->owner->prop( 'crosspost_footer_append' ) eq "A" ) {
+ # we are always adding a footer, but we need to
+ # make some adjustments based on whether it's a custom
+ # footer, whether comments are disabled, etc
+
+ $adding_footer = 1;
+ if ( $footer_text ) {
+ my $url = $entry->url;
+ $footer_text =~ s/%%url%%/$url/gi;
+ $footer_text = "\n\n" . $footer_text;
} else {
- $req->{event} = $req->{event} . "\n\n" .
LJ::Lang::ml("xpost.redirect.comment", { postlink => $entry->url });
- $req->{props}->{opt_nocomments} = 1;
+ if ( $disabling_comments ) {
+ $footer_text = "\n\n" . LJ::Lang::ml( "xpost.redirect", {
postlink => $entry->url } );
+ } else {
+ $footer_text = "\n\n" . LJ::Lang::ml(
"xpost.redirect.comment", { postlink => $entry->url } );
+ }
}
+
+ } elsif ( $extacct->owner->prop( 'crosspost_footer_append' ) eq "D" &&
$disabling_comments ) {
+ # we are only adding a footer if comments are disabled
+ # (and they are)
+
+ $adding_footer = 1;
+ if ( $footer_text ) {
+ my $url = $entry->url;
+ $footer_text =~ s/%%url%%/$url/gi;
+ $footer_text = "\n\n" . $footer_text;
+ } else {
+ $footer_text = "\n\n" . LJ::Lang::ml( 'xpost.redirect', {
postlink => $entry->url } );
+ }
+ } else {
+ # we aren't adding a footer
+ $adding_footer = 0;
}
+
+ # now that we have all of that settled, let's assemble it
+ # together into the post-in-progress:
+
+ $req->{event} = $req->{event} . $footer_text if $adding_footer;
+
}
-
+
# get the correct itemid for edit
$req->{itemid} = $itemid if $itemid;
diff -r c2ddf1cae0c9 -r d497a58c35e5 cgi-bin/DW/Setting/XPostAccounts.pm
--- a/cgi-bin/DW/Setting/XPostAccounts.pm Thu Jul 02 04:18:21 2009 +0000
+++ b/cgi-bin/DW/Setting/XPostAccounts.pm Thu Jul 02 04:38:46 2009 +0000
@@ -5,7 +5,7 @@ use warnings;
use Digest::MD5 qw(md5_hex);
-sub tags { qw(xpost_option_server xpost_option_username xpost_option_password
xpost_option_xpostbydefault) }
+sub tags { qw(xpost_option_server xpost_option_username xpost_option_password
xpost_option_xpostbydefault crosspost_footer_append crosspost_footer_text) }
# show this setting editor
sub should_render {
@@ -103,13 +103,39 @@ sub option {
}
# disable comments on crosspost
- $ret .= "<p><label for='${key}xpostdisablecomments'>" .
$class->ml('setting.xpost.option.disablecomments') . "</label>";
+ $ret .= "<br /><p><label for='${key}xpostdisablecomments'>" .
$class->ml('setting.xpost.option.disablecomments') . "</label>";
$ret .= LJ::html_check({
name => "${key}xpostdisablecomments",
value => 1,
id => "${key}xpostdisablecomments",
selected => $u->prop('opt_xpost_disable_comments')
}) . "</p>";
+
+ # define custom footer
+ $ret .= "<p><label for='${key}crosspost_footer_text'>" . $class->ml(
'setting.xpost.option.footer' ) . "</label>";
+ my $footer_text = $u->prop('crosspost_footer_text');
+
+ $ret .= LJ::html_text({
+ name => "${key}crosspost_footer_text",
+ id => "${key}crosspost_footer_text",
+ size => "70",
+ maxlength => "255",
+ value => $footer_text
+ }) . "</p>";
+
+ # When should the footer be displayed?
+ $ret .= "<p><label for='${key}crosspost_footer_append'>" . $class->ml(
'setting.xpost.option.footer.when' ) . "</label> ";
+ my $append_when = $u->prop('crosspost_footer_append');
+
+ $ret .= LJ::html_select({
+ name => "${key}crosspost_footer_append",
+ id => "${key}crosspost_footer_append",
+ class => "select",
+ selected => $append_when || 'D' },
+ 'A' => $class->ml( 'setting.xpost.option.footer.when.always' ),
+ 'D' => $class->ml( 'setting.xpost.option.footer.when.disabled' ),
+ 'N' => $class->ml( 'setting.xpost.option.footer.when.never' )
+ );
return $ret;
}
@@ -143,6 +169,13 @@ sub save {
# reset disable comments
$u->set_prop( opt_xpost_disable_comments => $class->get_arg($args,
"xpostdisablecomments") ? "1" : "0");
+ # change footer text
+ $u->set_prop( crosspost_footer_text => $class->get_arg( $args,
"crosspost_footer_text" ) );
+
+ # change footer display
+ $u->set_prop( crosspost_footer_append => $class->get_arg( $args,
"crosspost_footer_append" ) );
+
+
return 1;
}
_______________________________________________
dw-changelog mailing list
[email protected]
http://lists.dwscoalition.org/mailman/listinfo/dw-changelog