OnEvent
(redirected from Cookbook.OnGroup)
Questions answered by this recipe
How can I change configurations, create dynamic visitor profiles, and activate recipes in config.php based on page(s), group(s), action(s), cookie(s), session var(s), mark(s), upload var(s)=value(s) and download var(s)=value(s) in a multi event match per call?
Description
Enable recipes and different configurations on based on name(s), group(s), action(s), mark(s),upload var(s)=value(s) and download var(s)=value(s) from config.php in a multi event match per call.
This is an amalgamation of the recipes OnGet, OnPost, OnUpload, OnDownload, OnName, OnGroup, OnAction, OnCookie, OnSession, OnSearch, OnSearchLen, OnNameLen and OnMark, so you don't have to load all of them separately in config.php.
Installation
Just do a include_once in config.php, you have to save the recipe on cookbook folder.
include_once("$FarmD/cookbook/onevent.php");
Usage
On config.php, do as shown below:
if(OnName('Main,WikiSandbox,DocumentationIndex') && OnGroup('Main,PmWiki') && OnCookie('water=blue,sky=blue,sand=beige') && OnSession('authid=Necromonger,secret=ok,') && OnAction('edit,browse') && OnMark('(:div,(:table,(:problematic-markup')) { echo "Condition triggered!"; } More tests you can do: ## OnEvent Recipe tests include_once("cookbook/onevent-20180225.php"); ## fill up some vars $_COOKIE['water'] = 'blue'; $_SESSION['nene'] = 'cuca'; ## 1 - OnMark if(OnMark('(:div, (:table, (:div, (:load')) echo "<pre>-= On Mark =-</pre>"; # OnMark test 2 - edit Main/WikiSandbox to trigger it if(OnAction('edit') && OnGroup('Main') && OnName('WikiSandbox, HomePage') && OnMark('(:load,[[PmWiki/Text Forma')) echo "<pre>-= On Action & Group & Name & Mark | $pagename =-</pre>"; ## 2 - OnName if(OnName('Main,Venus')) echo "<pre>-= On Name =-</pre>"; ## 3 - OnGroup if(OnGroup('Main, PmWiki , Pm ')) echo "<pre>-= On Group =-</pre>"; ## 4 - OnAction if(OnAction("edit,diff")) echo "<pre>-= On Action =-</pre>"; ## 5 - OnCookie test if(OnCookie('water=blue,sapo=amarelo')) echo "<pre>-= On Cookie =-</pre>"; ## 6 - OnSession test if(OnSession('nene=cuca'))echo "<pre>-= On Session =-</pre>"; ## 7 - OnUpload test if(OnUpload('name=test.txt,tmp_name=test.txt,name=boh.txt')) echo "<pre>-= On Upload =-</pre>"; ## 8 - OnDownload test if(OnDownload('test.txt,teste.txt,boh.gif')) file_put_contents('./proof.txt', "<pre>-= On Download =-</pre>"); ## 9 - OnNameLen if(OnNameLen('<3,>10')) echo "<pre>-= On Name Len =-</pre>"; ## 10 - OnSearchLen if(OnSearchLen('>3')) echo "<pre>-= On Search Len =-</pre>"; ## 11 - OnSearch if(OnSearch('wi')) echo "<pre>-= On Search =-</pre>"; ## 12 - OnGet if(OnGet('water=blue,sapo=amarelo')) echo "<pre>-= On Get =-</pre>"; ## 13 - OnPost if(OnPost('q=blue,sapo=amarelo')) echo "<pre>-= On Post=-</pre>";
You can include recipes as well, all based on this simple syntax.
Change log / Release notes
20180220 - first release - onevent-20180220.phpΔ
20180220-2 - second release - onevent-20180220-2.phpΔ
20180221 - shrinked the code a bit, introduced new On* events - onevent-20180221.phpΔ
20180225 - included some new events, now (almost) all of them accept arrays as well - onevent-20180225.phpΔ
20180313 - all events accept arrays and string, changed OnPage() to OnName() - onevent-20180313.phpΔ
20180417 - New events: OnRecipe, OnRecipeVer, OnFile totalizing 16 events now - onevent-20180417.phpΔ
See also
- Administration
- SystemTools
- OnEvent this recipe
Contributors
CarlosAB February 20, 2018, at 05:04 PM
Comments
See discussion at OnEvent-Talk?
User notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.