Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Posting a list of all users

Quote Reply
Posting a list of all users
Can anyone think of a simple way to list all users in the database along with any other selected field such as password or status? I know you can view them through the admin, but I want to be able to view the list as a line by line item where I can get 40-50 at a time.

Thanks for any info,
Perl Hopefull
Quote Reply
Re: [stilton] Posting a list of all users In reply to
Could put something on home.html, and then have something like;

Code:
<%if Username eq 'Administrator'%>
<%show_users%>
<%endif%>

...and then a global called 'show_users' which contains;

Code:
sub {

my $back;
my $table = $DB->table('Users');
my $sth = $table->select();
while (my $hit = $sth->fetchrow_hashref) {
my $user = $hit->{Username};
my $pass = $hit->{Password};
my $name = $hit->{Name};
$back .= qq|User: $user <BR>Pass: $pass<BR>Name: $name<BR><BR>|;
}

return $back;

}

This should give you something like;

Quote:
User: andy
Pass: 543_43
Name: Andy

User: youradds
Pass: 5434_fe4
Name: Test person

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Posting a list of all users In reply to
Thanks for such a quick reply Andy! That will be perfect for what I need it for.
Perl Hopefull
Quote Reply
Re: [stilton] Posting a list of all users In reply to
How would you change the code if you wanted it to be displayed like this in an html table.

User Name Pass

jay Jay Dec
Quote Reply
Re: [texhost] Posting a list of all users In reply to
Hm I dont need the email and the passwords on the all-users side.
But all users and the number of link entries they habe in ( ) would be perfect ;-)

Anybody who knows how to change the code for this?

Thanks
Matthias

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] Posting a list of all users In reply to
Hi,

This should work.

Code:
sub {

if ($username ne "admin") {
return '';
}

my $back;
my $table = $DB->table('Users');
my $sth = $table->select();

while (my $hit = $sth->fetchrow_hashref) {
my $user = $hit->{Username};
my $count = $DB->table('Links')->count( { LinkOwner => $user } ) || 0;
$back .= qq|User: $user ($count links)<br />|;
}

return $back;

}

Just change the bit in red to your username, so only you can see the results :)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Posting a list of all users In reply to
Thanks Andy,
it works but the users are sorted by ID or so.

Can they sorted by number of links?

Would be great, when the number of links of each user are clickable and combined with the search function to show these links with search.cgi.

Do I want to much Cool

Matthias

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] Posting a list of all users In reply to
Man, the things I do for this forum Tongue

Try this (took about an hour to get right - so better work <G>)

Code:
sub {

my $db = $DB->table('Links');
$db->select_options( "GROUP BY LinkOwner","ORDER BY link_count DESC" );
my $sth = $db->select("LinkOwner", "COUNT(*) as link_count") or die "Query Error: $GT::SQL::error";

my $back;
while (my ($s, $c) = $sth->fetchrow_array) {
$back .= qq|LinkOwner: $s Link Count: $c <br />|;
}

return $back;

}

I'm guessing this isn't just going to be for showing to yourself - so I didn't bother putting the bit in to stop it showing to normal users.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Posting a list of all users In reply to
Thanks Andy,
it works perfekt.

I found another global (from andy who else :-) called get_links_by_owner

Code:
sub {

my $user = $_[0];

my $sth = $DB->table('Links')->select( { LinkOwner => $user, isValidated => 'Yes' } ) || return $GT::SQL::error;

my $back;
while (my $hit = $sth->fetchrow_hashref) {
$back .= qq|<p><a href="$CFG->{build_root_url}/Detailed/$hit->{ID}.html">$hit->{Title}</a></p>|;
}

return $back;
}
I don't dare to ask but is it possible to combine these to globals? So that in the userlist every name is clickable and then shows the link of this user?

Hey Andy, but do it just, if it's easy to combine. I do really not know how many work there is behind.
But at the moment I'm fighting with the css-file of links. And this is sometimes hard enough....

Matthias

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] Posting a list of all users In reply to
Hi,

Theeasiest way, is to use search.cg to do it for you =)

Just change:

Code:
$back .= qq|LinkOwner: $s Link Count: $c <br />|;

..to:

Code:
my $url = $CFG->{db_cgi_url} . "/search.cgi?query=;LinkOwner=$s";
$back .= qq|LinkOwner: <a href="$url">$s</a> Link Count: $c <br />|;

..in the global I wrote for you.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Posting a list of all users In reply to
Hi Andy,
thanks a lot for all the support you gave me in the last days.
Say is your amazon wishlist still up to date?

Matthias

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] Posting a list of all users In reply to
Hi,

Quote:
thanks a lot for all the support you gave me in the last days.

No problem :)

Quote:
Say is your amazon wishlist still up to date?

It hadn't been updated for a while - but I've just had a look through it, and added a couple of things / removed some stuff that isn't available any more Smile

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Posting a list of all users In reply to
Andy wrote:
Code:
sub {

my $db = $DB->table('Links');
$db->select_options( "GROUP BY LinkOwner","ORDER BY link_count DESC" );
my $sth = $db->select("LinkOwner", "COUNT(*) as link_count") or die "Query Error: $GT::SQL::error";

my $back;
while (my ($s, $c) = $sth->fetchrow_array) {
$back .= qq|LinkOwner: $s Link Count: $c <br />|;
}

return $back;

}

Hi Andy,
is there a way to modify this global to show Link Owners with more than one link?
The list is to long with all users. Would be great if the global shows only users with more than one link.

Matthias

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] Posting a list of all users In reply to
Hi,

It should be as simple as adding just the bit in red:

Code:
sub {

my $db = $DB->table('Links');
$db->select_options( "GROUP BY LinkOwner","ORDER BY link_count DESC" );
my $sth = $db->select("LinkOwner", "COUNT(*) as link_count") or die "Query Error: $GT::SQL::error";

my $back;
while (my ($s, $c) = $sth->fetchrow_array) {
if ($c < 2) { next; }
$back .= qq|LinkOwner: $s Link Count: $c <br />|;
}

return $back;

}

Hope that helps.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Posting a list of all users In reply to
That's it Andy simple but works perfect
Thanks
Matthias

Matthias
gpaed.de