TinyPortal

Development => Support => Topic started by: NightOwl on March 24, 2005, 09:41:49 AM

Title: Blocks permission
Post by: NightOwl on March 24, 2005, 09:41:49 AM
I found premission isn't working right with what it's expected to be.

The reason that cause the flaw is (post-base) included and Unregistered Guests, Ungrouped Members are not included in the permission choice.

post-base rank are for everyone(I can't delete it, so every group will be related to it.), so if I block post-base, every group is unable to see the block no matter the group is given permission. So the double grouping(post-base=denied, group=allow) doesn't over-ride the post-base denying permission.

Then here comes the logical problem. There is no way I can deny viewing on Guest. Only if both Unregistered Guests and Ungrouped Members can be included in the permission range.

There is always double groupings in SMF structure. The Newbie(post-base) and Group that the user assigned. So if post-base are not blockable(if blocked = no group able to access). I think we need to have group permission over-ride post-base.

BTW, the test-box of html/php always give this:
Notice: Undefined index: t in E:\linktoSMF\TPpreview.php on line 16
Title: Re: Blocks permission
Post by: NightOwl on March 24, 2005, 01:49:45 PM
Humm... all blocks here is gone now. Only 5 is available for me. That is:
content
user
stats
online
search
Title: Re: Blocks permission
Post by: Bjørn on March 24, 2005, 02:04:09 PM
Back again. It was just a test of a alternative bloczone theme. But it did not work quite right.  ???

- after thinking some on the permission system, it does cater for guests and ungrouped members really.To include ungrouped members, just tick the first post-group, all members will usually be in that, if you have the postcount low. if not, maybe you should create one entry post-based group.

What I mean:

- members only ( all members, ungrouped too) -->
   ON: newbie
    OFF: all else

- all guests + members -->
    OFF: everything(default)

- some membergroup ( either one of the postbased, then also showing ungrouped members the block if they have a cetain amount of posts, or one or more selected membergroup) -->
    ON: your preferred groups
    OFF: all else
Title: Re: Blocks permission
Post by: Bjørn on March 24, 2005, 02:07:43 PM
I forgot..if you DO set SOME permission, guests will not be in regardless.Set all to off, and guests are allowed.

Kind of opposite logic, but it makes it easier to check every block fast.

So, if all permissions are OFF, the block is shown to all. As soon as you set a tick for someone, guests see nothing.
Title: Re: Blocks permission
Post by: NightOwl on March 24, 2005, 03:21:06 PM
Yes, I've use that before. But now, I have to switch the board to manual accept application so I can assign them to the proper group. Because ungroup members are not included in the permission setting. I want to made a shortcut blocks for moderators and admins to access faster to the needed page. But I can't block ungrouped members from seeing it if I keep using email activation.

The point is, Guest can be blocked from viewing, but not un-grouped members. If they need to be blocked, that is only blocking post-base group can do the job. When post-base group are blocked, that's means everyone in that group are blocked as well(so do moderators). That's why I comment this as a logical problem. You can try this by disable all groups but giving Newbie(post-base) access. This give a result of no groups are blocked, even you didn't tick on any groups.

Scenario 1
Block guest by giving permission to all groups except Newbie(post-base)
Result: This blocks everyone except admins. (because each group member also is Newbie).

Scenario 2
Block certian group but let Newbie(post-base) have access.
Result: This let every one have access, include groups i want to blocked. (Same here, the blocked group are given access by the Newbie).

This problem is cause by the double grouping of SMF default, the assigned group (non-postbase) and the post-based which are counted together. But post-base override group permission. While forum permission works the other way, group(non-postbase) will override post-base.

BTW, Guest are blocked by disable "Allow guests to browse the forum". I've tried this cause now my settings of blocks are all permitted(no tick).
Title: Re: Blocks permission
Post by: Bjørn on March 24, 2005, 06:14:39 PM
Hm, I see the problem now. Its pretty obvious really.
Title: Re: Blocks permission
Post by: NightOwl on March 26, 2005, 05:22:23 PM
Bloc, any progress with this fixed?

Would it simply just reverse the permission code executing sequence of postbase and groups so the group permission can override the postbase?
Title: Re: Blocks permission
Post by: Bjørn on March 26, 2005, 05:42:26 PM
No, its a bit more complicated than that. the way it is stored now, is that an array contains all groups the user is in, then all blocks just rapidly check if the current blocks permissions(which groups are allowed) is inbetween users groups. if not, don't show it.

It does not distinguish between postbased and real groups at this stage. Thats is only done in tpadmin, to see which is which. So my initial view of it was to either 1) use JUST add. groups, to be sure the postbased isn't "slipping some through" 2) use ONLY postbased to be just a regular member/non-member/posts type of permission.

As pointed out , if you need accces for ungrouped members, just use the postbased(all of them, or at least the ones with high enough postcount), an NO add.groups. And to allow guests, just untick everything.

its when there are mixes between these trouble arise, because as soon you use both groups, the add.groups no longer work.Because, as also pointed out,  all members aslo have some sort of post-based group.

So I am looking at either making add.groups ticked out when using post-based and viceversa, or simply having two lists. i am not sure yet.
Title: Re: Blocks permission
Post by: NightOwl on March 26, 2005, 10:32:19 PM
Well, I just wonder how the forum permission can be done with blocking post-base but letting add.group access on the same user. IMO, post-base group usage is far more casual in security needs than custom groups. I think most admins don'tl want a post-base group user access things that they shouldn't with just increasing post counts. And for smf structural design, there should be an option to choose using post-base or not. Far better than what is now post-base is hardcoded without options to disable. So I have an un-used post-base group which makes everyone a double grouping if I need to work with a custom grouping system.

