Advertisement:

New permission to be added with mod

Aloittaja Dannii, joulukuu 05, 2005, 08:37:22 AP

« edellinen - seuraava »

Dannii

I've tried searching, and I've downloaded many of the most popular and complex mods to try and understand it, but I still don't.

For my mod I would like to add a new permission, and as default set it to be allowed for all GMod and ungrouped/regular members.
Can someone who knows how to do this please explain for some of the more stupid coders like myself? :P
"Never imagine yourself not to be otherwise than what it might appear to others that what you were or might have been was not otherwise than what you had been would have appeared to them to be otherwise."

Compuart

Since there are several questions related to adding permissions for modifications, I've written a tutorial in the tips and tricks board: Adding and checking permissions

I hope this answers your questions as well.
Hendrik Jan Visser
Former Lead Developer & Co-founder www.simplemachines.org
Personal Signature:
Realitynet.nl -> ExpeditieRobinson.net / PekingExpress.org / WieIsDeMol.Com

Sheepy

Hehe, I've also created my own recipe for group permissions:

1) Think up an id for your permission.
2) Open ManagePermissions.php, find loadAllPermissions().
3) Add permission to $permissionList, set to true if it makes a different for own/any event, false if you want a single option.
4) Find setPermissionLevel, add permission to one of the default groups if applies.
5) At Modifications.language.php, add 'group_'+group_name if you opened a new permission group
6) Add 'permissionname_'+id as name of permission. (e.g. permissionname_manage_smileys)
7) If multiple options (own/any makes a different), add 'permissionname_'+id+'_own' and 'permissionname_'+id+'_any' as labels.
8) Add 'permissionhelp_'+id as help of permission.  Optional.
9) Add 'cannot_'+id as default error message.

Check for permissions by using allowedTo(permission_id) which returns a boolean value.
Alternatively, use isAllowedTo(permission_id) which will stop and shows error message or login screen if the check fails.

Dannii

Thankyou both. That tutorial is excellent :D
"Never imagine yourself not to be otherwise than what it might appear to others that what you were or might have been was not otherwise than what you had been would have appeared to them to be otherwise."

niko

I thin there should be basic plug-in interface so it would contain functions to add permission, admin area, action, and maybe even menu item... This wouldn't be very hard to implement... (just make theme print from array, add data to array whenever needed)
Websites: Madjoki || (2 links retracted by team, links out of date and taken over.)
Mods: SMF Arcade, Related topics, SMF Project Tools, Post History

WIP Mods: Bittorrent Tracker || SMF Wiki

JayBachatero

Great stuff Compuart.  I wish this would've been created sooner, so I wouldn't have had to go through all the trouble when I was creating "the mod" :P
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

Dannii

I disagree. You'll only be adding new permissions and actions when you're messing around in the code already so it's not much more work. And Some themes come with blank new menu items ;)
"Never imagine yourself not to be otherwise than what it might appear to others that what you were or might have been was not otherwise than what you had been would have appeared to them to be otherwise."

niko

Lainaus käyttäjältä: eldacar - joulukuu 05, 2005, 07:08:29 IP
I disagree. You'll only be adding new permissions and actions when you're messing around in the code already so it's not much more work. And Some themes come with blank new menu items ;)

I understand that but it wouldnt need editing for every version... but i agree with you...

i meant like $contex['menu'] = array(
         'home' => array(name => 'Home', 'href' => $sripturl,),
         'help' => array(name => 'Help', 'href' => $sripturl.'?action=help',),
);

So it would make changes to ALL themes same time :)

foreach($context['menu'] as $id => $name)
{
         /// item with image of $id.gif and alt of $name etc
}
Websites: Madjoki || (2 links retracted by team, links out of date and taken over.)
Mods: SMF Arcade, Related topics, SMF Project Tools, Post History

WIP Mods: Bittorrent Tracker || SMF Wiki

Advertisement: