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-07-06 12:21 am

[dw-free] Change console-only "set" commands to an Advanced Options tab

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

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

Oops. Add DW::Settings::EmailAlias file.

Patch by [personal profile] kareila.

Files modified:
  • cgi-bin/DW/Setting/EmailAlias.pm
--------------------------------------------------------------------------------
diff -r 7128b83b0d2e -r d4e35c18bc4f cgi-bin/DW/Setting/EmailAlias.pm
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cgi-bin/DW/Setting/EmailAlias.pm	Mon Jul 06 00:21:06 2009 +0000
@@ -0,0 +1,63 @@
+#!/usr/bin/perl
+#
+# DW::Setting::EmailAlias
+#
+# LJ::Setting module for choosing whether or not to disable email
+# forwarding via the site alias for a given user, as governed by the
+# "no_mail_alias" user property.
+#
+# Authors:
+#      Jen Griffin <kareila@livejournal.com>
+#
+# Copyright (c) 2009 by Dreamwidth Studios, LLC.
+#
+# This program is free software; you may redistribute it and/or modify it under
+# the same terms as Perl itself.  For a copy of the license, please reference
+# 'perldoc perlartistic' or 'perldoc perlgpl'.
+#
+
+package DW::Setting::EmailAlias;
+use base 'LJ::Setting';
+use strict;
+use warnings;
+
+sub should_render {
+    my ( $class, $u ) = @_;
+    return $u && LJ::get_cap( $u, 'useremail' ) ? 1 : 0;
+}
+
+sub label {
+    my $class = shift;
+    return $class->ml( 'setting.emailalias.label' );
+}
+
+sub option {
+    my ( $class, $u, $errs, $args ) = @_;
+    my $key = $class->pkgkey;
+
+    my $emailalias = $class->get_arg( $args, "emailalias" ) || ! $u->prop( "no_mail_alias" );
+
+    my $ret = LJ::html_check( {
+        name => "${key}emailalias",
+        id => "${key}emailalias",
+        value => 1,
+        selected => $emailalias ? 1 : 0,
+    } );
+
+    $ret .= " <label for='${key}emailalias'>";
+    $ret .= $class->ml( 'setting.emailalias.option', { user => $u->username, domain => $LJ::USER_DOMAIN } );
+    $ret .= "</label>";
+
+    return $ret;
+}
+
+sub save {
+    my ( $class, $u, $args ) = @_;
+
+    my $val = $class->get_arg( $args, "emailalias" );
+    $u->set_prop( "no_mail_alias" => ! $val );
+
+    return 1;
+}
+
+1;
--------------------------------------------------------------------------------