Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 3.0 > vBulletin 3.0 Beta Releases
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
New Thread on Calendar Event Details »»
New Thread on Calendar Event
Version: 1.00, by Colin F Colin F is offline
Developer Last Online: Apr 2014 Show Printable Version Email this Page

Version: 3.0.3 Rating:
Released: 07-10-2004 Last Update: Never Installs: 19
Re-useable Code Translations Is in Beta Stage  
No support by the author.

New Thread on Calendar Event

What it does:
This rather small hack is easy: it starts a new thread in a specific forum for every Event that is posted in the calendar. On our forum it is used for discussion of partys (as it's a party calendar).

Is it complicated?
There is actually very little to change, but in that small part, there are a lot of variables to be edited which are forum specific. That might make it a bit hard for php newlings

Changes:
New files (0):
none

Changed files(1):
calendar.php

New database fields/tables(0):
none

New templates(0):
none

Changed templates(0):
none

New phrases(0):
none


Screenshots:
No visible changes

Instructions:
  • Backup all your forum files as well as your database
  • Copy the following code into your favorite PHP editing program (Dreamweaver, Wordpad, Notepad...) and edit it to fit your forums.
    PHP Code:
    $forumid 1// forumid in which to post
    $botuserid 1//userid of poster
    $botusername "EventBot"// username of poster

    $dateformat "m-d-y";
    $threadtitle "[".vbdate($dateformat$dateline_from,false,true,false,true)."] ".$title;
    $postmessage "This is an automatically generated thread for the event [b]".$title."[/b].
    More information on this event is available on [url="
    .$vboptions['bburl']."/calendar.php?".$session[sessionurl]."do=getinfo&e=".$eventid."&day=".vbdate("Y-n-j",TIMENOW,false,true,false,true)."&c=".$calendarid."]this page[/url].";
    $iconid 0;
                
    $DB_site->query("INSERT INTO " TABLE_PREFIX "thread
    (title, lastpost, forumid, open, replycount, postusername, postuserid, lastposter, dateline, iconid, visible)
    VALUES ('" 
    addslashes($threadtitle) . "', " TIMENOW ", $forumid, 1, 0, '$botusername', $botuserid, '$botusername', " TIMENOW ", $iconid, 1)
    "
    );
    $threadid $DB_site->insert_id();
                
    $DB_site->query("INSERT INTO " TABLE_PREFIX "post
    (threadid, parentid, title, username, userid, dateline, pagetext, allowsmilie, showsignature, ipaddress, iconid, visible)
    VALUES (
    $threadid, 0, '" addslashes($threadtitle) . "', '$botusername', $botuserid, " TIMENOW ", '" addslashes($postmessage) . "', 1, 0, 0, $iconid, 1)
    "
    );
    $firstpostid $DB_site->insert_id();

    $DB_site->query("UPDATE " TABLE_PREFIX "thread
    SET firstpostid = 
    $firstpostid
    WHERE threadid = 
    $threadid
    "
    );
                
    $DB_site->query("
    UPDATE " 
    TABLE_PREFIX "forum
    SET replycount = replycount +  1,
    threadcount = threadcount + 1,
    lastpost = " 
    TIMENOW ",
    lastposter = 
    $botusername,
    lastthread = '" 
    addslashes($threadtitle) . "',
    lastthreadid = 
    $threadid,
    lasticonid = 
    $iconid
    WHERE forumid = 
    $forumid
    "
    ); 
    The variables to be edited (marked green) are:
    • forumid is the forumid of the forum in which the Bot will be posting the threads to the calendar events
    • botuserid is the userid of the user that will be shown as the author of the thread. I suggest making a special user and naming him something like EventBot
    • botusername is the username of the user that will be shown as the author of the thread. Should be the username to the userid indicated in botuserid. Make sure the username is enclosed in quotation marks ("").
  • Open your calendar.php and look for
    PHP Code:
    if ($calendarinfo['neweventemail']) 
  • Above that add the code you just edited.

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #12  
Old 07-12-2004, 04:44 PM
MrNase MrNase is offline
 
Join Date: May 2003
Location: Germany
Posts: 670
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Could we make it so that we can select wether a new thread is started or not? Not every entry is worth a discussion
Reply With Quote
  #13  
Old 07-12-2004, 05:25 PM
Colin F's Avatar
Colin F Colin F is offline
 
Join Date: Jul 2004
Location: Switzerland
Posts: 1,551
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by MrNase
Could we make it so that we can select wether a new thread is started or not? Not every entry is worth a discussion
Sure. Just add a checkbox in the template with value=1, and put this at the beginning of the code
PHP Code:
if ($_POST[checkboxname] == 1) { 
and a } at the end of the code.
Reply With Quote
  #14  
Old 07-13-2004, 12:34 PM
MrNase MrNase is offline
 
Join Date: May 2003
Location: Germany
Posts: 670
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

That's cool. Thank you


I will use it
Reply With Quote
  #15  
Old 07-14-2004, 06:34 AM
snyx's Avatar
snyx snyx is offline
 
Join Date: Oct 2001
Location: Vancouver (whistler.2010)
Posts: 556
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by KirbyDE
Instead of $botuserid and $botusername use $bbuserinfo[userid] and $bbuserinfo[username].

And I wonder why this hack re-invents the wheel instead of just using build_new_post()?

PHP Code:
$forumid 1// forumid in which to post 

// Get forum info
$foruminfo fetch_foruminfo($forumidfalse);

// Prepare the thread ...
$post[title] = "[".date($dateformat$dateline_from)."] ".$title
$post[poststarttime] = TIMENOW;
$post[posthash] = md5($post[poststarttime] . $bbuserinfo['userid'] . $bbuserinfo['salt']);
$post[message] = "This is an automatically generated thread for the event [b]".$title."[/b].
More information on this event is available on [url="
.$vboptions['bburl']."/calendar.php?".$session[sessionurl]."do=getinfo&e=".$eventid."&day=".date("Y-n-j")."&c=".$calendarid."]this page[/url]."
$post[username] = $bbuserinfo[userid];
$post[iconid] = 0;
$post[emailupdate] = 9999;

// ... and create it
require_once('./includes/functions_newpost.php');
build_new_post('thread'$foruminfo, array(), 0$post$errors); 
If you want to be fully flexible, one could make the text as a phrase, forum ID and date format string as a setting
I don't like this automated message within the thread, is it possible it mimic the calendar post into the new thread?
Reply With Quote
  #16  
Old 07-14-2004, 02:19 PM
Colin F's Avatar
Colin F Colin F is offline
 
Join Date: Jul 2004
Location: Switzerland
Posts: 1,551
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Theoretically yes.

Try making $post[message] = $message;
Reply With Quote
  #17  
Old 07-14-2004, 06:58 PM
DaveLogic DaveLogic is offline
 
Join Date: Jun 2003
Location: London
Posts: 51
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Colin F
Theoretically yes.

Try making $post[message] = $message;
This works with the main message content but would it be possible to say include a link (alike the original ) say Click here for full info which would rthen link back to the calendat???
Reply With Quote
  #18  
Old 07-14-2004, 08:05 PM
Colin F's Avatar
Colin F Colin F is offline
 
Join Date: Jul 2004
Location: Switzerland
Posts: 1,551
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Do you want the message content as well as a link back, or just part of the message content and a link saying something like [...more]?

The first could be done with something like
PHP Code:
$post[message] = $message."
[url="
.$vboptions['bburl']."/calendar.php?".$session[sessionurl]."do=getinfo&e=".$eventid."&day=".date("Y-n-j")."&c=".$calendarid."]Click here for full info[/url]"
Reply With Quote
  #19  
Old 07-16-2004, 04:52 AM
FleaBag's Avatar
FleaBag FleaBag is offline
 
Join Date: Dec 2001
Posts: 1,674
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Code:
Invalid SQL:  
UPDATE forum 
SET replycount = replycount +  1, 
threadcount = threadcount + 1, 
lastpost = 1089956923, 
lastposter = EventBot, 
lastthread = '[07-12-04] hkhkhk', 
lastthreadid = 12529, 
lasticonid = 0 
WHERE forumid = 47 

mysql error: Unknown column 'EventBot' in 'field list'
Any idea what went wrong?
Reply With Quote
  #20  
Old 07-24-2004, 07:46 AM
Colin F's Avatar
Colin F Colin F is offline
 
Join Date: Jul 2004
Location: Switzerland
Posts: 1,551
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

surround EventBot with 's
making it:
PHP Code:
$DB_site->query("
UPDATE " 
TABLE_PREFIX "forum
SET replycount = replycount +  1,
threadcount = threadcount + 1,
lastpost = " 
TIMENOW ",
lastposter = '
$botusername',
lastthread = '" 
addslashes($threadtitle) . "',
lastthreadid = 
$threadid,
lasticonid = 
$iconid
WHERE forumid = 
$forumid
"
); 
Reply With Quote
  #21  
Old 07-28-2004, 02:35 PM
obsidian's Avatar
obsidian obsidian is offline
 
Join Date: Apr 2003
Location: Austin Tx
Posts: 52
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I tried this out using Colins original hack and it comes up with a thread title that is one day off of the event. The "posted by" on the thread view is also blank. I ended up trying Kirby's code as well and the username shows up but the date is 1 day off as well.

Edit: After digging through the calendar.php file I assume this is because I am using a single all day event. If I do the ranged event it comes up correctly. I guess when it gets the single all day event it starts the previous day plus how ever many hours. Anyways anyone have an idea on a simple fix for it
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 10:02 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05008 seconds
  • Memory Usage 2,356KB
  • Queries Executed 25 (?)
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)bbcode_code
  • (6)bbcode_php
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)pagenav_pagelink
  • (11)post_thanks_box
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)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