Ignore:
Timestamp:
12/13/09 18:05:25 (2 years ago)
Author:
gcosmin
Message:

Constraints for virtual contests.

Solves ticket #372.
Review URL: http://reviewboard.infoarena.ro/r/116/

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/common/round.php

    r1046 r1076  
    5151function round_validate_parameters($round_type, $parameters) { 
    5252    $errors = array(); 
    53     if ($round_type == 'classic' or $round_type == 'user-defined') { 
     53    if ($round_type == 'classic' or $round_type == 'user-defined' 
     54            or $round_type == 'archive') { 
    5455        // Check duration 
    5556        $duration = getattr($parameters, 'duration'); 
     
    5758            $errors['duration'] = "Durata trebuie specificata"; 
    5859        } 
     60 
     61        if ($round_type == 'user-defined') { 
     62            if ($duration > IA_USER_DEFINED_ROUND_DURATION_LIMIT) { 
     63                $errors['duration'] = "Durata maxim admisa este de " . 
     64                    IA_USER_DEFINED_ROUND_DURATION_LIMIT . " ore"; 
     65            } 
     66        } 
     67 
    5968        if (!is_numeric($duration) || $duration < 0) { 
    6069            $errors['duration'] = "Durata trebuie sa fie un numar pozitiv"; 
    6170        } 
    62     } elseif ($round_type == 'archive') { 
    63         // Empty... 
    6471    } else { 
    6572        log_error("Bad round_type"); 
     
    119126    if (!is_db_date(getattr($round, 'start_time', db_date_format()))) { 
    120127        $errors['start_time'] = "Timpul trebuie specificat ca YYYY-MM-DD HH:MM:SS"; 
     128    } else { 
     129        if ($round['type'] == 'user-defined') { 
     130            $current_time = db_date_parse(date("Y-m-d H:i:s")); 
     131            $round_time = db_date_parse($round['start_time']); 
     132 
     133            if (($round_time - $current_time) > 
     134                    IA_USER_DEFINED_ROUND_DAYSBEFORE_LIMIT * 60 * 60 * 24) { 
     135                $errors['start_time'] = "Nu poti creea o runda cu mai mult de " 
     136                    . IA_USER_DEFINED_ROUND_DAYSBEFORE_LIMIT . " zile inainte"; 
     137            } 
     138        } 
    121139    } 
    122140 
Note: See TracChangeset for help on using the changeset viewer.