Returns all users from the current connection.

@param array  $fields
@param bool   $sorted
@param string $sortBy
@param string $sortByDirection

@return array|bool

@throws AdldapException
329841
public function all($fields = [], $sorted = true, $sortBy = 'cn', $sortByDirection = 'asc')
    {
        $personCategory = $this->adldap->getPersonFilter('category');
        $person = $this->adldap->getPersonFilter('person');

        $search = $this->adldap->search()
            ->select($fields)
            ->where($personCategory, '=', $person)
            ->where('samaccounttype', '=', Adldap::ADLDAP_NORMAL_ACCOUNT);

        if ($sorted) {
            $search->sortBy($sortBy, $sortByDirection);
        }

        return $search->get();
    }
8271
public function getAllFriendships($limit = null, $offset = null): array
    {
        return $this->findFriendshipsByStatus(null, $limit, $offset);
    }
1333109
public function selectArray($fields = null, $where = null, $orderBy = null, $limit = null): array
    {
        return self::select2($fields, $where, $orderBy, $limit);
    }
36339
public function getUserByField($field, $data)
    {
        $user = new User();
        $userVarArray = get_object_vars($user);
        $arrayKeys = array_keys($userVarArray);
        $userData = $this->userStorage->getUserByField($field, $data);
        if (empty($userData)) {
            return $user;
        }
        foreach ($arrayKeys as $key) {
            $user->{$key} = $userData->$key;
        }
        return $user;
    }
40361
function getUserFields(selector, sort) {
  var selectorFields = Object.keys(selector);
  var sortFields = sort? sort.map(getKey) : [];
  var userFields;
  if (selectorFields.length >= sortFields.length) {
    userFields = selectorFields;
  } else {
    userFields = sortFields;
  }

  if (sortFields.length === 0) {
    return {
      fields: userFields
    };
  }

  // sort according to the user's preferred sorting
  userFields = userFields.sort(function (left, right) {
    var leftIdx = sortFields.indexOf(left);
    if (leftIdx === -1) {
      leftIdx = Number.MAX_VALUE;
    }
    var rightIdx = sortFields.indexOf(right);
    if (rightIdx === -1) {
      rightIdx = Number.MAX_VALUE;
    }
    return leftIdx < rightIdx ? -1 : leftIdx > rightIdx ? 1 : 0;
  });

  return {
    fields: userFields,
    sortOrder: sort.map(getKey)
  };
}
326120
public function index(
        array $filters = [],
        $orderBy = [],
        $groupBy = []
    ) {
        $selection = $this->provider->selectAll($filters, $orderBy, $groupBy);
        $query = $this->provider->query($selection);
        return $query->getResult();
    }
926513
public function listTrashed($offset, $limit, array $sort = null)
    {
        try {
            return $this->innerGateway->listTrashed($offset, $limit, $sort);
        } catch (DBALException $e) {
            throw new RuntimeException('Database error', 0, $e);
        } catch (PDOException $e) {
            throw new RuntimeException('Database error', 0, $e);
        }
    }
221582
public function sortRecords(array $sorting)
    {
        if (!$this->writeConnection) {
            throw new AnyContentClientException ('Current connection(s) doesn\'t support write operations.');
        }

        $records = $records = $this->getRecords();
        foreach ($records as $record) {
            $record->setPosition(null);
            $record->setParent(null);
        }

        $positions = [];
        foreach ($sorting as $recordId => $parentId) {
            if (!array_key_exists($parentId, $positions)) {
                $positions[$parentId] = 1;
            }

            $records[$recordId]->setPosition($positions[$parentId]++);
            $records[$recordId]->setParent($parentId);
        }

        return $this->saveRecords($records);
    }
671987
public function GetSummary($OrderFields = '', $OrderDirection = 'asc', $Limit = FALSE, $Offset = FALSE) {
      $this->UserQuery(TRUE);
      return $this->SQL
         ->Where('u.Deleted', 0)
         ->OrderBy($OrderFields, $OrderDirection)
         ->Limit($Limit, $Offset)
         ->Get();
   }
1277823
public function search($dn, $filter, array $fields)
    {
        if ($this->suppressErrors) {
            return @ldap_search($this->getConnection(), $dn, $filter, $fields);
        }

        return ldap_search($this->getConnection(), $dn, $filter, $fields);
    }
595640
public function filterBy(array $criteria, array $orderBy = null, $limit = null, $offset = null, CompositeExpression $externalExpression = null)
    {
        $qb = $this->repository->createQueryBuilder('user')->distinct(true)
            ->leftJoin('user.contact', 'contact')
            ->leftJoin('contact.addresses', 'address')
            ->andWhere('address.type = :addressType')
            ->setParameter('addressType', 'main');

        if (array_key_exists('search', $criteria)) {
            $qb->andWhere('user.username like :searchLike or address.firstName like :searchLike or address.lastName like :searchLike or user.id=:search');
            $qb->setParameter('search', $criteria['search']);
            $qb->setParameter('searchLike', '%'.$criteria['search'].'%');
        }

        if (is_array($orderBy)) {
            foreach ($orderBy as $key => $value) {
                if ($key === 'id') {
                    $key = 'user.id';
                }
                $qb->orderBy($key, $value);
            }
        }

        $query = $qb->getQuery();
        $arrayResult = $query->getResult();
        $count = count($arrayResult);

        if ($offset === null) {
            $offset = 0;
        }

        if ($offset || $limit) {
            $arrayResult = array_slice($arrayResult, $offset, $limit);
        }

        $result = new FilterResult($arrayResult);
        $result->setCount($count);

        return $result;
    }
650388
public static function get_discussion_posts(int $discussionid, ?string $sortby, ?string $sortdirection) {
        global $USER;
        // Validate the parameter.
        $params = self::validate_parameters(self::get_discussion_posts_parameters(), [
                'discussionid' => $discussionid,
                'sortby' => $sortby,
                'sortdirection' => $sortdirection,
            ]);
        $warnings = [];

        $vaultfactory = mod_forum\local\container::get_vault_factory();

        $discussionvault = $vaultfactory->get_discussion_vault();
        $discussion = $discussionvault->get_from_id($params['discussionid']);

        $forumvault = $vaultfactory->get_forum_vault();
        $forum = $forumvault->get_from_id($discussion->get_forum_id());

        $sortby = $params['sortby'];
        $sortdirection = $params['sortdirection'];
        $sortallowedvalues = ['id', 'created', 'modified'];
        $directionallowedvalues = ['ASC', 'DESC'];

        if (!in_array(strtolower($sortby), $sortallowedvalues)) {
            throw new invalid_parameter_exception('Invalid value for sortby parameter (value: ' . $sortby . '),' .
                'allowed values are: ' . implode(', ', $sortallowedvalues));
        }

        $sortdirection = strtoupper($sortdirection);
        if (!in_array($sortdirection, $directionallowedvalues)) {
            throw new invalid_parameter_exception('Invalid value for sortdirection parameter (value: ' . $sortdirection . '),' .
                'allowed values are: ' . implode(',', $directionallowedvalues));
        }

        $managerfactory = mod_forum\local\container::get_manager_factory();
        $capabilitymanager = $managerfactory->get_capability_manager($forum);

        $postvault = $vaultfactory->get_post_vault();
        $posts = $postvault->get_from_discussion_id(
                $USER,
                $discussion->get_id(),
                $capabilitymanager->can_view_any_private_reply($USER),
                "{$sortby} {$sortdirection}"
            );

        $builderfactory = mod_forum\local\container::get_builder_factory();
        $postbuilder = $builderfactory->get_exported_posts_builder();

        $legacydatamapper = mod_forum\local\container::get_legacy_data_mapper_factory();

        return [
            'posts' => $postbuilder->build($USER, [$forum], [$discussion], $posts),
            'ratinginfo' => \core_rating\external\util::get_rating_info(
                $legacydatamapper->get_forum_data_mapper()->to_legacy_object($forum),
                $forum->get_context(),
                'mod_forum',
                'post',
                $legacydatamapper->get_post_data_mapper()->to_legacy_objects($posts)
            ),
            'warnings' => $warnings,
        ];
    }
459021
public function getUsers($page = 0, $pagesize = 100, $sort = 'id', $direction = 'asc')
    {
        $result = (Object)array(
            "users" =>  array(),
            "total" => 0
        );

        $repo = $this->getRepository('erdiko\users\entities\User');

        $offset = 0;
        if ($page > 0) {
            $offset = ($page - 1) * $pagesize;
        }

        $result->users = $repo->findBy(
                                        array(),
                                        array(
                                            $sort => $direction
                                        ),
                                        $pagesize,
                                        $offset
                                    );

        // get total users count
        $result->total = (int)$repo->createQueryBuilder('u')
                                   ->select('count(u.id)')
                                   ->getQuery()
                                   ->getSingleScalarResult();

		return $result;
	}
1280274
public static function byFieldsValues(array $shortSortByElements): SortBy
    {
        $sortBy = self::create();
        foreach ($shortSortByElements as $field => $order) {
            $sortBy->byFieldValue($field, $order);
        }

        return $sortBy;
    }
1143801
function sortFieldsByIndex(userFields, index) {
  var indexFields = index.def.fields.map(getKey);

  return userFields.slice().sort(function (a, b) {
    var aIdx = indexFields.indexOf(a);
    var bIdx = indexFields.indexOf(b);
    if (aIdx === -1) {
      aIdx = Number.MAX_VALUE;
    }
    if (bIdx === -1) {
      bIdx = Number.MAX_VALUE;
    }
    return utils.compare(aIdx, bIdx);
  });
}
530170
private function buildUserFieldList(array $fields, array $excludes = [])
    {
        $ret = [];

        foreach ($fields as $key => $field) {
            $data['name'] = $key;

            foreach ($field as $k => $i) {
                if (in_array($k, $excludes)) {
                    continue;
                }

                $data[$k] = $i;
            }

            $ret[] = $data;
        }

        return $ret;
    }
57101
public function orderBy($fields, $defaultDirection = 'ASC')
    {
        if (!is_array($fields)) {
            $fields = array($fields);
        }

        foreach ($fields as $key => $value) {
            $field = $key;
            $type = $value;
            if (is_int($key)) {
                $field = $value;
                $type = $defaultDirection;
            }
            if (!$field instanceof Raw) {
                $field = $this->addTablePrefix($field);
            }
            $this->statements['orderBys'][] = compact('field', 'type');
        }

        return $this;
    }