[ticket/10411] Catch exceptions from grouppositions

PHPBB3-10411
This commit is contained in:
Joas Schilling 2013-02-26 16:53:51 +01:00
parent e0df593448
commit 9e70f7a4e0
2 changed files with 108 additions and 49 deletions

View file

@ -851,10 +851,11 @@ class acp_groups
{ {
$group_position = $phpbb_container->get('groupposition.' . $field); $group_position = $phpbb_container->get('groupposition.' . $field);
$group_position->set_admin_back_link($this->u_action);
} }
if ($field == 'teampage') if ($field == 'teampage')
{
try
{ {
switch ($action) switch ($action)
{ {
@ -879,7 +880,14 @@ class acp_groups
break; break;
} }
} }
catch (phpbb_groupposition_exception $exception)
{
trigger_error($user->lang($exception->getMessage()) . adm_back_link($this->u_action), E_USER_WARNING);
}
}
else if ($field == 'legend') else if ($field == 'legend')
{
try
{ {
switch ($action) switch ($action)
{ {
@ -900,6 +908,11 @@ class acp_groups
break; break;
} }
} }
catch (phpbb_groupposition_exception $exception)
{
trigger_error($user->lang($exception->getMessage()) . adm_back_link($this->u_action), E_USER_WARNING);
}
}
else else
{ {
switch ($action) switch ($action)

View file

@ -2605,10 +2605,17 @@ function group_create(&$group_id, $type, $name, $desc, $group_attributes, $allow
$legend = $phpbb_container->get('groupposition.legend'); $legend = $phpbb_container->get('groupposition.legend');
$teampage = $phpbb_container->get('groupposition.teampage'); $teampage = $phpbb_container->get('groupposition.teampage');
if ($group_id) if ($group_id)
{
try
{ {
$current_legend = $legend->get_group_value($group_id); $current_legend = $legend->get_group_value($group_id);
$current_teampage = $teampage->get_group_value($group_id); $current_teampage = $teampage->get_group_value($group_id);
} }
catch (phpbb_groupposition_exception $exception)
{
trigger_error($user->lang($exception->getMessage()));
}
}
if (!empty($group_attributes['group_legend'])) if (!empty($group_attributes['group_legend']))
{ {
@ -2626,7 +2633,14 @@ function group_create(&$group_id, $type, $name, $desc, $group_attributes, $allow
else if ($group_id && ($current_legend != phpbb_groupposition_legend::GROUP_DISABLED)) else if ($group_id && ($current_legend != phpbb_groupposition_legend::GROUP_DISABLED))
{ {
// Group is removed from the legend // Group is removed from the legend
try
{
$legend->delete_group($group_id, true); $legend->delete_group($group_id, true);
}
catch (phpbb_groupposition_exception $exception)
{
trigger_error($user->lang($exception->getMessage()));
}
$group_attributes['group_legend'] = phpbb_groupposition_legend::GROUP_DISABLED; $group_attributes['group_legend'] = phpbb_groupposition_legend::GROUP_DISABLED;
} }
else else
@ -2732,9 +2746,16 @@ function group_create(&$group_id, $type, $name, $desc, $group_attributes, $allow
// Remove the group from the teampage, only if unselected and we are editing a group, // Remove the group from the teampage, only if unselected and we are editing a group,
// which is currently displayed. // which is currently displayed.
if (!$group_teampage && $group_id && $current_teampage != phpbb_groupposition_teampage::GROUP_DISABLED) if (!$group_teampage && $group_id && $current_teampage != phpbb_groupposition_teampage::GROUP_DISABLED)
{
try
{ {
$teampage->delete_group($group_id); $teampage->delete_group($group_id);
} }
catch (phpbb_groupposition_exception $exception)
{
trigger_error($user->lang($exception->getMessage()));
}
}
if (!$group_id) if (!$group_id)
{ {
@ -2746,6 +2767,8 @@ function group_create(&$group_id, $type, $name, $desc, $group_attributes, $allow
} }
} }
try
{
if ($group_teampage && $current_teampage == phpbb_groupposition_teampage::GROUP_DISABLED) if ($group_teampage && $current_teampage == phpbb_groupposition_teampage::GROUP_DISABLED)
{ {
$teampage->add_group($group_id); $teampage->add_group($group_id);
@ -2762,6 +2785,11 @@ function group_create(&$group_id, $type, $name, $desc, $group_attributes, $allow
{ {
$teampage->delete_group($group_id); $teampage->delete_group($group_id);
} }
}
catch (phpbb_groupposition_exception $exception)
{
trigger_error($user->lang($exception->getMessage()));
}
unset($teampage); unset($teampage);
// Set user attributes // Set user attributes
@ -2887,13 +2915,31 @@ function group_delete($group_id, $group_name = false)
while ($start); while ($start);
// Delete group from legend and teampage // Delete group from legend and teampage
try
{
$legend = $phpbb_container->get('groupposition.legend'); $legend = $phpbb_container->get('groupposition.legend');
$legend->delete_group($group_id); $legend->delete_group($group_id);
unset($legend); unset($legend);
}
catch (phpbb_groupposition_exception $exception)
{
// The group we want to delete does not exist.
// No reason to worry, we just continue the deleting process.
//trigger_error($user->lang($exception->getMessage()));
}
try
{
$teampage = $phpbb_container->get('groupposition.teampage'); $teampage = $phpbb_container->get('groupposition.teampage');
$teampage->delete_group($group_id); $teampage->delete_group($group_id);
unset($teampage); unset($teampage);
}
catch (phpbb_groupposition_exception $exception)
{
// The group we want to delete does not exist.
// No reason to worry, we just continue the deleting process.
//trigger_error($user->lang($exception->getMessage()));
}
// Delete group // Delete group
$sql = 'DELETE FROM ' . GROUPS_TABLE . " $sql = 'DELETE FROM ' . GROUPS_TABLE . "