The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
![]()
I'm working on a project for the admin CP that requires permission from the site owner / super admin so I don't want to put the settings in settings > options. I thought of creating a new table but as I researched how the various vB options are stored for use I see they are serialized and put in the datastore table. Somewhere this table is queried and the options unserialized to be available as $vbulletin->options. I want to do something similar and store my project settings this way as $vbulletin->my_project
If I go this route I see no reason to build a new table for my settings. Is there any reason I should have my settings in a new table if they're in datastore? But most importantly, where is the datastore table queried and how do I unserialize my project settings (i.e., what hook location)? |
#2
|
|||
|
|||
![]()
Function build_datastore() in includes/functions.php has a function build_datastore(). It has a parameter to automatically unserialize the data when it's read. You can arrange for your datastore item to be read back in (and unserialized) by adding it to $new_datastore_fetch[] at hook init_startup. If you want it only to be read in the admincp, you can check for VB_AREA == 'AdminCP'.
Just for the record, the settings are kept in the 'setting' table and automatically built in to the settings datastore item when they are edited. So I think another option might be to add your settings to the setting table but put a value for grouptitle that doesn't exist in the settinggroup table, then I think they won't be displayed. (But now that I think about it more, I'm not sure what the advantage of that would be.) |
#3
|
|||
|
|||
![]()
I had gotten as far as build_datastore() but couldn't find where was queried. Your idea almost did it but you have to do it like this:
Code:
$datastore_fetch[] = "'my_project'"; Code:
336 ($hook = vBulletinHook::fetch_hook('init_startup')) ? eval($hook) : false; 337 338 if (!empty($datastore_fetch)) 339 { 340 // Remove the single quotes that $datastore_fetch required 341 foreach ($datastore_fetch AS $value) 342 { 343 $new_datastore_fetch[] = substr($value, 1, -1); 344 } 345 } Another idea I was tinkering with was to gather all the settings into an array in the code block to which the form submits , then serialize the array and write it to a file my_project/settings.txt. My project has its own my_project/global.php that is required by the other files, and in there it would read the file and unserialized the data into a settings array for all the other files. Either approach would work but I think I'll go with using datastore just to be more like vBulletin coding. Thanks for the help. |
#4
|
|||
|
|||
![]() Quote:
That might be. You can actually set $new_datastore_fetch[] directly and not use the extra quotes if you'd rather. Looks like they decided to leave $datastore_fetch[] the same so as not to break old mods. |
#5
|
|||
|
|||
![]() Quote:
Anyway, I have it working more or less. Thanks again. |
#6
|
|||
|
|||
![]()
You know, someone else said the same thing once, even after I tested it myself and it seemed to work. I guess there must be something I don't understand about it.
|
#7
|
|||
|
|||
![]()
You're right, that does work. I must have had another problem at the time. But I think I'll stick with the nested quoting anyway in case older versions need that. I'm hoping this will work in vB3. Some time when I don't have a dozen windows open I might follow through and see how all that works
|
#8
|
|||
|
|||
![]()
Good point, i hadn't thought of that. I checked vb3.8.7 and it has $new_datastore_fetch, but vb3.8.3 doesn't.
|
![]() |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|