change emoji removal to optional

This commit is contained in:
2017-09-09 11:26:46 +10:00
parent a7d24fb16c
commit 784bf46378

View File

@@ -9,7 +9,12 @@ function booking_node_presave($node) {
'!event' => $event->booking_eventname, '!event' => $event->booking_eventname,
'!name' => $node->booking_firstname . ' ' . $node->booking_lastname, '!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; $node->title = $title;
} }
} }
@@ -416,23 +421,32 @@ function booking_update($node) {
//check if the key is a field that belongs in the database //check if the key is a field that belongs in the database
if ((strpos($key, "booking_") === 0) || $key === "nid") { if ((strpos($key, "booking_") === 0) || $key === "nid") {
//what special handling does this field need? //what special handling does this field need?
//handle dates properly //handle dates properly
if ((strpos($key, "booking_dob") === 0) || (strpos($key, "booking_passport_issue_date") === 0)) { if ((strpos($key, "booking_dob") === 0) || (strpos($key, "booking_passport_issue_date") === 0)) {
$data[$key] = _date_to_ts($value); $data[$key] = _date_to_ts($value);
} }
//skip these fields from the update of booking_person
elseif (in_array($key, $excluded_keys, FALSE)) { 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)) { elseif (in_array($key, $boolean_keys, FALSE)) {
$data[$key] = $value == 1 ? 'Y' : 'N'; $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)) { elseif (in_array($key, $default_zero_keys, FALSE)) {
$data[$key] = $value == '' ? 0 : $value; $data[$key] = $value == '' ? 0 : $value;
} }
//just handle this field normally
else { 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))); watchdog('booking', 'Updating node: @info', array('@info' => var_export($data, TRUE)));