Gossamer Forum
Home : Products : Others : Gossamer Community :

Automatic update of application fields

Quote Reply
Automatic update of application fields
This is a small feature request for a next version of Gossamer Community.

It would be very nice if the admin could define fields for every application in community that are automatically updated whenever a user updates the field in his profile. For example, let's say you have set up a new field in community 'prof_newsletter'. Whenever a user changes their preference about whether or not to receive the newsletter, this should automatically be reflected in a Links SQL application that is tied to community.

One could maybe add a text box to the 'edit application' page, where the admin could specify something like the following for his Links SQL application
Code:
prof_newsletter => Newsletter
prof_mailings => ReveiveMailings
I hope this makes sense.

I think this would not be very difficult to implement, and it would be very powerful.

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] Automatic update of application fields In reply to
Hi,

Yes, currently this only happens for email, but making it generic would definitely be a good idea.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Automatic update of application fields In reply to
+1

Wink
Quote Reply
Re: [yogi] Automatic update of application fields In reply to
I already took care of that

Added to the Community/Apps/Local/LinksSQL.pm file the following lines, to both INSERT and UPDATE methods, assuring that
the LSQL DB is always up-to-date and the Mailing info can be used.

added to UPDATE method:
Name => "$user->{prof_first_name} $user->{prof_last_name}",
ReceiveMail => $user->{prof_ReceiveMail},
Newsletter => $user->{prof_Newsletter}

added to INSERT method:
ReceiveMail => $user->{prof_ReceiveMail},
Newsletter => $user->{prof_Newsletter}
Quote Reply
Re: [jaltuve] Automatic update of application fields In reply to
Thanks for that tip - very useful and has helped me make Community live on my site.
Quote Reply
Re: [jaltuve] Automatic update of application fields In reply to
Yes, that's indeed the method to use at the moment, and I also implemented it on my site.

However, my proposal was to have this implemented such that you don't have to hack the modules if you want to update application fields.

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] Automatic update of application fields In reply to
Totally agree - will be much better when we don't have to hack the code.
Quote Reply
Re: [afinlr] Automatic update of application fields In reply to
Hi,

I'm trying this and it still doesn't seem to be working...Could it be the fact that I have two different implentations of linksSQL regsitered under my GComm?

Anyway, here's my update...

Code:

sub update {
# -------------------------------------------------------------------
# Update is called whenever a community user information is changed.
#
my ($app, $user) = @_;
_setup($app) or return;
comm_debug("Updating user |$user->{comm_username}| to new email address |$user->{comm_email}|");
my $ok = $Links::DB->table('Users')->update(
{
Email => $user->{comm_email}
},
{
Username => $user->{comm_username}
},
{
Name => "$user->{prof_first_name} $user->{prof_last_name}"
}
);
if ( $ok ) {
comm_debug("success. |$user->{comm_username}| updated in Links SQL.");
return 1;
}
comm_debug("Could not update user |$user->{comm_username}| because $GT::SQL::error in LinksSQL.");
return;
}



Thanks, Mike
Quote Reply
Re: [Swaylock] Automatic update of application fields In reply to
I think you want this:

update(
{
Email => $user->{comm_email},

Name => "$user->{prof_first_name} $user->{prof_last_name}"
},
{
Username => $user->{comm_username}
}
);


The first bracket contains the fields that you want to update and the second bracket contains the field that you are using to lookup the row in the table.
Quote Reply
Re: [afinlr] Automatic update of application fields In reply to
Doh! Shocked -- that makes total sense now.

Actually, I kinda realized that just before I went to bed last night when in one of my trials, I ended up changing each record all of my linksSQL users to be the same person! Laugh

Guess i'll reimport and start over.

Thanks -- it's good to know some folks are willing to help,
Mike
Quote Reply
Re: [Swaylock] Automatic update of application fields In reply to
Hi...

Where would I call this update subroutine? I want it so that when a user changes his or her name, it is automatically changed in the linksSQL database as well without hacking the code. Why is the email in the update sub routine if it is already taken care of? Also, would I put this in the community globals or linksSQL globals?

Thanks,

- Jonathan
Quote Reply
Re: [jdgamble] Automatic update of application fields In reply to
Just now figured out what I need to do... How hard would it be to write a plugin that changes the update sub routine in linksSQL.pm? What hook would I use... Any advice would be appreciated.

