This topic was marked solved by Nao, on June 4th, 2014, 12:58 AM

gevv

  • Posts: 91

Nao

  • Dadman with a boy
  • Posts: 16,082
Re: Broken Privacy Topic
« Reply #1, on April 12th, 2014, 12:25 AM »
Hmm... Confirmed.

It's looking like the $topic 'creation' process never goes through {query_see_topic}, which is odd... I thought it did, really.
I mean, if a board is set to a specific group, attempting to access a topic in it will fail... So, I guess I need to add query_see_topic in the same query.
Can someone else look into it, to save me a few minutes? (or dozen minutes, depending on how it turns out...) I need to find where this one is. Possibly boardsAllowedTo or something. Have to jump to bed now... :-/
Re: Broken Privacy Topic
« Reply #3, on April 12th, 2014, 04:57 PM »
This is getting annoying... I need some opinions here.

Part 1: the problem.

This is how Noisen.com does topic privacy:
- build a query checking the privacy state
- load board, with query above, and also load topic approval
- check topic approval manually. Actually, I didn't really bother with that, because Noisen doesn't use topic approvals much.

This is how Wedge.org does topic privacy:
- build a query checking privacy & approval states
- load board, with query above (if private or not approved, no topic, thus nothing to show)

The problem is with the query building. Privacy is fine, but approval is not, because if you're a moderator, you're exempt from having to check on approval states, since you're the one who's supposed to approve messages...
However, and the trick is here, the query check is built BEFORE the board is loaded, which also means it's built BEFORE permissions are loaded. Thus, allowedTo() will always return FALSE, making it impossible for moderators to see unapproved posts.

Part 2: how I solved it in late March. (And why it fails to work correctly.)

I simply removed the topic privacy/approval check in loadBoard, and figured I'd move it to Display.php (which I forgot to do). I fixed that today (not committed yet). However... It also means that if you have ";topic=..." in your URL, but are NOT viewing a topic page, the topic approval query won't be loaded. Oops!

I went for an alternative solution, which was to move the $topicinfo builder to its own loadTopic() function, and then automatically load it on all pages if the topic itself is shown NOT to have a 'default' privacy or approved setting. Then, I can easily close access to that topic if the user isn't allowed to see it.
Still, that makes it all very complicated, and it loads a lot of data for nothing.
Another (close) way to do it would be to accept that I'm spending an extra query on all pages with ";topic=" in them, but a SUPER FAST query like "SELECT 1 FROM topics AS t WHERE id_topic = $topic AND {query_see_topic}". That would only manipulate a single row in a single table, id_topic has an index so it's all fine, and query_see_topic only manipulates that row as well.

Part 3: what should I do?

Not worry about the extra query? It takes about a millisecond on my local install. (Still, I find it 'too much'.)
Move the $topicinfo builder to loadTopic, and call loadTopic if $topic is set, then not call it again from Display()..? (Problem: although it's a similar query to my simplified one, filling $topicinfo when you don't actually need that info is also overkill. Then again, maybe people would LIKE for $topicinfo to be systematically available when a current topic ID is available.)
Something else..?

Help :sob:

madfitz

  • Elite Class Non Coder
  • Posts: 97
Re: Broken Privacy Topic
« Reply #5, on April 12th, 2014, 11:43 PM »
Your last post was too long/techy for me to really take in but if the extra query is really a millisecond(s) - don't worry about it.

If that would fix the problem it really isn't "too much".

That's my opinion and I'm sticking to it :eheh:

Pandos

  • Living on the edge of Wedge
  • Posts: 635
Re: Broken Privacy Topic
« Reply #6, on April 13th, 2014, 06:33 PM »
Quote
Not worry about the extra query? It takes about a millisecond on my local install. (Still, I find it 'too much'.)
Yes, who cares. IMHO there's no better way to deal with it. And it's a really handy query that don't impact much loading speed.
# dpkg-reconfigure brain
error: brain is not installed or configured

Nao

  • Dadman with a boy
  • Posts: 16,082
Re: Broken Privacy Topic
« Reply #7, on April 13th, 2014, 08:01 PM »
It's just unbelievable how complicated this code initialization flow is.
Load user then board & topic info then permissions then test board & topic privacy... If only I could load permissions before boards.
Heck, err.. Why can't I, BTW? Oh yeah permissions are prolly setting the current board's perms based on a database field.

Hmm.. Maybe I could cache all board permission data. Then I could simply retrieve it, build board perms and then board privacies.

madfitz

  • Elite Class Non Coder
  • Posts: 97
Re: Broken Privacy Topic
« Reply #8, on April 13th, 2014, 11:43 PM »
You lost me at "complicated" then went on to make matters worse :wow:

Nao

  • Dadman with a boy
  • Posts: 16,082

Pandos

  • Living on the edge of Wedge
  • Posts: 635
Re: Broken Privacy Topic
« Reply #10, on April 14th, 2014, 02:10 PM »
Quote
Should admins be able to access topics that are off-limits to them..?
Ehm... YES!!!
Admins should must have the right to see anythimg. They need to see what's going on, because it's their forum and they are responsible for it, especially from a legal point of view.

Nao

  • Dadman with a boy
  • Posts: 16,082
Re: Broken Privacy Topic
« Reply #11, on April 14th, 2014, 02:38 PM »
But that's the thing... Are they responsible for what they can't view?

If no, then they shouldn't be able to view private topics. A very good example, to me, is the idea that you'd set a topic as private because you're in the process of writing it, and don't want to bother with drafts.

If yes, then they should be able to read anyone's PMs, too...!!
Which is a no-no for everyone, am I right...?

Pandos

  • Living on the edge of Wedge
  • Posts: 635
Re: Broken Privacy Topic
« Reply #12, on April 14th, 2014, 02:58 PM »Last edited on April 14th, 2014, 03:13 PM
You can't compare Apples PM's with Eggs Forums.
They are from a technical point of view completely different.
So this is the legal situation in Germany:

The admin of a forum is fully responsible for the contents of his forum.
It's a natural fact that you can see all postings as admin in a forum. Therefor you are responsible for them.
Funny, because you can't read them, when you claim to have topic privacy.. :)

PM's take the status of Mail, Letters, etc.
It's forbidden to read them. So you can't get prosecuted for contents.
Funny, because you'll have the possibility to do that with PHPMyAdmin, etc. :)

Even if you claim to have a software that doesn't support reading of private topics, it's just a forum in the eyes of the law.
Re: Broken Privacy Topic
« Reply #13, on April 14th, 2014, 03:03 PM »
The only way I can think of to get it working is to encrypt private topics AND PM's in DB.
Re: Broken Privacy Topic
« Reply #14, on April 14th, 2014, 03:10 PM »
Just a thought...
What if someone is reporting a private topic to moderator or admin?
How to take action when they can't see it?