[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
This commit is contained in:
Joas Schilling 2011-02-14 16:43:56 +01:00
parent 8d12838aed
commit ad05f32c49
2 changed files with 21 additions and 5 deletions

View file

@ -821,7 +821,7 @@ class acp_groups
} }
else if ($field) else if ($field)
{ {
$group_position = new phpbb_group_positions($db, $field); $group_position = new phpbb_group_positions($db, $field, $this->u_action);
} }
switch ($action) switch ($action)

View file

@ -40,15 +40,23 @@ class phpbb_group_positions
*/ */
private $field = ''; private $field = '';
/**
* URI for the adm_back_link when there was an error.
*/
private $adm_back_link = '';
/** /**
* Constructor * 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'))) if (!in_array($field, array('teampage', 'legend')))
{ {
$this->error('NO_MODE');
} }
$this->db = $db; $this->db = $db;
$this->field = $field; $this->field = $field;
} }
@ -70,8 +78,7 @@ class phpbb_group_positions
if ($current_value === false) if ($current_value === false)
{ {
// Group not found. // Group not found.
global $user; $this->error('NO_GROUP');
trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action), E_USER_WARNING);
} }
return (int) $current_value; return (int) $current_value;
@ -232,4 +239,13 @@ class phpbb_group_positions
return 'GROUP_OPEN'; 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);
}
} }