Version: 1.00, by Colin F
Developer Last Online: Apr 2014
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;
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.
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($forumid, false);
// 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?
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???
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]";
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