phpBB2Refugees.com Logo
Not affiliated with or endorsed by the phpBB Group

Register •  Login 

Continue the legacy...

Welcome to all phpBB2 Refugees!Wave Smilie

This site is intended to continue support for the legacy 2.x line of the phpBB2 bulletin board package. If you are a fan of phpBB2, please, by all means register, post, and help us out by offering your suggestions. We are primarily a community and support network. Our secondary goal is to provide a phpBB2 MOD Author and Styles area.

Disable user+posts


 
Search this topic... | Search MOD Requests... | Search Box
Register or Login to Post    Index » MOD Requests  Previous TopicPrint TopicNext Topic
Author Message
hoimyr
Board Member



Joined: 16 Apr 2009

Posts: 115
Location: Oslo


flag
PostPosted: Sat Sep 18, 2010 12:18 pm 
Post subject: Disable user+posts

Hi!
I have a user that wants all his posts and topics hidden. But he may want them back some years later... So NOT deleted.
The topics is easy, just move them to a hidden topic(and i can move them back) but what about his post in other topics all over? I was looking at an approve mod (v2?) but it seems not to be able to do just this. "Un-approving posts" would be an ok solution.
I dont want to split them out of threads because that would too much work and much work to get back. icon_wink.gif

Do you know of any mods i can use for this or ideas? Can the permissions or groups system be used?

Is there an "Disable user and all his posts and topics mod"?

Thanks!

Thomas
Back to top
Acaria
Board Member



Joined: 20 Feb 2009

Posts: 238



PostPosted: Sat Sep 18, 2010 6:33 pm 
Post subject: Re: Disable user+posts

Don't know of any mod, but I have an idea of how you could do it:

  1. Go into phpMyAdmin
  2. Create a new table
  3. Execute SQL to show all posts made by him
  4. Copy all the info into your new table as a backup
  5. Now run an SQL statement that will replace all of his posts with something like "[Message Hidden]" or something of the like.


Simple enough, but it will take time. And if he ever wants them back, you just run SQL to restore the original post bodies. Though I can't see why anyone would need to do this...
Back to top
Salvatos
Board Member



Joined: 19 Feb 2009

Posts: 414
Location: Québec


flag
PostPosted: Sat Sep 18, 2010 6:40 pm 
Post subject: Re: Disable user+posts

I see two ways of doing this. The first would be to change the SQL queries so that this user's posts are not even fetched from the database. This means that the topics will flow as if he had never posted in them (which probably won't look natural sometimes).

The second option, which I prefer, would be to only prevent the fetched post from being displayed. You also have two options within this one: either you only replace the post with a message like "[Message hidden by admin]" or you skip it altogether for a result similar to our first option. I would personally just hide the content as it is easier to implement and remove, and looks better to me.

