View Single Post
  #2  
Old 05-12-2010, 09:46 PM
reefland reefland is offline
 
Join Date: Jan 2002
Posts: 68
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If anyone is interested in helping out, here is the code I am using. This is to be cronned as a scheduled task.

PHP Code:
<?php

// ######################## SET PHP ENVIRONMENT ###########################
//error_reporting(E_ALL & ~E_NOTICE);
if (!is_object($vbulletin->db))
{
    exit;
}

// ########################################################################
// ######################### START MAIN SCRIPT ############################
// ########################################################################

require_once(DIR '/includes/functions_newpost.php');
require_once(
DIR '/includes/functions_wysiwyg.php');
require_once(
DIR '/includes/functions_calendar.php');

$now time();
$month date('m'$now);
$day date('d'$now);
$year date('Y'$now);
$date mktime(000$month$day$year);
$day1 $date 604800;
$day2 $day1 86400;
$day3 $day2 86400;
$day4 $day3 86400;
$day5 $day4 86400;
$day6 $day5 86400;
$day7 $day6 86400;
$calendarinfo[calendarid] = 5;
echo 
"<html><head><title>test</title></head><body>Today is: $date and One Week from Today is: $day1 Calendarid is $calendarinfo[calendarid]</body></html>";

$day1post1title "7am - OPEN";
$day1post2title "10am - OPEN";
$day1post3title "1pm - OPEN";
$day1post4title "4pm - OPEN";
$day1post5title "7pm - OPEN";
$day1post6title "10pm - OPEN";

$vbulletin->db->query_write("
    INSERT INTO " 
TABLE_PREFIX ."event (eventid, userid, event, title, allowsmilies, recurring, recuroption, calendarid, customfields, visible, dateline, utc, dst, dateline_from, dateline_to)
        VALUES ('', '1', 'Open', '" 
$day1post1title "', '1', '0', '', '5', NULL, '1', '" $day1 "', '0.00', '0', '" $day1 "', '0')
    "
); 

global 
$vbulletin$vbphrase$_CALENDAROPTIONS;

    if (!
$vbulletin->options['showevents'])
    {
        return 
false;
    }

    
$storeevents = array();

    
// Store timestamp 48 hours before the current time and 48 hours after the showevent period
    
$beginday TIMENOW 172800;
    
$endday TIMENOW 86400 86400 $vbulletin->options['showevents'];
    
$storeevents['date'] = gmdate('n-j-Y' $endday);


        
$events $vbulletin->db->query_read_slave("
        SELECT eventid, userid, event.title, recurring, recuroption, dateline_from, dateline_to, event.calendarid, IF (dateline_to = 0, 1, 0) AS singleday, customfields,
            dateline_from AS dateline_from_user, dateline_to AS dateline_to_user, utc, dst
        FROM " 
TABLE_PREFIX "event AS event
        INNER JOIN " 
TABLE_PREFIX "calendar AS calendar USING (calendarid)
        WHERE ((dateline_to >= 
$beginday AND dateline_from < $endday) OR (dateline_to = 0 AND dateline_from >= $beginday AND dateline_from <= $endday ))
            AND visible = 1
            AND calendar.options & " 
intval($_CALENDAROPTIONS['showupcoming']) . "
        ORDER BY dateline_from
    "
);

    while (
$event $vbulletin->db->fetch_array($events))
    {
        
$event['title'] = htmlspecialchars_uni($event['title']);
        
$storeevents["$event[eventid]"] = $event;
    }

    
build_datastore('eventcache'serialize($storeevents), 1);

    return 
$storeevents;

?>
This successfully inserts the event, which can then be access via calendar.php?e=xxxx&c=5 but the event is not viewable on the calendar.
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01197 seconds
  • Memory Usage 1,824KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.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_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • 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
  • showpost_complete