mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 14:18:52 +00:00
[ticket/10411] Fix create_group and delete_group functions
PHPBB3-10411
This commit is contained in:
parent
6a27a95f30
commit
6e286218ec
2 changed files with 34 additions and 39 deletions
|
@ -61,9 +61,11 @@ class acp_groups
|
|||
// Grab basic data for group, if group_id is set and exists
|
||||
if ($group_id)
|
||||
{
|
||||
$sql = 'SELECT *
|
||||
FROM ' . GROUPS_TABLE . "
|
||||
WHERE group_id = $group_id";
|
||||
$sql = 'SELECT g.*, t.teampage_position AS group_teampage
|
||||
FROM ' . GROUPS_TABLE . ' g
|
||||
LEFT JOIN ' . TEAMPAGE_TABLE . ' t
|
||||
ON (t.group_id = g.group_id)
|
||||
WHERE g.group_id = ' . $group_id;
|
||||
$result = $db->sql_query($sql);
|
||||
$group_row = $db->sql_fetchrow($result);
|
||||
$db->sql_freeresult($result);
|
||||
|
@ -497,6 +499,7 @@ class acp_groups
|
|||
}
|
||||
|
||||
$cache->destroy('sql', GROUPS_TABLE);
|
||||
$cache->destroy('sql', TEAMPAGE_TABLE);
|
||||
|
||||
$message = ($action == 'edit') ? 'GROUP_UPDATED' : 'GROUP_CREATED';
|
||||
trigger_error($user->lang[$message] . adm_back_link($this->u_action));
|
||||
|
|
|
@ -2594,13 +2594,16 @@ function group_create(&$group_id, $type, $name, $desc, $group_attributes, $allow
|
|||
$error[] = $user->lang['GROUP_ERR_TYPE'];
|
||||
}
|
||||
|
||||
$group_teampage = !empty($group_attributes['group_teampage']);
|
||||
unset($group_attributes['group_teampage']);
|
||||
|
||||
if (!sizeof($error))
|
||||
{
|
||||
$current_legend = phpbb_group_positions::GROUP_DISABLED;
|
||||
$current_teampage = phpbb_group_positions::GROUP_DISABLED;
|
||||
$current_legend = phpbb_groupposition_legend::GROUP_DISABLED;
|
||||
$current_teampage = phpbb_groupposition_teampage::GROUP_DISABLED;
|
||||
|
||||
$legend = new phpbb_group_positions($db, 'legend');
|
||||
$teampage = new phpbb_group_positions($db, 'teampage');
|
||||
$legend = new phpbb_groupposition_legend($db, $user, '');
|
||||
$teampage = new phpbb_groupposition_teampage($db, $user, '');
|
||||
if ($group_id)
|
||||
{
|
||||
$current_legend = $legend->get_group_value($group_id);
|
||||
|
@ -2609,7 +2612,7 @@ function group_create(&$group_id, $type, $name, $desc, $group_attributes, $allow
|
|||
|
||||
if (!empty($group_attributes['group_legend']))
|
||||
{
|
||||
if (($group_id && ($current_legend == phpbb_group_positions::GROUP_DISABLED)) || !$group_id)
|
||||
if (($group_id && ($current_legend == phpbb_groupposition_legend::GROUP_DISABLED)) || !$group_id)
|
||||
{
|
||||
// Old group currently not in the legend or new group, add at the end.
|
||||
$group_attributes['group_legend'] = 1 + $legend->get_group_count();
|
||||
|
@ -2620,44 +2623,19 @@ function group_create(&$group_id, $type, $name, $desc, $group_attributes, $allow
|
|||
$group_attributes['group_legend'] = $current_legend;
|
||||
}
|
||||
}
|
||||
else if ($group_id && ($current_legend > phpbb_group_positions::GROUP_DISABLED))
|
||||
else if ($group_id && ($current_legend > phpbb_groupposition_legend::GROUP_DISABLED))
|
||||
{
|
||||
// Group is removed from the legend
|
||||
$legend->delete_group($group_id, true);
|
||||
$group_attributes['group_legend'] = phpbb_group_positions::GROUP_DISABLED;
|
||||
$group_attributes['group_legend'] = phpbb_groupposition_legend::GROUP_DISABLED;
|
||||
}
|
||||
else
|
||||
{
|
||||
$group_attributes['group_legend'] = phpbb_group_positions::GROUP_DISABLED;
|
||||
}
|
||||
|
||||
if (!empty($group_attributes['group_teampage']))
|
||||
{
|
||||
if (($group_id && ($current_teampage == phpbb_group_positions::GROUP_DISABLED)) || !$group_id)
|
||||
{
|
||||
// Old group currently not on the teampage or new group, add at the end.
|
||||
$group_attributes['group_teampage'] = 1 + $teampage->get_group_count();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Group stayes on the teampage
|
||||
$group_attributes['group_teampage'] = $current_teampage;
|
||||
}
|
||||
}
|
||||
else if ($group_id && ($current_teampage > phpbb_group_positions::GROUP_DISABLED))
|
||||
{
|
||||
// Group is removed from the teampage
|
||||
$teampage->delete_group($group_id, true);
|
||||
$group_attributes['group_teampage'] = phpbb_group_positions::GROUP_DISABLED;
|
||||
}
|
||||
else
|
||||
{
|
||||
$group_attributes['group_teampage'] = phpbb_group_positions::GROUP_DISABLED;
|
||||
$group_attributes['group_legend'] = phpbb_groupposition_legend::GROUP_DISABLED;
|
||||
}
|
||||
|
||||
// Unset the objects, we don't need them anymore.
|
||||
unset($legend);
|
||||
unset($teampage);
|
||||
|
||||
$user_ary = array();
|
||||
$sql_ary = array(
|
||||
|
@ -2761,6 +2739,19 @@ function group_create(&$group_id, $type, $name, $desc, $group_attributes, $allow
|
|||
}
|
||||
}
|
||||
|
||||
if ($group_teampage)
|
||||
{
|
||||
if ($current_teampage == phpbb_groupposition_teampage::GROUP_DISABLED)
|
||||
{
|
||||
$teampage->add_group($group_id);
|
||||
}
|
||||
}
|
||||
else if ($group_id && ($current_teampage > phpbb_groupposition_teampage::GROUP_DISABLED))
|
||||
{
|
||||
$teampage->delete_group($group_id);
|
||||
}
|
||||
unset($teampage);
|
||||
|
||||
// Set user attributes
|
||||
$sql_ary = array();
|
||||
if (sizeof($group_attributes))
|
||||
|
@ -2842,7 +2833,7 @@ function avatar_remove_db($avatar_name)
|
|||
*/
|
||||
function group_delete($group_id, $group_name = false)
|
||||
{
|
||||
global $db, $phpbb_root_path, $phpEx, $phpbb_dispatcher;
|
||||
global $db, $user, $phpbb_root_path, $phpEx, $phpbb_dispatcher;
|
||||
|
||||
if (!$group_name)
|
||||
{
|
||||
|
@ -2884,10 +2875,11 @@ function group_delete($group_id, $group_name = false)
|
|||
while ($start);
|
||||
|
||||
// Delete group from legend and teampage
|
||||
$legend = new phpbb_group_positions($db, 'legend');
|
||||
$legend = new phpbb_groupposition_legend($db, $user, '');
|
||||
$legend->delete_group($group_id);
|
||||
unset($legend);
|
||||
$teampage = new phpbb_group_positions($db, 'teampage');
|
||||
|
||||
$teampage = new phpbb_groupposition_teampage($db, $user, '');
|
||||
$teampage->delete_group($group_id);
|
||||
unset($teampage);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue