mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-12 12:33:26 +00:00
Display registration should use pending Registrations.
fixes 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', [
|
||||
|
@@ -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