By Tim on Saturday, 15 March 2014
Posted in General Issues
Replies 6
Likes 0
Views 747
Votes 0
I have a set group of about 1200 users in my network (only 450 have logged in so far) and I would like to customize the user list view based on a custom-filter I created that allows the user to choose the building they work in. If I could add an option below, that would help people find their friends much more easily.

I found this switch in com_easysocial controllers, which appears to set the $option

switch( $filter )
{
case 'online':
$options[ 'login' ] = true;

break;

case 'photos':
$options[ 'picture' ] = true;
break;

default:
break;
}

I also found in theme->wireframe->user the file default.list.php which accesses <?php foreach( $users as $user ){ ?>

What I would like to know: where do I find the function that pulls users from the database according to the preset options?

something like "sql get userID where userid.customfield equals "harrison"

Any advice appreciated!
I think I just got a step closer. administrator->models->user has function getUsersWithState which includes

// Determines if we want to filter by logged in users.
$login = isset( $options[ 'login' ] ) ? $options[ 'login' ] : '';

if( $login )
{
$tmp = 'EXISTS( SELECT ' . $db->nameQuote( 'userid' ) . ' FROM ' . $db->nameQuote( '#__session' ) . ' AS f WHERE ' . $db->nameQuote( 'userid' ) . ' = a.' . $db->nameQuote( 'id' ) . ')';

$sql->exists( $tmp );
}

$picture = isset( $options[ 'picture' ] ) ? $options[ 'picture' ] : '';

// Determines if we should only pick users with picture
if( $picture )
{
$sql->join( '#__social_avatars' , 'g' );
$sql->on( 'a.id' , 'g.uid' );

$sql->where( 'g.small' , '' , '!=' );
}

so I think I'm very close. I just need to figure out something like $sql->join( '#__social_avatars' , 'g' ); except for the custom field that specifies the user's building.
Tim
·
Saturday, 15 March 2014 22:37
·
0 Likes
·
0 Votes
·
0 Comments
·
Hello Tim,

What you are actually trying to achieve here is not really as simple as you see You need to join the SQL query with the other tables to get the correct custom field values.
·
Saturday, 15 March 2014 23:38
·
0 Likes
·
0 Votes
·
0 Comments
·
That's ok. I'm not concerned about the difficulty (toomuch ) . This is important to my customer so I'm willing to get into the database and build the sql query myself if you think I'm on the right track.
Tim
·
Sunday, 16 March 2014 00:23
·
0 Likes
·
0 Votes
·
0 Comments
·
Hello Tim,

Yep, you are almost there just that in the controllers/users.php file, you need to add a new condition and with that condition, you have to run a custom sql query. The logic for ajax calls in EasySocial is fairly easy:

Javascript does an ajax call -> controllers processes it (controllers/users.php) -> passes it back to the view to determine what to return (views/users/view.ajax.php)
·
Sunday, 16 March 2014 00:33
·
0 Likes
·
0 Votes
·
0 Comments
·
Thanks Mark!
Tim
·
Sunday, 16 March 2014 00:39
·
0 Likes
·
0 Votes
·
0 Comments
·
No problem
·
Sunday, 16 March 2014 01:00
·
0 Likes
·
0 Votes
·
0 Comments
·
View Full Post