Changeset 1036 for trunk/common
- Timestamp:
- 03/14/09 22:31:53 (3 years ago)
- Location:
- trunk/common
- Files:
-
- 3 edited
-
db/task.php (modified) (1 diff)
-
job.php (modified) (2 diffs)
-
security.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/common/db/task.php
r1010 r1036 160 160 } 161 161 162 // Returns list of running round ids that include this task to which 163 // $user_id can submit 164 function task_get_submit_rounds($task_id, $user_id) { 165 $rounds = task_get_parent_rounds($task_id); 166 foreach($rounds as $id => $round) { 167 $round = round_get($rounds[$id]); 168 if (!security_query($user_id, "round-submit", $round)) { 169 unset($rounds[$id]); 170 } 171 } 172 return array_values($rounds); 173 } 174 162 175 ?> -
trunk/common/job.php
r997 r1036 29 29 // Validate round id. 30 30 $round = null; 31 if (array_key_exists('round_id', $args)) { 32 if (!is_round_id($args['round_id'])) { 33 $errors['round_id'] = "Id de runda invalid"; 34 } else if (is_null($round = round_get($args['round_id']))) { 35 $errors['round_id'] = "Runda '{$args['round_id']}' nu exista."; 36 } 31 if (!array_key_exists('round_id', $args)) { 32 $errors['round_id'] = "Nu ai specificat un concurs."; 33 } else if (!is_round_id($args['round_id'])) { 34 $errors['round_id'] = "Nu ai specificat un concurs corect."; 35 } else if (is_null($round = round_get($args['round_id']))) { 36 $errors['round_id'] = "Runda '{$args['round_id']}' nu exista."; 37 } 38 // Check if task is new and hasn't been added to any rounds 39 if (getattr($args, "round_id") == "" && 40 security_query($user, 'task-submit', $task)) { 41 unset($errors["round_id"]); 37 42 } 38 43 … … 65 70 $errors[] = "Nu ai voie sa trimiti la acest task."; 66 71 } 67 if ($round && !security_query($ round, 'task-submit', $round)) {72 if ($round && !security_query($user, 'round-submit', $round)) { 68 73 $errors[] = "Nu poti sa trimiti la aceasta runda."; 69 74 } 70 75 71 // FIXME: check round-submit or something?72 73 76 // Only now create the job. 74 77 if (count($errors) === 0) { 75 // round_id can be missing. 76 // If it's missing then the job is multiplied and sent to all parent rounds. 77 // This is compatible with 2.1.3 78 if (array_key_exists('round_id', $args)) { 79 job_create($args['task_id'], $args['round_id'], $user['id'], 80 $args['compiler_id'], $args['solution'], 81 getattr($args, 'remote_ip_info')); 82 } else { 83 $parent_rounds = task_get_parent_rounds($args['task_id']); 84 if (count($parent_rounds) === 0) { 85 // some jobs just don't have a round 86 job_create($args['task_id'], '', $user['id'], 87 $args['compiler_id'], $args['solution'], 88 getattr($args, 'remote_ip_info')); 89 } 90 else { 91 foreach ($parent_rounds as $round_id) { 92 if (security_query($user, 'round-submit', round_get($round_id))) { 93 job_create($args['task_id'], $round_id, $user['id'], 94 $args['compiler_id'], $args['solution'], 95 getattr($args, 'remote_ip_info')); 96 } 97 } 98 } 99 } 78 job_create($args['task_id'], $args['round_id'], $user['id'], 79 $args['compiler_id'], $args['solution'], 80 getattr($args, 'remote_ip_info')); 100 81 } 101 82 -
trunk/common/security.php
r1030 r1036 509 509 510 510 case 'round-submit': 511 // FIXME: This sucks. 512 // FIXME: job_get_submit_targets 513 $rparams = round_get_parameters($round['id']); 514 $time = time(); 515 $rstart = db_date_parse($round['start_time']); 516 $rduration = getattr($rparams, 'duration', 10000000) * 60 * 60; 517 if ($time >= $rstart && $time <= $rstart + $rduration) { 518 return true; 519 } else { 520 return false; 521 } 511 return $round["state"] == "running"; 522 512 523 513 case 'sensitive-info':
Note: See TracChangeset
for help on using the changeset viewer.
![[infoarena] development](/chrome/site/logo.png)