Welcome, Guest. Please login or register.
Did you miss your activation email?


Login with username, password and session length

Search

 
Advanced search

8001 Posts in 1848 Topics- by 2099 Members - Latest Member: roi
Pages: [1]   Go Down
Print
Author Topic: private or hidden event  (Read 380 times)
0 Members and 1 Guest are viewing this topic.
delicia
New Member
*

Karma: 0
Offline Offline

Posts: 5


WWW
« on: December 17, 2003, 06:39:00 AM »

i want to hide some events from visitors unless they are logged in. i set up an event field called hidden which is set to yes or no when event is entered or edited. i downloaded and installed the plug in for private events and edited as shown below:

# ADDED         # Skip if it's private
#         next unless ($event_details->{$s->{'event_id'}}->{'author_id'} eq $main::User->{'username'});
         next unless (($event_details->{$s->{'event_id'}}->{'hidden'} eq "no") | | ($Session));


it seems to work for me -- when i'm logged in i can see the hidden events, but when i'm not logged in i can't. however, i sent a link to my test calendar to a friend and she could see the events set to yes. i did not give her any login info.

could someone tell me what i'm doing wrong? thanks.

Logged
DanO
Moderator
Full Member
*****

Karma: 13
Offline Offline

Posts: 212

Please don't PM me. Post in the open forum.


WWW
« Reply #1 on: December 17, 2003, 12:43:00 PM »

Even if a user hasn't logged in the $Session variable is still set when they view the calendar (providing their browser is accepting cookies). The difference however is if they're not logged in, they have a user name of "anonymous".

You'll have to make your test conditional upon that.

BTW. I don't think your changes with limit the search results.

Dan O.


[This message has been edited by DanO (edited December 17, 2003).]

Logged
delicia
New Member
*

Karma: 0
Offline Offline

Posts: 5


WWW
« Reply #2 on: December 17, 2003, 05:07:00 PM »

i have my browser set to prompt for cookies but i'm not getting a prompt for the calendar. i still don't see 'hidden' events unless logged in. i'm going straight to default calendar without searching.

------------------

Logged
DanO
Moderator
Full Member
*****

Karma: 13
Offline Offline

Posts: 212

Please don't PM me. Post in the open forum.


WWW
« Reply #3 on: December 17, 2003, 07:00:00 PM »

If you want to post a link to the calendar and tell us which events shouldn't be displaying, others can test it for you. If not, all I can suggest is you try my suggestion and ask your friend to try again.

Dan O.

[This message has been edited by DanO (edited December 17, 2003).]

Logged
delicia
New Member
*

Karma: 0
Offline Offline

Posts: 5


WWW
« Reply #4 on: December 17, 2003, 08:21:00 PM »

here's the link: http://www.delicia.com/cgi-bin/cs3/calendar.pl

december 23 -- you should not see an event unless you are logged in.

------------------

Logged
DanO
Moderator
Full Member
*****

Karma: 13
Offline Offline

Posts: 212

Please don't PM me. Post in the open forum.


WWW
« Reply #5 on: December 17, 2003, 09:54:00 PM »

I see it.  

Did you try the change I suggested?

Dan O.

------------------

Logged
delicia
New Member
*

Karma: 0
Offline Offline

Posts: 5


WWW
« Reply #6 on: December 18, 2003, 07:33:00 AM »

i think so, but not sure of field names. this is what i did:

         next if (($event_details->{$s->{'event_id'}}->{'hidden'} eq "yes") && ($User->{name} eq 'anonymous'));

i also edited default.html to display the value of of those two fields for each event.

------------------

[This message has been edited by delicia (edited December 18, 2003).]

Logged
DanO
Moderator
Full Member
*****

Karma: 13
Offline Offline

Posts: 212

Please don't PM me. Post in the open forum.


WWW
« Reply #7 on: December 19, 2003, 04:45:00 PM »

** not sure of field names **

It should be $User->{username} not $User->{name}

Try

next if (($event_details->{$s->{'event_id'}}->{'hidden'} eq "yes") && (!$User->{username} | | $User->{username} eq 'anonymous'));

(all on one line)

     NOTE: This forum software adds a space between double bars ( | | ) which would have to be removed from the code you use.

Dan O.

[This message has been edited by DanO (edited December 19, 2003).]

Logged
delicia
New Member
*

Karma: 0
Offline Offline

Posts: 5


WWW
« Reply #8 on: December 19, 2003, 09:56:00 PM »

should username be enclosed in single quotes?

------------------
i guess not; i looked at other places in the script and it wasn't. i've implemented your suggestion and am awaiting my friend to test.

another question -- i noticed in the plugin, there is a usermessage that can be commented out to show that the script got to the plugin. it is never displayed (after i uncommented it); i looked in default.html and the message only appears under search, not under regular view -- correct?

and you are quite right that this plugin doesn't do what i want in a search. how would i customize the before_search part -- can i just set flags like:

if not logged in, hidden = no

or will i need to duplicate the before get event sub, or worse write a whole new routine (over my head)?

[This message has been edited by delicia (edited December 20, 2003).]

[This message has been edited by delicia (edited December 20, 2003).]

Logged
DanO
Moderator
Full Member
*****

Karma: 13
Offline Offline

Posts: 212

Please don't PM me. Post in the open forum.


WWW
« Reply #9 on: December 20, 2003, 01:10:00 PM »

** should username be enclosed in single quotes? **

Technically yes, either single or double quotes but Perl is very forgiving.

** the message only appears under search, not under regular view -- correct? **

Yes... unless you modify the template to display it elsewhere.

** how would i customize the before_search part -- or will i need to duplicate the before get event sub **

You would need to modify the 'sub search' subroutine in the Event.inc file or duplicate it and add all the necessary code to the display_before_search.pl file along with a modified # SEARCH routine from the calendar.pl file (which calls 'sub search').

Or you could totally disable the search function by having the display_before_search.pl return a value of 1 instead of 0 (zero) like it originally is set to.

Dan O.

[This message has been edited by DanO (edited December 20, 2003).]

Logged
Pages: [1]   Go Up
Print
Jump to: