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 05-11-2010, 11:49 AM
reefland reefland is offline
 
Join Date: Jan 2002
Posts: 68
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Calendar Event INSERT

I am working on a bit of a modification/addition for my site and I am in need of some help. I am building a script that will be cronned and will insert events into the calendar every day. I have the script built and the insert query working however for some reason the even does not show in the calendar. I can access the event via the url for the eventid and it works fine, and I can edit the event and it will then show in the calendar. So I am missing something that needs to happen in addition to the INSERT into the event table.

To complicate matters, I can't find where the existing functions are for the event creation in the files. I am looked through calendar.php, class_dm_event and functions_calendar and can't find a single insert there anywhere.

Code:
$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')
        ");
Again, this inserts the event into the database just fine, but the event will not show on the calendar until it is edited via the UI. Thoughts?

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

Entering a row directly to the database does the same thing. So it must be some cache function I am missing or something.
Reply With Quote
  #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
  #3  
Old 05-16-2010, 03:56 PM
reefland reefland is offline
 
Join Date: Jan 2002
Posts: 68
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Still looking for help with this...
Reply With Quote
  #4  
Old 05-20-2010, 12:00 AM
reefland reefland is offline
 
Join Date: Jan 2002
Posts: 68
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

^^ Still looking.
Reply With Quote
  #5  
Old 05-26-2010, 10:59 PM
reefland reefland is offline
 
Join Date: Jan 2002
Posts: 68
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Most of the times, it's the stupid things. The date from has to be midnight gmt.
Reply With Quote
  #6  
Old 12-12-2010, 02:13 AM
Wood 20th* Wood 20th* is offline
 
Join Date: Mar 2010
Location: Canada
Posts: 29
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

So Reefland

how's the progress on this? Is it showing up now?
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 02:42 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.04019 seconds
  • Memory Usage 2,242KB
  • 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
  • (1)bbcode_code
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (6)post_thanks_box
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (6)post_thanks_postbit_info
  • (6)postbit
  • (6)postbit_onlinestatus
  • (6)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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete