private function buildGroup($name)
 {
     $group = new Group();
     $group->setName($name);
     $this->om->persist($group);
     return $group;
 }
Beispiel #2
0
 public function group($name)
 {
     $group = new Group();
     $group->setGuid($this->container->get('claroline.utilities.misc')->generateGuid());
     $group->setName($name);
     $this->om->persist($group);
     return $group;
 }
Beispiel #3
0
 public function load(ObjectManager $manager)
 {
     $groupManager = $this->container->get('claroline.manager.group_manager');
     foreach ($this->groups as $properties) {
         $group = new Group();
         $group->setName($properties['name']);
         $role = $manager->getRepository('ClarolineCoreBundle:Role')->findOneByName($properties['role']);
         $group->addRole($role);
         $groupManager->insertGroup($group);
     }
 }
 public function findSessionGroupsByGroup(Group $group, $executeQuery = true)
 {
     $dql = '
         SELECT csg
         FROM Claroline\\CursusBundle\\Entity\\CourseSessionGroup csg
         JOIN csg.group g
         WHERE g.name = :group
         ORDER BY csg.registrationDate DESC
     ';
     $query = $this->_em->createQuery($dql);
     $query->setParameter('group', $group->getName());
     return $executeQuery ? $query->getResult() : $query;
 }
Beispiel #5
0
 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     foreach ($this->groups as $name => $users) {
         $group = new Group();
         $group->setName($name);
         foreach ($users as $username) {
             $user = $this->getReference('user/' . $username);
             $group->addUser($user);
         }
         $manager->persist($group);
         $this->addReference('group/' . $name, $group);
     }
     $manager->flush();
 }
 /**
  * Returns the users who are not members of a group and whose first name, last
  * name or username match a given search string.
  *
  * @param \Claroline\CoreBundle\Entity\Group $group
  * @param string                             $search
  * @param bool                               $executeQuery
  * @param string                             $orderedBy
  *
  * @return User[]|Query
  *
  * @todo Find out why the join on profile preferences is necessary
  */
 public function findGroupOutsidersByName(Group $group, $search, $executeQuery = true, $orderedBy = 'id')
 {
     $dql = "\n            SELECT DISTINCT u FROM Claroline\\CoreBundle\\Entity\\User u\n            WHERE (\n                UPPER(u.lastName) LIKE :search\n                OR UPPER(u.firstName) LIKE :search\n                OR UPPER(u.lastName) LIKE :search\n            )\n            AND u NOT IN (\n                SELECT us FROM Claroline\\CoreBundle\\Entity\\User us\n                JOIN us.groups gr\n                WHERE gr.id = :groupId\n            )\n            AND u.isRemoved = false\n            ORDER BY u.{$orderedBy}\n        ";
     $search = strtoupper($search);
     $query = $this->_em->createQuery($dql);
     $query->setParameter('groupId', $group->getId());
     $query->setParameter('search', "%{$search}%");
     return $executeQuery ? $query->getResult() : $query;
 }
Beispiel #7
0
    public function countUsersOfGroupByRole(Group $group, Role $role)
    {
        $dql = '
            SELECT count(u) FROM Claroline\\CoreBundle\\Entity\\User u
            JOIN u.groups g
            WHERE g.name = :groupName
            AND u.id in
                (
                    SELECT u2.id FROM Claroline\\CoreBundle\\Entity\\User u2
                    LEFT JOIN u2.roles r1
                    LEFT JOIN u2.groups g2
                    LEFT JOIN g2.roles r2
                    WHERE r1.name = :roleName
                    OR r2.name = :roleName
                )

        ';
        $query = $this->_em->createQuery($dql);
        $query->setParameter('roleName', $role->getName());
        $query->setParameter('groupName', $group->getName());
        return $query->getSingleScalarResult();
    }
Beispiel #8
0
 public function validateAddUsersToGroup(array $users, Group $group)
 {
     $countToRegister = count($users);
     $roles = $group->getPlatformRoles();
     foreach ($roles as $role) {
         $max = $role->getMaxUsers();
         $countRegistered = $this->om->getRepository('ClarolineCoreBundle:User')->countUsersByRoleIncludingGroup($role);
         if ($max < $countRegistered + $countToRegister) {
             return false;
         }
     }
     return true;
 }
 /**
  * @EXT\Route(
  *     "/form/group/{group}",
  *     name="claro_message_form_for_group"
  * )
  *
  * Displays the message form with the "to" field filled with users of a group.
  *
  * @param Group $group
  *
  * @return Response
  */
 public function formForGroupAction(Group $group)
 {
     $url = $this->router->generate('claro_message_show', ['message' => 0]) . '?grpsIds[]=' . $group->getId();
     return new RedirectResponse($url);
 }
Beispiel #10
0
 private function isOrganizationManager(TokenInterface $token, Group $group)
 {
     $adminOrganizations = $token->getUser()->getAdministratedOrganizations();
     $groupOrganizations = $group->getOrganizations();
     foreach ($adminOrganizations as $adminOrganization) {
         foreach ($groupOrganizations as $groupOrganization) {
             if ($groupOrganization === $adminOrganization) {
                 return true;
             }
         }
     }
     return false;
 }
Beispiel #11
0
 public function registerGroupToSessions(array $sessions, Group $group, $type = 0)
 {
     $registrationDate = new \DateTime();
     $this->om->startFlushSuite();
     foreach ($sessions as $session) {
         $users = $group->getUsers()->toArray();
         $sessionGroup = $this->sessionGroupRepo->findOneSessionGroupBySessionAndGroup($session, $group, $type);
         if (is_null($sessionGroup)) {
             $sessionGroup = new CourseSessionGroup();
             $sessionGroup->setSession($session);
             $sessionGroup->setGroup($group);
             $sessionGroup->setGroupType($type);
             $sessionGroup->setRegistrationDate($registrationDate);
             $this->om->persist($sessionGroup);
         }
         foreach ($users as $user) {
             $sessionUser = $this->sessionUserRepo->findOneSessionUserBySessionAndUserAndType($session, $user, $type);
             if (is_null($sessionUser)) {
                 $sessionUser = new CourseSessionUser();
                 $sessionUser->setSession($session);
                 $sessionUser->setUser($user);
                 $sessionUser->setUserType($type);
                 $sessionUser->setRegistrationDate($registrationDate);
                 $this->om->persist($sessionUser);
             }
         }
         $role = null;
         if (intval($type) === 0) {
             $role = $session->getLearnerRole();
         } elseif (intval($type) === 1) {
             $role = $session->getTutorRole();
         }
         if (!is_null($role)) {
             $this->roleManager->associateRole($group, $role);
         }
     }
     $this->om->endFlushSuite();
 }
Beispiel #12
0
 public function findByGroupAndWorkspace(Group $group, Workspace $workspace)
 {
     $dql = "\n            SELECT r FROM Claroline\\CoreBundle\\Entity\\Role r\n            JOIN r.groups g\n            JOIN r.workspace w\n            WHERE g.id = :groupId AND w.id = :workspaceId\n            ";
     $query = $this->_em->createQuery($dql);
     $query->setParameter('groupId', $group->getId());
     $query->setParameter('workspaceId', $workspace->getId());
     return $query->getResult();
 }
 public function findCursusByGroup(Group $group, $executeQuery = true)
 {
     $dql = '
         SELECT c
         FROM Claroline\\CursusBundle\\Entity\\Cursus c
         WHERE EXISTS (
             SELECT cg
             FROM Claroline\\CursusBundle\\Entity\\CursusGroup cg
             JOIN cg.group g
             WHERE g.name = :group
             AND cg.cursus = c
         )
     ';
     $query = $this->_em->createQuery($dql);
     $query->setParameter('group', $group->getName());
     return $executeQuery ? $query->getResult() : $query;
 }
 /**
  * @ApiDoc(
  *     description="Returns the searchable user fields",
  *     views = {"user"}
  * )
  */
 public function getGroupSearchableFieldsAction()
 {
     $baseFields = Group::getSearchableFields();
     return $baseFields;
 }
