Port PHRAS-1593

This commit is contained in:
Mike Ng
2017-11-24 16:22:31 +04:00
parent 79493d9dca
commit a79b72fbaf
5 changed files with 230 additions and 149 deletions

View File

@@ -47,10 +47,22 @@ class Share implements ControllerProviderInterface, ServiceProviderInterface
$controllers->get('/record/{base_id}/{record_id}/', 'controller.prod.share:shareRecord')
->before(function (Request $request) use ($app, $firewall) {
$firewall->requireRightOnSbas(
\phrasea::sbasFromBas($app, $request->attributes->get('base_id')),
\ACL::BAS_CHUPUB
);
$socialTools = $app['conf']->get(['registry', 'actions', 'social-tools']);
if($socialTools === "all") {
return;
}
elseif($socialTools === "none") {
$app->abort(403, 'social tools disabled');
}
elseif($socialTools === "publishers") {
$firewall->requireRightOnSbas(
\phrasea::sbasFromBas($app, $request->attributes->get('base_id')),
\ACL::BAS_CHUPUB
);
}
else {
throw new \Exception("bad value \"" . $socialTools . "\" for social tools");
}
})
->bind('share_record');