Gossamer Forum
Home : Products : Gossamer Links : Version 1.x :

Widgetz Modify mod

Quote Reply
Widgetz Modify mod
Hi,

I have installed the widgetz mod that prevent to add or modify a link whithout being log in :
http://www.gossamer-threads.com/perl/forum/showthreaded.pl?Cat=&Board=LSQLDisc&Number=69800&page=&view=&sb=&vc=1#Post69800

with this mod, when a user want to add a site, he click on add then he is prompt to the login page then he enter a login and a password ; After, a page say him you are log in and after he can browse the site to choose a category. He click on add a link in the category of his choice and he is prompted to the form that permited him to add a link.

I would like the following thing :
1) when a user is in the category (ie /hardware/motherboard/) of his choice, he click on add a link.
2) The user is prompted to the login form (to prevent him from adding a link whithout being logged).
3) After he logs, instead of having the message you are log in the user in redirect to the modify form corresponding to the ctegory he choose (ie /hardware/motherboard/)

In order to achieve this, i have installed the code by widgetz which allowed to redirect :

if ($to) {
print $in->redirect( -uri => "$LINKS{build_root_url}$to" );
}
else {
# regular stuff
}
and the template code

<%if to%>
<input type="hidden" name="to" value="<%to%>">
<%endif%>

but i have 2 problem :
1 it does not work
2 in what template have i to install the code :

<%if to%>
<input type="hidden" name="to" value="<%to%>">
<%endif%>

bye

manu


Quote Reply
Re: Widgetz Modify mod In reply to
Hi manu

The redirection works in 4 Steps

1. The user clicks on the link /add.cgi?ID=12
( add.cgi is called with the param ID=12 )

add.cgi checks if the user is logged in.
If not it will redirect the user to user.cgi passing
the parameter 'to' with the value 'add.cgi?ID=12'
( user.cgi?to=$ENV{'SCRIPT_NAME'} )

my $s = $in->param('s') || $in->cookie('s');
$USER = &authenticate ($s);
if (! defined $USER) {
my $id=$in->param('ID');
if ($id){
my $para='?ID='.$id;
print $in->redirect("$LINKS{db_cgi_url}/user.cgi?to=$ENV{'SCRIPT_NAME'}$para") and return;
}
else {
print $in->redirect("$LINKS{db_cgi_url}/user.cgi?to=$ENV{'SCRIPT_NAME'}") and return;
}
}

2. User.cgi is being called with the param To=add.cgi?ID=12

It will now display the loginscreen. It checks if the param 'to' is given and passes it to the sub site_html_login_form.

my $to =$in->param('to');
&site_html_login_form ( { Username => $username, to => $to }, $dynamic);

You have to insert the Tag <%To%> in the template login.html in the form.
with the code:

<%if to%>
<input type="hidden" name="to" value="<%to%>">
<%endif%>

The User submits the loginform (with the field 'to')

3. User.cgi is called from the loginform
It calls the sub login_user. In this subroutine the param 'to' is evaluated with the code:

my $to =$in->param('to');

after the user is checked an logged in this sub displays the loginsuccess page passing the 'to' tag

&site_html_login_success ( {to=>$to}, $in );


4. I inserted a refresh with the value 'to'
in the <head> section of the template login_success.html

<%if to%>
<meta http-equiv="refresh" content="3;URL=<%to%>">
<%endif%>

this refresh will send the user to the page he intended to go.
( in this case to add.cgi?ID=12 )because he is logged in he will be able to ad a link.

regards, alexander