[*] Classes: calcul position in class when an attribute, an image or a scene is added

This commit is contained in:
rMalie
2011-10-25 15:17:26 +00:00
parent 3c85847608
commit d2f1d99edb
4 changed files with 36 additions and 21 deletions
+4 -1
View File
@@ -124,6 +124,9 @@ class AttributeCore extends ObjectModel
public function add($autodate = true, $null_values = false)
{
if ($this->position <= 0)
$this->position = Attribute::getHigherPosition($this->id_attribute_group) + 1;
$return = parent::add($autodate, $null_values);
if ($return)
Module::hookExec('afterSaveAttribute', array('id_attribute' => $this->id));
@@ -339,7 +342,7 @@ class AttributeCore extends ObjectModel
FROM `'._DB_PREFIX_.'attribute`
WHERE id_attribute_group = '.(int)$id_attribute_group;
$position = DB::getInstance()->getValue($sql);
return ($position !== false) ? $position : -1;
return (is_numeric($position)) ? $position : -1;
}
}