News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

AWSP - Add WebSite Permission (Partially Hook!)

Started by Hj Ahmad Rasyid Hj Ismail, September 13, 2010, 08:12:19 PM

Previous topic - Next topic

Joker™

Quote from: Labradoodle-360 on February 17, 2011, 02:07:31 PM
I'll shoot you a couple of helpful Hook links in a PM. And you can ask me any questions if you want.
Sure I would be very glad for your help. Right now just heading towards the bed.
Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

Joker™

Quote from: Labradoodle-360 on February 17, 2011, 01:56:18 PM
You should be able to do it fairly easily by using an integration hook, and unset();.
Lab can you explain a bit how can we use unset() in this mod, as it is complete stuck due to permissions. Most of the times we check the permission of member group user is in, but for this mod we need to check permission of all member groups for the present user.
Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

Matthew K.

That does make it a little bit more complicated...sounds like it'd need to involve a query.

Joker™

Quote from: Labradoodle-360 on March 21, 2011, 12:19:30 PM
That does make it a little bit more complicated...sounds like it'd need to involve a query.
Much more of a query as till now I haven't seen a way in SMF too check the permissions of other member group for a user.
Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

Arantor

*cough* membersAllowedTo('permission') in Subs-Members.php *cough*

Joker™

Quote from: Arantor on March 21, 2011, 12:55:11 PM
*cough* membersAllowedTo('permission') in Subs-Members.php *cough*
Thanks for pointing it out will start to work on it.

BTW, do you require some cough syrup as your throat seems to be in bad shape ;D.
Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

Arantor

Yeah, I do need some syrup after dispensing vocal sarcasm ;D

Joker™

Quote from: Arantor on March 22, 2011, 05:58:33 AM
Yeah, I do need some syrup after dispensing vocal sarcasm ;D
I love vocal sarcasm when it is meant for help ;). Your suggestion seems to be the solution for the bug.

Attached a new package in this post, can someone test and give a feedback as for me it seems to working fine.
Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

Arantor

I'm confused. What exactly were you hoping to test for with:

(!empty($context['enable_website_url']) || $context['other_members'])
when $context['other_members'] is just an array?

Joker™

$context['other_members'] = membersAllowedTo('add_website');

Loaded permission in $context['other_members'], and then used it to verify other members permission in the array. I was hoping if someone checks that whether the mod is working perfectly as it should be, i.e showing websites url of those users who have the permission of adding it.

For me the permission system worked fine and everything seems to be in order as it should be, but before updating the mod I would love to have some feedback this time.
Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

Arantor

QuoteLoaded permission in $context['other_members'], and then used it to verify other members permission in the array

So it's an array of user ids for users that have that permission. You need to do more than just || it, like see if the user in question is in that list with in_array or similar. Right now that test is absolutely useless because all it will do is amount to || true as there must be at least one administrator, who has all permissions including that one, and a non-empty array when recast to boolean (as here) will be true.

Joker™

Quote from: Arantor on March 22, 2011, 09:33:12 AM
So it's an array of user ids for users that have that permission. You need to do more than just || it, like see if the user in question is in that list with in_array or similar. Right now that test is absolutely useless because all it will do is amount to || true as there must be at least one administrator, who has all permissions including that one, and a non-empty array when recast to boolean (as here) will be true.

Got your point, but aren't we taking of the permission that even if a user don't has the permission to add the website urls then also he can see the website urls of those users who have the permission to add urls.

Quote from: Oya on September 14, 2010, 01:42:08 PM
dont work proply

if i set it so i dont have permisson i cant see any website links even from those who do have permisson to post tehm
Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

Arantor

No. Let me break down what's going on.

$context['other_members'] gets a list of all the user ids who can add URLs. Since that includes admins, and there is always an admin, this array will always contain something.

In consequence:
(!empty($context['enable_website_url']) || $context['other_members'])

Will ALWAYS result in true. That means it will always, always display the URL for users, because it will always be true for every single user. Unless you manually remove administrators from the equation.

You might have more luck with:
(!empty($context['enable_website_url']) || in_array($user, $context['other_members']))

As in, the user that you're running loadMemberContext on (which is where you're making that change as far as I can tell) is in the list of those who have that permission.

Joker™

Quote from: Arantor on March 22, 2011, 11:01:57 AM
No. Let me break down what's going on.

$context['other_members'] gets a list of all the user ids who can add URLs. Since that includes admins, and there is always an admin, this array will always contain something.

In consequence:
(!empty($context['enable_website_url']) || $context['other_members'])

Will ALWAYS result in true. That means it will always, always display the URL for users, because it will always be true for every single user. Unless you manually remove administrators from the equation.

You might have more luck with:
(!empty($context['enable_website_url']) || in_array($user, $context['other_members']))

As in, the user that you're running loadMemberContext on (which is where you're making that change as far as I can tell) is in the list of those who have that permission.
That did the trick, thanks a lot for all your help ;), was busy in making theme.
Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

Hj Ahmad Rasyid Hj Ismail

Hiya all.

I am entrusted with this mod now but I haven't have time to look into it deeply yet. I also believe that my brother Joker is a better coder than I am. I will try to do my best in handling this mod.

Thank you for supporting this mod and do feel free to ask for support.

Hj Ahmad Rasyid Hj Ismail

Mod updated.

#Change Logs

@Version 1.4.1
- Author and license changed.
- Mod upgraded to partially hook.

Hj Ahmad Rasyid Hj Ismail

Mod updated again.

#Change Logs

@Version 1.4.2
- Fix permission from being displayed as an option in guest profile permission.
- Properly track and record all previous changes.
- Add github link.

Hj Ahmad Rasyid Hj Ismail

Updated again.

#Change Logs

@Version 1.4.3
- Fix display in both classic and simple view in permission page.

Advertisement: