View | Details | Raw Unified | Return to bug 33239
Collapse All | Expand All

(-)a/C4/Members/Messaging.pm (+3 lines)
Lines 243-248 sub SetMessagingPreferencesFromDefaults { Link Here
243
243
244
    my $messaging_options = GetMessagingOptions();
244
    my $messaging_options = GetMessagingOptions();
245
    OPTION: foreach my $option ( @$messaging_options ) {
245
    OPTION: foreach my $option ( @$messaging_options ) {
246
        if ( defined $params->{message_name} && $option->{'message_name'} ne $params->{message_name} ) {
247
            next OPTION;
248
        }
246
        my $default_pref = GetMessagingPreferences( { categorycode => $params->{categorycode},
249
        my $default_pref = GetMessagingPreferences( { categorycode => $params->{categorycode},
247
                                                      message_name => $option->{'message_name'} } );
250
                                                      message_name => $option->{'message_name'} } );
248
        # FIXME - except for setting the borrowernumber, it really ought to be possible
251
        # FIXME - except for setting the borrowernumber, it really ought to be possible
(-)a/misc/maintenance/borrowers-force-messaging-defaults.pl (-6 / +14 lines)
Lines 34-40 sub usage { Link Here
34
34
35
35
36
sub force_borrower_messaging_defaults {
36
sub force_borrower_messaging_defaults {
37
    my ($doit, $since, $not_expired, $no_overwrite, $category ) = @_;
37
    my ($doit, $since, $not_expired, $no_overwrite, $category, $message_name ) = @_;
38
38
39
    print "Since: $since\n" if $since;
39
    print "Since: $since\n" if $since;
40
40
Lines 62-71 WHERE 1|; Link Here
62
    while ( my ($borrowernumber, $categorycode) = $sth->fetchrow ) {
62
    while ( my ($borrowernumber, $categorycode) = $sth->fetchrow ) {
63
        print "$borrowernumber: $categorycode\n";
63
        print "$borrowernumber: $categorycode\n";
64
        next unless $doit;
64
        next unless $doit;
65
        C4::Members::Messaging::SetMessagingPreferencesFromDefaults( {
65
        my $options = {
66
            borrowernumber => $borrowernumber,
66
            borrowernumber => $borrowernumber,
67
            categorycode   => $categorycode,
67
            categorycode   => $categorycode,
68
        } );
68
        };
69
        $options{message_name} = $message_name if defined $message_name;
70
        C4::Members::Messaging::SetMessagingPreferencesFromDefaults($options);
69
        $cnt++;
71
        $cnt++;
70
    }
72
    }
71
    $dbh->commit();
73
    $dbh->commit();
Lines 73-91 WHERE 1|; Link Here
73
}
75
}
74
76
75
77
76
my ( $doit, $since, $help, $not_expired, $no_overwrite, $category );
78
my ( $doit, $since, $help, $not_expired, $no_overwrite, $category, $message_name );
77
my $result = GetOptions(
79
my $result = GetOptions(
78
    'doit'        => \$doit,
80
    'doit'        => \$doit,
79
    'since:s'     => \$since,
81
    'since:s'     => \$since,
80
    'not-expired' => \$not_expired,
82
    'not-expired' => \$not_expired,
81
    'no-overwrite'  => \$no_overwrite,
83
    'no-overwrite'  => \$no_overwrite,
82
    'category:s'  => \$category,
84
    'category:s'  => \$category,
85
    'message-name:s' => \$message_name,
83
    'help|h'      => \$help,
86
    'help|h'      => \$help,
84
);
87
);
85
88
86
usage() if $help;
89
usage() if $help;
87
90
88
force_borrower_messaging_defaults( $doit, $since, $not_expired, $no_overwrite, $category );
91
force_borrower_messaging_defaults( $doit, $since, $not_expired, $no_overwrite, $category, $message_name );
89
92
90
=head1 NAME
93
=head1 NAME
91
94
Lines 98-103 borrowers-force-messaging-defaults.pl Link Here
98
  borrowers-force-messaging-defaults.pl --doit
101
  borrowers-force-messaging-defaults.pl --doit
99
  borrowers-force-messaging-defaults.pl --doit --not-expired
102
  borrowers-force-messaging-defaults.pl --doit --not-expired
100
  borrowers-force-messaging-defaults.pl --doit --category PT
103
  borrowers-force-messaging-defaults.pl --doit --category PT
104
  borrowers-force-messaging-defaults.pl --doit --message-name 'Item_Due'
101
105
102
=head1 DESCRIPTION
106
=head1 DESCRIPTION
103
107
Lines 134-139 already set their preferences. Link Here
134
138
135
Will only update patrons in the category specified.
139
Will only update patrons in the category specified.
136
140
141
=item B<--message-name>
142
143
Will only update the specified message name.
144
List of values can be found in installer/data/mysql/mandatory/sample_notices_message_attributes.sql
145
137
=item B<--since>
146
=item B<--since>
138
147
139
Will only update borrowers enrolled since the specified date.
148
Will only update borrowers enrolled since the specified date.
140
- 

Return to bug 33239