Display only the first post to certain groups

Discussion forum for Extension Writers regarding Extension Development.
Locked
User avatar
axe70
Registered User
Posts: 752
Joined: Sun Nov 17, 2002 10:55 am
Location: Italy
Name: Alessio
Contact:

Display only the first post to certain groups

Post by axe70 »

Hello! Random and boring questions

May to bots, guests etc.
Display only the first post.
It has been asked to me to write something like this and i executed in few steps, hooking into the
viewtopic_modify_post_data event which seem to be the good one for the scope.

Questions: i do not want to follow on adding more code for event listeners that will hide this:
hiddenPostsResult.png
as you can see, the result by setting all posts except the first as hidden
$v['hide_post'] = 1; // set as hidden all posts except the first (the lower post ID)
produce the result above.
Adding an asort in some ways, always return the right result despite the user's chosen mode to view the topic (ascendant or descendant).

Any idea? It is good by the way done in this way, the result is acceptable, but i would like to cut off all rows instead.
I will see if it is possible without hooking somewhere else. But it is 40degree around, so as it will be more comfortable!

May it is good this way, so that it can be possible to replace the hidden post's content, with something like:
if you were registered you would be able to see this content
Let see what best.

Second question:
is there around something doing this already?

Cheers!

[EDITED]
Last edited by Mick on Sun Sep 11, 2022 8:05 am, edited 1 time in total.
Reason: Solved.
Do not take me too serious
Anyway i do not like Discourse
User avatar
KevC
Support Team Member
Support Team Member
Posts: 72343
Joined: Fri Jun 04, 2004 10:44 am
Location: Oxford, UK
Contact:

Re: Display only the first post to certain groups

Post by KevC »

There's already an extension for that for the guest group
https://www.phpbb.com/customise/db/exte ... _to_guest/
-:|:- Support Request Template -:|:-
Image
"Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb"
User avatar
warmweer
Jr. Extension Validator
Posts: 11234
Joined: Fri Jul 04, 2003 6:34 am
Location: Van Allen Bel ... gium
Contact:

Re: Display only the first post to certain groups

Post by warmweer »

Your topic title mentions "to groups"
but
your post mentions bots, guest, etc...

This should get you started
Show First Post Only To Guest

added: OMG, KevC again :shock:
Spelling is freeware, which means you can use it for free.
On the other hand, it is not open source, which means you cannot change it or publish it in a modified form.


Time flies like an arrow, but fruit flies like a banana.
User avatar
axe70
Registered User
Posts: 752
Joined: Sun Nov 17, 2002 10:55 am
Location: Italy
Name: Alessio
Contact:

Re: Display only the first post to certain groups

Post by axe70 »

Thank for your suggestions guys!

I will add three fields for the configuration into ACP (and not adding a php config file as done in the past).

One for the excluded forums ids list
One for groups list which will not be able to see those forums ids
One for the text to display in place of the replaced post's content (maybe)

Then i will propose to be validated as ready, thank you!

[EDITED 0]

mhh no
One for the text to display in place of the replaced post's content (maybe)
it will be just a lang file

[EDITED 1]
Do not take me too serious
Anyway i do not like Discourse
User avatar
axe70
Registered User
Posts: 752
Joined: Sun Nov 17, 2002 10:55 am
Location: Italy
Name: Alessio
Contact:

Re: Display only the first post to certain groups

Post by axe70 »

hello, just a fast log about the going on:

Code: Select all

	  foreach($tempRW as $r => &$v){ // set as hidden all posts except the first (the lower ID)
	   if($r != $vx){
	    //$v['hide_post'] = 1;
	    $v['post_text'] = $this->language->lang('DISPLAYONLYFIRSTPOST_EVENT_REPLACEMENT_TEXT');
	   }
	  }
i actually will change giving an option more (there are 3 into ACP module):
hide posts, so that the result will be the one you see on previous image attach, and so that about replies on this topic, nobody will know users that replied and more (may) sensible info.
OR
replace the post text with the content of the lang var DISPLAYONLYFIRSTPOST_EVENT_REPLACEMENT_TEXT

so that the result will be this instead:
hiddenPostsResult2.png

the three options into ACP looks like this mess:

hiddenPostsAdminConfig.png
so asking myself if the option:
Forums IDS that will shown only the first post to the selected groups.
If you wish to select all the forums in once, set the word all as value here, so that this rule will affect all the existent forums:
can be acceptable, and looking any hint that could help on make it better!

I see that any html passed into lang files is parsed.... also an adv code i assume, an image, or something else and also may randomly... what stupids thoughts!
Do not take me too serious
Anyway i do not like Discourse
User avatar
axe70
Registered User
Posts: 752
Joined: Sun Nov 17, 2002 10:55 am
Location: Italy
Name: Alessio
Contact:

Re: Display only the first post to certain groups

Post by axe70 »

if i get
\phpbb\user $user

$user->data just contain the user's table values, that about groups which the user belong to, only contain the default one.
How would be possible to get all groups that the user belong to, if more than one?
Possible to have the value, and if yes, using which property or how at best?

Thank you!
Do not take me too serious
Anyway i do not like Discourse
User avatar
axe70
Registered User
Posts: 752
Joined: Sun Nov 17, 2002 10:55 am
Location: Italy
Name: Alessio
Contact:

Re: Display only the first post to certain groups

Post by axe70 »

Well, the extension code is ready., will be published very soon

I have not find out the way to include this result, and i still not checked where it should be available on the flow:

/includes/functions_user.php

Code: Select all

/**
* Obtain either the members of a specified group, the groups the specified user is subscribed to
* or checking if a specified user is in a specified group. This function does not return pending memberships.
*
* Note: Never use this more than once... first group your users/groups
*/
function group_memberships($group_id_ary = false, $user_id_ary = false, $return_bool = false)
should be this (may i am wrong) but to call something like this each time the script load on viewtopic, seem not a good idea.
It is not stored into some global var this value? It is just used on certain circumstances and not any time the user/session start?

I know these are may hard and stupid questions.
I will follow on as possible, since it is Ferragosto today!

The extension works very fine as is, and the above is just a plus that may is not useful. The default user group is enough to manage any situation, because the setting can contain multiple groups ids.

Anyway, whenever the data about to know to what groups an user belong to would be necessary, it remain at moment a mystery on how to get this value in a convenient way.

Buon Ferragosto a tutti!

[EDITED]
Do not take me too serious
Anyway i do not like Discourse
User avatar
axe70
Registered User
Posts: 752
Joined: Sun Nov 17, 2002 10:55 am
Location: Italy
Name: Alessio
Contact:

Re: Display only the first post to certain groups

Post by axe70 »

So, i have not follow to look around for the groups mentioned issue, since the requirement to get all groups that an user belong to, is something that can by bypassed by the extension settings (in this case).
But if anyone could help i will be glad!

The extension code is ready.
I had write the code adding the user argument into services for the front-end listener, but soon i realized it is not required because the same info we want, are already contained and comes within the language.
It already contain the forum id the user is going to view, and also all the required user's data, so that the user argument has been removed from loaded services because seem not useful (and can be re-added with easy).
I will go to post into proper forum the easy code that is ready, and that can be improved in few steps by anyone.
It will be also githubbed.

Cheers to all the lovely people! ;)

p.s i know you'll hate me for terms i use that aren't conventional... hope all is anyway clear, sorry! :D
Do not take me too serious
Anyway i do not like Discourse
User avatar
axe70
Registered User
Posts: 752
Joined: Sun Nov 17, 2002 10:55 am
Location: Italy
Name: Alessio
Contact:

Re: Display only the first post to certain groups

Post by axe70 »

Hello nice guys, all the necessary has been done and the extension is ready:
https://github.com/axew3/phpbb-display-only-first-post

the stupid question now is: where i should submit it for the validation?
Thank you
Do not take me too serious
Anyway i do not like Discourse
User avatar
HiFiKabin
Community Team Member
Community Team Member
Posts: 6673
Joined: Wed May 14, 2014 9:10 am
Location: Swearing at the PC, UK
Name: James
Contact:

Re: Display only the first post to certain groups

Post by HiFiKabin »

https://www.phpbb.com/customise/db/

"New Contribution" Button and follow the instructions
User avatar
axe70
Registered User
Posts: 752
Joined: Sun Nov 17, 2002 10:55 am
Location: Italy
Name: Alessio
Contact:

Re: Display only the first post to certain groups

Post by axe70 »

Ok all done
Thank you!
Do not take me too serious
Anyway i do not like Discourse
User avatar
HiFiKabin
Community Team Member
Community Team Member
Posts: 6673
Joined: Wed May 14, 2014 9:10 am
Location: Swearing at the PC, UK
Name: James
Contact:

Re: Display only the first post to certain groups

Post by HiFiKabin »

Topic concluded therefore closing
Locked

Return to “Extension Writers Discussion”