Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 07-27-2012, 04:01 PM
DetroitYES's Avatar
DetroitYES DetroitYES is offline
 
Join Date: Mar 2009
Posts: 43
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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 View Post
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)
{
//... 
Reply With Quote
Благодарность от:
Sarteck
  #2  
Old 07-28-2012, 01:27 AM
Sarteck's Avatar
Sarteck Sarteck is offline
 
Join Date: Mar 2008
Posts: 304
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #3  
Old 08-01-2012, 04:00 PM
DetroitYES's Avatar
DetroitYES DetroitYES is offline
 
Join Date: Mar 2009
Posts: 43
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Sarteck View Post
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...
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 12:07 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03974 seconds
  • Memory Usage 2,196KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (3)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (3)post_thanks_box
  • (1)post_thanks_box_bit
  • (3)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (3)post_thanks_postbit_info
  • (3)postbit
  • (3)postbit_onlinestatus
  • (3)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete