afuna: Cat under a blanket. Text: "Cats are just little people with Fur and Fangs" (Default)
afuna ([personal profile] afuna) wrote in [site community profile] changelog2009-05-09 09:32 am

[dw-free] crossposter: deleting via crossposter

[commit: http://hg.dwscoalition.org/dw-free/rev/77a790f71115]

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

Second confirmation pop-up when deleting crossposted entries

Patch by [personal profile] allen.

Files modified:
  • bin/upgrading/en.dat
  • cgi-bin/weblib.pl
  • htdocs/js/xpost.js
--------------------------------------------------------------------------------
diff -r 824f806db3f2 -r 77a790f71115 bin/upgrading/en.dat
--- a/bin/upgrading/en.dat	Sat May 09 09:13:46 2009 +0000
+++ b/bin/upgrading/en.dat	Sat May 09 09:31:39 2009 +0000
@@ -1135,6 +1135,8 @@ entryform.delete=Delete Entry
 entryform.delete=Delete Entry
 
 entryform.delete.confirm=Are you sure you want to delete this entry?
+
+entryform.delete.xposts.confirm=This will also delete the selected crossposts.  Are you sure?
 
 entryform.deletespam=Delete and Mark as Spam
 
diff -r 824f806db3f2 -r 77a790f71115 cgi-bin/weblib.pl
--- a/cgi-bin/weblib.pl	Sat May 09 09:13:46 2009 +0000
+++ b/cgi-bin/weblib.pl	Sat May 09 09:31:39 2009 +0000
@@ -1835,10 +1835,13 @@ PREVIEW
                                           'tabindex' => $tabindex->() }) . " \n";
             }
 
+            # do a double-confirm on delete if we have crossposts that
+            # would also get removed
+            my $delete_onclick = "return LiveJournal.confirmDelete('" . LJ::ejs(BML::ml('entryform.delete.confirm')) . "', '" . LJ::ejs(BML::ml('entryform.delete.xposts.confirm')) . "')";
             $out .= LJ::html_submit('action:delete', BML::ml('entryform.delete'), {
                 'disabled' => $opts->{'disabled_delete'},
                 'tabindex' => $tabindex->(),
-                'onclick' => "return confirm('" . LJ::ejs(BML::ml('entryform.delete.confirm')) . "')" }) . " \n";
+                'onclick' => $delete_onclick }) . " \n";
 
             if (!$opts->{'disabled_spamdelete'}) {
                 $out .= LJ::html_submit('action:deletespam', BML::ml('entryform.deletespam'), {
diff -r 824f806db3f2 -r 77a790f71115 htdocs/js/xpost.js
--- a/htdocs/js/xpost.js	Sat May 09 09:13:46 2009 +0000
+++ b/htdocs/js/xpost.js	Sat May 09 09:31:39 2009 +0000
@@ -27,6 +27,25 @@ LiveJournal.updateXpostFromJournal = fun
 
 }
 
+LiveJournal.confirmDelete = function (confMessage, xpostConfMessage) {
+  // basic confirm
+  var conf = confirm(confMessage);
+  if (conf) {
+    // check to see if we have any crossposts selected
+    var xpost_button = document.getElementById("prop_xpost_check");
+    if (xpost_button != null && xpost_button.checked) {
+      var xpost_checkboxes = DOM.getElementsByTagAndClassName(document, "input", "xpost_acct_checkbox") || [];
+      var showconf2 = false;
+      for (var i=0; ! showconf2 && i < xpost_checkboxes.length; i++) {
+        showconf2 = xpost_checkboxes[i].checked;
+      }
+      if (showconf2) {
+        conf = confirm(xpostConfMessage);
+      }
+    }
+  }
+  return conf;
+}
 
 // NOTE:  this functionality is disabled; for now, we're requiring passwords
 // for external accounts.
--------------------------------------------------------------------------------