Gossamer Forum
Home : Products : Others : Gossamer Community :

Editor Only Link

Quote Reply
Editor Only Link
Hi,
I already posted a similar question in the LinksSQL area, but does anyone know how to only display link for those that have access to it. Editors will be the only people needing to access the forum and I can't figure out how to only display the link for people that are editors in LinksSQL ???

Thanks, John
Significant Media
Quote Reply
Re: [Jag] Editor Only Link In reply to
I'm not sure what you have tried but this is from the default category template.

<!-- Editors -->
<%Links::Utils::load_editors%>
<%if editors%>
<%header_row%><td width="30%">
<%header_font%>EDITORS:<%/header_font%></td>
<td width="70%" bgcolor="white">&nbsp;</td></tr>
<tr><td colspan=2><%body_font%>
<ul><%editors%></ul></font></td></tr>
<%endif%>

The above should show the editors for the category but I'm unsure what it displays.
You may have to call the editors inside of the above.
ie
<%Links::Utils::load_editors%>
<%if editor%>
Editor link
<%endif%>

This is from the help menu:
<%Links::Utils::load_editors%>
<%if editors%>
The following users maintain this category: <%editors%>
<%endif%>

I don't use editors so I'm not that familiar , can you just call the username for the person that is an editor ?
<%if username jeditor or username beditor or username ceditor%>
editor link
<5endif%>

Regards

minesite

Last edited by:

minesite: Sep 12, 2004, 8:58 PM
Quote Reply
Re: [minesite] Editor Only Link In reply to
I'm sorry I wasn't explicit enough in my first post, my fault.

I want to display a link on the Gossamer Community Login Page along with the link to the profile information and where extra applications is displayed by default, to the forum.

The Forum is only going to be used by editors hence my question about finding a way to only display it for the editors.

However I'm not sure how to get Gos Community to check for editor status in LinksSQL, 'cos "<%Links::Utils::load_editors%>" won't work from within a Gos Community template.

John

Edit : Is something like this going to do it ?
sub { my $user = shift; lib->import('/path/to/links/admin');
# might not be necessary require GT::SQL;

from :
http://www.gossamer-threads.com/...i?post=246859#246859
Significant Media

Last edited by:

Jag: Sep 13, 2004, 5:12 PM
Quote Reply
Re: [Jag] Editor Only Link In reply to
Hi Jag

I don't use the editors feature so I'm not going to be real helpfull.

I presume the Community login page is also accessed by the general public and not just editors.

And do you have the Pagebuilder plugin ?

Regards

minesite
Quote Reply
Re: [Jag] Editor Only Link In reply to
Hi,

You'd need a custom global for this, something that connects to Links SQL and checks to see if the logged in user is an editor.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Editor Only Link In reply to
Ok,

I'm actually laughing right now, Laugh which is a good sign. I'm getting near to the launch of the web site and I'm really happy with what I've done, which I wouldn't have been able to do without your great scripts and some really cool plug-ins.
As for the laughing it's a sort of "yeah man nice answer" Crazy and if you weren't the guy who did the scripts that I'm greatfull for I'd most probably be writing something "a bit cocky" as they say in the UK, but thanks for the answer I'll know where to start looking for a solution to this...

Maybe it could be added to the next release Wink please Blush

John

Thanks for a great ride so far, your scripts are well cool... Wink
Significant Media
Quote Reply
Re: [Jag] Editor Only Link In reply to
Hi,

Sorry, that was a bit of a useless answer. =) How about this: You need a global to connect to Links SQL. Something like:

sub {
my $tags = shift;
my $username = $tags->{comm_username};
my $db = GT::SQL->new('/path/to/linkssql/admin/defs');
my $is_editor = $db->table('Editors')->count( { Username => $username });
return $is_editor;
}

Then you could do:

<%if is_editor%>
display link
<%else%>
display something else
<%endif%>

Hope that helps,

Alex
--
Gossamer Threads Inc.

Last edited by:

Alex: Sep 30, 2004, 11:31 AM
Quote Reply
Re: [Alex] Editor Only Link In reply to
Hi Alex,

thanks for your response. I tried this out but I'm having no luck. Whether it is a simple user or an editor user the following code just isn't displayed :

is_editor sub in GT Comm Template Globals :

sub {
my $username = shift;
my $db = GT::SQL->new('/usr/local/etc/httpd/perl/sitename/admin/defs');
my $is_editor = $db->table('Editors')->count( { Username => $username });
return $is_editor;
}

