Beispiel #1
0
 function check_input_errors($edit)
 {
     $errors = array();
     if (!validate_nonhtml($edit['name'])) {
         $errors[] = "A valid league name must be entered";
     }
     if (!validate_yyyymmdd_input($edit['roster_deadline'])) {
         $errors[] = 'You must provide a valid roster deadline';
     }
     switch ($edit['schedule_type']) {
         case 'none':
         case 'roundrobin':
             break;
         case 'ratings_ladder':
         case 'ratings_wager_ladder':
             if ($edit['games_before_repeat'] == null || $edit['games_before_repeat'] == 0) {
                 $errors[] = "Invalid 'Games Before Repeat' specified!";
             }
             break;
         default:
             $errors[] = "Values for allow schedule are none, roundrobin, ratings_ladder, and ratings_wager_ladder";
     }
     if ($edit['schedule_type'] != 'none') {
         if (!$edit['day']) {
             $errors[] = "One or more days of play must be selected";
         }
     }
     if (!validate_number($edit['finalize_after']) || $edit['finalize_after'] < 0) {
         $errors[] = "A valid number must be entered for the game finalization delay";
     }
     return $errors;
 }
Beispiel #2
0
 function check_input_errors($edit)
 {
     $errors = array();
     if (!validate_nonhtml($edit['display_name'])) {
         $errors[] = "A valid season name must be entered";
     }
     if (!validate_yyyymmdd_input($edit['year'] . '-01-01')) {
         $errors[] = 'You must provide a valid year';
     }
     return $errors;
 }
Beispiel #3
0
 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;
 }
Beispiel #4
0
 function check_input_errors($edit)
 {
     $errors = array();
     if (!validate_nonhtml($edit['name'])) {
         $errors[] = 'Name cannot be left blank, and cannot contain HTML';
     }
     if (!validate_currency_code($edit['currency_code'])) {
         $errors[] = 'You must provide a valid currency code';
     }
     if (!validate_number($edit['cost'])) {
         $errors[] = 'Invalid cost: not a number';
     } else {
         if ($edit['cost'] < 0) {
             $errors[] = 'Invalid cost: cannot be negative';
         }
     }
     if (!validate_number($edit['gst'])) {
         $errors[] = 'Invalid GST: not a number';
     } else {
         if ($edit['gst'] < 0) {
             $errors[] = 'Invalid GST: cannot be negative';
         }
     }
     if (!validate_number($edit['pst'])) {
         $errors[] = 'Invalid PST: not a number';
     } else {
         if ($edit['pst'] < 0) {
             $errors[] = 'Invalid PST: cannot be negative';
         }
     }
     if (!validate_yyyymmdd_input($edit['open_date'])) {
         $errors[] = 'You must provide a valid open date';
     }
     if (!validate_yyyymmdd_input($edit['close_date'])) {
         $errors[] = 'You must provide a valid close date';
     }
     if (!validate_number($edit['cap_male'])) {
         $errors[] = 'Invalid male cap: not a number';
     } else {
         if ($edit['cap_male'] < -1) {
             $errors[] = 'Invalid male cap: cannot be less than -1';
         }
     }
     if (!validate_number($edit['cap_female'])) {
         $errors[] = 'Invalid female cap: not a number';
     } else {
         if ($edit['cap_female'] < -2) {
             $errors[] = 'Invalid female cap: cannot be less than -2';
         } else {
             if ($edit['cap_female'] == -2 && $edit['cap_male'] <= 0) {
                 $errors[] = 'Invalid female cap: can only be -2 if male cap is > 0';
             }
         }
     }
     return $errors;
 }