Advertisement:

Author Topic: AWSP - Add WebSite Permission (Partially Hook!)  (Read 22277 times)

Offline Joker™

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 5,914
  • Gender: Male
    • siddhartha-gupta on GitHub
Re: Permission for Website url in Profile
« Reply #40 on: February 17, 2011, 02:08:45 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

Offline Joker™

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 5,914
  • Gender: Male
    • siddhartha-gupta on GitHub
Re: Permission for Website url in Profile
« Reply #41 on: March 21, 2011, 10:07:20 AM »
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

Offline Matthew K.

  • SMF Super Hero
  • *******
  • Posts: 12,430
  • Gender: Male
    • matthew.kerle on Facebook
    • @matthew_kerle on Twitter
Re: Permission for Website url in Profile
« Reply #42 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.

Offline Joker™

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 5,914
  • Gender: Male
    • siddhartha-gupta on GitHub
Re: Permission for Website url in Profile
« Reply #43 on: March 21, 2011, 12:28:10 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

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 70,492
    • StoryBB/StoryBB on GitHub
Re: Permission for Website url in Profile
« Reply #44 on: March 21, 2011, 12:55:11 PM »
*cough* membersAllowedTo('permission') in Subs-Members.php *cough*
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline Joker™

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 5,914
  • Gender: Male
    • siddhartha-gupta on GitHub
Re: Permission for Website url in Profile
« Reply #45 on: March 22, 2011, 05:57:24 AM »
*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

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 70,492
    • StoryBB/StoryBB on GitHub
Re: Permission for Website url in Profile
« Reply #46 on: March 22, 2011, 05:58:33 AM »
Yeah, I do need some syrup after dispensing vocal sarcasm ;D
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline Joker™

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 5,914
  • Gender: Male
    • siddhartha-gupta on GitHub
Re: Permission for Website url in Profile
« Reply #47 on: March 22, 2011, 06:41:51 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

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 70,492
    • StoryBB/StoryBB on GitHub
Re: Permission for Website url in Profile
« Reply #48 on: March 22, 2011, 09:22:34 AM »
I'm confused. What exactly were you hoping to test for with:

Code: [Select]
(!empty($context['enable_website_url']) || $context['other_members'])when $context['other_members'] is just an array?
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline Joker™

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 5,914
  • Gender: Male
    • siddhartha-gupta on GitHub
Re: Permission for Website url in Profile
« Reply #49 on: March 22, 2011, 09:28:17 AM »
Code: [Select]
$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

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 70,492
    • StoryBB/StoryBB on GitHub
Re: Permission for Website url in Profile
« Reply #50 on: March 22, 2011, 09:33:12 AM »
Quote
Loaded 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.
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline Joker™

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 5,914
  • Gender: Male
    • siddhartha-gupta on GitHub
Re: Permission for Website url in Profile
« Reply #51 on: March 22, 2011, 10:54:47 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.

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

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 70,492
    • StoryBB/StoryBB on GitHub
Re: Permission for Website url in Profile
« Reply #52 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:
Code: [Select]
(!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:
Code: [Select]
(!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.
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline Joker™

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 5,914
  • Gender: Male
    • siddhartha-gupta on GitHub
Re: Permission for Website url in Profile
« Reply #53 on: March 22, 2011, 03:09:28 PM »
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:
Code: [Select]
(!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:
Code: [Select]
(!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

Offline ahrasis

  • SMF Hero
  • ******
  • Posts: 4,921
  • Gender: Male
  • Busy mode is on.
    • ahrasis on GitHub
    • ahrasis on LinkedIn
    • ElkArte Malaysia
Re: Permission for Website url in Profile
« Reply #54 on: October 08, 2014, 05:52:16 AM »
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.

Offline ahrasis

  • SMF Hero
  • ******
  • Posts: 4,921
  • Gender: Male
  • Busy mode is on.
    • ahrasis on GitHub
    • ahrasis on LinkedIn
    • ElkArte Malaysia
Re: AWSP - Add WebSite Permission
« Reply #55 on: December 18, 2014, 01:21:04 AM »
Mod updated.

#Change Logs

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

Offline ahrasis

  • SMF Hero
  • ******
  • Posts: 4,921
  • Gender: Male
  • Busy mode is on.
    • ahrasis on GitHub
    • ahrasis on LinkedIn
    • ElkArte Malaysia
Re: AWSP - Add WebSite Permission
« Reply #56 on: December 19, 2014, 09:25:16 PM »
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.

Offline ahrasis

  • SMF Hero
  • ******
  • Posts: 4,921
  • Gender: Male
  • Busy mode is on.
    • ahrasis on GitHub
    • ahrasis on LinkedIn
    • ElkArte Malaysia
Re: AWSP - Add WebSite Permission (Partially Hook!)
« Reply #57 on: January 02, 2015, 01:29:03 PM »
Updated again.

#Change Logs

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