vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Update options outside of the settings menu? (https://vborg.vbsupport.ru/showthread.php?t=286006)

DetroitYES 07-27-2012 04:01 PM

Update options outside of the settings menu?
 
I found this thread:

https://vborg.vbsupport.ru/showthread.php?t=157223

Which lead me to develop this code in my admincp for the product:

PHP Code:

//...
$db->query_first("UPDATE " TABLE_PREFIX "setting SET " TABLE_PREFIX "setting.value = ".$_REQUEST['userid']." WHERE " TABLE_PREFIX "setting.varname = 'atdisg_featured_feed'");
print_cp_message('Featured user was updated successfully.''atdisg_admin.php?do=user_tracker');
//... 

This executes correctly, and if I go to the option under the settings menu, displays the updated value correctly. However, I also have this code that generates a diffrent button if the id of the user being displayed for the row matches the setting. It only works correctly when I update the option via the settings menu, not via the query. In other words, $vbulletin->options['atdisg_featured_feed'] does not seem to be pulling from the database...

PHP Code:


            
if ($row['userid'] == $vbulletin->options['atdisg_featured_feed']) {
                
$set_unset_featured "<input style='border:2px solid #FF0000; cursor:pointer;' type=\"button\" class=\"button\" onclick=\"window.location.href = 'atdisg_admin.php?do=set_featured_user&userid=".$row['userid']."';\" value=\"Stop Featuring\">";
            } else {
                
$set_unset_featured "<input style='border:2px solid #00AA00; cursor:pointer;' type=\"button\" class=\"button\" onclick=\"window.location.href = 'atdisg_admin.php?do=set_featured_user&userid=".$row['userid']."';\" value=\"Set As Feature\">";
            } 

I have to assume this is due to the datastore Paul mentioned in the related thread:

Quote:

Originally Posted by Paul M (Post 1334422)
They are stored as a serialized array in the datastore for general access, and ultimately, in the settings table.

Is there a way to update the datastore as well when I run the query?.. Or is there some reason that I should not update the options outside of settings?

--------------- Added [DATE]1343410605[/DATE] at [TIME]1343410605[/TIME] ---------------

#############UPDATE

i found the save_settings() function, on line ~430 of adminfunctions_options.php

PHP Code:

 /**
* Updates the setting table based on data passed in then rebuilds the datastore.
* Only entries in the array are updated (allows partial updates).
*@param    array    Array of settings. Format: [setting_name] = new_value
*/
function save_settings($settings)
{
//... 


Sarteck 07-28-2012 01:27 AM

Dude! Thanks for this! I've been using a "Daily Stuff" type of thing on my forum for a while now, and using the settings to save stuff like "Last Time Updated" so on and so forth, but I've always been doing it "manually." I never knew there was a built-in function, and sometimes some of my users get their "Daily Stuff" twice n a row.

I assume that was because of the datastore? I dunno, tbh, but I assume that using this function will change that if so. :3

DetroitYES 08-01-2012 04:00 PM

Quote:

Originally Posted by Sarteck (Post 2352027)
Dude! Thanks for this! I've been using a "Daily Stuff" type of thing on my forum for a while now, and using the settings to save stuff like "Last Time Updated" so on and so forth, but I've always been doing it "manually." I never knew there was a built-in function, and sometimes some of my users get their "Daily Stuff" twice n a row.

I assume that was because of the datastore? I dunno, tbh, but I assume that using this function will change that if so. :3

Glad to help, and yes, it was due to the datastore which save_settings() updates along with the actual database column...


All times are GMT. The time now is 11:55 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.00963 seconds
  • Memory Usage 1,733KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (3)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete