Fixed Permission Flag Default Value Not Working?

James

Well-known member
On my XF installation, I have set the default value of a permission to Flag, with default value: Allow - however when uninstalling and reinstalling the add-on, the default value is actually Not set (no).
 
But then that doesn't make sense... if I go to create a new usergroup via the URL admin.php?user-groups/add - all the permissions are default to Not set (no)?
 
I can see why this is happening.

I have to admit that I'm tempted to remove those values. With our permission system design, I don't know of a time when you'd want to set them, and they probably don't do what you initially think. Thoughts?

The reason they don't apply to add-on installs is that you will usually want to set permissions programmatically, not across the board. Look at any of the upgrade scripts where we added permissions - they're set based on the presence of another value usually.
 
With our permission system design, I don't know of a time when you'd want to set them, and they probably don't do what you initially think. Thoughts?
My initial thought on the permission flag default values is that it sets the default value for the add-on's permissions. It's useful when add-on authors want to pre-define permission defaults.

My original use for this was a custom add-on I made, I wanted to set the default value to Allow so that the permission was automatically granted and my client didn't have to set the permission for each user group himself.
 
Well my thought on this, is that it would be very usefull.
I design an addon, lets say an image slide show on the front forumpage (its only an example!)
The first permission I add is:
View slideshow.
It would be great (and I thought thats what it was for) that the default permission would be ALLOW for all usergroups.
Admin could (if he wants) set to Deny for guests, but default value should be "allow" in this case.

now of course I could write some code to set the permissions like i want them to be, by changing the db on first run... (like adding an option: "reset permissions" in the addons options, and if this is set, it would set default permissions and change the option "reset permissions" to false)
but it would be sooo much easier to just have the possibility of doing it like by setting the default when designing the permission.
Thats my 2 cents.
Luc

PS: Actually I wanted to set an integer as default (I set 5) for permission: Amount of images in Slideshow. - Imagining at install, all usergroups will have 5 images in the slideshow.. and then, if admin wants, he can change the amount on a per usergroup base.

But even though in the addon xml the default integer is 5, at first install, it will be 0 for All usergroups.... strange....

But if I uninstall the addon, and install it again, AND had set perm to 5 in a usergroup before uninstalling, it will show the 5 in that group.
[EDIT]
Actually found the problem partiallly.. seems that if i uninstall the addon, the reference to the addon is not deleted in table: xf_permission_entry and maybe others.
[/EDIT]
 
I'm going to tag this as "fixed", though it's not exactly. The default value options have been removed. The default value referred to what was selected by default when creating a group and not when an add-on is installed, so forget that preconception. :)

With our secondary group, additive permissions concept, setting a permission to anything but "not set" doesn't really make sense.

Note that you can still set permissions during add-on install -- and indeed you should set them. You just need to run a query to insert the necessary rows. You can see how we do this in the 1.1 beta 1 upgrade script.
 
Top Bottom