[ABD] Topic View Counter

Any abandoned Extensions will be moved to this forum.

WARNING: Extensions in this forum are not currently being supported or maintained by the original Extension author. Proceed at your own risk.
Forum rules
IMPORTANT: Extension Development Forum rules

WARNING: Extensions in this forum are not currently being supported nor updated by the original Extension author. Proceed at your own risk.
Locked
lansingred
Registered User
Posts: 37
Joined: Fri Feb 22, 2019 4:51 am

[ABD] Topic View Counter

Post by lansingred »

Extension Name: Topic View Counter
Author: lansingred

Extension Description:
Replaces the topic view numbers on the viewforum page. This topic view counter register a new view from a user based on time span set from his last visit of the topic page. Time span can be custom defined. So view number won't increase from spamming.

Extension Version: 1.0.0

Requirements:
phpBB Version: >=3.2.0,<3.3.0@dev | PHP Version: >=5.4

Features:
Setting in ACP for users to define their own time span. Default is 3 hours, max is 24 hours

Screenshots:
before:
Image

after:
Image

Installation:
  1. Download the files
  2. Unzip the files to your phpbb\ext\ directory, standard full path would look like this phpbb\ext\lansingred\topicviewcounter\
  3. Go to ACP on your forum, then go to Customize->Manage extensions and enable Topic View Counter extension
Latest version: 1.0.2

Extension Download:
https://github.com/gundamftw/phpbb-ext- ... ew-counter

Important Notes:
This extension will stores IP addresses from guests and view time from registered users, board owners please take that into consideration with their GDPR compliance.
Last edited by lansingred on Tue Feb 26, 2019 9:57 pm, edited 3 times in total.
lansingred
Registered User
Posts: 37
Joined: Fri Feb 22, 2019 4:51 am

Re: [3.2][BETA] Topic View Counter

Post by lansingred »

wrong edit, please delete
User avatar
mrgoldy
Development Team Member
Development Team Member
Posts: 1392
Joined: Tue Oct 06, 2009 7:34 pm
Location: The Netherlands
Name: Gijs
Contact:

Re: [3.2][BETA] Topic View Counter

Post by mrgoldy »

It might be important to note that this stores IP addresses from guests and the view time for registered users, so board owners can take that into consideration with their GDPR compliance.

And on a site note, perhaps you can look into creating a github account and repository, so people can more easily see the code and know what and from where they're downloading, as I can imagine people might be a bit reluctant of downloading things from mediafire.
phpBB Studio / Member of the Studio

Contributing: You can do it too! Including testing Pull Requests (PR).
phpBB Development and Testing made easy.
lansingred
Registered User
Posts: 37
Joined: Fri Feb 22, 2019 4:51 am

Re: [3.2][BETA] Topic View Counter

Post by lansingred »

mrgoldy wrote:
Tue Feb 26, 2019 7:32 pm
It might be important to note that this stores IP addresses from guests and the view time for registered users, so board owners can take that into consideration with their GDPR compliance.

And on a site note, perhaps you can look into creating a github account and repository, so people can more easily see the code and know what and from where they're downloading, as I can imagine people might be a bit reluctant of downloading things from mediafire.
Okay I updated the download link to github and added the notes.
User avatar
lopoto
Registered User
Posts: 108
Joined: Thu Feb 12, 2015 3:13 pm

Re: [3.2][BETA] Topic View Counter

Post by lopoto »

What's the difference between these two photos? because I can not see any. am too old? :mrgreen:
User avatar
</Solidjeuh>
Registered User
Posts: 1788
Joined: Tue Mar 29, 2016 3:45 am
Location: Aalst (Belgium)
Name: Andy Dm
Contact:

Re: [3.2][BETA] Topic View Counter

Post by </Solidjeuh> »

lansingred wrote:
Mon Feb 25, 2019 4:11 am
Extension Description:
Replaces the topic view numbers on the viewforum page. This topic view counter register a new view from a user based on time span set from his last visit of the topic page. Time span can be custom defined. So view number won't increase from spamming.
User avatar
FredQ
Registered User
Posts: 138
Joined: Sat Nov 01, 2014 10:48 am
Location: Northeast Scotland
Name: Fred Q
Contact:

Re: [3.2][BETA] Topic View Counter

Post by FredQ »

lopoto wrote:
Tue Feb 26, 2019 10:14 pm
What's the difference between these two photos? because I can not see any. am too old? :mrgreen:
The number of views are smaller, because the extension detected it was the same user refreshing the page (or going back and forth)
My board (converted from vBulletin)
User avatar
3Di
Former Team Member
Posts: 16032
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milan (IT) Frankfurt (DE)
Name: Marco
Contact:

Re: [3.2][BETA] Topic View Counter

Post by 3Di »

https://github.com/gundamftw/phpbb-ext- ... r.php#L110

Code: Select all

		// this config was set from update_data() in the migration file
		$topics_table = $this->config['table_prefix'] . 'topics';
Why don't use constants instead and avoid that step in the migration? And save a query :)
See includes/constants.php. define('TOPICS_TABLE', $table_prefix . 'topics');

Else use the config/services.yml file of your extension and add - '%tables.topics%' to your listener.
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
mrgoldy
Development Team Member
Development Team Member
Posts: 1392
Joined: Tue Oct 06, 2009 7:34 pm
Location: The Netherlands
Name: Gijs
Contact:

Re: [3.2][BETA] Topic View Counter

Post by mrgoldy »

There are some thoughts out there that we should rely less on constants, so this approach is certainly allowed. The best one is indeed the last mentioned by 3Di, injecting the service parameter - '%tables.topics%'. But that could become very crowded once more tables are needed in various files. So thoughts differ on what the correct approach would be. Currently any of the three is fine (constant, table prefix, service parameter).

Oh my bad, did not see it was retrieved through config. I would suggest, if you want to use the table prefix approach, inject the - '%core.table_prefix%' service parameter instead.
phpBB Studio / Member of the Studio

Contributing: You can do it too! Including testing Pull Requests (PR).
phpBB Development and Testing made easy.
lansingred
Registered User
Posts: 37
Joined: Fri Feb 22, 2019 4:51 am

Re: [3.2][BETA] Topic View Counter

Post by lansingred »

Okay I'll update it, I just started learning it a few days ago, and the documentation isn't really newb friendly.

And I have question is here:
https://github.com/gundamftw/phpbb-ext- ... r.php#L124

From this line till the end, I basically copy and paste the same query code twice, one for the uid_counter_table data and one for the ip_counter_table data. Is this a okay, or should I refactor the core of the code into a function and then plug in the respective data? My thought is that having the two blocks separated would be more flexible if I decided to modify anyone of them in the future.
User avatar
3Di
Former Team Member
Posts: 16032
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milan (IT) Frankfurt (DE)
Name: Marco
Contact:

Re: [3.2][BETA] Topic View Counter

Post by 3Di »

lansingred wrote:
Wed Feb 27, 2019 1:03 am
the documentation isn't really newb friendly.
Just ask there at the writers' forum in case. ;)
lansingred wrote:
Wed Feb 27, 2019 1:03 am
From this line till the end, I basically copy and paste the same query code twice, one for the uid_counter_table data and one for the ip_counter_table data. Is this a okay, or should I refactor the core of the code into a function and then plug in the respective data? My thought is that having the two blocks separated would be more flexible if I decided to modify anyone of them in the future.
The same code if repeated should be moved to a helper class, that's considered a good habit and noted during the validation process AFAIK.
Indeed it is more flexible but is considered like spaghetti code somehow, if you need to modify one of them in the future I am sure you can find a solution like creating another function or make the help function itself more "flexible" - don't worry.

BTW, while using multiple UPDATE / INSERT / DELETE queries see here for example, it is better to surround such blocks within DB transactions, an example here: https://github.com/phpbb/phpbb/pull/552 ... cb9ec0b0d9
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! 🚀
lansingred
Registered User
Posts: 37
Joined: Fri Feb 22, 2019 4:51 am

Re: [3.2][BETA] Topic View Counter

Post by lansingred »

3Di wrote:
Wed Feb 27, 2019 1:15 am
lansingred wrote:
Wed Feb 27, 2019 1:03 am
the documentation isn't really newb friendly.
Just ask there at the writers' forum in case. ;)
lansingred wrote:
Wed Feb 27, 2019 1:03 am
From this line till the end, I basically copy and paste the same query code twice, one for the uid_counter_table data and one for the ip_counter_table data. Is this a okay, or should I refactor the core of the code into a function and then plug in the respective data? My thought is that having the two blocks separated would be more flexible if I decided to modify anyone of them in the future.
The same code if repeated should be moved to a helper class, that's considered a good habit and noted during the validation process AFAIK.
Indeed it is more flexible but is considered like spaghetti code somehow, if you need to modify one of them in the future I am sure you can find a solution like creating another function or make the help function itself more "flexible" - don't worry.
Where do you put that helper class in the ext folder?
User avatar
3Di
Former Team Member
Posts: 16032
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milan (IT) Frankfurt (DE)
Name: Marco
Contact:

Re: [3.2][BETA] Topic View Counter

Post by 3Di »

lansingred wrote:
Wed Feb 27, 2019 7:23 am
Where do you put that helper class in the ext folder?
That's another Class, you make a new folder, ie.: core and create the new Class , ie.: operator
example: https://github.com/phpBB-Studio/DateTop ... erator.php (that's one of the helper classes there)

Here's the related service
https://github.com/phpBB-Studio/DateTop ... ml#L62-L77

And inject that service in the listener (or controller, whatever), like
https://github.com/phpBB-Studio/DateTop ... es.yml#L16

And here is the listener using such service (helper class)
https://github.com/phpBB-Studio/DateTop ... hp#L48-L49

So you can make a function to call - in this case - for your duplicated queries, something like:
https://github.com/phpBB-Studio/DateTop ... #L238-L294
as you can see the first protected function is being used by the two below, giving a bit more flexibility to the whole stuff.
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! 🚀
lansingred
Registered User
Posts: 37
Joined: Fri Feb 22, 2019 4:51 am

Re: [3.2][BETA] Topic View Counter

Post by lansingred »

3Di wrote:
Wed Feb 27, 2019 7:38 am
lansingred wrote:
Wed Feb 27, 2019 7:23 am
Where do you put that helper class in the ext folder?
That's another Class, you make a new folder, ie.: core and create the new Class , ie.: operator
example: https://github.com/phpBB-Studio/DateTop ... erator.php (that's one of the helper classes there)

Here's the related service
https://github.com/phpBB-Studio/DateTop ... ml#L62-L77

And inject that service in the listener (or controller, whatever), like
https://github.com/phpBB-Studio/DateTop ... es.yml#L16

And here is the listener using such service (helper class)
https://github.com/phpBB-Studio/DateTop ... hp#L48-L49

So you can make a function to call - in this case - for your duplicated queries, something like:
https://github.com/phpBB-Studio/DateTop ... #L238-L294
as you can see the first protected function is being used by the two below, giving a bit more flexibility to the whole stuff.
So I should be keeping all the if-else logic in the listener file even it repeated twice and move only the queries to the new query handling class?
Paul
Infrastructure Team Leader
Infrastructure Team Leader
Posts: 26813
Joined: Sat Dec 04, 2004 3:44 pm
Location: The netherlands.
Name: Paul Sohier
Contact:

Re: [ABD] Topic View Counter

Post by Paul »

This topic has been marked as [ABD] - Abandoned as the extension author has not been active recently. If the extension author wishes to continue development, please PM anyone on the Extension Customisations Team to request this topic be unlocked.

Notice!
We do not recommend that a user of the phpBB software install this extension, or any other extension that is marked as "abandoned" or "in development", on a live forum. Doing so may cause your forum to not perform in the manner it should.


Thank you,
The phpBB Extension Customisations Team
Knock knock
Race condition
Who's there?

My BlogMy Photosmy phpBB Extensionscustom phpBB work & Development
Locked

Return to “Abandoned Extensions”