A good idea perhaps, though I'm not sure it would be faster. We might get more mileage out of caching the function output, but generally I think this function is fast enough. I will think about it and explore the implications. It would likely break LOT's of existing plugins.
Cheers Dan On Sat, Sep 26, 2009 at 5:01 AM, DrunkenMonk <[email protected]> wrote: > > I still strongly suggest storing $BOLTmemberships and $BOLTadmin as > arrays, by $BOLTmemberships = explode(',', > $BOLTmemberships_string_or_whatever_they_are_generated_from); when > initializing. > > in_array($id, $BOLTmemberships) is faster than strpos, and > constructing new string from $BOLTmemberships each time it's checked > in order to have legal strpos? Thats ugly code. > > On Sep 26, 12:59 am, The Editor <[email protected]> wrote: >> I just added a core BOLTingroup function which works quite nicely. >> Hopefully anyway... >> >> function BOLTingroup($group, $id='') { >> global $BOLTid, $pagesPath, $BOLTmemberships, $BOLTadmin; >> if ($id == '') $id = $BOLTid; >> if (strpos(" ,$BOLTadmin,", ",$id,") && $BOLTadmin != '') return >> true; >> $BOLTgroupPages = BOLTconfig('BOLTgroupPages', 'group'); >> $group = BOLTlowercase($group); >> if ($id == $BOLTid) return (strpos(",$BOLTmemberships,", ",$group,") >> !== false); >> return (strpos("\n".BOLTloadpage("$BOLTgroupPages.$group")."\n", >> "\n$id\n") !== false); >> } >> >> This allows me to simplify the admin, editor, and ingroup function, >> and extend all their functionalities, as you can now do: >> >> [if ingroup chessclub id=caveman] >> >> More important perhaps, it makes plugin development much easier. I >> still have to go through the functions but there are likely a good >> number of lines that can be simplified to: >> >> if (! BOLTingroup('admin')) ... >> >> Thanks DM for the great idea. Will be in the next release... I won't >> be able to get it out till Sunday, I'm afraid. But as you can see from >> the roadmap, it already has a good number of fixes in it. If it all >> works without a glitch, with this many changes... I'll be astonished! >> >> Cheers, >> Dan > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "BoltWire" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/boltwire?hl=en -~----------~----~----~----~------~----~------~--~---
