From 4f2b0d9d42869d743a04e6e2b2541383ffeff16c Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 9 Feb 2011 21:05:10 +0100 Subject: [ticket/9549] Add the module and files for the ACP. PHPBB3-9549 --- phpBB/includes/functions_user.php | 67 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) (limited to 'phpBB/includes/functions_user.php') diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 317578cd54..fba96f93e9 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -2495,6 +2495,69 @@ function group_create(&$group_id, $type, $name, $desc, $group_attributes, $allow if (!sizeof($error)) { + + $current_legend = phpbb_group_positions::GROUP_DISABLED; + $current_teampage = phpbb_group_positions::GROUP_DISABLED; + if ($group_id) + { + $current_legend = phpbb_group_positions::get_group_value('legend', $group_id); + $current_teampage = phpbb_group_positions::get_group_value('teampage', $group_id); + } + + if (isset($group_attributes['group_legend'])) + { + if (($group_id && ($current_legend == phpbb_group_positions::GROUP_DISABLED)) || !$group_id) + { + // Old group currently not in the legend or new group, add at the end. + $group_attributes['group_legend'] = 1 + phpbb_group_positions::get_group_count('legend'); + } + else + { + // Group stayes in the legend + $group_attributes['group_legend'] = $current_legend; + } + } + else if ($group_id && ($current_legend > phpbb_group_positions::GROUP_DISABLED)) + { + // Group is removed from the legend + $sql = 'UPDATE ' . GROUPS_TABLE . ' + SET group_teampage = group_teampage - 1 + WHERE group_teampage > ' . $current_legend; + $db->sql_query($sql); + $group_attributes['group_legend'] = phpbb_group_positions::GROUP_DISABLED; + } + else + { + $group_attributes['group_legend'] = phpbb_group_positions::GROUP_DISABLED; + } + + if (isset($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 + phpbb_group_positions::get_group_count('teampage'); + } + 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 + $sql = 'UPDATE ' . GROUPS_TABLE . ' + SET group_teampage = group_teampage - 1 + WHERE group_teampage > ' . $current_teampage; + $db->sql_query($sql); + $group_attributes['group_teampage'] = phpbb_group_positions::GROUP_DISABLED; + } + else + { + $group_attributes['group_teampage'] = phpbb_group_positions::GROUP_DISABLED; + } + $user_ary = array(); $sql_ary = array( 'group_name' => (string) $name, @@ -2719,6 +2782,10 @@ function group_delete($group_id, $group_name = false) } while ($start); + // Delete group from legend and teampage + phpbb_group_positions::delete_group('legend', $group_id); + phpbb_group_positions::delete_group('teampage', $group_id); + // Delete group $sql = 'DELETE FROM ' . GROUPS_TABLE . " WHERE group_id = $group_id"; -- cgit v1.2.1 From 8d12838aedeaa23cccf128e98e93d05507edda4d Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 14 Feb 2011 16:09:09 +0100 Subject: [ticket/9549] Make the class non static and extend delete_group function. delete_group() can now be used, so it does not update the actual group. This can save a query, when you update the group anyway. PHPBB3-9549 --- phpBB/includes/functions_user.php | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) (limited to 'phpBB/includes/functions_user.php') diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index fba96f93e9..ab2481a5dd 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -2495,13 +2495,15 @@ function group_create(&$group_id, $type, $name, $desc, $group_attributes, $allow if (!sizeof($error)) { - $current_legend = phpbb_group_positions::GROUP_DISABLED; $current_teampage = phpbb_group_positions::GROUP_DISABLED; + + $legend = new phpbb_group_positions($db, 'legend'); + $teampage = new phpbb_group_positions($db, 'teampage'); if ($group_id) { - $current_legend = phpbb_group_positions::get_group_value('legend', $group_id); - $current_teampage = phpbb_group_positions::get_group_value('teampage', $group_id); + $current_legend = $legend->get_group_value($group_id); + $current_teampage = $teampage->get_group_value($group_id); } if (isset($group_attributes['group_legend'])) @@ -2509,7 +2511,7 @@ function group_create(&$group_id, $type, $name, $desc, $group_attributes, $allow if (($group_id && ($current_legend == phpbb_group_positions::GROUP_DISABLED)) || !$group_id) { // Old group currently not in the legend or new group, add at the end. - $group_attributes['group_legend'] = 1 + phpbb_group_positions::get_group_count('legend'); + $group_attributes['group_legend'] = 1 + $legend->get_group_count(); } else { @@ -2520,10 +2522,7 @@ function group_create(&$group_id, $type, $name, $desc, $group_attributes, $allow else if ($group_id && ($current_legend > phpbb_group_positions::GROUP_DISABLED)) { // Group is removed from the legend - $sql = 'UPDATE ' . GROUPS_TABLE . ' - SET group_teampage = group_teampage - 1 - WHERE group_teampage > ' . $current_legend; - $db->sql_query($sql); + $legend->delete_group($group_id, true); $group_attributes['group_legend'] = phpbb_group_positions::GROUP_DISABLED; } else @@ -2536,7 +2535,7 @@ function group_create(&$group_id, $type, $name, $desc, $group_attributes, $allow 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 + phpbb_group_positions::get_group_count('teampage'); + $group_attributes['group_teampage'] = 1 + $teampage->get_group_count(); } else { @@ -2547,10 +2546,7 @@ function group_create(&$group_id, $type, $name, $desc, $group_attributes, $allow else if ($group_id && ($current_teampage > phpbb_group_positions::GROUP_DISABLED)) { // Group is removed from the teampage - $sql = 'UPDATE ' . GROUPS_TABLE . ' - SET group_teampage = group_teampage - 1 - WHERE group_teampage > ' . $current_teampage; - $db->sql_query($sql); + $teampage->delete_group($group_id, true); $group_attributes['group_teampage'] = phpbb_group_positions::GROUP_DISABLED; } else @@ -2558,6 +2554,10 @@ function group_create(&$group_id, $type, $name, $desc, $group_attributes, $allow $group_attributes['group_teampage'] = phpbb_group_positions::GROUP_DISABLED; } + // Unset the objects, we don't need them anymore. + unset($legend); + unset($teampage); + $user_ary = array(); $sql_ary = array( 'group_name' => (string) $name, @@ -2783,8 +2783,12 @@ function group_delete($group_id, $group_name = false) while ($start); // Delete group from legend and teampage - phpbb_group_positions::delete_group('legend', $group_id); - phpbb_group_positions::delete_group('teampage', $group_id); + $legend = new phpbb_group_positions($db, 'legend'); + $legend->delete_group($group_id); + unset($legend); + $teampage = new phpbb_group_positions($db, 'teampage'); + $teampage->delete_group($group_id); + unset($teampage); // Delete group $sql = 'DELETE FROM ' . GROUPS_TABLE . " -- cgit v1.2.1 From d9f092a18b149d62afd5ac8a1c6f7d8e7263d17b Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 17 Feb 2011 23:53:05 +0100 Subject: [ticket/9549] Only add group to legend/teampage when the checkbox is checked. The checkbox for the teampage was also missing from the template file. PHPBB3-9549 --- phpBB/includes/functions_user.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/functions_user.php') diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index ab2481a5dd..087a85a583 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -2506,7 +2506,7 @@ function group_create(&$group_id, $type, $name, $desc, $group_attributes, $allow $current_teampage = $teampage->get_group_value($group_id); } - if (isset($group_attributes['group_legend'])) + if (!empty($group_attributes['group_legend'])) { if (($group_id && ($current_legend == phpbb_group_positions::GROUP_DISABLED)) || !$group_id) { @@ -2530,7 +2530,7 @@ function group_create(&$group_id, $type, $name, $desc, $group_attributes, $allow $group_attributes['group_legend'] = phpbb_group_positions::GROUP_DISABLED; } - if (isset($group_attributes['group_teampage'])) + if (!empty($group_attributes['group_teampage'])) { if (($group_id && ($current_teampage == phpbb_group_positions::GROUP_DISABLED)) || !$group_id) { -- cgit v1.2.1