function prepareInputForUpdate($input)
{
if (isset($input[$this->getForeignKeyField()])) {
// Can't move a parent under a child
if (in_array($input[$this->getForeignKeyField()], getSonsOf($this->getTable(), $input['id']))) {
return false;
}
// Parent changes => clear ancestors and update its level and completename
if ($input[$this->getForeignKeyField()] != $this->fields[$this->getForeignKeyField()]) {
$input["ancestors_cache"] = '';
return $this->adaptTreeFieldsFromUpdateOrAdd($input);
}
}
// Name changes => update its completename (and its level : side effect ...)
if (isset($input['name']) && $input['name'] != $this->fields['name']) {
return $this->adaptTreeFieldsFromUpdateOrAdd($input);
}
return $input;
}