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

Reply
 
Thread Tools Display Modes
  #1  
Old 03-15-2008, 04:07 PM
almannai almannai is offline
 
Join Date: Oct 2007
Posts: 889
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Need help with product coding

I'm creating a vb product and having this scenario which i don't know how to do it.

In the product there is two textbox options that the administrator can alter their values. The first box got a values like 3,4,7,...,100 and the second can take any integer number like 2.

A variable x in the product should start with the first number in the first textbox which is 3. The second textbox represent a time in hours where each time the system time elapsed that time the variable x will jump to the next value of the first textbox which is 4 in the example above and so on until it reaches 100 then it will get back to value 3.

regards,
Reply With Quote
  #2  
Old 03-15-2008, 05:53 PM
Opserty Opserty is offline
 
Join Date: Apr 2007
Posts: 4,103
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You need to create a scheduled task that runs once an hour then use some PHP along the lines of:
PHP Code:
// You need to create a setting field that holds the current value
// You don't really need this line I just added to make it easier to see what is going on below
$curval =& $vbulletin->options['settingcurval']; 

// Explode the comma seperated values into array
$settinglist explode(','$vbulletin->options['varsettingname']);  

$curkey array_search($curval$settinglist);

// Move the key along one
$curkey++;

// Set the new value
$curval $settinglist[$curkey];

// RUN A QUERY TO UPDATE SETTINGS TABLE 
// To update the $curval into the database. 

// Includes adminfunctions.php
require_once('/includes/adminfunctions.php');

// Update the datastore
build_options(); 
Something like that I think should work, there might be a better way to do it. But that is the way I would have done it anyway
Reply With Quote
  #3  
Old 03-16-2008, 07:53 AM
almannai almannai is offline
 
Join Date: Oct 2007
Posts: 889
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks Opserty for your reply but the problem I don't know how to
create a scheduled task for the plugin or product?

I tried to search the forum to see how but to many posts to find what i need.
Reply With Quote
  #4  
Old 03-16-2008, 08:45 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Admin CP > Scheduled Task > Add New Task?
Reply With Quote
  #5  
Old 03-16-2008, 10:13 AM
almannai almannai is offline
 
Join Date: Oct 2007
Posts: 889
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Dismounted View Post
Admin CP > Scheduled Task > Add New Task?
Thanks for the reply.

But I don't get it! this is ok for my forum but how to distribute the corn with the product files to be used by other vb forums.

Also what is the line in code to check if number of hours had elapsed in the corn php file

something like
if((timenow-lasttimesaved)>numberofhours){
lasttimesaved=timenow;
do something...
}

Thanks for your time
Reply With Quote
  #6  
Old 03-17-2008, 06:22 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Have you turned on debug mode, attached the task to your product, and export the product like that?
Reply With Quote
  #7  
Old 03-17-2008, 02:56 PM
almannai almannai is offline
 
Join Date: Oct 2007
Posts: 889
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ok I got this task working but how to read a variable like $curval in the product templates? It always returns null!
Reply With Quote
  #8  
Old 03-17-2008, 03:20 PM
Opserty Opserty is offline
 
Join Date: Apr 2007
Posts: 4,103
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP Code:
// RUN A QUERY TO UPDATE SETTINGS TABLE 
// To update the $curval into the database. 
Make sure you do that bit.

Then run build_options(). Then you should be able to read curval from $vbulletin->options array.

Bear in mind this is just a rough guide to the procedure to follow, it is by no means a work example. You will need to refine it appropriately.
Reply With Quote
  #9  
Old 03-17-2008, 04:29 PM
almannai almannai is offline
 
Join Date: Oct 2007
Posts: 889
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Opserty View Post
PHP Code:
// RUN A QUERY TO UPDATE SETTINGS TABLE 
// To update the $curval into the database. 
How to do it? I don't know what is the settings table and never done it before...
Reply With Quote
  #10  
Old 03-19-2008, 10:16 AM
almannai almannai is offline
 
Join Date: Oct 2007
Posts: 889
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Anybody has any clue on how to solve this issue? Hint , example...
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 08:41 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.03947 seconds
  • Memory Usage 2,257KB
  • Queries Executed 13 (?)
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
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete