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.
Meta Extension (does it make sense?)
I finally got 0.9.3 running an now created the Meta Extension I was thinking about disucssing the User Export extension. The Meta Extension is available in the Add Ons Directroy. It handles Extension Settings which are written to an extra table in the database and makes it easy to have Install and Uninstall Routines when an extension is enabled or disabled.
1) I like the idea of having (Un)Installation routines when extensions are dis/enabled. With the Meta Extension you just need to place a function called YourExtensionDirectoryName_Install() in your extension file to make it possible. If your extension requires a new db table or extra field you may check if table allready exists or create it there.
2) I think it's best to have one place to store all settings from different extensions cause it keeps administration and maintenance simple. Therefore the Meta Extension creates an simple Property-Value table and provides Get, Set and Remove functions.
3) Thinking forward a unique directory (with subfolders) for files would be great, too. Admins only have to set write permissions once.
I'm intresting in your opinon, if such an extensions makes life easier or even more complicated.
1) I like the idea of having (Un)Installation routines when extensions are dis/enabled. With the Meta Extension you just need to place a function called YourExtensionDirectoryName_Install() in your extension file to make it possible. If your extension requires a new db table or extra field you may check if table allready exists or create it there.
2) I think it's best to have one place to store all settings from different extensions cause it keeps administration and maintenance simple. Therefore the Meta Extension creates an simple Property-Value table and provides Get, Set and Remove functions.
3) Thinking forward a unique directory (with subfolders) for files would be great, too. Admins only have to set write permissions once.
I'm intresting in your opinon, if such an extensions makes life easier or even more complicated.
0
This discussion has been closed.
Comments
When you install an extension that requires extra database tables or columns, there should be a configuration parameter for that extension that is '0' by default. The extension, even if enabled, will never work unless that setting is changed to '1'. So, the extension file itself would go something like this:
if ($Configuration['MY_EXTENSION_NAME_INSTALLED'] == '0') { // Only attempt to install the extension if you are on the settings tab and there is a related PostBackAction. // You do this because if there are errors installing the extensions extra db structure, you don't want it // to completely kill the site or management thereof. $PostBackAction = ForceIncomingString('PostBackAction', ''); if ($Context->SelfUrl == 'settings.php' && $PostBackAction == 'SetUpMyExtensionName') { // Execute any sql necessary to install the database structure required for the extension. // I'd make sure to check to see that the structure doesn't already exist before brute forcing the changes. // ... // Now set the configuration option to 1 and save it in the conf/settings.php file. } } else { // Standard extension code goes here and the extension is used. }
Finally, I'd either like to allow html in the description and allow the extension description to contain a link to the correct postbackaction, or just explain what the postbackaction should be in the description or readme that accompanies the extension.
Thoughts?
As far as the other part goes, I'm not convinced that the extra tables/columns should be removed when an extension is disabled. They don't really hurt anything, and could contain useful data that I want to keep.
Is it eays to set the configuration option automatically or has it to be done by hand?
I like the idea of an installation routine, cause I want extensions to work for administrators without doing changes in files or database directly.
What about including the extensions default.php checking if an installation function exists and then calling the function after the extension has been enabled? Mhh: On errors and warnings this would cause some problems with the Ajax switch option..
@Bergamont: Yes, it's eays to check if a table exists or not. But its one more database operation each time the extension is loaded. Querying this only when the extension is enabled or (when $Configuration['MY_EXTENSION_NAME_INSTALLED'] == 0 in Marks idea) seems to be more elegant for me. As you I don't think, that columns/tables should be removed, when disabling an extension. I doesn't hurt.
You really want this extra query on every single page-load, forever and ever amen? That's a huge waste of resources.
Is it eays to set the configuration option automatically or has it to be done by hand?
There is a configuration manager that allows you to do it pretty easily. I can document it easily enough, too.
And I would like to have html allowed in the description to link to a postback action.
For now I'm still a bit confused:
When is the ['MY_EXTENSION_NAME_INSTALLED'] in the configuration first set for new extensions? Or should we just check it this way?
if (!in_array('MY_EXTENSION_NAME_INSTALLED', $Configuration)) { //Installation //Set 'MY_EXTENSION_NAME_INSTALLED' via configuration manager } else { //extension }
When your idea works in the new version, I'll remove the installation support hack from the Met a Extension. ithcy is right: if its not a standard it is confusing.
oops... misread thread title
Plus i'm a dirty sex deprived teenager.
I'm developing an "easy" way to plug Settings Panels into... well... the Settings page.
I'm quite there, the next *must* step is something like the Meta Extension.
I'm building every component in my extension (FeedReader), where possible and with time constraint, as a class.
So I've got a class to fetch the feed (Snoopy, not mine), a class to cache it (RSSCache, not mine), a class to parse it (XMLPlainParser for PHP4/5, mine) and I was doing the class above (VanillaEasySettingsPanel, mine).
So, I was now doing searches to allow virtually any extension to add some configuration data to Vanilla. I noticed that a table like that doesn't exists, so I found this extension.
The problem is: this is an extension. It's an usability problem if anyone that wanted to use my extension should also use this Meta one. I'd like to *port* this one (or make something similar) in order to have a class, simple, to be included in my estension (and in any extension).
I think that the 'burden' of a few kbytes for each extension is payed back from the removal of an "extensions requirement".
What do you think about it?
The original developer for this class is still on it?
interesting thoughts.
I'm not working on this extension anymore, cause as not being a standard it makes things more complicated as itchy points out.
Please read the comments by Mark (developer of vanilla) carefully.
Especially the way of setting the ExtensionName_INSTALLED variable to the configuration file.
So I think the best thing is to put the class (or a ported version) in your extension and handle the installation stuff by your own (as in the PredefinedAttributes example code above).
Hope this works for you.
I'll work on it asap... I'll post some news here when I've got something working.