public function getLeaders($searchString, $city, $limit)
 {
     Loader::model('user_list');
     $av = Loader::helper('concrete/avatar');
     $ul = new UserList();
     $ul->filterByKeywords($searchString);
     $ul->filterByGroup('Walk Leaders');
     $ul->filterByIsActive(1);
     $ul->filterByFirstName(null, '!=');
     $ul->filterByFirstName('', '!=');
     $ul->filter('uLastLogin', 0, '!=');
     $ul->sortBy('uLastLogin');
     $userSet = [];
     foreach ($ul->get($limit ?: 5) as $user) {
         $home_city = $user->getAttribute('home_city');
         $userSet[$user->getUserID()] = ['user_id' => $user->getUserID(), 'first_name' => $user->getAttribute('first_name'), 'last_name' => $user->getAttribute('last_name'), 'city_name' => $home_city ? $home_city->getCollectionName() : null, 'city_id' => $home_city ? $home_city->getCollectionID() : null, 'bio' => $user->getAttribute('bio'), 'twitter' => $user->getAttribute('twitter'), 'facebook' => $user->getAttribute('facebook'), 'website' => $user->getAttribute('website'), 'avatar' => $av->getImagePath($user)];
     }
     return json_encode($userSet);
 }
Example #2
0
$filters = json_decode((string) $this->getBlockObject()->getBlockName() ?: '{"groups": ["Staff"]}', true);
/**
 * Get a list of members to display
 *
 * @param array $filters Assoc array of the filters to apply
 * @return array
 */
$getMembers = function ($filters) use($av) {
    // Filter to show only the staff members, or customize
    // by 'custom template' and choose a block name
    $ul = new UserList();
    $defaultAttribute = ['', true, '='];
    foreach ($filters as $k => $filter) {
        if ($k === 'groups') {
            foreach ($filter as $group) {
                $ul->filterByGroup($group);
            }
        } elseif ($k === 'attributes') {
            // $attribute keys: 'id', 'value', 'compare'
            foreach ($filter as $attribute) {
                list($handle, $value, $comparison) = array_replace($defaultAttribute, $attribute);
                $ul->filterByAttribute($handle, $value, $comparison);
            }
        }
        $ul->sortBy('ak_order', 'asc');
    }
    /**
     * Build doc with all the 'member's in it, and load the values we'll
     * need to display.
     */
    return array_map(function ($member) use($av) {