X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FUserBundle%2FRepository%2FUserRepository.php;h=b1d753d2f42e97d2b1e016f45a87cc5ee546ec61;hb=f808b01692a835673f328d7221ba8c212caa9b61;hp=009c4881d0ea8945379e159894f00b4ca51a1f2d;hpb=a7f1921f7db312b5def3839393357f443dcbb52c;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/UserBundle/Repository/UserRepository.php b/src/Wallabag/UserBundle/Repository/UserRepository.php index 009c4881..b1d753d2 100644 --- a/src/Wallabag/UserBundle/Repository/UserRepository.php +++ b/src/Wallabag/UserBundle/Repository/UserRepository.php @@ -38,4 +38,31 @@ class UserRepository extends EntityRepository ->getQuery() ->getSingleResult(); } + + /** + * Count how many users are enabled. + * + * @return int + */ + public function getSumEnabledUsers() + { + return $this->createQueryBuilder('u') + ->select('count(u)') + ->andWhere('u.enabled = true') + ->getQuery() + ->getSingleScalarResult(); + } + + /** + * Retrieves users filtered with a search term. + * + * @param string $term + * + * @return QueryBuilder + */ + public function getQueryBuilderForSearch($term) + { + return $this->createQueryBuilder('u') + ->andWhere('lower(u.username) LIKE lower(:term) OR lower(u.email) LIKE lower(:term) OR lower(u.name) LIKE lower(:term)')->setParameter('term', '%' . $term . '%'); + } }