Gossamer Forum
Home : Products : Gossamer Forum : Discussion :

help debugging a subroutine

Quote Reply
help debugging a subroutine
Hi,

I'm hoping someone can shed some light on this. I've got a special FACustom.pm file with a subroutine that's supposed to calculate the number of posts in an Announcements forum since the last time the user was seen at that forum. This count is also supposed to max out at the last 30 days, so nothing older than that should be counted.

Right now something is seriously messed up, since when I call it in the template I'm getting the following error message:

Error: Unable to load module: GForum::FACustom. Reason:
Error: No subroutine 'GForum::FACustom::getUserNewAnnouncements' in 'GForum/FACustom.pm',
Error: No subroutine 'GForum::FACustom::getUserNewAnnouncements' in 'GForum.pm'

Code:
use strict;
use vars qw/@EXPORT_OK/;
use GForum qw/$DB $USER $CFG/;

sub getUserNewAnnouncements {
if ($USER) {

my $cutoff = shift;
if(!$cutoff) {
$cutoff = time() - (3600*24*30);
}

my $user_id = $USER->{user_id};
my $forum_id = 11; #this is the id of the announcements forum
my $last_in_forum = $DB->table('UserNew')->select('usernew_last' => { user_id_fk => $user_id, forum_id_fk => $forum_id})->fetchrow_hashref->{usernew_last};

if(!$last_in_forum || $last_in_forum < $cutoff) {
my $cond = GT::SQL::Condition->new(
forum_id_fk => '=' => $forum_id,
post_root_id => '=' => 0,
post_time => '>' => $cutoff
);

return $DB->table('Post')->count($cond);

} else {
my $cond = GT::SQL::Condition->new(
forum_id_fk => '=' => $forum_id,
post_root_id => '=' => 0,
post_time => '>' => $last_in_forum
);

return $DB->table('Post')->count($cond);
}

} else {

return 0;
}
}

1;

Thanks in advance for any suggestions.

Fractured Atlas :: Liberate the Artist
Services: Healthcare, Fiscal Sponsorship, Marketing, Education, The Emerging Artists Fund
Subject Author Views Date
Thread help debugging a subroutine hennagaijin 5483 Apr 8, 2005, 2:32 PM
Thread Re: [hennagaijin] help debugging a subroutine
Andy 5359 Apr 9, 2005, 1:26 AM
Thread Re: [Andy] help debugging a subroutine
hennagaijin 5384 Apr 9, 2005, 4:42 AM
Thread Re: [hennagaijin] help debugging a subroutine
Andy 5343 Apr 9, 2005, 11:15 AM
Thread Re: [Andy] help debugging a subroutine
hennagaijin 5359 Apr 9, 2005, 11:40 AM
Post Re: [hennagaijin] help debugging a subroutine
Andy 5357 Apr 10, 2005, 11:36 PM
Thread Re: [hennagaijin] help debugging a subroutine
Andy 5372 Apr 10, 2005, 11:39 PM
Post Re: [Andy] help debugging a subroutine
hennagaijin 5349 Apr 14, 2005, 6:46 AM