Beispiel #15
0
 /**
  * Import users from an array.
  * There is the array format:.
  *
  * @todo some batch processing
  *
  * array(
  *     array(firstname, lastname, username, pwd, email, code, phone),
  *     array(firstname2, lastname2, username2, pwd2, email2, code2, phone2),
  *     array(firstname3, lastname3, username3, pwd3, email3, code3, phone3),
  * )
  *
  * @param array    $users
  * @param string   $authentication an authentication source
  * @param bool     $mail           do the users need to be mailed
  * @param \Closure $logger         an anonymous function allowing to log actions
  *
  * @return array
  */
 public function importUsers(array $users, $sendMail = true, $logger = null, $additionalRoles = [], $enableEmailNotifaction = false, $options = [])
 {
     //build options
     if (!isset($options['ignore-update'])) {
         $options['ignore-update'] = false;
     }
     $returnValues = [];
     $skipped = [];
     //keep these roles before the clear() will mess everything up. It's not what we want.
     $tmpRoles = $additionalRoles;
     $additionalRoles = [];
     //I need to do that to import roles from models. Please don't ask why, I have no f*****g idea.
     $this->objectManager->clear();
     foreach ($tmpRoles as $role) {
         if ($role) {
             $additionalRoles[] = $this->objectManager->merge($role);
         }
     }
     $roleUser = $this->roleManager->getRoleByName('ROLE_USER');
     $max = $roleUser->getMaxUsers();
     $total = $this->countUsersByRoleIncludingGroup($roleUser);
     if ($total + count($users) > $max) {
         throw new AddRoleException();
     }
     $lg = $this->platformConfigHandler->getParameter('locale_language');
     $this->objectManager->startFlushSuite();
     $i = 1;
     $j = 0;
     $countCreated = 0;
     $countUpdated = 0;
     foreach ($users as $user) {
         $firstName = $user[0];
         $lastName = $user[1];
         $username = $user[2];
         $pwd = $user[3];
         $email = trim($user[4]);
         if (isset($user[5])) {
             $code = trim($user[5]) === '' ? null : $user[5];
         } else {
             $code = null;
         }
         if (isset($user[6])) {
             $phone = trim($user[6]) === '' ? null : $user[6];
         } else {
             $phone = null;
         }
         if (isset($user[7])) {
             $authentication = trim($user[7]) === '' ? null : $user[7];
         } else {
             $authentication = null;
         }
         if (isset($user[8])) {
             $modelName = trim($user[8]) === '' ? null : $user[8];
         } else {
             $modelName = null;
         }
         if (isset($user[9])) {
             $groupName = trim($user[9]) === '' ? null : $user[9];
         } else {
             $groupName = null;
         }
         if (isset($user[10])) {
             $organizationName = trim($user[10]) === '' ? null : $user[10];
         } else {
             $organizationName = null;
         }
         $hasPersonalWorkspace = isset($user[11]) ? (bool) $user[11] : false;
         $isMailValidated = isset($user[12]) ? (bool) $user[12] : false;
         $isMailNotified = isset($user[13]) ? (bool) $user[13] : $enableEmailNotifaction;
         if ($modelName) {
             $model = $this->objectManager->getRepository('Claroline\\CoreBundle\\Entity\\Model\\WorkspaceModel')->findOneByName($modelName);
         } else {
             $model = null;
         }
         if ($organizationName) {
             $organizations = [$this->objectManager->getRepository('Claroline\\CoreBundle\\Entity\\Organization\\Organization')->findOneByName($organizationName)];
         } else {
             $organizations = [];
         }
         $group = $groupName ? $this->groupManager->getGroupByName($groupName) : null;
         if ($groupName) {
             $group = $this->groupManager->getGroupByNameAndScheduledForInsert($groupName);
             if (!$group) {
                 $group = new Group();
                 $group->setName($groupName);
                 $group = $this->groupManager->insertGroup($group);
             }
         } else {
             $group = null;
         }
         $userEntity = $this->userRepo->findOneByMail($email);
         if (!$userEntity) {
             $userEntity = $this->userRepo->findOneByUsername($username);
             if (!$userEntity && $code !== null) {
                 //the code isn't required afaik
                 $userEntity = $this->userRepo->findOneByAdministrativeCode($code);
             }
         }
         if ($userEntity && $options['ignore-update']) {
             if ($logger) {
                 $logger(" Skipping  {$userEntity->getUsername()}...");
             }
             continue;
         }
         $isNew = false;
         if (!$userEntity) {
             $isNew = true;
             $userEntity = new User();
             $userEntity->setPlainPassword($pwd);
             ++$countCreated;
         } else {
             if (!empty($pwd)) {
                 $userEntity->setPlainPassword($pwd);
             }
             ++$countUpdated;
         }
         $userEntity->setUsername($username);
         $userEntity->setMail($email);
         $userEntity->setFirstName($firstName);
         $userEntity->setLastName($lastName);
         $userEntity->setAdministrativeCode($code);
         $userEntity->setPhone($phone);
         $userEntity->setLocale($lg);
         $userEntity->setAuthentication($authentication);
         $userEntity->setIsMailNotified($isMailNotified);
         $userEntity->setIsMailValidated($isMailValidated);
         if ($options['single-validate']) {
             $errors = $this->validator->validate($userEntity);
             if (count($errors) > 0) {
                 $skipped[$i] = $userEntity;
                 if ($isNew) {
                     --$countCreated;
                 } else {
                     --$countUpdated;
                 }
                 continue;
             }
         }
         if (!$isNew && $logger) {
             $logger(" User {$j} ({$username}) being updated...");
             $this->roleManager->associateRoles($userEntity, $additionalRoles);
         }
         if ($isNew) {
             if ($logger) {
                 $logger(" User {$j} ({$username}) being created...");
             }
             $this->createUser($userEntity, $sendMail, $additionalRoles, $model, $username . uniqid(), $organizations, $hasPersonalWorkspace, false);
         }
         $this->objectManager->persist($userEntity);
         $returnValues[] = $firstName . ' ' . $lastName;
         if ($group) {
             $this->groupManager->addUsersToGroup($group, [$userEntity]);
         }
         if ($logger) {
             $logger(' [UOW size: ' . $this->objectManager->getUnitOfWork()->size() . ']');
         }
         ++$i;
         ++$j;
         if ($i % self::MAX_USER_BATCH_SIZE === 0) {
             if ($logger) {
                 $logger(' [UOW size: ' . $this->objectManager->getUnitOfWork()->size() . ']');
             }
             $this->objectManager->forceFlush();
             if ($logger) {
                 $logger(' flushing users...');
             }
             $tmpRoles = $additionalRoles;
             $this->objectManager->clear();
             $additionalRoles = [];
             foreach ($tmpRoles as $toAdd) {
                 if ($toAdd) {
                     $additionalRoles[] = $this->objectManager->merge($toAdd);
                 }
             }
             if ($this->tokenStorage->getToken()) {
                 $this->objectManager->merge($this->tokenStorage->getToken()->getUser());
             }
         }
     }
     $this->objectManager->endFlushSuite();
     if ($logger) {
         $logger($countCreated . ' users created.');
         $logger($countUpdated . ' users updated.');
     }
     foreach ($skipped as $key => $user) {
         $logger('The user ' . $user . ' was skipped at line ' . $key . ' because it failed the validation pass.');
     }
     return $returnValues;
 }
