AWSP - Add WebSite Permission (Partially Hook!)

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

Previous topic - Next topic

Hj Ahmad Rasyid Hj Ismail

Link to Mod

AWSP - Add WebSite Permission

- For SMF 2.0.x
- Partially using hook, minor modifications on one file.

1. Please do your own backup though every installation is backed up automatically.
2. By default, forum members are usually allowed to have their own website link with its title (advertised).
3. These websites links and titles are shown at memberlist, display (post), personal messsage, profile summary etc (are there any more?).
4. Some links and titles are anoying and forum admins / owners dislike this (or they want to charge some payment for them :P).
5. Using this mod added permission, forum admins / owners can decide which groups are allowed to have their website link(s).
6. This mod will automatically stop displaying members' website link with its title, if any, until permission is given.
7. You can test it in all lower SMF 2.0.x version too as IMO it should work just fine. ;)


Thank you for using/testing it.


Yours friendly,
Abu Fahim Ismail.

BSD License. Feel free to modify accordingly but keep original and current authors' link(s) if it is in there somewhere. ;)

Original Author: Joker™
Alternative Support Site: BurkeKnight Enterprises
Github link: ahrasis/AWSP-Add-Web-Site-Permission-Mod

 

#Change Logs

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

@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.

@Version 1.4.1
- Author and license changed.
- Mod upgraded to partially hook.
- Remove previously created $context and simplify the code.

@Version 1.4.0
- Arantor's fix is now correctly applied.

@Version 1.3.0
- Try to fix permission by adding membersAllowedTo('permission') in Subs-Members.php as suggested here.

@Version 1.2.0
- Remove this bug.

@Version 1.1.0
- Add turkish language support.

@Version 1.0.0
- Initial release.


Joker™

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.

I would also suggest adding some sort of template side edits.

What happens if I already have something in that field and then you toggle the permission? I will still have it filled out, it just won't show up when I go to edit my profile. You should have something in the displays that prevents it from even being displayed if the permission is not true.

Oya

Quote from: Joker™ on September 13, 2010, 10:23:58 PM
Quote from: Oya on September 13, 2010, 08:14:27 PM
btw this is part of http://arantormods.com/index.php?action=media;sa=item;in=1
is the code of that mod and my mod here is same ?

no but teh other mod i found does more and with one less eidt

fixing teh display would be ogod tho larbadoodle i havent really looked myself to see how easy tat'd be and arantor is well a bit bad tempered so i aint gonna sk him bout it

iPhoneDestek

#5
translatıon ın turkısh





<file name="$languagedir/ManagePermissions.turkish.php">
<operation>
  <search position="end" />
   <add><![CDATA[
// Permission Mod translation by SirtLanVadisi.net
    $txt['permissionname_add_website'] = 'Web Site Adressi ekleyebilir';
    $txt['permissionhelp_add_website'] = ' Üyenin Websitesi ve Adressi belirli yerlerde Forumda gösterilir.Profil alanında';
// End Permission Mod translation by SirtLanVadisi.net
   ]]></add>
</operation>
</file>
<file name="$languagedir/ManagePermissions.turkish-utf8.php">
<operation>
  <search position="end" />
   <add><![CDATA[
// Permission Mod translation by SirtLanVadisi.net
    $txt['permissionname_add_website'] = 'Web Site Adressi ekleyebilir';
    $txt['permissionhelp_add_website'] = ' Ãœyenin Websitesi ve Adressi belirli yerlerde Forumda gösterilir.Profil alanında';
// End Permission Mod translation by SirtLanVadisi.net
   ]]></add>
</operation>
</file>



$$  Q u a l i t y    I n f o r m a t i o n    L i n e  for iPhone $$



<   M O D  |  T R A N S L A T O R  |  TO  |  TUR  |  A N D   |  G E R   >


Joker™

#6
Quote from: Labradoodle-360 on September 13, 2010, 11:03:26 PM
I would also suggest adding some sort of template side edits.

What happens if I already have something in that field and then you toggle the permission? I will still have it filled out, it just won't show up when I go to edit my profile. You should have something in the displays that prevents it from even being displayed if the permission is not true.
i think it could be done fairly easily with put if condition in load.php . Editing template files is last option for me now , as i'm bit tired off providing support for different theme's . So, it is better to heck source files rather putting code in templates. I'll be updating mod about this very soon ;).

Quote from: Oya on September 14, 2010, 03:43:12 AM
no but teh other mod i found does more and with one less eidt

fixing teh display would be ogod tho larbadoodle i havent really looked myself to see how easy tat'd be and arantor is well a bit bad tempered so i aint gonna sk him bout it
I had a bit of tough time understanding that first :). Now as far as that mod is concern i've not seen the code , will take a look at it later . About the template file i've explained myself above already.

Quote from: ®SirtLan on September 14, 2010, 06:54:06 AM
translatıon ın turkısh


