diff options
author | Joas Schilling <nickvergessen@gmx.de> | 2013-02-25 20:58:12 +0100 |
---|---|---|
committer | Joas Schilling <nickvergessen@gmx.de> | 2013-02-25 20:58:12 +0100 |
commit | 1d7b082a6fa05d5760ef15ef8bf78cd3a1d204cf (patch) | |
tree | f8885b5742649b1eb6204bbce200608b04283b7d /phpBB | |
parent | b0dc5925b91cb0447046e8a7f089c6675e4be95c (diff) | |
download | forums-1d7b082a6fa05d5760ef15ef8bf78cd3a1d204cf.tar forums-1d7b082a6fa05d5760ef15ef8bf78cd3a1d204cf.tar.gz forums-1d7b082a6fa05d5760ef15ef8bf78cd3a1d204cf.tar.bz2 forums-1d7b082a6fa05d5760ef15ef8bf78cd3a1d204cf.tar.xz forums-1d7b082a6fa05d5760ef15ef8bf78cd3a1d204cf.zip |
[ticket/10411] Add return value to move functions
PHPBB3-10411
Diffstat (limited to 'phpBB')
-rw-r--r-- | phpBB/includes/groupposition/interface.php | 6 | ||||
-rw-r--r-- | phpBB/includes/groupposition/legend.php | 15 | ||||
-rw-r--r-- | phpBB/includes/groupposition/teampage.php | 36 |
3 files changed, 39 insertions, 18 deletions
diff --git a/phpBB/includes/groupposition/interface.php b/phpBB/includes/groupposition/interface.php index 749ad61071..6fb16134e0 100644 --- a/phpBB/includes/groupposition/interface.php +++ b/phpBB/includes/groupposition/interface.php @@ -59,7 +59,7 @@ interface phpbb_groupposition_interface * Moves a group up by group_id * * @param int $group_id group_id of the group to be moved - * @return null + * @return bool True if the group was moved successfully */ public function move_up($group_id); @@ -67,7 +67,7 @@ interface phpbb_groupposition_interface * Moves a group down by group_id * * @param int $group_id group_id of the group to be moved - * @return null + * @return bool True if the group was moved successfully */ public function move_down($group_id); @@ -78,7 +78,7 @@ interface phpbb_groupposition_interface * @param int $delta number of steps: * - positive = move up * - negative = move down - * @return null + * @return bool True if the group was moved successfully */ public function move($group_id, $delta); } diff --git a/phpBB/includes/groupposition/legend.php b/phpBB/includes/groupposition/legend.php index 51f2510e85..9b69f9d2b3 100644 --- a/phpBB/includes/groupposition/legend.php +++ b/phpBB/includes/groupposition/legend.php @@ -168,7 +168,7 @@ class phpbb_groupposition_legend implements phpbb_groupposition_interface */ public function move_up($group_id) { - $this->move($group_id, 1); + return $this->move($group_id, 1); } /** @@ -178,7 +178,7 @@ class phpbb_groupposition_legend implements phpbb_groupposition_interface */ public function move_down($group_id) { - $this->move($group_id, -1); + return $this->move($group_id, -1); } /** @@ -188,9 +188,10 @@ class phpbb_groupposition_legend implements phpbb_groupposition_interface */ public function move($group_id, $delta) { - if (!is_int($delta) || !$delta) + $delta = (int) $delta; + if (!$delta) { - return; + return false; } $move_up = ($delta > 0) ? true : false; @@ -221,10 +222,16 @@ class phpbb_groupposition_legend implements phpbb_groupposition_interface SET group_legend = group_legend ' . (($move_up) ? ' - ' : ' + ') . $delta . ' WHERE group_id = ' . (int) $group_id; $this->db->sql_query($sql); + + $this->db->sql_transaction('commit'); + + return true; } $this->db->sql_transaction('commit'); } + + return false; } /** diff --git a/phpBB/includes/groupposition/teampage.php b/phpBB/includes/groupposition/teampage.php index f13e171134..cbdf06ebaf 100644 --- a/phpBB/includes/groupposition/teampage.php +++ b/phpBB/includes/groupposition/teampage.php @@ -359,18 +359,18 @@ class phpbb_groupposition_teampage implements phpbb_groupposition_interface */ public function move_up($group_id) { - $this->move($group_id, 1); + return $this->move($group_id, 1); } /** * Moves an item up by teampage_id * * @param int $group_id group_id of the group to be moved - * @return null + * @return bool True if the group was moved successfully */ public function move_up_teampage($teampage_id) { - $this->move_teampage($teampage_id, 1); + return $this->move_teampage($teampage_id, 1); } /** @@ -380,18 +380,18 @@ class phpbb_groupposition_teampage implements phpbb_groupposition_interface */ public function move_down($group_id) { - $this->move($group_id, -1); + return $this->move($group_id, -1); } /** * Movesan item down by teampage_id * * @param int $group_id group_id of the group to be moved - * @return null + * @return bool True if the group was moved successfully */ public function move_down_teampage($teampage_id) { - $this->move_teampage($teampage_id, -1); + return $this->move_teampage($teampage_id, -1); } /** @@ -401,9 +401,10 @@ class phpbb_groupposition_teampage implements phpbb_groupposition_interface */ public function move($group_id, $delta) { - if (!is_int($delta) || !$delta) + $delta = (int) $delta; + if (!$delta) { - return; + return false; } $move_up = ($delta > 0) ? true : false; @@ -463,12 +464,18 @@ class phpbb_groupposition_teampage implements phpbb_groupposition_interface SET teampage_position = teampage_position ' . (($move_up) ? ' - ' : ' + ') . abs($delta) . ' WHERE group_id = ' . (int) $group_id; $this->db->sql_query($sql); + + $this->db->sql_transaction('commit'); + $this->cache->destroy('sql', TEAMPAGE_TABLE); + + return true; } $this->db->sql_transaction('commit'); } $this->cache->destroy('sql', TEAMPAGE_TABLE); + return false; } /** @@ -478,13 +485,14 @@ class phpbb_groupposition_teampage implements phpbb_groupposition_interface * @param int $delta number of steps: * - positive = move up * - negative = move down - * @return null + * @return bool True if the group was moved successfully */ public function move_teampage($teampage_id, $delta) { - if (!is_int($delta) || !$delta) + $delta = (int) $delta; + if (!$delta) { - return; + return false; } $move_up = ($delta > 0) ? true : false; @@ -559,12 +567,18 @@ class phpbb_groupposition_teampage implements phpbb_groupposition_interface WHERE teampage_id = ' . (int) $teampage_id . ' OR teampage_parent = ' . (int) $teampage_id; $this->db->sql_query($sql); + + $this->db->sql_transaction('commit'); + $this->cache->destroy('sql', TEAMPAGE_TABLE); + + return true; } $this->db->sql_transaction('commit'); } $this->cache->destroy('sql', TEAMPAGE_TABLE); + return false; } /** |