Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 3.0 > vBulletin 3.0 Beta Releases

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
  #2  
Old 07-11-2004, 07:52 PM
Colin F's Avatar
Colin F Colin F is offline
 
Join Date: Jul 2004
Location: Switzerland
Posts: 1,551
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Tips and Tricks

What's with the ugly US date format in the title?
If you want to change the date format in the title, just change the variable dateformat.
The european format is: d.m.Y (with leading zeros on day and month)
or j.n.Y (without leading zeros on day and month).
All the recognized characters in the date format can be found under http://www.php.net/date

It's all english! Where can I translate it? ORHow can I change the post text?
The whole posttext is saved in the postmessage variable. It can be translated, changed to your liking. New lines are achieved simply by having a new line in the code, no <br /> or \n\r. Also, smileys,bbcode,img tag as well as HTML can be used if you have these options enabled for the forum specified in forumid

I want all these event threads to have a special icon
Easy. Just edit the variable iconid to the iconid of the icon you wish to use.

Can I use the Event poster as the user that posts the thread?
Sure. Just change the 2 lines
PHP Code:
$botuserid 1//userid of poster 
$botusername "EventBot"// username of poster 
to
PHP Code:
$botuserid $bbuserinfo[userid]; //userid of poster 
$botusername $bbuserid[username]; // username of poster 
Careful: these posts don't update the users post count.

Questions and Problems

The postcount of my bot/the user that is used to post threads hasn't changed!
It isn't supposed to. As the whole system is automated, I don't think they count as posts. Also, no one is interested in the postcount of a bot
Reply With Quote
  #3  
Old 07-12-2004, 12:25 AM
FleaBag's Avatar
FleaBag FleaBag is offline
 
Join Date: Dec 2001
Posts: 1,674
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Just what I've been looking for - but is there a way to make the thread creator the user who adds the event to the calendar?
Reply With Quote
  #4  
Old 07-12-2004, 12:44 AM
nexialys
Guest
 
Posts: n/a
Default

yeah i was to suggest this.. i don't know why you use a BOT... just put the author's ID would do better... i don't see why using a bot anyway, it's not an automated feature, the creation of the thread is asked by a user...
Reply With Quote
  #5  
Old 07-12-2004, 12:52 AM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by FleaBag
Just what I've been looking for - but is there a way to make the thread creator the user who adds the event to the calendar?
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
Reply With Quote
  #6  
Old 07-12-2004, 12:56 AM
teksigns's Avatar
teksigns teksigns is offline
 
Join Date: Sep 2003
Posts: 133
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

getting error

Database error in vBulletin 3.0.0:

Invalid SQL: INSERT INTO thread
(title, lastpost, forumid, open, replycount, postusername, postuserid, lastposter, dateline, iconid, visible)
VALUES ('[] test event', 1089597260, 41, 1, 0, EventBot, 1364, EventBot, 1089597260, 0, 1)

mysql error: Unknown column 'EventBot' in 'field list'

mysql error number: 1054
Reply With Quote
  #7  
Old 07-12-2004, 01:08 AM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by teksigns
getting error
PHP Code:
$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)
"
); 
should be

PHP Code:
$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)
"
); 
And
PHP Code:
$dateformat "m-d-y"
should be before
PHP Code:
$threadtitle 
Reply With Quote
  #8  
Old 07-12-2004, 01:43 AM
alkatraz alkatraz is offline
 
Join Date: Oct 2002
Location: Vancouver, Canada
Posts: 384
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

awesome hack! thank you
Reply With Quote
  #9  
Old 07-12-2004, 09:34 AM
Colin F's Avatar
Colin F Colin F is offline
 
Join Date: Jul 2004
Location: Switzerland
Posts: 1,551
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

OK, looks like my small hack just got fully rewritten Thanks for the help KirbyDe!

I just did this the first way I saw how from looking at the code. I haven't tested it, but KirbyDe's Code would probably work just as well if anyone wants to use that.
Reply With Quote
  #10  
Old 07-12-2004, 09:47 AM
nexialys
Guest
 
Posts: n/a
Default

maybe a little setting in the admincp, calendar section, where we can disable the feature, and select what forum to use, and maybe more options, like groups that can post...

i'm suggesting, maybe i will do that later anyway.
Reply With Quote
Reply

Thread Tools

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 03:10 PM.


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.04668 seconds
  • Memory Usage 2,339KB
  • Queries Executed 23 (?)
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
  • (9)bbcode_php
  • (2)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
  • (2)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (9)postbit
  • (8)postbit_onlinestatus
  • (10)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