<<

NAME

C4::Form::MessagingPreferences - manage messaging preferences form

SYNOPSIS

In script:

    use C4::Form::MessagingPreferences;
    C4::Form::MessagingPreferences::set_form_value({ borrowernumber => 51 }, $template);
    C4::Form::MessagingPreferences::handle_form_action($input, { categorycode => 'CPL' }, $template);

In HTML template:

    <!-- TMPL_INCLUDE NAME="messaging-preference-form.inc" -->

DESCRIPTION

This module manages input and output for the messaging preferences form that is used in the staff patron editor, the staff patron category editor, and the OPAC patron messaging prefereneces form. It in its current form, it essentially serves only to eliminate copy-and-paste code, but suggests at least one approach for reconciling functionality that does mostly the same thing in staff and OPAC.

FUNCTIONS

handle_form_action

    C4::Form::MessagingPreferences::handle_form_action($input, { categorycode => 'CPL' }, $template, $insert);

Processes CGI parameters and updates the target patron or patron category's preferences.

$input is the CGI query object.

$target_params is a hashref containing either a categorycode key or a borrowernumber key identifying the patron or patron category whose messaging preferences are to be updated.

$template is the Template::Toolkit object for the response; this routine adds a settings_updated template variable.

set_form_values

    C4::Form::MessagingPreferences::set_form_value({ borrowernumber => 51 }, $template);

Retrieves the messaging preferences for the specified patron or patron category and fills the corresponding template variables.

$target_params is a hashref containing either a categorycode key or a borrowernumber key identifying the patron or patron category.

$template is the Template::Toolkit object for the response.

TODO

Reduce coupling between processing CGI parameters and updating the messaging preferences
Handle when form input is invalid
Generalize into a system of form handler clases

SEE ALSO

C4::Members::Messaging, admin/categories.pl, opac/opac-messaging.pl, members/messaging.pl

AUTHOR

Koha Development Team <http://koha-community.org/>

Galen Charlton <galen.charlton@liblime.com> refactoring code by Andrew Moore.

<<