Finds all users who already have been awarded a badge by current role

@param string $search
@return array
349247
public function find_users($search) {
        global $DB;
        list($wherecondition, $params) = $this->search_sql($search, 'u');
        $params['badgeid'] = $this->badgeid;
        $params['issuerrole'] = $this->issuerrole;

        list($esql, $eparams) = get_enrolled_sql($this->context, 'moodle/badges:earnbadge', 0, true);
        $fields = $this->required_fields_sql('u');
        list($sort, $sortparams) = users_order_by_sql('u', $search, $this->accesscontext);

        $params = array_merge($params, $eparams, $sortparams);
        $recipients = $DB->get_records_sql("SELECT $fields
                FROM {user} u
                JOIN ($esql) je ON je.id = u.id
                JOIN {badge_manual_award} s ON s.recipientid = u.id
                WHERE $wherecondition AND s.badgeid = :badgeid AND s.issuerrole = :issuerrole
                ORDER BY $sort", $params);

        return array(get_string('existingrecipients', 'badges') => $recipients);
    }
552044
@Override
    public List<User> searchUsers(String search) throws AuthenticationException {
        // Complete list of users
        String[] users = file_store.keySet().toArray(
                new String[file_store.size()]);
        List<User> found = new ArrayList<User>();

        // Look through the list for anyone who matches
        for (int i = 0; i < users.length; i++) {
            if (users[i].toLowerCase().contains(search.toLowerCase())) {
                found.add(getUser(users[i]));
            }
        }

        // Return the list
        return found;
    }
280775
public function findFirstGroupsByName($search)
    {
        return $this->_em->createQueryBuilder()
            ->select('g.id, g.name')
            ->from('ClarolineCoreBundle:Group', 'g')
            ->where('g.name LIKE :search')
            ->setMaxResults(5)
            ->setParameter(':search', "%{$search}%")
            ->getQuery()
            ->getArrayResult();
    }
83441
public function findMember($searchTerm) {
		$term = Convert::raw2sql($searchTerm);
		$current = (int) $this->securityContext->getMember()->ID;
		$filter = '("Username" LIKE \'' . $term .'%\' OR "FirstName" LIKE \'' . $term .'%\' OR "Surname" LIKE \'' . $term . '%\') AND "ID" <> ' . $current;

		$items = DataList::create('Member')->where($filter)->restrict();
		
		return $items;
	}
787641
public function find_users($search) {
        global $DB;
        list($wherecondition, $params) = $this->search_sql($search, 'u');
        $params['forumid'] = $this->forumid;

        // only active enrolled or everybody on the frontpage
        list($esql, $eparams) = get_enrolled_sql($this->context, '', $this->currentgroup, true);
        $fields = $this->required_fields_sql('u');
        list($sort, $sortparams) = users_order_by_sql('u', $search, $this->accesscontext);
        $params = array_merge($params, $eparams, $sortparams);

        $subscribers = $DB->get_records_sql("SELECT $fields
                                               FROM {user} u
                                               JOIN ($esql) je ON je.id = u.id
                                               JOIN {forum_subscriptions} s ON s.userid = u.id
                                              WHERE $wherecondition AND s.forum = :forumid
                                           ORDER BY $sort", $params);

        $cm = get_coursemodule_from_instance('forum', $this->forumid);
        $modinfo = get_fast_modinfo($cm->course);
        $info = new \core_availability\info_module($modinfo->get_cm($cm->id));
        $subscribers = $info->filter_user_list($subscribers);

        return array(get_string("existingsubscribers", 'forum') => $subscribers);
    }
501044
public function findByUsernameContains($searched_term)
    {
        $qb = $this->createQueryBuilder('u');
        $qb instanceof QueryBuilder;

        $qb->add('where', $qb->expr()->like('u.username', $qb->expr()->lower(':searched_term')))
            ->setParameter('searched_term', $searched_term . '%');

        return $qb->getQuery()->getResult();
    }
1313142
public function getRolesReadOnly($domain = false)
    {
        $rolesReadOnly = [];

        if (!$this->tokenStorage->getToken()) {
            return $rolesReadOnly;
        }

        $this->iterateAdminRoles(function ($role, $isMaster) use ($domain, &$rolesReadOnly): void {
            if (!$isMaster && $this->authorizationChecker->isGranted($role)) {
                // although the user has no MASTER permission, allow the currently logged in user to view the role
                $rolesReadOnly[$role] = $this->translateRole($role, $domain);
            }
        });

        return $rolesReadOnly;
    }
461743
public function findDisplayableNonPersonalWorkspacesBySearch($search)
    {
        $dql = '
            SELECT w
            FROM Claroline\CoreBundle\Entity\Workspace\Workspace w
            WHERE w.displayable = true
            AND (
                UPPER(w.name) LIKE :search
                OR UPPER(w.code) LIKE :search
            )
            AND NOT EXISTS (
                SELECT u
                FROM Claroline\CoreBundle\Entity\User u
                JOIN u.personalWorkspace pw
                WHERE pw = w
            )
            ORDER BY w.name
        ';

        $search = strtoupper($search);
        $query = $this->_em->createQuery($dql);
        $query->setParameter('search', "%{$search}%");

        return $query->getResult();
    }
558616
public static function getRoleUsers($role)
    {
        global $PPHP;
        $db = $PPHP['db'];

        $out = $db->selectList(
            "
            SELECT userId FROM users_roles
            WHERE role=?
            ORDER BY userId ASC
            ",
            array($role)
        );
        return (is_array($out) ? $out : array());
    }
309326
private function getPropertyFilters($search = '')
    {
        $propertyFilters = [];

        if(is_string($search) && strlen(trim($search)) > 0){
            $propertyFilters[self::LABEL_URI] = $search;
        }
        if(is_array($search)){
            foreach($search as $uri => $value){
                if( is_string($uri) &&
                    (is_string($value) && strlen(trim($value)) > 0) ||
                    (is_array($value) && count($value) > 0) ) {
                    $propertyFilters[$uri] = $value;
                }
            }
        }
        return $propertyFilters;
    }
1071966
protected function searchField($search)
    {
        foreach ($this->data as $field) {
            if (method_exists($field, 'getField') && $find = $field->getField($search)) {
                return $find;
            }
        }
    }
759426
public function getField($search)
    {
        foreach ($this->data as $field) {
            if ($find = $field->getField($search)) {
                break;
            }
        }

        return $find;
    }
1170364
public function searchByQuery($query) {
		$results = $this->ldap->search($this->basedn, $query);
		return $results;
	}
21651
public function findByRoleNamesBySearch(array $roleNames, $search, $orderedToolType = 0)
    {
        $dql = '
            SELECT DISTINCT w
            FROM Claroline\CoreBundle\Entity\Workspace\Workspace w
            JOIN w.orderedTools ot
            JOIN ot.rights otr
            JOIN otr.role r
            WHERE r.name IN (:roleNames)
            AND ot.type = :type
            AND BIT_AND(otr.mask, :openValue) = :openValue
            AND (
                UPPER(w.name) LIKE :search
                OR UPPER(w.code) LIKE :search
            )
            ORDER BY w.name
        ';

        $upperSearch = strtoupper($search);
        $query = $this->_em->createQuery($dql);
        $query->setParameter('roleNames', $roleNames);
        $query->setParameter('openValue', ToolMaskDecoder::$defaultValues['open']);
        $query->setParameter('search', "%{$upperSearch}%");
        $query->setParameter('type', $orderedToolType);

        return $query->getResult();
    }
390599
public function find($search)
    {
        foreach ($this->all() as $theme) {
            if ($theme->getLowerName() == strtolower($search)) {
                return $theme;
            }
        }

        return;
    }
740128
public function search()
    {
        $options = [
            'first_name' => [
                'label' => __('decoy::admins.controller.search.first_name'),
                'type' => 'text',
            ],
            'last_name' => [
                'label' => __('decoy::admins.controller.search.last_name'),
                'type' => 'text',
            ],
            'email' => [
                'label' => __('decoy::admins.controller.search.email'),
                'type' => 'text',
            ],
            'status' => [
                'label' => __('decoy::admins.controller.search.status'),
                'type' => 'select',
                'options' => [
                    1 => __('decoy::admins.controller.search.enabled'),
                    0 => __('decoy::admins.controller.search.disabled'),
                ],
            ],
        ];

        if (($roles = Admin::getRoleTitles()) && count($roles)) {
            $options['role'] = [
                'label' => __('decoy::admins.controller.search.role'),
                'type' => 'select',
                'options' => $roles,
            ];
        }

        return $options;
    }
988365
@Override
	public String[] searchRoles(String search) throws RolesException {
		// Complete list of users
		String[] roles = role_list.keySet().toArray(new String[role_list.size()]);
		List<String> found = new ArrayList<String>();

		// Look through the list for anyone who matches
		for (int i = 0; i < roles.length; i++) {
			if (roles[i].toLowerCase().contains(search.toLowerCase())) {
				found.add(roles[i]);
			}
		}

		// Return the list
		return found.toArray(new String[found.size()]);
	}