Beispiel #16
0
 /**
  * @EXT\Route("/{groupId}/update", name="claro_admin_update_group_settings")
  * @EXT\ParamConverter(
  *      "group",
  *      class="ClarolineCoreBundle:Group",
  *      options={"id" = "groupId", "strictId" = true}
  * )
  * @EXT\Template("ClarolineCoreBundle:Administration/Groups:settingsForm.html.twig")
  *
  * Updates the settings of a group and redirects to the group list.
  *
  * @param Group $group
  *
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  */
 public function updateSettingsAction(Group $group)
 {
     $oldRoles = $group->getPlatformRoles();
     $form = $this->formFactory->create(FormFactory::TYPE_GROUP_SETTINGS, array('isAdmin' => true, 'roles' => $oldRoles), $group);
     $form->handleRequest($this->request);
     $unavailableRoles = [];
     $roles = $form['platformRoles']->getData();
     foreach ($roles as $role) {
         $isAvailable = $this->roleManager->validateRoleInsert($group, $role);
         if (!$isAvailable) {
             $unavailableRoles[] = $role;
         }
     }
     if ($form->isValid() && count($unavailableRoles) === 0) {
         $group = $form->getData();
         $newRoles = $form['platformRoles']->getData();
         $this->groupManager->setPlatformRoles($group, $newRoles);
         $this->groupManager->updateGroup($group, $oldRoles);
         return $this->redirect($this->generateUrl('claro_admin_group_list'));
     }
     return array('group' => $group, 'form_settings' => $form->createView(), 'unavailableRoles' => $unavailableRoles);
 }
 public function registerGroupToCursusAndSessions(Group $group, array $multipleCursus, array $sessions)
 {
     $this->checkCursusToolRegistrationAccess();
     $coursesWithSession = [];
     $sessionsToCreate = [];
     $root = 0;
     $cursusRoot = null;
     $registrationDate = new \DateTime();
     $configStartDate = $this->platformConfigHandler->getParameter('cursusbundle_default_session_start_date');
     $configEndDate = $this->platformConfigHandler->getParameter('cursusbundle_default_session_end_date');
     $startDate = empty($configStartDate) ? null : new \DateTime($configStartDate);
     $endDate = empty($configEndDate) ? null : new \DateTime($configEndDate);
     foreach ($sessions as $session) {
         $course = $session->getCourse();
         $coursesWithSession[$course->getId()] = true;
     }
     foreach ($multipleCursus as $cursus) {
         $root = $cursus->getRoot();
         $course = $cursus->getCourse();
         if (!is_null($course) && !isset($coursesWithSession[$course->getId()]) && !in_array($course, $sessionsToCreate)) {
             $sessionsToCreate[] = $course;
         }
     }
     if ($root > 0) {
         $cursusRoot = $this->getOneCursusById($root);
         $this->associateCursusToSessions($cursusRoot, $sessions);
     }
     // Generate the list of sessions where the user will be register
     foreach ($sessionsToCreate as $course) {
         $sessionName = $group->getName();
         $session = $this->createCourseSession($course, $sessionName, null, [$cursusRoot], $registrationDate, $startDate, $endDate, false, $course->getPublicRegistration(), $course->getPublicUnregistration(), $course->getRegistrationValidation(), $course->getUserValidation(), $course->getOrganizationValidation(), $course->getMaxUsers(), 0, $course->getValidators(), CourseSession::REGISTRATION_AUTO, $course->getDisplayOrder());
         $sessions[] = $session;
     }
     $results = $this->registerGroupToSessions($sessions, $group);
     if ($results['status'] === 'success') {
         $this->registerGroupToMultipleCursus($multipleCursus, $group);
     }
     return $results;
 }
 protected static function createGroup($name, array $users = array(), array $roles = array())
 {
     $group = new Group();
     $group->setName($name);
     foreach ($users as $user) {
         $group->addUser($user);
     }
     foreach ($roles as $role) {
         $group->addRole($role);
     }
     self::create($name, $group);
 }
 /**
  * @param WorkspaceModel $model
  * @param Group $group
  */
 public function removeGroup(WorkspaceModel $model, Group $group)
 {
     $group->removeModel($model);
     $this->om->persist($model);
     $this->om->flush();
 }
 /**
  * @EXT\Route(
  *     "multiple/cursus/register/group/{group}",
  *     name="claro_cursus_multiple_register_group",
  *     options = {"expose"=true}
  * )
  * @EXT\Method("POST")
  * @EXT\ParamConverter("authenticatedUser", options={"authenticatedUser" = true})
  * @EXT\ParamConverter(
  *     "multipleCursus",
  *      class="ClarolineCursusBundle:Cursus",
  *      options={"multipleIds" = true, "name" = "cursusIds"}
  * )
  * @EXT\ParamConverter(
  *     "sessions",
  *      class="ClarolineCursusBundle:CourseSession",
  *      options={"multipleIds" = true, "name" = "sessionIds"}
  * )
  *
  * @param Group $group
  * @param Cursus[] $multipleCursus
  * @param CourseSession[] $sessions
  * @param User $authenticatedUser
  */
 public function cursusGroupRegisterToMultipleCursusAction(Group $group, array $multipleCursus, array $sessions, User $authenticatedUser)
 {
     $this->checkToolAccess();
     $coursesWithSession = array();
     $sessionsToCreate = array();
     $root = 0;
     $cursusRoot = null;
     $registrationDate = new \DateTime();
     $configStartDate = $this->platformConfigHandler->getParameter('cursusbundle_default_session_start_date');
     $configEndDate = $this->platformConfigHandler->getParameter('cursusbundle_default_session_end_date');
     $startDate = empty($configStartDate) ? null : new \DateTime($configStartDate);
     $endDate = empty($configEndDate) ? null : new \DateTime($configEndDate);
     foreach ($sessions as $session) {
         $course = $session->getCourse();
         $coursesWithSession[$course->getId()] = true;
     }
     foreach ($multipleCursus as $cursus) {
         $root = $cursus->getRoot();
         $course = $cursus->getCourse();
         if (!is_null($course) && !isset($coursesWithSession[$course->getId()]) && !in_array($course, $sessionsToCreate)) {
             $sessionsToCreate[] = $course;
         }
     }
     if ($root > 0) {
         $cursusRoot = $this->cursusManager->getOneCursusById($root);
     }
     // Generate the list of sessions where the user will be register
     foreach ($sessionsToCreate as $course) {
         $sessionName = $group->getName();
         $session = $this->cursusManager->createCourseSession($course, $authenticatedUser, $sessionName, $cursusRoot, $registrationDate, $startDate, $endDate);
         $sessions[] = $session;
     }
     $this->cursusManager->registerGroupToMultipleCursus($multipleCursus, $group);
     $this->cursusManager->registerGroupToSessions($sessions, $group);
     return new JsonResponse('success', 200);
 }
