From 784bf463783b117a7f380e1dbbfdab6069cab1f5 Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Sat, 9 Sep 2017 11:26:46 +1000 Subject: [PATCH] change emoji removal to optional --- booking.regn_node.inc | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/booking.regn_node.inc b/booking.regn_node.inc index 497a1ba..7c7d962 100644 --- a/booking.regn_node.inc +++ b/booking.regn_node.inc @@ -9,7 +9,12 @@ function booking_node_presave($node) { '!event' => $event->booking_eventname, '!name' => $node->booking_firstname . ' ' . $node->booking_lastname, )); - $title = _booking_remove_emoji($title); + + //strip any emojis from user input if that feature is enabled + if (variable_get('booking_enable_emoji_removal', 1) == 1) { + $title = _booking_remove_emoji($title); + } + $node->title = $title; } } @@ -416,23 +421,32 @@ function booking_update($node) { //check if the key is a field that belongs in the database if ((strpos($key, "booking_") === 0) || $key === "nid") { //what special handling does this field need? + //handle dates properly if ((strpos($key, "booking_dob") === 0) || (strpos($key, "booking_passport_issue_date") === 0)) { $data[$key] = _date_to_ts($value); } + //skip these fields from the update of booking_person elseif (in_array($key, $excluded_keys, FALSE)) { - //skip these fields from the update of booking_person + //do nothing } + //this field needs 0/1 translated to N/Y elseif (in_array($key, $boolean_keys, FALSE)) { $data[$key] = $value == 1 ? 'Y' : 'N'; } + //this field has a default value of zero rather than null elseif (in_array($key, $default_zero_keys, FALSE)) { $data[$key] = $value == '' ? 0 : $value; } + //just handle this field normally else { - $data[$key] = _booking_remove_emoji($value); + if (variable_get('booking_enable_emoji_removal', 1) == 1) { + $data[$key] = _booking_remove_emoji($value); + } + else { + $data[$key] = $value; + } } - } } watchdog('booking', 'Updating node: @info', array('@info' => var_export($data, TRUE)));