diff options
author | Joas Schilling <nickvergessen@gmx.de> | 2013-04-18 00:50:30 +0200 |
---|---|---|
committer | Joas Schilling <nickvergessen@gmx.de> | 2013-04-18 00:50:30 +0200 |
commit | 514bcb2fac1a11a53e20c789ea95be6207c38e80 (patch) | |
tree | eeebdaf32c5459e76556ab5948139adee497916f /phpBB | |
parent | e0393a3062c6bde9314ad061db781d8823cf5b97 (diff) | |
download | forums-514bcb2fac1a11a53e20c789ea95be6207c38e80.tar forums-514bcb2fac1a11a53e20c789ea95be6207c38e80.tar.gz forums-514bcb2fac1a11a53e20c789ea95be6207c38e80.tar.bz2 forums-514bcb2fac1a11a53e20c789ea95be6207c38e80.tar.xz forums-514bcb2fac1a11a53e20c789ea95be6207c38e80.zip |
[ticket/11495] Move nestedset default values to new method
PHPBB3-11495
Diffstat (limited to 'phpBB')
-rw-r--r-- | phpBB/includes/nestedset/base.php | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/phpBB/includes/nestedset/base.php b/phpBB/includes/nestedset/base.php index 630512d713..5673a913fc 100644 --- a/phpBB/includes/nestedset/base.php +++ b/phpBB/includes/nestedset/base.php @@ -67,14 +67,7 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface */ public function insert(array $additional_data) { - $item_data = array_merge($additional_data, array( - $this->column_parent_id => 0, - $this->column_left_id => 0, - $this->column_right_id => 0, - $this->column_item_parents => '', - )); - - unset($item_data[$this->column_item_id]); + $item_data = $this->reset_nestedset_values($additional_data); $sql = 'INSERT INTO ' . $this->table_name . ' ' . $this->db->sql_build_array('INSERT', $item_data); $this->db->sql_query($sql); @@ -565,6 +558,26 @@ abstract class phpbb_nestedset_base implements phpbb_nestedset_interface } /** + * Resets values required for the nested set system + * + * @param array $item Original item data + * @return array Original item data + nested set defaults + */ + protected function reset_nestedset_values(array $item) + { + $item_data = array_merge($item, array( + $this->column_parent_id => 0, + $this->column_left_id => 0, + $this->column_right_id => 0, + $this->column_item_parents => '', + )); + + unset($item_data[$this->column_item_id]); + + return $item_data; + } + + /** * @inheritdoc */ public function recalculate_nested_set($new_id, $parent_id = 0, $reset_ids = false) |