/** * getUserListing * * Gets user listing with filtering options. * * @params array $filter $page, $count $order $list * @return array * @author Jari Korpela */ public function getUserListing(&$filter = null, $page = 1, $count = 10, $order = 'login', $list = 'DESC', &$listSize = 1) { //For some odd reason this order and list default set has to be done here and wont work on ^... if (!$order) { $order = 'username'; } if (!$list) { $list = 'ASC'; } //Get full sorted and filtered userIdList $userIdList = $this->sortAndFilterUsers($filter, $order, $list); $listSize = sizeof($userIdList); if ($listSize == 0) { return array(); } //If list size is 0, we just return //Then we choose the part of id list we want to show and collect data on $userIdListCut = array(); $i = ($page - 1) * $count; $limit = $i + $count; for ($i; $i < $limit; $i++) { if (!isset($userIdList[$i])) { break; } $userIdListCut[] = $userIdList[$i]; } if (sizeof($userIdListCut) == 0) { return array(); } $userIdList = $userIdListCut; //We replace the whole list with the user Ids we want (this is for final ordering purpose) $userInfo = $this->getUserInfo($userIdList); //Get basic user information $userData = $userInfo; //We start to collect data about users to $userData array $userContents = $this->getUsersContents($userIdList); //Get all content ID's from users in id list //Add these contents to $userData array in which we collect data (if user doesnt have content we add empty array) foreach ($userData as $key => $data) { if (!isset($userContents[$data['id_usr']])) { $userContents[$data['id_usr']] = array(); } $userData[$key]['contents'] = $userContents[$data['id_usr']]; } ksort($userContents); //We sort $userContents again because we might have added empty arrays //Calculate contentCounts for users. foreach ($userData as $key => $data) { $userData[$key]['contentCount'] = sizeof($data['contents']); } //Get Ratings statistics $userRatings = $this->getUserContentRatings($userContents); $userData = $this->intersectMergeArray($userData, $userRatings); //Get location info $profileModel = new Default_Model_UserProfiles(); $userLocations = $profileModel->getUsersLocation($userIdList); $userData = $this->intersectMergeArray($userData, $userLocations); //Finally we sort the $userData array to same order as our $userIdList $final = array(); foreach ($userIdList as $id) { foreach ($userData as $data) { if ($data['id_usr'] == $id) { $final[] = $data; continue 2; } } } return $final; }