<file name="$languagedir/ManagePermissions.turkish.php">
<operation>
  <search position="end" />
   <add><![CDATA[
// Permission Mod translation by SirtLanVadisi.net
    $txt['permissionname_add_website'] = 'Web Site Adressi ekleyebilir';
    $txt['permissionhelp_add_website'] = ' Üyenin Websitesi ve Adressi belirli yerlerde Forumda gösterilir.Profil alanında';
// End Permission Mod translation by SirtLanVadisi.net
   ]]></add>
</operation>
</file>
<file name="$languagedir/ManagePermissions.turkish-utf8.php">
<operation>
  <search position="end" />
   <add><![CDATA[
// Permission Mod translation by SirtLanVadisi.net
    $txt['permissionname_add_website'] = 'Web Site Adressi ekleyebilir';
    $txt['permissionhelp_add_website'] = ' Ãœyenin Websitesi ve Adressi belirli yerlerde Forumda gösterilir.Profil alanında';
// End Permission Mod translation by SirtLanVadisi.net
   ]]></add>
</operation>
</file>

Thanks a lot bro , will add it shortly :).
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.

Haha do you not think I am aware of that, Joker?

I said template side for a reason. Go ahead, try it Source end and see what you can do :) If you can successfully do it without causing *any* errors, go for it.

Joker™

Quote from: Labradoodle-360 on September 14, 2010, 11:01:34 AM
Haha do you not think I am aware of that, Joker?

I said template side for a reason. Go ahead, try it Source end and see what you can do :) If you can successfully do it without causing *any* errors, go for it.
Mod updated , do try and give the feedback :)
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.


Joker™

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

Oya

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

Matthew K.

I should have noticed that...duh!

Here's your problem.
./Sources/Load.php
Code (Find) Select

'website' => (!empty($context['enable_website_url'])) ? array(
'title' => $profile['website_title'],
'url' => $profile['website_url'],
) : array('title' => '', 'url' =>''),

Code (Should be) Select
        'website' => ($context['enable_website_url']) ? array(
            'title' => $profile['website_title'],
            'url' => $profile['website_url'],
        ) : array('title' => '', 'url' =>''),


You don't need to find out whether $context['enable_website_url'] is empty or not; it's a permission that you put in a context for ease, but you still need to keep it in permission format when checking it.

Oya

no

that checks the *current* user permisson

not the permisson of the user whose profile ur checkin

Matthew K.

But that is in the user array, so it would.

Oya

no it wont

it doesnt load the permissons of every user whose avatar is displayed so it never checks that

u could even try it and see what happens

Matthew K.

allowedTo(''); checks for the user, not if it's checked or not.

Plus, it's in the array, so it should work how I quoted.

Oya

yes... the *current* user

so i have a new user  who doesnt have this permisson allowedto() returns false

because thats false for *him* it means he cant see *ANY* of the urls even mine and im the admin so i definately have permisson which isnt the same as hiding one he already put in when he did have permisson before

Joker™

#18
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
thanks for reporting it , will try to remove the bug shortly :).
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

iPhoneDestek

translation in german





<file name="$languagedir/ManagePermissions.german.php">
<operation>
  <search position="end" />
   <add><![CDATA[
// Permission Mod translation by SirtLanVadisi.net
    $txt['permissionname_add_website'] = 'Kann Webseite Adresse zufügen';
    $txt['permissionhelp_add_website'] = 'Webseite und die URL der Nutzer im Forum und Profil angezeigt.';
// End Permission Mod translation by SirtLanVadisi.net
   ]]></add>
</operation>
</file>
<file name="$languagedir/ManagePermissions.german-utf8.php">
<operation>
  <search position="end" />
   <add><![CDATA[
// Permission Mod translation by SirtLanVadisi.net
    $txt['permissionname_add_website'] = 'Kann Webseite Adresse zufügen';
    $txt['permissionhelp_add_website'] = 'Webseite und die URL der Nutzer im Forum und Profil angezeigt.';
// End Permission Mod translation by SirtLanVadisi.net
   ]]></add>
</operation>
</file>





$$  Q u a l i t y    I n f o r m a t i o n    L i n e  for iPhone $$



<   M O D  |  T R A N S L A T O R  |  TO  |  TUR  |  A N D   |  G E R   >


virtualdave

Has anyone tried using the parser and running this on 1.1.11?
vd

Oya

looks liek it would need to get totally rewritten for 1.1.11

Matthew K.

And I doubt that's going to happen, saying the mod author is trying to get rid of all of his mods now.

Joker™

Quote from: ®SirtLan on September 15, 2010, 07:16:11 AM
translation in german





<file name="$languagedir/ManagePermissions.german.php">
<operation>
  <search position="end" />
   <add><![CDATA[
// Permission Mod translation by SirtLanVadisi.net
    $txt['permissionname_add_website'] = 'Kann Webseite Adresse zufügen';
    $txt['permissionhelp_add_website'] = 'Webseite und die URL der Nutzer im Forum und Profil angezeigt.';
// End Permission Mod translation by SirtLanVadisi.net
   ]]></add>
