News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Running a script in the background

Started by Alex4108, February 10, 2012, 05:01:35 PM

Previous topic - Next topic

Alex4108

addMembersToGroup
This function has a parameter, titled bool $permissionCheckDone
The $permissionCheckDone variable is in a sense, an "override".  It overrides the permissions system. 

If it's true, there is no permission check done on the user (practical example: The user isn't logged in, because it's the Cron Daemon)
If it's false, a permission check is done against the user (practical example: An admin)




I have a script using both the addMembersToGroup function and removeMembersFromGroups function.

On addMembersToGroup, I call it as such:


addMembersToGroup($id_member, 24, 'force_primary', true);

Notice the true to override a permissions check.




I need to apply the same idea to the usage of removeMembersFromGroups, to allow my cron script to remove all a user's groups.

I notice that there is a "Requires the manage_membergroups permission" note at the bottom. Is there a way to define a permission temporarily?

Oldiesmann

If it's just running in the background, why is a permission check needed?

The best option would be to add a custom permission and have your script check for that permission before calling the function.
Michael Eshom
Christian Metal Fans

Alex4108

#2
Quote from: Oldiesmann on February 11, 2012, 02:34:12 PM
If it's just running in the background, why is a permission check needed?

The best option would be to add a custom permission and have your script check for that permission before calling the function.

A permission check isn't needed.  The remove function doesn't have an override variable.  The add function does (and I override)
How would I go about adding custom permissions?


Alex4108


Alex4108

And another....? Please?

I don't want to have to run this straight through SQL.

Advertisement: