fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)
fu ([personal profile] fu) wrote in [site community profile] changelog2010-10-01 04:29 pm

[dw-free] Support system: allow users to receive copies of their own responses to requests.

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

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

Add an option so that volunteers can opt into receiving their own responses.

Patch by [personal profile] kareila.

Files modified:
  • bin/upgrading/proplists.dat
  • cgi-bin/LJ/Support.pm
  • htdocs/support/changenotify.bml
  • htdocs/support/changenotify.bml.text
--------------------------------------------------------------------------------
diff -r 647800dfd8a1 -r ebea5b13e8a4 bin/upgrading/proplists.dat
--- a/bin/upgrading/proplists.dat	Fri Oct 01 23:28:36 2010 +0800
+++ b/bin/upgrading/proplists.dat	Sat Oct 02 00:29:19 2010 +0800
@@ -653,6 +653,14 @@ userproplist.opt_getselfemail:
   indexed: 0
   multihomed: 0
   prettyname: Get Emails for Comments You Make
+
+userproplist.opt_getselfsupport:
+  cldversion: 4
+  datatype: bool
+  des: If true, include user's own responses in support notifications.
+  indexed: 0
+  multihomed: 0
+  prettyname: Get Emails for Your Own Support Responses
 
 userproplist.opt_getting_started:
   cldversion: 4
diff -r 647800dfd8a1 -r ebea5b13e8a4 cgi-bin/LJ/Support.pm
--- a/cgi-bin/LJ/Support.pm	Fri Oct 01 23:28:36 2010 +0800
+++ b/cgi-bin/LJ/Support.pm	Sat Oct 02 00:29:19 2010 +0800
@@ -355,6 +355,17 @@ sub can_read_screened
 sub can_read_screened
 {
     return LJ::Support::support_check_priv(@_, 'supportviewscreened');
+}
+
+sub can_read_response
+{
+    my ( $sp, $u, $rtype, $posterid ) = @_;
+    return 1 if $posterid == $u->id;
+    return 0 if $rtype eq 'screened' &&
+                ! LJ::Support::can_read_screened( $sp, $u );
+    return 0 if $rtype eq 'internal' &&
+                ! LJ::Support::can_read_internal( $sp, $u );
+    return 1;
 }
 
 sub can_perform_actions
@@ -1081,11 +1092,9 @@ sub work {
         foreach my $u (values %$userids) {
             next unless $u->is_visible;
             next unless $u->{status} eq "A";
-            next if $posterid == $u->id;
-            next if $rtype eq 'screened' &&
-                !LJ::Support::can_read_screened($sp, $u);
-            next if $rtype eq 'internal' &&
-                !LJ::Support::can_read_internal($sp, $u);
+            next unless LJ::Support::can_read_response( $sp, $u, $rtype, $posterid );
+            next if $posterid == $u->id &&
+                ! $u->prop( 'opt_getselfsupport' );
             push @emails, $u->email_raw;
         }
     }
diff -r 647800dfd8a1 -r ebea5b13e8a4 htdocs/support/changenotify.bml
--- a/htdocs/support/changenotify.bml	Fri Oct 01 23:28:36 2010 +0800
+++ b/htdocs/support/changenotify.bml	Sat Oct 02 00:29:19 2010 +0800
@@ -78,6 +78,11 @@ body<=
      }
      $ret .= "</div>\n";
 
+     $ret .= "<p><label for='opt_getselfsupport'>$ML{'.getownresponses'}</label> ";
+     $ret .= LJ::html_check( { type => 'check', name => 'opt_getselfsupport',
+                               id => 'opt_getselfsupport',
+                               selected => $remote->prop( 'opt_getselfsupport' ) } );
+     $ret .= "</p>\n";
 
      ### ending submit block
      $ret .= "<?h1 $ML{'.done.title'} h1?>";
@@ -90,6 +95,8 @@ body<=
 
  if ($mode eq "save")
  {
+     $remote->set_prop( 'opt_getselfsupport' => $FORM{opt_getselfsupport} ? 1 : 0 );
+
      my $dbh = LJ::get_db_writer();
      $dbh->do("DELETE FROM supportnotify WHERE userid=$remote->{'userid'}");
      my $sql;
diff -r 647800dfd8a1 -r ebea5b13e8a4 htdocs/support/changenotify.bml.text
--- a/htdocs/support/changenotify.bml.text	Fri Oct 01 23:28:36 2010 +0800
+++ b/htdocs/support/changenotify.bml.text	Sat Oct 02 00:29:19 2010 +0800
@@ -6,6 +6,8 @@
 .done.text=When done, press the "Save Changes" button below...
 
 .done.title=Done?
+
+.getownresponses=Check here if you'd also like to include notifications for your own responses.
 
 .mustlogin=You must first <a href=[[login]]>login</a>.
 
--------------------------------------------------------------------------------

Post a comment in response:

This account has disabled anonymous posting.
If you don't have an account you can create one now.
No Subject Icon Selected
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org