Bug 16011: $VERSION - remove use vars $VERSION
[koha_ffzg] / C4 / Members / Messaging.pm
index f5530e9..72d942d 100644 (file)
@@ -4,28 +4,28 @@ package C4::Members::Messaging;
 #
 # This file is part of Koha.
 #
-# Koha is free software; you can redistribute it and/or modify it under the
-# terms of the GNU General Public License as published by the Free Software
-# Foundation; either version 2 of the License, or (at your option) any later
-# version.
+# Koha is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
 #
-# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+# Koha is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
 #
-# You should have received a copy of the GNU General Public License along
-# with Koha; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+# You should have received a copy of the GNU General Public License
+# along with Koha; if not, see <http://www.gnu.org/licenses>.
 
 use strict;
 use warnings;
 use C4::Context;
 
-use vars qw($VERSION);
+use vars qw();
 
 BEGIN {
     # set the version for version checking
-    $VERSION = 3.00;
+    $VERSION = 3.07.00.049;
 }
 
 =head1 NAME
@@ -98,9 +98,9 @@ END_SQL
         $return->{'days_in_advance'} = $row->{'days_in_advance'} if defined $row->{'days_in_advance'};
         $return->{'wants_digest'}    = $row->{'wants_digest'}    if defined $row->{'wants_digest'};
         $return->{'letter_code'}     = $row->{'letter_code'};
-        $transports{$row->{'message_transport_type'}} = 1;
+        next unless defined $row->{'message_transport_type'};
+        $return->{'transports'}->{ $row->{'message_transport_type'} } = $row->{'letter_code'};
     }
-    @{$return->{'transports'}} = keys %transports;
     return $return;
 }
 
@@ -213,17 +213,20 @@ END_SQL
         $choices->{ $row->{'message_name'} }->{'message_name'}         = $row->{'message_name'};
         $choices->{ $row->{'message_name'} }->{'takes_days'}           = $row->{'takes_days'};
         $choices->{ $row->{'message_name'} }->{'has_digest'}           = 1 if $row->{'is_digest'};
-        $choices->{ $row->{'message_name'} }->{'transport-' . $row->{'message_transport_type'}} = ' ';
+        $choices->{ $row->{'message_name'} }->{'transport_' . $row->{'message_transport_type'}} = ' ';
     }
 
     my @return = values %$choices;
+
+    @return = sort { $a->{message_attribute_id} <=> $b->{message_attribute_id} } @return;
+
     # warn( Data::Dumper->Dump( [ \@return ], [ 'return' ] ) );
     return \@return;
 }
 
 =head2 SetMessagingPreferencesFromDefaults
 
-  C4::Members::Messaging::SetMessagingPreferenceFromDefaults( { borrowernumber => $borrower->{'borrowernumber'}
+  C4::Members::Messaging::SetMessagingPreferencesFromDefaults( { borrowernumber => $borrower->{'borrowernumber'}
                                                                 categorycode   => 'CPL' } );
 
 Given a borrowernumber and a patron category code (from the C<borrowernumber> and C<categorycode> keys
@@ -248,8 +251,9 @@ sub SetMessagingPreferencesFromDefaults {
         # FIXME - except for setting the borrowernumber, it really ought to be possible
         # to have the output of GetMessagingPreferences be able to be the input
         # to SetMessagingPreference
+        my @message_transport_types = keys %{ $default_pref->{transports} };
         $default_pref->{message_attribute_id}    = $option->{'message_attribute_id'};
-        $default_pref->{message_transport_types} = $default_pref->{transports};
+        $default_pref->{message_transport_types} = \@message_transport_types;
         $default_pref->{borrowernumber}          = $params->{borrowernumber};
         SetMessagingPreference( $default_pref );
     }