Gossamer Forum
Home : Products : Gossamer Forum : Discussion :

How to update User table with an external global?

Quote Reply
How to update User table with an external global?
Hi,

I try to update the GForum User table throw a global in Links SQL. Here the global I try to use in Links SQL:

Code:

sub {
my $vars = shift;
my $user_id = $vars->{user_id};
use lib '/path/to/GForum/admin';
my $tu = GT::SQL->new ("/path/to/GForum/admin/defs");
$tu->table('User')->update( { user_something => '1' }, { user_id => $user_id } );
}


When I try the global, I receive this error:

Code:

Can't call method "table" on an undefined value at /path/to/GForum/admin/GForum/Table/User.pm line 360.


The global works with the Post or Forum table, but not with the User table. It's probably a permission problem, but I don't know how to solve it.

Thank you very much for your help!

François

Last edited by:

Franco: May 19, 2004, 7:48 AM
Quote Reply
Re: [Franco] How to update User table with an external global? In reply to
Hi François,

Try adding:

$GForum::DB = $tu;

after the 'my $tu =' line. Gossamer Forum attempts to access other columns when doing a User table update, and uses $GForum::DB for this.


Jason Rhinelander
Gossamer Threads
jason@gossamer-threads.com
Quote Reply
Re: [Jagerman] How to update User table with an external global? In reply to
J-Man:

This is something I was working on for a while, and gave up on.... but this thread has started me on it again. What I am trying to go is get GTComm to update Links and Forum User Tables when I disable a user. Basically, when I disable a user in GTComm, I want it to go and disable the user, as well as turn off any Mail things in their profiles...

I have had it updating Links for a while, but I still have to go update Foryum, because (as above) I could never get forum)Users to update.

Followed the instructions above, and I get this error:

Quote:

Can't call method "fetchrow_array" on an undefined value at /hd2/web/f/forum/public_html/forum/admin/GForum/Table/User.pm line 275. GT::SQL::error => Failed to execute query: 'SELECT user_id,user_username,user_status FROM forum_User WHERE Username = ?' Reason: Unknown column 'Username' in 'where clause' OK


I am GUESSING I need to somehow pass the Username over to Forum???

Here is the code I am using in Community::Web:Admin:

Quote:

require lib;
lib->import('/hd2/web/b/bcdb/public_html/bcdb/admin');
lib->import('/hd2/web/f/forum/public_html/forum/admin');

my $other_db = new GT::SQL '/hd2/web/b/bcdb/public_html/bcdb/admin/defs';
my $user_db = $other_db->table ('Users');

my $other_db1 = new GT::SQL '/hd2/web/f/forum/public_html/forum/admin/defs';
$GForum::DB = $other_db1;
my $user_db1 = $other_db1->table ('User');

... blah blah...

if ($user->{comm_enabled} == '0') {
$user_db1->update ( {
user_enabled => '0',
user_admin_validated => '0',
user_default_reply_notify => '0',
user_status => '1',
user_message_notify => '0',
user_real_name => "$user->{prof_first_name} $user->{prof_last_name}",
user_homepage => $user->{prof_website},
user_member => $user->{comm_member},
user_occupation => $user->{prof_occupation},
user_location => $user->{prof_location}
}, { Username => $user->{comm_username} }) or die "Can't Update: $GT::SQL::error";
}
dave

Big Cartoon DataBase
Big Comic Book DataBase
Quote Reply
Re: [carfac] How to update User table with an external global? In reply to
For what it's worth, the above code works fine in Community::Web:User.pm- I put code in there so that when someone updates their, lets say Location in GTCom, it will update the Location in Links and Forum.

If I can vent for a minute... this is something I have suggested before for inclusion in GT Com for a while- updating the satelite programs from GT Com... when a user updates a profile in GT Com, I think it just makes sense that Comm should update the other programs associated with it. I have coded this function in, and it works great.

Taking it a step further- and what I am trying to do with Community::Web:Admin.pm- I think the admin updates should update the other programs, too, but also do more (we are, after all, the admins!). When I make a change as an admin, it is typically because of bounced e-mail. So I go to Comm Admin, and disable the account. With a bit of extra coding, I have also gotten it to close the Links account, and set Recieve Mailer to "No" when I do that. If I can get Forum in on this, too, I will close that account, and set "Send PM Notice" and "Send Reply Notice" to No, too... which just seems to make sense when you are closing an account because of bounced e-mail.

OK, Rant Off... just my idea of what should make Comm better integrate into Forum!
dave

Big Cartoon DataBase
Big Comic Book DataBase
Quote Reply
Re: [carfac] How to update User table with an external global? In reply to
OK, fixed the code. I just copied and pasted the Links code down, not noticing that "Username" (in "{ Username => $user->{comm_username} }) or die "Can't Update: $GT::SQL::error"; ") changes to "user_username" in forum!

Running sweet!
dave

Big Cartoon DataBase
Big Comic Book DataBase
Quote Reply
Re: [Jagerman] How to update User table with an external global? In reply to
Thank you very much Jason!

I will try it this weekend.