[ticket/11587] Pass legend and teampage settings to group_create()

Without passing those values, the group is removed from the teampage and
the legend while submitting the edit form on the ucp groups manage page.

PHPBB3-11587
This commit is contained in:
Marc Alexander 2013-06-04 14:25:37 +02:00
parent 74da9e32e5
commit 27bcf25c3b

View file

@ -416,9 +416,11 @@ class ucp_groups
if ($group_id) if ($group_id)
{ {
$sql = 'SELECT * $sql = 'SELECT g.*, t.teampage_position AS group_teampage
FROM ' . GROUPS_TABLE . " FROM ' . GROUPS_TABLE . ' g
WHERE group_id = $group_id"; LEFT JOIN ' . TEAMPAGE_TABLE . ' t
ON (t.group_id = g.group_id)
WHERE g.group_id = ' . $group_id;
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
$group_row = $db->sql_fetchrow($result); $group_row = $db->sql_fetchrow($result);
$db->sql_freeresult($result); $db->sql_freeresult($result);
@ -514,6 +516,8 @@ class ucp_groups
'receive_pm' => isset($_REQUEST['group_receive_pm']) ? 1 : 0, 'receive_pm' => isset($_REQUEST['group_receive_pm']) ? 1 : 0,
'message_limit' => request_var('group_message_limit', 0), 'message_limit' => request_var('group_message_limit', 0),
'max_recipients'=> request_var('group_max_recipients', 0), 'max_recipients'=> request_var('group_max_recipients', 0),
'legend' => $group_row['group_legend'],
'teampage' => $group_row['group_teampage'],
); );
if ($config['allow_avatar']) if ($config['allow_avatar'])
@ -569,6 +573,9 @@ class ucp_groups
// Only set the rank, colour, etc. if it's changed or if we're adding a new // Only set the rank, colour, etc. if it's changed or if we're adding a new
// group. This prevents existing group members being updated if no changes // group. This prevents existing group members being updated if no changes
// were made. // were made.
// However there are some attributes that need to be set everytime,
// otherwise the group gets removed from the feature.
$set_attributes = array('legend', 'teampage');
$group_attributes = array(); $group_attributes = array();
$test_variables = array( $test_variables = array(
@ -580,13 +587,14 @@ class ucp_groups
'avatar_height' => 'int', 'avatar_height' => 'int',
'receive_pm' => 'int', 'receive_pm' => 'int',
'legend' => 'int', 'legend' => 'int',
'teampage' => 'int',
'message_limit' => 'int', 'message_limit' => 'int',
'max_recipients'=> 'int', 'max_recipients'=> 'int',
); );
foreach ($test_variables as $test => $type) foreach ($test_variables as $test => $type)
{ {
if (isset($submit_ary[$test]) && ($action == 'add' || $group_row['group_' . $test] != $submit_ary[$test] || isset($group_attributes['group_avatar']) && strpos($test, 'avatar') === 0)) if (isset($submit_ary[$test]) && ($action == 'add' || $group_row['group_' . $test] != $submit_ary[$test] || isset($group_attributes['group_avatar']) && strpos($test, 'avatar') === 0 || in_array($test, $set_attributes)))
{ {
settype($submit_ary[$test], $type); settype($submit_ary[$test], $type);
$group_attributes['group_' . $test] = $group_row['group_' . $test] = $submit_ary[$test]; $group_attributes['group_' . $test] = $group_row['group_' . $test] = $submit_ary[$test];
@ -596,6 +604,7 @@ class ucp_groups
if (!($error = group_create($group_id, $group_type, $group_name, $group_desc, $group_attributes, $allow_desc_bbcode, $allow_desc_urls, $allow_desc_smilies))) if (!($error = group_create($group_id, $group_type, $group_name, $group_desc, $group_attributes, $allow_desc_bbcode, $allow_desc_urls, $allow_desc_smilies)))
{ {
$cache->destroy('sql', GROUPS_TABLE); $cache->destroy('sql', GROUPS_TABLE);
$cache->destroy('sql', TEAMPAGE_TABLE);
$message = ($action == 'edit') ? 'GROUP_UPDATED' : 'GROUP_CREATED'; $message = ($action == 'edit') ? 'GROUP_UPDATED' : 'GROUP_CREATED';
trigger_error($user->lang[$message] . $return_page); trigger_error($user->lang[$message] . $return_page);