From 1373336e944c89318b14f6976a40b73930de8171 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 20 Aug 2010 15:56:33 +0000 Subject: [PATCH] Fix: possibility to defined rang with an external module --- htdocs/core/class/commonobject.class.php | 38 +++++++++++++----------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 84eda354c38..918c95f8811 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -732,15 +732,8 @@ class CommonObject { $this->line_order(); - /* Lecture du rang de la ligne */ - $sql = 'SELECT rang FROM '.MAIN_DB_PREFIX.$this->table_element_line; - $sql.= ' WHERE rowid ='.$rowid; - $resql = $this->db->query($sql); - if ($resql) - { - $row = $this->db->fetch_row($resql); - $rang = $row[0]; - } + // Get rang of line + $rang = $this->getRangOfLine($rowid); if ($rang > 1 ) { @@ -767,15 +760,8 @@ class CommonObject { $this->line_order(); - /* Lecture du rang de la ligne */ - $sql = 'SELECT rang FROM '.MAIN_DB_PREFIX.$this->table_element_line; - $sql.= ' WHERE rowid ='.$rowid; - $resql = $this->db->query($sql); - if ($resql) - { - $row = $this->db->fetch_row($resql); - $rang = $row[0]; - } + // Get rang of line + $rang = $this->getRangOfLine($rowid); // Get max value for rang $max = $this->line_max(); @@ -800,6 +786,22 @@ class CommonObject } } } + + /** + * Get position of line (rang) + * @result int Value of rang in table of lines + */ + function getRangOfLine($rowid) + { + $sql = 'SELECT rang FROM '.MAIN_DB_PREFIX.$this->table_element_line; + $sql.= ' WHERE rowid ='.$rowid; + $resql = $this->db->query($sql); + if ($resql) + { + $row = $this->db->fetch_row($resql); + return $row[0]; + } + } /** * Get max value used for position of line (rang)