Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Users disabling certain extensions for themselves?
I was wondering if it was possible to allow users the ability to turn on and off certain extensions on their own, or if each extensions needed to be coded to create a user preference. For example, some of my members really enjoy the yellow fade and the quick tags, but others dont like them at all, and I'd like to give people an option. At the moment I only see how I can enable and disable them globally. Is there something I'm missing?
0
This discussion has been closed.
Comments
But it's really easy to change an extension and have it switched on/off by a user! Let's take a look at the YellowFade add-on:
<?php /* Extension Name: YellowFade Effect Extension Url: http://michaelraichelson.com/hacks/vanilla/ Description: Adds the YellowFade effect on some stuff. Version: 0.1 Author: Michael Raichelson Author Url: http://michaelraichelson.com/ */ if (in_array($Context->SelfUrl, array("index.php", "categories.php", ... bla bla.. { $Head->AddScript('extensions/YellowFade/functions.js'); } ?>
Now let's make a user preference, so we add the following:
if ($Context->SelfUrl == 'account.php') { $Context->AddToDelegate('PreferencesForm', 'PreRender', 'YellowFade_PreferencesForm'); function YellowFade_PreferencesForm(&$PreferencesForm) { $PreferencesForm->AddPreference('Other', 'EnableYellowFade', 'showYellowFade'); } }
The second parameter for adding a preference is our language definition, so we should add it to our dictionary:
$Context->Dictionary['EnableYellowFade'] = 'Show YellowFade';
And now we need to check for the preference if we need to add the javascript to the head object:
if( $Context->Session->User->Preference('showYellowFade')) { $Head->AddScript('extensions/YellowFade/functions.js'); }
We're done!
If you got a min, I got this working and the pref is there, but toggling the button makes no difference. YellowFade is on regardless. Hmmm?
Here's the full code (maybe you made a typo? It works for me):
<?php /* Extension Name: YellowFade Effect Extension Url: http://michaelraichelson.com/hacks/vanilla/ Description: Adds the YellowFade effect on some stuff. Version: 0.1 Author: Michael Raichelson Author Url: http://michaelraichelson.com/ */ $Context->Dictionary['EnableYellowFade'] = 'Show YellowFade'; if (in_array($Context->SelfUrl, array("index.php", "categories.php", "comments.php", "search.php", "post.php", "account.php", "settings.php"))) { if( $Context->Session->User->Preference('showYellowFade')) { $Head->AddScript('extensions/YellowFade/functions.js'); } } // Add preference if ($Context->SelfUrl == 'account.php') { $Context->AddToDelegate('PreferencesForm', 'PreRender', 'YellowFade_PreferencesForm'); function YellowFade_PreferencesForm(&$PreferencesForm) { $PreferencesForm->AddPreference('Other', 'EnableYellowFade', 'showYellowFade'); } } ?>
sorry for interupting here
edit//
I got it working now! I didnt know I had to activate it within the forum preferences tab. Thanks for posting that here!
<?php /* Extension Name: Quicktags Extension Url: http://lussumo.com/addons/ Description: Inserts an HTML formatting bar above the input field, using Alex King's Quicktags. Requires SirNot's Html Formatter extension. See http://www.tamba2.org.uk/wordpress/quicktags/ for guidance on adding custom Quicktags. Version: 0.6 Author: James Greig Author Url: http://www.3stripe.net */ $Configuration["QUICKTAGS_PATH"] = 'extensions/Quicktags/'; $Context->Dictionary['UseQuicktags'] = 'Show the Quicktags formatting bar above the post area'; $Context->Dictionary['MenuOptions'] = 'Nanananananannananana'; if(!in_array($Context->SelfUrl, array("post.php", "comments.php"))) return; if (in_array($Context->SelfUrl, array("post.php", "comments.php"))) { class QuicktagsBar { function QuicktagsBar_Create() { echo ' <div id="quicktags"> <script type="text/javascript">edToolbar();</script> </div> '; } function QuicktagsBarApres_Create() { echo ' <script type="text/javascript">var edCanvas = document.getElementById(\'CommentBox\');</script> '; } } } function AddQuicktagstoCommentForm(&$DiscussionForm) { $QuicktagsBar = new QuicktagsBar($DiscussionForm->Context); $QuicktagsBar-> QuicktagsBar_Create(); } function AddQuicktagsJavascriptafterCommentForm(&$DiscussionForm) { $QuicktagsBar = new QuicktagsBar($DiscussionForm->Context); $QuicktagsBar-> QuicktagsBarApres_Create(); } if( $Context->Session->UserID > 0) { if ($Context->Session->User->Preference('UseQuicktags')) { $Head->AddScript($Context->Configuration["BASE_URL"].$Context->Configuration["QUICKTAGS_PATH"].'quicktags.js'); $GLOBALS['Head']->AddStyleSheet($Context->Configuration["QUICKTAGS_PATH"].'quicktags.css'); $Context->AddToDelegate("DiscussionForm", "CommentForm_PreCommentsInputRender", 'AddQuicktagstoCommentForm'); $Context->AddToDelegate("DiscussionForm", "DiscussionForm_PreCommentRender",'AddQuicktagstoCommentForm'); $Context->AddToDelegate("DiscussionForm", "CommentForm_PreButtonsRender", 'AddQuicktagsJavascriptafterCommentForm'); $Context->AddToDelegate("DiscussionForm", "DiscussionForm_PreButtonsRender",'AddQuicktagsJavascriptafterCommentForm'); } } // Add the Quicktags setting to the forum preferences form if ($Context->SelfUrl == 'account.php' && $Context->Session->UserID > 0) { $PostBackAction = ForceIncomingString('PostBackAction', ''); if ($PostBackAction == 'Functionality') { function PreferencesForm_AddQuicktagsPreference(&$PreferencesForm) { $PreferencesForm->AddPreference('MenuOptions', 'UseQuicktags', 'UseQuicktags', 1); } $Context->AddToDelegate('PreferencesForm', 'Constructor', 'PreferencesForm_AddQuicktagsPreference'); } } ?>