Code used in html template :

<%if is_editor("username")%>
link here to sitename/editors
<%endif%>

John
Significant Media
Quote Reply
Re: [Jag] Editor Only Link In reply to
<%if is_editor("username")%>
Is username a valid user name?

If not, it should be
<%if is_editor("jag")%>
or
<%if is_editor('jag')%>
if Jag is a valid username.

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
Quote Reply
Re: [webmaster33] Editor Only Link In reply to
Hi,

I thought the sub routine pulled up the current user and checked to see they are an editor !?

That's why i was thinking that <%if is_editor("username")%> was using the part of the sub :
my $username
to get the current users name and check it in the database to see if the user is an editor !

I need to have the page checking whether a user is an editor to display or not a link.

John
Significant Media
Quote Reply
Re: [Jag] Editor Only Link In reply to
Then you should use
<%if is_editor($username)%>

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
Quote Reply
Re: [Alex] Editor Only Link In reply to
Thanks for your input webmaster33, I can't get it to work though. I thought I had a one point but I think it was because community bounced me back to LinkSQL page and I thought I was still in the community area.

I can only actually get anything to appear if a valid user is recognized by using the following :Frown

<%if session_cookie_name_user%>

why doesn't <%if username%> work to display content ie.

<%if username%>
Hello <%username>
<%endif%>

And I'm not too sure that the <%if session_cookie_name_user%> is that secure if it just works with cookies.

John
Significant Media
Quote Reply
Re: [Jag] Editor Only Link In reply to
Because in GCommunity comm_username is used:
<%if is_editor($comm_username)%>

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
Quote Reply
Re: [webmaster33] Editor Only Link In reply to
Hi webmaster33,

Thanks, once again, spot on, and I can display info when I get a valid user.

I also tried to modify the global thinking that it reflect the correct username naming (i.e. comm_username) :

sub {
my $comm_username = shift;
my $db = GT::SQL->new('/usr/local/etc/httpd/perl/sitename/admin/defs');
my $is_editor = $db->table('Editors')->count( { Username => $comm_username });
return $is_editor;
}

however this still will not display the link when I choose to login as a user that is an editor. Crazy

John
Significant Media
Quote Reply
Re: [Jag] Editor Only Link In reply to
Interesting problem.
The LSQL Editor table contains Username column.
The GComm users contains comm_username.
Both may have different username values.

I'm not sure, that if GComm is taking care to synchronize them when the GComm install is done. I'm afraid not.
Anyway, this would need deeper analysis to find how it's solved, which would need more time.

Contact Alex or choose paid support.


BTW: first open a database client, and check if spedific username e.g. 'Jag' exists in both Username and comm_username column. I support 'Jag' doesn't exists in Username of Editor table. That's the reason why the global doesn't work.
If 'Jag' exists in both tables, then let me know.


Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...

Last edited by:

webmaster33: Sep 30, 2004, 5:07 AM
Quote Reply
Re: [Jag] Editor Only Link In reply to
Hi,

Oops, try my edited version above.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Editor Only Link In reply to
Alex, how is solved in GComm, to keep synchronized the foreign key Username in LSQL Editor table, and comm_username in GComm?
I should have look into the code, but if you are around here, I ask from you.

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
Quote Reply
Re: [webmaster33] Editor Only Link In reply to
Hi,

Neither Community or Links SQL support changing a username. Gossamer Forum lets users do this, and it's supported in Community as it only stores the Gossamer Forum userid (although it's generally a bad idea to allow users to alter their usernames).

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Editor Only Link In reply to
And what if a user is deleted?
The corresponding username is deleted also from LSQL Editor table, right? At least it should.

Community::Apps::Local::LinksSQL::delete doesn't seem to delete the matchng user from LSQL Editor table...

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
Quote Reply
Re: [Alex] Editor Only Link In reply to
Hi

Thanks Alex it works with your modification and I can display items that are only supposed to be for Editors (the forum). Thanks webmaster33 as well for your help.
I'm nearly there... Wink
Significant Media
Quote Reply
Re: [webmaster33] Editor Only Link In reply to
Quote:
The corresponding username is deleted also from LSQL Editor table, right? At least it should.
Correct. It calls delete on the Links table, which will clean up all related tables including the editors.

Cheers,

Alex
--
Gossamer Threads Inc.