If we change the name of a CommonTreeDropDown object (and only its
name), its completename is not updated.
So, I propose the attached patch to solve this problem.
Regards
Damien
--
--------------------------------------------------------------------
Damien TOURAINE - Ingénieur de Recherche CNRS, LIMSI-CNRS
Groupe de RV&A "VENISE", (http://www.limsi.fr/venise/)
Bat. 508, Universite Paris-Sud 91403 Orsay cedex - +33 1 69 85 81 64
--------------------------------------------------------------------
Index: commontreedropdown.class.php
===================================================================
--- commontreedropdown.class.php (revision 15415)
+++ commontreedropdown.class.php (working copy)
@@ -159,15 +159,20 @@
function prepareInputForUpdate($input) {
- // Can't move a parent under a child
- if (isset($input[$this->getForeignKeyField()])
- && in_array($input[$this->getForeignKeyField()],
- getSonsOf($this->getTable(), $input['id']))) {
- return false;
+ 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"] = NULL;
+ return $this->adaptTreeFieldsFromUpdateOrAdd($input);
+ }
}
- if ($input[$this->getForeignKeyField()] !=
$this->fields[$this->getForeignKeyField()]) {
- // Only the parents changes, so we must update theses, but not the
sons !
- $input["ancestors_cache"] = NULL;
+ // 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;
_______________________________________________
Glpi-dev mailing list
Glpi-dev@gna.org
https://mail.gna.org/listinfo/glpi-dev