Simple Machines Community Forum

Customizing SMF => Modifications and Packages => Topic started by: Kays on April 06, 2011, 06:57:06 PM

Title: Custom Permissions
Post by: Kays on April 06, 2011, 06:57:06 PM
Link to Mod (http://custom.simplemachines.org/mods/index.php?mod=2930)

This mod will allow you to create custom permissions. Custom permissions can be used when one is scripting to include or exclude member groups from doing certain actions or viewing certain pages.

Usage:

Permissions are used in conjunction with the allowedTo() function. Which will return either true or false depending on whether the permission is set for that member group or not. As an example, if you create a permission named view_this then it can be used as such:


if (allowedTo('view_this'))
echo 'Yes, you can see this.';
else
echo 'Nope, say goodbye';
Title: Re: Custom Permissions
Post by: Jokerâ„¢ on April 06, 2011, 10:14:58 PM
Great mod :).
Title: Re: Custom Permissions
Post by: mgrmgr on April 07, 2011, 12:26:44 PM
Great mod. It wouldn't be me if I hadn't a request though: I desperately search for something like that for SMF 1.1.13 (our production forum) - would you possibly be able to implement something like this mod also for the V1 version ???
Title: Re: Custom Permissions
Post by: Kays on April 07, 2011, 07:24:11 PM
Thanks Joker. :)

mgrmgr, it will install for both versions.
Title: Re: Custom Permissions
Post by: mgrmgr on April 08, 2011, 04:42:39 AM
Quote from: Kays on April 07, 2011, 07:24:11 PM
...
mgrmgr, it will install for both versions.

Thanks for the answer. Just a tip: mentioning that in the modification description could be a good way to promote this fabulous mod even more :)

Just saw - you already did so :)
Title: Re: Custom Permissions
Post by: Chas Large on April 27, 2011, 04:29:53 PM
Great mod Kays,

Now all I need to do is work out how to add a permission to just one board.
Title: Re: Custom Permissions
Post by: live627 on April 27, 2011, 04:40:47 PM
Create a new permission profile and assign it to a board as a first step
Title: Re: Custom Permissions
Post by: Kays on April 27, 2011, 06:07:43 PM
Thanks. This mod is only for user permissions and not board permissions.

Plus, if you do create a permission, It does nothing unless you code it in.
Title: Re: Custom Permissions
Post by: live627 on April 27, 2011, 06:26:55 PM
If allowedTo() is called on a board, it first attempts to check the related permission in the board.
Title: Re: Custom Permissions
Post by: Kays on April 27, 2011, 06:42:42 PM
Yes, but this mod doesn't add to the board permission list. So the board id would need to be checked as well.
Title: Re: Custom Permissions
Post by: CapadY on June 25, 2011, 07:25:27 AM
Great MOD but I have a little problem.

I've installed it in SMF 2.0 but the permissions are only shown in an own group (custom_permissions) in the classic mode, in simple mode they are not shown in an own group (custom_permissions) but they are added to the basic functionality group.

edit:

Another problem.
When I try to edit the permission description I get an errormessage the permission name can't be the same as an existing permission.
Title: Re: Custom Permissions
Post by: DanCarroll on March 16, 2012, 06:39:23 AM
I  hope this thread isn't dead. Kays: great mod. Very useful.

But I have the same problem as CapadY, the [Edit] function won't allow an edit to be saved. Unless you modify the permission name, which in effect creates a new permission. Also, I would expect an edit function to allow editing the description. The description field value isn't included in the "edit".

Thank you again for a great mod.
Title: Re: Custom Permissions
Post by: Kays on March 16, 2012, 07:31:25 PM
Not dead, just kinda forgotten about. And thanks. :)

Quote from: CapadY on June 25, 2011, 07:25:27 AM
Great MOD but I have a little problem.

I've installed it in SMF 2.0 but the permissions are only shown in an own group (custom_permissions) in the classic mode, in simple mode they are not shown in an own group (custom_permissions) but they are added to the basic functionality group.

This has something to do with how SMF handles permissions added by a mod and from what I've can tell there's no way around it.

Quote from: DanCarroll on March 16, 2012, 06:39:23 AM
Also, I would expect an edit function to allow editing the description. The description field value isn't included in the "edit".

This might be difficult to do since the focus can only be on one field. (I think). Plus if one is to edit a current description I figured it's best to start with an empty field. :)

I did fix the bug when trying to edit a permission and uploaded an updated version.

Title: Re: Custom Permissions
Post by: bigjoe11a on October 29, 2012, 02:53:32 PM
Hi! again Kays, I wanted to let you know that I just installed your custom permissions mod on my test pc that I have SMF 2.0.2 installed. And I been getting some errors from your mod. and one of the errors I can't remove from the logs. It says.

http://www.toppersbbs.info/smf/index.php?action=admin;area=logs;sa=errorlog;desc=
8: Undefined index: custom_permissions
File: C:/www/vhosts/_static/toppers/smf/Sources/Admin.php
Line: 327

