From c27f2c10057aa332fbd7d19d5c6b7f277576eaf1 Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Fri, 8 Sep 2017 23:37:00 +1000 Subject: [PATCH] add some field exclusions to update hook --- booking.regn_node.inc | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/booking.regn_node.inc b/booking.regn_node.inc index ce8d9ba..88cac81 100644 --- a/booking.regn_node.inc +++ b/booking.regn_node.inc @@ -384,13 +384,23 @@ function booking_update($node) { global $event; $data = array(); + //these fields should be stored in the database as Y or N, but come back from the FAPI as 1 or 0 $boolean_keys = array('booking_baptised', 'booking_married', 'booking_help_praying', 'booking_help_meditations', 'booking_help_reading', 'booking_help_chairing', 'booking_help_readgroup_lead', 'booking_help_discussgroup_lead', 'booking_lifesaver', 'booking_firstaid', 'booking_nurse', 'booking_doctor', 'booking_has_mission_experience', 'booking_skills_builder', 'booking_skills_cooking', 'booking_skills_childminding', 'booking_skills_language', 'booking_skills_other', 'booking_welfare_required', 'booking_payment_complete', 'booking_refund_processed', 'booking_committee_member' ); + //these fields should be zero if not defined $default_zero_keys = array('booking_luckynum', 'booking_bf_gf_nid', 'booking_keepseparate_id', 'booking_refund_due'); + + //some fields are present in $node from the SQL view we use that don't belong in booking_person so exclude them + $excluded_keys = array('booking_person_nid', 'booking_transport_type', 'booking_transport_from_morriset_reqd', 'booking_transport_to_morriset_reqd', + 'booking_flightnum_inbound', 'booking_flight_datetime_inbound', 'booking_flightnum_outbound', 'booking_flight_datetime_outbound', 'booking_accom_before_reqd', + 'booking_accom_before_staying_with', 'booking_accom_after_reqd', 'booking_accom_after_staying_with', 'booking_roomlocation_descrip', + 'booking_roomlocation_active', 'booking_price', 'booking_price_descrip', 'booking_late_price', 'booking_earlyaccess_code', + 'booking_room_bedtype', 'booking_room_location_id', 'booking_room_number', 'booking_agreement' + ); //before we update this user, check what their previous registration status was $previous_status = db_query("SELECT booking_status, booking_payment_id, booking_total_pay_reqd, booking_amount_paid FROM {booking_person} where nid = :nid", array( @@ -408,6 +418,9 @@ function booking_update($node) { elseif (in_array($key, $default_zero_keys, FALSE)) { $data[$key] = $value == '' ? 0 : $value; } + elseif (in_array($key, $excluded_keys, FALSE)) { + //skip these fields from the update of booking_person + } else { $data[$key] = _booking_remove_emoji($value); } @@ -415,7 +428,7 @@ function booking_update($node) { } } watchdog('booking', 'Updating node: @info', array('@info' => var_export($data, TRUE))); - //db_update('booking_person')->fields($data)->condition('nid', $node->nid)->execute(); + db_update('booking_person')->fields($data)->condition('nid', $node->nid)->execute(); /* //watchdog('booking', 'Updating node: @info', array('@info' => var_export($node, TRUE))); db_update('booking_person')