Gossamer Forum
Home : Products : Gossamer Links : Discussions :

launch a script when a link is added

Quote Reply
launch a script when a link is added
Hi,

I would like to launch a cgi script called alert.cgi when a link is added.

Which file do I have to modify and where?

Thanks in advance for your answers.

Vercyb
Quote Reply
Re: [vercyb] launch a script when a link is added In reply to
Your best bet would probably be to make a global, which calls your script, and then call it on add_success.html. Something like;

Code:
sub {
system('perl /full/path/to/script.cgi');
}

... and then in add_success.html, put something like <%global_name%> (with global_name obviously being replaced with the actual name of your global) .... and then that script should be run each time someone submits a link on your site Smile

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] launch a script when a link is added In reply to
Hi,

> on add_success.html.

If I am not wronf this template is used when a user add a link, but what is the template to modify when it comes to admininistrators?

Thanks

Vercyb

In Reply To:
Your best bet would probably be to make a global, which calls your script, and then call it on add_success.html. Something like;

Code:
sub {
system('perl /full/path/to/script.cgi');
}

... and then in add_success.html, put something like <%global_name%> (with global_name obviously being replaced with the actual name of your global) .... and then that script should be run each time someone submits a link on your site Smile

Cheers
Quote Reply
Re: [vercyb] launch a script when a link is added In reply to
I'm not quite sure what you mean :/

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] launch a script when a link is added In reply to
I mean that I want to activate this script when a site is added from the adminstrator side (where it is possible to modifty the templates, go directli into ther database and so on).

I have tried to modify the add_success.html but it seems that it does take effect. Is there any to compile or something like that?

Regards,

Jérôme

In Reply To:
I'm not quite sure what you mean :/

Cheers
Quote Reply
Re: [vercyb] launch a script when a link is added In reply to
You would probably be best to write a plugin, which would access the add_link hook, and check to see if its been added via the admin panel, and if it has, then run the script.

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] launch a script when a link is added In reply to
What about using the gloabal and modifying the admin template set?

I can see a use for this ... as it's one of the things that has bugged me, and why editor/user tracking was discussed awhile back. I had started a logging program, to track all changes, sort of like a program log file. I was worried mostly about links or posts being edited by inexperienced or malicious editors.

Any changes would be logged to a file in standard CSV or log format. I don't think an SQL database would be needed, though it would be possible. You'd just need a table for each log event you'd want to watch, and link them via time or ID if they were related. It could get really, really hairy quickly, but if your concern was mainly changes to links, editor_name/Link_data_original/Link_data_changed was about all you needed to track (plus date/time). If the _data_ fields were text fields that held a data dump hash, they could be easily read into a formatting routine for comparason.

Tracking category moves, edits, and such was more of an issue.

Link deletions were treated as "modifications" BTW, with an empty Link_data_changed field.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] launch a script when a link is added In reply to
Hi,

Thanks to your various answers I have partially succeded

I have done directly in admin.pm in the add_success part which is like this:

$COMPILE{add_success} = __LINE__ . <<'END_OF_SUB';
sub add_success {
my ($self, $id) = @_;
print $self->{in}->header;
my $hsh;
if ($self->{table}->ai) {
$hsh = $self->{table}->get ($id, 'HASH');
}
else {
my $lookup = {};
my $pk = $self->{table}->pk;
foreach (@$pk) { $lookup->{$_} = $self->{cgi}->{$_}; }
$hsh = $self->{table}->get ($lookup, 'HASH');
}
print $self->_start_html ( { title => "Record Added" });
print $self->_header ("Record Added", "The following record was successfully added:");
print "<p>";
print $self->{html}->display ( { mode => 'add_success', values => $hsh } );
print "<p>", $self->_footer;
print $self->_end_html;

and added some line code to send a mail like:

open (MAIL,"|/usr/sbin/sendmail -it");
print MAIL "To: user\@domain.com\n";
print MAIL "From: user\@domain.com\n";
print MAIL "Subject: new link\n";

**************

Now what I woiuld like to do is to also send in the mail the information related to the link that has been added.
How can I get them all?
How can I get one in particular, for instance the category?

Thanks
Quote Reply
Re: [vercyb] launch a script when a link is added In reply to
Hi. You would be better using GT::Mail;

Code:
require GT::Mail;
$GT::Mail::error ||= ''; # Silence -w
GT::Mail->send (
smtp => '',
sendmail => '/usr/sbin/sendmail',
from => $from,
subject => $subject,
to => $to,
msg => $msg,
debug => $Links::DEBUG
) or die "Unable to send mail: $GT::Mail::error";

... and then to define the values that were entered, you would use;

$IN->param('VariableName')

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!