+ /** Filter a list of profiles to extract the users matching the rule.
+ */
+ public function filterProfiles(array $profiles, $limit = null)
+ {
+ $limit = self::defaultLimit($limit);
+ $this->requireProfiles();
+ $this->buildQuery();
+ $table = array();
+ $pids = array();
+ foreach ($profiles as $profile) {
+ if ($profile instanceof Profile) {
+ $pid = $profile->id();
+ } else {
+ $pid = $profile;
+ }
+ $pids[] = $pid;
+ $table[$pid] = $profile;
+ }
+ $fetched = $this->getPIDList($pids, $limit);
+ $output = array();
+ foreach ($fetched as $pid) {
+ $output[] = $table[$pid];
+ }
+ return $output;
+ }
+
+ public function getUIDs($limit = null)
+ {
+ $limit = self::defaultLimit($limit);
+ return $this->getUIDList(null, $limit);
+ }
+
+ public function getUID($pos = 0)
+ {
+ $uids =$this->getUIDList(null, new PlLimit(1, $pos));
+ if (count($uids) == 0) {
+ return null;
+ } else {
+ return $uids[0];
+ }
+ }
+
+ public function getPIDs($limit = null)
+ {
+ $limit = self::defaultLimit($limit);
+ return $this->getPIDList(null, $limit);
+ }
+
+ public function getPID($pos = 0)
+ {
+ $pids =$this->getPIDList(null, new PlLimit(1, $pos));
+ if (count($pids) == 0) {
+ return null;
+ } else {
+ return $pids[0];
+ }
+ }
+
+ public function getUsers($limit = null)
+ {
+ return User::getBulkUsersWithUIDs($this->getUIDs($limit));
+ }
+
+ public function getUser($pos = 0)
+ {
+ $uid = $this->getUID($pos);
+ if ($uid == null) {
+ return null;
+ } else {
+ return User::getWithUID($uid);
+ }
+ }
+
+ public function iterUsers($limit = null)
+ {
+ return User::iterOverUIDs($this->getUIDs($limit));
+ }
+
+ public function getProfiles($limit = null, $fields = 0x0000, $visibility = null)
+ {
+ return Profile::getBulkProfilesWithPIDs($this->getPIDs($limit), $fields, $visibility);
+ }
+
+ public function getProfile($pos = 0, $fields = 0x0000, $visibility = null)
+ {
+ $pid = $this->getPID($pos);
+ if ($pid == null) {
+ return null;
+ } else {
+ return Profile::get($pid, $fields, $visibility);
+ }
+ }
+
+ public function iterProfiles($limit = null, $fields = 0x0000, $visibility = null)