Gossamer Forum
Home : Products : Others : Gossamer Community :

ReceiveMail = Yes/No

Quote Reply
ReceiveMail = Yes/No
How to put ReceiveMail = Yes/On option in Community when user register so he can choose to receive or not to receive emails from administrator.

Also, maybe it would be better to put Email functions (send mails to users) in Gcomm.

Regards.

UnReal Network
Quote Reply
Re: [deadroot] ReceiveMail = Yes/No In reply to
Hi,

This should help:

http://www.gossamer-threads.com/...?post=297997#p297997

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] ReceiveMail = Yes/No In reply to
That worked well.

I've put ReceiveMail in my GComm and it's ok. But, now I want to copy 'options' from ReceiveMail in GLinks user table to GComm user table so user can see that new option in their profile. How to do this?

Thanks.

Regards.

UnReal Network
Quote Reply
Re: [deadroot] ReceiveMail = Yes/No In reply to
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 Angelic

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!