mark: A photo of Mark kneeling on top of the Taal Volcano in the Philippines. It was a long hike. (Default)
Mark Smith ([staff profile] mark) wrote in [site community profile] changelog2009-04-29 06:11 am

[dw-free] remove crosspost option when posting to comms

[commit: http://hg.dwscoalition.org/dw-free/rev/8bcec436b07f]

http://bugs.dwscoalition.org/show_bug.cgi?id=951

Xposter: don't show option to crosspost when you're posting to a community.

Patch by [personal profile] allen.

Files modified:
  • cgi-bin/weblib.pl
  • htdocs/editjournal.bml
  • htdocs/js/xpost.js
  • htdocs/update.bml
--------------------------------------------------------------------------------
diff -r 30376569bcb4 -r 8bcec436b07f cgi-bin/weblib.pl
--- a/cgi-bin/weblib.pl	Wed Apr 29 06:09:38 2009 +0000
+++ b/cgi-bin/weblib.pl	Wed Apr 29 06:11:27 2009 +0000
@@ -1185,12 +1185,13 @@ sub entry_form {
                 $out .= "<label for='usejournal' class='left'>" . BML::ml('entryform.postto') . "</label>\n";
                 $out .= LJ::html_select({ 'name' => 'usejournal', 'id' => 'usejournal', 'selected' => $usejournal,
                                     'tabindex' => $tabindex->(), 'class' => 'select',
-                                    "onchange" => "changeSubmit('".$submitprefix."','".$remote->{'user'}."'); getUserTags('$remote->{user}'); changeSecurityOptions('$remote->{user}');" },
+                                    "onchange" => "changeSubmit('".$submitprefix."','".$remote->{'user'}."'); getUserTags('$remote->{user}'); changeSecurityOptions('$remote->{user}'); LiveJournal.updateXpostFromJournal('$remote->{user}');" },
                                     "", $remote->{'user'},
                                     map { $_, $_ } @{$res->{'usejournals'}}) . "\n";
                 $out .= "</p>\n";
             }
         }
+        $$onload .= " LiveJournal.updateXpostFromJournal('$remote->{user}');";
 
         # Authentication box
         $out .= "<p class='update-errors'><?inerr $errors->{'auth'} inerr?></p>\n" if $errors->{'auth'};
@@ -1614,11 +1615,12 @@ MOODS
                     }
                 }
 
-                $out .= "<p><label for='prop_xpost' class='left options'>" . BML::ml('entryform.xpost') . "</label>";
+                $out .= "<div id='xpostdiv'>\n";
+                $out .= "<p><label for='prop_xpost_check' class='left options'>" . BML::ml('entryform.xpost') . "</label>";
                 $out .= LJ::html_check({
                     'type'     => 'checkbox',
-                    'name'     => 'prop_xpost',
-                    'id'       => 'prop_xpost',
+                    'name'     => 'prop_xpost_check',
+                    'id'       => 'prop_xpost_check',
                     'class'    => 'check',
                     'value'    => '1',
                     'selected' => $xpostbydefault,
@@ -1626,12 +1628,13 @@ MOODS
                     'tabindex' => $xpost_tabindex,
                     'onchange' => 'LiveJournal.xpostButtonUpdated();',
                                        });
-                $out .= LJ::help_icon_html('prop_xpost');
+                $out .= LJ::help_icon_html('prop_xpost_check');
                 $out .= "<a href = '/manage/settings/?cat=othersites'>" . BML::ml('entryform.xpost.manage') . "</a>";
                 $out .= "</p>\n<table>";
                 $out .= $accthtml;
                 $out .= "</table>\n";
                 
+                $out .= "</div>\n";
                 # disable choices if no xpost selected by default.
                 $out .= qq [ 
               <script type="javascript">
diff -r 30376569bcb4 -r 8bcec436b07f htdocs/editjournal.bml
--- a/htdocs/editjournal.bml	Wed Apr 29 06:09:38 2009 +0000
+++ b/htdocs/editjournal.bml	Wed Apr 29 06:11:27 2009 +0000
@@ -238,10 +238,10 @@ body<=
                 my $entry_url = LJ::item_link($journalu, $itemid, $res{anum});
                 my $edititemlink = "/editjournal.bml?itemid=$ditemid";
 
-                # update crossposts
+                # update crosspost if we're posting to our own journal and have
+                # selected crosspost.
                 my $xpost_result = '';
-
-                if ($POST{prop_xpost} || $GET{prop_xpost}) {
+                if ($journalu == $remote && ($POST{prop_xpost_check} || $GET{prop_xpost_check})) {
                     my @xpost_success;
                     my @xpost_errors;
 
diff -r 30376569bcb4 -r 8bcec436b07f htdocs/js/xpost.js
--- a/htdocs/js/xpost.js	Wed Apr 29 06:09:38 2009 +0000
+++ b/htdocs/js/xpost.js	Wed Apr 29 06:11:27 2009 +0000
@@ -1,9 +1,30 @@ LiveJournal.xpostButtonUpdated = functio
 LiveJournal.xpostButtonUpdated = function () {
-  var xpost_button = document.getElementById("prop_xpost");
+  var xpost_button = document.getElementById("prop_xpost_check");
   var xpost_checkboxes = DOM.getElementsByTagAndClassName(document, "input", "xpost_acct_checkbox") || [];
   for (var i=0; i < xpost_checkboxes.length; i++) {
     xpost_checkboxes[i].disabled = ! xpost_button.checked;
   }
+}
+
+LiveJournal.updateXpostFromJournal = function (user) {
+  // only allow crossposts to the user's own journal
+  var journal = document.updateForm.usejournal.value;
+  var allowXpost = (journal == '' || user == journal);
+
+  var xpost_button = document.getElementById("prop_xpost_check");
+  xpost_button.disabled = ! allowXpost;
+  var xpost_checkboxes = DOM.getElementsByTagAndClassName(document, "input", "xpost_acct_checkbox") || [];
+  for (var i=0; i < xpost_checkboxes.length; i++) {
+    xpost_checkboxes[i].disabled = ! allowXpost;
+  }
+
+  var xpostdiv = document.getElementById('xpostdiv');
+  if (allowXpost) {
+    xpostdiv.style.display = 'block';
+  } else {
+    xpostdiv.style.display = 'none';
+  }
+
 }
 
 
diff -r 30376569bcb4 -r 8bcec436b07f htdocs/update.bml
--- a/htdocs/update.bml	Wed Apr 29 06:09:38 2009 +0000
+++ b/htdocs/update.bml	Wed Apr 29 06:11:27 2009 +0000
@@ -431,8 +431,9 @@
 
                     my $edititemlink = "/editjournal.bml?journal=$juser&itemid=$itemid";
 
-                    #crosspost if necessary
-                    if ($POST{prop_xpost} || $GET{prop_xpost}) {
+                    # crosspost if we're posting to our own journal and have
+                    # selected crosspost.
+                    if ($ju == $remote && ($POST{prop_xpost_check} || $GET{prop_xpost_check})) {
                         my @xpost_success;
                         my @xpost_errors;
 
--------------------------------------------------------------------------------