[RFC|Merged] Improve User Pruning feature

These requests for comments/change have lead to an implemented feature that has been successfully merged into the 3.1/Ascraeus branch. Everything listed in this forum will be available in phpBB 3.1.
MartinTruckenbrodt
Posts: 171
Joined: Sun Jan 29, 2006 1:00 pm
Location: Germany
Contact:

Re: [RFC|Accepted] Improve User Pruning feature

Post by MartinTruckenbrodt » Wed Jun 22, 2011 3:39 pm

Hello Oleg,
could post a screenshot of the new ACP page?
I'm interested in seeing the new settings.
Sorry, I'm not using Github. I'm just a MOD author, I'm not a developer.

Just to remind: viewtopic.php?p=211137#p211137 .
What's the matter of a true auto user pruning?
Code from Advanced Double Activation Pack could be used. But I can't you if it is programmed good enough or not.
I'm just a MOD author, I'm not a developer.
:)

Bye Martin
Advanced Block MOD 1.1.1 has been released! - Prevent spam on your phpBB3 board with Stop Forum Spam, BotScout, Akismet, Project Honey Pot and several IP-RBL and Domain-RBL DNS blacklists! - My MODs


User avatar
AmigoJack
Registered User
Posts: 92
Joined: Wed May 04, 2011 7:47 pm
Location: グリーン ヒル ゾーン
Contact:

Re: [RFC] Improve User Pruning feature

Post by AmigoJack » Sun Aug 07, 2011 9:53 pm

Oleg wrote:return a list of results that have checkboxes next to each user, in a form, submitting which removes checked users
This is very helpful. I've added this to the otherwise rather useless "are you sure..." question - it now shows:
  • Username as link (leads to user administration)
  • Checkbox in front of the username which is checked by default
  • Post count as link (searches all posts)
  • Topic count as link (searches all topics)
  • Registration date
  • Last seen date
  • Last post date (if any)
This way you can really check on who will be pruned.


Other things I've included regarding pruning:
  1. An option "Banned: Also find users which are currently banned by username or by e-mail-address", so your results will also include banned users (which otherwise will never be found).
  2. For ACP > Users and groups > Users > Manage users > Overview I've added an option "Never prune: This will always exclude the member from the "prune users" function". This is meant for accounts which may get inactive for a long time or which may be found again and again by the prune search where you'd have to uncheck those accounts always.

Oleg
Posts: 1150
Joined: Tue Feb 23, 2010 2:38 am
Contact:

Re: [RFC|Accepted] Improve User Pruning feature

Post by Oleg » Sun Aug 07, 2011 11:38 pm

Is there any code to go with that informative post? ;)

MartinTruckenbrodt
Posts: 171
Joined: Sun Jan 29, 2006 1:00 pm
Location: Germany
Contact:

Re: [RFC|Accepted] Improve User Pruning feature

Post by MartinTruckenbrodt » Mon Aug 08, 2011 9:25 am

Hello Oleg,
if you want you can use the code of the Advanced Double Activation Pack. The feature which excludeds users or urser groups from auto user pruning is included in ADAP since about two years.

I'm not a programmer. So I'm quite sure that the ADAP code could be realized in a better way. But I think at least it could be a little idea or help for you.
I think all of the ADAP features are missing core and basic features in phpBB. Just a feature to set members temporary or permanent offline is the last feature I would include to make ADAP complete. This could be usefull if a member has to make a break with the community. So other members can not contact this offline user. Then they will not wait fot answers for posts or PMs unsuccessfully.

Please give the features of ADAP a chance in Ascraeus! I'm absolutely sure that a lot of people would use at least the Double Activation and the true Auto user prune.

True Auto prune will reduce the number of possible misconfigured prune settings. So I'm sure that phpBB using webmasters will be much more happier and much more relaxed.

Bye Martin
Advanced Block MOD 1.1.1 has been released! - Prevent spam on your phpBB3 board with Stop Forum Spam, BotScout, Akismet, Project Honey Pot and several IP-RBL and Domain-RBL DNS blacklists! - My MODs

User avatar
AmigoJack
Registered User
Posts: 92
Joined: Wed May 04, 2011 7:47 pm
Location: グリーン ヒル ゾーン
Contact:

Re: [RFC|Accepted] Improve User Pruning feature

Post by AmigoJack » Mon Aug 08, 2011 11:33 am

Open /includes/acp/acp_prune.php and find (will occur twice):

Code: Select all

                $user_ids = $usernames = array();
                $this->get_prune_users($user_ids, $usernames);
Change to:

Code: Select all

                /*** 2010-10-23 BEGIN AmigoJack
                    Additional details to be displayed ***/
                $aDetail= 
                $user_ids = $usernames = array();
                //$this->get_prune_users($user_ids, $usernames);
                $this->get_prune_users($user_ids, $usernames, $aDetail);
                /*** 2010-10-23 END ***/
Find:

Code: Select all

            if (confirm_box(true))
            {
                $user_ids = $usernames = array();
                $this->get_prune_users($user_ids, $usernames);
After, add:

Code: Select all

                /*** 2011-05-17 BEGIN AmigoJack
                    Only leave those which are checked ***/
                $aCheck= request_var( 'user_id_check', array( 0 ) );
                foreach( $user_ids as $k1=> $v1 ) if( !in_array( $v1, $aCheck ) ) {
                    unset( $user_ids[$k1] );
                    unset( $usernames[$v1] );
                }
                /*** 2011-05-17 END ***/
Find:

Code: Select all

                        'U_USER_ADMIN'        => ($auth->acl_get('a_user')) ? append_sid("{$phpbb_admin_path}index.$phpEx", 'i=users&mode=overview&u=' . $user_id, true, $user->session_id) : '',
After, add:

Code: Select all

                        /*** 2010-10-23 BEGIN AmigoJack
                            Additional details to be displayed ***/
                        'ID'=> $user_id,
                        'USERPOSTS'=> $aDetail[$user_id]['user_posts'],
                        'U_USERPOSTS'=> $auth-> acl_get( 'u_search' )? append_sid( "{$phpbb_root_path}search.$phpEx", 'author_id=' . $user_id. '&sr=posts' ): '',
                        'USERTOPICS'=> $aDetail[$user_id]['user_topics'],
                        'U_USERTOPICS'=> $auth-> acl_get( 'u_search' )? append_sid( "{$phpbb_root_path}search.$phpEx", 'author_id=' . $user_id. '&sr=topics' ): '',
                        'USERJOINED'=> $user-> format_date( $aDetail[$user_id]['user_regdate'], FALSE, FALSE ),
                        'ACTIVE'=> $user-> format_date( $aDetail[$user_id]['user_lastvisit'], FALSE, FALSE ),
                        'LASTPOST'=> $user-> format_date( $aDetail[$user_id]['user_lastpost_time'], FALSE, FALSE ),
                        /*** 2010-10-23 END ***/
Find:

Code: Select all

                    'deleteposts'    => request_var('deleteposts', 0),
After, add:

Code: Select all

                    /*** 2010-12-17 BEGIN AmigoJack
                        Find banned users ***/
                    'banned'=> request_var( 'banned', 0 ),
                    /*** 2010-12-17 END ***/
Find:

Code: Select all

    function get_prune_users(&$user_ids, &$usernames)
Replace with:

Code: Select all

    function get_prune_users(&$user_ids, &$usernames
    /*** 2010-10-23 BEGIN AmigoJack
        Additional details to be displayed ***/
    , &$aDetail
    /*** 2010-10-23 END ***/
    )
Find:

Code: Select all

            $where_sql .= ($count !== '') ? " AND user_posts " . $key_match[$count_select] . ' ' . (int) $count . ' ' : '';
After, add:

Code: Select all

            /*** 2010-12-17 BEGIN AmigoJack
                Find banned users ***/
            $aBanned= array();
            if( request_var( 'banned', 0 ) ) {
                // Find all users banned by name or e-mail-address
                $sql= 'SELECT u.user_id
                    FROM '. BANLIST_TABLE. ' b INNER
                    JOIN '. USERS_TABLE. ' u ON ( ( b.ban_userid= u.user_id and b.ban_userid> 0 ) or ( b.ban_email= u.user_email and b.ban_email<> \'\' ) ) 
                    WHERE b.ban_userid> 0 or b.ban_email<> \'\'';
                $result= $db-> sql_query( $sql );
                while( $row= $db-> sql_fetchrow( $result ) ) $aBanned[]= $row['user_id'];
                $db-> sql_freeresult( $result );

                // Add filter of found user IDs
                $where_sql.= ' AND '. $db-> sql_in_set( 'user_id', $aBanned, FALSE, TRUE );
            }
            /*** 2010-12-17 END ***/
Find:

Code: Select all

        // Do not prune founder members
        $sql = 'SELECT user_id, username
            FROM ' . USERS_TABLE . '
            WHERE user_id <> ' . ANONYMOUS . '
                AND user_type <> ' . USER_FOUNDER . "
            $where_sql";
Replace with:

Code: Select all

        // Do not prune founder members
        /*** 2010-08-06 BEGIN AmigoJack
            Prevent members from being pruned and get more details ***/
        $sql = 'SELECT user_id, username, user_regdate, user_posts, user_topics, user_lastvisit, user_lastpost_time
            FROM ' . USERS_TABLE . '
            WHERE user_id <> ' . ANONYMOUS . '
                AND user_type <> ' . USER_FOUNDER. "
                AND user_neverprune= 0
            $where_sql";
        /*** 2010-08-06 END ***/
Find:

Code: Select all

$usernames[$row['user_id']] = $row['username'];
After, add:

Code: Select all

                /*** 2010-10-23 BEGIN AmigoJack
                    Additional details to be displayed ***/
                $aDetail[$row['user_id']]= $row;
                /*** 2010-10-23 END ***/
Open /adm/style/acp_prune_users.html and find:

Code: Select all

<dl>
	<dt><label for="count">{L_POSTS}:</label></dt>
	<dd><select name="count_select">{S_COUNT_OPTIONS}</select> <input type="text" id="count" name="count" /></dd>
</dl>
After, add:

Code: Select all

<dl>
	<dt><label for="banned">{L_BANNED}:</label><br /><span>{L_BANNED_EXPLAIN}</span></dt>
	<dd><label><input type="radio" class="radio" name="banned" value="1" /> {L_YES}</label>
		<label><input type="radio" class="radio" id="banned" name="banned" value="0" checked="checked" /> {L_NO}</label></dd>
</dl>
Open /adm/style/confirm_body_prune.html and find:

Code: Select all

	<br />
	<!-- BEGIN users -->
	&raquo; <a href="{users.U_PROFILE}">{users.USERNAME}</a><!-- IF users.U_USER_ADMIN --> [<a href="{users.U_USER_ADMIN}">{L_USER_ADMIN}</a>]<!-- ENDIF --><br />
	<!-- END users -->
Replace with:

Code: Select all

	<br /><table><thead><tr>
		<th>{L_USERNAME}</th>
		<th>{L_POSTS}</th>
		<th>{L_TOPICS}</th>
		<th>{L_JOINED}</th>
		<th>{L_LAST_ACTIVE}</th>
		<th>{L_LAST_POST}</th>
	</tr></thead><tbody>
	<!-- BEGIN users --><tr>
		<td><input type="checkbox" name="user_id_check[]" value="{users.ID}" checked="checked" /> <a href="<!-- IF users.U_USER_ADMIN -->{users.U_USER_ADMIN}<!-- ELSE -->{users.U_PROFILE}<!-- ENDIF -->">{users.USERNAME}</a></td>
		<td style="text-align: right;"><a href="{users.U_USERPOSTS}">{users.USERPOSTS}</a></td>
		<td style="text-align: right;"><a href="{users.U_USERTOPICS}">{users.USERTOPICS}</a></td>
		<td>{users.USERJOINED}</td>
		<td>{users.ACTIVE}</td>
		<td>{users.LASTPOST}</td>
	</tr><!-- END users -->
	</tbody></table>

	<p class="small">
		<a href="#" onclick="marklist('confirm', 'user_id_check', true); return false;">{L_MARK_ALL}</a> &bull; 
		<a href="#" onclick="marklist('confirm', 'user_id_check', false); return false;">{L_UNMARK_ALL}</a>
	</p>
Open /language/*/acp/prune.php and find:

Code: Select all

$lang = array_merge($lang, array(
After, add:

Code: Select all

    /*** 2010-12-17 BEGIN AmigoJack
        Find banned user(name)s ***/
    'BANNED'=> 'Banned',
    'BANNED_EXPLAIN'=> 'Also find users which are currently banned by username or by e-mail-address.',
    /*** 2010-12-17 END ***/
The column phpbb_users.user_topics is another addition (copies the behaviour of user_posts accordingly and everywhere) and phpbb_users.user_neverprune behaves like a boolean, which can be set in the ACP users overview only. Yes I know, the code doesn't follow the phpBB guidelines.

Oleg
Posts: 1150
Joined: Tue Feb 23, 2010 2:38 am
Contact:

Re: [RFC|Accepted] Improve User Pruning feature

Post by Oleg » Sun Dec 04, 2011 12:34 am

That is a little too much code for me to make into a diff. For now I will only finish and pull request A Jelly Doughut's changes.

On which note, the group filter appears to only include user-defined groups, such that it has no groups in a vanilla installation. This is confusing, either wording should be changed or it needs to include built-in groups as well. And if we change wording, do not display the select box if it has no groups in it.

User avatar
A_Jelly_Doughnut
Registered User
Posts: 1780
Joined: Wed Jun 04, 2003 4:23 pm

Re: [RFC|Accepted] Improve User Pruning feature

Post by A_Jelly_Doughnut » Tue Dec 13, 2011 12:50 am

Oleg wrote: On which note, the group filter appears to only include user-defined groups, such that it has no groups in a vanilla installation. This is confusing, either wording should be changed or it needs to include built-in groups as well. And if we change wording, do not display the select box if it has no groups in it.
I have fixed this locally (will be pushing once I get some data to test with).

@Martin, Jack:

Many of the things you've suggested are already implemented. Some things that are not:
- Pruning cannot be made automatic.
- You cannot prune on the last post date or date when the account was deactivated
- On the confirmation page listing the users to be pruned, only the username is listed. The username is a link to the profile of the user in question, with a checkbox to exclude the user from the prune.

Continued feedback is welcome. UI screenshots are attached.
Attachments
UserPrune.png
(86.06 KiB) Downloaded 3577 times
UserPrune2.png
(31.55 KiB) Downloaded 3577 times
A_Jelly_Doughnut

User avatar
A_Jelly_Doughnut
Registered User
Posts: 1780
Joined: Wed Jun 04, 2003 4:23 pm

Re: [RFC|Accepted] Improve User Pruning feature

Post by A_Jelly_Doughnut » Tue Dec 13, 2011 2:36 am

Code is up.

Git log data is ... eh, wrong. Reference: https://github.com/jellydoughnut/phpbb3 ... rune-users
Looks like a good time to use git cherry-pick?
A_Jelly_Doughnut

User avatar
naderman
Product Manager
Product Manager
Posts: 1727
Joined: Sun Jan 11, 2004 2:11 am
Location: Karlsruhe, Germany
Contact:

Re: [RFC|Accepted] Improve User Pruning feature

Post by naderman » Tue Dec 13, 2011 2:56 pm

Rebase onto latet develop and send a WIP pull request to track it properly from now on?

Post Reply