Log in

View Full Version : PLS Help: How to add Scheduled Task to run Update User Titles and Ranks script when:


Quarterbore
02-14-2006, 01:25 AM
I have subscriptions in my forums for people that donate to the website. The subscriptions work fine but I have noticed that after the subscription ends the member is pulled from the "contributor group" but they still have a contributor title in their member name.

This is sure to cause confusion as their PM, Attachments, and PhotoPost limits are higher as a contributor, plus they have access to some "Members Only" forums.

So, what I need is a way to run a "Scheduled Task" to ping the "Update User Titles and Ranks" script that we have in the "Update Counters" area of the Admin CP.

Can someone advise how I might be able to add a task to do this and I assume there would be no problems with having the server do this at least once a day...

Thanks!

p.s. I did try VB.com but they said to try here:

http://www.vbulletin.com/forum/showthread.php?p=1073338#post1073338

Now, until someone suggest how to do this I am going to disect the code here:

In /admincp I see the file /usertitle.php which has a section:



// ###################### Start do update #######################
if ($_POST['do'] == 'doupdate')
{

$vbulletin->input->clean_array_gpc('p', array(
'title' => TYPE_STR,
'minposts' => TYPE_UINT
));

if (empty($vbulletin->GPC['title']))
{
print_stop_message('invalid_user_title_specified') ;
}

$db->query_write("
UPDATE " . TABLE_PREFIX . "usertitle
SET title = '" . $db->escape_string($vbulletin->GPC['title']) . "',
minposts = " . $vbulletin->GPC['minposts'] . "
WHERE usertitleid = " . $vbulletin->GPC['usertitleid'] . "
");

define('CP_REDIRECT', 'usertitle.php?do=modify');
print_stop_message('saved_user_title_x_successfull y', $vbulletin->GPC['title']);


In Misc.php I find a few bits of code that must be related to this:


// ###################### Start user choices #######################
if ($_REQUEST['do'] == 'chooser')
{
print_form_header('misc', 'updateuser');
print_table_header($vbphrase['update_user_titles'], 2, 0);
print_input_row($vbphrase['number_of_users_to_process_per_cycle'], 'perpage', 1000);
print_submit_row($vbphrase['update_user_titles']);


Now, the server delivered HTML code for this MISC script that does the Update of User titles looks like this (copied from a right click of admin CP)


<script type="text/javascript">
<!--
var SESSIONHASH = "";
function set_cp_title()
{
if (typeof(parent.document) != 'undefined' && typeof(parent.document) != 'unknown' && typeof(parent.document.title) == 'string')
{
parent.document.title = (document.title != '' ? document.title : 'vBulletin');
}
}
//-->
</script>
<script type="text/javascript" src="../clientscript/vbulletin_global.js"></script>

</head>
<body style="margin:0px" onload="set_cp_title();">
<div class="pagetitle">Maintenance</div>
<div style="margin:10px">
<!-- END CONTROL PANEL HEADER -->


<!-- form started:6 queries executed -->
<form action="misc.php" name="cpform" method="post">
<input type="hidden" name="do" value="updateuser" />
<br />
<table cellpadding="4" cellspacing="0" border="0" align="center" width="90%" class="tborder">
<tr>
<td class="tcat" align="center" colspan="2">
<div style="float:right"><a class="helplink" href="#" onclick="js_open_help('misc', 'chooser', ''); return false;">Help <img src="../cpstyles/vBulletin_3_Default/cp_help.gif" alt="" border="0" title="Click for help on these options" style="vertical-align:middle" /></a></div>
<b>Update User Titles and Ranks</b>
</td>
</tr>
<tr valign="top">
<td class="alt1">Number of users to process per cycle</td>
<td class="alt1"><table cellpadding="0" cellspacing="0" border="0" width="100%"><tr valign="top"><td><input type="text" class="bginput" name="perpage" id="it_perpage" value="1000" size="35" dir="ltr" tabindex="1" /></td><td align="right" style="padding-left:4px"><a class="helplink" href="#" onclick="js_open_help('misc', 'chooser', 'perpage'); return false;"><img src="../cpstyles/vBulletin_3_Default/cp_help.gif" alt="" border="0" title="Click for help on this option" /></a> </td></tr></table></td>
</tr>
<tr>
<td class="tfoot" colspan="2" align="center"> <input type="submit" class="button" tabindex="1" value="Update User Titles and Ranks" accesskey="s" />
<input type="reset" class="button" tabindex="1" value=" Reset " accesskey="r" />
</td>
</tr>
</table>
</form>
<!-- form ended: 6 queries executed -->


Note, I don't know java but it looks to be like this code is working with the java to do the work... if so, I guess I will never figure this out without some Java help!

Quarterbore
02-22-2006, 07:34 PM
I still need some help with programing this sceduled task....

Even if it was some help coming up with a small php file that acts like the original request so that when the CRON gets done it pings the PHP script that causes the work to be done....

I am sure others could use this as well....

Marco van Herwaarden
02-22-2006, 07:55 PM
just copy one of the existing scripts in the includes/cron directory, and work from there.

Quarterbore
02-22-2006, 08:27 PM
Yea, I am trying... I am prety sure I know what I need to do I just can't figure out the code to do it yet.... I assume I need to get the value "updateuser" to the "admincp/misc.php" script. I believe I need to do this with the variable "cpform"... (this from the code above)

I know it is the right section of code as I put the form in my main index.php file and it pinged the script and ran the user update as I need... The problem is it works in the forum but I need it out of the form.

I will grow grey trying to figure this out with my PHP books and random pinging away with code... but one day I will figure it out (I think) ... :ermm:

I think this tidbit of info might be along the line of what I need...

http://www.alt-php-faq.org/local/55/#id55

Then there is this:

http://www.phpbuilder.com/board/showthread.php?t=10317131