So far this is the only error I'm getting and the one I can't remove

Title: Re: Custom Permissions
Post by: Kays on October 29, 2012, 08:03:58 PM
Thanks for that, but I can't reproduce it. And I can't see why it's happening. ???

The problem appears to be a missing $txt string.


'custom' => array($txt['custom_permissions'], 'admin_forum'),


So check Modifications.english.php to see if it is there. But it should be as the other $txt strings added appear to be there
Title: Re: Custom Permissions
Post by: bigjoe11a on October 29, 2012, 09:00:58 PM
Well I check the installer for your mod, and I guess you do have some thing wrong. That part to show me goes into the Admin.php file. Below is from your installer.


<id>Kays:CustomPermissions</id> <version>1.1.0</version> -<file name="$sourcedir/Admin.php"> -<operation> -<search position="before">
<![CDATA['profiles' => array($txt['permissions_profiles'], 'manage_permissions'), 'postmod' => array($txt['permissions_post_moderation'], 'manage_permissions', 'enabled' => $modSettings['postmod_active']),]]>
</search> -<add>
<![CDATA[ 'custom' => array($txt['custom_permissions'], 'admin_forum'),]]>
</add> </operation> </file>

Title: Re: Custom Permissions
Post by: bigjoe11a on October 29, 2012, 09:30:10 PM
Could the reason why I'm getting this error is because I'm using it my mod. ?
Title: Re: Custom Permissions
Post by: Kays on October 30, 2012, 06:05:58 PM
It could have something to do with your mod. ???

What to do is to add the following to your Admin language file.


$txt['custom_permissions'] = 'Custom Permissions';
Title: Re: Custom Permissions
Post by: bigjoe11a on October 31, 2012, 08:45:08 PM
Ok, well This got rid of the error. So I don't know. Thanks
Title: Re: Custom Permissions
Post by: Eclipse16V on April 19, 2013, 01:05:53 AM
Hello,
first of all thanks for the great mod
I now have but one question:
In my SMF version 2.0.4 I've created a few new profile fields manually. These work quite well. Now I wanted to with this mod make it so that only certain groups can fill out these fields and can see.
How do I connect this mod for example in the Profiles-Modify.php with this one:
function tmMap($memID)
{
global $context, $user_profile, $user_info, $txt, $modSettings;

loadThemeOptions($memID);
if (allowedTo(array('profile_extra_own', 'profile_extra_any')))
loadCustomFields($memID, 'tmmap');

$context['sub_template'] = 'edit_options';
$context['page_desc'] = $txt['tmMap_info'];

setupProfileContext(
array(
'pf_design_der_map', ... 'pf_css_a_link_color',
)
);
}


It just does not work as I would like.
Title: Re: Custom Permissions
Post by: Kays on April 19, 2013, 08:38:22 AM
Hi, if you only want people with that permission to enter that page. Add the allowedTo() check for that permission before the call to that function.

Or after the globals are defined:


if (!allowedTo('seeThis'))
   return;
Title: Re: Custom Permissions
Post by: Kite on May 30, 2013, 04:25:55 AM
Thanks for this mod, It is really helpful !

Do you think it can be possible to set specific subgroup ?

I want to create permissions in a new group called "website" and i don't want them to stay under the "Custom Permissions" group.

Thanks !
Title: Re: Custom Permissions
Post by: Kays on June 01, 2013, 04:06:48 PM
Hi, permissions apply to which ever group they are assigned to. If you have a problem with inherent permissions, then use deny.
Title: Re: Custom Permissions
Post by: Branko. on August 07, 2013, 08:28:41 AM
Hi Kays!
This mod is really useful for specific permissions. I want to create permission(s) for Profile view. This permission includes track IP/user and all subactions. In default installation, I can grant IP viewing option by Moderate forum members permission but it comes with extra rights. I want only IP viewing option with subactions.

Thanks in advance
Title: Re: Custom Permissions
Post by: Kays on August 08, 2013, 09:53:33 AM
I think what you might need to do is to look for everywhere that the original permission is used and then change it in the appropriate spots to the new permission.
Title: Re: Custom Permissions
Post by: Chas Large on October 26, 2018, 02:51:57 AM
Hi Kays,

Sorry to wake an old topic but I'd like to use this mod on 2.0.15.

It installs but the CUSTOM PERMISSIONS does not show, so I cannot add the permission I want, which is to remove the ability to send emails to any member that allows it for a specific post count group.

The standard permissions allows an ADMIN to turn off PM's but not emails. So a group may have restricted PM access but unrestricted email system access. An alternative would be to restrict the number of emails a certain group can send.

I assumed I could do that with this mod and would be obliged if you could kindly,

a. update the mod to work with 2.0.15 and above.

b. advise how to use the mod to achieve my goal.

Very much obliged for any help you - or indeed anyone else - can offer.

Thanks

Chas