</operation>
</file>
<file name="$languagedir/ManagePermissions.german-utf8.php">
<operation>
  <search position="end" />
   <add><![CDATA[
// Permission Mod translation by SirtLanVadisi.net
    $txt['permissionname_add_website'] = 'Kann Webseite Adresse zufügen';
    $txt['permissionhelp_add_website'] = 'Webseite und die URL der Nutzer im Forum und Profil angezeigt.';
// End Permission Mod translation by SirtLanVadisi.net
   ]]></add>
</operation>
</file>

Translation added , thanks for providing it.

Quote from: virtualdave on September 15, 2010, 04:57:36 PM
Has anyone tried using the parser and running this on 1.1.11?
vd
Sorry for getting to your request late , right now there were some major issues in my real life was sorting them out. Today i'm bit free if i get time i'll try to make it compatible to SMF 1x series also.

Mod Updated to version 1.2 , removing this bug
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

Oya

doesnt seem to fix it :( not sure what its doing now but dont look liek its right

i got users who should be seeing links but cant and users who shouldnt but can

Joker™

#25
Quote from: Oya on September 19, 2010, 11:53:02 AM
i got users who should be seeing links but cant and users who shouldnt but can
package updated ;)
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

Oya

taht change doesnt fix it

all ur chekcing is whether the user is a regular member or not which doesnt solve the problem

u need to actually check the other users permission

Joker™

Quote from: Oya on September 19, 2010, 02:55:47 PM
taht change doesnt fix it

all ur chekcing is whether the user is a regular member or not which doesnt solve the problem

u need to actually check the other users permission
I tested it for moderators , regular members . And which thing it doesn't fix ? as for me if the user's user group doesn't have permission to add then websites url and title won't load his group , but he can still see members belonging to other groups website's title and url .

Can you put some more light what mistake i need to rectify ? A huge thanks to you for point the bugs ;) . (Working on 1x series version also)
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

Oya

in my forum its done on post count groups so teh newbie group ( less than 50 posts) doesnt have permisson to post links in teh website area or they have to be in a premium vip group

but they should be able to see all those who can right? except i got some users who have say 40 posts and not in the group who can see urls of people who have permission themselves and i got some users who have 50 posts and in the vip group who cant see

cant give a link tho...

Joker™

#29
Quote from: Oya on September 19, 2010, 04:17:35 PM
in my forum its done on post count groups so teh newbie group ( less than 50 posts) doesnt have permisson to post links in teh website area or they have to be in a premium vip group

but they should be able to see all those who can right? except i got some users who have say 40 posts and not in the group who can see urls of people who have permission themselves and i got some users who have 50 posts and in the vip group who cant see

cant give a link tho...
in short you mean post group is creating the problem.

*Edit - the problem comes
If a member has no regular group , only having a post group , then he can see website link of those group members also who don't have permission to show there websites .

Am i correct 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

Oya

yeah thats the problem

ur mod only checks for (non)existence of primary group but it should actually check the permissons properly of each meber if ur going to do that since not everyone will do it my way and not veryone does it teh way u did sorry :(

Joker™

Quote from: Oya on September 20, 2010, 08:53:03 AM
yeah thats the problem

ur mod only checks for (non)existence of primary group but it should actually check the permissons properly of each meber if ur going to do that since not everyone will do it my way and not veryone does it teh way u did sorry :(
and how to accomplish this in your way ?
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

Oya

i didnt say i knew how to do that cuz i dont its much too coplex for me but thats what ud have to do to be sure it was right

probly very slow too

Joker™

Quote from: Oya on September 20, 2010, 09:01:40 AM
i didnt say i knew how to do that cuz i dont its much too coplex for me but thats what ud have to do to be sure it was right

probly very slow too
the mod is really much tricky (at least for me) then it seems . Now as i know the bug i can work in right direction . Let's see what can i come up with.
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

NathanC

Is there anyway you can make this compatible with 1.1.12? This is the exact mod I need, only it's incompatible.  ;D
Apple's got an app for that. SMF's got a mod for that.

}{ellKnight

I second NathanC's request. I'm running on 1.1.12 myself and tried coding it in manually but I wasn't able to do that so a 1.1.12 version or some instructions on how to set it up for that version would be greatly appreciated :)

HK

Joker™

While updating my mods I think this mod requires some special attention as it is very tricky mod. I'll try to rearrange and update this mod in upcoming days.
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.

You should be able to do it fairly easily by using an integration hook, and unset();.

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();.
I'm not familiar with the hooks, just got the wiki link for it. I think have to read a lot that how to use these hooks first :P.
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.

I'll shoot you a couple of helpful Hook links in a PM. And you can ask me any questions if you want.

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: