vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Hide threads by usergroup (https://vborg.vbsupport.ru/showthread.php?t=47150)

Martin64 12-30-2002 08:37 PM

Hide threads by usergroup
 
I've been working on making the secretely banned users hack even more secret :laugh: but I'm stuck at the moment so I thought I'd ask for help. :)

What I'm wanting to do is to prevent all threads started by users from my secretely banned users group to show up in forumdisplay (visible to the banned users, admins and mods though). I figured out a way of doing this based on userids, but not usergroups. Here's what I did in forumdisplay.php:

Code:

if (($bbuserinfo['usergroupid']!=16 && $bbuserinfo['usergroupid']!=6 && $bbuserinfo['usergroupid']!=5 &&
$bbuserinfo['usergroupid']!=7) && ($thread[postuserid]==X or $thread[postuserid]==XX or
$thread[postuserid]==XXX)) { continue; }

Also, I did this in showthread.php, which gives an error message if members try to view a thread started by those members:

Code:

if (($bbuserinfo['usergroupid']!=16 && $bbuserinfo['usergroupid']!=6 && $bbuserinfo['usergroupid']!=5 &&
$bbuserinfo['usergroupid']!=7) && ($thread[postuserid]==X or
$thread[postuserid]==XX or $thread[postuserid]==XXX)) {
      $idname="thread";
      eval("standarderror(\"".gettemplate("error_invalidid")."\");");
    }

Once again, giving this error message based on usergroup rather than having to edit the files whenever a new member is put in the secretely banned users group would be splendid.

I hope someone can help with some tips. :classic:

Xenon 12-31-2002 01:14 PM

well, the usergroupid isn't saved within the threadtable, so you have to include the usertable to the query:

in forumdisplay find this:
PHP Code:

$getthreadids=$DB_site->query("
    SELECT
    "
.iif($sortfield=="voteavg",$votequery,"")."
        thread.threadid
    FROM thread
    WHERE thread.forumid = 
$foruminfo[forumid]
        AND thread.sticky=0
        AND thread.visible=1
    
$datecut
    
$limitothers
      ORDER BY sticky DESC, 
$sortfield $sqlsortorder
      LIMIT "
.($sel_limitlower-1).",$perpage"); 

and change it to:
PHP Code:

$getthreadids=$DB_site->query("
    SELECT
    "
.iif($sortfield=="voteavg",$votequery,"")."
        thread.threadid    FROM thread
              LEFT JOIN user ON (thread.postuserid = user.userid)
    WHERE thread.forumid = 
$foruminfo[forumid]
        AND thread.sticky=0
 "
.iif(in_array($bbuserinfo[usergroupid], array(5,6,7,16)), """AND user.usergroupid != 16 ") . "
        AND thread.visible=1
    
$datecut
    
$limitothers
      ORDER BY sticky DESC, 
$sortfield $sqlsortorder
      LIMIT "
.($sel_limitlower-1).",$perpage"); 


Chris M 12-31-2002 03:05 PM

Couldn't you just make it so that his threads get automatically moved to another forum?

Satan

Xenon 12-31-2002 03:09 PM

then he'd see that something isn't normal for him :)

Martin64 12-31-2002 03:30 PM

Yeah, I figured it would need something like that. It gives me an error though:

"There seems to have been a slight problem with the EmuTalk.net database.
Please try again by pressing the refresh button in your browser.
An E-Mail has been dispatched to our Technical Staff, who you can also contact if the problem persists.

We apologise for any inconvenience."

Martin64 12-31-2002 03:39 PM

Here's the error report the board sent me:

"Database error in vBulletin 2.2.8:

Invalid SQL:
SELECT

thread.threadid FROM thread
LEFT JOIN user ON (thread.postuserid = user.userid)
WHERE thread.forumid = 19
AND thread.sticky=0
AND user.usergroupid != 16
AND thread.visible=1
AND lastpost >= 1038763258 AND sticky=0

ORDER BY sticky DESC, lastpost DESC
LIMIT 0,20
mysql error: Column: 'lastpost' in where clause is ambiguous

mysql error number: 1052"

Xenon 01-01-2003 06:42 PM

ahh, yes i see

find this code:
PHP Code:

if ($daysprune != 1000) {
  
$checkdate time() - ($daysprune 86400);
  
$datecut 'AND lastpost >= ' $checkdate;


and change it to:
PHP Code:

if ($daysprune != 1000) {
  
$checkdate time() - ($daysprune 86400);
  
$datecut 'AND thread.lastpost >= ' $checkdate;



Martin64 01-01-2003 07:19 PM

Yeah, I figured it out earlier today with the help of a friend. Thanks a lot. :D

Now, how would I go about doing the same for showthread.php (cause the error based on usegroup rather than userid)? Any help would be appreciated. :D

EDIT: Nevermind, problem solved. :)

hamed 01-01-2003 07:54 PM

The same here. When I use :
PHP Code:

".iif(in_array($bbuserinfo[usergroupid], array(6,12)), "", "AND user.usergroupid != 12 ") . " 

it works perfect for the groups that have the permission to see the threads but the "There seems to have been a slight problem with Database" for the rest.
Any help please?

Martin64 01-01-2003 08:10 PM

Make sure you apply Xenon's latest code change. :)

hamed 01-01-2003 08:25 PM

Tanx for the help. I have done that but still the database error :(

Martin64 01-01-2003 08:43 PM

hamed, in forumdisplay...

FIND this:

Code:

$sortfield="lastpost";
REPLACE it with:

Code:

$sortfield="thread.lastpost";
FIND this:

Code:

$sortfield='lastpost';
REPLACE it with:

Code:

$sortfield='thread.lastpost';
That should do the trick. ;)

hamed 01-01-2003 09:13 PM

Tanx a lot. :) That did it.
I had missed the second one.

hamed 01-02-2003 09:40 AM

Is there anyway to stop pms from a user group?

Xenon 01-02-2003 01:34 PM

you can disable the whole pm-function for a usergroup in your ACP

hamed 01-02-2003 01:41 PM

Thank you Xenon. But if I do that then the banned user notices something is wrong.
Is there any way to hide the secret banned user group's pms for everyone?

Xenon 01-02-2003 02:04 PM

yes, just don't save em to the db ;)

open private.php find this:
PHP Code:

$DB_site->query("INSERT INTO privatemessage (privatemessageid,userid,touserid,fromuserid,title,message,dateline,showsignature,iconid,messageread,folderid,receipt) VALUES (NULL,$touserinfo[userid],$touserinfo[userid],$bbuserinfo[userid],'".addslashes(htmlspecialchars($title))."','".addslashes($message)."',".time().",'$signature','$iconid',0,0,$receipt)"); 

and change it to:
PHP Code:

if($bbuserinfo[usergroupid]!=16$DB_site->query("INSERT INTO privatemessage (privatemessageid,userid,touserid,fromuserid,title,message,dateline,showsignature,iconid,messageread,folderid,receipt) VALUES (NULL,$touserinfo[userid],$touserinfo[userid],$bbuserinfo[userid],'".addslashes(htmlspecialchars($title))."','".addslashes($message)."',".time().",'$signature','$iconid',0,0,$receipt)"); 

it should work :)

hamed 01-02-2003 02:31 PM

Thank you. But still I can send pms with my test ban user :(

Xenon 01-02-2003 02:40 PM

i've edited it, a bit, it was a little typing error ;)

also your banned group id is 16 wasn't it`?

hamed 01-02-2003 03:38 PM

Tanx ever so much. It is working now.
Just the popup and email notification are still working for the person that the pm is sent to. :(

Xenon 01-02-2003 03:57 PM

no problem also

find this in private.php:
PHP Code:

if ($userignored!=1) { 

and change to:
PHP Code:

if ($userignored!=and $bbuserinfo[usergroupid]!=16) { 


hamed 01-03-2003 03:11 AM

Thanks many thanks. It is perfect now!
Thank you :)

Xenon 01-03-2003 09:05 PM

:)

no problem, you're welcome

Martin64 01-03-2003 09:36 PM

I plan on releasing a full hack (either that or as an add-on to the secretly banned users hack). If I have Xenon's permission, I will include the additions in this thread as well. :)

So far the additions to the secretly banned users hack are:

- Option for moderators to either set a regular ban or a secret ban in the Mod CP.
- Hide threads started by secretely banned users to everyone but the user himself, admins and mods.
- Ignore private messages by secretely banned users.
- Give an "invalid thread error" when trying to view a thread started by a secretly banned user, unless the viewer is secretely banned, admin or mod. This is to prevent users from searching for posts by secretly banned users and being able to view them.

Xenon 01-04-2003 10:00 AM

feel free to use the additions from this thread here :)

Martin64 01-04-2003 08:39 PM

Great, and thanks for all your help. :)

Xenon 01-04-2003 09:32 PM

no problem

you're welcome :)

catbaba 05-31-2003 06:26 PM

Despite applying the 'thread.lastpost' fix mentioned here, I kept getting the following error every so often (a few times a day, and only when 'power forum users' tried to play with the thread display options at the bottom of the page), when using mySQL 4.0.13 and PHP 4.3.2:

Code:

Database error in vBulletin 2.3.0:

Invalid SQL:
    SELECT
   
        thread.threadid    FROM thread
              LEFT JOIN user ON (thread.postuserid = user.userid)
    WHERE thread.forumid = 18
        AND thread.sticky=0
 
        AND thread.visible=1
    AND thread.lastpost >= 1045766820
   
      ORDER BY sticky DESC, lastpost DESC
      LIMIT 25,25
mysql error: Column: 'lastpost' in order clause is ambiguous

mysql error number: 1052

Date: Saturday 31st of May 2003 07:47:00 PM
Script: http://www.ummah.com/forum/forumdisp...e=100&x=13&y=9

I fixed it by adding the following line of code before the database query:

PHP Code:

if ($sortfield == 'lastpost') {
    
$sortfield 'thread.lastpost';


So now the DB query code block looks like this (my secret ban usergroup is 104):

PHP Code:

// bismillah, add secret ban hack

if ($sortfield == 'lastpost') {
    
$sortfield 'thread.lastpost';
}

$getthreadids=$DB_site->query("
    SELECT
    "
.iif($sortfield=="voteavg",$votequery,"")."
        thread.threadid    FROM thread
              LEFT JOIN user ON (thread.postuserid = user.userid)
    WHERE thread.forumid = 
$foruminfo[forumid]
        AND thread.sticky=0
 "
.iif(in_array($bbuserinfo[usergroupid], array(5,6,7,104)), """AND user.usergroupid != 104 ") . "
        AND thread.visible=1
    
$datecut
    
$limitothers
      ORDER BY sticky DESC, 
$sortfield $sqlsortorder
      LIMIT "
.($sel_limitlower-1).",$perpage");

// end secret ban hack 

I just thought I'd post this in case anyone else is getting the same error.

ghroob 06-11-2003 06:16 AM

Hello
It is nice idea
May you make it hack please for v.2.3.0 ?

Tahnck you


All times are GMT. The time now is 01:20 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01317 seconds
  • Memory Usage 1,838KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (7)bbcode_code_printable
  • (11)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (29)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete