mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-23 18:03:17 +00:00
Merge pull request #1387 from bburnichon/feature/update-account-400-error-phras-547
Fixes PHRAS-547 and PHRAS-551
This commit is contained in:
@@ -356,14 +356,19 @@ class UserController extends Controller
|
||||
$userRegistrations = [];
|
||||
/** @var RegistrationRepository $registrationRepository */
|
||||
$registrationRepository = $this->app['repo.registrations'];
|
||||
foreach (
|
||||
$registrationRepository->getUserRegistrations(
|
||||
$authenticatedUser,
|
||||
$this->getAclForConnectedUser()->get_granted_base(['canadmin'])
|
||||
) as $registration) {
|
||||
$collections = $this->getAclForConnectedUser()->get_granted_base(['canadmin']);
|
||||
$authenticatedUserId = $authenticatedUser->getId();
|
||||
foreach ($registrationRepository->getPendingRegistrations($collections) as $registration) {
|
||||
$user = $registration->getUser();
|
||||
$userRegistrations[$user->getId()]['user'] = $user;
|
||||
$userRegistrations[$user->getId()]['registrations'][$registration->getBaseid()] = $registration;
|
||||
$userId = $user->getId();
|
||||
// Can not handle self registration.
|
||||
if ($authenticatedUserId == $userId) {
|
||||
continue;
|
||||
}
|
||||
if (!isset($userRegistrations[$userId])) {
|
||||
$userRegistrations[$userId] = ['user' => $user, 'registrations' => []];
|
||||
}
|
||||
$userRegistrations[$userId]['registrations'][$registration->getBaseid()] = $registration;
|
||||
}
|
||||
|
||||
return $this->render('admin/user/registrations.html.twig', [
|
||||
|
@@ -338,7 +338,7 @@ class Account implements ControllerProviderInterface
|
||||
*/
|
||||
public function updateAccount(PhraseaApplication $app, Request $request)
|
||||
{
|
||||
$registrations = $request->request->get('registrations');
|
||||
$registrations = $request->request->get('registrations', []);
|
||||
if (false === is_array($registrations)) {
|
||||
$app->abort(400, '"registrations" parameter must be an array of base ids.');
|
||||
}
|
||||
|
@@ -644,7 +644,7 @@ SQL;
|
||||
* Return an instance of native cache query for default ORM
|
||||
* @todo return an instance of NativeQueryProvider for given orm;
|
||||
*/
|
||||
$app['orm.orm.em.native-query'] = $app->share(function ($app) {
|
||||
$app['orm.em.native-query'] = $app->share(function ($app) {
|
||||
return new NativeQueryProvider($app['orm.em']);
|
||||
});
|
||||
|
||||
|
@@ -49,6 +49,29 @@ class RegistrationRepository extends EntityRepository
|
||||
return $qb->getQuery()->getResult();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Current pending registrations.
|
||||
*
|
||||
* @param \collection[] $collections
|
||||
* @return Registration[]
|
||||
*/
|
||||
public function getPendingRegistrations(array $collections)
|
||||
{
|
||||
$builder = $this->createQueryBuilder('r');
|
||||
$builder->where('r.pending = 1');
|
||||
|
||||
if (!empty($collections)) {
|
||||
$builder->andWhere('r.baseId IN (:bases)');
|
||||
$builder->setParameter('bases', array_map(function (\collection $collection) {
|
||||
return $collection->get_base_id();
|
||||
}, $collections));
|
||||
}
|
||||
|
||||
$builder->orderBy('r.created', 'DESC');
|
||||
|
||||
return $builder->getQuery()->getResult();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets registration registrations for a user.
|
||||
*
|
||||
|
Reference in New Issue
Block a user