sort users by name

At the members page, members are ordered by  "time_created". 

Many users like to browse in alphabetical order.

here's a posssible solution.

 

replace the mod/members/index.php with this:

 

[CODE]

 

 

 

/**
 * Elgg members index page - called from filter or search
 *
 * @package ElggMembers
 * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
 * @author Curverider <info@elgg.com>
 * @copyright Curverider Ltd 2008-2010
 * @link http://elgg.com/
 */

require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");





function elgg_get_entities_az(array $options = array()) {
    global $CONFIG;

    $defaults = array(
        'site_guids'            =>    $CONFIG->site_guid,
        'limit'                    =>    10,
        'offset'                =>    0,
        'count'                    =>    FALSE
    );

    $options = array_merge($defaults, $options);


    $singulars = array('type', 'subtype', 'owner_guid', 'container_guid', 'site_guid');
    $options = elgg_normalise_plural_options_array($options, $singulars);

    // evaluate where clauses
    if (!is_array($options['wheres'])) {
        $options['wheres'] = array($options['wheres']);
    }

    // Add access controls
    $query = "SELECT    DISTINCT e.* , u.*
                        FROM elgg_entities e inner join elgg_users_entity u
                        on u.guid = e.guid
                        WHERE ((e.type = 'user'))
                        AND (e.site_guid IN (1))
                        AND ( (1 = 1)
                        and e.enabled='yes')
                        ORDER BY u.name asc";    
        if ($options['limit']) {
            $limit = sanitise_int($options['limit']);
            $offset = sanitise_int($options['offset']);
            $query .= " LIMIT $offset, $limit";
        }
        //die($query);
        $dt = get_data($query, "entity_row_to_elggstar");
        //echo '<pre>';print_r($dt);echo'</pre>';
        //@todo normalize this to array()
        return $dt;
}







function elgg_list_entities_az($options) {
    $defaults = array(
        'offset' => (int) max(get_input('offset', 0), 0),
        'limit' => (int) max(get_input('limit', 10), 0),
        'full_view' => TRUE,
        'view_type_toggle' => FALSE,
        'pagination' => TRUE,
        
    );
    $options = array_merge($defaults, $options);
    //echo '<pre>';print_r($options);echo'</pre>';
    $count = elgg_get_entities(array_merge(array('count' => TRUE), $options));
    //echo '$count: '.$count;
    $entities = elgg_get_entities_az($options);
    //echo '<pre>';print_r($entities);echo'</pre>';
    return elgg_view_entity_list($entities, $count, $options['offset'],
        $options['limit'], $options['full_view'], $options['view_type_toggle'], $options['pagination']);
}



    
// get filter parameters
$limit = get_input('limit', 10);
$offset = get_input('offset', 0);
$filter = get_input("filter", "newest");

// search options
$tag = get_input('tag');


//search members
$sidebar = elgg_view("members/search");
        
// get the correct content based on filter/search
switch ($filter) {
    case "pop":
        $filter_content = list_entities_by_relationship_count('friend', true, '', '', 0, 10, false);
    break;
    case "active":
        $filter_content = elgg_view("members/online");
    break;
    // search based on name
    case "search":
        set_context('search');
        $filter_content = list_user_search($tag);
    break;
    // search based on tags
    case "search_tags":
        $options = array();
        $options['query'] = $tag;
        $options['type'] = "user";
        $options['order_by'] = array('name' => 'name','direction' => 'ASC', 'as' => 'text');
        $options['offset'] = $offset;
        $options['limit'] = $limit;
        $results = trigger_plugin_hook('search', 'tags', $options, array());
        $count = $results['count'];
        $users = $results['entities'];
        $filter_content = elgg_view_entity_list($users, $count, $offset, $limit, false, false, true);
    break;
    case "newest":
    case 'default':
        $filter_content = elgg_list_entities(array('type' => 'user', 'offset' => $offset, 'full_view' => FALSE));
    break;
    case 'az':
        $filter_content = elgg_list_entities_az(array('type' => 'user', 'offset' => $offset, 'full_view' => FALSE ));
    break;
}

// create the members navigation/filtering
$members = get_number_users();
$members_nav = elgg_view("members/members_sort_menu", array("count" => $members, "filter" => $filter));

$content = $members_nav . $filter_content;

// title
$main_content = elgg_view_title(elgg_echo("members:members"));

$main_content .= elgg_view('page_elements/contentwrapper', array('body' => $content, 'subclass' => 'members'));

$body = elgg_view_layout("sidebar_boxes", $sidebar, $main_content);

page_draw(elgg_echo('members:members'), $body);

 

[CODE]