Skip to content

Commit

Permalink
fix(web): enable the deletion of text parameters on contacts (centreo…
Browse files Browse the repository at this point in the history
…n#11330)

* fix(web): enable the deletion of text parameters on contacts

* Do not exceed 120 characters by line

* Update www/include/configuration/configObject/contact/DB-Func.php

Co-authored-by: TamazC <[email protected]>

Co-authored-by: TamazC <[email protected]>
  • Loading branch information
s-duret and TamazC authored Sep 7, 2022
1 parent cbaffd5 commit f6b3e9b
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions www/include/configuration/configObject/contact/DB-Func.php
Original file line number Diff line number Diff line change
Expand Up @@ -694,8 +694,16 @@ function updateContact_MC($contact_id = null)
return;
}

$ret = array();
$ret = $form->getSubmitValues();

// Remove all parameters that have an empty value in order to keep
// the contact properties that have not been modified
foreach ($ret as $name => $value) {
if (is_string($value) && empty($value)) {
unset($ret[$name]);
}
}

$bindParams = sanitizeFormContactParameters($ret);
$rq = "UPDATE contact SET ";
foreach (array_keys($bindParams) as $token) {
Expand Down Expand Up @@ -1280,15 +1288,13 @@ function sanitizeFormContactParameters(array $ret): array
case 'contact_address5':
case 'contact_address6':
if (
$inputValue = filter_var(
($inputValue = filter_var(
$inputValue ?? "",
FILTER_SANITIZE_STRING,
FILTER_FLAG_NO_ENCODE_QUOTES
)
)) !== false
) {
if (!empty($inputValue)) {
$bindParams[':' . $inputName] = [\PDO::PARAM_STR => $inputValue];
}
$bindParams[':' . $inputName] = [\PDO::PARAM_STR => $inputValue];
}
break;
}
Expand Down

0 comments on commit f6b3e9b

Please sign in to comment.