function check_input_errors($edit = array()) { $errors = parent::check_input_errors($edit); if (!validate_name_input($edit['username'])) { $errors[] = "You can only use letters, numbers, spaces, and the characters - ' and . in usernames"; } $existing_user = Person::load(array('username' => $edit['username'])); if ($existing_user) { $errors[] = "A user with that username already exists; please choose another"; } if ($edit['password_once'] != $edit['password_twice']) { $errors[] = error_exit("First and second entries of password do not match"); } return $errors; }
function check_input_errors($edit = array()) { global $lr_session; $errors = array(); if ($lr_session->has_permission('person', 'edit', $this->person->user_id, 'name')) { if (!validate_name_input($edit['firstname']) || !validate_name_input($edit['lastname'])) { $errors[] = "You can only use letters, numbers, spaces, and the characters - ' and . in first and last names"; } } if ($lr_session->has_permission('person', 'edit', $this->person->user_id, 'username')) { if (!validate_name_input($edit['username'])) { $errors[] = "You can only use letters, numbers, spaces, and the characters - ' and . in usernames"; } $user = Person::load(array('username' => $edit['username'])); # TODO: BUG: need to check that $user->user_id != current id if ($user && !$lr_session->is_admin()) { $errors[] = "A user with that username already exists; please choose another"; } } if (!validate_email_input($edit['email'])) { $errors[] = "You must supply a valid email address"; } if (!validate_nonblank($edit['home_phone']) && !validate_nonblank($edit['work_phone']) && !validate_nonblank($edit['mobile_phone'])) { $errors[] = "You must supply at least one valid telephone number. Please supply area code, number and (if any) extension."; } if (validate_nonblank($edit['home_phone']) && !validate_telephone_input($edit['home_phone'])) { $errors[] = "Home telephone number is not valid. Please supply area code, number and (if any) extension."; } if (validate_nonblank($edit['work_phone']) && !validate_telephone_input($edit['work_phone'])) { $errors[] = "Work telephone number is not valid. Please supply area code, number and (if any) extension."; } if (validate_nonblank($edit['mobile_phone']) && !validate_telephone_input($edit['mobile_phone'])) { $errors[] = "Mobile telephone number is not valid. Please supply area code, number and (if any) extension."; } $address_errors = validate_address($edit['addr_street'], $edit['addr_city'], $edit['addr_prov'], $edit['addr_postalcode'], $edit['addr_country']); if (count($address_errors) > 0) { $errors = array_merge($errors, $address_errors); } if (!preg_match("/^[mf]/i", $edit['gender'])) { $errors[] = "You must select either male or female for gender."; } if (!validate_yyyymmdd_input($edit['birthdate'])) { $errors[] = "You must provide a valid birthdate"; } if (validate_nonblank($edit['height'])) { if (!$lr_session->is_admin() && ($edit['height'] < 36 || $edit['height'] > 84)) { $errors[] = "Please enter a reasonable and valid value for your height."; } } if ($edit['skill_level'] < 1 || $edit['skill_level'] > 10) { $errors[] = "You must select a skill level between 1 and 10. You entered " . $edit['skill_level']; } $current = localtime(time(), 1); $this_year = $current['tm_year'] + 1900; if ($edit['year_started'] > $this_year) { $errors[] = "Year started must be before current year."; } if ($edit['year_started'] < 1986) { $errors[] = "Year started must be after 1986. For the number of people who started playing before then, I don't think it matters if you're listed as having played 17 years or 20, you're still old. :)"; } $birth_year = substr($edit['birthdate'], 0, 4); $yearDiff = $edit['year_started'] - $birth_year; if ($yearDiff < 8) { $errors[] = "You can't have started playing when you were {$yearDiff} years old! Please correct your birthdate, or your starting year"; } return $errors; }