Retrieve Forum Permissions

Discussion forum for MOD Writers regarding MOD Development.
Locked
User avatar
$tring
Registered User
Posts: 233
Joined: Thu Mar 31, 2011 11:30 pm

Retrieve Forum Permissions

Post by $tring »

I have an array containing user id's. I want to know which users within the array have read access to a particular forum.

Code: Select all

$user_ary = array(2,4,7,9);
$forum_id = 1;
So, what is the easiest way to check which of these users has read access to that forum?

TIA
User avatar
AmigoJack
Registered User
Posts: 5779
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: Retrieve Forum Permissions

Post by AmigoJack »

Code: Select all

$aReadListAccess= $auth-> acl_get_list
( array
    ( 1  // Users to check
    , 2
    , 3
    , 4
    , 5 
    )
, array
    ( 'f_list'  // Permissions to check
    , 'f_read'
    )
, array
    ( 2  // Forums to check
              , 3
    )
);

// Show all results
foreach( $aReadListAccess as $kForum=> $vForum )
foreach( $vForum as $kPermission=> $vPermission )
foreach( $vPermission as $vUser )
printf( "in forum #%d user #%d is allowed to %s<br>\n", $kForum, $vUser, $kPermission );

// Direct test: is user #4 allowed to "read" forum #2:
if( in_array( 4, $aReadListAccess[2]['f_read'] ) ) printf( 'yes' );

// Or: print all users which are able to list forum #1:
print_r( $aReadListAccess[1]['f_list'] ); 
The worst thing about censorship is ███████████
Affin wrote:
Tue Nov 20, 2018 9:51 am
The problem is probably not my English but you do not want to understand correctly.
...
We will not come anybody anyway, nevertheless, it's best to shit this.
axe70 wrote:
Sat Oct 10, 2020 6:52 pm
But this shit is not here for you. You can follow with your.
Maybe the question, instead, was for you, who know, so you shoved us how you are.
User avatar
$tring
Registered User
Posts: 233
Joined: Thu Mar 31, 2011 11:30 pm

Re: Retrieve Forum Permissions

Post by $tring »

AmigoJack wrote:

Code: Select all

$aReadListAccess= $auth-> acl_get_list
( array
    ( 1  // Users to check
    , 2
    , 3
    , 4
    , 5 
    )
, array
    ( 'f_list'  // Permissions to check
    , 'f_read'
    )
, array
    ( 2  // Forums to check
              , 3
    )
);

// Show all results
foreach( $aReadListAccess as $kForum=> $vForum )
foreach( $vForum as $kPermission=> $vPermission )
foreach( $vPermission as $vUser )
printf( "in forum #%d user #%d is allowed to %s<br>\n", $kForum, $vUser, $kPermission );

// Direct test: is user #4 allowed to "read" forum #2:
if( in_array( 4, $aReadListAccess[2]['f_read'] ) ) printf( 'yes' );

// Or: print all users which are able to list forum #1:
print_r( $aReadListAccess[1]['f_list'] ); 
Stunning Sir, just what I needed.

Thank you very much indeed.

$
Locked

Return to “[3.0.x] MOD Writers Discussion”