Hi,
First of all BACKUP YOUR WHOLE DATABASE in case it doesn't do what you want!!!! Something like this should work (call it update_mail.cgi):
NB: This isn't tested, I just wrote it for you
Code:
#!/usr/bin/perl5
use strict;
use lib '
/path/to/community/secure_data/lib';
use Community qw/comm_init comm_config comm_fatal $DB $IN $CFG/;
use GT::CGI;
use GT::Date;
use CGI::Carp qw(fatalsToBrowser);
use Carp;
require Community::Web::User;
use GT::SQL::Condition;
local $SIG{__DIE__} = \&fatal;
Community::init('
/path/to/community/secure_data');
print $IN->header();
my $NEWDB = loadConnection("
/path/to/glinks/admin/defs");
my $sth = $DB->table('Users') || die $GT::SQL::error;
while (my $user = $sth->fetchrow_hashref) {
update_profile($user->{Username},$user->{ReceiveMail});
print qq|Updating $user->{Username} with RecieveMail set to "$user->{ReceiveMail}" \n <br />|;
}
sub update_profile {
my $Username = $_[0];
my $ReceiveMail = $_[1];
$DB->table('users')->update( {
RecieveMail => $RecieveMail }, { comm_username => $Username } ) || die $GT::SQL::error;
}
sub loadConnection {
my $path = $_[0];
my $NEWDB = new GT::SQL (
def_path => $path,
cache => 0,
debug => 0,
subclass => 1
);
return $NEWDB;
}
Be sure to replace the bits in
bold with the right paths for your installation.
Also, the bit in red may need changing - depending on how you added the new field.
Possible combinations may be:
prof_RecieveMail
comm_RecieveMail
Give the first one a go - as that will most likely work - but there's a small chance it won't :)
You can run it via SSH or browser (SSH is preferred)
Code:
cd /path/to/folder/its/in
perl update_mail.cgi
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!