Beispiel #21
0
 public function manageGroupCreation(array $datas)
 {
     $logs = array();
     $identicalGroupTxt = $this->translator->trans('identical_group_name', array(), 'platform');
     $groupTxt = $this->translator->trans('group', array(), 'platform');
     $createdTxt = $this->translator->trans('has_been_created', array(), 'platform');
     $existedTxt = $this->translator->trans('already_exists', array(), 'platform');
     $this->om->startFlushSuite();
     // Checks for double entries
     foreach ($datas as $lineNb => $lineDatas) {
         if (!isset($lineDatas['error'])) {
             $groupName = strtolower($lineDatas['name']);
             foreach ($datas as $lineNbBis => $lineDatasBis) {
                 if ($lineNb !== $lineNbBis && !isset($lineDatasBis['error']) && $groupName === strtolower($lineDatasBis['name'])) {
                     $groupNameBis = $lineDatasBis['name'];
                     $datas[$lineNb]['error'] = "[{$lineNb}] {$identicalGroupTxt} [{$groupName}]";
                     $datas[$lineNbBis]['error'] = "[{$lineNbBis}] {$identicalGroupTxt} [{$groupNameBis}]";
                 }
             }
         }
     }
     foreach ($datas as $lineNb => $lineDatas) {
         if (isset($lineDatas['error'])) {
             $logs[] = $lineDatas['error'];
         } else {
             $groupName = $lineDatas['name'];
             $group = $this->groupManager->getGroupByName($groupName);
             if (is_null($group)) {
                 $group = new Group();
                 $group->setName($groupName);
                 $this->om->persist($group);
                 $logs[] = "{$groupTxt} [{$groupName}] {$createdTxt}";
             } else {
                 $logs[] = "{$groupTxt} [{$groupName}] {$existedTxt}";
             }
         }
     }
     $this->om->endFlushSuite();
     return $logs;
 }
 protected function persistGroup($name)
 {
     $group = new Group();
     $group->setName($name);
     $group->setGuid($name);
     $this->om->persist($group);
     return $group;
 }
Beispiel #23
0
 public function searchPartialList($searches, $page, $limit, $count = false, $exclude = false)
 {
     $baseFieldsName = Group::getSearchableFields();
     $qb = $this->om->createQueryBuilder();
     $count ? $qb->select('count(g)') : $qb->select('g');
     $qb->from('Claroline\\CoreBundle\\Entity\\Group', 'g');
     //Admin can see everything, but the others... well they can only see their own organizations.
     //Cli always win aswell
     if (php_sapi_name() !== 'cli' || $this->container->get('kernel')->getEnvironment() === 'test') {
         if (!$this->container->get('security.authorization_checker')->isGranted('ROLE_ADMIN')) {
             $currentUser = $this->container->get('security.token_storage')->getToken()->getUser();
             $qb->join('g.organizations', 'go');
             $qb->join('go.administrators', 'ga');
             $qb->andWhere('ga.id = :userId');
             $qb->setParameter('userId', $currentUser->getId());
         }
     }
     foreach ($searches as $key => $search) {
         foreach ($search as $id => $el) {
             if (in_array($key, $baseFieldsName)) {
                 $string = "UPPER (g.{$key})";
                 if ($exclude) {
                     $string .= ' NOT';
                 }
                 $string .= " LIKE :{$key}{$id}";
                 $qb->andWhere($string);
                 $qb->setParameter($key . $id, '%' . strtoupper($el) . '%');
             }
         }
     }
     $query = $qb->getQuery();
     if ($page !== null && $limit !== null && !$count) {
         $query->setMaxResults($limit);
         $query->setFirstResult($page * $limit);
     }
     return $count ? $query->getSingleScalarResult() : $query->getResult();
 }
Beispiel #24
0
 public function addGroup(Group $group)
 {
     $group->addModel($this);
 }