It would be nice if TP can have an option to choose which group-base to use for permission checking. So the Newbie(post-base) won't affect the whole custom groups. We can't take off  the Newbie(post-base) status from a new join user or from a board owner, so the only way is to ignore it.
Title: Re: Blocks permission
Post by: Bjørn on March 26, 2005, 11:11:50 PM
Yes.. I am leaning towards this as well. Its the add.membergroups thats important in this, not so the post-based.
Title: Re: Blocks permission
Post by: NightOwl on March 30, 2005, 04:48:45 PM
Permission confusion fixed on 0.6 beta

With post-base out of permission range.
Title: Re: Blocks permission
Post by: NightOwl on March 31, 2005, 11:51:15 PM
Humm.. weird things happens.

Seems the block permission only works with one selected group. More groups selected result in opposite, that is every given permission groups are blocked.

case 1, with one group selected, the group with see the block.
case 2, with two group selected, both group can't see the block.
Title: Re: Blocks permission
Post by: Bjørn on April 01, 2005, 01:15:47 AM
I will check it.
Title: Re: Blocks permission
Post by: Bjørn on April 01, 2005, 06:20:51 PM
Yes, it was not checking right..I ahve solved and it will go into the next release..but if you need the change, open up TPortal.php and find this:
        // get the blocks
        $blocktype=array('no','userbox','newsbox','statsbox','searchbox','html','onlinebox','themebox','shoutbox','catmenu','phpbox','scriptbox','recentbox');

        $request = db_query("SELECT * FROM tportal_blocks WHERE off=0 ORDER BY bar,pos,id ASC", __FILE__, __LINE__);
        $lcount=0; $rcount=0;
        if (mysql_num_rows($request) > 0)
        {
          $access=array();
          while($row = mysql_fetch_assoc($request)){
              $access=explode(',',$row['access']);
              foreach($access as $acc => $val){
                    $show=true;
                    if($val!='0' && $val!=''){
                       $show=false;
                       if(in_array($val,$context['TPortal']['membergroups']))
                          $show=true;
                    }
                    if($val=='-1' && $context['user']['is_guest'])
                       $show=false;
              }
              // admin sees all
              if($context['user']['is_admin'])
                 $show=true;

              if($show){
               if($row['bar']=='1'){
                       $context['TPortal']['leftblock']['blocks'][$lcount]=array('frame' => $row['frame'], 'title' => $row['title'], 'type' => $blocktype[$row['type']], 'body' => $row['body']);
                       $lcount++;
               }
               elseif($row['bar']=='2'){
                       $context['TPortal']['rightblock']['blocks'][$rcount]=array('frame' => $row['frame'], 'title' => $row['title'], 'type' => $blocktype[$row['type']], 'body' => $row['body']);
                       $rcount++;
               }
             }
          }
          mysql_free_result($request);
        }
        // is there any blocks at all shown?


and replace with:
        // get the blocks
        $blocktype=array('no','userbox','newsbox','statsbox','searchbox','html','onlinebox','themebox','shoutbox','catmenu','phpbox','scriptbox','recentbox');

        $request = db_query("SELECT * FROM tportal_blocks WHERE off=0 ORDER BY bar,pos,id ASC", __FILE__, __LINE__);
        $lcount=0; $rcount=0;
        if (mysql_num_rows($request) > 0)
        {
          $access=array();
          while($row = mysql_fetch_assoc($request)){
              $access=explode(',',$row['access']);
              $show=false;
              if($row['access']=='' || $row['access']=='0'){
                  $show=true;
              }
              elseif($row['access']=='-1' || $row['access']=='0,-1' || $row['access']=='-1,0'){
                  if($context['user']['is_logged'])
                     $show=true;
              }
              elseif($row['access']!='' && $row['access']!='0' && $row['access']!='-1'){
                   $acc=explode(',',$row['access']);
                   foreach($acc as $grp => $val){
                       if(in_array($val,$context['TPortal']['membergroups']))
                           $show=true;
                   }
             }
              // admin sees all
              if($context['user']['is_admin'])
                 $show=true;

              if($show){
               if($row['bar']=='1'){
                       $context['TPortal']['leftblock']['blocks'][$lcount]=array('frame' => $row['frame'], 'title' => $row['title'], 'type' => $blocktype[$row['type']], 'body' => $row['body']);
                       $lcount++;
               }
               elseif($row['bar']=='2'){
                       $context['TPortal']['rightblock']['blocks'][$rcount]=array('frame' => $row['frame'], 'title' => $row['title'], 'type' => $blocktype[$row['type']], 'body' => $row['body']);
                       $rcount++;
               }
             }
          }
          mysql_free_result($request);
        }
        // is there any blocks at all shown?
Title: Re: Blocks permission
Post by: NightOwl on April 02, 2005, 09:39:29 AM
Thanks Bloc :)
Title: Re: Blocks permission
Post by: NightOwl on April 02, 2005, 08:07:34 PM
Seems that really fix the thing finally.
Title: Re: Blocks permission
Post by: Bjørn on April 02, 2005, 10:39:16 PM
Good to hear.. :)
Title: Re: Blocks permission
Post by: NightOwl on April 15, 2005, 03:04:18 PM
Bloc, bad news again

Seems ungroup members are not following the permission setting.

They can access everything even it is blocked.