| Total Complexity | 117 |
| Total Lines | 1431 |
| Duplicated Lines | 0 % |
| Changes | 3 | ||
| Bugs | 0 | Features | 0 |
Complex classes like UserRepository often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use UserRepository, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 68 | class UserRepository extends ResourceRepository implements UserLoaderInterface, PasswordUpgraderInterface |
||
| 69 | { |
||
| 70 | /** |
||
| 71 | * @var UserPasswordEncoderInterface |
||
| 72 | */ |
||
| 73 | protected $encoder; |
||
| 74 | |||
| 75 | public function setEncoder(UserPasswordEncoderInterface $encoder) |
||
| 76 | { |
||
| 77 | $this->encoder = $encoder; |
||
| 78 | } |
||
| 79 | |||
| 80 | public function loadUserByUsername($username): ?User |
||
| 81 | { |
||
| 82 | return $this->findBy(['username' => $username]); |
||
| 83 | } |
||
| 84 | |||
| 85 | public function updateUser($user, $andFlush = true) |
||
| 86 | { |
||
| 87 | $this->updateCanonicalFields($user); |
||
| 88 | $this->updatePassword($user); |
||
| 89 | $this->getEntityManager()->persist($user); |
||
| 90 | if ($andFlush) { |
||
| 91 | $this->getEntityManager()->flush(); |
||
| 92 | } |
||
| 93 | } |
||
| 94 | |||
| 95 | public function canonicalize($string) |
||
| 96 | { |
||
| 97 | $encoding = mb_detect_encoding($string); |
||
| 98 | |||
| 99 | return $encoding |
||
| 100 | ? mb_convert_case($string, MB_CASE_LOWER, $encoding) |
||
| 101 | : mb_convert_case($string, MB_CASE_LOWER); |
||
| 102 | } |
||
| 103 | |||
| 104 | public function updateCanonicalFields(UserInterface $user) |
||
| 105 | { |
||
| 106 | $user->setUsernameCanonical($this->canonicalize($user->getUsername())); |
||
| 107 | $user->setEmailCanonical($this->canonicalize($user->getEmail())); |
||
| 108 | } |
||
| 109 | |||
| 110 | public function updatePassword(UserInterface $user) |
||
| 117 | // $encoder = $this->getEncoder($user); |
||
| 118 | //$user->setPassword($encoder->encodePassword($password, $user->getSalt())); |
||
| 119 | //$user->eraseCredentials(); |
||
| 120 | } |
||
| 121 | } |
||
| 122 | |||
| 123 | public function upgradePassword(UserInterface $user, string $newEncodedPassword): void |
||
| 124 | { |
||
| 125 | // this code is only an example; the exact code will depend on |
||
| 126 | // your own application needs |
||
| 127 | $user->setPassword($newEncodedPassword); |
||
| 128 | $this->getEntityManager()->persist($user); |
||
| 129 | $this->getEntityManager()->flush(); |
||
| 130 | } |
||
| 131 | |||
| 132 | public function getRootUser(): User |
||
| 133 | { |
||
| 134 | $qb = $this->getRepository()->createQueryBuilder('u'); |
||
| 135 | $qb |
||
| 136 | ->innerJoin( |
||
| 137 | 'u.resourceNode', |
||
| 138 | 'r' |
||
| 139 | ); |
||
| 140 | $qb->where('r.creator = u'); |
||
| 141 | $qb->andWhere('r.parent IS NULL'); |
||
| 142 | $qb->getFirstResult(); |
||
| 143 | |||
| 144 | $rootUser = $qb->getQuery()->getSingleResult(); |
||
| 145 | |||
| 146 | if (null === $rootUser) { |
||
| 147 | throw new UsernameNotFoundException('Root user not found'); |
||
| 148 | } |
||
| 149 | |||
| 150 | return $rootUser; |
||
| 151 | } |
||
| 152 | |||
| 153 | public function deleteUser(User $user) |
||
| 154 | { |
||
| 155 | $em = $this->getEntityManager(); |
||
| 156 | $type = $user->getResourceNode()->getResourceType(); |
||
| 157 | $rootUser = $this->getRootUser(); |
||
| 158 | |||
| 159 | // User children will be set to the root user. |
||
| 160 | $criteria = Criteria::create()->where(Criteria::expr()->eq('resourceType', $type)); |
||
| 161 | $userNodeCreatedList = $user->getResourceNodes()->matching($criteria); |
||
| 162 | /** @var ResourceNode $userCreated */ |
||
| 163 | foreach ($userNodeCreatedList as $userCreated) { |
||
| 164 | $userCreated->setCreator($rootUser); |
||
| 165 | } |
||
| 166 | |||
| 167 | $em->remove($user->getResourceNode()); |
||
| 168 | |||
| 169 | foreach ($user->getGroups() as $group) { |
||
| 170 | $user->removeGroup($group); |
||
| 171 | } |
||
| 172 | |||
| 173 | $em->remove($user); |
||
| 174 | $em->flush(); |
||
| 175 | } |
||
| 176 | |||
| 177 | public function addUserToResourceNode(int $userId, int $creatorId): ResourceNode |
||
| 178 | { |
||
| 179 | /** @var User $user */ |
||
| 180 | $user = $this->find($userId); |
||
| 181 | $creator = $this->find($creatorId); |
||
| 182 | |||
| 183 | $resourceNode = new ResourceNode(); |
||
| 184 | $resourceNode |
||
| 185 | ->setTitle($user->getUsername()) |
||
| 186 | ->setCreator($creator) |
||
| 187 | ->setResourceType($this->getResourceType()) |
||
| 188 | //->setParent($resourceNode) |
||
| 189 | ; |
||
| 190 | |||
| 191 | $user->setResourceNode($resourceNode); |
||
| 192 | |||
| 193 | $this->getEntityManager()->persist($resourceNode); |
||
| 194 | $this->getEntityManager()->persist($user); |
||
| 195 | |||
| 196 | return $resourceNode; |
||
| 197 | } |
||
| 198 | |||
| 199 | public function findByUsername(string $username): ?User |
||
| 200 | { |
||
| 201 | $user = $this->repository->findOneBy(['username' => $username]); |
||
| 202 | |||
| 203 | if (null === $user) { |
||
| 204 | throw new UsernameNotFoundException(sprintf("User with id '%s' not found.", $username)); |
||
| 205 | } |
||
| 206 | |||
| 207 | return $user; |
||
| 208 | } |
||
| 209 | |||
| 210 | /** |
||
| 211 | * @param string $role |
||
| 212 | * |
||
| 213 | * @return array |
||
| 214 | */ |
||
| 215 | public function findByRole($role) |
||
| 216 | { |
||
| 217 | $em = $this->repository->getEntityManager(); |
||
| 218 | $qb = $em->createQueryBuilder(); |
||
| 219 | |||
| 220 | $qb->select('u') |
||
| 221 | ->from($this->_entityName, 'u') |
||
| 222 | ->where('u.roles LIKE :roles') |
||
| 223 | ->setParameter('roles', '%"'.$role.'"%'); |
||
| 224 | |||
| 225 | return $qb->getQuery()->getResult(); |
||
| 226 | } |
||
| 227 | |||
| 228 | /** |
||
| 229 | * @param string $keyword |
||
| 230 | */ |
||
| 231 | public function searchUserByKeyword($keyword) |
||
| 250 | } |
||
| 251 | |||
| 252 | /** |
||
| 253 | * Get course user relationship based in the course_rel_user table. |
||
| 254 | * |
||
| 255 | * @return Course[] |
||
| 256 | */ |
||
| 257 | public function getCourses(User $user, AccessUrl $url, int $status, $keyword = '') |
||
| 258 | { |
||
| 259 | $qb = $this->repository->createQueryBuilder('user'); |
||
| 260 | |||
| 261 | $qb |
||
| 262 | ->select('DISTINCT course') |
||
| 263 | //->addSelect('user.courses') |
||
| 264 | ->innerJoin( |
||
| 265 | CourseRelUser::class, |
||
| 266 | 'courseRelUser', |
||
| 267 | Join::WITH, |
||
| 268 | 'user = courseRelUser.user' |
||
| 269 | ) |
||
| 270 | ->innerJoin('courseRelUser.course', 'course') |
||
| 271 | ->innerJoin('course.urls', 'accessUrlRelCourse') |
||
| 272 | ->innerJoin('accessUrlRelCourse.url', 'url') |
||
| 273 | ->where('user = :user') |
||
| 274 | ->andWhere('url = :url') |
||
| 275 | ->andWhere('courseRelUser.status = :status') |
||
| 276 | ->setParameters(['user' => $user, 'url' => $url, 'status' => $status]) |
||
| 277 | ->addSelect('courseRelUser'); |
||
| 278 | |||
| 279 | if (!empty($keyword)) { |
||
| 280 | $qb |
||
| 281 | ->andWhere('course.title like = :keyword') |
||
| 282 | ->setParameter('keyword', $keyword); |
||
| 283 | } |
||
| 284 | |||
| 285 | $qb->add('orderBy', 'course.title DESC'); |
||
| 286 | |||
| 287 | $query = $qb->getQuery(); |
||
| 288 | |||
| 289 | return $query->getResult(); |
||
| 290 | } |
||
| 291 | |||
| 292 | /* |
||
| 293 | public function getTeachers() |
||
| 294 | { |
||
| 295 | $queryBuilder = $this->repository->createQueryBuilder('u'); |
||
| 296 | |||
| 297 | // Selecting course info. |
||
| 298 | $queryBuilder |
||
| 299 | ->select('u') |
||
| 300 | ->where('u.groups.id = :groupId') |
||
| 301 | ->setParameter('groupId', 1); |
||
| 302 | |||
| 303 | $query = $queryBuilder->getQuery(); |
||
| 304 | |||
| 305 | return $query->execute(); |
||
| 306 | }*/ |
||
| 307 | |||
| 308 | /*public function getUsers($group) |
||
| 309 | { |
||
| 310 | $queryBuilder = $this->repository->createQueryBuilder('u'); |
||
| 311 | |||
| 312 | // Selecting course info. |
||
| 313 | $queryBuilder |
||
| 314 | ->select('u') |
||
| 315 | ->where('u.groups = :groupId') |
||
| 316 | ->setParameter('groupId', $group); |
||
| 317 | |||
| 318 | $query = $queryBuilder->getQuery(); |
||
| 319 | |||
| 320 | return $query->execute(); |
||
| 321 | }*/ |
||
| 322 | |||
| 323 | /** |
||
| 324 | * Get a filtered list of user by status and (optionally) access url. |
||
| 325 | * |
||
| 326 | * @todo not use status |
||
| 327 | * |
||
| 328 | * @param string $query The query to filter |
||
| 329 | * @param int $status The status |
||
| 330 | * @param int $accessUrlId The access URL ID |
||
| 331 | * |
||
| 332 | * @return array |
||
| 333 | */ |
||
| 334 | public function findByStatus($query, $status, $accessUrlId = null) |
||
| 335 | { |
||
| 336 | $accessUrlId = (int) $accessUrlId; |
||
| 337 | $queryBuilder = $this->repository->createQueryBuilder('u'); |
||
| 338 | |||
| 339 | if ($accessUrlId > 0) { |
||
| 340 | $queryBuilder->innerJoin( |
||
| 341 | 'ChamiloCoreBundle:AccessUrlRelUser', |
||
| 342 | 'auru', |
||
| 343 | Join::WITH, |
||
| 344 | 'u.id = auru.user' |
||
| 345 | ); |
||
| 346 | } |
||
| 347 | |||
| 348 | $queryBuilder->where('u.status = :status') |
||
| 349 | ->andWhere('u.username LIKE :query OR u.firstname LIKE :query OR u.lastname LIKE :query') |
||
| 350 | ->setParameter('status', $status) |
||
| 351 | ->setParameter('query', "$query%"); |
||
| 352 | |||
| 353 | if ($accessUrlId > 0) { |
||
| 354 | $queryBuilder->andWhere('auru.url = :url') |
||
| 355 | ->setParameter(':url', $accessUrlId); |
||
| 356 | } |
||
| 357 | |||
| 358 | return $queryBuilder->getQuery()->getResult(); |
||
| 359 | } |
||
| 360 | |||
| 361 | /** |
||
| 362 | * Get the coaches for a course within a session. |
||
| 363 | * |
||
| 364 | * @param Session $session The session |
||
| 365 | * @param Course $course The course |
||
| 366 | * |
||
| 367 | * @return \Doctrine\ORM\QueryBuilder |
||
| 368 | */ |
||
| 369 | public function getCoachesForSessionCourse(Session $session, Course $course) |
||
| 370 | { |
||
| 371 | $queryBuilder = $this->repository->createQueryBuilder('u'); |
||
| 372 | |||
| 373 | $queryBuilder->select('u') |
||
| 374 | ->innerJoin( |
||
| 375 | 'ChamiloCoreBundle:SessionRelCourseRelUser', |
||
| 376 | 'scu', |
||
| 377 | Join::WITH, |
||
| 378 | 'scu.user = u' |
||
| 379 | ) |
||
| 380 | ->where( |
||
| 381 | $queryBuilder->expr()->andX( |
||
| 382 | $queryBuilder->expr()->eq('scu.session', $session->getId()), |
||
| 383 | $queryBuilder->expr()->eq('scu.course', $course->getId()), |
||
| 384 | $queryBuilder->expr()->eq('scu.status', SessionRelCourseRelUser::STATUS_COURSE_COACH) |
||
| 385 | ) |
||
| 386 | ); |
||
| 387 | |||
| 388 | return $queryBuilder->getQuery()->getResult(); |
||
| 389 | } |
||
| 390 | |||
| 391 | /** |
||
| 392 | * Get course user relationship based in the course_rel_user table. |
||
| 393 | * |
||
| 394 | * @return array |
||
| 395 | */ |
||
| 396 | /*public function getCourses(User $user) |
||
| 397 | { |
||
| 398 | $queryBuilder = $this->createQueryBuilder('user'); |
||
| 399 | |||
| 400 | // Selecting course info. |
||
| 401 | $queryBuilder->select('c'); |
||
| 402 | |||
| 403 | // Loading User. |
||
| 404 | //$qb->from('Chamilo\CoreBundle\Entity\User', 'u'); |
||
| 405 | |||
| 406 | // Selecting course |
||
| 407 | $queryBuilder->innerJoin('Chamilo\CoreBundle\Entity\Course', 'c'); |
||
| 408 | |||
| 409 | //@todo check app settings |
||
| 410 | //$qb->add('orderBy', 'u.lastname ASC'); |
||
| 411 | |||
| 412 | $wherePart = $queryBuilder->expr()->andx(); |
||
| 413 | |||
| 414 | // Get only users subscribed to this course |
||
| 415 | $wherePart->add($queryBuilder->expr()->eq('user.userId', $user->getUserId())); |
||
| 416 | |||
| 417 | $queryBuilder->where($wherePart); |
||
| 418 | $query = $queryBuilder->getQuery(); |
||
| 419 | |||
| 420 | return $query->execute(); |
||
| 421 | } |
||
| 422 | |||
| 423 | public function getTeachers() |
||
| 424 | { |
||
| 425 | $queryBuilder = $this->createQueryBuilder('u'); |
||
| 426 | |||
| 427 | // Selecting course info. |
||
| 428 | $queryBuilder |
||
| 429 | ->select('u') |
||
| 430 | ->where('u.groups.id = :groupId') |
||
| 431 | ->setParameter('groupId', 1); |
||
| 432 | |||
| 433 | $query = $queryBuilder->getQuery(); |
||
| 434 | |||
| 435 | return $query->execute(); |
||
| 436 | }*/ |
||
| 437 | |||
| 438 | /*public function getUsers($group) |
||
| 439 | { |
||
| 440 | $queryBuilder = $this->createQueryBuilder('u'); |
||
| 441 | |||
| 442 | // Selecting course info. |
||
| 443 | $queryBuilder |
||
| 444 | ->select('u') |
||
| 445 | ->where('u.groups = :groupId') |
||
| 446 | ->setParameter('groupId', $group); |
||
| 447 | |||
| 448 | $query = $queryBuilder->getQuery(); |
||
| 449 | |||
| 450 | return $query->execute(); |
||
| 451 | }*/ |
||
| 452 | |||
| 453 | /** |
||
| 454 | * Get the sessions admins for a user. |
||
| 455 | * |
||
| 456 | * @return array |
||
| 457 | */ |
||
| 458 | public function getSessionAdmins(User $user) |
||
| 459 | { |
||
| 460 | $queryBuilder = $this->repository->createQueryBuilder('u'); |
||
| 461 | $queryBuilder |
||
| 462 | ->distinct() |
||
| 463 | ->innerJoin( |
||
| 464 | 'ChamiloCoreBundle:SessionRelUser', |
||
| 465 | 'su', |
||
| 466 | Join::WITH, |
||
| 467 | $queryBuilder->expr()->eq('u', 'su.user') |
||
| 468 | ) |
||
| 469 | ->innerJoin( |
||
| 470 | 'ChamiloCoreBundle:SessionRelCourseRelUser', |
||
| 471 | 'scu', |
||
| 472 | Join::WITH, |
||
| 473 | $queryBuilder->expr()->eq('su.session', 'scu.session') |
||
| 474 | ) |
||
| 475 | ->where( |
||
| 476 | $queryBuilder->expr()->eq('scu.user', $user->getId()) |
||
| 477 | ) |
||
| 478 | ->andWhere( |
||
| 479 | $queryBuilder->expr()->eq('su.relationType', SESSION_RELATION_TYPE_RRHH) |
||
| 480 | ) |
||
| 481 | ; |
||
| 482 | |||
| 483 | return $queryBuilder->getQuery()->getResult(); |
||
| 484 | } |
||
| 485 | |||
| 486 | /** |
||
| 487 | * Get the student bosses for a user. |
||
| 488 | * |
||
| 489 | * @return array |
||
| 490 | */ |
||
| 491 | public function getStudentBosses(User $user) |
||
| 492 | { |
||
| 493 | $queryBuilder = $this->repository->createQueryBuilder('u'); |
||
| 494 | $queryBuilder |
||
| 495 | ->distinct() |
||
| 496 | ->innerJoin( |
||
| 497 | 'ChamiloCoreBundle:UserRelUser', |
||
| 498 | 'uu', |
||
| 499 | Join::WITH, |
||
| 500 | $queryBuilder->expr()->eq('u.id', 'uu.friendUserId') |
||
| 501 | ) |
||
| 502 | ->where( |
||
| 503 | $queryBuilder->expr()->eq('uu.relationType', USER_RELATION_TYPE_BOSS) |
||
| 504 | ) |
||
| 505 | ->andWhere( |
||
| 506 | $queryBuilder->expr()->eq('uu.userId', $user->getId()) |
||
| 507 | ); |
||
| 508 | |||
| 509 | return $queryBuilder->getQuery()->getResult(); |
||
| 510 | } |
||
| 511 | |||
| 512 | /** |
||
| 513 | * Get number of users in URL. |
||
| 514 | * |
||
| 515 | * @return int |
||
| 516 | */ |
||
| 517 | public function getCountUsersByUrl(AccessUrl $url) |
||
| 518 | { |
||
| 519 | return $this->repository->createQueryBuilder('a') |
||
| 520 | ->select('COUNT(a)') |
||
| 521 | ->innerJoin('a.portals', 'u') |
||
| 522 | ->where('u.portal = :u') |
||
| 523 | ->setParameters(['u' => $url]) |
||
| 524 | ->getQuery() |
||
| 525 | ->getSingleScalarResult(); |
||
| 526 | } |
||
| 527 | |||
| 528 | /** |
||
| 529 | * Get number of users in URL. |
||
| 530 | * |
||
| 531 | * @return int |
||
| 532 | */ |
||
| 533 | public function getCountTeachersByUrl(AccessUrl $url) |
||
| 534 | { |
||
| 535 | $qb = $this->repository->createQueryBuilder('a'); |
||
| 536 | |||
| 537 | return $qb |
||
| 538 | ->select('COUNT(a)') |
||
| 539 | ->innerJoin('a.portals', 'u') |
||
| 540 | ->where('u.portal = :u') |
||
| 541 | ->andWhere($qb->expr()->in('a.roles', ['ROLE_TEACHER'])) |
||
| 542 | ->setParameters(['u' => $url]) |
||
| 543 | ->getQuery() |
||
| 544 | ->getSingleScalarResult() |
||
| 545 | ; |
||
| 546 | } |
||
| 547 | |||
| 548 | /** |
||
| 549 | * Find potential users to send a message. |
||
| 550 | * |
||
| 551 | * @param int $currentUserId The current user ID |
||
| 552 | * @param string $searchFilter Optional. The search text to filter the user list |
||
| 553 | * @param int $limit Optional. Sets the maximum number of results to retrieve |
||
| 554 | */ |
||
| 555 | public function findUsersToSendMessage($currentUserId, $searchFilter = null, $limit = 10) |
||
| 556 | { |
||
| 557 | $allowSendMessageToAllUsers = api_get_setting('allow_send_message_to_all_platform_users'); |
||
| 558 | $accessUrlId = api_get_multiple_access_url() ? api_get_current_access_url_id() : 1; |
||
| 559 | |||
| 560 | if ('true' === api_get_setting('allow_social_tool') && |
||
| 561 | 'true' === api_get_setting('allow_message_tool') |
||
| 562 | ) { |
||
| 563 | // All users |
||
| 564 | if ('true' === $allowSendMessageToAllUsers || api_is_platform_admin()) { |
||
| 565 | $dql = "SELECT DISTINCT U |
||
| 566 | FROM ChamiloCoreBundle:User U |
||
| 567 | LEFT JOIN ChamiloCoreBundle:AccessUrlRelUser R |
||
| 568 | WITH U = R.user |
||
| 569 | WHERE |
||
| 570 | U.active = 1 AND |
||
| 571 | U.status != 6 AND |
||
| 572 | U.id != $currentUserId AND |
||
| 573 | R.url = $accessUrlId"; |
||
| 574 | } else { |
||
| 575 | $dql = 'SELECT DISTINCT U |
||
| 576 | FROM ChamiloCoreBundle:AccessUrlRelUser R, ChamiloCoreBundle:UserRelUser UF |
||
| 577 | INNER JOIN ChamiloCoreBundle:User AS U |
||
| 578 | WITH UF.friendUserId = U |
||
| 579 | WHERE |
||
| 580 | U.active = 1 AND |
||
| 581 | U.status != 6 AND |
||
| 582 | UF.relationType NOT IN('.USER_RELATION_TYPE_DELETED.', '.USER_RELATION_TYPE_RRHH.") AND |
||
| 583 | UF.userId = $currentUserId AND |
||
| 584 | UF.friendUserId != $currentUserId AND |
||
| 585 | U = R.user AND |
||
| 586 | R.url = $accessUrlId"; |
||
| 587 | } |
||
| 588 | } elseif ( |
||
| 589 | 'false' === api_get_setting('allow_social_tool') && |
||
| 590 | 'true' === api_get_setting('allow_message_tool') |
||
| 591 | ) { |
||
| 592 | if ('true' === $allowSendMessageToAllUsers) { |
||
| 593 | $dql = "SELECT DISTINCT U |
||
| 594 | FROM ChamiloCoreBundle:User U |
||
| 595 | LEFT JOIN ChamiloCoreBundle:AccessUrlRelUser R |
||
| 596 | WITH U = R.user |
||
| 597 | WHERE |
||
| 598 | U.active = 1 AND |
||
| 599 | U.status != 6 AND |
||
| 600 | U.id != $currentUserId AND |
||
| 601 | R.url = $accessUrlId"; |
||
| 602 | } else { |
||
| 603 | $time_limit = api_get_setting('time_limit_whosonline'); |
||
| 604 | $online_time = time() - $time_limit * 60; |
||
| 605 | $limit_date = api_get_utc_datetime($online_time); |
||
| 606 | $dql = "SELECT DISTINCT U |
||
| 607 | FROM ChamiloCoreBundle:User U |
||
| 608 | INNER JOIN ChamiloCoreBundle:TrackEOnline T |
||
| 609 | WITH U.id = T.loginUserId |
||
| 610 | WHERE |
||
| 611 | U.active = 1 AND |
||
| 612 | T.loginDate >= '".$limit_date."'"; |
||
| 613 | } |
||
| 614 | } |
||
| 615 | |||
| 616 | $parameters = []; |
||
| 617 | |||
| 618 | if (!empty($searchFilter)) { |
||
| 619 | $dql .= ' AND (U.firstname LIKE :search OR U.lastname LIKE :search OR U.email LIKE :search OR U.username LIKE :search)'; |
||
|
|
|||
| 620 | $parameters['search'] = "%$searchFilter%"; |
||
| 621 | } |
||
| 622 | |||
| 623 | return $this->getEntityManager() |
||
| 624 | ->createQuery($dql) |
||
| 625 | ->setMaxResults($limit) |
||
| 626 | ->setParameters($parameters) |
||
| 627 | ->getResult(); |
||
| 628 | } |
||
| 629 | |||
| 630 | /** |
||
| 631 | * Get the list of HRM who have assigned this user. |
||
| 632 | * |
||
| 633 | * @param int $userId |
||
| 634 | * @param int $urlId |
||
| 635 | * |
||
| 636 | * @return array |
||
| 637 | */ |
||
| 638 | public function getAssignedHrmUserList($userId, $urlId) |
||
| 657 | } |
||
| 658 | |||
| 659 | /** |
||
| 660 | * Serialize the whole entity to an array. |
||
| 661 | * |
||
| 662 | * @param int $userId |
||
| 663 | * @param array $substitutionTerms Substitute terms for some elements |
||
| 664 | * |
||
| 665 | * @return string |
||
| 666 | */ |
||
| 667 | public function getPersonalDataToJson($userId, array $substitutionTerms) |
||
| 1473 | } |
||
| 1474 | |||
| 1475 | /** |
||
| 1476 | * Get the last login from the track_e_login table. |
||
| 1477 | * This might be different from user.last_login in the case of legacy users |
||
| 1478 | * as user.last_login was only implemented in 1.10 version with a default |
||
| 1479 | * value of NULL (not the last record from track_e_login). |
||
| 1480 | * |
||
| 1481 | * @throws \Exception |
||
| 1482 | * |
||
| 1483 | * @return TrackELogin|null |
||
| 1484 | */ |
||
| 1485 | public function getLastLogin(User $user) |
||
| 1501 |