Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

Browser Multiple Add forms depending on type of link

Quote Reply
Browser Multiple Add forms depending on type of link
I'm trying to get the browser.cgi system to allow for different forms for different types of links and at the moment I can get one custom add form to work :

I'll have :

http://www.sitename.com/perl/browser.cgi?category_id=1&action=link_add_form
this comes from the browser_link_add_form.html template where I have replaced <%form%> with my own code and created all the hidden input fields for my own form manually.

So I'd like to add :
browser_link_add_form_type2.html
to get a link to :
http://www.sitename.com/perl/browser.cgi?category_id=1&action=link_add_form_type2

But I'm getting an error :
"You're not authorised to do this" type error when I click on this link

Does anybody know whether it's possible to get around this. Does the template need to be declared somewhere and access permissions created or is it to do with the user ??

Any ideas ?

Thanks, John
Significant Media

Last edited by:

Jag: Apr 8, 2005, 2:21 PM
Quote Reply
Re: [Jag] Browser Multiple Add forms depending on type of link In reply to
I'll be interested in hearing the answer to this as well, since I will need multiple add forms for 2 of my installations.
Quote Reply
Re: [Jag] Browser Multiple Add forms depending on type of link In reply to
To add different actions, you need to add the action to Links/Browser/Controller.pm. See sub link_add_form in there.

Adrian
Quote Reply
Re: [brewt] Browser Multiple Add forms depending on type of link In reply to
Hi Adrian,

Thanks for your response.

I just added this :
Code:
sub link_add_form_site {
# -------------------------------------------------------------------
# Display add link form.
my $self = shift;
my $base = $self->is_in_subtree ($IN->param ('category_id')) or return;
return ($self->{perms}->{$base}->{CanAddLink} eq 'Yes') ? 1 : 0;
}

with regards to my example but I'm still getting the you are not authorised to do this message...

It's this message : BROWSER_UNAUTHORIZED from the language file. Don't know if that helps to figure out what is going on ?

Thanks, John
Significant Media
Quote Reply
Re: [Jag] Browser Multiple Add forms depending on type of link In reply to
When you pass in action=some_action_name, it will check Links::Browser::Controller::some_action_name to see if you have permission to perform that action. If you do, it will then run Links::Browser::some_action_name.

Adrian
Quote Reply
Re: [brewt] Browser Multiple Add forms depending on type of link In reply to
I'm still not quite able to understand what I'm supposed to be doing.

In the Links/Browser/Controller.pm you said I should add an action.

I have :
Code:
sub link_add_form {
# -------------------------------------------------------------------
# Display add link form.
my $self = shift;
my $base = $self->is_in_subtree ($IN->param ('category_id')) or return;
return ($self->{perms}->{$base}->{CanAddLink} eq 'Yes') ? 1 : 0;
}

sub site_add_form {
# -------------------------------------------------------------------
# Display add link form.
my $self = shift;
my $base = $self->is_in_subtree ($IN->param ('category_id')) or return;
return ($self->{perms}->{$base}->{CanAddLink} eq 'Yes') ? 1 : 0;
}

sub link_add {
# -------------------------------------------------------------------
# Display add link form.
my $self = shift;
my $base = $self->is_in_subtree ($IN->param ('CatLinks.CategoryID')) or return;
return ($self->{perms}->{$base}->{CanAddLink} eq 'Yes') ? 1 : 0;
}

sub site_add {
# -------------------------------------------------------------------
# Display add link form.
my $self = shift;
my $base = $self->is_in_subtree ($IN->param ('CatLinks.CategoryID')) or return;
return ($self->{perms}->{$base}->{CanAddLink} eq 'Yes') ? 1 : 0;
}



Both "link_add" and "link_add_form" are already in Controller.pm so I added "site_add" and "site_add_form" since I don't know what the relationship is between the initial two.

Since I basically am adding a new link I have not seen it necessary to create a new permissions value "CanAddLink" but maybe this is where the issue is ? Do I need to add a new permission like "CanAddSite" I find it weird that I can't rely upon the "CanAddLink" permissions since in the above example both "link_add" and "link_add_form" do.

I have two extra templates :
browser_site_add_form.html
browser_site_add.html

Plus a link in browser_navbar.html to :
<%if CanAddLink eq 'Yes'%> <br /><a href="<%db_cgi_url%>/browser.cgi?category_id=<%category_id%>&action=link_add_form">Add an Article</a> | <a href="<%db_cgi_url%>/browser.cgi?category_id=<%category_id%>&action=site_add_form">Add A Site</a><%endif%>

Note Both links appear in the browser and the second gives me the error.

I'm testing with a user that has permissions to add a link with "CanAddLink" set to Yes.

Thanks, John
Significant Media
Quote Reply
Re: [brewt] Browser Multiple Add forms depending on type of link In reply to
Hi Adrian,

Mea culpa as they used to say...

Too much French wine Wink

In Reply To:
If you do, it will then run Links::Browser::some_action_name.

I was stuck on the controller.pm

Didn't see that you referring to Browser.pm

Created a sub in there as well and I now have my "site" template Smile.

If I may could you tell me what the "link_add" sub is and whether I need to create this type of sub to accompany the "link_add_form" as I was thinking above. In other words do I need "site_add" for my "site_add_form" to work ?

Thanks very much Adrian

John
Significant Media
Quote Reply
Re: [Jag] Browser Multiple Add forms depending on type of link In reply to
Hi,

Just found the "link_add" action in the link_add_form template, I used the same for the other template and it seems to work OK so it doesn't look I need to create a separate site_add sub...

Cheers, John
Significant Media