vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Calendar Event INSERT (https://vborg.vbsupport.ru/showthread.php?t=242274)

reefland 05-11-2010 11:49 AM

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.

reefland 05-12-2010 09:46 PM

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.

reefland 05-16-2010 03:56 PM

Still looking for help with this...

reefland 05-20-2010 12:00 AM

^^ Still looking.

reefland 05-26-2010 10:59 PM

Most of the times, it's the stupid things. The date from has to be midnight gmt.

Wood 20th* 12-12-2010 02:13 AM

So Reefland

how's the progress on this? Is it showing up now?


All times are GMT. The time now is 02:09 AM.

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.01753 seconds
  • Memory Usage 1,758KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete