mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-12 20:43:25 +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 = [];
|
$userRegistrations = [];
|
||||||
/** @var RegistrationRepository $registrationRepository */
|
/** @var RegistrationRepository $registrationRepository */
|
||||||
$registrationRepository = $this->app['repo.registrations'];
|
$registrationRepository = $this->app['repo.registrations'];
|
||||||
foreach (
|
$collections = $this->getAclForConnectedUser()->get_granted_base(['canadmin']);
|
||||||
$registrationRepository->getUserRegistrations(
|
$authenticatedUserId = $authenticatedUser->getId();
|
||||||
$authenticatedUser,
|
foreach ($registrationRepository->getPendingRegistrations($collections) as $registration) {
|
||||||
$this->getAclForConnectedUser()->get_granted_base(['canadmin'])
|
|
||||||
) as $registration) {
|
|
||||||
$user = $registration->getUser();
|
$user = $registration->getUser();
|
||||||
$userRegistrations[$user->getId()]['user'] = $user;
|
$userId = $user->getId();
|
||||||
$userRegistrations[$user->getId()]['registrations'][$registration->getBaseid()] = $registration;
|
// 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', [
|
return $this->render('admin/user/registrations.html.twig', [
|
||||||
|
@@ -644,7 +644,7 @@ SQL;
|
|||||||
* Return an instance of native cache query for default ORM
|
* Return an instance of native cache query for default ORM
|
||||||
* @todo return an instance of NativeQueryProvider for given 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']);
|
return new NativeQueryProvider($app['orm.em']);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -49,6 +49,29 @@ class RegistrationRepository extends EntityRepository
|
|||||||
return $qb->getQuery()->getResult();
|
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.
|
* Gets registration registrations for a user.
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user