Let's suppose you have a clean viewtopic.php. Go to line 1158 and you see this:
Code:
        $template->assign_block_vars('postrow', array(
      'ROW_COLOR' => '#' . $row_color,

BEFORE, ADD
Code:
    if ($poster_id == 9000) // replace 9000 with your user's ID
    {
        $message = "[Message hidden by admin]"; // Or whatever message you want displayed instead
    }

Easy as pie. Posts can also be seen in includes/topic_review.php, however, so let's change that one too. In a clean file, you'd go to line 190:
Code:
            $template->assign_block_vars('postrow', array(
                'ROW_COLOR' => '#' . $row_color,

BEFORE, ADD
Code:
            if ($row['user_id'] == 9000) // replace 9000 with your user's ID
            {
                $message = "[Message hidden by admin]"; // Or whatever message you want displayed instead
            }

And lastly there's that pesky search.php that keeps bringing them up too. Now you're aiming for line 1039 in a clean file:
Code:
                $template->assign_block_vars("searchresults", array(
                    'TOPIC_TITLE' => $topic_title,

BEFORE, ADD
Code:
                if ($searchset[$i]['user_id'] == 9000) // replace 9000 with your user's ID
                {
                    $message = "[Message hidden by admin]"; // Or whatever message you want displayed instead
                }


And there you go. Using this method you have all the posts' spots saved, but the messages aren't displayed. You can expand from this to also hide their username, avatar, etc. by replacing the variables used in the $template->assign_block_vars from within the if clause. And the day you want to cancel that change, you only have about four consecutive lines to remove from three files.

It should be noted that the search function itself will still find the content of the hidden user's posts. So if, for instance, "bubba bubba" is found once in a topic and happens to be in that user's post, a person looking for it will see the topic/post come up in the results but won't actually find the string. It might cause confusion once a decade, but I don't suppose that warrants altering the code more heavily (you decide, though). But it could be done by adding something like "p.poster_id != 9000" in the two queries around line 750 - let me know if you would like the actual modification for that too.


N. B. Using this MOD you don't really have to move the user's topics since their content will be hidden all the same and you might want to keep the rest of the topic visible (depends on what kind it is). Regardless, this brings to my attention the fact that quotes from his posts will remain intact whatever you do, lest you manually look for them all and actually delete them from the quoting users' posts. Obviously if you have a large board this is not the kind of thing you'd like to do, but you may want to warn the departing user about it.
Back to top
dogs and things
Board Member



Joined: 18 Nov 2008

Posts: 621
Location: Spain


flag
PostPosted: Sat Sep 18, 2010 11:17 pm 
Post subject: Re: Disable user+posts

Another option I see is to create a new user and then use the Post Associator MOD to associate the leaving user's posts and topics to the newly created user.

If the leaving user ever decides to come back you simple associate the post and topics from the fake user you created back to the original poster.

This way all posts, topics and quotes remain visible carrying another username and thus the impact on the flow of the board is minimal.

If really needed you can now delete the leaving user, if he ever wants to come he simple registers again and you associate everything to that new account.

He won´t have anything to complain about as he has disappeared from your board altogether.

_________________
phpBB2 will never die, I hope!
Back to top
hoimyr
Board Member



Joined: 16 Apr 2009

Posts: 115
Location: Oslo


flag
PostPosted: Sun Sep 19, 2010 10:32 am 
Post subject: Re: Disable user+posts

Wow!! Many cool solutions here! Thanks for helping!

My board isnt very heavy yet. About 80.000 posts but growing so want to keep the queries to a minimum. Salvatos, is it possible to just make the whole post disappear? Not even showing up. Doing this with one user is OK but when other members see that "hidden by admin" message i fear that other old members want that too. So if i have this fix on 5..or 10 users i guess it starts to get heavy right? Just empty posts may be good though.
Yes please, if you get time to do the search fix thats awesome! icon_biggrin.gif

The Post Associator MOD is also an alternative way to do it. But i think he will see that they are just renamed? Will take a closer look on that one too! Cool!

Appretiate all solutions here! Thanks! icon_smile.gif Now to try it out in action.
Back to top
dogs and things
Board Member



Joined: 18 Nov 2008

Posts: 621
Location: Spain


flag
PostPosted: Sun Sep 19, 2010 11:12 am 
Post subject: Re: Disable user+posts

But was does it matter that he sees they are just renamed?
_________________
phpBB2 will never die, I hope!
Back to top
hoimyr
Board Member



Joined: 16 Apr 2009

Posts: 115
Location: Oslo


flag
PostPosted: Sun Sep 19, 2010 3:42 pm 
Post subject: Re: Disable user+posts

I run a creative site and the user has posted his own works in wip threads(images). So i cant do that on this user. The images and content needs to be hidden. :/
Back to top
Salvatos
Board Member



Joined: 19 Feb 2009

Posts: 414
Location: Québec


flag
PostPosted: Sun Sep 19, 2010 4:37 pm 
Post subject: Re: Disable user+posts

hoimyr wrote:
Salvatos, is it possible to just make the whole post disappear? Not even showing up.

hoimyr wrote:
Yes please, if you get time to do the search fix thats awesome! icon_biggrin.gif

Sure, I'll work on that a bit later, gotta log off soon.

hoimyr wrote:
So if i have this fix on 5..or 10 users i guess it starts to get heavy right? Just empty posts may be good though.

As far as speed and resource go, I'm no expert but I would surmise the difference would be minimal, since you're just adding conditions to your clause. Coding-wise, the only difference would be to change the 'if' so that it says (pseudo-code) "user_id == 3000 OR user_id == 6000 OR user_id == 9000" etc. instead of having just one ID to check.

Please let me know if you choose to settle for that option so I don't work on the other in vain icon_wink.gif


Note to self: 831
Back to top
hoimyr
Board Member



Joined: 16 Apr 2009

Posts: 115
Location: Oslo


flag
PostPosted: Sun Sep 19, 2010 7:03 pm 
Post subject: Re: Disable user+posts

Quote:
I would surmise the difference would be minimal

That is great news! The most important is to make them not showing up. If you figgure out how to do it thats totally awesome!! icon_biggrin.gif
I was wondering. Is it possible to make it use a group id instead of user_id? That way admins and moderators could then add members to a group instead of adding user id's in the files. But if that gets heavy again on server load don't do it!! Just an idea. Appreciate your help!
Back to top
Salvatos
Board Member



Joined: 19 Feb 2009

Posts: 414
Location: Québec


flag
PostPosted: Sun Sep 19, 2010 7:20 pm 
Post subject: Re: Disable user+posts

That's an interesting approach. Groups are not identified in viewtopic.php, but there's ranks that we can use. Just create a rank, say "Hidden", and give it to all members whose posts you want hidden. But they're not in search.php nor topic_review.php so we'd have to add some stuff to the SQL queries and code in those, thus making it more complicated than just adding IDs to your modification.

Let me know what you think, I'll edit this post when my fix for search.php is done.

Search fix:
Replace line 749:
Code:
                    AND p.poster_id = u.user_id";

with:
Code:
                    AND p.poster_id = u.user_id
                    AND p.poster_id != '9000'"; // Add a line like this for each user_id to block from search

and 760:
Code:
                    AND u2.user_id = p2.poster_id";

with
Code:
                    AND u2.user_id = p2.poster_id
                    AND u2.user_id != '9000'"; // Add a line like this for each user_id to block from search


Again, change 9000 to the actual user_id, and as mentioned, add a similar line for each user (make sure to end the last line (only the last) with '";', excluding the comment after '//', as in the examples above).
Back to top
hoimyr
Board Member



Joined: 16 Apr 2009

Posts: 115
Location: Oslo


flag
PostPosted: Sun Sep 19, 2010 8:08 pm 
Post subject: Re: Disable user+posts

Salvatos wrote:
But they're not in search.php nor topic_review.php so we'd have to add some stuff to the SQL queries and code in those, thus making it more complicated than just adding IDs to your modification.
Oh, no dont spend time on the groups then. This user_id hardcoding is perfect for this. This dont happen alot so can add them in the files. No problem! icon_smile.gif
You are fast!! testing this now! icon_biggrin.gif

edit: it works great. I have a "disabled post" message on the posts. Thanks again!
Back to top
Salvatos
Board Member



Joined: 19 Feb 2009

Posts: 414
Location: Québec


flag
PostPosted: Tue Sep 21, 2010 5:53 pm 
Post subject: Re: Disable user+posts

Glad to hear that! icon_smile.gif
Back to top
Display posts from previous:   
Register or Login to Post    Index » MOD Requests  Previous TopicPrint TopicNext Topic
Page 1 of 1 All times are GMT
 
Jump to:  

Index • About • FAQ • Rules • Privacy • Search •  Register •  Login 
Not affiliated with or endorsed by the phpBB Group
Powered by phpBB2 © phpBB Group
Generated in 0.0265 seconds using 15 queries. (SQL 0.0061 Parse 0.0006 Other 0.0199)
phpBB Customizations by the phpBBDoctor.com
Template Design by DeLFlo and MomentsOfLight.com Moments of Light Logo