Thanks,

- Jonathan
Quote Reply
Re: [afinlr] Automatic update of application fields In reply to
Hi,

I just wanted to add the following information just in case it can help someone. When using this "mod" if you find that it is not working you may want to check on the status of the user in the "User Management" area.

I was pulling my hair out wondering why only modifications through the admin panal in Links where affecting the user I was testing.

On checking the user in the User Management area I noticed the Application status of Links (below the user form) was set at 'Disabled' or 'Not Created'. Changing this to 'Enabled' had, as you can imagine, the wonderful effect of allowing the above modifications to work.

I had already come across this issue before and Virginia from GT had pointed it out to me on another project. I just thought this might save somebody else's time ;)

Cheers,

John

PS : I had got to the user being disabled like this through having left an extra bracket by mistake and I'm guessing there is some king of fail safe that disabled the user I tried to update, a kind of idiot-proof fail safe ;)
Significant Media
Quote Reply
Re: [jaltuve] Automatic update of application fields In reply to
O.K. Here are my changes in LinksSQL.pm

Code:
sub insert {
# -------------------------------------------------------------------
# Insert is called whenever a new user is created. You should add the
# user to your application, and return 1 on success, 0 on error and have
# the error message stored in $Community::error.
#
my ($app, $user) = @_;

_setup($app) or return;
my $user_ins = {
Username => $user->{comm_username},
Password => ' ',
Email => $user->{comm_email},
Name => "$user->{prof_first_name} $user->{prof_last_name}",
ReceiveMail => $user->{prof_ReceiveMail},
Newsletter => $user->{prof_Newsletter},

Status => 'Registered'
};


Code:
sub update {
# -------------------------------------------------------------------
# Update is called whenever a community user information is changed.
#
my ($app, $user) = @_;
_setup($app) or return;

comm_debug("Updating user |$user->{comm_username}| to new email address |$user->{comm_email}|");
my $ok = $Links::DB->table('Users')->update(
{
Email => $user->{comm_email},
Name => "$user->{prof_first_name} $user->{prof_last_name}",
ReceiveMail => $user->{prof_ReceiveMail},
Newsletter => $user->{prof_Newsletter}

},
{
Username => $user->{comm_username}
}
);



But what should I do now?
I think I have to add the two Columns called prof_ReceiveMail and prof_Newsletter in Community with the same conditions as in gossamer links.
Thats where I get stucked.
ReceiveMail in links is a ENUM Column and in Community there is no option to add a ENUM Column???

Who can help me?
Matthias

Matthias
gpaed.de

Last edited by:

Matthias70: Aug 13, 2007, 4:21 PM
Quote Reply
Re: [Matthias70] Automatic update of application fields In reply to
Hi,

You shouldn't need to use ENUM for those fields. Try it with a CHAR (say 5 characters long, as you don't need any more than that for a yes/no field =))

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!
Quote Reply
Re: [Andy] Automatic update of application fields In reply to
Hi Andy,
works great with prof_ReceiveMail in Community and ReceiveMail in gossamer links :-)
but I can not find the column newsletter in links 3.2.0 user tables?

I'm using the wonderful plugin RNotifier from Andy.
Andy what do you think can the columns ReceiveReviewReplys and ReceiveYourPostReplys autoupdated in the community profile as well?

Thanks
Matthias

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] Automatic update of application fields In reply to
Hi,

I believe the ReceiveMail option is for the Newsletter.

Quote:
I'm using the wonderful plugin RNotifier from Andy.
Andy what do you think can the columns ReceiveReviewReplys and ReceiveYourPostReplys autoupdated in the community profile as well?

I don't see why that wouldn't work too.

Just change that code you posted above, to:

Code:
Email => $user->{comm_email},
Name => "$user->{prof_first_name} $user->{prof_last_name}",
ReceiveMail => $user->{prof_ReceiveMail},
Newsletter => $user->{prof_Newsletter},
ReceiveReviewReplys => $user->{prof_ReceiveReviewReplys},
ReceiveYourPostReplys => $user->{prof_ReceiveYourPostReplys}

..and obviously you need to create the new prof_ fields :)

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!
Quote Reply
Re: [Andy] Automatic update of application fields In reply to
Hi Andy,
thanks it works perfect :-)
Matthias

Matthias
gpaed.de