Home : Products : Gossamer Links : Development, Plugins and Globals :

Products: Gossamer Links: Development, Plugins and Globals: Re: [YoYoYoYo] Global to display user link count?: Edit Log

Here is the list of edits for this post
Re: [YoYoYoYo] Global to display user link count?
Quote:
Of course, it would be much better if counts of validated, unvalidated and deleted links were stored in the User table.
GT: next version?

Try this. It could packaged into a trivial plugin, and use a <%GT::Plugins::Get_Counts%> format for updating the tags.

Also, if you used a plugin, you could hook into the "delete" routine, and keep a count of links deleted. That can't be done via a global.

Code:
sub {
## if you add two columns to your Users table, Link_Count_Validated and Link_Count_Unvalidated
## every time a user logs on, their counts will be updated in their user record.
## low overhead call, as long as you only call it on the Logon Success page.
## or, add a test, and another parameter to flag the updates.
##
## my $update_USER_counts = shift;
##
## and wrap the db_user->update call in an 'if $update_USER_counts call.
## pass in <%get_user_link_count (1)%> to flag the update, 0 to ignore.
##
my $update = shift;
($USER) || return (user_link_count => 0, user_link_count_un => 0, user_link_count_val => 0);
my $db = $DB->table('Links');
## print "username is: $USER->{Username}";
my $user_link_count_val = $db->count(isValidated => 'Yes', LinkOwner => $USER->{Username});
my $user_link_count_un = $db->count(isValidated => 'No', LinkOwner => $USER->{Username});
my $user_link_count = $user_link_count_val + $user_link_count_un ;

if ($update) {
my $db_user = $DB->table('Users');
$db_user->update ( {
Link_Count_Validated => $user_link_count_val,
Link_Count_Unvalidated => $user_link_count_un
},
{
Username => $USER->{'Username'}
});

};


##print "User link count is : $user_link_count";
return ( {
user_link_count => $user_link_count,
user_link_count_un => $user_link_count_un,
user_link_count_val => $user_link_count_val
})
}



Note... I didn't try this, the concept should work, might contain some typos.

NOTE: I did try it, fixed the typos, and it seems to work as indicated.


THe html is:



Code:
<%get_user_link_count (1)%>
<%if user_link_count > 0%>
<P>
You have <%user_link_count_val%> validated links<BR>
You have <%user_link_count_un%> unvalidated links<BR>
You have <%user_link_count%> total links in the system.
</P>
<%endif%>


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.

Last edited by:

pugdog: Apr 21, 2003, 6:26 PM

Edit Log: