Skip to content

Commit

Permalink
Require author and translator dates are numeric
Browse files Browse the repository at this point in the history
This goes some way to addressing issue LibriVox#154 -- users won't be able to
enter non-numeric dates, which is unfortunate, but it does mean that
they'll get a proper error message instead of the random server error
that they get right now.

For the more technical explanation -- When we save the form generation,
that all goes into the `form_generators` table. Any new authors that are
created as part of the generator are saved into
`form_generators_authors`, which has the `auth_yob` and `auth_yod`
columns as four-digit integers. This doesn't align well with the actual
`authors` table, which allows pretty much anything (`varchar(10)`), and
I have no idea how people specify AD vs. BCE using the generator.

I don't know enough about how the table is used to know whether we
should consider migrating it to `varchar(10)` to match `authors`, but
having the two consistent with each other would be good probably.

I also tried specifying the input fields as numeric in the HTML, but
that didn't quite have the desired effect -- it would just submit the
field as empty if it wasn't right, which meant we'd silently drop the
data rather than get a validation error.
  • Loading branch information
garethsime committed Aug 21, 2023
1 parent faa493f commit 30784a6
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions application/controllers/public/Project_launch.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,15 +209,15 @@ private function _validate_form()
$this->form_validation->set_rules('auth_id[]', 'Author id', 'trim|xss_clean');
$this->form_validation->set_rules('auth_first_name[]', 'lang:proj_launch_auth_first_name', 'trim|xss_clean');
$this->form_validation->set_rules('auth_last_name[]', 'lang:proj_launch_auth_last_name', 'trim|xss_clean');
$this->form_validation->set_rules('auth_yob[]', 'lang:proj_launch_auth_dob', 'trim|xss_clean');
$this->form_validation->set_rules('auth_yod[]', 'lang:proj_launch_auth_dod', 'trim|xss_clean');
$this->form_validation->set_rules('auth_yob[]', 'lang:proj_launch_auth_dob', 'trim|xss_clean|numeric');
$this->form_validation->set_rules('auth_yod[]', 'lang:proj_launch_auth_dod', 'trim|xss_clean|numeric');
$this->form_validation->set_rules('link_to_auth[]', 'lang:proj_launch_link_to_auth', 'trim|xss_clean|prep_url');

$this->form_validation->set_rules('trans_id[]', 'Translator id', 'trim|xss_clean|numeric');
$this->form_validation->set_rules('trans_first_name[]', 'lang:proj_launch_auth_first_name', 'trim|xss_clean');
$this->form_validation->set_rules('trans_last_name[]', 'lang:proj_launch_auth_last_name', 'trim|xss_clean');
$this->form_validation->set_rules('trans_yob[]', 'lang:proj_launch_trans_dob', 'trim|xss_clean');
$this->form_validation->set_rules('trans_yod[]', 'lang:proj_launch_trans_dod', 'trim|xss_clean');
$this->form_validation->set_rules('trans_yob[]', 'lang:proj_launch_trans_dob', 'trim|xss_clean|numeric');
$this->form_validation->set_rules('trans_yod[]', 'lang:proj_launch_trans_dod', 'trim|xss_clean|numeric');
$this->form_validation->set_rules('link_to_trans[]', 'lang:proj_launch_link_to_trans', 'trim|xss_clean');

$this->form_validation->set_rules('project_type', 'lang:proj_launch_type_of_project', 'trim|xss_clean|alpha_dash');
Expand Down

0 comments on commit 30784a6

Please sign in to comment.