From ad05f32c494d6622eca97c028cbde53e44a54647 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 14 Feb 2011 16:43:56 +0100 Subject: [PATCH] [ticket/9549] Throw an error when the given field-name is invalid. Also the code now only appends an adm_back_link, when we are in the ACP. PHPBB3-9549 --- phpBB/includes/acp/acp_groups.php | 2 +- phpBB/includes/group_positions.php | 24 ++++++++++++++++++++---- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/phpBB/includes/acp/acp_groups.php b/phpBB/includes/acp/acp_groups.php index 015be3c30e..dde556c19e 100644 --- a/phpBB/includes/acp/acp_groups.php +++ b/phpBB/includes/acp/acp_groups.php @@ -821,7 +821,7 @@ class acp_groups } else if ($field) { - $group_position = new phpbb_group_positions($db, $field); + $group_position = new phpbb_group_positions($db, $field, $this->u_action); } switch ($action) diff --git a/phpBB/includes/group_positions.php b/phpBB/includes/group_positions.php index e63e17c384..a697d96f66 100644 --- a/phpBB/includes/group_positions.php +++ b/phpBB/includes/group_positions.php @@ -40,15 +40,23 @@ class phpbb_group_positions */ private $field = ''; + /** + * URI for the adm_back_link when there was an error. + */ + private $adm_back_link = ''; + /** * Constructor */ - public function __construct ($db, $field) + public function __construct ($db, $field, $adm_back_link = '') { + $this->adm_back_link = $adm_back_link; + if (!in_array($field, array('teampage', 'legend'))) { - + $this->error('NO_MODE'); } + $this->db = $db; $this->field = $field; } @@ -70,8 +78,7 @@ class phpbb_group_positions if ($current_value === false) { // Group not found. - global $user; - trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action), E_USER_WARNING); + $this->error('NO_GROUP'); } return (int) $current_value; @@ -232,4 +239,13 @@ class phpbb_group_positions return 'GROUP_OPEN'; } } + + /** + * Error + */ + public function error($message) + { + global $user; + trigger_error($user->lang[$message] . (($this->adm_back_link) ? adm_back_link($this->adm_back_link) : ''), E_USER_WARNING); + } }