X-Git-Url: https://git.rapsys.eu/airbundle/blobdiff_plain/f30bae21701a9fed737e81a426e58e76eb193b5e..24c1566e22b2ae6a0840f950748c57a1aa1d3320:/Repository/UserRepository.php diff --git a/Repository/UserRepository.php b/Repository/UserRepository.php index 8660e39..985b3b2 100644 --- a/Repository/UserRepository.php +++ b/Repository/UserRepository.php @@ -25,7 +25,7 @@ class UserRepository extends \Doctrine\ORM\EntityRepository { //Get quoted table names //XXX: this allow to make this code table name independent $tables = [ - 'RapsysAirBundle:GroupUser' => $qs->getJoinTableName($em->getClassMetadata('RapsysAirBundle:User')->getAssociationMapping('groups'), $em->getClassMetadata('RapsysAirBundle:User'), $dp), + 'RapsysAirBundle:UserGroup' => $qs->getJoinTableName($em->getClassMetadata('RapsysAirBundle:User')->getAssociationMapping('groups'), $em->getClassMetadata('RapsysAirBundle:User'), $dp), 'RapsysAirBundle:Group' => $qs->getTableName($em->getClassMetadata('RapsysAirBundle:Group'), $dp), 'RapsysAirBundle:Civility' => $qs->getTableName($em->getClassMetadata('RapsysAirBundle:Civility'), $dp), 'RapsysAirBundle:User' => $qs->getTableName($em->getClassMetadata('RapsysAirBundle:User'), $dp) @@ -36,7 +36,7 @@ class UserRepository extends \Doctrine\ORM\EntityRepository { SELECT u.id, u.forename, u.surname, t.id AS t_id, t.short AS t_short, t.title AS t_title, g.id AS g_id, g.title AS g_title FROM RapsysAirBundle:User AS u JOIN RapsysAirBundle:Civility AS t ON (t.id = u.civility_id) - LEFT JOIN RapsysAirBundle:GroupUser AS gu ON (gu.user_id = u.id) + LEFT JOIN RapsysAirBundle:UserGroup AS gu ON (gu.user_id = u.id) LEFT JOIN RapsysAirBundle:Group AS g ON (g.id = gu.group_id) ORDER BY g.id DESC, NULL LIMIT '.PHP_INT_MAX.' ) AS a GROUP BY a.id ORDER BY NULL'; @@ -140,7 +140,7 @@ class UserRepository extends \Doctrine\ORM\EntityRepository { //Get quoted table names //XXX: this allow to make this code table name independent $tables = [ - 'RapsysAirBundle:GroupUser' => $qs->getJoinTableName($em->getClassMetadata('RapsysAirBundle:User')->getAssociationMapping('groups'), $em->getClassMetadata('RapsysAirBundle:User'), $dp), + 'RapsysAirBundle:UserGroup' => $qs->getJoinTableName($em->getClassMetadata('RapsysAirBundle:User')->getAssociationMapping('groups'), $em->getClassMetadata('RapsysAirBundle:User'), $dp), 'RapsysAirBundle:Group' => $qs->getTableName($em->getClassMetadata('RapsysAirBundle:Group'), $dp), 'RapsysAirBundle:User' => $qs->getTableName($em->getClassMetadata('RapsysAirBundle:User'), $dp), //XXX: Set limit used to workaround mariadb subselect optimization @@ -151,17 +151,11 @@ class UserRepository extends \Doctrine\ORM\EntityRepository { //Set the request $req = <<addScalarResult('id', 'id', 'integer') + ->addScalarResult('mail', 'mail', 'string') ->addScalarResult('pseudonym', 'pseudonym', 'string') ->addScalarResult('g_id', 'g_id', 'integer') - ->addScalarResult('g_title', 'g_title', 'string') - ->addIndexByScalar('id'); + ->addScalarResult('g_title', 'g_title', 'string'); //Fetch result $res = $em @@ -191,7 +185,7 @@ SQL; //Process result foreach($res as $data) { //Get translated group - $group = $translator->trans($data['g_title']?:'User'); + $group = $translator->trans($data['g_title']); //Init group subarray if (!isset($ret[$group])) { @@ -199,7 +193,10 @@ SQL; } //Set data - $ret[$group][$data['id']] = $data['pseudonym']; + $ret[$group][$data['id']] = [ + 'mail' => $data['mail'], + 'pseudonym' => $data['pseudonym'] + ]; } //Send result