TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

March 29, 2024, 04:37:00 AM

Login with username, password and session length
Members
Stats
  • Total Posts: 195,105
  • Total Topics: 21,213
  • Online today: 142
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 0
  • Guests: 144
  • Total: 144

A few questions

Started by [chrisB], January 03, 2023, 09:05:11 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

tino

Quote from: [chrisB] on January 28, 2023, 07:01:57 PM
Will a fix be able to be patched to TP 2.2.2? 😇

You all do a great job with TinyPortal. If you ever need help finding bugs, I'm happy to help and have worked with IPS Devs before the release apps/plugins.

We're wrapping up the changes for 2.3.0 which will include this change I am sure, so I would wait for that personally.

@rjen

Quote from: tino on January 28, 2023, 06:52:06 PM
That's not what I am getting. I have admin see all blocks set to off and display settings set to ungrouped and I can see them, if I uncheck ungrouped, I can't.

I really wish I could say the same, but no.

I have a user that has 'Administrator' as primary user group, without any other memeergroups and set the 'Admin can see all blocks'  to OFF.

I have multiple blocks
1. blocks that are assigned to all membergroups
2. blocks that are assigned to NO membergroups
3. blocks that are assigned to ungrouped members only

NO blocks are showing at all.
Running Latest TP on SMF2.1 at: www.fjr-club.nl

tino

I've put a PR with the changes in, what version of PHP are you using? That's possibly the error.

@rjen

Using your code, PHP Version 8.0.26
Running Latest TP on SMF2.1 at: www.fjr-club.nl

tino

That doesn't help as I'm also on PHP 8.0 atm...

What is in the access field in the database for the blocks?

Also what group is your admin user in, that's in the members table.

Also you've not got the language setting checked? As that'll work correctly now..

@rjen

Quote from: tino on January 28, 2023, 07:22:40 PM
What is in the access field in the database for the blocks?
- Test block NO groups: access is blank
- Test block ALL: access is -1,0,3,11,12,13,14,15,16,17,18,19,20,21,22
- Test block UNgrouped: access is 0

Also what group is your admin user in, that's in the members table.
- as I said: administrator (group 1)

Also you've not got the language setting checked? As that'll work correctly now..
- Use language visibility option for blocks is not active


Running Latest TP on SMF2.1 at: www.fjr-club.nl

@rjen

@tino, did I formulate this correctly?

QuoteOk, coming back to the original question....

As it seems there is a small bug with the 'Admin can see all blocks' setting in 2.2.2 that we will address in 2.3.0.

BUT, the fix will NOT do what you want exactly: it will make the setting 'Admin can see all bocks' behave consistently for all blocks, the way it was originally designed.

The expected behaviour is this:

If a user has de Administrator as primary membergroup, this user will by default see ALL active TinyPortal blocks. The setting 'Admin can see all blocks' in TinyPortal can be used to suppress ALL blocks completely to Administrators.

If you have the requirement to have an administrator user see only the blocks assigned to a certain membergroup, you will have to maintain the member permissions differently:
1. Assign the user to a primary membergroup that is NOT administrator,
2. Assign the user to the administrator as an additional membergroup, and any additional membergroups that you find applicable
3. Then disable the 'admin can see all blocks' setting

With this setup you will achieve what you desired: a user with administrator priviliges that will not see alle blocks, but only those that are visisible to his own membergroup(s).
Running Latest TP on SMF2.1 at: www.fjr-club.nl

tino

Quote from: @rjen on January 28, 2023, 07:30:43 PM
Quote from: tino on January 28, 2023, 07:22:40 PM
What is in the access field in the database for the blocks?
- Test block NO groups: access is blank
- Test block ALL: access is -1,0,3,11,12,13,14,15,16,17,18,19,20,21,22
- Test block UNgrouped: access is 0

Also what group is your admin user in, that's in the members table.
- as I said: administrator (group 1)

Also you've not got the language setting checked? As that'll work correctly now..
- Use language visibility option for blocks is not active



Ok well the first shouldn't show for anyone
Second and third however should show.

Can you add some echo's in the if statements to see which ones are evaluating.

@rjen

Well I am testing with Admin can see all boards set to OFF.

And now I do not see any blocks
Running Latest TP on SMF2.1 at: www.fjr-club.nl

tino

Quote from: @rjen on January 28, 2023, 07:38:33 PM
Well I am testing with Admin can see all boards set to OFF.

And now I do not see any blocks

Can you change it to the below and let me know what numbers you see please.

    public function getBlockPermissions( ) {{{
        global $context, $user_info;

        $blocks = array();
        $user   = $user_info['groups'];
        $activeBlocks = $this->getActiveBlocks();
        foreach($activeBlocks as $block) {
            // Check group access
            if(allowedTo('tp_blocks') && (!empty($context['TPortal']['admin_showblocks']) || !isset($context['TPortal']['admin_showblocks']))) {
                echo '1';
            }
            else if(!isset($block['access'])) {
                echo '2';
                continue;
            }
            else if(isset($block['access']) && (strpos($block['access'],',') === false) && (empty(array_intersect(array($block['access']), $user))) ) {
                echo '3';
                continue;
            }
            else if(empty(array_intersect($user, explode(',', $block['access'])))) {
                echo '4';
                continue;
            }

            // check page settings
            $display = explode(',', $block['display']);
            if( $this->checkDisplayBlock( $display ) !== TRUE ) {
                echo '5';
                continue;
            }

            $blocks[] = $block;
        }

        return $blocks;

    }}}