Staff Access to two Department bug?

Started by Ice_Drake1, August 10, 2012, 08:48:43 PM

Previous topic - Next topic

Ice_Drake1

#15
Could it be coming from PortaMx 1.45? I did encounter a bug with it back then preventing other users from accessing the front page, so I fixed the code on one of their files to fix it.

From this in PortaMX.php:
if(empty($useFront) || !empty($context['pmx']['show_frontpanel']) || !empty($context['pmx']['show_pagespanel']) || !empty($_GET['pmxerror']))

to:
if(!empty($useFront) || !empty($context['pmx']['show_frontpanel']) || !empty($context['pmx']['show_pagespanel']) || !empty($_GET['pmxerror']))

Also, I manually installed SMFPets 0.3 since it doesn't support newer than SMF 1.1.

Spoogs

Ven can weigh in on that but I doubt that's the problem. I disabled the portal all together http://site/index.php?pmxportal=off and it still occurred.

If I however made Game Designer staff in both departments both became visible. I'll try another local setup later on and see if I can duplicate it this time.

Spoogs

#17
Ok this is an actual bug, only happens when member is User in 1 dept and Staff in another.
I was certain this was fixed in issue 577
QuoteThe checks for members being allowed to do a permission does not cover for departments, while all the user-side checks do.

Needs to have the option of being a per-dept check as well as any-dept, much as shd_allowed_to offers.

Basically what I'm seeing now is that if user is staff in at least 1 dept, they will only see the depts in which they are staff.

If they are staff in both depts they will see the both.
if they are user in both depts they will see the both.

venguard223

Issue 577 is mostly unrelated.

Hmm, if this is an actual bug, I still can't reproduce it.

Spoogs

I took a fresh install, created a 2nd user and made it a GMod
Created Helpdesk user and helpdesk staff
Created Workdesk as a dept
Made GMod a user in HelpDesk abut staff in WorkDesk and booom there we go... GMod can only see Workdesk where he is staff.

For fun I created TestDesk and played with many variations and each time that GMod had staff and user roles, only the dept with tha staff roll was visible.

I wasnt able to repro it before but it's constant now

venguard223

Yay another permissions bug relating to departments, though I honestly thought they'd all been nailed after a period of about three weeks finding one bug after another >_<

If I get time I'll look into it, but no promises. If I do find something I'll document the patch on Github (not that I like Github, mind)

Spoogs

I'm shocked too, I remember us getting real brutal with the testing once you deployed departments. I don't like git much either, never wrapped my head around that thing.

Ice_Drake1

I guess it is good news that you guys found the source of the problem...any pointer on where I can look for this bug? Or do I just wait?

Spoogs

Well we havent found the source just yet but rather able to reproduce the bug. As Ven said, if'when he gets the chance he may look into it.

Thanks for the report but just like you for right now we all wait... as you may have noticed development has been rather nil for a bit.

Ice_Drake1

Yeah, that is why I request a pointer on direction and I might be able to figure out how to fix it on my own as I have fixed issues for other mods already.

venguard223

You're still pretty much waiting for me in any case because I'm the one who wrote *all* of that code and even I don't remember a lot of it in places seeing how we're over a year on.

I've also had some pretty murky personal stuff today so I honestly have no idea about looking at the code any time soon, sorry :(

Ice_Drake1

sigh...I gave a try at the codes, but to no avail. :(

The codes are far too complicated for me. There are way too much arrays and variables to keep track of. I gave up! It would take too much time just to figure where the source of the problem is when I have other bugs to fry for my game.

Please let me know whenever you have some ideas or time of where the problem might be. Thanks!

venguard223

QuoteThere are way too much arrays and variables to keep track of.

Yup, and what's in SD is only a fraction of the arrays and variables in SMF in total, and I had to keep pretty much all of them all in my mind at once. I'm sorry, I've had so much personal stuff going on lately that I haven't had time to debug something I wrote a year ago.

Ice_Drake1

#28
I found the source of the problem after finally figuring how to debug for it, but I don't know how to fix it. Any advice?

The problem is in this query found in Subs-SimpleDeskPermissions.php:

// 1. Get all the roles that conceivably apply to this user.
$query = $smcFunc['db_query']('', '
SELECT hdrg.id_role, hdr.template
FROM {db_prefix}helpdesk_role_groups AS hdrg
INNER JOIN {db_prefix}helpdesk_roles AS hdr ON (hdrg.id_role = hdr.id_role)
WHERE hdrg.id_group IN ({array_int:groups})',
array(
'groups' => $user_info['groups'],
)
);

$roles = array();


I did an array dump for $roles:

Array
(
    [0] => Array
        (
            [id_role] => 1
            [template] => 1
        )

    [1] => Array
        (
            [id_role] => 2
            [template] => 2
        )
)


This array is missing the array below:

    [2] => Array
        (
            [id_role] => 5
            [template] => 2
        )


The query is wrong because of the wrong merges.


The array $user_info['groups'] is consists of:

Array
(
    [0] => 24
    [1] => 4
    [2] => 17
)


The contents of helpdesk_role_groups are as follows:

 
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
id_roleid_group
111
112
113
114
116
118
124
214
217
32
315
413
414
511
512
524

The contents of helpdesk_roles are as follows:

 
   
   
   
   
   
   
id_roletemplaterole_name
11Helpdesk Users
22Helpdesk Staff
34Helpdesk Managers
41Workdesk Users
52Workdesk Staff