mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-17 15:03:25 +00:00
Refactor && Typo && Use plain objects as function parameters instead of ids
This commit is contained in:
@@ -232,7 +232,7 @@ class Account implements ControllerProviderInterface
|
||||
public function accountAccess(Application $app, Request $request)
|
||||
{
|
||||
return $app['twig']->render('account/access.html.twig', [
|
||||
'inscriptions' => $app['manipulator.registration']->getRegistrationSummary($app['authentication']->getUser()->getId())
|
||||
'inscriptions' => $app['registration.manager']->getRegistrationSummary($app['authentication']->getUser())
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -326,13 +326,13 @@ class Account implements ControllerProviderInterface
|
||||
*/
|
||||
public function updateAccount(PhraseaApplication $app, Request $request)
|
||||
{
|
||||
$demands = $request->request->get('demand');
|
||||
if (false === is_array($demands)) {
|
||||
$app->abort(400, '"demand" parameter must be an array of base id ');
|
||||
$registrations = $request->request->get('registrations');
|
||||
if (false === is_array($registrations)) {
|
||||
$app->abort(400, '"registrations" parameter must be an array of base ids.');
|
||||
}
|
||||
if (0 !== count($demands)) {
|
||||
foreach ($demands as $baseId) {
|
||||
$app['registration-manager']->createRegistration($app['authentication']->getUser()->get_id(), $baseId);
|
||||
if (0 !== count($registrations)) {
|
||||
foreach ($registrations as $baseId) {
|
||||
$app['manipulator.registration']->createRegistration($app['authentication']->getUser(), \collection::get_from_base_id($app, $baseId));
|
||||
}
|
||||
$app->addFlash('success', $app->trans('Your registration requests have been taken into account.'));
|
||||
}
|
||||
|
@@ -267,7 +267,7 @@ class Login implements ControllerProviderInterface
|
||||
|
||||
public function doRegistration(PhraseaApplication $app, Request $request)
|
||||
{
|
||||
if (! $app['registration.manager']->isRegistrationEnabled()) {
|
||||
if (!$app['registration.manager']->isRegistrationEnabled()) {
|
||||
$app->abort(404, 'Registration is disabled');
|
||||
}
|
||||
|
||||
@@ -335,7 +335,7 @@ class Login implements ControllerProviderInterface
|
||||
} else {
|
||||
$selected = isset($data['collections']) ? $data['collections'] : null;
|
||||
}
|
||||
$inscriptions = $app['manipulator.registration']->getRegistrationSummary();
|
||||
$inscriptions = $app['registration.manager']->getRegistrationSummary();
|
||||
$inscOK = [];
|
||||
|
||||
foreach ($app['phraseanet.appbox']->get_databoxes() as $databox) {
|
||||
@@ -385,33 +385,25 @@ class Login implements ControllerProviderInterface
|
||||
$app['EM']->flush();
|
||||
}
|
||||
|
||||
$demandOK = [];
|
||||
|
||||
$registrationsOK = [];
|
||||
if ($app['conf']->get(['registry', 'registration', 'auto-register-enabled'])) {
|
||||
$template_user = $app['manipulator.user']->getRepository()->findByLogin(User::USER_AUTOREGISTER);
|
||||
|
||||
$base_ids = [];
|
||||
|
||||
foreach (array_keys($inscOK) as $base_id) {
|
||||
$base_ids[] = $base_id;
|
||||
}
|
||||
|
||||
$app['acl']->get($user)->apply_model($template_user, $base_ids);
|
||||
$app['acl']->get($user)->apply_model($template_user, array_keys($inscOK));
|
||||
}
|
||||
|
||||
$autoReg = $app['acl']->get($user)->get_granted_base();
|
||||
|
||||
foreach ($inscOK as $base_id => $autorisation) {
|
||||
if (false === $autorisation || $app['acl']->get($user)->has_access_to_base($base_id)) {
|
||||
foreach ($inscOK as $baseId => $authorization) {
|
||||
if (false === $authorization || $app['acl']->get($user)->has_access_to_base($baseId)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$app['manipulator.registration']->createRegistration($user->getId(), $base_id);
|
||||
$demandOK[$base_id] = true;
|
||||
$app['manipulator.registration']->createRegistration($user, \collection::get_from_base_id($app, $baseId));
|
||||
$registrationsOK[$baseId] = true;
|
||||
}
|
||||
|
||||
$params = [
|
||||
'demand' => $demandOK,
|
||||
'registrations'=> $registrationsOK,
|
||||
'autoregister' => $autoReg,
|
||||
'usr_id' => $user->getId()
|
||||
];
|
||||
|
Reference in New Issue
Block a user