Refactor booking hooks

This commit is contained in:
2015-03-18 11:05:53 +11:00
parent 27c6d7b1c9
commit 034785d70c
2 changed files with 17 additions and 36 deletions

View File

@@ -31,7 +31,7 @@ module_load_include('inc', 'booking', 'booking.tokens');
// Load the include that contains the user registration form
module_load_include('inc', 'booking', 'booking.regn_form');
// Load the include that processes booking nodes
module_load_include('inc', 'booking', 'booking.node');
module_load_include('inc', 'booking', 'booking.regn_node');
// Load the include that contains the registration confirmation page
module_load_include('inc', 'booking', 'booking.confirm');
// Load the include that contains the registration balance payment page
@@ -791,37 +791,6 @@ function booking_mail($key, &$message, $params) {
}
/**
* Registration node modification hooks for booking nodes.
*/
function booking_insert($node) {
//moved to booking.register.inc
watchdog('booking', 'Inserting person: @info', array('@info' => var_export($node, TRUE)));
_booking_insert($node);
}
function booking_update($node) {
//moved to booking.register.inc
_booking_update($node);
}
function booking_delete($node) {
//moved to booking.register.inc
_booking_delete($node);
}
//Update node table specific attributes before hook_update is called
function booking_node_presave($node) {
global $event;
if($node->type == 'booking')
{
$node->title = t('!event registration: !name',
array('!event' => $event->booking_eventname, '!name' => $node->booking_firstname . ' ' . $node->booking_lastname));
//watchdog('booking', 'Presave of person: @info', array('@info' => var_export($node, TRUE)));
}
}
/**
* Function for generating the "lucky number" to be used on the lanyard

View File

@@ -1,5 +1,17 @@
<?php
//Update node table specific attributes before hook_update is called
function booking_node_presave($node) {
global $event;
if($node->type == 'booking')
{
$node->title = t('!event registration: !name',
array('!event' => $event->booking_eventname, '!name' => $node->booking_firstname . ' ' . $node->booking_lastname));
//watchdog('booking', 'Presave of person: @info', array('@info' => var_export($node, TRUE)));
}
}
/**
* Function to query the database for the complete object representing a registration
*
@@ -106,8 +118,8 @@ function booking_load($nodes) {
// no return necessary since $nodes array members reference objects global to this function
}
function _booking_insert($node) {
//watchdog('booking', 'Inserting node: @info', array('@info' => var_export($node, TRUE)));
function booking_insert($node) {
watchdog('booking', 'Inserting node: @info', array('@info' => var_export($node, TRUE)));
//TODO: Generalise this by using the keys from $node instead of hard coding everything
@@ -208,7 +220,7 @@ function _booking_insert($node) {
* @param $node from form submission
* @return nothing
*/
function _booking_update($node) {
function booking_update($node) {
global $event;
//before we update this user, check what their previous registration status was
@@ -528,7 +540,7 @@ function _booking_update($node) {
//end trigger processing
}
function _booking_delete($node) {
function booking_delete($node) {
$last = $node->booking_lastname;
$first = $node->booking_firstname;