https://www.icyphoenix.com/viewtopic.php?f=35&t=7789
-----------------------------------
TheSteffen
Sat 09 Apr, 2011 14:56

Only First Post Possible To Read For Guests
-----------------------------------
Hey,
I don´t know if this is easy possible...

I would like to have a switch, that in one special forum guest can only read the first post.
Maybe with sponsor text above.

Now guest can read the complet topic with all replys.
Does anyone know how to change this or maybe there would be a chnace to insert this in next version of IP
Maybe other users also would like it.
Thanks


-----------------------------------
spydie
Sat 09 Apr, 2011 15:42

Re: Only First Post Possible To Read For Guests
-----------------------------------
should be possible

i think, i´ve seen something in posting php, or was it viewtopic.php, that had to do with the first post check and post sorting, 

adding some code there like : 

IF is not first post and Forum ID = Forum ID
display : false;

ElseIf blahblah

This is no actual code,
It´s just an idea

got to play with this idea a bit further, to actual put some usable code here


-----------------------------------
Informpro
Sat 09 Apr, 2011 16:33

Re: Only First Post Possible To Read For Guests
-----------------------------------
This should'nt be too complicated.


-----------------------------------
TheSteffen
Sat 09 Apr, 2011 16:38

Re: Only First Post Possible To Read For Guests
-----------------------------------
Thanks [b]spydie[/b] and [b]Informpro[/b] for your quick answer.
If you have some time you can play with it  :mricy: 
Thanks a lot

Hardcoded would be enough for me ;-)


-----------------------------------
Informpro
Sat 09 Apr, 2011 18:04

Re: Only First Post Possible To Read For Guests
-----------------------------------
(see above)


-----------------------------------
TheSteffen
Sat 09 Apr, 2011 18:43

Re: Only First Post Possible To Read For Guests
-----------------------------------
WOW [b]Informpro[/b], thanks a lot, I will give it a try later.

One Question about that:
[code]if (!$user->data['session_logged_in'])  
{  
    $sql .= " LIMIT 1";  
}  [/code]

Doesn´t that mean, when user is logged_in then set Limit to 1
Shoudn´t it be, if User logged_out (for guests) then set Limit to 1

Can you please explain to me, that I learn a bit more about php  :D 
Thanks


-----------------------------------
Informpro
Sat 09 Apr, 2011 19:45

Re: Only First Post Possible To Read For Guests
-----------------------------------
The "!" means "not".
So "if not logged_id then limit 1".

Tell me if it works !


-----------------------------------
TheSteffen
Sat 09 Apr, 2011 22:34

Re: Only First Post Possible To Read For Guests
-----------------------------------
Hey [b]Informpro[/b],
I tried both versions, but it doesn´t seems to work.

Tested it local with xampp

Do you have something elso for me to test?!?


-----------------------------------
Informpro
Sat 09 Apr, 2011 23:19

Re: Only First Post Possible To Read For Guests
-----------------------------------
The real solution :

For every forum
search[code syntax=php]	LIMIT " . $start . ", " . $config['posts_per_page'];[/code]Replace with[code syntax=php]	LIMIT " . ($user->data['session_logged_in'] ? $start . ", " . $config['posts_per_page'] : 1);[/code]


For particular forums only
search[code syntax=php]	LIMIT " . $start . ", " . $config['posts_per_page'];[/code]Replace with[code syntax=php]	LIMIT " . (!$user->data['session_logged_in'] && ($forum_id == 5 || $forum_id == 6) ? 1 : $start . ", " . $config['posts_per_page']);[/code]


-----------------------------------
TheSteffen
Sat 09 Apr, 2011 23:48

Re: Only First Post Possible To Read For Guests
-----------------------------------
Thanks [b]Informpro[/b],
this is working
[code]LIMIT " . (!$user->data['session_logged_in'] and ($forum_id == 1) ? 1 : $start . ", " . $config['posts_per_page']);[/code]
But now I get for all topics only the first post.  :D 
Not only for $forum_id == 1

Can that be fixed? Thanks


-----------------------------------
Informpro
Sun 10 Apr, 2011 00:18

Re: Only First Post Possible To Read For Guests
-----------------------------------
Wow - I'm pretty tired. Just replace "and" with "&&" (and or by ||, if you have). Sorry.


-----------------------------------
TheSteffen
Sun 10 Apr, 2011 00:28

Re: Only First Post Possible To Read For Guests
-----------------------------------
Thanks a lot... it is working fine  :mricy: 

Here is the code I used

OPEN [b]viewtopic.php[/b]
FIND
[codeblock]LIMIT " . $start . ", " . $config['posts_per_page'];[/codeblock]
REPLACE WITH
[codeblock]LIMIT " . (!$user->data['session_logged_in'] && ($forum_id == 1) ? 1 : $start . ", " . $config['posts_per_page']);[/codeblock]


-----------------------------------
Informpro
Sun 10 Apr, 2011 00:30

Re: [SOLVED]   Only First Post Possible To Read For Guests
-----------------------------------
Oh, yes, it should be enough. Glad to help !


-----------------------------------
TheSteffen
Tue 12 Apr, 2011 20:31

Re: [SOLVED]   Only First Post Possible To Read For Guests
-----------------------------------
Sorry, but I have to ask again...

The chages I made works, but not only for guests.
Even admins can now only see the first post in each topic.
Can that be solved?
Thanks


-----------------------------------
Informpro
Tue 12 Apr, 2011 21:43

Re: [SOLVED]   Only First Post Possible To Read For Guests
-----------------------------------
I just tried it in my dev version and it works. Try to reverse && parts but ...


-----------------------------------
TheSteffen
Wed 13 Apr, 2011 19:06

Re: Only First Post Possible To Read For Guests
-----------------------------------
Hey [b]Informpro[/b],
thanks for your testing.

I saw now that I was testing it with latest SVN version and not IP 1.3
It is very similar but maybe this was the problem.

I fixed it now I little bit different

OPEN [b]viewtopic.php[/b]
FIND
[codeblock]LIMIT " . $start . ", " . $config['posts_per_page'];[/codeblock]
REPLACE WITH
[codeblock]LIMIT " . (($userdata['user_id'] == ANONYMOUS) && ($forum_id == 1) ? 1 : $start . ", " . $config['posts_per_page']);[/codeblock]

Do you think this is safe to use?
Thanks for your opinion.


-----------------------------------
Informpro
Wed 13 Apr, 2011 19:09

Re: [SOLVED]   Only First Post Possible To Read For Guests
-----------------------------------
Oh ! yeah ! sorry. I havn't guessed.

[quote]save to use?[/quote]I suppose you mean "safe" : so yeah, for posts, it's safe. But there's many other ways to get the content. They are listed in a key lang (about self auth) : as "random post", "recent post", and so on.


-----------------------------------
TheSteffen
Wed 13 Apr, 2011 19:13

Re: [SOLVED]   Only First Post Possible To Read For Guests
-----------------------------------
Yes, thats right... but I dont care about the other options to get the content.

Thanks for your help


