private function prepare(ProfilePage $page, array &$new_value) { $initial_value = XDB::fetchOneAssoc('SELECT lastname_main, firstname_main FROM profile_public_names WHERE pid = {?}', $page->pid()); $success = true; foreach ($initial_value as $field => $name) { $initial = name_to_basename($name); $new = name_to_basename($new_value[$field]); if (!($this->matchWord($initial, $new, strlen($new)) || $field == 'lastname_main' && $new == 'DE ' . $initial)) { $new_value[$field . '_error'] = true; $success = false; Platal::page()->trigError('Le nom choisi (' . $new . ') est trop loin de sa valeur initiale (' . $initial . ').'); } } return $success; }
/** Compares two strings and check if they are two forms of the * same name (different case, with accents or with - instead of * blanks). * @see name_to_basename to retreive the compared string */ function compare_basename($a, $b) { return name_to_basename($a) == name_to_basename($b); }