Looking for advice: best way to add a new "visibility"

Discussion forum for Extension Writers regarding Extension Development.
Post Reply
User avatar
javiexin
Code Contributor
Posts: 1157
Joined: Wed Oct 12, 2011 11:46 pm
Location: Madrid, Spain
Name: Javier
Contact:

Looking for advice: best way to add a new "visibility"

Post by javiexin »

Hello all,

For an extension I am working on, I want to add a new "visibility", different from the standard ones.

What I want to achieve is a post that is only visible to the poster and moderators, that may be edited by either, even (soft)deleted. But that nobody can reply, quote or otherwise see (except for the above). This is in "general" forums, so, not forum wide, but post specific (it does not need to be a new topic, could be a reply to an existing topic). Another way to describe the required functionality would be as a "Draft" message, but may be seen and edited by moderators, and may include Poll and Attachments (so Drafts are ruled out).

The characteristics of this mode would be as I explained: unlimited edit and delete for the poster (like a draft), moderator access according to permissions (edit/delete), NO approval possible, and everybody else should not even know it exists. Of course it should not appear in searches (for poster and moderator, whatever happens now for UNAPPROVED would be fine).

It is very similar to an "UNAPPROVED" post, except for the poster being able to modify/delete it, and the fact that the moderators cannot approve it (this is done by the extension itself) but can edit/delete themselves if they have the right permissions.

I have seen the content_visibility class, but I have also seen a very big amount of places where the actual visibilities are hardcoded, so this cannot be used in a simple way.

My question here is what is your advice as to how and where to deal with this situation?
Some options I see, but may be "undoable", are:
  1. New visibility mode (other than APPROVED, UNAPPROVED, REAPPROVE, DELETED); pros, the most clear, cons, there is no simple way to achieve this, might require a very high number of events and possibly even places where no event is available.
  2. Use UNAPPROVED, and add the post to the topic page for the poster (moderators already see UNAPPROVED posts), but remove moderator approval, from viewtopic and MCP; also remove moderator notification (or at least change it) and remove from approval queue.
  3. Use APPROVED, and remove the post from the viewtopic page except for poster and mod; this I see very complicated, because of search indexing and first/last post id for topic and forum.
  4. Any other?
My current thinking is that the easiest (and probably best) is the second option. But I would like your opinions about this.

Thanks a lot,
-javiexin

PS: It does not have anything to do with this extension, althoug some requirements might look similar
User avatar
Steve
Registered User
Posts: 1092
Joined: Tue Apr 07, 2009 7:48 pm
Location: UK ,up north!!
Name: Steven Clark
Contact:

Re: Looking for advice: best way to add a new "visibility"

Post by Steve »

If you get some one to help you on this, here's a thumb ๐Ÿ‘๐Ÿป๐Ÿ˜†
If you don't get any one to do or help you achieve this then I would like you to nominate your self to to do this ๐Ÿ˜†
User avatar
3Di
Former Team Member
Posts: 16038
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milan (IT) Frankfurt (DE)
Name: Marco
Contact:

Re: Looking for advice: best way to add a new "visibility"

Post by 3Di »

I'd go for
javiexin wrote: โ†‘
Fri Jul 07, 2017 9:22 pm
2. Use UNAPPROVED, and add the post to the topic page for the poster (moderators already see UNAPPROVED posts), but remove moderator approval, from viewtopic and MCP; also remove moderator notification (or at least change it) and remove from approval queue.
, about the search indexing , if I correctly recall the submit_post() function already have it available as an option. Yes, I don't think that will be enough tough in order to let moderators/user find those posts if searched, though an event "after" for submit post does already exists but I haven't explored it yet.

Regards.
- Marco
Please PM me only to request paid works. Thx.
Want to compensate me for my interest? Donate
My development's activity ยบ PhpStorm's proud user
Extensions, Scripts, MOD porting, Update/Upgrades
Looking for a specific feature or alternative option? We will rock you! ๐Ÿš€
User avatar
javiexin
Code Contributor
Posts: 1157
Joined: Wed Oct 12, 2011 11:46 pm
Location: Madrid, Spain
Name: Javier
Contact:

Re: Looking for advice: best way to add a new "visibility"

Post by javiexin »

Thanks Marco.

I have started working on option 2 above, and... well, a disaster.

The first thing I want to achieve is SIMPLY to allow the poster of a unapproved post/topic to see it, and then, to have some specific visuals to make it clear it is unapproved. When I complete this, I will probably release it as a separate extension, because there are a lot of "doubts" when someone posts something and does not see it in the forum (I have had quite a number of users in my forum asking for their "disappeared" posts, that just happened to be unapproved: people do not read the messages, and are impatient by nature).

