本文整理汇总了PHP中Authorization::CanEditRun方法的典型用法代码示例。如果您正苦于以下问题:PHP Authorization::CanEditRun方法的具体用法?PHP Authorization::CanEditRun怎么用?PHP Authorization::CanEditRun使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Authorization
的用法示例。
在下文中一共展示了Authorization::CanEditRun方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: CanViewRun
public static function CanViewRun($user_id, Runs $run)
{
if (is_null($run) || !is_a($run, 'Runs')) {
return false;
}
return $run->getUserId() === $user_id || Authorization::CanEditRun($user_id, $run);
}
示例2: apiRejudge
/**
* Re-sends a problem to Grader.
*
* @param Request $r
* @throws InvalidDatabaseOperationException
*/
public static function apiRejudge(Request $r)
{
// Init
self::initializeGrader();
// Get the user who is calling this API
self::authenticateRequest($r);
self::validateDetailsRequest($r);
if (!Authorization::CanEditRun($r['current_user_id'], $r['run'])) {
throw new ForbiddenAccessException('userNotAllowed');
}
self::$log->info('Run being rejudged!!');
// Try to delete existing directory, if exists.
try {
$grade_dir = RunController::getGradePath($r['run']);
FileHandler::DeleteDirRecursive($grade_dir);
} catch (Exception $e) {
// Soft error :P
self::$log->warn($e);
}
try {
self::$grader->Grade([$r['run']->guid], true, $r['debug'] || false);
} catch (Exception $e) {
self::$log->error('Call to Grader::grade() failed:');
self::$log->error($e);
}
$response = array();
$response['status'] = 'ok';
self::invalidateCacheOnRejudge($r['run']);
// Expire ranks
UserController::deleteProblemsSolvedRankCacheList();
return $response;
}