File/program/modules/mailpage/mailpage_view.php

Description

/program/modules/mailpage/mailpage_view.php - interface to the view-part of the mailpage module

This file defines the interface with the mailpage-module for viewing content. The interface consists of this function:

    mailpage_view(&$output,$area_id,$node_id,$module)

This function is called from /index.php when the node to display is connected to this module.

Includes
 require_once ($CFG->progdir."/lib/tokenlib.php") (line 38)
Constants
MAILPAGE_REFERENCE = sha1(__FILE__.'":".__LINE__) (line 37)
Functions
mailpage_send_message (line 488)

actually send the visitor's message to the selected destination

In order to get a feeling for the time a visitor needs, we also record the delay (in seconds) next to the visitor's IP address.

  • return: FALSE on error, TRUE on success + message sent
  • todo: extra validation of set_mailreplyto and set_subject?
  • todo: more available parameters in subject_line?
  • todo: make body of mail configuratble?
bool mailpage_send_message (array $config, array $dialogdef, string $ip_addr, int $delay)
  • array $dialogdef: array that defines the data fields including values
  • string $ip_addr: the originating IP-address
  • int $delay: the # of seconds since time=t0
  • array $config: mailpage configuration data in a (nested) array
mailpage_show_form (line 348)

display the contact form

this displays the contact form. Every destination gets a separate DIV just below the listbox, with the additional information for that destination. If JavaScript is NOT enabled, all DIVs are displayed, otherwise only the currently selected destination is displayed and the others are not. IOW: this form is still usable even without JS enabled AND it is screenreader-friendly.

If there is only a single destination, the listbox is not defined in the dialogdef and hence not rendered at all: there is no point in showing a list of options if there is nothing to choose from. This means that the necessary javascript is NOT added and also no DIVs are shown. So: a clean, uncluttered form in case of a single destination.

  • return: output writted to $theme
void mailpage_show_form (object &$theme, array $config, array $dialogdef)
  • object &$theme: collects the (html) output
  • array $dialogdef: array that defines the input fields
  • array $config: mailpage configuration data in a (nested) array
mailpage_show_preview (line 431)

show a preview of the message to the visitor

this shows a preview of the message to visitor. Nothing is editable, it is view-only. The only option is to either press the Send-button to actually send the messate OR to press the Edit button to go back to the editable form.

Sending a message is a two-step procedure by design.

  • return: output writted to $theme
void mailpage_show_preview (object &$theme, array $config, array $dialogdef, string $ip_addr)
  • object &$theme: collects the (html) output
  • array $dialogdef: array that defines the input fields
  • string $ip_addr: the originating IP-address
  • array $config: mailpage configuration data in a (nested) array
mailpage_show_thankyou (line 531)

thank the visitor for the message and show a text copy too

Almost the same as {@see mailpage_show_preview()}.

  • return: output writted to $theme
  • todo: should we have an OK button at all???
void mailpage_show_thankyou (object &$theme, array $config, array $dialogdef, string $ip_addr)
  • object &$theme: collects the (html) output
  • array $dialogdef: array that defines the input fields
  • string $ip_addr: the originating IP-address
  • array $config: mailpage configuration data in a (nested) array
mailpage_view (line 48)

display the content of the mailpage linked to node $node_id

  • return: TRUE on success + output via $theme, FALSE otherwise
bool mailpage_view (object &$theme, int $area_id, int $node_id, array $module)
  • object &$theme: collects the (html) output
  • int $area_id: identifies the area where $node_id lives
  • int $node_id: the node to which this module is connected
  • array $module: the module record straight from the database
mailpage_view_dialog_validate (line 307)

validate the data entered by the visitor

Other than the standard validation we check for at least 1 @-sign in the email address. (It is non-trivial to validate an email address, it may not even be possible to do it in a single regular expression. See http://stackoverflow.com/questions/201323 for more information.)

  • return: TRUE if valid, else FALSE + messages added to dialogdef
bool mailpage_view_dialog_validate (object &$dialogdef)
  • object &$dialogdef: defines the dialog and will hold POSTed values
mailpage_view_get_config (line 187)

retrieve all configuration data for this mailpage

this retrieves all configuration data for this mailpage, i.e. both the general parameters (header/intro/etc.) and the full list of configured destination addresses. Here is a quick reminder of the structure in $config.

'node_id'
'header'
'introduction'
'message'
'addresses' = ['mailpage_address_id','node_id','sort_order','name','email','description','thankyou'],...

  • return: configuration data in a (nested) array or FALSE on error
bool|array mailpage_view_get_config (int $node_id)
  • int $node_id: identifies the page
mailpage_view_get_dialogdef (line 220)

construct a dialog definition for the visitor's mail form

this defines the contact form. If there is but one destination we don't even add the listbox because it makes no sense to tell the user to select an option from a listbox with a single item.

  • return: datadefinition
array mailpage_view_get_dialogdef (array $config, string $token_key)
  • array $config: mailpage configuration including addresses
  • string $token_key

Documentation generated on Tue, 28 Jun 2016 19:10:17 +0200 by phpDocumentor 1.4.0