Seams easy, but immediately after starting, I hit a wall: the content_visibility class events are ill defined, and do not (properly) allow what they promise. I have filed a Tracker ticket (https://tracker.phpbb.com/browse/PHPBB3-15266) with some details.

And I have also realized that there are LOTS of places where content_visibility is not being used at all, but just testing against the visibility constants directly, making it impossible to really "package" such a change. It must be widespread all over phpbb... An example: I have been able to show the unapproved topic in the list of topics in a forum to the poster, but the post count is wrong, and if I try to access the topic, it says "Topic does not exist".

As I said, this is going to be VERY complex (well, maybe not complex, but convoluted, and LOTS of corner cases and exceptions), so any help or pointer to some extension that has gone through something similar would be very helpful!

-javiexin
User avatar
3Di
Former Team Member
Posts: 16038
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milan (IT) Frankfurt (DE)
Name: Marco
Contact:

Re: Looking for advice: best way to add a new "visibility"

Post by 3Di »

Hi, yes .. I am understanding the issue here.
Let's see, as a font of search in this cases I use GitHub, I search for the core event name, I refine the search then for "code" then for "PHP".. this time I got only two repos related, one is the brunoais's repo which I think you already are aware of it.

Then I got a "VIP posts" extension, nothing else this time.
https://github.com/ciakval/phpbb-vippos ... stener.php

ATM that's all I can do, let us know if has been of interest.

Regards. :)
Please PM me only to request paid works. Thx.
Want to compensate me for my interest? Donate
My development's activity ยบ PhpStorm's proud user
Extensions, Scripts, MOD porting, Update/Upgrades
Looking for a specific feature or alternative option? We will rock you! ๐Ÿš€
User avatar
javiexin
Code Contributor
Posts: 1157
Joined: Wed Oct 12, 2011 11:46 pm
Location: Madrid, Spain
Name: Javier
Contact:

Re: Looking for advice: best way to add a new "visibility"

Post by javiexin »

The "VIP posts" extension is interesting as it does some things that I want to achieve... Thanks a lot, I didn't know that!
-javiexin
User avatar
javiexin
Code Contributor
Posts: 1157
Joined: Wed Oct 12, 2011 11:46 pm
Location: Madrid, Spain
Name: Javier
Contact:

Re: Looking for advice: best way to add a new "visibility"

Post by javiexin »

Next big (huge) hurdle found: content_visibility is NOT ready to EXPAND the visibility, but only to RESTRICT it.

In fact, that is halfway true: the real issue here is not content_visibility, but the very big amount of times where the content_visibility conditions are hardcoded in the core rather than being checked through the class. A couple of examples that do not have any controlling event and are blockers:
https://github.com/phpbb/phpbb/blob/3.1 ... #L264-L269
https://github.com/phpbb/phpbb/blob/3.1 ... #L668-L672

So I think that the chosen option will have to be discarded, and this "simplified" extension is simply impossible to realize.

Please, anyone, prove me wrong!
Thanks,
-javiexin
User avatar
javiexin
Code Contributor
Posts: 1157
Joined: Wed Oct 12, 2011 11:46 pm
Location: Madrid, Spain
Name: Javier
Contact:

Re: Looking for advice: best way to add a new "visibility"

Post by javiexin »

For information, there are MORE than 225 uses of the visibility constants throught the phpbb software WITHOUT the uses within content_visibility (around 50). This is really unmanageable. All (most) of those uses should be somehow function calls to content_visibility, otherwise, it is almost impossible to "redefine" the concept of visibility within an extension. What I have seen is that RESTRICTING the visibility may be at least partially possible, but WIDENING the visibility is not feasible at all. And there are other concepts that interfere or interact with the above as well...

Any help would be much appreciated.

To restrict the question a lot, let's simplify the issue to "How to allow the poster of an UNAPPROVED topic to edit it without limitation while unapproved".

Thanks a lot in advance. If you feel this should be improved in the core, let me know, and I will open a discussion in Area51.

-javiexin
Paul
Infrastructure Team Leader
Infrastructure Team Leader
Posts: 26840
Joined: Sat Dec 04, 2004 3:44 pm
Location: The netherlands.
Name: Paul Sohier
Contact:

Re: Looking for advice: best way to add a new "visibility"

Post by Paul »

the visibility class was new in 3.1, and not all of the old usages were simply converted.
Knock knock
Race condition
Who's there?

My Blog โ€ข My Photos โ€ข my phpBB Extensions โ€ข custom phpBB work & Development
User avatar
javiexin
Code Contributor
Posts: 1157
Joined: Wed Oct 12, 2011 11:46 pm
Location: Madrid, Spain
Name: Javier
Contact:

Re: Looking for advice: best way to add a new "visibility"

Post by javiexin »

Paul wrote: โ†‘
Tue Jul 11, 2017 4:57 pm
the visibility class was new in 3.1, and not all of the old usages were simply converted.
I know Paul, and what I am saying is that the change was, as you indicate, partial, making it extremely difficult for an extension to modify the core behaviour. In fact, very few cases were converted...

Do you think this would require additional work in the core?
Post Reply

Return to โ€œExtension Writers Discussionโ€