Bug 16011: $VERSION - remove use vars $VERSION
[koha_ffzg] / C4 / Members / Messaging.pm
index 1a9e3c4..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
@@ -74,7 +74,7 @@ LEFT JOIN borrower_message_transport_preferences
 ON     borrower_message_transport_preferences.borrower_message_preference_id = borrower_message_preferences.borrower_message_preference_id
 LEFT JOIN message_attributes
 ON     message_attributes.message_attribute_id = borrower_message_preferences.message_attribute_id
-JOIN message_transports
+LEFT JOIN message_transports
 ON     message_transports.message_attribute_id = message_attributes.message_attribute_id
 AND    message_transports.message_transport_type = borrower_message_transport_preferences.message_transport_type
 WHERE  message_attributes.message_name = ?
@@ -98,6 +98,7 @@ 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'};
+        next unless defined $row->{'message_transport_type'};
         $return->{'transports'}->{ $row->{'message_transport_type'} } = $row->{'letter_code'};
     }
     return $return;
@@ -216,13 +217,16 @@ END_SQL
     }
 
     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