- return $db->problem($1)->owner if m,^/pb/$word, && $db->problem($1)->private;
- return $db->job ($1)->owner if m,^/log/(?:job|src)/$word, && $db->job($1)->private;
- return $db->contest($1)->owner if m,^/ct/$word/(?:pb|log), && time < $db->contest($1)->start;
- return $db->job ($2)->owner if m,^/ct/$word/log/(?:job|src)/$word, && time < $db->contest($1)->stop;
+ my $env = $_[1];
+ return $db->contest($env->{'gruntmaster.contest'})->owner->id if $env->{'gruntmaster.contest'} && $db->contest($env->{'gruntmaster.contest'})->start > time;
+ return $db->problem($1)->owner->id if m,^/pb/$word, && is_problem_private $1;
+ return $db->problem($1)->owner->id if m,^/pb/$word, && !is_problem_in_contest $1, $env->{'gruntmaster.contest'};
+ return $db->problem($env->{'gruntmaster.problem'}) if $env->{'gruntmaster.problem'} && is_problem_private $env->{'gruntmaster.problem'};
+ return $db->problem($env->{'gruntmaster.problem'}) if $env->{'gruntmaster.problem'} && !is_problem_in_contest $env->{'gruntmaster.problem'}, $env->{'gruntmaster.contest'};
+ return $db->job ($1)->owner->id if m,^/log/(?:src/)?$number, && $db->job($1)->private;
+ return $db->job ($1)->owner->id if m,^/log/(?:src/)?$number, && is_problem_private $db->job($1)->problem->id;
+ return $db->job ($1)->owner->id if m,^/log/(?:src/)?$number, && $db->job($1)->contest && $db->job($1)->contest->stop > time;