mirror of
https://github.com/phpbb/phpbb.git
synced 2025-05-10 09:35:24 +02:00
[ticket/10411] Fix comment in interface and some problems in teampage
Category names on the teampage can not be empty. Also fixing a problem with the delta when moving a category. PHPBB3-10411
This commit is contained in:
parent
8ee908d32e
commit
53cb148d70
@ -47,10 +47,10 @@ interface phpbb_groupposition_interface
|
|||||||
public function add_group($group_id);
|
public function add_group($group_id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes a group by setting the field to self::GROUP_DISABLED and closing the gap in the list.
|
* Deletes a group by group_id
|
||||||
*
|
*
|
||||||
* @param int $group_id group_id of the group to be deleted
|
* @param int $group_id group_id of the group to be deleted
|
||||||
* @param bool $skip_group Skip setting the group to GROUP_DISABLED, to save the query, when you need to update it anyway.
|
* @param bool $skip_group Skip setting the value for this group, to save the query, when you need to update it anyway.
|
||||||
* @return null
|
* @return null
|
||||||
*/
|
*/
|
||||||
public function delete_group($group_id, $skip_group = false);
|
public function delete_group($group_id, $skip_group = false);
|
||||||
|
@ -203,6 +203,17 @@ class phpbb_groupposition_teampage implements phpbb_groupposition_interface
|
|||||||
if ($current_value == self::GROUP_DISABLED)
|
if ($current_value == self::GROUP_DISABLED)
|
||||||
{
|
{
|
||||||
if ($parent_id != self::NO_PARENT)
|
if ($parent_id != self::NO_PARENT)
|
||||||
|
{
|
||||||
|
// Check, whether the given parent is a category
|
||||||
|
$sql = 'SELECT teampage_id
|
||||||
|
FROM ' . TEAMPAGE_TABLE . '
|
||||||
|
WHERE group_id = 0
|
||||||
|
AND teampage_id = ' . (int) $parent_id;
|
||||||
|
$result = $this->db->sql_query_limit($sql, 1);
|
||||||
|
$parent_is_category = (bool) $this->db->sql_fetchfield('teampage_id');
|
||||||
|
$this->db->sql_freeresult($result);
|
||||||
|
|
||||||
|
if ($parent_is_category)
|
||||||
{
|
{
|
||||||
// Get value of last child from this parent and add group there
|
// Get value of last child from this parent and add group there
|
||||||
$sql = 'SELECT teampage_position
|
$sql = 'SELECT teampage_position
|
||||||
@ -218,7 +229,7 @@ class phpbb_groupposition_teampage implements phpbb_groupposition_interface
|
|||||||
SET teampage_position = teampage_position + 1
|
SET teampage_position = teampage_position + 1
|
||||||
WHERE teampage_position > ' . $new_position;
|
WHERE teampage_position > ' . $new_position;
|
||||||
$this->db->sql_query($sql);
|
$this->db->sql_query($sql);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -245,13 +256,18 @@ class phpbb_groupposition_teampage implements phpbb_groupposition_interface
|
|||||||
*/
|
*/
|
||||||
public function add_category_teampage($category_name)
|
public function add_category_teampage($category_name)
|
||||||
{
|
{
|
||||||
|
if ($category_name === '')
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$num_entries = $this->get_group_count();
|
$num_entries = $this->get_group_count();
|
||||||
|
|
||||||
$sql_ary = array(
|
$sql_ary = array(
|
||||||
'group_id' => 0,
|
'group_id' => 0,
|
||||||
'teampage_position' => $num_entries + 1,
|
'teampage_position' => $num_entries + 1,
|
||||||
'teampage_parent' => 0,
|
'teampage_parent' => 0,
|
||||||
'teampage_name' => $category_name,
|
'teampage_name' => truncate_string($category_name, 255, 255),
|
||||||
);
|
);
|
||||||
|
|
||||||
$sql = 'INSERT INTO ' . TEAMPAGE_TABLE . ' ' . $this->db->sql_build_array('INSERT', $sql_ary);
|
$sql = 'INSERT INTO ' . TEAMPAGE_TABLE . ' ' . $this->db->sql_build_array('INSERT', $sql_ary);
|
||||||
@ -384,12 +400,17 @@ class phpbb_groupposition_teampage implements phpbb_groupposition_interface
|
|||||||
ORDER BY teampage_position' . (($move_up) ? ' DESC' : ' ASC');
|
ORDER BY teampage_position' . (($move_up) ? ' DESC' : ' ASC');
|
||||||
$result = $this->db->sql_query_limit($sql, $delta);
|
$result = $this->db->sql_query_limit($sql, $delta);
|
||||||
|
|
||||||
|
$sibling_count = 0;
|
||||||
|
$sibling_limit = $delta;
|
||||||
|
|
||||||
// Reset the delta, as we recalculate the new real delta
|
// Reset the delta, as we recalculate the new real delta
|
||||||
$delta = 0;
|
$delta = 0;
|
||||||
while ($row = $this->db->sql_fetchrow($result))
|
while ($row = $this->db->sql_fetchrow($result))
|
||||||
{
|
{
|
||||||
|
$sibling_count++;
|
||||||
$delta = $current_value - $row['teampage_position'];
|
$delta = $current_value - $row['teampage_position'];
|
||||||
if (!$move_up && $data['teampage_parent'] == self::NO_PARENT)
|
|
||||||
|
if (!$move_up && $data['teampage_parent'] == self::NO_PARENT && $sibling_count == $sibling_limit)
|
||||||
{
|
{
|
||||||
// Remove the additional sibling we added previously
|
// Remove the additional sibling we added previously
|
||||||
$delta++;
|
$delta++;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user