diff options
author | Perl Tidy <perltidy@bugzilla.org> | 2019-01-30 20:00:43 -0500 |
---|---|---|
committer | Dylan William Hardison <dylan@hardison.net> | 2019-01-30 20:31:44 -0500 |
commit | 7f3a749d7bd78a3e4aee163f562d7e95b0954b44 (patch) | |
tree | f86271c0b1f3ece6d55d8fa44767d41bb890f1f6 /editvalues.cgi | |
parent | Bug 1226123 - Email addresses with an apostrophe in them break the "Send Mail... (diff) | |
download | bugzilla-7f3a749d7bd78a3e4aee163f562d7e95b0954b44.tar.gz bugzilla-7f3a749d7bd78a3e4aee163f562d7e95b0954b44.tar.bz2 bugzilla-7f3a749d7bd78a3e4aee163f562d7e95b0954b44.zip |
no bug - reformat all the code using the new perltidy rules
Diffstat (limited to 'editvalues.cgi')
-rwxr-xr-x | editvalues.cgi | 133 |
1 files changed, 66 insertions, 67 deletions
diff --git a/editvalues.cgi b/editvalues.cgi index 75ebee0fc..0031312c0 100755 --- a/editvalues.cgi +++ b/editvalues.cgi @@ -25,12 +25,12 @@ use Bugzilla::Field::Choice; ############### sub display_field_values { - my $vars = shift; - my $template = Bugzilla->template; - $vars->{'values'} = $vars->{'field'}->legal_values; - $template->process("admin/fieldvalues/list.html.tmpl", $vars) - || ThrowTemplateError($template->error()); - exit; + my $vars = shift; + my $template = Bugzilla->template; + $vars->{'values'} = $vars->{'field'}->legal_values; + $template->process("admin/fieldvalues/list.html.tmpl", $vars) + || ThrowTemplateError($template->error()); + exit; } ###################################################################### @@ -43,7 +43,7 @@ my $user = Bugzilla->login(LOGIN_REQUIRED); my $dbh = Bugzilla->dbh; my $cgi = Bugzilla->cgi; my $template = Bugzilla->template; -my $vars = {}; +my $vars = {}; # Replace this entry by separate entries in templates when # the documentation about legal values becomes bigger. @@ -52,33 +52,31 @@ $vars->{'doc_section'} = 'administering/field-values.html'; print $cgi->header(); $user->in_group('admin') - || ThrowUserError('auth_failure', {group => "admin", - action => "edit", - object => "field_values"}); + || ThrowUserError('auth_failure', + {group => "admin", action => "edit", object => "field_values"}); # # often-used variables # -my $action = trim($cgi->param('action') || ''); -my $token = $cgi->param('token'); +my $action = trim($cgi->param('action') || ''); +my $token = $cgi->param('token'); # # field = '' -> Show nice list of fields # if (!$cgi->param('field')) { - my @field_list = - @{ Bugzilla->fields({ is_select => 1, is_abnormal => 0 }) }; + my @field_list = @{Bugzilla->fields({is_select => 1, is_abnormal => 0})}; - $vars->{'fields'} = \@field_list; - $template->process("admin/fieldvalues/select-field.html.tmpl", $vars) - || ThrowTemplateError($template->error()); - exit; + $vars->{'fields'} = \@field_list; + $template->process("admin/fieldvalues/select-field.html.tmpl", $vars) + || ThrowTemplateError($template->error()); + exit; } # At this point, the field must be defined. my $field = Bugzilla::Field->check($cgi->param('field')); if (!$field->is_select || $field->is_abnormal) { - ThrowUserError('fieldname_invalid', { field => $field }); + ThrowUserError('fieldname_invalid', {field => $field}); } $vars->{'field'} = $field; @@ -92,30 +90,30 @@ display_field_values($vars) unless $action; # (next action will be 'new') # if ($action eq 'add') { - $vars->{'token'} = issue_session_token('add_field_value'); - $template->process("admin/fieldvalues/create.html.tmpl", $vars) - || ThrowTemplateError($template->error()); - exit; + $vars->{'token'} = issue_session_token('add_field_value'); + $template->process("admin/fieldvalues/create.html.tmpl", $vars) + || ThrowTemplateError($template->error()); + exit; } # # action='new' -> add field value entered in the 'action=add' screen # if ($action eq 'new') { - check_token_data($token, 'add_field_value'); + check_token_data($token, 'add_field_value'); - my $created_value = Bugzilla::Field::Choice->type($field)->create({ - value => scalar $cgi->param('value'), - sortkey => scalar $cgi->param('sortkey'), - is_open => scalar $cgi->param('is_open'), - visibility_value_id => scalar $cgi->param('visibility_value_id'), - }); + my $created_value = Bugzilla::Field::Choice->type($field)->create({ + value => scalar $cgi->param('value'), + sortkey => scalar $cgi->param('sortkey'), + is_open => scalar $cgi->param('is_open'), + visibility_value_id => scalar $cgi->param('visibility_value_id'), + }); - delete_token($token); + delete_token($token); - $vars->{'message'} = 'field_value_created'; - $vars->{'value'} = $created_value; - display_field_values($vars); + $vars->{'message'} = 'field_value_created'; + $vars->{'value'} = $created_value; + display_field_values($vars); } # After this, we always have a value @@ -127,16 +125,17 @@ $vars->{'value'} = $value; # (next action would be 'delete') # if ($action eq 'del') { - # If the value cannot be deleted, throw an error. - if ($value->is_static) { - ThrowUserError('fieldvalue_not_deletable', $vars); - } - $vars->{'token'} = issue_session_token('delete_field_value'); - $template->process("admin/fieldvalues/confirm-delete.html.tmpl", $vars) - || ThrowTemplateError($template->error()); + # If the value cannot be deleted, throw an error. + if ($value->is_static) { + ThrowUserError('fieldvalue_not_deletable', $vars); + } + $vars->{'token'} = issue_session_token('delete_field_value'); - exit; + $template->process("admin/fieldvalues/confirm-delete.html.tmpl", $vars) + || ThrowTemplateError($template->error()); + + exit; } @@ -144,12 +143,12 @@ if ($action eq 'del') { # action='delete' -> really delete the field value # if ($action eq 'delete') { - check_token_data($token, 'delete_field_value'); - $value->remove_from_db(); - delete_token($token); - $vars->{'message'} = 'field_value_deleted'; - $vars->{'no_edit_link'} = 1; - display_field_values($vars); + check_token_data($token, 'delete_field_value'); + $value->remove_from_db(); + delete_token($token); + $vars->{'message'} = 'field_value_deleted'; + $vars->{'no_edit_link'} = 1; + display_field_values($vars); } @@ -158,11 +157,11 @@ if ($action eq 'delete') { # (next action would be 'update') # if ($action eq 'edit') { - $vars->{'token'} = issue_session_token('edit_field_value'); - $template->process("admin/fieldvalues/edit.html.tmpl", $vars) - || ThrowTemplateError($template->error()); + $vars->{'token'} = issue_session_token('edit_field_value'); + $template->process("admin/fieldvalues/edit.html.tmpl", $vars) + || ThrowTemplateError($template->error()); - exit; + exit; } @@ -170,21 +169,21 @@ if ($action eq 'edit') { # action='update' -> update the field value # if ($action eq 'update') { - check_token_data($token, 'edit_field_value'); - $vars->{'value_old'} = $value->name; - my %params = ( - name => scalar $cgi->param('value_new'), - sortkey => scalar $cgi->param('sortkey'), - visibility_value => scalar $cgi->param('visibility_value_id'), - ); - if ($cgi->should_set('is_active')) { - $params{is_active} = $cgi->param('is_active'); - } - $value->set_all(\%params); - $vars->{'changes'} = $value->update(); - delete_token($token); - $vars->{'message'} = 'field_value_updated'; - display_field_values($vars); + check_token_data($token, 'edit_field_value'); + $vars->{'value_old'} = $value->name; + my %params = ( + name => scalar $cgi->param('value_new'), + sortkey => scalar $cgi->param('sortkey'), + visibility_value => scalar $cgi->param('visibility_value_id'), + ); + if ($cgi->should_set('is_active')) { + $params{is_active} = $cgi->param('is_active'); + } + $value->set_all(\%params); + $vars->{'changes'} = $value->update(); + delete_token($token); + $vars->{'message'} = 'field_value_updated'; + display_field_values($vars); } # No valid action found |